@tamagui/core 1.0.1-beta.219 → 1.0.1-beta.221
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/addTheme.js +7 -10
- package/dist/cjs/addTheme.js.map +3 -3
- package/dist/cjs/config.js +8 -4
- package/dist/cjs/config.js.map +2 -2
- package/dist/cjs/{hooks/useUnmountEffect.js → contexts/ButtonNestingContext.js} +7 -9
- package/dist/cjs/contexts/ButtonNestingContext.js.map +7 -0
- package/dist/cjs/createComponent.js +63 -67
- package/dist/cjs/createComponent.js.map +3 -3
- package/dist/cjs/createFont.js +11 -4
- package/dist/cjs/createFont.js.map +2 -2
- package/dist/cjs/createFont.test.js +125 -0
- package/dist/cjs/createFont.test.js.map +7 -0
- package/dist/cjs/createTamagui.js +13 -12
- package/dist/cjs/createTamagui.js.map +2 -2
- package/dist/cjs/createTokens.js.map +2 -2
- package/dist/cjs/createTokens.test.js +27 -0
- package/dist/cjs/createTokens.test.js.map +7 -0
- package/dist/cjs/createVariable.js +4 -9
- package/dist/cjs/createVariable.js.map +2 -2
- package/dist/cjs/createVariable.test.js +7 -0
- package/dist/cjs/createVariable.test.js.map +7 -0
- package/dist/cjs/createVariables.js +6 -7
- package/dist/cjs/createVariables.js.map +2 -2
- package/dist/cjs/helpers/ThemeManager.js +161 -147
- package/dist/cjs/helpers/ThemeManager.js.map +3 -3
- package/dist/cjs/helpers/ThemeManager.test.js +449 -0
- package/dist/cjs/helpers/ThemeManager.test.js.map +7 -0
- package/dist/cjs/helpers/{getTokens.js → ThemeManagerContext.js} +8 -8
- package/dist/cjs/helpers/ThemeManagerContext.js.map +7 -0
- package/dist/cjs/helpers/createPropMapper.js +4 -4
- package/dist/cjs/helpers/createPropMapper.js.map +2 -2
- package/dist/cjs/helpers/extendStaticConfig.js +2 -4
- package/dist/cjs/helpers/extendStaticConfig.js.map +2 -2
- package/dist/cjs/helpers/{assignNativePropsToWeb.native.js → getBoundingClientRect.js} +15 -8
- package/dist/cjs/helpers/getBoundingClientRect.js.map +7 -0
- package/dist/cjs/{hooks/useConstant.js → helpers/getRect.js} +14 -17
- package/dist/cjs/helpers/getRect.js.map +7 -0
- package/dist/cjs/helpers/getSplitStyles.js +82 -87
- package/dist/cjs/helpers/getSplitStyles.js.map +3 -3
- package/dist/cjs/helpers/getStylesAtomic.native.js.map +2 -2
- package/dist/cjs/helpers/getThemeCSSRules.js +6 -2
- package/dist/cjs/helpers/getThemeCSSRules.js.map +2 -2
- package/dist/cjs/helpers/insertStyleRule.js +1 -1
- package/dist/cjs/helpers/insertStyleRule.js.map +2 -2
- package/dist/cjs/helpers/mergeTransform.js +11 -8
- package/dist/cjs/helpers/mergeTransform.js.map +2 -2
- package/dist/cjs/helpers/pseudoDescriptors.js +1 -0
- package/dist/cjs/helpers/pseudoDescriptors.js.map +2 -2
- package/dist/cjs/helpers/themeable.js +9 -9
- package/dist/cjs/helpers/themeable.js.map +2 -2
- package/dist/cjs/hooks/useElementLayout.js +4 -12
- package/dist/cjs/hooks/useElementLayout.js.map +2 -2
- package/dist/cjs/hooks/useMedia.js +2 -1
- package/dist/cjs/hooks/useMedia.js.map +2 -2
- package/dist/cjs/hooks/useTheme.js +114 -156
- package/dist/cjs/hooks/useTheme.js.map +3 -3
- package/dist/cjs/hooks/{useIsMounted.js → useThemeName.js} +23 -14
- package/dist/cjs/hooks/useThemeName.js.map +7 -0
- package/dist/cjs/index.js +2 -5
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/setupReactNative.js +20 -7
- package/dist/cjs/setupReactNative.js.map +2 -2
- package/dist/cjs/styled.js +2 -19
- package/dist/cjs/styled.js.map +2 -2
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/updateTheme.js +9 -9
- package/dist/cjs/updateTheme.js.map +2 -2
- package/dist/cjs/views/TamaguiProvider.js +3 -3
- package/dist/cjs/views/TamaguiProvider.js.map +2 -2
- package/dist/cjs/views/Theme.js +39 -28
- package/dist/cjs/views/Theme.js.map +3 -3
- package/dist/cjs/views/ThemeInverse.js +4 -2
- package/dist/cjs/views/ThemeInverse.js.map +2 -2
- package/dist/cjs/views/ThemeProvider.js +8 -33
- package/dist/cjs/views/ThemeProvider.js.map +3 -3
- package/dist/esm/addTheme.js +7 -10
- package/dist/esm/addTheme.js.map +3 -3
- package/dist/esm/config.js +8 -3
- package/dist/esm/config.js.map +2 -2
- package/dist/esm/contexts/ButtonNestingContext.js +6 -0
- package/dist/esm/contexts/ButtonNestingContext.js.map +7 -0
- package/dist/esm/createComponent.js +65 -70
- package/dist/esm/createComponent.js.map +3 -3
- package/dist/esm/createFont.js +11 -4
- package/dist/esm/createFont.js.map +2 -2
- package/dist/esm/createFont.test.js +124 -0
- package/dist/esm/createFont.test.js.map +7 -0
- package/dist/esm/createTamagui.js +13 -12
- package/dist/esm/createTamagui.js.map +2 -2
- package/dist/esm/createTokens.js.map +2 -2
- package/dist/esm/createTokens.test.js +26 -0
- package/dist/esm/createTokens.test.js.map +7 -0
- package/dist/esm/createVariable.js +4 -9
- package/dist/esm/createVariable.js.map +2 -2
- package/dist/esm/createVariable.test.js +6 -0
- package/dist/esm/createVariable.test.js.map +7 -0
- package/dist/esm/createVariables.js +6 -7
- package/dist/esm/createVariables.js.map +2 -2
- package/dist/esm/helpers/ThemeManager.js +140 -144
- package/dist/esm/helpers/ThemeManager.js.map +3 -3
- package/dist/esm/helpers/ThemeManager.test.js +448 -0
- package/dist/esm/helpers/ThemeManager.test.js.map +7 -0
- package/dist/esm/helpers/ThemeManagerContext.js +6 -0
- package/dist/esm/helpers/ThemeManagerContext.js.map +7 -0
- package/dist/esm/helpers/createPropMapper.js +4 -4
- package/dist/esm/helpers/createPropMapper.js.map +2 -2
- package/dist/esm/helpers/extendStaticConfig.js +2 -4
- package/dist/esm/helpers/extendStaticConfig.js.map +2 -2
- package/dist/esm/helpers/getBoundingClientRect.js +13 -0
- package/dist/esm/helpers/getBoundingClientRect.js.map +7 -0
- package/dist/esm/helpers/getRect.js +12 -0
- package/dist/esm/helpers/getRect.js.map +7 -0
- package/dist/esm/helpers/getSplitStyles.js +90 -89
- package/dist/esm/helpers/getSplitStyles.js.map +3 -3
- package/dist/esm/helpers/getStylesAtomic.native.js.map +2 -2
- package/dist/esm/helpers/getThemeCSSRules.js +6 -2
- package/dist/esm/helpers/getThemeCSSRules.js.map +2 -2
- package/dist/esm/helpers/insertStyleRule.js +1 -1
- package/dist/esm/helpers/insertStyleRule.js.map +2 -2
- package/dist/esm/helpers/mergeTransform.js +8 -6
- package/dist/esm/helpers/mergeTransform.js.map +2 -2
- package/dist/esm/helpers/pseudoDescriptors.js +1 -0
- package/dist/esm/helpers/pseudoDescriptors.js.map +2 -2
- package/dist/esm/helpers/themeable.js +9 -9
- package/dist/esm/helpers/themeable.js.map +2 -2
- package/dist/esm/hooks/useElementLayout.js +2 -9
- package/dist/esm/hooks/useElementLayout.js.map +2 -2
- package/dist/esm/hooks/useMedia.js +3 -2
- package/dist/esm/hooks/useMedia.js.map +2 -2
- package/dist/esm/hooks/useTheme.js +114 -159
- package/dist/esm/hooks/useTheme.js.map +3 -3
- package/dist/esm/hooks/useThemeName.js +25 -0
- package/dist/esm/hooks/useThemeName.js.map +7 -0
- package/dist/esm/index.js +3 -5
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/setupReactNative.js +18 -6
- package/dist/esm/setupReactNative.js.map +2 -2
- package/dist/esm/styled.js +3 -20
- package/dist/esm/styled.js.map +2 -2
- package/dist/esm/updateTheme.js +9 -9
- package/dist/esm/updateTheme.js.map +2 -2
- package/dist/esm/views/TamaguiProvider.js +4 -4
- package/dist/esm/views/TamaguiProvider.js.map +2 -2
- package/dist/esm/views/Theme.js +40 -29
- package/dist/esm/views/Theme.js.map +3 -3
- package/dist/esm/views/ThemeInverse.js +4 -2
- package/dist/esm/views/ThemeInverse.js.map +2 -2
- package/dist/esm/views/ThemeProvider.js +8 -27
- package/dist/esm/views/ThemeProvider.js.map +2 -2
- package/package.json +13 -13
- package/src/__snapshots__/createTokens.test.ts.snap +877 -0
- package/src/addTheme.ts +9 -12
- package/src/config.ts +10 -2
- package/src/contexts/ButtonNestingContext.tsx +3 -0
- package/src/createComponent.tsx +117 -108
- package/src/createFont.test.ts +129 -0
- package/src/createFont.ts +12 -5
- package/src/createTamagui.ts +16 -14
- package/src/createTokens.test.ts +29 -0
- package/src/createTokens.ts +1 -1
- package/src/createVariable.test.ts +7 -0
- package/src/createVariable.ts +4 -10
- package/src/createVariables.ts +7 -7
- package/src/helpers/ThemeManager.test.tsx +480 -0
- package/src/helpers/ThemeManager.tsx +171 -166
- package/src/helpers/ThemeManagerContext.tsx +5 -0
- package/src/helpers/createPropMapper.ts +4 -4
- package/src/helpers/extendStaticConfig.ts +4 -4
- package/src/helpers/getBoundingClientRect.tsx +7 -0
- package/src/helpers/getRect.tsx +8 -0
- package/src/helpers/getSplitStyles.tsx +98 -94
- package/src/helpers/getStylesAtomic.native.ts +1 -0
- package/src/helpers/getThemeCSSRules.ts +9 -2
- package/src/helpers/insertStyleRule.tsx +2 -2
- package/src/helpers/mergeTransform.ts +13 -6
- package/src/helpers/pseudoDescriptors.ts +1 -0
- package/src/helpers/themeable.tsx +17 -9
- package/src/hooks/useElementLayout.tsx +3 -8
- package/src/hooks/useMedia.tsx +3 -3
- package/src/hooks/useTheme.tsx +138 -211
- package/src/hooks/useThemeName.tsx +25 -0
- package/src/index.ts +3 -4
- package/src/setupReactNative.ts +16 -5
- package/src/styled.tsx +4 -23
- package/src/types.tsx +42 -17
- package/src/updateTheme.ts +12 -9
- package/src/views/TamaguiProvider.tsx +5 -5
- package/src/views/Theme.tsx +48 -39
- package/src/views/ThemeProvider.tsx +11 -33
- package/types/Tamagui.d.ts +1 -1
- package/types/addTheme.d.ts +23 -2
- package/types/config.d.ts +0 -1
- package/types/contexts/ButtonNestingContext.d.ts +3 -0
- package/types/createFont.test.d.ts +2 -0
- package/types/createTokens.test.d.ts +2 -0
- package/types/createVariable.d.ts +2 -2
- package/types/createVariable.test.d.ts +2 -0
- package/types/helpers/ThemeManager.d.ts +20 -30
- package/types/helpers/ThemeManager.test.d.ts +2 -0
- package/types/helpers/ThemeManagerContext.d.ts +4 -0
- package/types/helpers/getBoundingClientRect.d.ts +2 -0
- package/types/helpers/getRect.d.ts +9 -0
- package/types/helpers/insertStyleRule.d.ts +1 -1
- package/types/helpers/mergeTransform.d.ts +5 -3
- package/types/helpers/themeable.d.ts +3 -0
- package/types/hooks/useElementLayout.d.ts +0 -8
- package/types/hooks/useTheme.d.ts +10 -20
- package/types/hooks/useThemeName.d.ts +5 -0
- package/types/index.d.ts +3 -4
- package/types/setupReactNative.d.ts +4 -2
- package/types/types.d.ts +35 -10
- package/types/updateTheme.d.ts +23 -2
- package/types/views/Theme.d.ts +3 -4
- package/dist/cjs/constants/platform.js +0 -74
- package/dist/cjs/constants/platform.js.map +0 -7
- package/dist/cjs/constants/platform.native.js +0 -62
- package/dist/cjs/constants/platform.native.js.map +0 -7
- package/dist/cjs/helpers/assignNativePropsToWeb.js +0 -188
- package/dist/cjs/helpers/assignNativePropsToWeb.js.map +0 -7
- package/dist/cjs/helpers/assignNativePropsToWeb.native.js.map +0 -7
- package/dist/cjs/helpers/calc.js +0 -71
- package/dist/cjs/helpers/calc.js.map +0 -7
- package/dist/cjs/helpers/getFont.js +0 -66
- package/dist/cjs/helpers/getFont.js.map +0 -7
- package/dist/cjs/helpers/getStackSize.js +0 -46
- package/dist/cjs/helpers/getStackSize.js.map +0 -7
- package/dist/cjs/helpers/getTokens.js.map +0 -7
- package/dist/cjs/helpers/startTransition.js +0 -36
- package/dist/cjs/helpers/startTransition.js.map +0 -7
- package/dist/cjs/helpers/validate.js +0 -2
- package/dist/cjs/helpers/validate.js.map +0 -7
- package/dist/cjs/hooks/useConstant.js.map +0 -7
- package/dist/cjs/hooks/useIsMounted.js.map +0 -7
- package/dist/cjs/hooks/usePressable.js +0 -36
- package/dist/cjs/hooks/usePressable.js.map +0 -7
- package/dist/cjs/hooks/useUnmountEffect.js.map +0 -7
- package/dist/cjs/injectStyles.js +0 -40
- package/dist/cjs/injectStyles.js.map +0 -7
- package/dist/cjs/react-native.js +0 -22
- package/dist/cjs/react-native.js.map +0 -7
- package/dist/esm/constants/platform.js +0 -39
- package/dist/esm/constants/platform.js.map +0 -7
- package/dist/esm/constants/platform.native.js +0 -28
- package/dist/esm/constants/platform.native.js.map +0 -7
- package/dist/esm/helpers/assignNativePropsToWeb.js +0 -164
- package/dist/esm/helpers/assignNativePropsToWeb.js.map +0 -7
- package/dist/esm/helpers/assignNativePropsToWeb.native.js +0 -6
- package/dist/esm/helpers/assignNativePropsToWeb.native.js.map +0 -7
- package/dist/esm/helpers/calc.js +0 -47
- package/dist/esm/helpers/calc.js.map +0 -7
- package/dist/esm/helpers/getFont.js +0 -42
- package/dist/esm/helpers/getFont.js.map +0 -7
- package/dist/esm/helpers/getStackSize.js +0 -22
- package/dist/esm/helpers/getStackSize.js.map +0 -7
- package/dist/esm/helpers/getTokens.js +0 -6
- package/dist/esm/helpers/getTokens.js.map +0 -7
- package/dist/esm/helpers/startTransition.js +0 -6
- package/dist/esm/helpers/startTransition.js.map +0 -7
- package/dist/esm/helpers/validate.js +0 -1
- package/dist/esm/helpers/validate.js.map +0 -7
- package/dist/esm/hooks/useConstant.js +0 -15
- package/dist/esm/hooks/useConstant.js.map +0 -7
- package/dist/esm/hooks/useIsMounted.js +0 -16
- package/dist/esm/hooks/useIsMounted.js.map +0 -7
- package/dist/esm/hooks/usePressable.js +0 -12
- package/dist/esm/hooks/usePressable.js.map +0 -7
- package/dist/esm/hooks/useUnmountEffect.js +0 -8
- package/dist/esm/hooks/useUnmountEffect.js.map +0 -7
- package/dist/esm/injectStyles.js +0 -16
- package/dist/esm/injectStyles.js.map +0 -7
- package/dist/esm/react-native.js +0 -3
- package/dist/esm/react-native.js.map +0 -7
- package/src/contexts/ButtonInsideButtonContext.tsx +0 -3
- package/src/contexts/ThemeContext.tsx +0 -5
- package/src/helpers/areEqualSets.tsx +0 -9
- package/src/views/ThemeInverse.tsx +0 -40
- package/src/views/ThemeReset.tsx +0 -43
- package/types/constants/platform.d.ts +0 -13
- package/types/constants/platform.native.d.ts +0 -13
- package/types/contexts/ButtonInsideButtonContext.d.ts +0 -3
- package/types/contexts/ThemeContext.d.ts +0 -7
- package/types/helpers/areEqualSets.d.ts +0 -2
- package/types/helpers/assignNativePropsToWeb.d.ts +0 -2
- package/types/helpers/assignNativePropsToWeb.native.d.ts +0 -2
- package/types/helpers/calc.d.ts +0 -1
- package/types/helpers/getFont.d.ts +0 -3
- package/types/helpers/getStackSize.d.ts +0 -8
- package/types/helpers/getTokens.d.ts +0 -2
- package/types/helpers/startTransition.d.ts +0 -3
- package/types/helpers/validate.d.ts +0 -1
- package/types/hooks/useConstant.d.ts +0 -2
- package/types/hooks/useIsMounted.d.ts +0 -3
- package/types/hooks/useMedia.test.d.ts +0 -1
- package/types/hooks/usePressable.d.ts +0 -3
- package/types/hooks/usePressablePressResponder.d.ts +0 -84
- package/types/hooks/useUnmountEffect.d.ts +0 -2
- package/types/injectStyles.d.ts +0 -7
- package/types/react-native.d.ts +0 -8
- package/types/views/AbsoluteFill.d.ts +0 -5
- package/types/views/AbsoluteFill.native.d.ts +0 -3
- package/types/views/ThemeInverse.d.ts +0 -9
- package/types/views/ThemeReset.d.ts +0 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/createTamagui.ts"],
|
|
4
|
-
"sourcesContent": ["import { isRSC, isWeb } from '@tamagui/constants'\n\nimport { configListeners, setConfig } from './config'\nimport { createVariables } from './createVariables'\nimport { getThemeCSSRules } from './helpers/getThemeCSSRules'\nimport { getAllRules } from './helpers/insertStyleRule'\nimport {\n registerCSSVariable,\n tokensValueToVariable,\n variableToCSS,\n} from './helpers/registerCSSVariable'\nimport { ensureThemeVariable, proxyThemeToParents } from './helpers/themes'\nimport { configureMedia } from './hooks/useMedia'\nimport { parseFont, registerFontVariables } from './insertFont'\nimport { Tamagui } from './Tamagui'\nimport { CreateTamaguiProps, InferTamaguiConfig, TamaguiInternalConfig, ThemeParsed } from './types'\n\n// config is re-run by the @tamagui/static, dont double validate\nconst createdConfigs = new WeakMap<any, boolean>()\n\nexport function createTamagui<Conf extends CreateTamaguiProps>(\n configIn: Conf\n): InferTamaguiConfig<Conf> {\n if (createdConfigs.has(configIn)) {\n return configIn as any\n }\n\n if (process.env.NODE_ENV === 'development') {\n if (!configIn.tokens) {\n throw new Error(`Must define tokens`)\n }\n if (!configIn.themes) {\n throw new Error(`Must define themes`)\n }\n if (!configIn.fonts) {\n throw new Error(`Must define fonts`)\n }\n }\n\n const fontTokens = Object.fromEntries(\n Object.entries(configIn.fonts!).map(([k, v]) => {\n return [k, createVariables(v, 'f', true)]\n })\n )\n\n const fontsParsed = (() => {\n const res = {} as typeof fontTokens\n for (const familyName in fontTokens) {\n res[`$${familyName}`] = parseFont(fontTokens[familyName])\n }\n return res!\n })()\n\n const themeConfig = (() => {\n const themes = { ...configIn.themes }\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
4
|
+
"sourcesContent": ["import { isClient, isRSC, isWeb } from '@tamagui/constants'\n\nimport { configListeners, setConfig } from './config'\nimport { createVariables } from './createVariables'\nimport { getThemeCSSRules } from './helpers/getThemeCSSRules'\nimport { getAllRules } from './helpers/insertStyleRule'\nimport {\n registerCSSVariable,\n tokensValueToVariable,\n variableToCSS,\n} from './helpers/registerCSSVariable'\nimport { ensureThemeVariable, proxyThemeToParents } from './helpers/themes'\nimport { configureMedia } from './hooks/useMedia'\nimport { parseFont, registerFontVariables } from './insertFont'\nimport { Tamagui } from './Tamagui'\nimport { CreateTamaguiProps, InferTamaguiConfig, TamaguiInternalConfig, ThemeParsed } from './types'\n\n// config is re-run by the @tamagui/static, dont double validate\nconst createdConfigs = new WeakMap<any, boolean>()\n\nexport function createTamagui<Conf extends CreateTamaguiProps>(\n configIn: Conf\n): InferTamaguiConfig<Conf> {\n if (createdConfigs.has(configIn)) {\n return configIn as any\n }\n\n if (process.env.NODE_ENV === 'development') {\n if (!configIn.tokens) {\n throw new Error(`Must define tokens`)\n }\n if (!configIn.themes) {\n throw new Error(`Must define themes`)\n }\n if (!configIn.fonts) {\n throw new Error(`Must define fonts`)\n }\n }\n\n const fontTokens = Object.fromEntries(\n Object.entries(configIn.fonts!).map(([k, v]) => {\n return [k, createVariables(v, 'f', true)]\n })\n )\n\n const fontsParsed = (() => {\n const res = {} as typeof fontTokens\n for (const familyName in fontTokens) {\n res[`$${familyName}`] = parseFont(fontTokens[familyName])\n }\n return res!\n })()\n\n const themeConfig = (() => {\n const themes = { ...configIn.themes }\n const cssRuleSets: string[] = []\n\n if (isWeb) {\n const declarations: string[] = []\n const fontDeclarations: Record<\n string,\n { name: string; declarations: string[]; language?: string }\n > = {}\n\n for (const key in configIn.tokens) {\n for (const skey in configIn.tokens[key]) {\n const val = configIn.tokens[key][skey]\n registerCSSVariable(val)\n declarations.push(variableToCSS(val))\n }\n }\n\n for (const key in fontsParsed) {\n const fontParsed = fontsParsed[key]\n const [name, language] = key.includes('_') ? key.split('_') : [key]\n const fontVars = registerFontVariables(fontParsed)\n fontDeclarations[key] = { name: name.slice(1), declarations: fontVars, language }\n }\n\n const sep = process.env.NODE_ENV === 'development' ? configIn.cssStyleSeparator || ' ' : ''\n\n function declarationsToRuleSet(decs: string[], selector = '') {\n return `:root${selector} {${sep}${[...decs].join(`;${sep}`)}${sep}}`\n }\n\n // non-font\n cssRuleSets.push(declarationsToRuleSet(declarations))\n\n // fonts\n if (fontDeclarations) {\n for (const key in fontDeclarations) {\n const { name, declarations, language = 'default' } = fontDeclarations[key]\n const fontSelector = `.font_${name}`\n const langSelector = `:root .t_lang-${name}-${language} ${fontSelector}`\n const selectors =\n language === 'default' ? ` ${fontSelector}, ${langSelector}` : langSelector\n const specificRuleSet = declarationsToRuleSet(declarations, selectors)\n cssRuleSets.push(specificRuleSet)\n }\n }\n }\n\n // dedupe themes to avoid duplicate CSS generation\n type DedupedTheme = {\n names: string[]\n theme: ThemeParsed\n }\n const dedupedThemes: {\n [key: string]: DedupedTheme\n } = {}\n const existing = new WeakMap<ThemeParsed, DedupedTheme>()\n\n // first, de-dupe and parse them\n for (const themeName in themes) {\n const rawTheme = themes[themeName] as ThemeParsed\n\n // if existing, avoid\n if (existing.has(rawTheme)) {\n const e = existing.get(rawTheme)!\n themes[themeName] = e.theme\n e.names.push(themeName)\n continue\n }\n\n // ensure each theme object unique for dedupe\n const theme = { ...rawTheme }\n // parse into variables\n for (const key in theme) {\n // make sure properly names theme variables\n ensureThemeVariable(theme, key)\n }\n themes[themeName] = theme\n\n // set deduped\n dedupedThemes[themeName] = {\n names: [themeName],\n theme,\n }\n existing.set(rawTheme, dedupedThemes[themeName])\n }\n\n // then, generate CSS from de-duped\n let themeRuleSets: string[] = []\n\n if (isWeb || isRSC) {\n for (const themeName in dedupedThemes) {\n themeRuleSets = [\n ...themeRuleSets,\n ...getThemeCSSRules({\n config: configIn,\n themeName,\n ...dedupedThemes[themeName],\n }),\n ]\n }\n }\n\n // proxy upwards to get parent variables (themes are subset going down)\n for (const themeName in themes) {\n themes[themeName] = proxyThemeToParents(themeName, themes[themeName], themes)\n }\n\n tokensValueToVariable.clear()\n\n return {\n themes,\n cssRuleSets,\n themeRuleSets,\n }\n })()\n\n // faster $lookups\n const tokensParsed: any = Object.fromEntries(\n Object.entries(configIn.tokens).map(([k, v]) => [\n k,\n Object.fromEntries(Object.entries(v).map(([k, v]) => [`$${k}`, v])),\n ])\n )\n\n const shorthands = configIn.shorthands || {}\n\n const config: TamaguiInternalConfig = {\n fontLanguages: [],\n animations: {} as any,\n media: {},\n ...configIn,\n // vite made this into a function if it wasn't set\n shorthands: { ...shorthands },\n inverseShorthands: shorthands\n ? Object.fromEntries(Object.entries(shorthands).map(([k, v]) => [v, k]))\n : {},\n themes: themeConfig.themes as any,\n fontsParsed,\n themeConfig,\n tokensParsed,\n parsed: true,\n getCSS: (separator = '\\n') => {\n return `\n .is_Text .is_Text {display:inline-flex;}\n ._dsp_contents {display:contents;}\n ${themeConfig.cssRuleSets.join(separator)}\n ${themeConfig.themeRuleSets.join(separator)}\n ${getAllRules().join(separator)}`\n },\n // const tokens = [...getToken(tokens.size[0])]\n // .spacer-sm + ._dsp_contents._dsp-sm-hidden { margin-left: -var(--${}) }\n }\n\n configureMedia(config)\n setConfig(config)\n\n if (configListeners.size) {\n configListeners.forEach((cb) => cb(config))\n configListeners.clear()\n }\n\n createdConfigs.set(config, true)\n\n if (process.env.NODE_ENV === 'development') {\n if (process.env.DEBUG?.startsWith('tamagui')) {\n // eslint-disable-next-line no-console\n console.log('Tamagui config:', config)\n }\n if (!globalThis['Tamagui']) {\n globalThis['Tamagui'] = Tamagui\n }\n }\n\n return config as any\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": ["declarationsToRuleSet", "declarations", "k", "v"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/createTokens.ts"],
|
|
4
|
-
"sourcesContent": ["import { Variable } from './createVariable'\nimport { createVariables } from './createVariables'\nimport { CreateTokens } from './types'\n\n// tokens.color.dark.red ===> { var: `color-dark-red`, val: '' }\nexport function createTokens<T extends CreateTokens>(tokens: T): MakeTokens<T> {\n return createVariables(tokens
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,6BAAgC;AAIzB,SAAS,aAAqC,QAA0B;AAC7E,aAAO,wCAAgB,
|
|
4
|
+
"sourcesContent": ["import { Variable } from './createVariable'\nimport { createVariables } from './createVariables'\nimport { CreateTokens } from './types'\n\n// tokens.color.dark.red ===> { var: `color-dark-red`, val: '' }\nexport function createTokens<T extends CreateTokens>(tokens: T): MakeTokens<T> {\n return createVariables(tokens) as any\n}\n\n// verbose but gives us nice types...\ntype MakeTokens<T> = T extends {\n color: infer E\n space: infer F\n size: infer G\n radius: infer H\n zIndex: infer J\n}\n ? {\n color: {\n [Key in keyof E]: E[Key] extends Variable ? E[Key] : Variable<E[Key]>\n }\n space: {\n [Key in keyof F]: F[Key] extends Variable ? F[Key] : Variable<F[Key]>\n }\n size: {\n [Key in keyof G]: G[Key] extends Variable ? G[Key] : Variable<G[Key]>\n }\n radius: {\n [Key in keyof H]: H[Key] extends Variable ? H[Key] : Variable<H[Key]>\n }\n zIndex: {\n [Key in keyof J]: J[Key] extends Variable ? J[Key] : Variable<J[Key]>\n }\n }\n : never\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,6BAAgC;AAIzB,SAAS,aAAqC,QAA0B;AAC7E,aAAO,wCAAgB,MAAM;AAC/B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var import_config_default_node = require("@tamagui/config-default-node");
|
|
3
|
+
var import_vitest = require("vitest");
|
|
4
|
+
var import_createTokens = require("./createTokens");
|
|
5
|
+
(0, import_vitest.test)("snapshot", () => {
|
|
6
|
+
(0, import_vitest.expect)((0, import_createTokens.createTokens)((0, import_config_default_node.getDefaultTamaguiConfig)().tokens)).toMatchSnapshot();
|
|
7
|
+
});
|
|
8
|
+
(0, import_vitest.test)("color name no dot", () => {
|
|
9
|
+
(0, import_vitest.expect)(
|
|
10
|
+
(0, import_createTokens.createTokens)({
|
|
11
|
+
color: {
|
|
12
|
+
"yellow.10": "yellow"
|
|
13
|
+
}
|
|
14
|
+
})
|
|
15
|
+
).toMatchObject({
|
|
16
|
+
color: {
|
|
17
|
+
"yellow.10": {
|
|
18
|
+
isVar: true,
|
|
19
|
+
key: "yellow101a",
|
|
20
|
+
name: "color-1",
|
|
21
|
+
val: "yellow",
|
|
22
|
+
variable: ""
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=createTokens.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/createTokens.test.ts"],
|
|
4
|
+
"sourcesContent": ["import { getDefaultTamaguiConfig } from '@tamagui/config-default-node'\nimport { expect, test } from 'vitest'\n\nimport { createTokens } from './createTokens'\n\ntest('snapshot', () => {\n expect(createTokens(getDefaultTamaguiConfig().tokens)).toMatchSnapshot()\n})\n\ntest('color name no dot', () => {\n expect(\n // @ts-ignore partial\n createTokens({\n color: {\n 'yellow.10': 'yellow',\n },\n })\n ).toMatchObject({\n color: {\n 'yellow.10': {\n isVar: true,\n key: 'yellow101a',\n name: 'color-1',\n val: 'yellow',\n variable: '',\n },\n },\n })\n})\n"],
|
|
5
|
+
"mappings": ";AAAA,iCAAwC;AACxC,oBAA6B;AAE7B,0BAA6B;AAAA,IAE7B,oBAAK,YAAY,MAAM;AACrB,gCAAO,sCAAa,oDAAwB,EAAE,MAAM,CAAC,EAAE,gBAAgB;AACzE,CAAC;AAAA,IAED,oBAAK,qBAAqB,MAAM;AAC9B;AAAA,QAEE,kCAAa;AAAA,MACX,OAAO;AAAA,QACL,aAAa;AAAA,MACf;AAAA,IACF,CAAC;AAAA,EACH,EAAE,cAAc;AAAA,IACd,OAAO;AAAA,MACL,aAAa;AAAA,QACX,OAAO;AAAA,QACP,KAAK;AAAA,QACL,MAAM;AAAA,QACN,KAAK;AAAA,QACL,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,EACF,CAAC;AACH,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -31,11 +31,10 @@ module.exports = __toCommonJS(createVariable_exports);
|
|
|
31
31
|
var import_constants = require("@tamagui/constants");
|
|
32
32
|
var import_helpers = require("@tamagui/helpers");
|
|
33
33
|
var import_config = require("./config");
|
|
34
|
-
const IS_VAR = "
|
|
34
|
+
const IS_VAR = "isVar";
|
|
35
35
|
const createVariable = (props) => {
|
|
36
|
-
if (isVariable(props))
|
|
36
|
+
if (isVariable(props))
|
|
37
37
|
return props;
|
|
38
|
-
}
|
|
39
38
|
return {
|
|
40
39
|
[IS_VAR]: true,
|
|
41
40
|
...props,
|
|
@@ -43,14 +42,10 @@ const createVariable = (props) => {
|
|
|
43
42
|
};
|
|
44
43
|
};
|
|
45
44
|
function variableToString(vrble, getValue = false) {
|
|
46
|
-
if (!vrble)
|
|
47
|
-
return "";
|
|
48
45
|
if (isVariable(vrble)) {
|
|
49
|
-
|
|
50
|
-
return `${vrble.val}`;
|
|
51
|
-
return `${import_constants.isWeb ? vrble.variable : vrble.val}`;
|
|
46
|
+
return getValue ? `${vrble.val}` : `${import_constants.isWeb ? vrble.variable : vrble.val}`;
|
|
52
47
|
}
|
|
53
|
-
return `${vrble}`;
|
|
48
|
+
return `${vrble || ""}`;
|
|
54
49
|
}
|
|
55
50
|
function isVariable(v) {
|
|
56
51
|
return !!(v && v[IS_VAR]);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/createVariable.ts"],
|
|
4
|
-
"sourcesContent": ["import { isWeb } from '@tamagui/constants'\nimport { simpleHash } from '@tamagui/helpers'\n\nimport { getConfig } from './config'\n\n/**\n * Should rename this to Token\n * Moving to objects for React Server Components support\n */\n\nconst IS_VAR = '
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAsB;AACtB,qBAA2B;AAE3B,oBAA0B;AAO1B,MAAM,SAAS;AAcR,MAAM,iBAAiB,CAAkC,UAAyB;AACvF,MAAI,WAAW,KAAK
|
|
4
|
+
"sourcesContent": ["import { isWeb } from '@tamagui/constants'\nimport { simpleHash } from '@tamagui/helpers'\n\nimport { getConfig } from './config'\n\n/**\n * Should rename this to Token\n * Moving to objects for React Server Components support\n */\n\nconst IS_VAR = 'isVar'\n\ntype VariableIn<A = any> = {\n val: A\n name: string\n key: string\n isFloating?: boolean\n}\n\nexport type Variable<A = any> = VariableIn<A> & {\n [IS_VAR]?: true\n variable?: string\n}\n\nexport const createVariable = <A extends string | number = any>(props: VariableIn<A>) => {\n if (isVariable(props)) return props\n return {\n [IS_VAR]: true,\n ...props,\n variable: isWeb ? createCSSVariable(props.name) : '',\n }\n}\n\nexport function variableToString(vrble?: any, getValue = false) {\n if (isVariable(vrble)) {\n return getValue ? `${vrble.val}` : `${isWeb ? vrble.variable : vrble.val}`\n }\n return `${vrble || ''}`\n}\n\nexport function isVariable(v: Variable | any): v is Variable {\n return !!(v && v[IS_VAR])\n}\n\nexport function getVariable(nameOrVariable: Variable | string) {\n if (isVariable(nameOrVariable)) {\n return variableToString(nameOrVariable)\n }\n const tokens = getConfig().tokensParsed\n return variableToString(tokens[nameOrVariable] ?? nameOrVariable)\n}\n\nexport function getVariableValue(v: Variable | any) {\n if (isVariable(v)) return v.val\n return v\n}\n\nexport function getVariableName(v: Variable | any) {\n if (isVariable(v)) return v.name\n return v\n}\n\nexport function getVariableVariable(v: Variable | any) {\n if (isVariable(v)) return v.variable\n return v\n}\n\n// bugfix { space: { 0.5: 10 } } was generating var(--space-0.5) (invalid CSS):\nexport const createCSSVariable = (nameProp: string, includeVar = true) => {\n if (process.env.NODE_ENV === 'development') {\n if (!nameProp || typeof nameProp !== 'string') {\n throw new Error(`createCSSVariable expected string: ${nameProp}`)\n }\n }\n const name = simpleHash(nameProp, 60)\n return includeVar ? `var(--${name})` : name\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAsB;AACtB,qBAA2B;AAE3B,oBAA0B;AAO1B,MAAM,SAAS;AAcR,MAAM,iBAAiB,CAAkC,UAAyB;AACvF,MAAI,WAAW,KAAK;AAAG,WAAO;AAC9B,SAAO;AAAA,IACL,CAAC,SAAS;AAAA,IACV,GAAG;AAAA,IACH,UAAU,yBAAQ,kBAAkB,MAAM,IAAI,IAAI;AAAA,EACpD;AACF;AAEO,SAAS,iBAAiB,OAAa,WAAW,OAAO;AAC9D,MAAI,WAAW,KAAK,GAAG;AACrB,WAAO,WAAW,GAAG,MAAM,QAAQ,GAAG,yBAAQ,MAAM,WAAW,MAAM;AAAA,EACvE;AACA,SAAO,GAAG,SAAS;AACrB;AAEO,SAAS,WAAW,GAAkC;AAC3D,SAAO,CAAC,EAAE,KAAK,EAAE;AACnB;AAEO,SAAS,YAAY,gBAAmC;AAC7D,MAAI,WAAW,cAAc,GAAG;AAC9B,WAAO,iBAAiB,cAAc;AAAA,EACxC;AACA,QAAM,aAAS,yBAAU,EAAE;AAC3B,SAAO,iBAAiB,OAAO,mBAAmB,cAAc;AAClE;AAEO,SAAS,iBAAiB,GAAmB;AAClD,MAAI,WAAW,CAAC;AAAG,WAAO,EAAE;AAC5B,SAAO;AACT;AAEO,SAAS,gBAAgB,GAAmB;AACjD,MAAI,WAAW,CAAC;AAAG,WAAO,EAAE;AAC5B,SAAO;AACT;AAEO,SAAS,oBAAoB,GAAmB;AACrD,MAAI,WAAW,CAAC;AAAG,WAAO,EAAE;AAC5B,SAAO;AACT;AAGO,MAAM,oBAAoB,CAAC,UAAkB,aAAa,SAAS;AACxE,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,CAAC,YAAY,OAAO,aAAa,UAAU;AAC7C,YAAM,IAAI,MAAM,sCAAsC,UAAU;AAAA,IAClE;AAAA,EACF;AACA,QAAM,WAAO,2BAAW,UAAU,EAAE;AACpC,SAAO,aAAa,SAAS,UAAU;AACzC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var import_vitest = require("vitest");
|
|
3
|
+
var import_createVariable = require("./createVariable");
|
|
4
|
+
(0, import_vitest.test)("dots", () => {
|
|
5
|
+
(0, import_vitest.expect)((0, import_createVariable.createCSSVariable)("yellow.10")).toBe("var(--yellow101a)");
|
|
6
|
+
});
|
|
7
|
+
//# sourceMappingURL=createVariable.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/createVariable.test.ts"],
|
|
4
|
+
"sourcesContent": ["import { expect, test } from 'vitest'\n\nimport { createCSSVariable } from './createVariable'\n\ntest('dots', () => {\n expect(createCSSVariable('yellow.10')).toBe('var(--yellow101a)')\n})\n"],
|
|
5
|
+
"mappings": ";AAAA,oBAA6B;AAE7B,4BAAkC;AAAA,IAElC,oBAAK,QAAQ,MAAM;AACjB,gCAAO,yCAAkB,WAAW,CAAC,EAAE,KAAK,mBAAmB;AACjE,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -21,27 +21,26 @@ __export(createVariables_exports, {
|
|
|
21
21
|
createVariables: () => createVariables
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(createVariables_exports);
|
|
24
|
+
var import_helpers = require("@tamagui/helpers");
|
|
24
25
|
var import_createVariable = require("./createVariable");
|
|
25
26
|
const createVariables = (tokens, parentPath = "", isFont = false) => {
|
|
26
27
|
const res = {};
|
|
27
28
|
let i = 0;
|
|
28
29
|
for (const key in tokens) {
|
|
29
30
|
i++;
|
|
30
|
-
const variableName = isFont ? key.slice(0, 2) : i;
|
|
31
31
|
const val = tokens[key];
|
|
32
32
|
if ((0, import_createVariable.isVariable)(val)) {
|
|
33
33
|
res[key] = val;
|
|
34
34
|
continue;
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
36
|
+
const niceKey = (0, import_helpers.simpleHash)(key);
|
|
37
|
+
let name = isFont ? niceKey.slice(0, 2) : i;
|
|
38
|
+
name = parentPath ? `${parentPath}-${name}` : niceKey;
|
|
40
39
|
if (val && typeof val === "object") {
|
|
41
|
-
res[key] = createVariables(tokens[key],
|
|
40
|
+
res[key] = createVariables(tokens[key], name);
|
|
42
41
|
continue;
|
|
43
42
|
}
|
|
44
|
-
res[key] = (0, import_createVariable.isVariable)(val) ? val : (0, import_createVariable.createVariable)({ val, name, key });
|
|
43
|
+
res[key] = (0, import_createVariable.isVariable)(val) ? val : (0, import_createVariable.createVariable)({ val, name, key: niceKey });
|
|
45
44
|
}
|
|
46
45
|
return res;
|
|
47
46
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/createVariables.ts"],
|
|
4
|
-
"sourcesContent": ["import { Variable, createVariable, isVariable } from './createVariable'\n\ntype DeepTokenObject<Val extends string | number = any> = {\n [key: string]: Val | DeepTokenObject<Val>\n}\n\nexport type DeepVariableObject<A extends DeepTokenObject> = {\n [Key in keyof A]: A[Key] extends string | number\n ? Variable<A[Key]>\n : A[Key] extends DeepTokenObject\n ? DeepVariableObject<A[Key]>\n : never\n}\n\nexport const createVariables = <A extends DeepTokenObject>(\n tokens: A,\n parentPath = '',\n isFont = false\n): DeepVariableObject<A> => {\n const res: any = {}\n let i = 0\n for (const key in tokens) {\n i++\n const
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAAqD;AAc9C,MAAM,kBAAkB,CAC7B,QACA,aAAa,IACb,SAAS,UACiB;AAC1B,QAAM,MAAW,CAAC;AAClB,MAAI,IAAI;AACR,aAAW,OAAO,QAAQ;AACxB;AACA,UAAM,
|
|
4
|
+
"sourcesContent": ["import { simpleHash } from '@tamagui/helpers'\n\nimport { Variable, createVariable, isVariable } from './createVariable'\n\ntype DeepTokenObject<Val extends string | number = any> = {\n [key: string]: Val | DeepTokenObject<Val>\n}\n\nexport type DeepVariableObject<A extends DeepTokenObject> = {\n [Key in keyof A]: A[Key] extends string | number\n ? Variable<A[Key]>\n : A[Key] extends DeepTokenObject\n ? DeepVariableObject<A[Key]>\n : never\n}\n\nexport const createVariables = <A extends DeepTokenObject>(\n tokens: A,\n parentPath = '',\n isFont = false\n): DeepVariableObject<A> => {\n const res: any = {}\n let i = 0\n for (const key in tokens) {\n i++\n const val = tokens[key]\n if (isVariable(val)) {\n res[key] = val\n continue\n }\n const niceKey = simpleHash(key)\n let name = isFont ? niceKey.slice(0, 2) : i\n name = parentPath ? `${parentPath}-${name}` : niceKey\n if (val && typeof val === 'object') {\n // recurse\n res[key] = createVariables(tokens[key] as any, name)\n continue\n }\n res[key] = isVariable(val) ? val : createVariable({ val, name, key: niceKey })\n }\n return res\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA2B;AAE3B,4BAAqD;AAc9C,MAAM,kBAAkB,CAC7B,QACA,aAAa,IACb,SAAS,UACiB;AAC1B,QAAM,MAAW,CAAC;AAClB,MAAI,IAAI;AACR,aAAW,OAAO,QAAQ;AACxB;AACA,UAAM,MAAM,OAAO;AACnB,YAAI,kCAAW,GAAG,GAAG;AACnB,UAAI,OAAO;AACX;AAAA,IACF;AACA,UAAM,cAAU,2BAAW,GAAG;AAC9B,QAAI,OAAO,SAAS,QAAQ,MAAM,GAAG,CAAC,IAAI;AAC1C,WAAO,aAAa,GAAG,cAAc,SAAS;AAC9C,QAAI,OAAO,OAAO,QAAQ,UAAU;AAElC,UAAI,OAAO,gBAAgB,OAAO,MAAa,IAAI;AACnD;AAAA,IACF;AACA,QAAI,WAAO,kCAAW,GAAG,IAAI,UAAM,sCAAe,EAAE,KAAK,MAAM,KAAK,QAAQ,CAAC;AAAA,EAC/E;AACA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -16,191 +16,205 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var __accessCheck = (obj, member, msg) => {
|
|
20
|
+
if (!member.has(obj))
|
|
21
|
+
throw TypeError("Cannot " + msg);
|
|
22
|
+
};
|
|
23
|
+
var __privateGet = (obj, member, getter) => {
|
|
24
|
+
__accessCheck(obj, member, "read from private field");
|
|
25
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
26
|
+
};
|
|
27
|
+
var __privateAdd = (obj, member, value) => {
|
|
28
|
+
if (member.has(obj))
|
|
29
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
30
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
31
|
+
};
|
|
32
|
+
var __privateSet = (obj, member, value, setter) => {
|
|
33
|
+
__accessCheck(obj, member, "write to private field");
|
|
34
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
35
|
+
return value;
|
|
36
|
+
};
|
|
19
37
|
var ThemeManager_exports = {};
|
|
20
38
|
__export(ThemeManager_exports, {
|
|
21
39
|
ThemeManager: () => ThemeManager,
|
|
22
|
-
|
|
23
|
-
emptyManager: () => emptyManager
|
|
40
|
+
hasNoThemeUpdatingProps: () => hasNoThemeUpdatingProps
|
|
24
41
|
});
|
|
25
42
|
module.exports = __toCommonJS(ThemeManager_exports);
|
|
26
|
-
var import_react = require("react");
|
|
27
43
|
var import_config = require("../config");
|
|
28
|
-
var
|
|
44
|
+
var import_constants2 = require("../constants/constants");
|
|
29
45
|
var import_getThemeUnwrapped = require("../hooks/getThemeUnwrapped");
|
|
46
|
+
var _allKeys;
|
|
47
|
+
const emptyState = { name: "" };
|
|
48
|
+
function hasNoThemeUpdatingProps(props) {
|
|
49
|
+
return !props.name && !props.componentName && !props.inverse && !props.reset;
|
|
50
|
+
}
|
|
30
51
|
class ThemeManager {
|
|
31
|
-
constructor(
|
|
32
|
-
this.
|
|
33
|
-
this.className = className;
|
|
34
|
-
this.theme = theme;
|
|
35
|
-
this.parentManager = parentManager;
|
|
36
|
-
this.reset = reset;
|
|
37
|
-
this.keys = /* @__PURE__ */ new Map();
|
|
38
|
-
this.listeners = /* @__PURE__ */ new Map();
|
|
52
|
+
constructor(props = {}, parentManager) {
|
|
53
|
+
this.props = props;
|
|
39
54
|
this.themeListeners = /* @__PURE__ */ new Set();
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
55
|
+
this.parentManager = null;
|
|
56
|
+
this.state = emptyState;
|
|
57
|
+
__privateAdd(this, _allKeys, null);
|
|
58
|
+
if (parentManager === "root") {
|
|
59
|
+
this.updateState(props, false);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (!parentManager) {
|
|
63
|
+
throw new Error(`Must set up root first`);
|
|
64
|
+
}
|
|
65
|
+
if (hasNoThemeUpdatingProps(props)) {
|
|
66
|
+
return parentManager;
|
|
67
|
+
}
|
|
68
|
+
if (parentManager) {
|
|
69
|
+
this.parentManager = parentManager;
|
|
70
|
+
}
|
|
71
|
+
const updatedState = this.getStateIfChanged(props);
|
|
72
|
+
if (updatedState) {
|
|
73
|
+
this.state = updatedState;
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
return parentManager || this;
|
|
77
|
+
}
|
|
78
|
+
updateState(props = this.props || {}, notify = true) {
|
|
79
|
+
const shouldFlush = (() => {
|
|
80
|
+
if (props.forceTheme) {
|
|
81
|
+
this.state.theme = props.forceTheme;
|
|
82
|
+
this.state.name = props.name || "";
|
|
83
|
+
return true;
|
|
46
84
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
} else {
|
|
52
|
-
this.parentManager = parent;
|
|
53
|
-
break;
|
|
85
|
+
const nextState = this.getStateIfChanged(props);
|
|
86
|
+
if (nextState) {
|
|
87
|
+
this.state = nextState;
|
|
88
|
+
return true;
|
|
54
89
|
}
|
|
90
|
+
})();
|
|
91
|
+
if (shouldFlush) {
|
|
92
|
+
__privateSet(this, _allKeys, null);
|
|
93
|
+
notify && this.notify();
|
|
94
|
+
return this.state;
|
|
55
95
|
}
|
|
56
96
|
}
|
|
57
|
-
|
|
58
|
-
|
|
97
|
+
getStateIfChanged(props = this.props, state = this.state, parentManager = this.parentManager) {
|
|
98
|
+
const _ = getState(props, parentManager) || (process.env.TAMAGUI_TARGET === "native" ? parentManager == null ? void 0 : parentManager.state : void 0);
|
|
99
|
+
if (!_ || !_.theme || _.theme === state.theme) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
return _;
|
|
59
103
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return ((_a = this.parentManager) == null ? void 0 : _a.name) || null;
|
|
104
|
+
getState(props = this.props) {
|
|
105
|
+
return getState(props, this.parentManager);
|
|
63
106
|
}
|
|
64
|
-
get
|
|
65
|
-
|
|
107
|
+
get allKeys() {
|
|
108
|
+
var _a;
|
|
109
|
+
__privateGet(this, _allKeys) ?? __privateSet(this, _allKeys, /* @__PURE__ */ new Set([
|
|
110
|
+
...((_a = this.parentManager) == null ? void 0 : _a.allKeys) || [],
|
|
111
|
+
...Object.keys(this.state.theme || {})
|
|
112
|
+
]));
|
|
113
|
+
return __privateGet(this, _allKeys);
|
|
66
114
|
}
|
|
67
|
-
getValue(key) {
|
|
68
|
-
let theme = this.theme;
|
|
115
|
+
getValue(key, state) {
|
|
116
|
+
let theme = (state || this.state).theme;
|
|
69
117
|
let manager = this;
|
|
70
|
-
while (
|
|
71
|
-
if (!theme)
|
|
72
|
-
return;
|
|
118
|
+
while (theme && manager) {
|
|
73
119
|
if (key in theme) {
|
|
74
120
|
return theme[key];
|
|
75
121
|
}
|
|
76
|
-
manager =
|
|
77
|
-
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
theme = manager.theme;
|
|
122
|
+
manager = manager.parentManager;
|
|
123
|
+
theme = manager == null ? void 0 : manager.state.theme;
|
|
81
124
|
}
|
|
82
125
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return Boolean((_a = this.keys.get(uuid)) == null ? void 0 : _a.size);
|
|
126
|
+
notify() {
|
|
127
|
+
this.themeListeners.forEach((cb) => cb(this.state.name, this));
|
|
86
128
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
129
|
+
onChangeTheme(cb) {
|
|
130
|
+
this.themeListeners.add(cb);
|
|
131
|
+
return () => {
|
|
132
|
+
this.themeListeners.delete(cb);
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
_allKeys = new WeakMap();
|
|
137
|
+
function getNextThemeClassName(name, isInverting = false) {
|
|
138
|
+
const next = `${import_constants2.THEME_CLASSNAME_PREFIX}${name}`;
|
|
139
|
+
if (isInverting) {
|
|
140
|
+
return next;
|
|
141
|
+
}
|
|
142
|
+
return next.replace("light_", "").replace("dark_", "");
|
|
143
|
+
}
|
|
144
|
+
function getState(props, parentManager) {
|
|
145
|
+
var _a, _b, _c;
|
|
146
|
+
const themes = (0, import_config.getThemes)();
|
|
147
|
+
if (props.name && props.reset) {
|
|
148
|
+
throw new Error(`Cannot reset + set new name`);
|
|
149
|
+
}
|
|
150
|
+
if (props.reset && !(parentManager == null ? void 0 : parentManager.parentManager)) {
|
|
151
|
+
throw new Error(`Cannot reset no grandparent exists`);
|
|
152
|
+
}
|
|
153
|
+
const nextName = props.reset ? ((_b = (_a = parentManager == null ? void 0 : parentManager.parentManager) == null ? void 0 : _a.state) == null ? void 0 : _b.name) || "" : props.name || "";
|
|
154
|
+
const { componentName } = props;
|
|
155
|
+
const parentName = ((_c = parentManager == null ? void 0 : parentManager.state) == null ? void 0 : _c.name) || "";
|
|
156
|
+
const base = parentName.split(import_constants2.THEME_NAME_SEPARATOR);
|
|
157
|
+
const lastSegment = base[base.length - 1];
|
|
158
|
+
const isParentAComponentTheme = parentName && lastSegment[0].toUpperCase() === lastSegment[0];
|
|
159
|
+
if (isParentAComponentTheme) {
|
|
160
|
+
base.pop();
|
|
161
|
+
}
|
|
162
|
+
const parentBaseTheme = isParentAComponentTheme ? base.slice(0, base.length).join(import_constants2.THEME_NAME_SEPARATOR) : parentName;
|
|
163
|
+
const max = base.length;
|
|
164
|
+
const min = componentName ? max : 0;
|
|
165
|
+
if (process.env.NODE_ENV === "development" && props.debug === "verbose")
|
|
166
|
+
console.log("getState", props, { parentName, parentBaseTheme, base, min, max, isParentAComponentTheme, parentManager });
|
|
167
|
+
for (let i = max; i >= min; i--) {
|
|
168
|
+
let prefix = base.slice(0, i).join(import_constants2.THEME_NAME_SEPARATOR);
|
|
169
|
+
if (props.inverse) {
|
|
170
|
+
prefix = inverseThemeName(prefix);
|
|
93
171
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
if (notify) {
|
|
98
|
-
this.notify();
|
|
172
|
+
const potentials = [];
|
|
173
|
+
if (prefix && prefix !== parentBaseTheme) {
|
|
174
|
+
potentials.push(prefix);
|
|
99
175
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
getNextTheme(props = {}, debug) {
|
|
103
|
-
var _a;
|
|
104
|
-
const { themes = (0, import_config.getThemes)(), name, componentName } = props;
|
|
105
|
-
if (props.reset && name) {
|
|
106
|
-
return {
|
|
107
|
-
name,
|
|
108
|
-
theme: themes[name],
|
|
109
|
-
className: this.getCN(name)
|
|
110
|
-
};
|
|
176
|
+
if (nextName) {
|
|
177
|
+
potentials.unshift(prefix ? `${prefix}_${nextName}` : nextName);
|
|
111
178
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
if (
|
|
115
|
-
|
|
116
|
-
`${this.name}_${componentName}`,
|
|
117
|
-
`${withoutComponentName(this.name)}_${componentName}`
|
|
118
|
-
];
|
|
119
|
-
for (const name2 of names) {
|
|
120
|
-
if (name2 in themes) {
|
|
121
|
-
const className = this.getCN(name2);
|
|
122
|
-
return { name: name2, theme: themes[name2], className };
|
|
123
|
-
}
|
|
124
|
-
}
|
|
179
|
+
if (i === 1) {
|
|
180
|
+
const lastSegment2 = potentials.findIndex((x) => !x.includes("_"));
|
|
181
|
+
if (lastSegment2 > 0) {
|
|
182
|
+
potentials.splice(lastSegment2, 0, nextName);
|
|
125
183
|
}
|
|
126
|
-
return {
|
|
127
|
-
name: this.name,
|
|
128
|
-
theme: this.theme,
|
|
129
|
-
className: this.className
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
let nextName = name || this.name || "";
|
|
133
|
-
let parentName = parentIsReset ? this.parentName || this.fullName : this.fullName;
|
|
134
|
-
while (true) {
|
|
135
|
-
if (nextName in themes)
|
|
136
|
-
break;
|
|
137
|
-
nextName = `${parentName}_${name}`;
|
|
138
|
-
if (nextName in themes)
|
|
139
|
-
break;
|
|
140
|
-
if (!parentName.includes(import_constants.THEME_NAME_SEPARATOR))
|
|
141
|
-
break;
|
|
142
|
-
parentName = parentName.slice(0, parentName.lastIndexOf(import_constants.THEME_NAME_SEPARATOR));
|
|
143
184
|
}
|
|
144
185
|
if (componentName) {
|
|
145
|
-
|
|
146
|
-
`${nextName}_${componentName}
|
|
147
|
-
`${withoutComponentName(nextName)}_${componentName}`
|
|
148
|
-
];
|
|
149
|
-
for (const name2 of names) {
|
|
150
|
-
if (name2 in themes) {
|
|
151
|
-
nextName = name2;
|
|
152
|
-
}
|
|
186
|
+
if (nextName) {
|
|
187
|
+
potentials.push(`${prefix.replace(/_.*$/, "")}_${nextName}_${componentName}`);
|
|
153
188
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
theme = themes[`light_${nextName}`];
|
|
158
|
-
}
|
|
159
|
-
if (process.env.NODE_ENV === "development") {
|
|
160
|
-
if (debug) {
|
|
161
|
-
console.log("getNextTheme", this.getCN(nextName), { props, nextName, parentName });
|
|
189
|
+
potentials.push(`${prefix}_${componentName}`);
|
|
190
|
+
if (nextName) {
|
|
191
|
+
potentials.unshift(`${prefix}_${nextName}_${componentName}`);
|
|
162
192
|
}
|
|
163
193
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
getCN(name) {
|
|
171
|
-
return `${import_constants.THEME_CLASSNAME_PREFIX}${name} t_Theme`.replace("light_", "").replace("dark_", "");
|
|
172
|
-
}
|
|
173
|
-
track(uuid, keys) {
|
|
174
|
-
if (!this.name)
|
|
175
|
-
return;
|
|
176
|
-
this.keys.set(uuid, keys);
|
|
177
|
-
}
|
|
178
|
-
notify() {
|
|
179
|
-
var _a;
|
|
180
|
-
if (!this.name) {
|
|
181
|
-
this.keys.clear();
|
|
182
|
-
}
|
|
183
|
-
for (const [uuid, keys] of this.keys.entries()) {
|
|
184
|
-
if (keys.size) {
|
|
185
|
-
(_a = this.listeners.get(uuid)) == null ? void 0 : _a();
|
|
194
|
+
if (process.env.NODE_ENV === "development" && props.debug === "verbose")
|
|
195
|
+
console.log("getState potentials", potentials);
|
|
196
|
+
const found = potentials.find((t) => t in themes);
|
|
197
|
+
if (found) {
|
|
198
|
+
if (found === parentName) {
|
|
199
|
+
return null;
|
|
186
200
|
}
|
|
201
|
+
const theme = themes[found];
|
|
202
|
+
return {
|
|
203
|
+
name: found,
|
|
204
|
+
theme: (0, import_getThemeUnwrapped.getThemeUnwrapped)(theme),
|
|
205
|
+
className: getNextThemeClassName(found, props.inverse),
|
|
206
|
+
parentName
|
|
207
|
+
};
|
|
187
208
|
}
|
|
188
|
-
this.themeListeners.forEach((cb) => cb(this.name, this));
|
|
189
|
-
}
|
|
190
|
-
onChangeTheme(cb) {
|
|
191
|
-
this.themeListeners.add(cb);
|
|
192
|
-
return () => {
|
|
193
|
-
this.themeListeners.delete(cb);
|
|
194
|
-
};
|
|
195
209
|
}
|
|
210
|
+
return null;
|
|
196
211
|
}
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
|
|
212
|
+
const inverseThemeName = (themeName) => {
|
|
213
|
+
return themeName.startsWith("light") ? themeName.replace(/^light/, "dark") : themeName.replace(/^dark/, "light");
|
|
214
|
+
};
|
|
200
215
|
// Annotate the CommonJS export names for ESM import in node:
|
|
201
216
|
0 && (module.exports = {
|
|
202
217
|
ThemeManager,
|
|
203
|
-
|
|
204
|
-
emptyManager
|
|
218
|
+
hasNoThemeUpdatingProps
|
|
205
219
|
});
|
|
206
220
|
//# sourceMappingURL=ThemeManager.js.map
|