mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-25 09:55:15 +00:00
1 line
31 KiB
JSON
1 line
31 KiB
JSON
|
{"ast":null,"code":"import PropTypes from 'prop-types'; // https://github.com/twbs/bootstrap/blob/v4.0.0-alpha.4/js/src/modal.js#L436-L443\n\nexport function getScrollbarWidth() {\n var scrollDiv = document.createElement('div'); // .modal-scrollbar-measure styles // https://github.com/twbs/bootstrap/blob/v4.0.0-alpha.4/scss/_modal.scss#L106-L113\n\n scrollDiv.style.position = 'absolute';\n scrollDiv.style.top = '-9999px';\n scrollDiv.style.width = '50px';\n scrollDiv.style.height = '50px';\n scrollDiv.style.overflow = 'scroll';\n document.body.appendChild(scrollDiv);\n var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;\n document.body.removeChild(scrollDiv);\n return scrollbarWidth;\n}\nexport function setScrollbarWidth(padding) {\n document.body.style.paddingRight = padding > 0 ? padding + \"px\" : null;\n}\nexport function isBodyOverflowing() {\n return document.body.clientWidth < window.innerWidth;\n}\nexport function getOriginalBodyPadding() {\n var style = window.getComputedStyle(document.body, null);\n return parseInt(style && style.getPropertyValue('padding-right') || 0, 10);\n}\nexport function conditionallyUpdateScrollbar() {\n var scrollbarWidth = getScrollbarWidth(); // https://github.com/twbs/bootstrap/blob/v4.0.0-alpha.6/js/src/modal.js#L433\n\n var fixedContent = document.querySelectorAll('.fixed-top, .fixed-bottom, .is-fixed, .sticky-top')[0];\n var bodyPadding = fixedContent ? parseInt(fixedContent.style.paddingRight || 0, 10) : 0;\n\n if (isBodyOverflowing()) {\n setScrollbarWidth(bodyPadding + scrollbarWidth);\n }\n}\nvar globalCssModule;\nexport function setGlobalCssModule(cssModule) {\n globalCssModule = cssModule;\n}\nexport function mapToCssModules(className, cssModule) {\n if (className === void 0) {\n className = '';\n }\n\n if (cssModule === void 0) {\n cssModule = globalCssModule;\n }\n\n if (!cssModule) return className;\n return className.split(' ').map(function (c) {\n return cssModule[c] || c;\n }).join(' ');\n}\n/**\n * Returns a new object with the key/value pairs from `obj` that are not in the array `omitKeys`.\n */\n\nexport function omit(obj, omitKeys) {\n var result = {};\n Object.keys(obj).forEach(function (key) {\n if (omitKeys.indexOf(key) === -1) {\n result[key] = obj[key];\n }\n });\n return result;\n}\n/**\n * Returns a filtered copy of an object with only the specified keys.\n */\n\nexport function pick(obj, keys) {\n var pickKeys = Array.isArray(keys) ? keys : [keys];\n var length = pickKeys.length;\n var key;\n var result = {};\n\n while (length > 0) {\n length -= 1;\n key = pickKeys[length];\n result[key] = obj[key];\n }\n\n return result;\n}\nvar warned = {};\nexport function warnOnce(message) {\n if (!warned[message]) {\n /* istanbul ignore else */\n if (typeof console !== 'undefined') {\n console.error(message); // eslint-disable-line no-console\n }\n\n warned[message] = true;\n }\n}\nexport function deprecated(propType, explanation) {\n return function validate(props, propName, componentName) {\n if (props[propName] !== null && typeof props[propName] !== 'undefined') {\n warnOnce(\"\\\"\" + propName + \"\\\" property of \\\"\" + componentName + \"\\\" has been deprecated.\\n\" + explanation);\n }\n\n for (var _len = arguments.length, rest = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {\n rest[_key - 3] = arguments[_key];\n }\n\n return propType.apply(void 0, [props, propName, componentName].concat(rest));\n };\n} // Shim Element if needed (e.g. in Node environment)\n\nvar Element = typeof window === 'object' && window.Element || function () {};\n\nexport function DOMElement(props, propName, componentName) {\n if (!(props[propName] instanceof Element)) {\n return new Error('Invalid prop `' + propName + '` supplied to `' + componentName + '`. Expected prop to be an instance of Element. Validation failed.');\n }\n}\nexport var targetPropType = PropTypes.oneOfType([PropTypes.string, PropTypes.func, DOMElement, PropTy
|