1 line
9.3 KiB
JSON
1 line
9.3 KiB
JSON
|
{"ast":null,"code":"import useMemo from \"rc-util/es/hooks/useMemo\";\nimport isEqual from \"rc-util/es/isEqual\";\nimport { devUseWarning } from '../../_util/warning';\nimport { defaultConfig } from '../../theme/internal';\nimport useThemeKey from './useThemeKey';\nexport default function useTheme(theme, parentTheme, config) {\n var _a, _b;\n const warning = devUseWarning('ConfigProvider');\n const themeConfig = theme || {};\n const parentThemeConfig = themeConfig.inherit === false || !parentTheme ? Object.assign(Object.assign({}, defaultConfig), {\n hashed: (_a = parentTheme === null || parentTheme === void 0 ? void 0 : parentTheme.hashed) !== null && _a !== void 0 ? _a : defaultConfig.hashed,\n cssVar: parentTheme === null || parentTheme === void 0 ? void 0 : parentTheme.cssVar\n }) : parentTheme;\n const themeKey = useThemeKey();\n if (process.env.NODE_ENV !== 'production') {\n const cssVarEnabled = themeConfig.cssVar || parentThemeConfig.cssVar;\n const validKey = !!(typeof themeConfig.cssVar === 'object' && ((_b = themeConfig.cssVar) === null || _b === void 0 ? void 0 : _b.key) || themeKey);\n process.env.NODE_ENV !== \"production\" ? warning(!cssVarEnabled || validKey, 'breaking', 'Missing key in `cssVar` config. Please upgrade to React 18 or set `cssVar.key` manually in each ConfigProvider inside `cssVar` enabled ConfigProvider.') : void 0;\n }\n return useMemo(() => {\n var _a, _b;\n if (!theme) {\n return parentTheme;\n }\n // Override\n const mergedComponents = Object.assign({}, parentThemeConfig.components);\n Object.keys(theme.components || {}).forEach(componentName => {\n mergedComponents[componentName] = Object.assign(Object.assign({}, mergedComponents[componentName]), theme.components[componentName]);\n });\n const cssVarKey = `css-var-${themeKey.replace(/:/g, '')}`;\n const mergedCssVar = ((_a = themeConfig.cssVar) !== null && _a !== void 0 ? _a : parentThemeConfig.cssVar) && Object.assign(Object.assign(Object.assign({\n prefix: config === null || config === void 0 ? void 0 : config.prefixCls\n }, typeof parentThemeConfig.cssVar === 'object' ? parentThemeConfig.cssVar : {}), typeof themeConfig.cssVar === 'object' ? themeConfig.cssVar : {}), {\n key: typeof themeConfig.cssVar === 'object' && ((_b = themeConfig.cssVar) === null || _b === void 0 ? void 0 : _b.key) || cssVarKey\n });\n // Base token\n return Object.assign(Object.assign(Object.assign({}, parentThemeConfig), themeConfig), {\n token: Object.assign(Object.assign({}, parentThemeConfig.token), themeConfig.token),\n components: mergedComponents,\n cssVar: mergedCssVar\n });\n }, [themeConfig, parentThemeConfig], (prev, next) => prev.some((prevTheme, index) => {\n const nextTheme = next[index];\n return !isEqual(prevTheme, nextTheme, true);\n }));\n}","map":{"version":3,"names":["useMemo","isEqual","devUseWarning","defaultConfig","useThemeKey","useTheme","theme","parentTheme","config","_a","_b","warning","themeConfig","parentThemeConfig","inherit","Object","assign","hashed","cssVar","themeKey","process","env","NODE_ENV","cssVarEnabled","validKey","key","mergedComponents","components","keys","forEach","componentName","cssVarKey","replace","mergedCssVar","prefix","prefixCls","token","prev","next","some","prevTheme","index","nextTheme"],"sources":["C:/Users/Аришина)/Desktop/promo/node_modules/antd/es/config-provider/hooks/useTheme.js"],"sourcesContent":["import useMemo from \"rc-util/es/hooks/useMemo\";\nimport isEqual from \"rc-util/es/isEqual\";\nimport { devUseWarning } from '../../_util/warning';\nimport { defaultConfig } from '../../theme/internal';\nimport useThemeKey from './useThemeKey';\nexport default function useTheme(theme, parentTheme, config) {\n var _a, _b;\n const warning = devUseWarning('ConfigProvider');\n const themeConfig = theme || {};\n const parentThemeConfig = themeConfig.inherit === false || !parentTheme ? Object.assign(Object.assign({}, defaultConfig), {\n hashed: (_a = parentTheme === null || parentTheme
|