@tamagui/web 1.88.13 → 1.88.15
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/LICENSE +21 -0
- package/dist/cjs/createComponent.js +2 -2
- package/dist/cjs/createComponent.js.map +1 -1
- package/dist/cjs/createComponent.native.js +1 -1
- package/dist/cjs/createComponent.native.js.map +1 -1
- package/dist/cjs/createTamagui.js.map +1 -1
- package/dist/cjs/createTamagui.native.js.map +1 -1
- package/dist/cjs/createVariables.js.map +1 -1
- package/dist/cjs/createVariables.native.js.map +1 -1
- package/dist/cjs/helpers/getSplitStyles.js +15 -19
- package/dist/cjs/helpers/getSplitStyles.js.map +1 -1
- package/dist/cjs/helpers/getSplitStyles.native.js +12 -18
- package/dist/cjs/helpers/getSplitStyles.native.js.map +1 -1
- package/dist/cjs/helpers/getStylesAtomic.js.map +1 -1
- package/dist/cjs/helpers/getThemeCSSRules.js.map +1 -1
- package/dist/cjs/helpers/insertStyleRule.js +3 -3
- package/dist/cjs/helpers/insertStyleRule.js.map +1 -1
- package/dist/cjs/helpers/insertStyleRule.native.js +3 -3
- package/dist/cjs/helpers/insertStyleRule.native.js.map +1 -1
- package/dist/cjs/helpers/propMapper.js.map +1 -1
- package/dist/cjs/helpers/propMapper.native.js.map +1 -1
- package/dist/cjs/helpers/registerCSSVariable.js.map +1 -1
- package/dist/cjs/helpers/registerCSSVariable.native.js.map +1 -1
- package/dist/cjs/hooks/getThemeProxied.js +66 -0
- package/dist/cjs/hooks/getThemeProxied.js.map +6 -0
- package/dist/cjs/hooks/getThemeProxied.native.js +100 -0
- package/dist/cjs/hooks/getThemeProxied.native.js.map +6 -0
- package/dist/cjs/hooks/useTheme.js.map +1 -1
- package/dist/cjs/hooks/useTheme.native.js.map +1 -1
- package/dist/cjs/insertFont.js.map +1 -1
- package/dist/cjs/insertFont.native.js.map +1 -1
- package/dist/cjs/setupHooks.js.map +1 -1
- package/dist/cjs/setupHooks.native.js.map +1 -1
- package/dist/cjs/views/FontLanguage.native.js.map +1 -1
- package/dist/cjs/views/Slot.js.map +1 -1
- package/dist/cjs/views/Slot.native.js.map +1 -1
- package/dist/cjs/views/TamaguiProvider.js +5 -5
- package/dist/cjs/views/TamaguiProvider.js.map +1 -1
- package/dist/cjs/views/TamaguiProvider.native.js +5 -5
- package/dist/cjs/views/TamaguiProvider.native.js.map +1 -1
- package/dist/cjs/views/Theme.js.map +1 -1
- package/dist/cjs/views/Theme.native.js.map +1 -1
- package/dist/esm/Tamagui.mjs +43 -0
- package/dist/esm/config.mjs +51 -0
- package/dist/esm/constants/accessibilityDirectMap.mjs +50 -0
- package/dist/esm/constants/constants.mjs +16 -0
- package/dist/esm/constants/isDevTools.mjs +7 -0
- package/dist/esm/contexts/ComponentContext.mjs +13 -0
- package/dist/esm/createComponent.js +2 -2
- package/dist/esm/createComponent.js.map +1 -1
- package/dist/esm/createComponent.mjs +771 -0
- package/dist/esm/createComponent.native.js +1 -1
- package/dist/esm/createComponent.native.js.map +1 -1
- package/dist/esm/createFont.mjs +18 -0
- package/dist/esm/createShorthands.mjs +4 -0
- package/dist/esm/createTamagui.js.map +1 -1
- package/dist/esm/createTamagui.mjs +206 -0
- package/dist/esm/createTamagui.native.js.map +1 -1
- package/dist/esm/createTheme.mjs +2 -0
- package/dist/esm/createTokens.mjs +5 -0
- package/dist/esm/createVariable.mjs +48 -0
- package/dist/esm/createVariables.js.map +1 -1
- package/dist/esm/createVariables.mjs +35 -0
- package/dist/esm/createVariables.native.js.map +1 -1
- package/dist/esm/defaultComponentState.mjs +16 -0
- package/dist/esm/helpers/ThemeManager.mjs +156 -0
- package/dist/esm/helpers/ThemeManagerContext.mjs +3 -0
- package/dist/esm/helpers/createMediaStyle.mjs +71 -0
- package/dist/esm/helpers/createShallowSetState.mjs +17 -0
- package/dist/esm/helpers/createStyledContext.mjs +35 -0
- package/dist/esm/helpers/defaultOffset.mjs +5 -0
- package/dist/esm/helpers/expandStyle.mjs +38 -0
- package/dist/esm/helpers/expandStyles.mjs +15 -0
- package/dist/esm/helpers/getExpandedShorthands.mjs +9 -0
- package/dist/esm/helpers/getFontLanguage.mjs +2 -0
- package/dist/esm/helpers/getGroupPropParts.mjs +13 -0
- package/dist/esm/helpers/getSplitStyles.js +15 -18
- package/dist/esm/helpers/getSplitStyles.js.map +1 -1
- package/dist/esm/helpers/getSplitStyles.mjs +638 -0
- package/dist/esm/helpers/getSplitStyles.native.js +12 -18
- package/dist/esm/helpers/getSplitStyles.native.js.map +1 -1
- package/dist/esm/helpers/getStylesAtomic.js +1 -4
- package/dist/esm/helpers/getStylesAtomic.js.map +1 -1
- package/dist/esm/helpers/getStylesAtomic.mjs +150 -0
- package/dist/esm/helpers/getThemeCSSRules.js.map +1 -1
- package/dist/esm/helpers/getThemeCSSRules.mjs +87 -0
- package/dist/esm/helpers/getVariantExtras.mjs +43 -0
- package/dist/esm/helpers/insertStyleRule.js +3 -3
- package/dist/esm/helpers/insertStyleRule.js.map +1 -1
- package/dist/esm/helpers/insertStyleRule.mjs +177 -0
- package/dist/esm/helpers/insertStyleRule.native.js +3 -3
- package/dist/esm/helpers/insertStyleRule.native.js.map +1 -1
- package/dist/esm/helpers/isObj.mjs +2 -0
- package/dist/esm/helpers/isTamaguiComponent.mjs +5 -0
- package/dist/esm/helpers/isTamaguiElement.mjs +4 -0
- package/dist/esm/helpers/log.mjs +4 -0
- package/dist/esm/helpers/matchMedia.mjs +11 -0
- package/dist/esm/helpers/mergeProps.mjs +21 -0
- package/dist/esm/helpers/mergeVariants.mjs +16 -0
- package/dist/esm/helpers/normalizeColor.mjs +17 -0
- package/dist/esm/helpers/normalizeShadow.mjs +23 -0
- package/dist/esm/helpers/normalizeStyle.mjs +23 -0
- package/dist/esm/helpers/normalizeStylePropKeys.mjs +2 -0
- package/dist/esm/helpers/normalizeValueWithProperty.mjs +32 -0
- package/dist/esm/helpers/objectIdentityKey.mjs +15 -0
- package/dist/esm/helpers/propMapper.js.map +1 -1
- package/dist/esm/helpers/propMapper.mjs +239 -0
- package/dist/esm/helpers/propMapper.native.js.map +1 -1
- package/dist/esm/helpers/proxyThemeToParents.mjs +36 -0
- package/dist/esm/helpers/proxyThemeVariables.mjs +12 -0
- package/dist/esm/helpers/pseudoDescriptors.mjs +34 -0
- package/dist/esm/helpers/registerCSSVariable.js.map +1 -1
- package/dist/esm/helpers/registerCSSVariable.mjs +7 -0
- package/dist/esm/helpers/registerCSSVariable.native.js.map +1 -1
- package/dist/esm/helpers/themeable.mjs +33 -0
- package/dist/esm/helpers/themes.mjs +14 -0
- package/dist/esm/helpers/timer.mjs +8 -0
- package/dist/esm/hooks/getThemeProxied.js +52 -0
- package/dist/esm/hooks/getThemeProxied.js.map +6 -0
- package/dist/esm/hooks/getThemeProxied.mjs +41 -0
- package/dist/esm/hooks/getThemeProxied.native.js +100 -0
- package/dist/esm/hooks/getThemeProxied.native.js.map +6 -0
- package/dist/esm/hooks/useConfiguration.mjs +20 -0
- package/dist/esm/hooks/useDisableSSR.mjs +5 -0
- package/dist/esm/hooks/useIsTouchDevice.mjs +4 -0
- package/dist/esm/hooks/useMedia.mjs +146 -0
- package/dist/esm/hooks/useProps.mjs +40 -0
- package/dist/esm/hooks/useTheme.js +1 -4
- package/dist/esm/hooks/useTheme.js.map +1 -1
- package/dist/esm/hooks/useTheme.mjs +222 -0
- package/dist/esm/hooks/useTheme.native.js.map +1 -1
- package/dist/esm/hooks/useThemeName.mjs +15 -0
- package/dist/esm/index.mjs +61 -0
- package/dist/esm/inject-styles.mjs +13 -0
- package/dist/esm/insertFont.js.map +1 -1
- package/dist/esm/insertFont.mjs +44 -0
- package/dist/esm/insertFont.native.js.map +1 -1
- package/dist/esm/interfaces/CSSColorNames.mjs +0 -0
- package/dist/esm/interfaces/GetRef.mjs +0 -0
- package/dist/esm/interfaces/KeyTypes.mjs +0 -0
- package/dist/esm/interfaces/RNExclusiveTypes.mjs +0 -0
- package/dist/esm/interfaces/Role.mjs +0 -0
- package/dist/esm/interfaces/TamaguiComponentEvents.mjs +0 -0
- package/dist/esm/interfaces/TamaguiComponentPropsBaseBase.mjs +0 -0
- package/dist/esm/interfaces/TamaguiComponentState.mjs +0 -0
- package/dist/esm/interfaces/WebOnlyPressEvents.mjs +0 -0
- package/dist/esm/internalWithTheme.mjs +14 -0
- package/dist/esm/setupHooks.js.map +1 -1
- package/dist/esm/setupHooks.mjs +5 -0
- package/dist/esm/setupHooks.native.js.map +1 -1
- package/dist/esm/setupReactNative.mjs +24 -0
- package/dist/esm/styled.mjs +56 -0
- package/dist/esm/type-utils.mjs +0 -0
- package/dist/esm/types.mjs +2 -0
- package/dist/esm/views/Configuration.mjs +12 -0
- package/dist/esm/views/FontLanguage.mjs +13 -0
- package/dist/esm/views/FontLanguage.native.js.map +1 -1
- package/dist/esm/views/FontLanguage.types.mjs +0 -0
- package/dist/esm/views/Slot.js.map +1 -1
- package/dist/esm/views/Slot.mjs +53 -0
- package/dist/esm/views/Slot.native.js.map +1 -1
- package/dist/esm/views/Stack.mjs +10 -0
- package/dist/esm/views/TamaguiProvider.js +5 -5
- package/dist/esm/views/TamaguiProvider.js.map +1 -1
- package/dist/esm/views/TamaguiProvider.mjs +32 -0
- package/dist/esm/views/TamaguiProvider.native.js +5 -5
- package/dist/esm/views/TamaguiProvider.native.js.map +1 -1
- package/dist/esm/views/Text.mjs +64 -0
- package/dist/esm/views/Theme.js.map +1 -1
- package/dist/esm/views/Theme.mjs +104 -0
- package/dist/esm/views/Theme.native.js.map +1 -1
- package/dist/esm/views/ThemeDebug.mjs +57 -0
- package/dist/esm/views/ThemeProvider.mjs +20 -0
- package/dist/esm/views/View.mjs +9 -0
- package/package.json +11 -11
- package/src/config.ts +1 -1
- package/src/contexts/ComponentContext.tsx +1 -1
- package/src/createComponent.tsx +7 -5
- package/src/createFont.ts +1 -1
- package/src/createShorthands.ts +1 -1
- package/src/createTamagui.ts +4 -3
- package/src/createTokens.ts +2 -2
- package/src/createVariables.ts +2 -1
- package/src/defaultComponentState.tsx +1 -1
- package/src/helpers/ThemeManager.tsx +1 -1
- package/src/helpers/createShallowSetState.tsx +2 -2
- package/src/helpers/expandStyle.ts +1 -1
- package/src/helpers/getExpandedShorthands.ts +1 -1
- package/src/helpers/getSplitStyles.tsx +33 -26
- package/src/helpers/getStylesAtomic.ts +4 -6
- package/src/helpers/getThemeCSSRules.ts +2 -1
- package/src/helpers/getVariantExtras.tsx +2 -2
- package/src/helpers/insertStyleRule.tsx +8 -3
- package/src/helpers/isTamaguiComponent.tsx +1 -1
- package/src/helpers/isTamaguiElement.tsx +1 -1
- package/src/helpers/matchMedia.native.ts +1 -1
- package/src/helpers/matchMedia.ts +1 -1
- package/src/helpers/propMapper.ts +2 -1
- package/src/helpers/proxyThemeToParents.ts +1 -1
- package/src/helpers/registerCSSVariable.ts +3 -2
- package/src/helpers/themeable.tsx +1 -1
- package/src/hooks/useDisableSSR.tsx +1 -1
- package/src/hooks/useProps.tsx +1 -1
- package/src/hooks/useTheme.tsx +4 -6
- package/src/hooks/useThemeName.tsx +1 -1
- package/src/insertFont.ts +4 -3
- package/src/interfaces/GetRef.tsx +2 -2
- package/src/interfaces/TamaguiComponentPropsBaseBase.tsx +2 -2
- package/src/interfaces/TamaguiComponentState.tsx +1 -1
- package/src/interfaces/WebOnlyPressEvents.tsx +1 -1
- package/src/setupHooks.ts +4 -8
- package/src/setupReactNative.ts +1 -1
- package/src/styled.tsx +1 -1
- package/src/types.tsx +9 -9
- package/src/views/FontLanguage.native.tsx +0 -1
- package/src/views/FontLanguage.types.ts +2 -2
- package/src/views/Slot.tsx +2 -1
- package/src/views/TamaguiProvider.tsx +8 -5
- package/src/views/Text.tsx +1 -1
- package/src/views/Theme.tsx +2 -1
- package/src/views/ThemeDebug.native.tsx +2 -2
- package/src/views/ThemeDebug.tsx +2 -2
- package/types/config.d.ts +1 -1
- package/types/config.d.ts.map +1 -1
- package/types/contexts/ComponentContext.d.ts +1 -1
- package/types/contexts/ComponentContext.d.ts.map +1 -1
- package/types/createComponent.d.ts +1 -1
- package/types/createComponent.d.ts.map +1 -1
- package/types/createFont.d.ts +1 -1
- package/types/createFont.d.ts.map +1 -1
- package/types/createShorthands.d.ts +1 -1
- package/types/createShorthands.d.ts.map +1 -1
- package/types/createTamagui.d.ts +1 -1
- package/types/createTamagui.d.ts.map +1 -1
- package/types/createTokens.d.ts +2 -2
- package/types/createTokens.d.ts.map +1 -1
- package/types/createVariables.d.ts +1 -1
- package/types/createVariables.d.ts.map +1 -1
- package/types/defaultComponentState.d.ts +1 -1
- package/types/defaultComponentState.d.ts.map +1 -1
- package/types/helpers/ThemeManager.d.ts +1 -1
- package/types/helpers/ThemeManager.d.ts.map +1 -1
- package/types/helpers/createShallowSetState.d.ts +2 -2
- package/types/helpers/createShallowSetState.d.ts.map +1 -1
- package/types/helpers/expandStyle.d.ts +1 -1
- package/types/helpers/expandStyle.d.ts.map +1 -1
- package/types/helpers/getExpandedShorthands.d.ts +1 -1
- package/types/helpers/getExpandedShorthands.d.ts.map +1 -1
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
- package/types/helpers/getStylesAtomic.d.ts +2 -2
- package/types/helpers/getStylesAtomic.d.ts.map +1 -1
- package/types/helpers/getThemeCSSRules.d.ts.map +1 -1
- package/types/helpers/getVariantExtras.d.ts +2 -2
- package/types/helpers/getVariantExtras.d.ts.map +1 -1
- package/types/helpers/insertStyleRule.d.ts.map +1 -1
- package/types/helpers/isTamaguiComponent.d.ts +1 -1
- package/types/helpers/isTamaguiComponent.d.ts.map +1 -1
- package/types/helpers/isTamaguiElement.d.ts +1 -1
- package/types/helpers/isTamaguiElement.d.ts.map +1 -1
- package/types/helpers/matchMedia.d.ts +1 -1
- package/types/helpers/matchMedia.d.ts.map +1 -1
- package/types/helpers/matchMedia.native.d.ts +1 -1
- package/types/helpers/matchMedia.native.d.ts.map +1 -1
- package/types/helpers/propMapper.d.ts.map +1 -1
- package/types/helpers/proxyThemeToParents.d.ts +1 -1
- package/types/helpers/proxyThemeToParents.d.ts.map +1 -1
- package/types/helpers/registerCSSVariable.d.ts +2 -2
- package/types/helpers/registerCSSVariable.d.ts.map +1 -1
- package/types/helpers/themeable.d.ts +1 -1
- package/types/helpers/themeable.d.ts.map +1 -1
- package/types/hooks/getThemeProxied.d.ts.map +1 -0
- package/types/hooks/useDisableSSR.d.ts +1 -1
- package/types/hooks/useDisableSSR.d.ts.map +1 -1
- package/types/hooks/useProps.d.ts +1 -1
- package/types/hooks/useProps.d.ts.map +1 -1
- package/types/hooks/useTheme.d.ts +3 -2
- package/types/hooks/useTheme.d.ts.map +1 -1
- package/types/hooks/useThemeName.d.ts +1 -1
- package/types/hooks/useThemeName.d.ts.map +1 -1
- package/types/insertFont.d.ts +2 -2
- package/types/insertFont.d.ts.map +1 -1
- package/types/interfaces/GetRef.d.ts +2 -2
- package/types/interfaces/GetRef.d.ts.map +1 -1
- package/types/interfaces/TamaguiComponentPropsBaseBase.d.ts +2 -2
- package/types/interfaces/TamaguiComponentPropsBaseBase.d.ts.map +1 -1
- package/types/interfaces/TamaguiComponentState.d.ts +1 -1
- package/types/interfaces/TamaguiComponentState.d.ts.map +1 -1
- package/types/interfaces/WebOnlyPressEvents.d.ts +1 -1
- package/types/interfaces/WebOnlyPressEvents.d.ts.map +1 -1
- package/types/setupHooks.d.ts +3 -3
- package/types/setupHooks.d.ts.map +1 -1
- package/types/setupReactNative.d.ts +1 -1
- package/types/setupReactNative.d.ts.map +1 -1
- package/types/styled.d.ts +1 -1
- package/types/styled.d.ts.map +1 -1
- package/types/types.d.ts +9 -9
- package/types/types.d.ts.map +1 -1
- package/types/views/FontLanguage.native.d.ts.map +1 -1
- package/types/views/FontLanguage.types.d.ts +2 -2
- package/types/views/FontLanguage.types.d.ts.map +1 -1
- package/types/views/Slot.d.ts +1 -1
- package/types/views/Slot.d.ts.map +1 -1
- package/types/views/TamaguiProvider.d.ts.map +1 -1
- package/types/views/Text.d.ts +1 -1
- package/types/views/Text.d.ts.map +1 -1
- package/types/views/Theme.d.ts +1 -1
- package/types/views/Theme.d.ts.map +1 -1
- package/types/views/ThemeDebug.d.ts +2 -2
- package/types/views/ThemeDebug.d.ts.map +1 -1
- package/types/views/ThemeDebug.native.d.ts +2 -2
- package/types/views/ThemeDebug.native.d.ts.map +1 -1
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import "@tamagui/constants";
|
|
2
|
+
import { tokenCategories } from "@tamagui/helpers";
|
|
3
|
+
import { getConfig } from "../config.mjs";
|
|
4
|
+
import { isDevTools } from "../constants/isDevTools.mjs";
|
|
5
|
+
import { getVariableValue, isVariable } from "../createVariable.mjs";
|
|
6
|
+
import { expandStyle } from "./expandStyle.mjs";
|
|
7
|
+
import { normalizeStyle } from "./normalizeStyle.mjs";
|
|
8
|
+
import { getFontsForLanguage, getVariantExtras } from "./getVariantExtras.mjs";
|
|
9
|
+
import { isObj } from "./isObj.mjs";
|
|
10
|
+
import { pseudoDescriptors } from "./pseudoDescriptors.mjs";
|
|
11
|
+
const propMapper = (key, value, styleStateIn, subPropsIn) => {
|
|
12
|
+
if (lastFontFamilyToken = null, key === "elevationAndroid") return;
|
|
13
|
+
if (value === "unset") {
|
|
14
|
+
const unsetVal = styleStateIn.conf.unset?.[key];
|
|
15
|
+
if (unsetVal != null) value = unsetVal;else return;
|
|
16
|
+
}
|
|
17
|
+
const subProps = styleStateIn.styleProps.fallbackProps || subPropsIn,
|
|
18
|
+
styleState = subProps ? new Proxy(styleStateIn, {
|
|
19
|
+
get(_, k) {
|
|
20
|
+
return k === "curProps" ? subProps : Reflect.get(_, k);
|
|
21
|
+
}
|
|
22
|
+
}) : styleStateIn,
|
|
23
|
+
{
|
|
24
|
+
conf,
|
|
25
|
+
styleProps,
|
|
26
|
+
fontFamily,
|
|
27
|
+
staticConfig
|
|
28
|
+
} = styleState,
|
|
29
|
+
{
|
|
30
|
+
variants
|
|
31
|
+
} = staticConfig;
|
|
32
|
+
if (process.env.NODE_ENV === "development" && fontFamily && fontFamily[0] === "$" && !(fontFamily in conf.fontsParsed) && console.warn(`Warning: no fontFamily "${fontFamily}" found in config: ${Object.keys(conf.fontsParsed).join(", ")}`), !styleProps.noExpand && variants && key in variants) {
|
|
33
|
+
styleState.curProps[key] = value;
|
|
34
|
+
const variantValue = resolveVariants(key, value, styleProps, styleState, "");
|
|
35
|
+
if (variantValue) return variantValue;
|
|
36
|
+
}
|
|
37
|
+
let shouldReturn = !1;
|
|
38
|
+
if (styleProps.disableExpandShorthands || key in conf.shorthands && (shouldReturn = !0, key = conf.shorthands[key]), value && (value[0] === "$" ? value = getTokenForKey(key, value, styleProps.resolveValues, styleState) : isVariable(value) && (value = resolveVariableValue(key, value, styleProps.resolveValues))), shouldReturn || value != null) {
|
|
39
|
+
const result = (styleProps.noExpand ? null : expandStyle(key, value)) || [[key, value]];
|
|
40
|
+
return key === "fontFamily" && lastFontFamilyToken && fontFamilyCache.set(result, lastFontFamilyToken), result;
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
resolveVariants = (key, value, styleProps, styleState, parentVariantKey) => {
|
|
44
|
+
const {
|
|
45
|
+
staticConfig,
|
|
46
|
+
conf,
|
|
47
|
+
debug
|
|
48
|
+
} = styleState,
|
|
49
|
+
{
|
|
50
|
+
variants
|
|
51
|
+
} = staticConfig;
|
|
52
|
+
if (!variants) return;
|
|
53
|
+
let variantValue = getVariantDefinition(variants[key], value, conf);
|
|
54
|
+
if (process.env.NODE_ENV === "development" && debug === "verbose" && (console.groupCollapsed(`\u2666\uFE0F\u2666\uFE0F\u2666\uFE0F resolve variant ${key}`), console.info({
|
|
55
|
+
key,
|
|
56
|
+
value,
|
|
57
|
+
variantValue,
|
|
58
|
+
variants,
|
|
59
|
+
curProps: {
|
|
60
|
+
...styleState.curProps
|
|
61
|
+
}
|
|
62
|
+
}), console.groupEnd()), !variantValue) {
|
|
63
|
+
if (process.env.TAMAGUI_WARN_ON_MISSING_VARIANT === "1" && typeof value != "boolean") {
|
|
64
|
+
const name = staticConfig.componentName || "[UnnamedComponent]";
|
|
65
|
+
console.warn(`No variant found: ${name} has variant "${key}", but no matching value "${value}"`);
|
|
66
|
+
}
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (typeof variantValue == "function") {
|
|
70
|
+
const fn = variantValue,
|
|
71
|
+
extras = getVariantExtras(styleState);
|
|
72
|
+
variantValue = fn(value, extras), process.env.NODE_ENV === "development" && debug === "verbose" && (console.groupCollapsed(" expanded functional variant", key), console.info({
|
|
73
|
+
fn,
|
|
74
|
+
variantValue,
|
|
75
|
+
extras
|
|
76
|
+
}), console.groupEnd());
|
|
77
|
+
}
|
|
78
|
+
let fontFamilyResult;
|
|
79
|
+
if (isObj(variantValue)) {
|
|
80
|
+
const fontFamilyUpdate = variantValue.fontFamily || variantValue[conf.inverseShorthands.fontFamily];
|
|
81
|
+
fontFamilyUpdate && (fontFamilyResult = getFontFamilyFromNameOrVariable(fontFamilyUpdate, conf), styleState.fontFamily = fontFamilyResult, process.env.NODE_ENV === "development" && debug === "verbose" && console.info(" updating font family", fontFamilyResult)), variantValue = resolveTokensAndVariants(key, variantValue, styleProps, styleState, parentVariantKey);
|
|
82
|
+
}
|
|
83
|
+
if (variantValue) {
|
|
84
|
+
const expanded = normalizeStyle(variantValue, !!styleProps.noNormalize);
|
|
85
|
+
process.env.NODE_ENV === "development" && debug === "verbose" && console.info(" expanding styles from ", variantValue, "to", expanded);
|
|
86
|
+
const next = Object.entries(expanded);
|
|
87
|
+
return fontFamilyResult && fontFamilyResult[0] === "$" && fontFamilyCache.set(next, getVariableValue(fontFamilyResult)), next;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
function getFontFamilyFromNameOrVariable(input, conf) {
|
|
91
|
+
if (isVariable(input)) {
|
|
92
|
+
const val = variableToFontNameCache.get(input);
|
|
93
|
+
if (val) return val;
|
|
94
|
+
for (const key in conf.fontsParsed) {
|
|
95
|
+
const familyVariable = conf.fontsParsed[key].family;
|
|
96
|
+
if (isVariable(familyVariable) && (variableToFontNameCache.set(familyVariable, key), familyVariable === input)) return key;
|
|
97
|
+
}
|
|
98
|
+
} else if (typeof input == "string" && input[0] === "$") return input;
|
|
99
|
+
}
|
|
100
|
+
const variableToFontNameCache = /* @__PURE__ */new WeakMap(),
|
|
101
|
+
fontFamilyCache = /* @__PURE__ */new WeakMap(),
|
|
102
|
+
getPropMappedFontFamily = expanded => expanded && fontFamilyCache.get(expanded),
|
|
103
|
+
resolveTokensAndVariants = (key, value, styleProps, styleState, parentVariantKey) => {
|
|
104
|
+
const {
|
|
105
|
+
conf,
|
|
106
|
+
staticConfig,
|
|
107
|
+
debug,
|
|
108
|
+
theme
|
|
109
|
+
} = styleState,
|
|
110
|
+
{
|
|
111
|
+
variants
|
|
112
|
+
} = staticConfig,
|
|
113
|
+
res = {};
|
|
114
|
+
process.env.NODE_ENV === "development" && debug === "verbose" && console.info(" - resolveTokensAndVariants", key, value);
|
|
115
|
+
for (const _key in value) {
|
|
116
|
+
const subKey = conf.shorthands[_key] || _key,
|
|
117
|
+
val = value[_key];
|
|
118
|
+
if (styleProps.noExpand) res[subKey] = val;else if (variants && subKey in variants) {
|
|
119
|
+
if (styleState.curProps[subKey] = val, parentVariantKey && parentVariantKey === key) res[subKey] =
|
|
120
|
+
// SYNC WITH *1
|
|
121
|
+
val[0] === "$" ? getTokenForKey(subKey, val, styleProps.resolveValues, styleState) : val;else {
|
|
122
|
+
const variantOut = resolveVariants(subKey, val, styleProps, styleState, key);
|
|
123
|
+
if (variantOut) for (const [key2, val2] of variantOut) val2 != null && (key2 in pseudoDescriptors ? (res[key2] ??= {}, Object.assign(res[key2], val2)) : res[key2] = val2);
|
|
124
|
+
}
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
if (isVariable(val)) {
|
|
128
|
+
res[subKey] = resolveVariableValue(subKey, val, styleProps.resolveValues), process.env.NODE_ENV === "development" && debug === "verbose" && console.info("variable", subKey, res[subKey]);
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
if (typeof val == "string") {
|
|
132
|
+
const fVal =
|
|
133
|
+
// SYNC WITH *1
|
|
134
|
+
val[0] === "$" ? getTokenForKey(subKey, val, styleProps.resolveValues, styleState) : val;
|
|
135
|
+
res[subKey] = fVal;
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
if (isObj(val)) {
|
|
139
|
+
const subObject = resolveTokensAndVariants(subKey, val, styleProps, styleState, key);
|
|
140
|
+
process.env.NODE_ENV === "development" && debug === "verbose" && console.info("object", subKey, subObject), res[subKey] ??= {}, Object.assign(res[subKey], subObject);
|
|
141
|
+
} else res[subKey] = val;
|
|
142
|
+
process.env.NODE_ENV === "development" && debug && res[subKey]?.[0] === "$" && console.warn(`\u26A0\uFE0F Missing token in theme ${theme.name}:`, subKey, res[subKey], theme);
|
|
143
|
+
}
|
|
144
|
+
return res;
|
|
145
|
+
},
|
|
146
|
+
tokenCats = ["size", "color", "radius", "space", "zIndex"].map(name => ({
|
|
147
|
+
name,
|
|
148
|
+
spreadName: `...${name}`
|
|
149
|
+
}));
|
|
150
|
+
function getVariantDefinition(variant, value, conf) {
|
|
151
|
+
if (typeof variant == "function") return variant;
|
|
152
|
+
const exact = variant[value];
|
|
153
|
+
if (exact) return exact;
|
|
154
|
+
if (value != null) {
|
|
155
|
+
const {
|
|
156
|
+
tokensParsed
|
|
157
|
+
} = conf;
|
|
158
|
+
for (const {
|
|
159
|
+
name,
|
|
160
|
+
spreadName
|
|
161
|
+
} of tokenCats) if (spreadName in variant && value in tokensParsed[name]) return variant[spreadName];
|
|
162
|
+
const fontSizeVariant = variant["...fontSize"];
|
|
163
|
+
if (fontSizeVariant && conf.fontSizeTokens.has(value)) return fontSizeVariant;
|
|
164
|
+
}
|
|
165
|
+
return variant[`:${typeof value}`] || variant["..."];
|
|
166
|
+
}
|
|
167
|
+
const fontShorthand = {
|
|
168
|
+
fontSize: "size",
|
|
169
|
+
fontWeight: "weight"
|
|
170
|
+
};
|
|
171
|
+
let lastFontFamilyToken = null;
|
|
172
|
+
const getTokenForKey = (key, value, resolveAs = "none", styleState) => {
|
|
173
|
+
if (resolveAs === "none") return value;
|
|
174
|
+
const {
|
|
175
|
+
theme,
|
|
176
|
+
conf = getConfig(),
|
|
177
|
+
context,
|
|
178
|
+
fontFamily,
|
|
179
|
+
staticConfig
|
|
180
|
+
} = styleState,
|
|
181
|
+
tokensParsed = conf.tokensParsed;
|
|
182
|
+
let valOrVar,
|
|
183
|
+
hasSet = !1;
|
|
184
|
+
if (theme && value in theme) valOrVar = theme[value], process.env.NODE_ENV === "development" && styleState.debug === "verbose" && console.info(` - resolving ${key} to theme value ${value}: ${valOrVar?.get?.()}`), hasSet = !0;else if (value in conf.specificTokens) hasSet = !0, valOrVar = conf.specificTokens[value];else {
|
|
185
|
+
const customTokenAccept = staticConfig?.acceptTokens?.[key];
|
|
186
|
+
if (customTokenAccept) {
|
|
187
|
+
const val = tokensParsed[customTokenAccept][value];
|
|
188
|
+
val && (valOrVar = val, hasSet = !0);
|
|
189
|
+
} else {
|
|
190
|
+
switch (key) {
|
|
191
|
+
case "fontFamily":
|
|
192
|
+
{
|
|
193
|
+
valOrVar = (context?.language ? getFontsForLanguage(conf.fontsParsed, context.language) : conf.fontsParsed)[value]?.family || value, lastFontFamilyToken = value, hasSet = !0;
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
case "fontSize":
|
|
197
|
+
case "lineHeight":
|
|
198
|
+
case "letterSpacing":
|
|
199
|
+
case "fontWeight":
|
|
200
|
+
{
|
|
201
|
+
const defaultFont = conf.defaultFont || "$body",
|
|
202
|
+
fam = fontFamily || defaultFont;
|
|
203
|
+
if (fam) {
|
|
204
|
+
const fontsParsed = context?.language ? getFontsForLanguage(conf.fontsParsed, context.language) : conf.fontsParsed;
|
|
205
|
+
valOrVar = (fontsParsed[fam] || fontsParsed[defaultFont])?.[fontShorthand[key] || key]?.[value] || value, hasSet = !0;
|
|
206
|
+
}
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
for (const cat in tokenCategories) if (key in tokenCategories[cat]) {
|
|
211
|
+
const res = tokensParsed[cat][value];
|
|
212
|
+
res != null && (valOrVar = res, hasSet = !0);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (!hasSet) {
|
|
216
|
+
const spaceVar = tokensParsed.space[value];
|
|
217
|
+
spaceVar != null && (valOrVar = spaceVar, hasSet = !0);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if (hasSet) {
|
|
221
|
+
const out = resolveVariableValue(key, valOrVar, resolveAs);
|
|
222
|
+
return process.env.NODE_ENV === "development" && styleState.debug === "verbose" && console.info("resolved", resolveAs, valOrVar, out), out;
|
|
223
|
+
}
|
|
224
|
+
return process.env.NODE_ENV === "development" && isDevTools && styleState.debug === "verbose" && (console.groupCollapsed(" \uFE52 propMap (val)", key, value), console.info({
|
|
225
|
+
valOrVar,
|
|
226
|
+
theme,
|
|
227
|
+
hasSet
|
|
228
|
+
}, theme ? theme[key] : ""), console.groupEnd()), value;
|
|
229
|
+
};
|
|
230
|
+
function resolveVariableValue(key, valOrVar, resolveValues) {
|
|
231
|
+
if (resolveValues === "none") return valOrVar;
|
|
232
|
+
if (isVariable(valOrVar)) {
|
|
233
|
+
if (resolveValues === "value") return valOrVar.val;
|
|
234
|
+
const get = valOrVar?.get;
|
|
235
|
+
return typeof get == "function" ? get(resolveValues === "web" ? "web" : void 0) : valOrVar.variable;
|
|
236
|
+
}
|
|
237
|
+
return valOrVar;
|
|
238
|
+
}
|
|
239
|
+
export { getFontFamilyFromNameOrVariable, getPropMappedFontFamily, getTokenForKey, propMapper };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/propMapper.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA0B,+BAC1B,iBAAgC,6BAEhC,gBA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I,CAAC,QAAQ;AACX,YAAM,WAAW,aAAa,MAAM,KAAK;AACzC,MAAI,YAAY,SACd,WAAW,UACX,SAAS;AAAA,IAEb;AAAA,EACF;AAGF,MAAI,QAAQ;AACV,UAAM,MAAM,qBAAqB,KAAK,UAAU,SAAS;AACzD,WAAI,QAAQ,IAAI,aAAa,iBAAiB,WAAW,UAAU,aACjE,QAAQ,KAAK,YAAY,WAAW,UAAU,GAAG,GAE5C;AAAA,EACT;AAEA,SACE,QAAQ,IAAI,aAAa,iBACzB,gCACA,WAAW,UAAU,cAErB,QAAQ,eAAe,0BAAqB,KAAK,KAAK,GACtD,QAAQ,KAAK,EAAE,UAAU,OAAO,OAAO,GAAG,QAAQ,MAAM,GAAG,IAAI,EAAE,GACjE,QAAQ,SAAS,IAGZ;AACT;AAEA,SAAS,qBACP,KACA,UACA,eACA;AACA,MAAI,kBAAkB;AAAQ,WAAO;AACrC,UAAI,kCAAW,QAAQ,GAAG;AACxB,QAAI,kBAAkB;AACpB,aAAO,SAAS;AAGlB,UAAM,MAAM,qCAAU;AAGtB,WAA+C,QAAQ,iBACjD,OAAO,OAAQ,aACV,IAAI,kBAAkB,QAAQ,QAAQ,MAAS,IAIT,SAAS;AAAA,EAC5D;AACA,SAAO;AACT;",
|
|
5
5
|
"names": ["key", "val"]
|
|
6
6
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { getTokenObject } from "../config.mjs";
|
|
2
|
+
const themesRaw = {};
|
|
3
|
+
function proxyThemesToParents(dedupedThemes) {
|
|
4
|
+
for (const {
|
|
5
|
+
names,
|
|
6
|
+
theme
|
|
7
|
+
} of dedupedThemes) for (const name of names) themesRaw[name] = theme;
|
|
8
|
+
const themes = {};
|
|
9
|
+
for (const {
|
|
10
|
+
names,
|
|
11
|
+
theme
|
|
12
|
+
} of dedupedThemes) for (const themeName of names) {
|
|
13
|
+
const proxiedTheme = proxyThemeToParents(themeName, theme);
|
|
14
|
+
themes[themeName] = proxiedTheme;
|
|
15
|
+
}
|
|
16
|
+
return themes;
|
|
17
|
+
}
|
|
18
|
+
function proxyThemeToParents(themeName, theme) {
|
|
19
|
+
const cur = [],
|
|
20
|
+
parents = themeName.split("_").slice(0, -1).map(part => (cur.push(part), cur.join("_"))),
|
|
21
|
+
numParents = parents.length;
|
|
22
|
+
return new Proxy(theme, {
|
|
23
|
+
get(target, key) {
|
|
24
|
+
if (!key ||
|
|
25
|
+
// dont ask me, idk why but on hermes you can see that useTheme()[undefined] passes in STRING undefined to proxy
|
|
26
|
+
// if someone is crazy enough to use "undefined" as a theme key then this not working is on them
|
|
27
|
+
key == "undefined" || Reflect.has(target, key)) return Reflect.get(target, key);
|
|
28
|
+
for (let i = numParents - 1; i >= 0; i--) {
|
|
29
|
+
const parent = themesRaw[parents[i]];
|
|
30
|
+
if (parent && Reflect.has(parent, key)) return Reflect.get(parent, key);
|
|
31
|
+
}
|
|
32
|
+
return getTokenObject(key);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
export { proxyThemeToParents, proxyThemesToParents };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
function proxyThemeVariables(obj) {
|
|
2
|
+
return new Proxy(obj || {}, {
|
|
3
|
+
has(target, key) {
|
|
4
|
+
return Reflect.has(target, removeStarting$(key));
|
|
5
|
+
},
|
|
6
|
+
get(target, key) {
|
|
7
|
+
return Reflect.get(target, removeStarting$(key));
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
const removeStarting$ = str => typeof str == "string" && str[0] === "$" ? str.slice(1) : str;
|
|
12
|
+
export { proxyThemeVariables };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const pseudoDescriptorsBase = {
|
|
2
|
+
// order of keys here important! in priority order
|
|
3
|
+
hoverStyle: {
|
|
4
|
+
name: "hover",
|
|
5
|
+
priority: 1
|
|
6
|
+
},
|
|
7
|
+
pressStyle: {
|
|
8
|
+
name: "active",
|
|
9
|
+
stateKey: "press",
|
|
10
|
+
priority: 2
|
|
11
|
+
},
|
|
12
|
+
focusStyle: {
|
|
13
|
+
name: "focus",
|
|
14
|
+
priority: 3
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
pseudoPriorities = {
|
|
18
|
+
hover: 1,
|
|
19
|
+
press: 2,
|
|
20
|
+
focus: 3
|
|
21
|
+
},
|
|
22
|
+
pseudoDescriptors = {
|
|
23
|
+
...pseudoDescriptorsBase,
|
|
24
|
+
enterStyle: {
|
|
25
|
+
name: "enter",
|
|
26
|
+
selector: ".t_unmounted",
|
|
27
|
+
priority: 4
|
|
28
|
+
},
|
|
29
|
+
exitStyle: {
|
|
30
|
+
name: "exit",
|
|
31
|
+
priority: 5
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
export { pseudoDescriptors, pseudoDescriptorsBase, pseudoPriorities };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/registerCSSVariable.ts"],
|
|
4
|
-
"mappings": "
|
|
4
|
+
"mappings": "AACA,SAAS,mBAAmB,wBAAwB;AAG7C,MAAM,sBAAsB,CAAC,MAA8B;AAChE,wBAAsB,IAAI,iBAAiB,CAAC,GAAG,CAAC;AAClD,GAEa,gBAAgB,CAAC,GAAa,WAAW,OAC7C,KAAK,kBAAkB,EAAE,MAAM,EAAK,CAAC,IAC1C,CAAC,YAAY,OAAO,EAAE,OAAQ,WAAW,GAAG,EAAE,GAAG,OAAO,EAAE,GAC5D,IAGW,wBAAwB,oBAAI,IAAc;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createCSSVariable, getVariableValue } from "../createVariable.mjs";
|
|
2
|
+
const registerCSSVariable = v => {
|
|
3
|
+
tokensValueToVariable.set(getVariableValue(v), v);
|
|
4
|
+
},
|
|
5
|
+
variableToCSS = (v, unitless = !1) => `--${createCSSVariable(v.name, !1)}:${!unitless && typeof v.val == "number" ? `${v.val}px` : v.val}`,
|
|
6
|
+
tokensValueToVariable = /* @__PURE__ */new Map();
|
|
7
|
+
export { registerCSSVariable, tokensValueToVariable, variableToCSS };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/registerCSSVariable.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,4BAAoD;AAG7C,MAAM,sBAAsB,CAAC,MAA8B;AAChE,wBAAsB,QAAI,wCAAiB,CAAC,GAAG,CAAC;AAClD,GAEa,gBAAgB,CAAC,GAAa,WAAW,OAC7C,SAAK,yCAAkB,EAAE,MAAM,EAAK,CAAC,IAC1C,CAAC,YAAY,OAAO,EAAE,OAAQ,WAAW,GAAG,EAAE,GAAG,OAAO,EAAE,GAC5D,IAGW,wBAAwB,oBAAI,IAAc;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import { Theme } from "../views/Theme.mjs";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
function themeable(Component, staticConfig) {
|
|
5
|
+
const withTheme = forwardRef(function (props, ref) {
|
|
6
|
+
const {
|
|
7
|
+
themeInverse,
|
|
8
|
+
theme,
|
|
9
|
+
componentName,
|
|
10
|
+
themeReset,
|
|
11
|
+
...rest
|
|
12
|
+
} = props,
|
|
13
|
+
element =
|
|
14
|
+
// @ts-expect-error its ok
|
|
15
|
+
/* @__PURE__ */
|
|
16
|
+
jsx(Component, {
|
|
17
|
+
ref,
|
|
18
|
+
...rest,
|
|
19
|
+
"data-disable-theme": !0
|
|
20
|
+
});
|
|
21
|
+
return /* @__PURE__ */jsx(Theme, {
|
|
22
|
+
componentName: componentName || staticConfig?.componentName,
|
|
23
|
+
name: theme,
|
|
24
|
+
"disable-child-theme": !0,
|
|
25
|
+
debug: props.debug,
|
|
26
|
+
inverse: themeInverse,
|
|
27
|
+
reset: themeReset,
|
|
28
|
+
children: element
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
return withTheme.displayName = `Themed(${Component?.displayName || Component?.name || "Anonymous"})`, withTheme;
|
|
32
|
+
}
|
|
33
|
+
export { themeable };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createVariable, isVariable } from "../createVariable.mjs";
|
|
2
|
+
function ensureThemeVariable(theme, key) {
|
|
3
|
+
const val = theme[key];
|
|
4
|
+
isVariable(val) ? val.name !== key && (theme[key] = createVariable({
|
|
5
|
+
key: val.name,
|
|
6
|
+
name: key,
|
|
7
|
+
val: val.val
|
|
8
|
+
})) : theme[key] = createVariable({
|
|
9
|
+
key,
|
|
10
|
+
name: key,
|
|
11
|
+
val
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export { ensureThemeVariable };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import "@tamagui/constants";
|
|
2
|
+
import { getConfig } from "../config";
|
|
3
|
+
import { getVariable } from "../createVariable";
|
|
4
|
+
function getThemeProxied({ theme, name, scheme }, deopt = !1, themeManager, keys, debug) {
|
|
5
|
+
if (!theme)
|
|
6
|
+
return {};
|
|
7
|
+
const config = getConfig();
|
|
8
|
+
function track(key) {
|
|
9
|
+
keys && !keys.includes(key) && (keys.push(key), process.env.NODE_ENV === "development" && debug && console.info(` \u{1F3A8} useTheme() tracking new key: ${key}`));
|
|
10
|
+
}
|
|
11
|
+
return new Proxy(theme, {
|
|
12
|
+
has(_, key) {
|
|
13
|
+
if (Reflect.has(theme, key))
|
|
14
|
+
return !0;
|
|
15
|
+
if (typeof key == "string")
|
|
16
|
+
return key[0] === "$" && (key = key.slice(1)), themeManager?.allKeys.has(key);
|
|
17
|
+
},
|
|
18
|
+
get(_, key) {
|
|
19
|
+
if (
|
|
20
|
+
// dont ask me, idk why but on hermes you can see that useTheme()[undefined] passes in STRING undefined to proxy
|
|
21
|
+
// if someone is crazy enough to use "undefined" as a theme key then this not working is on them
|
|
22
|
+
key !== "undefined" && typeof key == "string"
|
|
23
|
+
) {
|
|
24
|
+
const keyString = key[0] === "$" ? key.slice(1) : key, val = theme[keyString];
|
|
25
|
+
if (val && typeof val == "object")
|
|
26
|
+
return new Proxy(val, {
|
|
27
|
+
// when they touch the actual value we only track it
|
|
28
|
+
// if its a variable (web), its ignored!
|
|
29
|
+
get(_2, subkey) {
|
|
30
|
+
if (subkey === "val")
|
|
31
|
+
track(keyString);
|
|
32
|
+
else if (subkey === "get")
|
|
33
|
+
return (platform) => getVariable(val);
|
|
34
|
+
return Reflect.get(val, subkey);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
if (process.env.NODE_ENV === "development" && process.env.TAMAGUI_FEAT_THROW_ON_MISSING_THEME_VALUE === "1")
|
|
38
|
+
throw new Error(
|
|
39
|
+
`[tamagui] No theme key "${key}" found in theme ${name}.
|
|
40
|
+
Keys in theme: ${Object.keys(
|
|
41
|
+
theme
|
|
42
|
+
).join(", ")}`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
return Reflect.get(_, key);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
getThemeProxied
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=getThemeProxied.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/hooks/getThemeProxied.tsx"],
|
|
4
|
+
"mappings": "AAAA,OAAsB;AACtB,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAIrB,SAAS,gBACd,EAAE,OAAO,MAAM,OAAO,GACtB,QAAQ,IACR,cACA,MACA,OACgB;AAChB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["_"]
|
|
6
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import "@tamagui/constants";
|
|
2
|
+
import { getConfig } from "../config.mjs";
|
|
3
|
+
import { getVariable } from "../createVariable.mjs";
|
|
4
|
+
function getThemeProxied({
|
|
5
|
+
theme,
|
|
6
|
+
name,
|
|
7
|
+
scheme
|
|
8
|
+
}, deopt = !1, themeManager, keys, debug) {
|
|
9
|
+
if (!theme) return {};
|
|
10
|
+
const config = getConfig();
|
|
11
|
+
function track(key) {
|
|
12
|
+
keys && !keys.includes(key) && (keys.push(key), process.env.NODE_ENV === "development" && debug && console.info(` \u{1F3A8} useTheme() tracking new key: ${key}`));
|
|
13
|
+
}
|
|
14
|
+
return new Proxy(theme, {
|
|
15
|
+
has(_, key) {
|
|
16
|
+
if (Reflect.has(theme, key)) return !0;
|
|
17
|
+
if (typeof key == "string") return key[0] === "$" && (key = key.slice(1)), themeManager?.allKeys.has(key);
|
|
18
|
+
},
|
|
19
|
+
get(_, key) {
|
|
20
|
+
if (
|
|
21
|
+
// dont ask me, idk why but on hermes you can see that useTheme()[undefined] passes in STRING undefined to proxy
|
|
22
|
+
// if someone is crazy enough to use "undefined" as a theme key then this not working is on them
|
|
23
|
+
key !== "undefined" && typeof key == "string") {
|
|
24
|
+
const keyString = key[0] === "$" ? key.slice(1) : key,
|
|
25
|
+
val = theme[keyString];
|
|
26
|
+
if (val && typeof val == "object") return new Proxy(val, {
|
|
27
|
+
// when they touch the actual value we only track it
|
|
28
|
+
// if its a variable (web), its ignored!
|
|
29
|
+
get(_2, subkey) {
|
|
30
|
+
if (subkey === "val") track(keyString);else if (subkey === "get") return platform => getVariable(val);
|
|
31
|
+
return Reflect.get(val, subkey);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
if (process.env.NODE_ENV === "development" && process.env.TAMAGUI_FEAT_THROW_ON_MISSING_THEME_VALUE === "1") throw new Error(`[tamagui] No theme key "${key}" found in theme ${name}.
|
|
35
|
+
Keys in theme: ${Object.keys(theme).join(", ")}`);
|
|
36
|
+
}
|
|
37
|
+
return Reflect.get(_, key);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
export { getThemeProxied };
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
return to;
|
|
14
|
+
};
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
16
|
+
var getThemeProxied_exports = {};
|
|
17
|
+
__export(getThemeProxied_exports, {
|
|
18
|
+
getThemeProxied: () => getThemeProxied
|
|
19
|
+
});
|
|
20
|
+
module.exports = __toCommonJS(getThemeProxied_exports);
|
|
21
|
+
var import_constants = require("@tamagui/constants"), import_config = require("../config"), import_createVariable = require("../createVariable");
|
|
22
|
+
function getThemeProxied({ theme, name, scheme }, deopt = !1, themeManager, keys, debug) {
|
|
23
|
+
if (!theme)
|
|
24
|
+
return {};
|
|
25
|
+
const config = (0, import_config.getConfig)();
|
|
26
|
+
function track(key) {
|
|
27
|
+
keys && !keys.includes(key) && (keys.push(key), process.env.NODE_ENV === "development" && debug && console.info(` \u{1F3A8} useTheme() tracking new key: ${key}`));
|
|
28
|
+
}
|
|
29
|
+
return new Proxy(theme, {
|
|
30
|
+
has(_, key) {
|
|
31
|
+
if (Reflect.has(theme, key))
|
|
32
|
+
return !0;
|
|
33
|
+
if (typeof key == "string")
|
|
34
|
+
return key[0] === "$" && (key = key.slice(1)), themeManager == null ? void 0 : themeManager.allKeys.has(key);
|
|
35
|
+
},
|
|
36
|
+
get(_, key) {
|
|
37
|
+
if (
|
|
38
|
+
// dont ask me, idk why but on hermes you can see that useTheme()[undefined] passes in STRING undefined to proxy
|
|
39
|
+
// if someone is crazy enough to use "undefined" as a theme key then this not working is on them
|
|
40
|
+
key !== "undefined" && typeof key == "string"
|
|
41
|
+
) {
|
|
42
|
+
const keyString = key[0] === "$" ? key.slice(1) : key, val = theme[keyString];
|
|
43
|
+
if (val && typeof val == "object")
|
|
44
|
+
return new Proxy(val, {
|
|
45
|
+
// when they touch the actual value we only track it
|
|
46
|
+
// if its a variable (web), its ignored!
|
|
47
|
+
get(_2, subkey) {
|
|
48
|
+
if (subkey === "val")
|
|
49
|
+
track(keyString);
|
|
50
|
+
else if (subkey === "get")
|
|
51
|
+
return (platform) => {
|
|
52
|
+
const outVal = (0, import_createVariable.getVariable)(val);
|
|
53
|
+
if (platform !== "web" && import_constants.isIos && !deopt && config.settings.fastSchemeChange && !someParentIsInversed(themeManager) && scheme) {
|
|
54
|
+
const oppositeThemeName = name.replace(
|
|
55
|
+
scheme === "dark" ? "dark" : "light",
|
|
56
|
+
scheme === "dark" ? "light" : "dark"
|
|
57
|
+
), oppositeTheme = config.themes[oppositeThemeName], oppositeVal = (0, import_createVariable.getVariable)(oppositeTheme == null ? void 0 : oppositeTheme[keyString]);
|
|
58
|
+
if (oppositeVal)
|
|
59
|
+
return {
|
|
60
|
+
dynamic: {
|
|
61
|
+
dark: scheme === "dark" ? outVal : oppositeVal,
|
|
62
|
+
light: scheme === "light" ? outVal : oppositeVal
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
return track(keyString), outVal;
|
|
67
|
+
};
|
|
68
|
+
return Reflect.get(val, subkey);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
if (process.env.NODE_ENV === "development" && process.env.TAMAGUI_FEAT_THROW_ON_MISSING_THEME_VALUE === "1")
|
|
72
|
+
throw new Error(
|
|
73
|
+
`[tamagui] No theme key "${key}" found in theme ${name}.
|
|
74
|
+
Keys in theme: ${Object.keys(
|
|
75
|
+
theme
|
|
76
|
+
).join(", ")}`
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
return Reflect.get(_, key);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
function someParentIsInversed(manager) {
|
|
84
|
+
{
|
|
85
|
+
let cur = manager;
|
|
86
|
+
for (; cur; ) {
|
|
87
|
+
if (!cur.parentManager)
|
|
88
|
+
return !1;
|
|
89
|
+
if (cur.parentManager.state.scheme !== cur.state.scheme)
|
|
90
|
+
return !0;
|
|
91
|
+
cur = cur.parentManager;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return !1;
|
|
95
|
+
}
|
|
96
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
97
|
+
0 && (module.exports = {
|
|
98
|
+
getThemeProxied
|
|
99
|
+
});
|
|
100
|
+
//# sourceMappingURL=getThemeProxied.js.map
|