@tamagui/web 1.15.8 → 1.15.10

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.
Files changed (38) hide show
  1. package/dist/cjs/createComponent.js +2 -1
  2. package/dist/cjs/createComponent.js.map +2 -2
  3. package/dist/cjs/helpers/themeable.js +1 -1
  4. package/dist/cjs/helpers/themeable.js.map +2 -2
  5. package/dist/cjs/hooks/useTheme.js +3 -3
  6. package/dist/cjs/hooks/useTheme.js.map +2 -2
  7. package/dist/cjs/views/Theme.js +2 -2
  8. package/dist/cjs/views/Theme.js.map +2 -2
  9. package/dist/cjs/views/ThemeDebug.js +4 -1
  10. package/dist/cjs/views/ThemeDebug.js.map +2 -2
  11. package/dist/esm/createComponent.js +2 -1
  12. package/dist/esm/createComponent.js.map +2 -2
  13. package/dist/esm/createComponent.mjs +2 -1
  14. package/dist/esm/createComponent.mjs.map +2 -2
  15. package/dist/esm/helpers/themeable.js +1 -1
  16. package/dist/esm/helpers/themeable.js.map +2 -2
  17. package/dist/esm/helpers/themeable.mjs +1 -1
  18. package/dist/esm/helpers/themeable.mjs.map +2 -2
  19. package/dist/esm/hooks/useTheme.js +3 -3
  20. package/dist/esm/hooks/useTheme.js.map +2 -2
  21. package/dist/esm/hooks/useTheme.mjs +3 -3
  22. package/dist/esm/hooks/useTheme.mjs.map +2 -2
  23. package/dist/esm/views/Theme.js +2 -2
  24. package/dist/esm/views/Theme.js.map +2 -2
  25. package/dist/esm/views/Theme.mjs +2 -2
  26. package/dist/esm/views/Theme.mjs.map +2 -2
  27. package/dist/esm/views/ThemeDebug.js +4 -1
  28. package/dist/esm/views/ThemeDebug.js.map +2 -2
  29. package/dist/esm/views/ThemeDebug.mjs +4 -1
  30. package/dist/esm/views/ThemeDebug.mjs.map +2 -2
  31. package/package.json +9 -9
  32. package/src/createComponent.tsx +4 -1
  33. package/src/helpers/themeable.tsx +1 -1
  34. package/src/hooks/useTheme.tsx +3 -3
  35. package/src/views/Theme.tsx +2 -2
  36. package/src/views/ThemeDebug.tsx +6 -1
  37. package/types/createComponent.d.ts.map +1 -1
  38. package/types/views/ThemeDebug.d.ts.map +1 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/helpers/themeable.tsx"],
4
- "sourcesContent": ["import React, { forwardRef, useId } from 'react'\n\nimport { DebugProp, ThemeName } from '../types.js'\nimport { Theme } from '../views/Theme.js'\n\nexport interface ThemeableProps {\n theme?: ThemeName | null\n themeInverse?: boolean\n themeReset?: boolean\n componentName?: string\n debug?: DebugProp\n}\n\nexport function themeable<Component extends (props: any) => any>(\n component: Component,\n opts?: { componentName?: string }\n) {\n const withThemeComponent = forwardRef(function WithTheme(props: ThemeableProps, ref) {\n const { themeInverse, theme, componentName, themeReset, ...rest } = props\n const element = React.createElement(component, { ...rest, ref } as any)\n\n return (\n <Theme\n inverse={themeInverse}\n componentName={componentName || opts?.componentName}\n name={(theme as any) || null}\n data-themeable\n debug={props.debug}\n reset={props.themeReset}\n >\n {element}\n </Theme>\n )\n })\n\n const withTheme: any = withThemeComponent\n withTheme.displayName = `Themed(${\n (component as any)?.displayName || (component as any)?.name || 'Anonymous'\n })`\n\n return withTheme as Component extends (props: infer P) => infer R\n ? (props: Omit<P, 'theme' | 'themeInverse'> & ThemeableProps) => R\n : unknown\n}\n"],
5
- "mappings": "AAsBM;AAtBN,OAAO,SAAS,kBAAyB;AAGzC,SAAS,aAAa;AAUf,SAAS,UACd,WACA,MACA;AACA,QAAM,qBAAqB,WAAW,SAAS,UAAU,OAAuB,KAAK;AACnF,UAAM,EAAE,cAAc,OAAO,eAAe,YAAY,GAAG,KAAK,IAAI;AACpE,UAAM,UAAU,MAAM,cAAc,WAAW,EAAE,GAAG,MAAM,IAAI,CAAQ;AAEtE,WACE;AAAA,MAAC;AAAA;AAAA,QACC,SAAS;AAAA,QACT,eAAe,kBAAiB,6BAAM;AAAA,QACtC,MAAO,SAAiB;AAAA,QACxB,kBAAc;AAAA,QACd,OAAO,MAAM;AAAA,QACb,OAAO,MAAM;AAAA,QAEZ;AAAA;AAAA,IACH;AAAA,EAEJ,CAAC;AAED,QAAM,YAAiB;AACvB,YAAU,cAAc,WACrB,uCAAmB,iBAAgB,uCAAmB,SAAQ;AAGjE,SAAO;AAGT;",
4
+ "sourcesContent": ["import React, { forwardRef, useId } from 'react'\n\nimport { DebugProp, ThemeName } from '../types.js'\nimport { Theme } from '../views/Theme.js'\n\nexport interface ThemeableProps {\n theme?: ThemeName | null\n themeInverse?: boolean\n themeReset?: boolean\n componentName?: string\n debug?: DebugProp\n}\n\nexport function themeable<Component extends (props: any) => any>(\n component: Component,\n opts?: { componentName?: string }\n) {\n const withThemeComponent = forwardRef(function WithTheme(props: ThemeableProps, ref) {\n const { themeInverse, theme, componentName, themeReset, ...rest } = props\n const element = React.createElement(component, { ...rest, ref } as any)\n\n return (\n <Theme\n inverse={themeInverse}\n componentName={componentName || opts?.componentName}\n name={(theme as any) || null}\n disable-child-theme\n debug={props.debug}\n reset={props.themeReset}\n >\n {element}\n </Theme>\n )\n })\n\n const withTheme: any = withThemeComponent\n withTheme.displayName = `Themed(${\n (component as any)?.displayName || (component as any)?.name || 'Anonymous'\n })`\n\n return withTheme as Component extends (props: infer P) => infer R\n ? (props: Omit<P, 'theme' | 'themeInverse'> & ThemeableProps) => R\n : unknown\n}\n"],
5
+ "mappings": "AAsBM;AAtBN,OAAO,SAAS,kBAAyB;AAGzC,SAAS,aAAa;AAUf,SAAS,UACd,WACA,MACA;AACA,QAAM,qBAAqB,WAAW,SAAS,UAAU,OAAuB,KAAK;AACnF,UAAM,EAAE,cAAc,OAAO,eAAe,YAAY,GAAG,KAAK,IAAI;AACpE,UAAM,UAAU,MAAM,cAAc,WAAW,EAAE,GAAG,MAAM,IAAI,CAAQ;AAEtE,WACE;AAAA,MAAC;AAAA;AAAA,QACC,SAAS;AAAA,QACT,eAAe,kBAAiB,6BAAM;AAAA,QACtC,MAAO,SAAiB;AAAA,QACxB,uBAAmB;AAAA,QACnB,OAAO,MAAM;AAAA,QACb,OAAO,MAAM;AAAA,QAEZ;AAAA;AAAA,IACH;AAAA,EAEJ,CAAC;AAED,QAAM,YAAiB;AACvB,YAAU,cAAc,WACrB,uCAAmB,iBAAgB,uCAAmB,SAAQ;AAGjE,SAAO;AAGT;",
6
6
  "names": []
7
7
  }
@@ -126,13 +126,13 @@ const useChangeThemeEffect = (props, root = false, keys, disableUpdate) => {
126
126
  const { state, themeManager, mounted, isNewTheme } = themeState;
127
127
  const isInversingOnMount = Boolean(!themeState.mounted && props.inverse);
128
128
  const shouldReturnParentState = isInversingOnMount;
129
- function getShouldUpdateTheme(manager = themeManager, nextState, forceShouldChange = false) {
129
+ function getShouldUpdateTheme(manager = themeManager, nextState, prevState = state, forceShouldChange = false) {
130
130
  const next = nextState || manager.getState(props, parentManager);
131
131
  if (!next)
132
132
  return;
133
133
  if ((disableUpdate == null ? void 0 : disableUpdate()) === true)
134
134
  return;
135
- if (!forceShouldChange && !manager.getStateShouldChange(next, state))
135
+ if (!forceShouldChange && !manager.getStateShouldChange(next, prevState))
136
136
  return;
137
137
  return next;
138
138
  }
@@ -221,7 +221,7 @@ const useChangeThemeEffect = (props, root = false, keys, disableUpdate) => {
221
221
  themeManager2 = prev.themeManager;
222
222
  const forceChange = Boolean(keys == null ? void 0 : keys.length);
223
223
  const next = themeManager2.getState(props, parentManager);
224
- const nextState = getShouldUpdateTheme(themeManager2, next, forceChange);
224
+ const nextState = getShouldUpdateTheme(themeManager2, next, prev.state, forceChange);
225
225
  if (nextState) {
226
226
  state2 = nextState;
227
227
  if (!prev.isNewTheme || !isWeb) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/hooks/useTheme.tsx"],
4
- "sourcesContent": ["/* eslint-disable no-console */\nimport { isClient, isRSC, isServer, isWeb } from '@tamagui/constants'\nimport { useContext, useEffect, useLayoutEffect, useMemo, useState } from 'react'\n\nimport { getConfig } from '../config.js'\nimport { isDevTools } from '../constants/isDevTools.js'\nimport { isVariable } from '../createVariable.js'\nimport { createProxy } from '../helpers/createProxy.js'\nimport {\n ThemeManager,\n ThemeManagerState,\n getNonComponentParentManager,\n hasNoThemeUpdatingProps,\n} from '../helpers/ThemeManager.js'\nimport { ThemeManagerContext } from '../helpers/ThemeManagerContext.js'\nimport type { ThemeParsed, ThemeProps } from '../types.js'\nimport { GetThemeUnwrapped } from './getThemeUnwrapped.js'\nimport { useServerRef } from './useServerHooks.js'\n\nexport type ChangedThemeResponse = {\n isNewTheme: boolean\n themeManager: ThemeManager | null\n name: string\n theme?: ThemeParsed | null\n className?: string\n}\n\ntype State = {\n state: ThemeManagerState\n themeManager: ThemeManager\n isNewTheme: boolean\n mounted?: boolean\n}\n\nconst emptyProps = { name: null }\n\nfunction getDefaultThemeProxied() {\n const config = getConfig()\n const name = Object.keys(config.themes)[0]\n return getThemeProxied({\n theme: config.themes[name],\n name,\n })\n}\n\nexport const useTheme = (props: ThemeProps = emptyProps): ThemeParsed => {\n return (isRSC ? null : useThemeWithState(props)?.theme) || getDefaultThemeProxied()\n}\n\nexport const useThemeWithState = (props: ThemeProps) => {\n const keys = useServerRef<string[]>([])\n\n const changedTheme = useChangeThemeEffect(\n props,\n false,\n keys.current,\n isClient\n ? () => {\n return props.shouldUpdate?.() ?? keys.current.length === 0\n }\n : undefined\n )\n\n const { themeManager, theme, name, className } = changedTheme\n\n if (process.env.NODE_ENV === 'development' && props.debug === 'verbose') {\n console.groupCollapsed(' \uD83D\uDD39 useTheme =>', name)\n const logs = { ...props, name, className, ...(isDevTools && { theme }) }\n for (const key in logs) {\n console.log(' ', key, logs[key])\n }\n console.groupEnd()\n }\n\n if (!changedTheme.theme) {\n if (process.env.NODE_ENV === 'development') {\n console.warn('No theme found', name, props, themeManager)\n }\n return null\n }\n\n const proxiedTheme = useMemo(() => {\n return getThemeProxied(changedTheme as any, keys.current)\n }, [theme, name, className, themeManager])\n\n return {\n ...changedTheme,\n theme: proxiedTheme,\n }\n}\n\nexport function getThemeProxied(\n {\n theme,\n themeManager,\n }: Partial<ChangedThemeResponse> & {\n theme: ThemeParsed\n },\n keys?: string[]\n) {\n return createProxy(theme, {\n has(_, key) {\n if (typeof key === 'string') {\n if (key[0] === '$') key = key.slice(1)\n return themeManager?.allKeys.has(key)\n }\n return Reflect.has(theme, key)\n },\n get(_, key) {\n if (key === GetThemeUnwrapped) {\n return theme\n }\n if (\n key === '__proto__' ||\n key === '$typeof' ||\n typeof key !== 'string' ||\n !themeManager\n ) {\n return Reflect.get(_, key)\n }\n\n // auto convert variables to plain\n const keyString = key[0] === '$' ? key.slice(1) : key\n const val = themeManager.getValue(keyString)\n\n if (val && keys) {\n return new Proxy(val as any, {\n // when they touch the actual value we only track it\n // if its a variable (web), its ignored!\n get(_, subkey) {\n if (subkey === 'val' && !keys.includes(keyString)) {\n keys.push(keyString)\n }\n return Reflect.get(val as any, subkey)\n },\n })\n }\n\n return val\n },\n })\n}\n\nexport const activeThemeManagers = new Set<ThemeManager>()\n\nexport const useChangeThemeEffect = (\n props: ThemeProps,\n root = false,\n keys?: string[],\n disableUpdate?: () => boolean\n): ChangedThemeResponse => {\n if (isRSC) {\n // we need context working for this to work well\n return {\n isNewTheme: false,\n ...createState().state,\n themeManager: null,\n }\n }\n\n const {\n debug,\n // @ts-expect-error internal use only\n disable,\n } = props\n\n let parentManager = useContext(ThemeManagerContext)\n\n if (!disable) {\n parentManager = getNonComponentParentManager(parentManager)\n }\n\n if (disable) {\n if (!parentManager) throw `\u274C`\n return {\n isNewTheme: false,\n ...parentManager.state,\n themeManager: parentManager,\n }\n }\n\n const [themeState, setThemeState] = useState<State>(createState)\n const { state, themeManager, mounted, isNewTheme } = themeState\n const isInversingOnMount = Boolean(!themeState.mounted && props.inverse)\n const shouldReturnParentState = isInversingOnMount\n\n function getShouldUpdateTheme(\n manager = themeManager,\n nextState?: ThemeManagerState | null,\n forceShouldChange = false\n ) {\n const next = nextState || manager.getState(props, parentManager)\n if (!next) return\n if (disableUpdate?.() === true) return\n if (!forceShouldChange && !manager.getStateShouldChange(next, state)) return\n return next\n }\n\n if (!isServer) {\n useEffect(() => {\n // SSR safe inverse (because server can't know prefers scheme)\n // could be done through fancy selectors like how we do prefers-media\n // but may be a bit of explosion of selectors\n if (props.inverse && !mounted) {\n setThemeState({ ...themeState, mounted: true })\n return\n }\n\n if (!isNewTheme) return\n if (!themeManager) return\n\n activeThemeManagers.add(themeManager)\n\n return () => {\n activeThemeManagers.delete(themeManager)\n }\n }, [isNewTheme, themeManager, state])\n\n // listen for parent change + notify children change\n useLayoutEffect(() => {\n const nextState = getShouldUpdateTheme(themeManager)\n\n if (nextState) {\n if (isNewTheme) {\n // if it's a new theme we can just update + publish to children\n themeManager.updateState(nextState, true)\n }\n\n // if not we will be creating a whole new themeManager\n setThemeState(createState)\n } else {\n if (isNewTheme) {\n // need to revert to parent\n setThemeState(createState)\n }\n }\n\n const disposeChangeListener = parentManager?.onChangeTheme((name, manager) => {\n const shouldUpdate = Boolean(keys?.length || isNewTheme)\n if (shouldUpdate) {\n if (process.env.NODE_ENV === 'development' && props['debug']) {\n console.log(`onChangeTheme`, shouldUpdate, { props, name, manager, keys })\n }\n setThemeState(createState)\n }\n }, themeManager.id)\n\n return () => {\n disposeChangeListener?.()\n }\n }, [\n parentManager,\n isNewTheme,\n props.componentName,\n props.inverse,\n props.name,\n props.reset,\n ])\n\n if (process.env.NODE_ENV === 'development') {\n useEffect(() => {\n globalThis['TamaguiThemeManagers'] ??= new Set()\n globalThis['TamaguiThemeManagers'].add(themeManager)\n return () => {\n globalThis['TamaguiThemeManagers'].delete(themeManager)\n }\n }, [themeManager])\n }\n }\n\n if (shouldReturnParentState) {\n if (!parentManager) throw 'impossible'\n return {\n isNewTheme: false,\n ...parentManager.state,\n className: isInversingOnMount ? '' : parentManager.state.className,\n themeManager: parentManager,\n }\n }\n\n return {\n ...state,\n isNewTheme,\n themeManager,\n }\n\n function createState(prev?: State): State {\n if (prev && disableUpdate?.()) {\n return prev\n }\n\n // returns previous theme manager if no change\n let themeManager: ThemeManager\n let state: ThemeManagerState | undefined\n\n const getNewThemeManager = () => {\n return new ThemeManager(props, root ? 'root' : parentManager)\n }\n\n if (prev?.themeManager) {\n themeManager = prev.themeManager\n\n // this could be a bit better, problem is on toggling light/dark the state is actually\n // showing light even when the last was dark. but technically allso onChangeTheme should\n // basically always call on a change, so i'm wondering if we even need the shouldUpdate\n // at all anymore. this forces updates onChangeTheme for all dynamic style accessed components\n // which is correct, potentially in the future we can avoid forceChange and just know to\n // update if keys.length is set + onChangeTheme called\n const forceChange = Boolean(keys?.length)\n\n const next = themeManager.getState(props, parentManager)\n const nextState = getShouldUpdateTheme(themeManager, next, forceChange)\n\n if (nextState) {\n state = nextState\n\n if (!prev.isNewTheme || !isWeb) {\n themeManager = getNewThemeManager()\n } else {\n themeManager.updateState(nextState, true)\n }\n } else {\n if (prev.isNewTheme) {\n // reset to parent\n if (parentManager && !next) {\n themeManager = parentManager\n }\n }\n }\n } else {\n themeManager = getNewThemeManager()\n }\n\n const isNewTheme = Boolean(themeManager !== parentManager)\n\n // only inverse relies on this for ssr\n const mounted = !props.inverse ? true : root || prev?.mounted\n\n if (!state) {\n state = isNewTheme ? { ...themeManager.state } : { ...parentManager!.state }\n }\n\n const response = {\n state,\n themeManager,\n isNewTheme,\n mounted,\n }\n\n if (process.env.NODE_ENV === 'development' && props['debug']) {\n console.groupCollapsed(` \uD83D\uDD37 ${themeManager.id} useChangeThemeEffect createState`)\n const parentState = { ...parentManager?.state }\n const parentId = parentManager?.id\n const themeManagerState = { ...themeManager.state }\n console.log({\n props,\n parentState,\n parentId,\n themeManager,\n prev,\n response,\n themeManagerState,\n })\n console.groupEnd()\n }\n\n return response\n }\n}\n"],
5
- "mappings": "AACA,SAAS,UAAU,OAAO,UAAU,aAAa;AACjD,SAAS,YAAY,WAAW,iBAAiB,SAAS,gBAAgB;AAE1E,SAAS,iBAAiB;AAC1B,SAAS,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AACD,cAAQ,SAAS;AAAA,IACnB;AAEA,WAAO;AAAA,EACT;AACF;",
4
+ "sourcesContent": ["/* eslint-disable no-console */\nimport { isClient, isRSC, isServer, isWeb } from '@tamagui/constants'\nimport { useContext, useEffect, useLayoutEffect, useMemo, useState } from 'react'\n\nimport { getConfig } from '../config.js'\nimport { isDevTools } from '../constants/isDevTools.js'\nimport { isVariable } from '../createVariable.js'\nimport { createProxy } from '../helpers/createProxy.js'\nimport {\n ThemeManager,\n ThemeManagerState,\n getNonComponentParentManager,\n hasNoThemeUpdatingProps,\n} from '../helpers/ThemeManager.js'\nimport { ThemeManagerContext } from '../helpers/ThemeManagerContext.js'\nimport type { ThemeParsed, ThemeProps } from '../types.js'\nimport { GetThemeUnwrapped } from './getThemeUnwrapped.js'\nimport { useServerRef } from './useServerHooks.js'\n\nexport type ChangedThemeResponse = {\n isNewTheme: boolean\n themeManager: ThemeManager | null\n name: string\n theme?: ThemeParsed | null\n className?: string\n}\n\ntype State = {\n state: ThemeManagerState\n themeManager: ThemeManager\n isNewTheme: boolean\n mounted?: boolean\n}\n\nconst emptyProps = { name: null }\n\nfunction getDefaultThemeProxied() {\n const config = getConfig()\n const name = Object.keys(config.themes)[0]\n return getThemeProxied({\n theme: config.themes[name],\n name,\n })\n}\n\nexport const useTheme = (props: ThemeProps = emptyProps): ThemeParsed => {\n return (isRSC ? null : useThemeWithState(props)?.theme) || getDefaultThemeProxied()\n}\n\nexport const useThemeWithState = (props: ThemeProps) => {\n const keys = useServerRef<string[]>([])\n\n const changedTheme = useChangeThemeEffect(\n props,\n false,\n keys.current,\n isClient\n ? () => {\n return props.shouldUpdate?.() ?? keys.current.length === 0\n }\n : undefined\n )\n\n const { themeManager, theme, name, className } = changedTheme\n\n if (process.env.NODE_ENV === 'development' && props.debug === 'verbose') {\n console.groupCollapsed(' \uD83D\uDD39 useTheme =>', name)\n const logs = { ...props, name, className, ...(isDevTools && { theme }) }\n for (const key in logs) {\n console.log(' ', key, logs[key])\n }\n console.groupEnd()\n }\n\n if (!changedTheme.theme) {\n if (process.env.NODE_ENV === 'development') {\n console.warn('No theme found', name, props, themeManager)\n }\n return null\n }\n\n const proxiedTheme = useMemo(() => {\n return getThemeProxied(changedTheme as any, keys.current)\n }, [theme, name, className, themeManager])\n\n return {\n ...changedTheme,\n theme: proxiedTheme,\n }\n}\n\nexport function getThemeProxied(\n {\n theme,\n themeManager,\n }: Partial<ChangedThemeResponse> & {\n theme: ThemeParsed\n },\n keys?: string[]\n) {\n return createProxy(theme, {\n has(_, key) {\n if (typeof key === 'string') {\n if (key[0] === '$') key = key.slice(1)\n return themeManager?.allKeys.has(key)\n }\n return Reflect.has(theme, key)\n },\n get(_, key) {\n if (key === GetThemeUnwrapped) {\n return theme\n }\n if (\n key === '__proto__' ||\n key === '$typeof' ||\n typeof key !== 'string' ||\n !themeManager\n ) {\n return Reflect.get(_, key)\n }\n\n // auto convert variables to plain\n const keyString = key[0] === '$' ? key.slice(1) : key\n const val = themeManager.getValue(keyString)\n\n if (val && keys) {\n return new Proxy(val as any, {\n // when they touch the actual value we only track it\n // if its a variable (web), its ignored!\n get(_, subkey) {\n if (subkey === 'val' && !keys.includes(keyString)) {\n keys.push(keyString)\n }\n return Reflect.get(val as any, subkey)\n },\n })\n }\n\n return val\n },\n })\n}\n\nexport const activeThemeManagers = new Set<ThemeManager>()\n\nexport const useChangeThemeEffect = (\n props: ThemeProps,\n root = false,\n keys?: string[],\n disableUpdate?: () => boolean\n): ChangedThemeResponse => {\n if (isRSC) {\n // we need context working for this to work well\n return {\n isNewTheme: false,\n ...createState().state,\n themeManager: null,\n }\n }\n\n const {\n debug,\n // @ts-expect-error internal use only\n disable,\n } = props\n\n let parentManager = useContext(ThemeManagerContext)\n\n if (!disable) {\n parentManager = getNonComponentParentManager(parentManager)\n }\n\n if (disable) {\n if (!parentManager) throw `\u274C`\n return {\n isNewTheme: false,\n ...parentManager.state,\n themeManager: parentManager,\n }\n }\n\n const [themeState, setThemeState] = useState<State>(createState)\n const { state, themeManager, mounted, isNewTheme } = themeState\n const isInversingOnMount = Boolean(!themeState.mounted && props.inverse)\n const shouldReturnParentState = isInversingOnMount\n\n function getShouldUpdateTheme(\n manager = themeManager,\n nextState?: ThemeManagerState | null,\n prevState: ThemeManagerState = state,\n forceShouldChange = false\n ) {\n const next = nextState || manager.getState(props, parentManager)\n if (!next) return\n if (disableUpdate?.() === true) return\n if (!forceShouldChange && !manager.getStateShouldChange(next, prevState)) return\n return next\n }\n\n if (!isServer) {\n useEffect(() => {\n // SSR safe inverse (because server can't know prefers scheme)\n // could be done through fancy selectors like how we do prefers-media\n // but may be a bit of explosion of selectors\n if (props.inverse && !mounted) {\n setThemeState({ ...themeState, mounted: true })\n return\n }\n\n if (!isNewTheme) return\n if (!themeManager) return\n\n activeThemeManagers.add(themeManager)\n\n return () => {\n activeThemeManagers.delete(themeManager)\n }\n }, [isNewTheme, themeManager, state])\n\n // listen for parent change + notify children change\n useLayoutEffect(() => {\n const nextState = getShouldUpdateTheme(themeManager)\n\n if (nextState) {\n if (isNewTheme) {\n // if it's a new theme we can just update + publish to children\n themeManager.updateState(nextState, true)\n }\n\n // if not we will be creating a whole new themeManager\n setThemeState(createState)\n } else {\n if (isNewTheme) {\n // need to revert to parent\n setThemeState(createState)\n }\n }\n\n const disposeChangeListener = parentManager?.onChangeTheme((name, manager) => {\n const shouldUpdate = Boolean(keys?.length || isNewTheme)\n if (shouldUpdate) {\n if (process.env.NODE_ENV === 'development' && props['debug']) {\n console.log(`onChangeTheme`, shouldUpdate, { props, name, manager, keys })\n }\n setThemeState(createState)\n }\n }, themeManager.id)\n\n return () => {\n disposeChangeListener?.()\n }\n }, [\n parentManager,\n isNewTheme,\n props.componentName,\n props.inverse,\n props.name,\n props.reset,\n ])\n\n if (process.env.NODE_ENV === 'development') {\n useEffect(() => {\n globalThis['TamaguiThemeManagers'] ??= new Set()\n globalThis['TamaguiThemeManagers'].add(themeManager)\n return () => {\n globalThis['TamaguiThemeManagers'].delete(themeManager)\n }\n }, [themeManager])\n }\n }\n\n if (shouldReturnParentState) {\n if (!parentManager) throw 'impossible'\n return {\n isNewTheme: false,\n ...parentManager.state,\n className: isInversingOnMount ? '' : parentManager.state.className,\n themeManager: parentManager,\n }\n }\n\n return {\n ...state,\n isNewTheme,\n themeManager,\n }\n\n function createState(prev?: State): State {\n if (prev && disableUpdate?.()) {\n return prev\n }\n\n // returns previous theme manager if no change\n let themeManager: ThemeManager\n let state: ThemeManagerState | undefined\n\n const getNewThemeManager = () => {\n return new ThemeManager(props, root ? 'root' : parentManager)\n }\n\n if (prev?.themeManager) {\n themeManager = prev.themeManager\n\n // this could be a bit better, problem is on toggling light/dark the state is actually\n // showing light even when the last was dark. but technically allso onChangeTheme should\n // basically always call on a change, so i'm wondering if we even need the shouldUpdate\n // at all anymore. this forces updates onChangeTheme for all dynamic style accessed components\n // which is correct, potentially in the future we can avoid forceChange and just know to\n // update if keys.length is set + onChangeTheme called\n const forceChange = Boolean(keys?.length)\n const next = themeManager.getState(props, parentManager)\n const nextState = getShouldUpdateTheme(themeManager, next, prev.state, forceChange)\n\n if (nextState) {\n state = nextState\n\n if (!prev.isNewTheme || !isWeb) {\n themeManager = getNewThemeManager()\n } else {\n themeManager.updateState(nextState, true)\n }\n } else {\n if (prev.isNewTheme) {\n // reset to parent\n if (parentManager && !next) {\n themeManager = parentManager\n }\n }\n }\n } else {\n themeManager = getNewThemeManager()\n }\n\n const isNewTheme = Boolean(themeManager !== parentManager)\n\n // only inverse relies on this for ssr\n const mounted = !props.inverse ? true : root || prev?.mounted\n\n if (!state) {\n state = isNewTheme ? { ...themeManager.state } : { ...parentManager!.state }\n }\n\n const response = {\n state,\n themeManager,\n isNewTheme,\n mounted,\n }\n\n if (process.env.NODE_ENV === 'development' && props['debug']) {\n console.groupCollapsed(` \uD83D\uDD37 ${themeManager.id} useChangeThemeEffect createState`)\n const parentState = { ...parentManager?.state }\n const parentId = parentManager?.id\n const themeManagerState = { ...themeManager.state }\n console.log({\n props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AAqC;AAChF,YAAM,cAAc,EAAE,GAAG,+CAAe,MAAM;AAC9C,YAAM,WAAW,+CAAe;AAChC,YAAM,oBAAoB,EAAE,GAAGA,cAAa,MAAM;AAClD,cAAQ,IAAI;AAAA,QACV;AAAA,QACA;AAAA,QACA;AAAA,QACA,cAAAA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AACD,cAAQ,SAAS;AAAA,IACnB;AAEA,WAAO;AAAA,EACT;AACF;",
6
6
  "names": ["_", "themeManager", "state", "isNewTheme", "mounted"]
7
7
  }
@@ -126,13 +126,13 @@ const useChangeThemeEffect = (props, root = false, keys, disableUpdate) => {
126
126
  const { state, themeManager, mounted, isNewTheme } = themeState;
127
127
  const isInversingOnMount = Boolean(!themeState.mounted && props.inverse);
128
128
  const shouldReturnParentState = isInversingOnMount;
129
- function getShouldUpdateTheme(manager = themeManager, nextState, forceShouldChange = false) {
129
+ function getShouldUpdateTheme(manager = themeManager, nextState, prevState = state, forceShouldChange = false) {
130
130
  const next = nextState || manager.getState(props, parentManager);
131
131
  if (!next)
132
132
  return;
133
133
  if ((disableUpdate == null ? void 0 : disableUpdate()) === true)
134
134
  return;
135
- if (!forceShouldChange && !manager.getStateShouldChange(next, state))
135
+ if (!forceShouldChange && !manager.getStateShouldChange(next, prevState))
136
136
  return;
137
137
  return next;
138
138
  }
@@ -221,7 +221,7 @@ const useChangeThemeEffect = (props, root = false, keys, disableUpdate) => {
221
221
  themeManager2 = prev.themeManager;
222
222
  const forceChange = Boolean(keys == null ? void 0 : keys.length);
223
223
  const next = themeManager2.getState(props, parentManager);
224
- const nextState = getShouldUpdateTheme(themeManager2, next, forceChange);
224
+ const nextState = getShouldUpdateTheme(themeManager2, next, prev.state, forceChange);
225
225
  if (nextState) {
226
226
  state2 = nextState;
227
227
  if (!prev.isNewTheme || !isWeb) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/hooks/useTheme.tsx"],
4
- "sourcesContent": ["/* eslint-disable no-console */\nimport { isClient, isRSC, isServer, isWeb } from '@tamagui/constants'\nimport { useContext, useEffect, useLayoutEffect, useMemo, useState } from 'react'\n\nimport { getConfig } from '../config.js'\nimport { isDevTools } from '../constants/isDevTools.js'\nimport { isVariable } from '../createVariable.js'\nimport { createProxy } from '../helpers/createProxy.js'\nimport {\n ThemeManager,\n ThemeManagerState,\n getNonComponentParentManager,\n hasNoThemeUpdatingProps,\n} from '../helpers/ThemeManager.js'\nimport { ThemeManagerContext } from '../helpers/ThemeManagerContext.js'\nimport type { ThemeParsed, ThemeProps } from '../types.js'\nimport { GetThemeUnwrapped } from './getThemeUnwrapped.js'\nimport { useServerRef } from './useServerHooks.js'\n\nexport type ChangedThemeResponse = {\n isNewTheme: boolean\n themeManager: ThemeManager | null\n name: string\n theme?: ThemeParsed | null\n className?: string\n}\n\ntype State = {\n state: ThemeManagerState\n themeManager: ThemeManager\n isNewTheme: boolean\n mounted?: boolean\n}\n\nconst emptyProps = { name: null }\n\nfunction getDefaultThemeProxied() {\n const config = getConfig()\n const name = Object.keys(config.themes)[0]\n return getThemeProxied({\n theme: config.themes[name],\n name,\n })\n}\n\nexport const useTheme = (props: ThemeProps = emptyProps): ThemeParsed => {\n return (isRSC ? null : useThemeWithState(props)?.theme) || getDefaultThemeProxied()\n}\n\nexport const useThemeWithState = (props: ThemeProps) => {\n const keys = useServerRef<string[]>([])\n\n const changedTheme = useChangeThemeEffect(\n props,\n false,\n keys.current,\n isClient\n ? () => {\n return props.shouldUpdate?.() ?? keys.current.length === 0\n }\n : undefined\n )\n\n const { themeManager, theme, name, className } = changedTheme\n\n if (process.env.NODE_ENV === 'development' && props.debug === 'verbose') {\n console.groupCollapsed(' \uD83D\uDD39 useTheme =>', name)\n const logs = { ...props, name, className, ...(isDevTools && { theme }) }\n for (const key in logs) {\n console.log(' ', key, logs[key])\n }\n console.groupEnd()\n }\n\n if (!changedTheme.theme) {\n if (process.env.NODE_ENV === 'development') {\n console.warn('No theme found', name, props, themeManager)\n }\n return null\n }\n\n const proxiedTheme = useMemo(() => {\n return getThemeProxied(changedTheme as any, keys.current)\n }, [theme, name, className, themeManager])\n\n return {\n ...changedTheme,\n theme: proxiedTheme,\n }\n}\n\nexport function getThemeProxied(\n {\n theme,\n themeManager,\n }: Partial<ChangedThemeResponse> & {\n theme: ThemeParsed\n },\n keys?: string[]\n) {\n return createProxy(theme, {\n has(_, key) {\n if (typeof key === 'string') {\n if (key[0] === '$') key = key.slice(1)\n return themeManager?.allKeys.has(key)\n }\n return Reflect.has(theme, key)\n },\n get(_, key) {\n if (key === GetThemeUnwrapped) {\n return theme\n }\n if (\n key === '__proto__' ||\n key === '$typeof' ||\n typeof key !== 'string' ||\n !themeManager\n ) {\n return Reflect.get(_, key)\n }\n\n // auto convert variables to plain\n const keyString = key[0] === '$' ? key.slice(1) : key\n const val = themeManager.getValue(keyString)\n\n if (val && keys) {\n return new Proxy(val as any, {\n // when they touch the actual value we only track it\n // if its a variable (web), its ignored!\n get(_, subkey) {\n if (subkey === 'val' && !keys.includes(keyString)) {\n keys.push(keyString)\n }\n return Reflect.get(val as any, subkey)\n },\n })\n }\n\n return val\n },\n })\n}\n\nexport const activeThemeManagers = new Set<ThemeManager>()\n\nexport const useChangeThemeEffect = (\n props: ThemeProps,\n root = false,\n keys?: string[],\n disableUpdate?: () => boolean\n): ChangedThemeResponse => {\n if (isRSC) {\n // we need context working for this to work well\n return {\n isNewTheme: false,\n ...createState().state,\n themeManager: null,\n }\n }\n\n const {\n debug,\n // @ts-expect-error internal use only\n disable,\n } = props\n\n let parentManager = useContext(ThemeManagerContext)\n\n if (!disable) {\n parentManager = getNonComponentParentManager(parentManager)\n }\n\n if (disable) {\n if (!parentManager) throw `\u274C`\n return {\n isNewTheme: false,\n ...parentManager.state,\n themeManager: parentManager,\n }\n }\n\n const [themeState, setThemeState] = useState<State>(createState)\n const { state, themeManager, mounted, isNewTheme } = themeState\n const isInversingOnMount = Boolean(!themeState.mounted && props.inverse)\n const shouldReturnParentState = isInversingOnMount\n\n function getShouldUpdateTheme(\n manager = themeManager,\n nextState?: ThemeManagerState | null,\n forceShouldChange = false\n ) {\n const next = nextState || manager.getState(props, parentManager)\n if (!next) return\n if (disableUpdate?.() === true) return\n if (!forceShouldChange && !manager.getStateShouldChange(next, state)) return\n return next\n }\n\n if (!isServer) {\n useEffect(() => {\n // SSR safe inverse (because server can't know prefers scheme)\n // could be done through fancy selectors like how we do prefers-media\n // but may be a bit of explosion of selectors\n if (props.inverse && !mounted) {\n setThemeState({ ...themeState, mounted: true })\n return\n }\n\n if (!isNewTheme) return\n if (!themeManager) return\n\n activeThemeManagers.add(themeManager)\n\n return () => {\n activeThemeManagers.delete(themeManager)\n }\n }, [isNewTheme, themeManager, state])\n\n // listen for parent change + notify children change\n useLayoutEffect(() => {\n const nextState = getShouldUpdateTheme(themeManager)\n\n if (nextState) {\n if (isNewTheme) {\n // if it's a new theme we can just update + publish to children\n themeManager.updateState(nextState, true)\n }\n\n // if not we will be creating a whole new themeManager\n setThemeState(createState)\n } else {\n if (isNewTheme) {\n // need to revert to parent\n setThemeState(createState)\n }\n }\n\n const disposeChangeListener = parentManager?.onChangeTheme((name, manager) => {\n const shouldUpdate = Boolean(keys?.length || isNewTheme)\n if (shouldUpdate) {\n if (process.env.NODE_ENV === 'development' && props['debug']) {\n console.log(`onChangeTheme`, shouldUpdate, { props, name, manager, keys })\n }\n setThemeState(createState)\n }\n }, themeManager.id)\n\n return () => {\n disposeChangeListener?.()\n }\n }, [\n parentManager,\n isNewTheme,\n props.componentName,\n props.inverse,\n props.name,\n props.reset,\n ])\n\n if (process.env.NODE_ENV === 'development') {\n useEffect(() => {\n globalThis['TamaguiThemeManagers'] ??= new Set()\n globalThis['TamaguiThemeManagers'].add(themeManager)\n return () => {\n globalThis['TamaguiThemeManagers'].delete(themeManager)\n }\n }, [themeManager])\n }\n }\n\n if (shouldReturnParentState) {\n if (!parentManager) throw 'impossible'\n return {\n isNewTheme: false,\n ...parentManager.state,\n className: isInversingOnMount ? '' : parentManager.state.className,\n themeManager: parentManager,\n }\n }\n\n return {\n ...state,\n isNewTheme,\n themeManager,\n }\n\n function createState(prev?: State): State {\n if (prev && disableUpdate?.()) {\n return prev\n }\n\n // returns previous theme manager if no change\n let themeManager: ThemeManager\n let state: ThemeManagerState | undefined\n\n const getNewThemeManager = () => {\n return new ThemeManager(props, root ? 'root' : parentManager)\n }\n\n if (prev?.themeManager) {\n themeManager = prev.themeManager\n\n // this could be a bit better, problem is on toggling light/dark the state is actually\n // showing light even when the last was dark. but technically allso onChangeTheme should\n // basically always call on a change, so i'm wondering if we even need the shouldUpdate\n // at all anymore. this forces updates onChangeTheme for all dynamic style accessed components\n // which is correct, potentially in the future we can avoid forceChange and just know to\n // update if keys.length is set + onChangeTheme called\n const forceChange = Boolean(keys?.length)\n\n const next = themeManager.getState(props, parentManager)\n const nextState = getShouldUpdateTheme(themeManager, next, forceChange)\n\n if (nextState) {\n state = nextState\n\n if (!prev.isNewTheme || !isWeb) {\n themeManager = getNewThemeManager()\n } else {\n themeManager.updateState(nextState, true)\n }\n } else {\n if (prev.isNewTheme) {\n // reset to parent\n if (parentManager && !next) {\n themeManager = parentManager\n }\n }\n }\n } else {\n themeManager = getNewThemeManager()\n }\n\n const isNewTheme = Boolean(themeManager !== parentManager)\n\n // only inverse relies on this for ssr\n const mounted = !props.inverse ? true : root || prev?.mounted\n\n if (!state) {\n state = isNewTheme ? { ...themeManager.state } : { ...parentManager!.state }\n }\n\n const response = {\n state,\n themeManager,\n isNewTheme,\n mounted,\n }\n\n if (process.env.NODE_ENV === 'development' && props['debug']) {\n console.groupCollapsed(` \uD83D\uDD37 ${themeManager.id} useChangeThemeEffect createState`)\n const parentState = { ...parentManager?.state }\n const parentId = parentManager?.id\n const themeManagerState = { ...themeManager.state }\n console.log({\n props,\n parentState,\n parentId,\n themeManager,\n prev,\n response,\n themeManagerState,\n })\n console.groupEnd()\n }\n\n return response\n }\n}\n"],
5
- "mapp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;AAClD,cAAQ,IAAI;AAAA,QACV;AAAA,QACA;AAAA,QACA;AAAA,QACA,cAAAA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AACD,cAAQ,SAAS;AAAA,IACnB;AAEA,WAAO;AAAA,EACT;AACF;",
4
+ "sourcesContent": ["/* eslint-disable no-console */\nimport { isClient, isRSC, isServer, isWeb } from '@tamagui/constants'\nimport { useContext, useEffect, useLayoutEffect, useMemo, useState } from 'react'\n\nimport { getConfig } from '../config.js'\nimport { isDevTools } from '../constants/isDevTools.js'\nimport { isVariable } from '../createVariable.js'\nimport { createProxy } from '../helpers/createProxy.js'\nimport {\n ThemeManager,\n ThemeManagerState,\n getNonComponentParentManager,\n hasNoThemeUpdatingProps,\n} from '../helpers/ThemeManager.js'\nimport { ThemeManagerContext } from '../helpers/ThemeManagerContext.js'\nimport type { ThemeParsed, ThemeProps } from '../types.js'\nimport { GetThemeUnwrapped } from './getThemeUnwrapped.js'\nimport { useServerRef } from './useServerHooks.js'\n\nexport type ChangedThemeResponse = {\n isNewTheme: boolean\n themeManager: ThemeManager | null\n name: string\n theme?: ThemeParsed | null\n className?: string\n}\n\ntype State = {\n state: ThemeManagerState\n themeManager: ThemeManager\n isNewTheme: boolean\n mounted?: boolean\n}\n\nconst emptyProps = { name: null }\n\nfunction getDefaultThemeProxied() {\n const config = getConfig()\n const name = Object.keys(config.themes)[0]\n return getThemeProxied({\n theme: config.themes[name],\n name,\n })\n}\n\nexport const useTheme = (props: ThemeProps = emptyProps): ThemeParsed => {\n return (isRSC ? null : useThemeWithState(props)?.theme) || getDefaultThemeProxied()\n}\n\nexport const useThemeWithState = (props: ThemeProps) => {\n const keys = useServerRef<string[]>([])\n\n const changedTheme = useChangeThemeEffect(\n props,\n false,\n keys.current,\n isClient\n ? () => {\n return props.shouldUpdate?.() ?? keys.current.length === 0\n }\n : undefined\n )\n\n const { themeManager, theme, name, className } = changedTheme\n\n if (process.env.NODE_ENV === 'development' && props.debug === 'verbose') {\n console.groupCollapsed(' \uD83D\uDD39 useTheme =>', name)\n const logs = { ...props, name, className, ...(isDevTools && { theme }) }\n for (const key in logs) {\n console.log(' ', key, logs[key])\n }\n console.groupEnd()\n }\n\n if (!changedTheme.theme) {\n if (process.env.NODE_ENV === 'development') {\n console.warn('No theme found', name, props, themeManager)\n }\n return null\n }\n\n const proxiedTheme = useMemo(() => {\n return getThemeProxied(changedTheme as any, keys.current)\n }, [theme, name, className, themeManager])\n\n return {\n ...changedTheme,\n theme: proxiedTheme,\n }\n}\n\nexport function getThemeProxied(\n {\n theme,\n themeManager,\n }: Partial<ChangedThemeResponse> & {\n theme: ThemeParsed\n },\n keys?: string[]\n) {\n return createProxy(theme, {\n has(_, key) {\n if (typeof key === 'string') {\n if (key[0] === '$') key = key.slice(1)\n return themeManager?.allKeys.has(key)\n }\n return Reflect.has(theme, key)\n },\n get(_, key) {\n if (key === GetThemeUnwrapped) {\n return theme\n }\n if (\n key === '__proto__' ||\n key === '$typeof' ||\n typeof key !== 'string' ||\n !themeManager\n ) {\n return Reflect.get(_, key)\n }\n\n // auto convert variables to plain\n const keyString = key[0] === '$' ? key.slice(1) : key\n const val = themeManager.getValue(keyString)\n\n if (val && keys) {\n return new Proxy(val as any, {\n // when they touch the actual value we only track it\n // if its a variable (web), its ignored!\n get(_, subkey) {\n if (subkey === 'val' && !keys.includes(keyString)) {\n keys.push(keyString)\n }\n return Reflect.get(val as any, subkey)\n },\n })\n }\n\n return val\n },\n })\n}\n\nexport const activeThemeManagers = new Set<ThemeManager>()\n\nexport const useChangeThemeEffect = (\n props: ThemeProps,\n root = false,\n keys?: string[],\n disableUpdate?: () => boolean\n): ChangedThemeResponse => {\n if (isRSC) {\n // we need context working for this to work well\n return {\n isNewTheme: false,\n ...createState().state,\n themeManager: null,\n }\n }\n\n const {\n debug,\n // @ts-expect-error internal use only\n disable,\n } = props\n\n let parentManager = useContext(ThemeManagerContext)\n\n if (!disable) {\n parentManager = getNonComponentParentManager(parentManager)\n }\n\n if (disable) {\n if (!parentManager) throw `\u274C`\n return {\n isNewTheme: false,\n ...parentManager.state,\n themeManager: parentManager,\n }\n }\n\n const [themeState, setThemeState] = useState<State>(createState)\n const { state, themeManager, mounted, isNewTheme } = themeState\n const isInversingOnMount = Boolean(!themeState.mounted && props.inverse)\n const shouldReturnParentState = isInversingOnMount\n\n function getShouldUpdateTheme(\n manager = themeManager,\n nextState?: ThemeManagerState | null,\n prevState: ThemeManagerState = state,\n forceShouldChange = false\n ) {\n const next = nextState || manager.getState(props, parentManager)\n if (!next) return\n if (disableUpdate?.() === true) return\n if (!forceShouldChange && !manager.getStateShouldChange(next, prevState)) return\n return next\n }\n\n if (!isServer) {\n useEffect(() => {\n // SSR safe inverse (because server can't know prefers scheme)\n // could be done through fancy selectors like how we do prefers-media\n // but may be a bit of explosion of selectors\n if (props.inverse && !mounted) {\n setThemeState({ ...themeState, mounted: true })\n return\n }\n\n if (!isNewTheme) return\n if (!themeManager) return\n\n activeThemeManagers.add(themeManager)\n\n return () => {\n activeThemeManagers.delete(themeManager)\n }\n }, [isNewTheme, themeManager, state])\n\n // listen for parent change + notify children change\n useLayoutEffect(() => {\n const nextState = getShouldUpdateTheme(themeManager)\n\n if (nextState) {\n if (isNewTheme) {\n // if it's a new theme we can just update + publish to children\n themeManager.updateState(nextState, true)\n }\n\n // if not we will be creating a whole new themeManager\n setThemeState(createState)\n } else {\n if (isNewTheme) {\n // need to revert to parent\n setThemeState(createState)\n }\n }\n\n const disposeChangeListener = parentManager?.onChangeTheme((name, manager) => {\n const shouldUpdate = Boolean(keys?.length || isNewTheme)\n if (shouldUpdate) {\n if (process.env.NODE_ENV === 'development' && props['debug']) {\n console.log(`onChangeTheme`, shouldUpdate, { props, name, manager, keys })\n }\n setThemeState(createState)\n }\n }, themeManager.id)\n\n return () => {\n disposeChangeListener?.()\n }\n }, [\n parentManager,\n isNewTheme,\n props.componentName,\n props.inverse,\n props.name,\n props.reset,\n ])\n\n if (process.env.NODE_ENV === 'development') {\n useEffect(() => {\n globalThis['TamaguiThemeManagers'] ??= new Set()\n globalThis['TamaguiThemeManagers'].add(themeManager)\n return () => {\n globalThis['TamaguiThemeManagers'].delete(themeManager)\n }\n }, [themeManager])\n }\n }\n\n if (shouldReturnParentState) {\n if (!parentManager) throw 'impossible'\n return {\n isNewTheme: false,\n ...parentManager.state,\n className: isInversingOnMount ? '' : parentManager.state.className,\n themeManager: parentManager,\n }\n }\n\n return {\n ...state,\n isNewTheme,\n themeManager,\n }\n\n function createState(prev?: State): State {\n if (prev && disableUpdate?.()) {\n return prev\n }\n\n // returns previous theme manager if no change\n let themeManager: ThemeManager\n let state: ThemeManagerState | undefined\n\n const getNewThemeManager = () => {\n return new ThemeManager(props, root ? 'root' : parentManager)\n }\n\n if (prev?.themeManager) {\n themeManager = prev.themeManager\n\n // this could be a bit better, problem is on toggling light/dark the state is actually\n // showing light even when the last was dark. but technically allso onChangeTheme should\n // basically always call on a change, so i'm wondering if we even need the shouldUpdate\n // at all anymore. this forces updates onChangeTheme for all dynamic style accessed components\n // which is correct, potentially in the future we can avoid forceChange and just know to\n // update if keys.length is set + onChangeTheme called\n const forceChange = Boolean(keys?.length)\n const next = themeManager.getState(props, parentManager)\n const nextState = getShouldUpdateTheme(themeManager, next, prev.state, forceChange)\n\n if (nextState) {\n state = nextState\n\n if (!prev.isNewTheme || !isWeb) {\n themeManager = getNewThemeManager()\n } else {\n themeManager.updateState(nextState, true)\n }\n } else {\n if (prev.isNewTheme) {\n // reset to parent\n if (parentManager && !next) {\n themeManager = parentManager\n }\n }\n }\n } else {\n themeManager = getNewThemeManager()\n }\n\n const isNewTheme = Boolean(themeManager !== parentManager)\n\n // only inverse relies on this for ssr\n const mounted = !props.inverse ? true : root || prev?.mounted\n\n if (!state) {\n state = isNewTheme ? { ...themeManager.state } : { ...parentManager!.state }\n }\n\n const response = {\n state,\n themeManager,\n isNewTheme,\n mounted,\n }\n\n if (process.env.NODE_ENV === 'development' && props['debug']) {\n console.groupCollapsed(` \uD83D\uDD37 ${themeManager.id} useChangeThemeEffect createState`)\n const parentState = { ...parentManager?.state }\n const parentId = parentManager?.id\n const themeManagerState = { ...themeManager.state }\n console.log({\n props,\n parentState,\n parentId,\n themeManager,\n prev,\n response,\n themeManagerState,\n })\n console.groupEnd()\n }\n\n return response\n }\n}\n"],
5
+ "mappings": "AACA,SAAS,UAAU,OAAO,UAAU,aAAa;AACjD,SAAS,YAAY,WAAW,iBAAiB,SAAS,gBAAgB;AAE1E,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAE3B,SAAS,mBAAmB;AAC5B;AAAA,EACE;AAAA,EAEA;AAAA,OAEK;AACP,SAAS,2BAA2B;AAEpC,SAAS,yBAAyB;AAClC,SAAS,oBAAoB;AAiB7B,MAAM,aAAa,EAAE,MAAM,KAAK;AAEhC,SAAS,yBAAyB;AAChC,QAAM,SAAS,UAAU;AACzB,QAAM,OAAO,OAAO,KAAK,OAAO,MAAM,EAAE,CAAC;AACzC,SAAO,gBAAgB;AAAA,IACrB,OAAO,OAAO,OAAO,IAAI;AAAA,IACzB;AAAA,EACF,CAAC;AACH;AAEO,MAAM,WAAW,CAAC,QAAoB,eAA4B;AA7CzE;AA8CE,UAAQ,QAAQ,QAAO,uBAAkB,KAAK,MAAvB,mBAA0B,UAAU,uBAAuB;AACpF;AAEO,MAAM,oBAAoB,CAAC,UAAsB;AACtD,QAAM,OAAO,aAAuB,CAAC,CAAC;AAEtC,QAAM,eAAe;AAAA,IACnB;AAAA,IACA;AAAA,IACA,KAAK;AAAA,IACL,WACI,MAAM;AAzDd;AA0DU,eAAO,WAAM,iBAAN,mCAA0B,KAAK,QAAQ,WAAW;AAAA,IAC3D,IACA;AAAA,EACN;AAEA,QAAM,EAAE,cAAc,OAAO,MAAM,UAAU,IAAI;AAEjD,MAAI,QAAQ,IAAI,aAAa,iBAAiB,MAAM,UAAU,WAAW;AACvE,YAAQ,eAAe,2BAAoB,IAAI;AAC/C,UAAM,OAAO,EAAE,GA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AA,MACA,SAAAC;AAAA,IACF;AAEA,QAAI,QAAQ,IAAI,aAAa,iBAAiB,MAAM,OAAO,GAAG;AAC5D,cAAQ,eAAe,cAAOH,cAAa,qCAAqC;AAChF,YAAM,cAAc,EAAE,GAAG,+CAAe,MAAM;AAC9C,YAAM,WAAW,+CAAe;AAChC,YAAM,oBAAoB,EAAE,GAAGA,cAAa,MAAM;AAClD,cAAQ,IAAI;AAAA,QACV;AAAA,QACA;AAAA,QACA;AAAA,QACA,cAAAA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AACD,cAAQ,SAAS;AAAA,IACnB;AAEA,WAAO;AAAA,EACT;AACF;",
6
6
  "names": ["_", "themeManager", "state", "isNewTheme", "mounted"]
7
7
  }
@@ -12,9 +12,9 @@ function Theme(props) {
12
12
  }
13
13
  const isRoot = !!props["_isRoot"];
14
14
  const themeState = useChangeThemeEffect(props, isRoot);
15
- let children = props["data-themeable"] ? Children.map(
15
+ let children = props["disable-child-theme"] ? Children.map(
16
16
  props.children,
17
- (child) => cloneElement(child, { ["data-themeable"]: true })
17
+ (child) => cloneElement(child, { ["data-disable-theme"]: true })
18
18
  ) : props.children;
19
19
  if (process.env.NODE_ENV === "development") {
20
20
  if (props["debug"] === "visualize") {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/views/Theme.tsx"],
4
- "sourcesContent": ["import { isWeb } from '@tamagui/constants'\nimport { Children, cloneElement, isValidElement, useEffect, useId, useMemo } from 'react'\n\nimport { variableToString } from '../createVariable.js'\nimport { ThemeManagerContext } from '../helpers/ThemeManagerContext.js'\nimport { useServerRef } from '../hooks/useServerHooks.js'\nimport { ChangedThemeResponse, useChangeThemeEffect } from '../hooks/useTheme.js'\nimport type { DebugProp, ThemeProps } from '../types.js'\nimport { ThemeDebug } from './ThemeDebug'\n\nexport function Theme(props: ThemeProps) {\n // @ts-expect-error only for internal views\n if (props.disable) {\n return props.children\n }\n\n const isRoot = !!props['_isRoot']\n const themeState = useChangeThemeEffect(props, isRoot)\n\n let children = props['data-themeable']\n ? Children.map(props.children, (child) =>\n cloneElement(child, { ['data-themeable']: true })\n )\n : props.children\n\n if (process.env.NODE_ENV === 'development') {\n if (props['debug'] === 'visualize') {\n children = (\n <ThemeDebug themeState={themeState} themeProps={props}>\n {children}\n </ThemeDebug>\n )\n }\n }\n\n return useThemedChildren(themeState, children, props, isRoot)\n}\n\nexport function useThemedChildren(\n themeState: ChangedThemeResponse,\n children: any,\n props: {\n forceClassName?: boolean\n shallow?: boolean\n passPropsToChildren?: boolean\n debug?: DebugProp\n },\n isRoot = false\n) {\n const { themeManager, className, theme, isNewTheme } = themeState\n const { shallow, forceClassName } = props\n const hasEverThemed = useServerRef(false)\n if (isNewTheme) {\n hasEverThemed.current = true\n }\n\n const shouldRenderChildrenWithTheme =\n isNewTheme || hasEverThemed.current || forceClassName || isRoot\n\n return useMemo(() => {\n if (!shouldRenderChildrenWithTheme) {\n return children\n }\n\n // be sure to memoize shouldReset to avoid reparenting\n let next = Children.toArray(children)\n\n // each children of these children wont get the theme\n if (shallow && themeManager) {\n next = next.map((child) => {\n return isValidElement(child)\n ? cloneElement(\n child,\n undefined,\n <Theme name={themeManager.state.parentName}>\n {(child as any).props.children}\n </Theme>\n )\n : child\n })\n }\n\n const wrapped = (\n <ThemeManagerContext.Provider value={themeManager}>\n {next}\n </ThemeManagerContext.Provider>\n )\n\n if (forceClassName === false) {\n return wrapped\n }\n\n if (isWeb && !props.passPropsToChildren) {\n // in order to provide currentColor, set color by default\n const themeColor = theme && isNewTheme ? variableToString(theme.color) : ''\n const colorStyle = {\n color: themeColor,\n }\n\n return (\n <span className={`${className || ''} _dsp_contents is_Theme`} style={colorStyle}>\n {wrapped}\n </span>\n )\n }\n\n return wrapped\n }, [\n forceClassName,\n props.passPropsToChildren,\n shouldRenderChildrenWithTheme,\n themeManager,\n children,\n theme,\n isNewTheme,\n className,\n ])\n}\n"],
5
- "mappings": "AA4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MAAM,UACxB;AAAA,QACF,IACA;AAAA,MACN,CAAC;AAAA,IACH;AAEA,UAAM,UACJ,oBAAC,oBAAoB,UAApB,EAA6B,OAAO,cAClC,gBACH;AAGF,QAAI,mBAAmB,OAAO;AAC5B,aAAO;AAAA,IACT;AAEA,QAAI,SAAS,CAAC,MAAM,qBAAqB;AAEvC,YAAM,aAAa,SAAS,aAAa,iBAAiB,MAAM,KAAK,IAAI;AACzE,YAAM,aAAa;AAAA,QACjB,OAAO;AAAA,MACT;AAEA,aACE,oBAAC,UAAK,WAAW,GAAG,aAAa,6BAA6B,OAAO,YAClE,mBACH;AAAA,IAEJ;AAEA,WAAO;AAAA,EACT,GAAG;AAAA,IACD;AAAA,IACA,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;",
4
+ "sourcesContent": ["import { isWeb } from '@tamagui/constants'\nimport { Children, cloneElement, isValidElement, useEffect, useId, useMemo } from 'react'\n\nimport { variableToString } from '../createVariable.js'\nimport { ThemeManagerContext } from '../helpers/ThemeManagerContext.js'\nimport { useServerRef } from '../hooks/useServerHooks.js'\nimport { ChangedThemeResponse, useChangeThemeEffect } from '../hooks/useTheme.js'\nimport type { DebugProp, ThemeProps } from '../types.js'\nimport { ThemeDebug } from './ThemeDebug'\n\nexport function Theme(props: ThemeProps) {\n // @ts-expect-error only for internal views\n if (props.disable) {\n return props.children\n }\n\n const isRoot = !!props['_isRoot']\n const themeState = useChangeThemeEffect(props, isRoot)\n\n let children = props['disable-child-theme']\n ? Children.map(props.children, (child) =>\n cloneElement(child, { ['data-disable-theme']: true })\n )\n : props.children\n\n if (process.env.NODE_ENV === 'development') {\n if (props['debug'] === 'visualize') {\n children = (\n <ThemeDebug themeState={themeState} themeProps={props}>\n {children}\n </ThemeDebug>\n )\n }\n }\n\n return useThemedChildren(themeState, children, props, isRoot)\n}\n\nexport function useThemedChildren(\n themeState: ChangedThemeResponse,\n children: any,\n props: {\n forceClassName?: boolean\n shallow?: boolean\n passPropsToChildren?: boolean\n debug?: DebugProp\n },\n isRoot = false\n) {\n const { themeManager, className, theme, isNewTheme } = themeState\n const { shallow, forceClassName } = props\n const hasEverThemed = useServerRef(false)\n if (isNewTheme) {\n hasEverThemed.current = true\n }\n\n const shouldRenderChildrenWithTheme =\n isNewTheme || hasEverThemed.current || forceClassName || isRoot\n\n return useMemo(() => {\n if (!shouldRenderChildrenWithTheme) {\n return children\n }\n\n // be sure to memoize shouldReset to avoid reparenting\n let next = Children.toArray(children)\n\n // each children of these children wont get the theme\n if (shallow && themeManager) {\n next = next.map((child) => {\n return isValidElement(child)\n ? cloneElement(\n child,\n undefined,\n <Theme name={themeManager.state.parentName}>\n {(child as any).props.children}\n </Theme>\n )\n : child\n })\n }\n\n const wrapped = (\n <ThemeManagerContext.Provider value={themeManager}>\n {next}\n </ThemeManagerContext.Provider>\n )\n\n if (forceClassName === false) {\n return wrapped\n }\n\n if (isWeb && !props.passPropsToChildren) {\n // in order to provide currentColor, set color by default\n const themeColor = theme && isNewTheme ? variableToString(theme.color) : ''\n const colorStyle = {\n color: themeColor,\n }\n\n return (\n <span className={`${className || ''} _dsp_contents is_Theme`} style={colorStyle}>\n {wrapped}\n </span>\n )\n }\n\n return wrapped\n }, [\n forceClassName,\n props.passPropsToChildren,\n shouldRenderChildrenWithTheme,\n themeManager,\n children,\n theme,\n isNewTheme,\n className,\n ])\n}\n"],
5
+ "mappings": "AA4BQ;AA5BR,SAAS,aAAa;AACtB,SAAS,UAAU,cAAc,gBAAkC,eAAe;AAElF,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AACpC,SAAS,oBAAoB;AAC7B,SAA+B,4BAA4B;AAE3D,SAAS,kBAAkB;AAEpB,SAAS,MAAM,OAAmB;AAEvC,MAAI,MAAM,SAAS;AACjB,WAAO,MAAM;AAAA,EACf;AAEA,QAAM,SAAS,CAAC,CAAC,MAAM,SAAS;AAChC,QAAM,aAAa,qBAAq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AEA,aACE,oBAAC,UAAK,WAAW,GAAG,aAAa,6BAA6B,OAAO,YAClE,mBACH;AAAA,IAEJ;AAEA,WAAO;AAAA,EACT,GAAG;AAAA,IACD;AAAA,IACA,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;",
6
6
  "names": []
7
7
  }
@@ -12,9 +12,9 @@ function Theme(props) {
12
12
  }
13
13
  const isRoot = !!props["_isRoot"];
14
14
  const themeState = useChangeThemeEffect(props, isRoot);
15
- let children = props["data-themeable"] ? Children.map(
15
+ let children = props["disable-child-theme"] ? Children.map(
16
16
  props.children,
17
- (child) => cloneElement(child, { ["data-themeable"]: true })
17
+ (child) => cloneElement(child, { ["data-disable-theme"]: true })
18
18
  ) : props.children;
19
19
  if (process.env.NODE_ENV === "development") {
20
20
  if (props["debug"] === "visualize") {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/views/Theme.tsx"],
4
- "sourcesContent": ["import { isWeb } from '@tamagui/constants'\nimport { Children, cloneElement, isValidElement, useEffect, useId, useMemo } from 'react'\n\nimport { variableToString } from '../createVariable.js'\nimport { ThemeManagerContext } from '../helpers/ThemeManagerContext.js'\nimport { useServerRef } from '../hooks/useServerHooks.js'\nimport { ChangedThemeResponse, useChangeThemeEffect } from '../hooks/useTheme.js'\nimport type { DebugProp, ThemeProps } from '../types.js'\nimport { ThemeDebug } from './ThemeDebug'\n\nexport function Theme(props: ThemeProps) {\n // @ts-expect-error only for internal views\n if (props.disable) {\n return props.children\n }\n\n const isRoot = !!props['_isRoot']\n const themeState = useChangeThemeEffect(props, isRoot)\n\n let children = props['data-themeable']\n ? Children.map(props.children, (child) =>\n cloneElement(child, { ['data-themeable']: true })\n )\n : props.children\n\n if (process.env.NODE_ENV === 'development') {\n if (props['debug'] === 'visualize') {\n children = (\n <ThemeDebug themeState={themeState} themeProps={props}>\n {children}\n </ThemeDebug>\n )\n }\n }\n\n return useThemedChildren(themeState, children, props, isRoot)\n}\n\nexport function useThemedChildren(\n themeState: ChangedThemeResponse,\n children: any,\n props: {\n forceClassName?: boolean\n shallow?: boolean\n passPropsToChildren?: boolean\n debug?: DebugProp\n },\n isRoot = false\n) {\n const { themeManager, className, theme, isNewTheme } = themeState\n const { shallow, forceClassName } = props\n const hasEverThemed = useServerRef(false)\n if (isNewTheme) {\n hasEverThemed.current = true\n }\n\n const shouldRenderChildrenWithTheme =\n isNewTheme || hasEverThemed.current || forceClassName || isRoot\n\n return useMemo(() => {\n if (!shouldRenderChildrenWithTheme) {\n return children\n }\n\n // be sure to memoize shouldReset to avoid reparenting\n let next = Children.toArray(children)\n\n // each children of these children wont get the theme\n if (shallow && themeManager) {\n next = next.map((child) => {\n return isValidElement(child)\n ? cloneElement(\n child,\n undefined,\n <Theme name={themeManager.state.parentName}>\n {(child as any).props.children}\n </Theme>\n )\n : child\n })\n }\n\n const wrapped = (\n <ThemeManagerContext.Provider value={themeManager}>\n {next}\n </ThemeManagerContext.Provider>\n )\n\n if (forceClassName === false) {\n return wrapped\n }\n\n if (isWeb && !props.passPropsToChildren) {\n // in order to provide currentColor, set color by default\n const themeColor = theme && isNewTheme ? variableToString(theme.color) : ''\n const colorStyle = {\n color: themeColor,\n }\n\n return (\n <span className={`${className || ''} _dsp_contents is_Theme`} style={colorStyle}>\n {wrapped}\n </span>\n )\n }\n\n return wrapped\n }, [\n forceClassName,\n props.passPropsToChildren,\n shouldRenderChildrenWithTheme,\n themeManager,\n children,\n theme,\n isNewTheme,\n className,\n ])\n}\n"],
5
- "mappings": "AA4BQ;AA5BR,SAAS,aAAa;AACtB,SAAS,UAAU,cAAc,gBAAkC,eAAe;AAElF,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AACpC,SAAS,oBAAoB;AAC7B,SAA+B,4BAA4B;AAE3D,SAAS,kBAAkB;AAEpB,SAAS,MAAM,OAAmB;AAEvC,MAAI,MAAM,SAAS;AACjB,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a,SAAS,aAAa,iBAAiB,MAAM,KAAK,IAAI;AACzE,YAAM,aAAa;AAAA,QACjB,OAAO;AAAA,MACT;AAEA,aACE,oBAAC,UAAK,WAAW,GAAG,aAAa,6BAA6B,OAAO,YAClE,mBACH;AAAA,IAEJ;AAEA,WAAO;AAAA,EACT,GAAG;AAAA,IACD;AAAA,IACA,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;",
4
+ "sourcesContent": ["import { isWeb } from '@tamagui/constants'\nimport { Children, cloneElement, isValidElement, useEffect, useId, useMemo } from 'react'\n\nimport { variableToString } from '../createVariable.js'\nimport { ThemeManagerContext } from '../helpers/ThemeManagerContext.js'\nimport { useServerRef } from '../hooks/useServerHooks.js'\nimport { ChangedThemeResponse, useChangeThemeEffect } from '../hooks/useTheme.js'\nimport type { DebugProp, ThemeProps } from '../types.js'\nimport { ThemeDebug } from './ThemeDebug'\n\nexport function Theme(props: ThemeProps) {\n // @ts-expect-error only for internal views\n if (props.disable) {\n return props.children\n }\n\n const isRoot = !!props['_isRoot']\n const themeState = useChangeThemeEffect(props, isRoot)\n\n let children = props['disable-child-theme']\n ? Children.map(props.children, (child) =>\n cloneElement(child, { ['data-disable-theme']: true })\n )\n : props.children\n\n if (process.env.NODE_ENV === 'development') {\n if (props['debug'] === 'visualize') {\n children = (\n <ThemeDebug themeState={themeState} themeProps={props}>\n {children}\n </ThemeDebug>\n )\n }\n }\n\n return useThemedChildren(themeState, children, props, isRoot)\n}\n\nexport function useThemedChildren(\n themeState: ChangedThemeResponse,\n children: any,\n props: {\n forceClassName?: boolean\n shallow?: boolean\n passPropsToChildren?: boolean\n debug?: DebugProp\n },\n isRoot = false\n) {\n const { themeManager, className, theme, isNewTheme } = themeState\n const { shallow, forceClassName } = props\n const hasEverThemed = useServerRef(false)\n if (isNewTheme) {\n hasEverThemed.current = true\n }\n\n const shouldRenderChildrenWithTheme =\n isNewTheme || hasEverThemed.current || forceClassName || isRoot\n\n return useMemo(() => {\n if (!shouldRenderChildrenWithTheme) {\n return children\n }\n\n // be sure to memoize shouldReset to avoid reparenting\n let next = Children.toArray(children)\n\n // each children of these children wont get the theme\n if (shallow && themeManager) {\n next = next.map((child) => {\n return isValidElement(child)\n ? cloneElement(\n child,\n undefined,\n <Theme name={themeManager.state.parentName}>\n {(child as any).props.children}\n </Theme>\n )\n : child\n })\n }\n\n const wrapped = (\n <ThemeManagerContext.Provider value={themeManager}>\n {next}\n </ThemeManagerContext.Provider>\n )\n\n if (forceClassName === false) {\n return wrapped\n }\n\n if (isWeb && !props.passPropsToChildren) {\n // in order to provide currentColor, set color by default\n const themeColor = theme && isNewTheme ? variableToString(theme.color) : ''\n const colorStyle = {\n color: themeColor,\n }\n\n return (\n <span className={`${className || ''} _dsp_contents is_Theme`} style={colorStyle}>\n {wrapped}\n </span>\n )\n }\n\n return wrapped\n }, [\n forceClassName,\n props.passPropsToChildren,\n shouldRenderChildrenWithTheme,\n themeManager,\n children,\n theme,\n isNewTheme,\n className,\n ])\n}\n"],
5
+ "mappings": "AA4BQ;AA5BR,SAAS,aAAa;AACtB,SAAS,UAAU,cAAc,gBAAkC,eAAe;AAElF,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AACpC,SAAS,oBAAoB;AAC7B,SAA+B,4BAA4B;AAE3D,SAAS,kBAAkB;AAEpB,SAAS,MAAM,OAAmB;AAEvC,MAAI,MAAM,SAAS;AACjB,WAAO,MAAM;AAAA,EACf;AAEA,QAAM,SAAS,CAAC,CAAC,MAAM,SAAS;AAChC,QAAM,aAAa,qBAAqB,OAAO,MAAM;AAErD,MAAI,WAAW,MAAM,qBAAqB,IACtC,SAAS;AAAA,IAAI,MAAM;AAAA,IAAU,CAAC,UAC5B,aAAa,OAAO,EAAE,CAAC,oBAAoB,GAAG,KAAK,CAAC;AAAA,EACtD,IACA,MAAM;AAEV,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,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6
6
  "names": []
7
7
  }
@@ -9,6 +9,9 @@ function ThemeDebug({
9
9
  children
10
10
  }) {
11
11
  var _a, _b, _c, _d, _e, _f;
12
+ if (themeProps["disable-child-theme"]) {
13
+ return children;
14
+ }
12
15
  if (process.env.NODE_ENV === "development") {
13
16
  const [onChangeCount, setOnChangeCount] = useState(0);
14
17
  const rerender = useForceUpdate();
@@ -75,7 +78,7 @@ function ThemeDebug({
75
78
  ),
76
79
  node
77
80
  ),
78
- /* @__PURE__ */ jsx("div", { children: id }),
81
+ /* @__PURE__ */ jsx("div", { style: { color: "red" }, children: id }),
79
82
  children
80
83
  ] });
81
84
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/views/ThemeDebug.tsx"],
4
- "sourcesContent": ["import { useForceUpdate } from '@tamagui/use-force-update'\nimport { useEffect, useId, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport { ChangedThemeResponse } from '../hooks/useTheme.js'\nimport { ThemeProps } from '../types.js'\n\nlet node\n\nexport function ThemeDebug({\n themeState,\n themeProps,\n children,\n}: {\n themeState: ChangedThemeResponse\n themeProps: ThemeProps\n children: any\n}) {\n if (process.env.NODE_ENV === 'development') {\n const [onChangeCount, setOnChangeCount] = useState(0)\n const rerender = useForceUpdate()\n const id = useId()\n\n if (process.env.NODE_ENV === 'development' && typeof document !== 'undefined') {\n if (!node) {\n node = document.createElement('div')\n node.style.width = '100%'\n node.style.height = '200px'\n node.style.overflowY = 'scroll'\n node.style.position = 'fixed'\n node.style.top = '0px'\n node.style.left = '0px'\n node.style.display = 'flex'\n node.style.flexDirection = 'row'\n node.style.background = 'var(--background)'\n document.body.appendChild(node)\n }\n }\n\n useEffect(() => {\n themeState.themeManager?.parentManager?.onChangeTheme((name, manager) => {\n setOnChangeCount((p) => ++p)\n console.warn(`theme changed`, name)\n })\n }, [themeState.themeManager])\n\n useEffect(() => {\n // to refresh _listeningIds every so often\n const tm = setInterval(rerender, 100)\n return () => clearTimeout(tm)\n }, [])\n\n return (\n <>\n {createPortal(\n <code\n style={{\n whiteSpace: 'pre',\n }}\n >\n &lt;Theme {id} /&gt;&nbsp;\n {JSON.stringify(\n {\n name: themeState.name,\n className: themeState.className,\n inverse: themeProps.inverse,\n forceClassName: themeProps.forceClassName,\n parent: themeState.themeManager?.state.parentName,\n id: themeState.themeManager?.id,\n parentId: themeState.themeManager?.parentManager?.id,\n isNew: themeState.isNewTheme,\n onChangeCount,\n listening: [...(themeState.themeManager?.['_listeningIds'] || [])].join(\n ','\n ),\n _numChangeEventsSent: themeState.themeManager?.['_numChangeEventsSent'],\n },\n null,\n 2\n )}\n </code>,\n node\n )}\n\n <div>{id}</div>\n\n {children}\n </>\n )\n }\n return children\n}\n"],
5
- "mappings": "AAqDM,mBA+BE,KA7BE,YAFJ;AArDN,SAAS,sBAAsB;AAC/B,SAAS,WAAW,OAAe,gBAAgB;AACnD,SAAS,oBAAoB;AAK7B,IAAI;AAEG,SAAS,WAAW;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AACF,GAIG;AAjBH;AAkBE,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,UAAM,CAAC,eAAe,gBAAgB,IAAI,SAAS,CAAC;AACpD,UAAM,WAAW,eAAe;AAChC,UAAM,KAAK,MAAM;AAEjB,QAAI,QAAQ,IAAI,aAAa,iBAAiB,OAAO,aAAa,aAAa;AAC7E,UAAI,CAAC,MAAM;AACT,eAAO,SAAS,cAAc,KAAK;AACnC,aAAK,MAAM,QAAQ;AACnB,aAAK,MAAM,SAAS;AACpB,aAAK,MAAM,YAAY;AACvB,aAAK,MAAM,WAAW;AACtB,aAAK,MAAM,MAAM;AACjB,aAAK,MAAM,OAAO;AAClB,aAAK,MAAM,UAAU;AACrB,aAAK,MAAM,gBAAgB;AAC3B,aAAK,MAAM,aAAa;AACxB,iBAAS,KAAK,YAAY,IAAI;AAAA,MAChC;AAAA,IACF;AAEA,cAAU,MAAM;AAvCpB,UAAAA,KAAAC;AAwCM,OAAAA,OAAAD,MAAA,WAAW,iBAAX,gBAAAA,IAAyB,kBAAzB,gBAAAC,IAAwC,cAAc,CAAC,MAAM,YAAY;AACvE,yBAAiB,CAAC,MAAM,EAAE,CAAC;AAC3B,gBAAQ,KAAK,iBAAiB,IAAI;AAAA,MACpC;AAAA,IACF,GAAG,CAAC,WAAW,YAAY,CAAC;AAE5B,cAAU,MAAM;AAEd,YAAM,KAAK,YAAY,UAAU,GAAG;AACpC,aAAO,MAAM,aAAa,EAAE;AAAA,IAC9B,GAAG,CAAC,CAAC;AAEL,WACE,iCACG;AAAA;AAAA,QACC;AAAA,UAAC;AAAA;AAAA,YACC,OAAO;AAAA,cACL,YAAY;AAAA,YACd;AAAA,YACD;AAAA;AAAA,cACY;AAAA,cAAG;AAAA,cACb,KAAK;AAAA,gBACJ;AAAA,kBACE,MAAM,WAAW;AAAA,kBACjB,WAAW,WAAW;AAAA,kBACtB,SAAS,WAAW;AAAA,kBACpB,gBAAgB,WAAW;AAAA,kBAC3B,SAAQ,gBAAW,iBAAX,mBAAyB,MAAM;AAAA,kBACvC,KAAI,gBAAW,iBAAX,mBAAyB;AAAA,kBAC7B,WAAU,sBAAW,iBAAX,mBAAyB,kBAAzB,mBAAwC;AAAA,kBAClD,OAAO,WAAW;AAAA,kBAClB;AAAA,kBACA,WAAW,CAAC,KAAI,gBAAW,iBAAX,mBAA0B,qBAAoB,CAAC,CAAE,EAAE;AAAA,oBACjE;AAAA,kBACF;AAAA,kBACA,uBAAsB,gBAAW,iBAAX,mBAA0B;AAAA,gBAClD;AAAA,gBACA;AAAA,gBACA;AAAA,cACF;AAAA;AAAA;AAAA,QACF;AAAA,QACA;AAAA,MACF;AAAA,MAEA,oBAAC,SAAK,cAAG;AAAA,MAER;AAAA,OACH;AAAA,EAEJ;AACA,SAAO;AACT;",
4
+ "sourcesContent": ["import { useForceUpdate } from '@tamagui/use-force-update'\nimport { useEffect, useId, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport { ChangedThemeResponse } from '../hooks/useTheme.js'\nimport { ThemeProps } from '../types.js'\n\nlet node\n\nexport function ThemeDebug({\n themeState,\n themeProps,\n children,\n}: {\n themeState: ChangedThemeResponse\n themeProps: ThemeProps\n children: any\n}) {\n // disabled\n if (themeProps['disable-child-theme']) {\n return children\n }\n\n if (process.env.NODE_ENV === 'development') {\n const [onChangeCount, setOnChangeCount] = useState(0)\n const rerender = useForceUpdate()\n const id = useId()\n\n if (process.env.NODE_ENV === 'development' && typeof document !== 'undefined') {\n if (!node) {\n node = document.createElement('div')\n node.style.width = '100%'\n node.style.height = '200px'\n node.style.overflowY = 'scroll'\n node.style.position = 'fixed'\n node.style.top = '0px'\n node.style.left = '0px'\n node.style.display = 'flex'\n node.style.flexDirection = 'row'\n node.style.background = 'var(--background)'\n document.body.appendChild(node)\n }\n }\n\n useEffect(() => {\n themeState.themeManager?.parentManager?.onChangeTheme((name, manager) => {\n setOnChangeCount((p) => ++p)\n console.warn(`theme changed`, name)\n })\n }, [themeState.themeManager])\n\n useEffect(() => {\n // to refresh _listeningIds every so often\n const tm = setInterval(rerender, 100)\n return () => clearTimeout(tm)\n }, [])\n\n return (\n <>\n {createPortal(\n <code\n style={{\n whiteSpace: 'pre',\n }}\n >\n &lt;Theme {id} /&gt;&nbsp;\n {JSON.stringify(\n {\n name: themeState.name,\n className: themeState.className,\n inverse: themeProps.inverse,\n forceClassName: themeProps.forceClassName,\n parent: themeState.themeManager?.state.parentName,\n id: themeState.themeManager?.id,\n parentId: themeState.themeManager?.parentManager?.id,\n isNew: themeState.isNewTheme,\n onChangeCount,\n listening: [...(themeState.themeManager?.['_listeningIds'] || [])].join(\n ','\n ),\n _numChangeEventsSent: themeState.themeManager?.['_numChangeEventsSent'],\n },\n null,\n 2\n )}\n </code>,\n node\n )}\n\n <div style={{ color: 'red' }}>{id}</div>\n\n {children}\n </>\n )\n }\n return children\n}\n"],
5
+ "mappings": "AA0DM,mBA+BE,KA7BE,YAFJ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A,YACD;AAAA;AAAA,cACY;AAAA,cAAG;AAAA,cACb,KAAK;AAAA,gBACJ;AAAA,kBACE,MAAM,WAAW;AAAA,kBACjB,WAAW,WAAW;AAAA,kBACtB,SAAS,WAAW;AAAA,kBACpB,gBAAgB,WAAW;AAAA,kBAC3B,SAAQ,gBAAW,iBAAX,mBAAyB,MAAM;AAAA,kBACvC,KAAI,gBAAW,iBAAX,mBAAyB;AAAA,kBAC7B,WAAU,sBAAW,iBAAX,mBAAyB,kBAAzB,mBAAwC;AAAA,kBAClD,OAAO,WAAW;AAAA,kBAClB;AAAA,kBACA,WAAW,CAAC,KAAI,gBAAW,iBAAX,mBAA0B,qBAAoB,CAAC,CAAE,EAAE;AAAA,oBACjE;AAAA,kBACF;AAAA,kBACA,uBAAsB,gBAAW,iBAAX,mBAA0B;AAAA,gBAClD;AAAA,gBACA;AAAA,gBACA;AAAA,cACF;AAAA;AAAA;AAAA,QACF;AAAA,QACA;AAAA,MACF;AAAA,MAEA,oBAAC,SAAI,OAAO,EAAE,OAAO,MAAM,GAAI,cAAG;AAAA,MAEjC;AAAA,OACH;AAAA,EAEJ;AACA,SAAO;AACT;",
6
6
  "names": ["_a", "_b"]
7
7
  }
@@ -9,6 +9,9 @@ function ThemeDebug({
9
9
  children
10
10
  }) {
11
11
  var _a, _b, _c, _d, _e, _f;
12
+ if (themeProps["disable-child-theme"]) {
13
+ return children;
14
+ }
12
15
  if (process.env.NODE_ENV === "development") {
13
16
  const [onChangeCount, setOnChangeCount] = useState(0);
14
17
  const rerender = useForceUpdate();
@@ -75,7 +78,7 @@ function ThemeDebug({
75
78
  ),
76
79
  node
77
80
  ),
78
- /* @__PURE__ */ jsx("div", { children: id }),
81
+ /* @__PURE__ */ jsx("div", { style: { color: "red" }, children: id }),
79
82
  children
80
83
  ] });
81
84
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/views/ThemeDebug.tsx"],
4
- "sourcesContent": ["import { useForceUpdate } from '@tamagui/use-force-update'\nimport { useEffect, useId, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport { ChangedThemeResponse } from '../hooks/useTheme.js'\nimport { ThemeProps } from '../types.js'\n\nlet node\n\nexport function ThemeDebug({\n themeState,\n themeProps,\n children,\n}: {\n themeState: ChangedThemeResponse\n themeProps: ThemeProps\n children: any\n}) {\n if (process.env.NODE_ENV === 'development') {\n const [onChangeCount, setOnChangeCount] = useState(0)\n const rerender = useForceUpdate()\n const id = useId()\n\n if (process.env.NODE_ENV === 'development' && typeof document !== 'undefined') {\n if (!node) {\n node = document.createElement('div')\n node.style.width = '100%'\n node.style.height = '200px'\n node.style.overflowY = 'scroll'\n node.style.position = 'fixed'\n node.style.top = '0px'\n node.style.left = '0px'\n node.style.display = 'flex'\n node.style.flexDirection = 'row'\n node.style.background = 'var(--background)'\n document.body.appendChild(node)\n }\n }\n\n useEffect(() => {\n themeState.themeManager?.parentManager?.onChangeTheme((name, manager) => {\n setOnChangeCount((p) => ++p)\n console.warn(`theme changed`, name)\n })\n }, [themeState.themeManager])\n\n useEffect(() => {\n // to refresh _listeningIds every so often\n const tm = setInterval(rerender, 100)\n return () => clearTimeout(tm)\n }, [])\n\n return (\n <>\n {createPortal(\n <code\n style={{\n whiteSpace: 'pre',\n }}\n >\n &lt;Theme {id} /&gt;&nbsp;\n {JSON.stringify(\n {\n name: themeState.name,\n className: themeState.className,\n inverse: themeProps.inverse,\n forceClassName: themeProps.forceClassName,\n parent: themeState.themeManager?.state.parentName,\n id: themeState.themeManager?.id,\n parentId: themeState.themeManager?.parentManager?.id,\n isNew: themeState.isNewTheme,\n onChangeCount,\n listening: [...(themeState.themeManager?.['_listeningIds'] || [])].join(\n ','\n ),\n _numChangeEventsSent: themeState.themeManager?.['_numChangeEventsSent'],\n },\n null,\n 2\n )}\n </code>,\n node\n )}\n\n <div>{id}</div>\n\n {children}\n </>\n )\n }\n return children\n}\n"],
5
- "mappings": "AAqDM,mBA+BE,KA7B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AAK;AAAA,gBACJ;AAAA,kBACE,MAAM,WAAW;AAAA,kBACjB,WAAW,WAAW;AAAA,kBACtB,SAAS,WAAW;AAAA,kBACpB,gBAAgB,WAAW;AAAA,kBAC3B,SAAQ,gBAAW,iBAAX,mBAAyB,MAAM;AAAA,kBACvC,KAAI,gBAAW,iBAAX,mBAAyB;AAAA,kBAC7B,WAAU,sBAAW,iBAAX,mBAAyB,kBAAzB,mBAAwC;AAAA,kBAClD,OAAO,WAAW;AAAA,kBAClB;AAAA,kBACA,WAAW,CAAC,KAAI,gBAAW,iBAAX,mBAA0B,qBAAoB,CAAC,CAAE,EAAE;AAAA,oBACjE;AAAA,kBACF;AAAA,kBACA,uBAAsB,gBAAW,iBAAX,mBAA0B;AAAA,gBAClD;AAAA,gBACA;AAAA,gBACA;AAAA,cACF;AAAA;AAAA;AAAA,QACF;AAAA,QACA;AAAA,MACF;AAAA,MAEA,oBAAC,SAAK,cAAG;AAAA,MAER;AAAA,OACH;AAAA,EAEJ;AACA,SAAO;AACT;",
4
+ "sourcesContent": ["import { useForceUpdate } from '@tamagui/use-force-update'\nimport { useEffect, useId, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport { ChangedThemeResponse } from '../hooks/useTheme.js'\nimport { ThemeProps } from '../types.js'\n\nlet node\n\nexport function ThemeDebug({\n themeState,\n themeProps,\n children,\n}: {\n themeState: ChangedThemeResponse\n themeProps: ThemeProps\n children: any\n}) {\n // disabled\n if (themeProps['disable-child-theme']) {\n return children\n }\n\n if (process.env.NODE_ENV === 'development') {\n const [onChangeCount, setOnChangeCount] = useState(0)\n const rerender = useForceUpdate()\n const id = useId()\n\n if (process.env.NODE_ENV === 'development' && typeof document !== 'undefined') {\n if (!node) {\n node = document.createElement('div')\n node.style.width = '100%'\n node.style.height = '200px'\n node.style.overflowY = 'scroll'\n node.style.position = 'fixed'\n node.style.top = '0px'\n node.style.left = '0px'\n node.style.display = 'flex'\n node.style.flexDirection = 'row'\n node.style.background = 'var(--background)'\n document.body.appendChild(node)\n }\n }\n\n useEffect(() => {\n themeState.themeManager?.parentManager?.onChangeTheme((name, manager) => {\n setOnChangeCount((p) => ++p)\n console.warn(`theme changed`, name)\n })\n }, [themeState.themeManager])\n\n useEffect(() => {\n // to refresh _listeningIds every so often\n const tm = setInterval(rerender, 100)\n return () => clearTimeout(tm)\n }, [])\n\n return (\n <>\n {createPortal(\n <code\n style={{\n whiteSpace: 'pre',\n }}\n >\n &lt;Theme {id} /&gt;&nbsp;\n {JSON.stringify(\n {\n name: themeState.name,\n className: themeState.className,\n inverse: themeProps.inverse,\n forceClassName: themeProps.forceClassName,\n parent: themeState.themeManager?.state.parentName,\n id: themeState.themeManager?.id,\n parentId: themeState.themeManager?.parentManager?.id,\n isNew: themeState.isNewTheme,\n onChangeCount,\n listening: [...(themeState.themeManager?.['_listeningIds'] || [])].join(\n ','\n ),\n _numChangeEventsSent: themeState.themeManager?.['_numChangeEventsSent'],\n },\n null,\n 2\n )}\n </code>,\n node\n )}\n\n <div style={{ color: 'red' }}>{id}</div>\n\n {children}\n </>\n )\n }\n return children\n}\n"],
5
+ "mappings": "AA0DM,mBA+BE,KA7BE,YAFJ;AA1DN,SAAS,sBAAsB;AAC/B,SAAS,WAAW,OAAe,gBAAgB;AACnD,SAAS,oBAAoB;AAK7B,IAAI;AAEG,SAAS,WAAW;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AACF,GAIG;AAjBH;AAmBE,MAAI,WAAW,qBAAqB,GAAG;AACrC,WAAO;AAAA,EACT;AAEA,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,UAAM,CAAC,eAAe,gBAAgB,IAAI,SAAS,CAAC;AACpD,UAAM,WAAW,eAAe;AAChC,UAAM,KAAK,MAAM;AAEjB,QAAI,QAAQ,IAAI,aAAa,iBAAiB,OAAO,aAAa,aAAa;AAC7E,UAAI,CAAC,MAAM;AACT,eAAO,SAAS,cAAc,KAAK;AACnC,aAAK,MAAM,QAAQ;AACnB,aAAK,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0B;AAAA,gBAClD;AAAA,gBACA;AAAA,gBACA;AAAA,cACF;AAAA;AAAA;AAAA,QACF;AAAA,QACA;AAAA,MACF;AAAA,MAEA,oBAAC,SAAI,OAAO,EAAE,OAAO,MAAM,GAAI,cAAG;AAAA,MAEjC;AAAA,OACH;AAAA,EAEJ;AACA,SAAO;AACT;",
6
6
  "names": ["_a", "_b"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/web",
3
- "version": "1.15.8",
3
+ "version": "1.15.10",
4
4
  "source": "src/index.ts",
5
5
  "main": "dist/cjs",
6
6
  "module": "dist/esm",
@@ -27,19 +27,19 @@
27
27
  "reset.css"
28
28
  ],
29
29
  "dependencies": {
30
- "@tamagui/compose-refs": "1.15.8",
31
- "@tamagui/constants": "1.15.8",
32
- "@tamagui/helpers": "1.15.8",
33
- "@tamagui/normalize-css-color": "1.15.8",
34
- "@tamagui/use-did-finish-ssr": "1.15.8",
35
- "@tamagui/use-event": "1.15.8",
36
- "@tamagui/use-force-update": "1.15.8"
30
+ "@tamagui/compose-refs": "1.15.10",
31
+ "@tamagui/constants": "1.15.10",
32
+ "@tamagui/helpers": "1.15.10",
33
+ "@tamagui/normalize-css-color": "1.15.10",
34
+ "@tamagui/use-did-finish-ssr": "1.15.10",
35
+ "@tamagui/use-event": "1.15.10",
36
+ "@tamagui/use-force-update": "1.15.10"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "react": "*"
40
40
  },
41
41
  "devDependencies": {
42
- "@tamagui/build": "1.15.8",
42
+ "@tamagui/build": "1.15.10",
43
43
  "@testing-library/react": "^13.4.0",
44
44
  "csstype": "^3.0.10",
45
45
  "react": "^18.2.0",
@@ -289,13 +289,16 @@ export function createComponent<
289
289
  const shouldForcePseudo = !!propsIn.forceStyle
290
290
  const noClassNames = shouldAvoidClasses || shouldForcePseudo
291
291
 
292
+ // internal use only
293
+ const disableTheme = props['data-disable-theme']
294
+
292
295
  const themeState = useThemeWithState({
293
296
  name: props.theme,
294
297
  componentName,
295
298
  reset: props.reset,
296
299
  inverse: props.themeInverse,
297
300
  // @ts-ignore this is internal use only
298
- disable: props['data-themeable'],
301
+ disable: disableTheme,
299
302
  debug:
300
303
  process.env.NODE_ENV === 'development' && props.debug ? { hostRef } : undefined,
301
304
  shouldUpdate: () => !!stateRef.current.didAccessThemeVariableValue,
@@ -24,7 +24,7 @@ export function themeable<Component extends (props: any) => any>(
24
24
  inverse={themeInverse}
25
25
  componentName={componentName || opts?.componentName}
26
26
  name={(theme as any) || null}
27
- data-themeable
27
+ disable-child-theme
28
28
  debug={props.debug}
29
29
  reset={props.themeReset}
30
30
  >
@@ -187,12 +187,13 @@ export const useChangeThemeEffect = (
187
187
  function getShouldUpdateTheme(
188
188
  manager = themeManager,
189
189
  nextState?: ThemeManagerState | null,
190
+ prevState: ThemeManagerState = state,
190
191
  forceShouldChange = false
191
192
  ) {
192
193
  const next = nextState || manager.getState(props, parentManager)
193
194
  if (!next) return
194
195
  if (disableUpdate?.() === true) return
195
- if (!forceShouldChange && !manager.getStateShouldChange(next, state)) return
196
+ if (!forceShouldChange && !manager.getStateShouldChange(next, prevState)) return
196
197
  return next
197
198
  }
198
199
 
@@ -307,9 +308,8 @@ export const useChangeThemeEffect = (
307
308
  // which is correct, potentially in the future we can avoid forceChange and just know to
308
309
  // update if keys.length is set + onChangeTheme called
309
310
  const forceChange = Boolean(keys?.length)
310
-
311
311
  const next = themeManager.getState(props, parentManager)
312
- const nextState = getShouldUpdateTheme(themeManager, next, forceChange)
312
+ const nextState = getShouldUpdateTheme(themeManager, next, prev.state, forceChange)
313
313
 
314
314
  if (nextState) {
315
315
  state = nextState
@@ -17,9 +17,9 @@ export function Theme(props: ThemeProps) {
17
17
  const isRoot = !!props['_isRoot']
18
18
  const themeState = useChangeThemeEffect(props, isRoot)
19
19
 
20
- let children = props['data-themeable']
20
+ let children = props['disable-child-theme']
21
21
  ? Children.map(props.children, (child) =>
22
- cloneElement(child, { ['data-themeable']: true })
22
+ cloneElement(child, { ['data-disable-theme']: true })
23
23
  )
24
24
  : props.children
25
25
 
@@ -16,6 +16,11 @@ export function ThemeDebug({
16
16
  themeProps: ThemeProps
17
17
  children: any
18
18
  }) {
19
+ // disabled
20
+ if (themeProps['disable-child-theme']) {
21
+ return children
22
+ }
23
+
19
24
  if (process.env.NODE_ENV === 'development') {
20
25
  const [onChangeCount, setOnChangeCount] = useState(0)
21
26
  const rerender = useForceUpdate()
@@ -82,7 +87,7 @@ export function ThemeDebug({
82
87
  node
83
88
  )}
84
89
 
85
- <div>{id}</div>
90
+ <div style={{ color: 'red' }}>{id}</div>
86
91
 
87
92
  {children}
88
93
  </>
@@ -1 +1 @@
1
- {"version":3,"file":"createComponent.d.ts","sourceRoot":"","sources":["../src/createComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,KAYN,MAAM,OAAO,CAAA;AAiBd,OAAO,EACL,SAAS,EACT,cAAc,EACd,WAAW,EACX,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAEhB,qBAAqB,EAErB,cAAc,EAIf,MAAM,SAAS,CAAA;AAsBhB,eAAO,MAAM,qBAAqB,EAAE,qBAMnC,CAAA;AAeD,eAAO,MAAM,QAAQ,eAAsB,CAAA;AA8B3C,wBAAgB,eAAe,CAC7B,kBAAkB,SAAS,MAAM,GAAG,EAAE,EACtC,GAAG,GAAG,cAAc,EACpB,SAAS,GAAG,KAAK,EAEjB,QAAQ,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,kBAAkB,EACpD,eAAe,CAAC,EAAE,iBAAiB,wDAixBpC;AAGD,eAAO,MAAM,QAAQ;YAAW;QAAE,QAAQ,CAAC,EAAE,GAAG,CAAA;KAAE;;CAAmB,CAAA;AAMrE,eAAO,MAAM,MAAM,sDA8CjB,CAAA;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EA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EAAE,OAAO,GAAG,MAAM,CAAA;IAC5B,SAAS,CAAC,EAAE,cAAc,CAAA;IAC1B,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC3B,KAAK,CAAC,EAAE,SAAS,CAAA;CAClB,CAAA;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,mBAiGxD"}
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeDebug.d.ts","sourceRoot":"","sources":["../../src/views/ThemeDebug.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAIxC,wBAAgB,UAAU,CAAC,EACzB,UAAU,EACV,UAAU,EACV,QAAQ,GACT,EAAE;IACD,UAAU,EAAE,oBAAoB,CAAA;IAChC,UAAU,EAAE,UAAU,CAAA;IACtB,QAAQ,EAAE,GAAG,CAAA;CACd,OA0EA"}
1
+ {"version":3,"file":"ThemeDebug.d.ts","sourceRoot":"","sources":["../../src/views/ThemeDebug.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAIxC,wBAAgB,UAAU,CAAC,EACzB,UAAU,EACV,UAAU,EACV,QAAQ,GACT,EAAE;IACD,UAAU,EAAE,oBAAoB,CAAA;IAChC,UAAU,EAAE,UAAU,CAAA;IACtB,QAAQ,EAAE,GAAG,CAAA;CACd,OA+EA"}