1 line
9.7 KiB
JSON
1 line
9.7 KiB
JSON
|
{"ast":null,"code":"import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\nvar _excluded = [\"children\"];\nimport useMemo from \"rc-util/es/hooks/useMemo\";\nimport isEqual from \"rc-util/es/isEqual\";\nimport * as React from 'react';\nimport CacheEntity from \"./Cache\";\nexport var ATTR_TOKEN = 'data-token-hash';\nexport var ATTR_MARK = 'data-css-hash';\nexport var ATTR_CACHE_PATH = 'data-cache-path';\n\n// Mark css-in-js instance in style element\nexport var CSS_IN_JS_INSTANCE = '__cssinjs_instance__';\nexport function createCache() {\n var cssinjsInstanceId = Math.random().toString(12).slice(2);\n\n // Tricky SSR: Move all inline style to the head.\n // PS: We do not recommend tricky mode.\n if (typeof document !== 'undefined' && document.head && document.body) {\n var styles = document.body.querySelectorAll(\"style[\".concat(ATTR_MARK, \"]\")) || [];\n var firstChild = document.head.firstChild;\n Array.from(styles).forEach(function (style) {\n style[CSS_IN_JS_INSTANCE] = style[CSS_IN_JS_INSTANCE] || cssinjsInstanceId;\n\n // Not force move if no head\n if (style[CSS_IN_JS_INSTANCE] === cssinjsInstanceId) {\n document.head.insertBefore(style, firstChild);\n }\n });\n\n // Deduplicate of moved styles\n var styleHash = {};\n Array.from(document.querySelectorAll(\"style[\".concat(ATTR_MARK, \"]\"))).forEach(function (style) {\n var hash = style.getAttribute(ATTR_MARK);\n if (styleHash[hash]) {\n if (style[CSS_IN_JS_INSTANCE] === cssinjsInstanceId) {\n var _style$parentNode;\n (_style$parentNode = style.parentNode) === null || _style$parentNode === void 0 || _style$parentNode.removeChild(style);\n }\n } else {\n styleHash[hash] = true;\n }\n });\n }\n return new CacheEntity(cssinjsInstanceId);\n}\nvar StyleContext = /*#__PURE__*/React.createContext({\n hashPriority: 'low',\n cache: createCache(),\n defaultCache: true\n});\nexport var StyleProvider = function StyleProvider(props) {\n var children = props.children,\n restProps = _objectWithoutProperties(props, _excluded);\n var parentContext = React.useContext(StyleContext);\n var context = useMemo(function () {\n var mergedContext = _objectSpread({}, parentContext);\n Object.keys(restProps).forEach(function (key) {\n var value = restProps[key];\n if (restProps[key] !== undefined) {\n mergedContext[key] = value;\n }\n });\n var cache = restProps.cache;\n mergedContext.cache = mergedContext.cache || createCache();\n mergedContext.defaultCache = !cache && parentContext.defaultCache;\n return mergedContext;\n }, [parentContext, restProps], function (prev, next) {\n return !isEqual(prev[0], next[0], true) || !isEqual(prev[1], next[1], true);\n });\n return /*#__PURE__*/React.createElement(StyleContext.Provider, {\n value: context\n }, children);\n};\nexport default StyleContext;","map":{"version":3,"names":["_objectSpread","_objectWithoutProperties","_excluded","useMemo","isEqual","React","CacheEntity","ATTR_TOKEN","ATTR_MARK","ATTR_CACHE_PATH","CSS_IN_JS_INSTANCE","createCache","cssinjsInstanceId","Math","random","toString","slice","document","head","body","styles","querySelectorAll","concat","firstChild","Array","from","forEach","style","insertBefore","styleHash","hash","getAttribute","_style$parentNode","parentNode","removeChild","StyleContext","createContext","hashPriority","cache","defaultCache","StyleProvider","props","children","restProps","parentContext","useContext","context","mergedContext","Object","keys","key","value","undefined","prev","next","createElement","Provider"],"sources":["C:/Users/Аришина)/source/repos/PromoCursed/node_modules/@ant-design/cssinjs/es/StyleContext.js"],"sourcesContent":["import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\nvar _exclud
|