@tamagui/core 1.0.1-beta.173 → 1.0.1-beta.175
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/createComponent.js +13 -0
- package/dist/cjs/createComponent.js.map +2 -2
- package/dist/cjs/helpers/ThemeManager.js +4 -2
- package/dist/cjs/helpers/ThemeManager.js.map +2 -2
- package/dist/cjs/helpers/createPropMapper.js +54 -8
- package/dist/cjs/helpers/createPropMapper.js.map +2 -2
- package/dist/cjs/helpers/getSplitStyles.js +11 -4
- package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
- package/dist/cjs/hooks/useMedia.js +39 -0
- package/dist/cjs/hooks/useMedia.js.map +2 -2
- package/dist/cjs/hooks/useTheme.js +20 -3
- package/dist/cjs/hooks/useTheme.js.map +2 -2
- package/dist/cjs/index.js +4 -2
- package/dist/cjs/index.js.map +2 -2
- package/dist/esm/createComponent.js +13 -0
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/esm/helpers/ThemeManager.js +4 -2
- package/dist/esm/helpers/ThemeManager.js.map +2 -2
- package/dist/esm/helpers/createPropMapper.js +53 -9
- package/dist/esm/helpers/createPropMapper.js.map +2 -2
- package/dist/esm/helpers/getSplitStyles.js +11 -4
- package/dist/esm/helpers/getSplitStyles.js.map +2 -2
- package/dist/esm/hooks/useMedia.js +38 -0
- package/dist/esm/hooks/useMedia.js.map +2 -2
- package/dist/esm/hooks/useTheme.js +20 -3
- package/dist/esm/hooks/useTheme.js.map +2 -2
- package/dist/esm/index.js +3 -1
- package/dist/esm/index.js.map +2 -2
- package/package.json +11 -10
- package/src/createComponent.tsx +15 -0
- package/src/helpers/ThemeManager.tsx +4 -2
- package/src/helpers/createPropMapper.ts +69 -8
- package/src/helpers/getSplitStyles.tsx +16 -5
- package/src/hooks/useMedia.tsx +54 -0
- package/src/hooks/useTheme.tsx +24 -3
- package/src/index.ts +1 -0
- package/types/helpers/ThemeManager.d.ts +1 -1
- package/types/helpers/createPropMapper.d.ts +3 -1
- package/types/hooks/useMedia.d.ts +10 -0
- package/types/index.d.ts +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/useTheme.tsx"],
|
|
4
|
-
"sourcesContent": ["import { useForceUpdate } from '@tamagui/use-force-update'\nimport React, { useContext, useLayoutEffect, useMemo, useRef, useState } from 'react'\n\nimport { getConfig } from '../config'\nimport { isDevTools } from '../constants/isDevTools'\nimport { isRSC, isServer, useIsomorphicLayoutEffect } from '../constants/platform'\nimport { ThemeContext } from '../contexts/ThemeContext'\nimport { areEqualSets } from '../helpers/areEqualSets'\nimport {\n GetNextThemeProps,\n ThemeManager,\n ThemeManagerContext,\n emptyManager,\n} from '../helpers/ThemeManager'\nimport { ThemeName, ThemeParsed } from '../types'\nimport { GetThemeUnwrapped } from './getThemeUnwrapped'\nimport { useConstant } from './useConstant'\nimport { useServerRef } from './useServerHooks'\n\nexport interface ThemeProps {\n className?: string\n disableThemeClass?: boolean\n name: Exclude<ThemeName, number> | null\n componentName?: string\n children?: any\n reset?: boolean\n debug?: boolean | 'verbose'\n}\n\ninterface UseThemeState {\n uuid: Object\n keys: Set<string>\n isRendering: boolean\n}\n\nexport const useTheme = (\n themeName?: string | null,\n componentName?: string,\n props?: ThemeProps,\n forceUpdate?: any\n): ThemeParsed => {\n // TODO this can use useChangeThemeEffect almost ready\n if (isRSC) {\n const config = getConfig()\n // @ts-ignore\n return getThemeProxied(config.themes[config.defaultTheme], config.defaultTheme)\n }\n\n const state = useServerRef() as React.MutableRefObject<UseThemeState>\n if (!state.current) {\n state.current = {\n uuid: {},\n keys: new Set(),\n isRendering: true,\n }\n }\n\n const { name, theme, themes, themeManager, className } = useChangeThemeEffect(\n themeName,\n componentName,\n props,\n forceUpdate,\n state.current.uuid\n )\n\n if (process.env.NODE_ENV === 'development') {\n if (props?.debug === 'verbose') {\n // eslint-disable-next-line no-console\n console.groupCollapsed(' \uD83D\uDD39 useTheme =>', name)\n const logs = { themeName, componentName, name, className, ...(isDevTools && { theme }) }\n for (const key in logs) {\n // eslint-disable-next-line no-console\n console.log(' ', key, logs[key])\n }\n // eslint-disable-next-line no-console\n console.groupEnd()\n }\n }\n\n // track usage\n state.current.isRendering = true\n useIsomorphicLayoutEffect(() => {\n const st = state.current\n st.isRendering = false\n const cur = themeManager?.keys.get(st.uuid)\n if (!cur || !areEqualSets(st.keys, cur)) {\n themeManager?.track(st.uuid, st.keys)\n }\n })\n\n const debugProp = props && props['debug']\n\n if (!theme) {\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.warn('No theme with name', themeName)\n }\n return themes[getConfig().defaultTheme || 'light']\n }\n\n return useMemo(() => {\n return getThemeProxied(theme, name, className, themeManager, state, debugProp)\n }, [theme, name, className, themeManager, state, debugProp])\n}\n\nfunction getThemeProxied(\n theme: any,\n name: string,\n className?: string,\n themeManager?: ThemeManager | null,\n state?: React.MutableRefObject<UseThemeState>,\n debugProp?: boolean | 'verbose'\n) {\n return new Proxy(theme, {\n has(_, key) {\n if (typeof key === 'string' && key[0] === '$') {\n key = key.slice(1)\n }\n return Reflect.has(theme, key)\n },\n get(_, key) {\n if (key === GetThemeUnwrapped) {\n return theme\n }\n if (key === GetThemeManager) {\n return themeManager\n }\n if (key === 'name') {\n return name\n }\n if (key === 'className') {\n return className\n }\n if (!name || key === '__proto__' || typeof key === 'symbol' || key === '$typeof') {\n return Reflect.get(_, key)\n }\n // auto convert variables to plain\n if (key[0] === '$') {\n key = key.slice(1)\n }\n if (!themeManager) {\n return theme[key]\n }\n if (state) {\n if (state.current.isRendering && !state.current.keys.has(key)) {\n state.current.keys.add(key)\n if (process.env.NODE_ENV === 'development' && debugProp === 'verbose') {\n // eslint-disable-next-line no-console\n console.log(' \uD83D\uDD38 tracking theme', key)\n }\n }\n }\n return themeManager.getValue(key)\n },\n })\n}\n\nconst GetThemeManager = Symbol()\n\nexport const getThemeManager = (theme: any): ThemeManager | undefined => {\n if (!theme) return\n return theme[GetThemeManager]\n}\n\nexport const useThemeName = (opts?: { parent?: true }) => {\n if (isRSC) {\n const config = getConfig()\n return config.defaultTheme || 'light'\n }\n const parent = useContext(ThemeManagerContext)\n const [name, setName] = useState(parent?.name || '')\n\n useIsomorphicLayoutEffect(() => {\n if (!parent) return\n return parent.onChangeTheme((next, manager) => {\n const name = opts?.parent ? manager.parentName || next : next\n if (!name) return\n setName(name)\n })\n }, [parent])\n\n return name\n}\n\nexport const useDefaultThemeName = () => {\n return useContext(ThemeContext)?.defaultTheme\n}\n\nexport const activeThemeManagers = new Set<ThemeManager>()\n\nexport const useChangeThemeEffect = (\n name?: string | null,\n componentName?: string,\n props?: ThemeProps,\n forceUpdateProp?: any,\n uuid?: Object\n): {\n themes: Record<string, ThemeParsed>\n themeManager: ThemeManager | null\n name: string\n theme: ThemeParsed | null\n className?: string\n} => {\n const { themes } =
|
|
5
|
-
"mappings": "AAAA,SAAS,sBAAsB;AAC/B,SAAgB,YAAY,iBAAiB,SAAiB,gBAAgB;AAE9E,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAC3B,SAAS,OAAO,UAAU,iCAAiC;AAC3D,SAAS,oBAAoB;AAC7B,SAAS,oBAAoB;AAC7B;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,yBAAyB;AAClC,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAkBtB,MAAM,WAAW,CACtB,WACA,eACA,OACA,gBACgB;AAEhB,MAAI,OAAO;AACT,UAAM,SAAS,UAAU;AAEzB,WAAO,gBAAgB,OAAO,OAAO,OAAO,eAAe,OAAO,YAAY;AAAA,EAChF;AAEA,QAAM,QAAQ,aAAa;AAC3B,MAAI,CAAC,MAAM,SAAS;AAClB,UAAM,UAAU;AAAA,MACd,MAAM,CAAC;AAAA,MACP,MAAM,oBAAI,IAAI;AAAA,MACd,aAAa;AAAA,IACf;AAAA,EACF;AA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AAC,MAAM,YAAY;AAC7C,YAAMA,SAAO,6BAAM,UAAS,QAAQ,cAAc,OAAO;AACzD,UAAI,CAACA;AAAM;AACX,cAAQA,KAAI;AAAA,IACd,CAAC;AAAA,EACH,GAAG,CAAC,MAAM,CAAC;AAEX,SAAO;AACT;AAEO,MAAM,sBAAsB,MAAM;AAxLzC;AAyLE,UAAO,gBAAW,YAAY,MAAvB,mBAA0B;AACnC;AAEO,MAAM,sBAAsB,oBAAI,IAAkB;AAElD,MAAM,uBAAuB,CAClC,MACA,eACA,OACA,iBACA,SAOG;AACH,QAAM,EAAE,OAAO,IAAI
|
|
4
|
+
"sourcesContent": ["import { useForceUpdate } from '@tamagui/use-force-update'\nimport React, { useContext, useLayoutEffect, useMemo, useRef, useState } from 'react'\n\nimport { getConfig } from '../config'\nimport { isDevTools } from '../constants/isDevTools'\nimport { isRSC, isServer, useIsomorphicLayoutEffect } from '../constants/platform'\nimport { ThemeContext } from '../contexts/ThemeContext'\nimport { areEqualSets } from '../helpers/areEqualSets'\nimport {\n GetNextThemeProps,\n ThemeManager,\n ThemeManagerContext,\n emptyManager,\n} from '../helpers/ThemeManager'\nimport { ThemeName, ThemeParsed } from '../types'\nimport { GetThemeUnwrapped } from './getThemeUnwrapped'\nimport { useConstant } from './useConstant'\nimport { useServerRef } from './useServerHooks'\n\nexport interface ThemeProps {\n className?: string\n disableThemeClass?: boolean\n name: Exclude<ThemeName, number> | null\n componentName?: string\n children?: any\n reset?: boolean\n debug?: boolean | 'verbose'\n}\n\ninterface UseThemeState {\n uuid: Object\n keys: Set<string>\n isRendering: boolean\n}\n\nexport const useTheme = (\n themeName?: string | null,\n componentName?: string,\n props?: ThemeProps,\n forceUpdate?: any\n): ThemeParsed => {\n // TODO this can use useChangeThemeEffect almost ready\n if (isRSC) {\n const config = getConfig()\n // @ts-ignore\n return getThemeProxied(config.themes[config.defaultTheme], config.defaultTheme)\n }\n\n const state = useServerRef() as React.MutableRefObject<UseThemeState>\n if (!state.current) {\n state.current = {\n uuid: {},\n keys: new Set(),\n isRendering: true,\n }\n }\n\n const { name, theme, themes, themeManager, className } = useChangeThemeEffect(\n themeName,\n componentName,\n props,\n forceUpdate,\n state.current.uuid\n )\n\n if (process.env.NODE_ENV === 'development') {\n if (props?.debug === 'verbose') {\n // eslint-disable-next-line no-console\n console.groupCollapsed(' \uD83D\uDD39 useTheme =>', name)\n const logs = { themeName, componentName, name, className, ...(isDevTools && { theme }) }\n for (const key in logs) {\n // eslint-disable-next-line no-console\n console.log(' ', key, logs[key])\n }\n // eslint-disable-next-line no-console\n console.groupEnd()\n }\n }\n\n // track usage\n state.current.isRendering = true\n useIsomorphicLayoutEffect(() => {\n const st = state.current\n st.isRendering = false\n const cur = themeManager?.keys.get(st.uuid)\n if (!cur || !areEqualSets(st.keys, cur)) {\n themeManager?.track(st.uuid, st.keys)\n }\n })\n\n const debugProp = props && props['debug']\n\n if (!theme) {\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.warn('No theme with name', themeName)\n }\n return themes[getConfig().defaultTheme || 'light']\n }\n\n return useMemo(() => {\n return getThemeProxied(theme, name, className, themeManager, state, debugProp)\n }, [theme, name, className, themeManager, state, debugProp])\n}\n\nfunction getThemeProxied(\n theme: any,\n name: string,\n className?: string,\n themeManager?: ThemeManager | null,\n state?: React.MutableRefObject<UseThemeState>,\n debugProp?: boolean | 'verbose'\n) {\n return new Proxy(theme, {\n has(_, key) {\n if (typeof key === 'string' && key[0] === '$') {\n key = key.slice(1)\n }\n return Reflect.has(theme, key)\n },\n get(_, key) {\n if (key === GetThemeUnwrapped) {\n return theme\n }\n if (key === GetThemeManager) {\n return themeManager\n }\n if (key === 'name') {\n return name\n }\n if (key === 'className') {\n return className\n }\n if (!name || key === '__proto__' || typeof key === 'symbol' || key === '$typeof') {\n return Reflect.get(_, key)\n }\n // auto convert variables to plain\n if (key[0] === '$') {\n key = key.slice(1)\n }\n if (!themeManager) {\n return theme[key]\n }\n if (state) {\n if (state.current.isRendering && !state.current.keys.has(key)) {\n state.current.keys.add(key)\n if (process.env.NODE_ENV === 'development' && debugProp === 'verbose') {\n // eslint-disable-next-line no-console\n console.log(' \uD83D\uDD38 tracking theme', key)\n }\n }\n }\n return themeManager.getValue(key)\n },\n })\n}\n\nconst GetThemeManager = Symbol()\n\nexport const getThemeManager = (theme: any): ThemeManager | undefined => {\n if (!theme) return\n return theme[GetThemeManager]\n}\n\nexport const useThemeName = (opts?: { parent?: true }) => {\n if (isRSC) {\n const config = getConfig()\n return config.defaultTheme || 'light'\n }\n const parent = useContext(ThemeManagerContext)\n const [name, setName] = useState(parent?.name || '')\n\n useIsomorphicLayoutEffect(() => {\n if (!parent) return\n return parent.onChangeTheme((next, manager) => {\n const name = opts?.parent ? manager.parentName || next : next\n if (!name) return\n setName(name)\n })\n }, [parent])\n\n return name\n}\n\nexport const useDefaultThemeName = () => {\n return useContext(ThemeContext)?.defaultTheme\n}\n\nexport const activeThemeManagers = new Set<ThemeManager>()\n\nexport const useChangeThemeEffect = (\n name?: string | null,\n componentName?: string,\n props?: ThemeProps,\n forceUpdateProp?: any,\n uuid?: Object\n): {\n themes: Record<string, ThemeParsed>\n themeManager: ThemeManager | null\n name: string\n theme: ThemeParsed | null\n className?: string\n} => {\n const config = getConfig()\n\n if (process.env.NODE_ENV === 'development') {\n if (!config) {\n throw new Error(\n `Missing tamagui config, you either have a duplicate config, or haven't set it up. Be sure createTamagui is called before renderig.`\n )\n }\n }\n\n const { themes } = config\n\n if (isRSC) {\n // we need context working for this to work well\n const parentManager = new ThemeManager('light', 'light', themes.light)\n const next = parentManager.getNextTheme({\n name,\n componentName,\n themes,\n reset: props?.reset,\n })\n return {\n ...next,\n themes,\n themeManager: null,\n }\n }\n\n const debug = props && props['debug']\n const parentManager = useContext(ThemeManagerContext) || emptyManager\n const reset = props?.reset || false\n const getThemeProps: GetNextThemeProps = {\n name,\n componentName,\n themes,\n reset,\n }\n const next = parentManager.getNextTheme(getThemeProps, debug)\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const forceUpdate = forceUpdateProp || useForceUpdate()\n\n const themeManager = useConstant(() => {\n return new ThemeManager(next.name, next.className, next.theme, parentManager, reset)\n })\n\n // not concurrent safe but fixes native (but breaks SSR and not needed on web (i think) so leave only on native)\n let didChange = false\n if (process.env.TAMAGUI_TARGET === 'native') {\n didChange = Boolean(\n next?.name !== themeManager.name || next?.className !== themeManager.className\n )\n if (didChange) {\n themeManager.update(next, false, false)\n }\n }\n\n if (!isServer) {\n useLayoutEffect(() => {\n themeManager.update(next, didChange)\n activeThemeManagers.add(themeManager)\n\n const disposeParentOnChange = parentManager.onChangeTheme(() => {\n const next = parentManager.getNextTheme(getThemeProps, debug)\n if (!next) return\n if (themeManager.update(next)) {\n if (uuid && !themeManager.isTracking(uuid)) {\n // no need to re-render if not tracking any keys\n return\n }\n if (process.env.NODE_ENV === 'development' && debug) {\n // eslint-disable-next-line no-console\n console.log('Changed theme', componentName, next, { props })\n }\n forceUpdate()\n }\n })\n\n return () => {\n activeThemeManagers.delete(themeManager)\n disposeParentOnChange()\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [didChange, themes, next?.name, next?.className, componentName, debug])\n }\n\n return {\n ...(parentManager && {\n name: parentManager.name,\n theme: parentManager.theme,\n }),\n ...next,\n className: next.className === parentManager.className ? undefined : next.className,\n themes,\n themeManager,\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,sBAAsB;AAC/B,SAAgB,YAAY,iBAAiB,SAAiB,gBAAgB;AAE9E,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAC3B,SAAS,OAAO,UAAU,iCAAiC;AAC3D,SAAS,oBAAoB;AAC7B,SAAS,oBAAoB;AAC7B;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,yBAAyB;AAClC,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAkBtB,MAAM,WAAW,CACtB,WACA,eACA,OACA,gBACgB;AAEhB,M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;AAAA,IACzE;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["name", "parentManager", "next"]
|
|
7
7
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -46,6 +46,7 @@ import {
|
|
|
46
46
|
getMedia,
|
|
47
47
|
mediaState,
|
|
48
48
|
useMedia,
|
|
49
|
+
useMediaPropsActive,
|
|
49
50
|
mediaObjectToString,
|
|
50
51
|
addMediaQueryListener,
|
|
51
52
|
removeMediaQueryListener,
|
|
@@ -85,6 +86,7 @@ export {
|
|
|
85
86
|
mediaState,
|
|
86
87
|
onConfiguredOnce,
|
|
87
88
|
removeMediaQueryListener,
|
|
88
|
-
useMedia
|
|
89
|
+
useMedia,
|
|
90
|
+
useMediaPropsActive
|
|
89
91
|
};
|
|
90
92
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './Tamagui'\nexport * from './createComponent'\nexport * from './createShorthands'\nexport * from './createTheme'\nexport * from './createTamagui'\nexport * from './createFont'\nexport * from './createTokens'\nexport * from './createVariable'\nexport * from './createVariables'\nexport * from './insertFont'\nexport * from './addTheme'\nexport * from './updateTheme'\nexport * from './styled'\nexport * from './types'\n\n// for type portability\nexport type { RNWTextProps, RNWViewProps } from './types-rnw'\nexport { getHasConfigured, getConfig, getThemes, getTokens, onConfiguredOnce } from './config'\n\nexport * from './constants/constants'\nexport * from './constants/platform'\nexport { createDOMProps } from '@tamagui/rnw'\n\nexport * from './helpers/calc'\nexport * from './helpers/useShallowSetState'\nexport * from './helpers/getStackSize'\nexport * from './helpers/getVariantExtras'\nexport * from './helpers/getAnimationDriver'\nexport * from './helpers/getExpandedShorthands'\nexport * from './helpers/getSize'\nexport * from './helpers/getSplitStyles'\nexport * from './helpers/getStylesAtomic'\nexport * from './helpers/pseudoDescriptors'\nexport * from './helpers/mergeProps'\nexport * from './helpers/expandStyles'\nexport * from './helpers/getFont'\nexport * from './helpers/isObj'\nexport * from './helpers/isTamaguiElement'\nexport * from './helpers/isTamaguiComponent'\nexport * from './helpers/matchMedia'\nexport * from './helpers/startTransition'\nexport * from './helpers/themeable'\nexport * from './helpers/withStaticProperties'\n\nexport * from './contexts/ButtonInsideButtonContext'\n\nexport * from './hooks/useConstant'\nexport * from './hooks/useId'\nexport * from './hooks/useIsMounted'\nexport * from './hooks/useIsTouchDevice'\nexport {\n configureMedia,\n getMedia,\n mediaState,\n useMedia,\n mediaObjectToString,\n addMediaQueryListener,\n removeMediaQueryListener,\n mediaQueryConfig,\n} from './hooks/useMedia'\nexport * from './hooks/usePressable'\nexport * from './hooks/useTheme'\nexport * from './hooks/useIsSSR'\nexport * from './hooks/useUnmountEffect'\nexport * from './hooks/useSafeRef'\n\nexport * from './views/Slot'\nexport * from './views/Stack'\nexport * from './views/Text'\nexport { TextAncestorProvider, TextAncestorContext } from './contexts/TextAncestorContext'\nexport * from './views/Theme'\nexport * from './views/ThemeInverse'\nexport * from './views/ThemeProvider'\nexport * from './views/ThemeReset'\nexport * from './views/FontLanguage'\nexport * from './views/TamaguiProvider'\n\nexport * from '@tamagui/use-force-update'\nexport * from '@tamagui/use-event'\nexport * from '@tamagui/helpers'\n"],
|
|
5
|
-
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAId,SAAS,kBAAkB,WAAW,WAAW,WAAW,wBAAwB;AAEpF,cAAc;AACd,cAAc;AACd,SAAS,sBAAsB;AAE/B,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,sBAAsB,2BAA2B;AAC1D,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
4
|
+
"sourcesContent": ["export * from './Tamagui'\nexport * from './createComponent'\nexport * from './createShorthands'\nexport * from './createTheme'\nexport * from './createTamagui'\nexport * from './createFont'\nexport * from './createTokens'\nexport * from './createVariable'\nexport * from './createVariables'\nexport * from './insertFont'\nexport * from './addTheme'\nexport * from './updateTheme'\nexport * from './styled'\nexport * from './types'\n\n// for type portability\nexport type { RNWTextProps, RNWViewProps } from './types-rnw'\nexport { getHasConfigured, getConfig, getThemes, getTokens, onConfiguredOnce } from './config'\n\nexport * from './constants/constants'\nexport * from './constants/platform'\nexport { createDOMProps } from '@tamagui/rnw'\n\nexport * from './helpers/calc'\nexport * from './helpers/useShallowSetState'\nexport * from './helpers/getStackSize'\nexport * from './helpers/getVariantExtras'\nexport * from './helpers/getAnimationDriver'\nexport * from './helpers/getExpandedShorthands'\nexport * from './helpers/getSize'\nexport * from './helpers/getSplitStyles'\nexport * from './helpers/getStylesAtomic'\nexport * from './helpers/pseudoDescriptors'\nexport * from './helpers/mergeProps'\nexport * from './helpers/expandStyles'\nexport * from './helpers/getFont'\nexport * from './helpers/isObj'\nexport * from './helpers/isTamaguiElement'\nexport * from './helpers/isTamaguiComponent'\nexport * from './helpers/matchMedia'\nexport * from './helpers/startTransition'\nexport * from './helpers/themeable'\nexport * from './helpers/withStaticProperties'\n\nexport * from './contexts/ButtonInsideButtonContext'\n\nexport * from './hooks/useConstant'\nexport * from './hooks/useId'\nexport * from './hooks/useIsMounted'\nexport * from './hooks/useIsTouchDevice'\nexport {\n configureMedia,\n getMedia,\n mediaState,\n useMedia,\n useMediaPropsActive,\n mediaObjectToString,\n addMediaQueryListener,\n removeMediaQueryListener,\n mediaQueryConfig,\n} from './hooks/useMedia'\nexport * from './hooks/usePressable'\nexport * from './hooks/useTheme'\nexport * from './hooks/useIsSSR'\nexport * from './hooks/useUnmountEffect'\nexport * from './hooks/useSafeRef'\n\nexport * from './views/Slot'\nexport * from './views/Stack'\nexport * from './views/Text'\nexport { TextAncestorProvider, TextAncestorContext } from './contexts/TextAncestorContext'\nexport * from './views/Theme'\nexport * from './views/ThemeInverse'\nexport * from './views/ThemeProvider'\nexport * from './views/ThemeReset'\nexport * from './views/FontLanguage'\nexport * from './views/TamaguiProvider'\n\nexport * from '@tamagui/use-force-update'\nexport * from '@tamagui/use-event'\nexport * from '@tamagui/helpers'\n"],
|
|
5
|
+
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAId,SAAS,kBAAkB,WAAW,WAAW,WAAW,wBAAwB;AAEpF,cAAc;AACd,cAAc;AACd,SAAS,sBAAsB;AAE/B,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,sBAAsB,2BAA2B;AAC1D,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/core",
|
|
3
|
-
"version": "1.0.1-beta.
|
|
3
|
+
"version": "1.0.1-beta.175",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -28,14 +28,14 @@
|
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@expo/match-media": "^0.3.0",
|
|
31
|
-
"@tamagui/compose-refs": "^1.0.1-beta.
|
|
32
|
-
"@tamagui/helpers": "^1.0.1-beta.
|
|
33
|
-
"@tamagui/normalize-css-color-lite": "^1.0.1-beta.
|
|
34
|
-
"@tamagui/rnw": "^1.0.1-beta.
|
|
35
|
-
"@tamagui/rnw-lite": "^1.0.1-beta.
|
|
36
|
-
"@tamagui/use-debounce": "^1.0.1-beta.
|
|
37
|
-
"@tamagui/use-event": "^1.0.1-beta.
|
|
38
|
-
"@tamagui/use-force-update": "^1.0.1-beta.
|
|
31
|
+
"@tamagui/compose-refs": "^1.0.1-beta.175",
|
|
32
|
+
"@tamagui/helpers": "^1.0.1-beta.175",
|
|
33
|
+
"@tamagui/normalize-css-color-lite": "^1.0.1-beta.175",
|
|
34
|
+
"@tamagui/rnw": "^1.0.1-beta.175",
|
|
35
|
+
"@tamagui/rnw-lite": "^1.0.1-beta.175",
|
|
36
|
+
"@tamagui/use-debounce": "^1.0.1-beta.175",
|
|
37
|
+
"@tamagui/use-event": "^1.0.1-beta.175",
|
|
38
|
+
"@tamagui/use-force-update": "^1.0.1-beta.175",
|
|
39
39
|
"expo-screen-orientation": "^4.3.0",
|
|
40
40
|
"hyphenate-style-name": "^1.0.4"
|
|
41
41
|
},
|
|
@@ -44,7 +44,8 @@
|
|
|
44
44
|
"react-dom": "*"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@tamagui/build": "^1.0.1-beta.
|
|
47
|
+
"@tamagui/build": "^1.0.1-beta.175",
|
|
48
|
+
"@types/node": "^16.11.9",
|
|
48
49
|
"@types/react": "^18.0.15",
|
|
49
50
|
"csstype": "^3.0.10",
|
|
50
51
|
"esbuild": "^0.15.6",
|
package/src/createComponent.tsx
CHANGED
|
@@ -709,6 +709,21 @@ export function createComponent<
|
|
|
709
709
|
fontFamily = fontFamily.slice(1)
|
|
710
710
|
}
|
|
711
711
|
|
|
712
|
+
if (process.env.NODE_ENV === 'development') {
|
|
713
|
+
if (fontFamily?.startsWith(`var(`)) {
|
|
714
|
+
// eslint-disable-next-line no-console
|
|
715
|
+
console.warn(
|
|
716
|
+
`Received variable instead of resolved name of font, this is a bug. Please report on Github.`,
|
|
717
|
+
{
|
|
718
|
+
fontFamily,
|
|
719
|
+
props,
|
|
720
|
+
splitStyles,
|
|
721
|
+
staticConfig,
|
|
722
|
+
}
|
|
723
|
+
)
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
|
|
712
727
|
const classList = [
|
|
713
728
|
componentName ? componentClassName : '',
|
|
714
729
|
fontFamily ? `font_${fontFamily}` : '',
|
|
@@ -89,7 +89,7 @@ export class ThemeManager {
|
|
|
89
89
|
return Boolean(this.keys.get(uuid)?.size)
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
update({ name, theme, className }: SetActiveThemeProps = {}, force = false) {
|
|
92
|
+
update({ name, theme, className }: SetActiveThemeProps = {}, force = false, notify = true) {
|
|
93
93
|
if (!force) {
|
|
94
94
|
// className compare on web, avoids light/dark re-renders
|
|
95
95
|
const nameChanged = name !== this.name
|
|
@@ -100,7 +100,9 @@ export class ThemeManager {
|
|
|
100
100
|
this.className = className || ''
|
|
101
101
|
this.name = name || ''
|
|
102
102
|
this.theme = theme
|
|
103
|
-
|
|
103
|
+
if (notify) {
|
|
104
|
+
this.notifyListeners()
|
|
105
|
+
}
|
|
104
106
|
return true
|
|
105
107
|
}
|
|
106
108
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getConfig } from '../config'
|
|
2
2
|
import { isDevTools } from '../constants/isDevTools'
|
|
3
3
|
import { isWeb } from '../constants/platform'
|
|
4
|
-
import { Variable, isVariable } from '../createVariable'
|
|
4
|
+
import { Variable, getVariableValue, isVariable } from '../createVariable'
|
|
5
5
|
import {
|
|
6
6
|
DebugProp,
|
|
7
7
|
GenericVariantDefinitions,
|
|
@@ -57,6 +57,7 @@ export const createPropMapper = (staticConfig: StaticConfigParsed) => {
|
|
|
57
57
|
props[conf.inverseShorthands.fontFamily] ||
|
|
58
58
|
props.fontFamily ||
|
|
59
59
|
defaultProps.fontFamily ||
|
|
60
|
+
propsIn.fontFamily ||
|
|
60
61
|
'$body'
|
|
61
62
|
|
|
62
63
|
const variantValue = resolveVariants(
|
|
@@ -72,7 +73,8 @@ export const createPropMapper = (staticConfig: StaticConfigParsed) => {
|
|
|
72
73
|
staticConfig,
|
|
73
74
|
'',
|
|
74
75
|
languageContext,
|
|
75
|
-
avoidDefaultProps
|
|
76
|
+
avoidDefaultProps,
|
|
77
|
+
debug
|
|
76
78
|
)
|
|
77
79
|
|
|
78
80
|
if (variantValue) {
|
|
@@ -100,7 +102,7 @@ export const createPropMapper = (staticConfig: StaticConfigParsed) => {
|
|
|
100
102
|
debug
|
|
101
103
|
)
|
|
102
104
|
} else if (isVariable(value)) {
|
|
103
|
-
value =
|
|
105
|
+
value = resolveVariableValue(key, value, returnVariablesAs)
|
|
104
106
|
}
|
|
105
107
|
}
|
|
106
108
|
|
|
@@ -146,7 +148,10 @@ const resolveVariants: StyleResolver = (
|
|
|
146
148
|
debug
|
|
147
149
|
) => {
|
|
148
150
|
const variant = variants && variants[key]
|
|
149
|
-
if (!variant || value === undefined)
|
|
151
|
+
if (!variant || value === undefined) {
|
|
152
|
+
return
|
|
153
|
+
}
|
|
154
|
+
|
|
150
155
|
let variantValue = getVariantDefinition(variant, key, value, conf)
|
|
151
156
|
|
|
152
157
|
if (!variantValue) {
|
|
@@ -176,7 +181,16 @@ const resolveVariants: StyleResolver = (
|
|
|
176
181
|
)
|
|
177
182
|
}
|
|
178
183
|
|
|
184
|
+
let fontFamilyResult: any
|
|
185
|
+
|
|
179
186
|
if (isObj(variantValue)) {
|
|
187
|
+
const fontFamilyUpdate =
|
|
188
|
+
variantValue.fontFamily || variantValue[conf.inverseShorthands.fontFamily]
|
|
189
|
+
|
|
190
|
+
if (fontFamilyUpdate) {
|
|
191
|
+
fontFamilyResult = getFontFamilyFromNameOrVariable(fontFamilyUpdate, conf)
|
|
192
|
+
}
|
|
193
|
+
|
|
180
194
|
variantValue = resolveTokensAndVariants(
|
|
181
195
|
key,
|
|
182
196
|
variantValue,
|
|
@@ -184,7 +198,7 @@ const resolveVariants: StyleResolver = (
|
|
|
184
198
|
defaultProps,
|
|
185
199
|
theme,
|
|
186
200
|
variants,
|
|
187
|
-
fontFamily,
|
|
201
|
+
fontFamilyResult || fontFamily,
|
|
188
202
|
conf,
|
|
189
203
|
returnVariablesAs,
|
|
190
204
|
staticConfig,
|
|
@@ -196,10 +210,56 @@ const resolveVariants: StyleResolver = (
|
|
|
196
210
|
}
|
|
197
211
|
|
|
198
212
|
if (variantValue) {
|
|
199
|
-
|
|
213
|
+
const next = Object.entries(expandStyles(variantValue))
|
|
214
|
+
|
|
215
|
+
// store any changed font family (only support variables for now)
|
|
216
|
+
if (fontFamilyResult && fontFamilyResult[0] === '$') {
|
|
217
|
+
fontFamilyCache.set(next, getVariableValue(fontFamilyResult))
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return next
|
|
200
221
|
}
|
|
201
222
|
}
|
|
202
223
|
|
|
224
|
+
// handles finding and resolving the fontFamily to the token name
|
|
225
|
+
// this is used as `font_[name]` in className for nice css variable support
|
|
226
|
+
export function getFontFamilyFromNameOrVariable(input: any, conf: TamaguiInternalConfig) {
|
|
227
|
+
if (isVariable(input)) {
|
|
228
|
+
const val = variableToFontNameCache.get(input)
|
|
229
|
+
if (val) {
|
|
230
|
+
return val
|
|
231
|
+
} else {
|
|
232
|
+
for (const key in conf.fontsParsed) {
|
|
233
|
+
const familyVariable = conf.fontsParsed[key].family
|
|
234
|
+
if (isVariable(familyVariable)) {
|
|
235
|
+
variableToFontNameCache.set(familyVariable, key)
|
|
236
|
+
if (familyVariable === input) {
|
|
237
|
+
return key
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
} else if (typeof input === 'string') {
|
|
243
|
+
if (input?.[0] === '$') {
|
|
244
|
+
return input
|
|
245
|
+
} else {
|
|
246
|
+
// this could be mapped back to
|
|
247
|
+
if (process.env.NODE_ENV === 'development') {
|
|
248
|
+
// eslint-disable-next-line no-console
|
|
249
|
+
console.log('[tamagui] should map back', input)
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const variableToFontNameCache = new WeakMap<Variable, string>()
|
|
256
|
+
|
|
257
|
+
// special helper for special font family
|
|
258
|
+
const fontFamilyCache = new WeakMap()
|
|
259
|
+
export const getPropMappedFontFamily = (expanded?: any) => {
|
|
260
|
+
return expanded && fontFamilyCache.get(expanded)
|
|
261
|
+
}
|
|
262
|
+
|
|
203
263
|
const resolveTokensAndVariants: StyleResolver = (
|
|
204
264
|
key, // we dont use key assume value is object instead
|
|
205
265
|
value,
|
|
@@ -220,6 +280,7 @@ const resolveTokensAndVariants: StyleResolver = (
|
|
|
220
280
|
for (const rKey in value) {
|
|
221
281
|
const fKey = conf.shorthands[rKey] || rKey
|
|
222
282
|
const val = value[rKey]
|
|
283
|
+
|
|
223
284
|
if (isVariable(val)) {
|
|
224
285
|
res[fKey] = !isWeb || returnVariablesAs === 'value' ? val.val : val.variable
|
|
225
286
|
} else if (variants[fKey]) {
|
|
@@ -385,7 +446,7 @@ const getToken = (
|
|
|
385
446
|
// eslint-disable-next-line no-console
|
|
386
447
|
console.log(` ﹒ propMapper getToken`, key, valOrVar)
|
|
387
448
|
}
|
|
388
|
-
return
|
|
449
|
+
return resolveVariableValue(key, valOrVar, resolveAs)
|
|
389
450
|
}
|
|
390
451
|
if (process.env.NODE_ENV === 'development') {
|
|
391
452
|
if (value && value[0] === '$') {
|
|
@@ -407,7 +468,7 @@ Set the debug prop to true to see more detailed debug information.`
|
|
|
407
468
|
return value
|
|
408
469
|
}
|
|
409
470
|
|
|
410
|
-
function
|
|
471
|
+
function resolveVariableValue(
|
|
411
472
|
key: string,
|
|
412
473
|
valOrVar: Variable | any,
|
|
413
474
|
resolveAs: ResolveVariableTypes = 'auto'
|
|
@@ -19,6 +19,7 @@ import type {
|
|
|
19
19
|
} from '../types'
|
|
20
20
|
import { FontLanguageProps, LanguageContextType } from '../views/FontLanguage.types'
|
|
21
21
|
import { createMediaStyle } from './createMediaStyle'
|
|
22
|
+
import { getPropMappedFontFamily } from './createPropMapper'
|
|
22
23
|
import { fixStyles } from './expandStyles'
|
|
23
24
|
import { getAtomicStyle, getStylesAtomic, styleToCSS } from './getStylesAtomic'
|
|
24
25
|
import {
|
|
@@ -149,10 +150,6 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
149
150
|
keyInit = expandedKey
|
|
150
151
|
}
|
|
151
152
|
|
|
152
|
-
if (keyInit === 'fontFamily' && fontFamily === undefined) {
|
|
153
|
-
fontFamily = valInit
|
|
154
|
-
}
|
|
155
|
-
|
|
156
153
|
if (usedKeys.has(keyInit)) continue
|
|
157
154
|
if (skipProps[keyInit]) continue
|
|
158
155
|
if (!isWeb && keyInit.startsWith('data-')) continue
|
|
@@ -280,6 +277,10 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
280
277
|
debug
|
|
281
278
|
)
|
|
282
279
|
|
|
280
|
+
if (!fontFamily) {
|
|
281
|
+
fontFamily = getPropMappedFontFamily(expanded)
|
|
282
|
+
}
|
|
283
|
+
|
|
283
284
|
if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
|
|
284
285
|
// eslint-disable-next-line no-console
|
|
285
286
|
console.log('expanded', expanded)
|
|
@@ -332,7 +333,12 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
332
333
|
languageContext,
|
|
333
334
|
true
|
|
334
335
|
)
|
|
335
|
-
|
|
336
|
+
|
|
337
|
+
pseudos[key] = {
|
|
338
|
+
...pseudoStyleObject,
|
|
339
|
+
...pseudos[key],
|
|
340
|
+
}
|
|
341
|
+
|
|
336
342
|
if (shouldDoClasses && key !== 'enterStyle' && key !== 'exitStyle') {
|
|
337
343
|
const pseudoStyles = getAtomicStyle(pseudoStyleObject, pseudoDescriptors[key])
|
|
338
344
|
for (const style of pseudoStyles) {
|
|
@@ -413,6 +419,7 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
413
419
|
Object.assign(medias, mediaStyle)
|
|
414
420
|
} else {
|
|
415
421
|
for (const key in mediaStyle) {
|
|
422
|
+
// TODO we should likely account for importance here to match CSS, right??
|
|
416
423
|
usedKeys.add(key)
|
|
417
424
|
style[key] = mediaStyle[key]
|
|
418
425
|
if (key === 'fontFamily') {
|
|
@@ -431,6 +438,10 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
431
438
|
continue
|
|
432
439
|
}
|
|
433
440
|
|
|
441
|
+
if (key === 'fontFamily' && !fontFamily && valInit && val) {
|
|
442
|
+
fontFamily = valInit[0] === '$' ? valInit : val
|
|
443
|
+
}
|
|
444
|
+
|
|
434
445
|
if (validStyleProps[key]) {
|
|
435
446
|
usedKeys.add(key)
|
|
436
447
|
if (val && val[0] === '_') {
|
package/src/hooks/useMedia.tsx
CHANGED
|
@@ -177,6 +177,60 @@ export function useMedia(): {
|
|
|
177
177
|
)
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
+
/**
|
|
181
|
+
* Useful for more complex components that need access to the currently active props,
|
|
182
|
+
* accounting for the currently active media queries.
|
|
183
|
+
*
|
|
184
|
+
* Use sparingly, is will loop props and trigger re-render on all media queries.
|
|
185
|
+
*
|
|
186
|
+
* */
|
|
187
|
+
export function useMediaPropsActive<A extends Object>(
|
|
188
|
+
props: A
|
|
189
|
+
): {
|
|
190
|
+
// remove all media
|
|
191
|
+
[Key in keyof A extends `$${string}` ? never : keyof A]: A[Key]
|
|
192
|
+
} {
|
|
193
|
+
const media = useMedia()
|
|
194
|
+
|
|
195
|
+
return useMemo(() => {
|
|
196
|
+
const evaluated = {} as A
|
|
197
|
+
const lastSetImportanceForKey = {}
|
|
198
|
+
const propNames = Object.keys(props)
|
|
199
|
+
const mediaKeysOrdered = Object.keys(getMedia())
|
|
200
|
+
|
|
201
|
+
function update(k: string, v: any, importance = 0) {
|
|
202
|
+
if (lastSetImportanceForKey[k] > importance) {
|
|
203
|
+
return
|
|
204
|
+
}
|
|
205
|
+
lastSetImportanceForKey[k] = importance
|
|
206
|
+
evaluated[k] = v
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
for (let i = propNames.length - 1; i >= 0; i--) {
|
|
210
|
+
const key = propNames[i]
|
|
211
|
+
const val = props[key]
|
|
212
|
+
if (key[0] === '$') {
|
|
213
|
+
const shortKey = key.slice(1)
|
|
214
|
+
if (!media[shortKey]) {
|
|
215
|
+
continue
|
|
216
|
+
}
|
|
217
|
+
if (val && typeof val === 'object') {
|
|
218
|
+
const subPropNames = Object.keys(val)
|
|
219
|
+
const mediaImportance = mediaKeysOrdered.indexOf(shortKey)
|
|
220
|
+
for (let j = subPropNames.length; j--; j >= 0) {
|
|
221
|
+
const skey = subPropNames[j]
|
|
222
|
+
update(skey, val[skey], mediaImportance)
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
} else {
|
|
226
|
+
update(key, val)
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return evaluated
|
|
231
|
+
}, [media, props])
|
|
232
|
+
}
|
|
233
|
+
|
|
180
234
|
function camelToHyphen(str: string) {
|
|
181
235
|
return str.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`).toLowerCase()
|
|
182
236
|
}
|
package/src/hooks/useTheme.tsx
CHANGED
|
@@ -201,7 +201,17 @@ export const useChangeThemeEffect = (
|
|
|
201
201
|
theme: ThemeParsed | null
|
|
202
202
|
className?: string
|
|
203
203
|
} => {
|
|
204
|
-
const
|
|
204
|
+
const config = getConfig()
|
|
205
|
+
|
|
206
|
+
if (process.env.NODE_ENV === 'development') {
|
|
207
|
+
if (!config) {
|
|
208
|
+
throw new Error(
|
|
209
|
+
`Missing tamagui config, you either have a duplicate config, or haven't set it up. Be sure createTamagui is called before renderig.`
|
|
210
|
+
)
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const { themes } = config
|
|
205
215
|
|
|
206
216
|
if (isRSC) {
|
|
207
217
|
// we need context working for this to work well
|
|
@@ -236,9 +246,20 @@ export const useChangeThemeEffect = (
|
|
|
236
246
|
return new ThemeManager(next.name, next.className, next.theme, parentManager, reset)
|
|
237
247
|
})
|
|
238
248
|
|
|
249
|
+
// not concurrent safe but fixes native (but breaks SSR and not needed on web (i think) so leave only on native)
|
|
250
|
+
let didChange = false
|
|
251
|
+
if (process.env.TAMAGUI_TARGET === 'native') {
|
|
252
|
+
didChange = Boolean(
|
|
253
|
+
next?.name !== themeManager.name || next?.className !== themeManager.className
|
|
254
|
+
)
|
|
255
|
+
if (didChange) {
|
|
256
|
+
themeManager.update(next, false, false)
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
239
260
|
if (!isServer) {
|
|
240
261
|
useLayoutEffect(() => {
|
|
241
|
-
themeManager.update(next)
|
|
262
|
+
themeManager.update(next, didChange)
|
|
242
263
|
activeThemeManagers.add(themeManager)
|
|
243
264
|
|
|
244
265
|
const disposeParentOnChange = parentManager.onChangeTheme(() => {
|
|
@@ -262,7 +283,7 @@ export const useChangeThemeEffect = (
|
|
|
262
283
|
disposeParentOnChange()
|
|
263
284
|
}
|
|
264
285
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
265
|
-
}, [themes, next?.name, next?.className, componentName, debug])
|
|
286
|
+
}, [didChange, themes, next?.name, next?.className, componentName, debug])
|
|
266
287
|
}
|
|
267
288
|
|
|
268
289
|
return {
|
package/src/index.ts
CHANGED
|
@@ -28,7 +28,7 @@ export declare class ThemeManager {
|
|
|
28
28
|
get fullName(): string;
|
|
29
29
|
getValue(key: string): import("..").Variable<import("..").VariableValue> | undefined;
|
|
30
30
|
isTracking(uuid: Object): boolean;
|
|
31
|
-
update({ name, theme, className }?: SetActiveThemeProps, force?: boolean): boolean;
|
|
31
|
+
update({ name, theme, className }?: SetActiveThemeProps, force?: boolean, notify?: boolean): boolean;
|
|
32
32
|
getNextTheme(props?: GetNextThemeProps, debug?: any): {
|
|
33
33
|
name: string;
|
|
34
34
|
theme: ThemeParsed | null;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { PropMapper, SplitStyleState, StaticConfigParsed } from '../types';
|
|
1
|
+
import { PropMapper, SplitStyleState, StaticConfigParsed, TamaguiInternalConfig } from '../types';
|
|
2
2
|
export declare type ResolveVariableTypes = 'auto' | 'value' | 'variable' | 'both' | 'non-color-value';
|
|
3
3
|
export declare const getReturnVariablesAs: (props: any, state: Partial<SplitStyleState>) => "auto" | "value" | "non-color-value";
|
|
4
4
|
export declare const createPropMapper: (staticConfig: StaticConfigParsed) => PropMapper;
|
|
5
|
+
export declare function getFontFamilyFromNameOrVariable(input: any, conf: TamaguiInternalConfig): string | undefined;
|
|
6
|
+
export declare const getPropMappedFontFamily: (expanded?: any) => any;
|
|
5
7
|
//# sourceMappingURL=createPropMapper.d.ts.map
|
|
@@ -11,6 +11,16 @@ export declare function useMediaQueryListeners(config: TamaguiInternalConfig): v
|
|
|
11
11
|
export declare function useMedia(): {
|
|
12
12
|
[key in MediaQueryKey]: boolean;
|
|
13
13
|
};
|
|
14
|
+
/**
|
|
15
|
+
* Useful for more complex components that need access to the currently active props,
|
|
16
|
+
* accounting for the currently active media queries.
|
|
17
|
+
*
|
|
18
|
+
* Use sparingly, is will loop props and trigger re-render on all media queries.
|
|
19
|
+
*
|
|
20
|
+
* */
|
|
21
|
+
export declare function useMediaPropsActive<A extends Object>(props: A): {
|
|
22
|
+
[Key in keyof A extends `$${string}` ? never : keyof A]: A[Key];
|
|
23
|
+
};
|
|
14
24
|
export declare function mediaObjectToString(query: string | MediaQueryObject): string;
|
|
15
25
|
export {};
|
|
16
26
|
//# sourceMappingURL=useMedia.d.ts.map
|
package/types/index.d.ts
CHANGED
|
@@ -42,7 +42,7 @@ export * from './hooks/useConstant';
|
|
|
42
42
|
export * from './hooks/useId';
|
|
43
43
|
export * from './hooks/useIsMounted';
|
|
44
44
|
export * from './hooks/useIsTouchDevice';
|
|
45
|
-
export { configureMedia, getMedia, mediaState, useMedia, mediaObjectToString, addMediaQueryListener, removeMediaQueryListener, mediaQueryConfig, } from './hooks/useMedia';
|
|
45
|
+
export { configureMedia, getMedia, mediaState, useMedia, useMediaPropsActive, mediaObjectToString, addMediaQueryListener, removeMediaQueryListener, mediaQueryConfig, } from './hooks/useMedia';
|
|
46
46
|
export * from './hooks/usePressable';
|
|
47
47
|
export * from './hooks/useTheme';
|
|
48
48
|
export * from './hooks/useIsSSR';
|