@tamagui/web 1.13.4 → 1.14.1

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 (57) hide show
  1. package/dist/cjs/createComponent.js +2 -2
  2. package/dist/cjs/createComponent.js.map +3 -3
  3. package/dist/cjs/helpers/ThemeManager.js +1 -1
  4. package/dist/cjs/helpers/ThemeManager.js.map +3 -3
  5. package/dist/cjs/helpers/getSplitStyles.js +2 -2
  6. package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
  7. package/dist/cjs/hooks/useTheme.js +1 -1
  8. package/dist/cjs/hooks/useTheme.js.map +3 -3
  9. package/dist/cjs/types.js.map +1 -1
  10. package/dist/cjs/views/Theme.js +1 -1
  11. package/dist/cjs/views/Theme.js.map +3 -3
  12. package/dist/cjs/views/ThemeDebug.js +2 -0
  13. package/dist/cjs/views/ThemeDebug.js.map +7 -0
  14. package/dist/esm/createComponent.js +2 -2
  15. package/dist/esm/createComponent.js.map +3 -3
  16. package/dist/esm/createComponent.mjs +2 -2
  17. package/dist/esm/createComponent.mjs.map +3 -3
  18. package/dist/esm/helpers/ThemeManager.js +1 -1
  19. package/dist/esm/helpers/ThemeManager.js.map +3 -3
  20. package/dist/esm/helpers/ThemeManager.mjs +1 -1
  21. package/dist/esm/helpers/ThemeManager.mjs.map +3 -3
  22. package/dist/esm/helpers/getSplitStyles.js +2 -2
  23. package/dist/esm/helpers/getSplitStyles.js.map +2 -2
  24. package/dist/esm/helpers/getSplitStyles.mjs +2 -2
  25. package/dist/esm/helpers/getSplitStyles.mjs.map +2 -2
  26. package/dist/esm/hooks/useTheme.js +1 -1
  27. package/dist/esm/hooks/useTheme.js.map +3 -3
  28. package/dist/esm/hooks/useTheme.mjs +1 -1
  29. package/dist/esm/hooks/useTheme.mjs.map +3 -3
  30. package/dist/esm/views/Theme.js +1 -1
  31. package/dist/esm/views/Theme.js.map +3 -3
  32. package/dist/esm/views/Theme.mjs +1 -1
  33. package/dist/esm/views/Theme.mjs.map +3 -3
  34. package/dist/esm/views/ThemeDebug.js +2 -0
  35. package/dist/esm/views/ThemeDebug.js.map +7 -0
  36. package/dist/esm/views/ThemeDebug.mjs +2 -0
  37. package/dist/esm/views/ThemeDebug.mjs.map +7 -0
  38. package/package.json +9 -9
  39. package/src/createComponent.tsx +31 -5
  40. package/src/helpers/ThemeManager.tsx +43 -35
  41. package/src/helpers/getSplitStyles.tsx +0 -8
  42. package/src/hooks/useTheme.tsx +145 -93
  43. package/src/types.tsx +2 -2
  44. package/src/views/Theme.tsx +43 -31
  45. package/src/views/ThemeDebug.tsx +49 -0
  46. package/types/createComponent.d.ts.map +1 -1
  47. package/types/helpers/ThemeManager.d.ts +1 -0
  48. package/types/helpers/ThemeManager.d.ts.map +1 -1
  49. package/types/helpers/getSplitStyles.d.ts.map +1 -1
  50. package/types/hooks/useTheme.d.ts +5 -7
  51. package/types/hooks/useTheme.d.ts.map +1 -1
  52. package/types/types.d.ts +2 -2
  53. package/types/types.d.ts.map +1 -1
  54. package/types/views/Theme.d.ts +3 -2
  55. package/types/views/Theme.d.ts.map +1 -1
  56. package/types/views/ThemeDebug.d.ts +9 -0
  57. package/types/views/ThemeDebug.d.ts.map +1 -0
@@ -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 } 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 { ThemeProps } from '../types.js'\n\nexport function Theme(props: ThemeProps) {\n // @ts-expect-error only for internal views\n if (props.disable) return props.children\n const isRoot = !!props['_isRoot']\n const themeState = useChangeThemeEffect(props, isRoot)\n const children = props['data-themeable']\n ? Children.map(props.children, (child) =>\n cloneElement(child, { ['data-themeable']: true })\n )\n : props.children\n\n return useThemedChildren(themeState, children, props, isRoot)\n}\n\nexport function useThemedChildren(\n themeState: ChangedThemeResponse,\n children: any,\n options: {\n forceClassName?: boolean\n shallow?: boolean\n passPropsToChildren?: boolean\n },\n isRoot = false\n) {\n const { themeManager, isNewTheme, className, theme } = themeState\n const { shallow, forceClassName } = options\n const hasEverThemed = useServerRef(false)\n if (isNewTheme) {\n hasEverThemed.current = true\n }\n\n if (isNewTheme || hasEverThemed.current || forceClassName || isRoot) {\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 // tried this but themes css doesn't fully like it\n // if (shouldAttachClassName && options.passPropsToChildren) {\n // next = next.map((child: any) => {\n // const childStyle = child.props?.style\n // console.log('pass it down', className, child.props.className || '')\n // const newProps = {\n // className: (child.props.className || '') + ' ' + className,\n // style: Array.isArray(childStyle)\n // ? [colorStyle, ...childStyle]\n // : {\n // ...colorStyle,\n // ...childStyle,\n // },\n // }\n // return isValidElement(child) ? cloneElement(child as any, newProps) : 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 && !options.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`} style={colorStyle}>\n {wrapped}\n </span>\n )\n }\n\n return wrapped\n }\n\n return children\n}\n"],
5
- "mappings": "AAmDc,cAAAA,MAAA,oBAnDd,OAAS,SAAAC,MAAa,qBACtB,OAAS,YAAAC,EAAU,gBAAAC,EAAc,kBAAAC,MAAsB,QAEvD,OAAS,oBAAAC,MAAwB,uBACjC,OAAS,uBAAAC,MAA2B,oCACpC,OAAS,gBAAAC,MAAoB,6BAC7B,OAA+B,wBAAAC,MAA4B,uBAGpD,SAASC,EAAMC,EAAmB,CAEvC,GAAIA,EAAM,QAAS,OAAOA,EAAM,SAChC,MAAMC,EAAS,CAAC,CAACD,EAAM,QACjBE,EAAaJ,EAAqBE,EAAOC,CAAM,EAC/CE,EAAWH,EAAM,gBAAgB,EACnCR,EAAS,IAAIQ,EAAM,SAAWI,GAC5BX,EAAaW,EAAO,CAAE,CAAC,gBAAgB,EAAG,EAAK,CAAC,CAClD,EACAJ,EAAM,SAEV,OAAOK,EAAkBH,EAAYC,EAAUH,EAAOC,CAAM,CAC9D,CAEO,SAASI,EACdH,EACAC,EACAG,EAKAL,EAAS,GACT,CACA,KAAM,CAAE,aAAAM,EAAc,WAAAC,EAAY,UAAAC,EAAW,MAAAC,CAAM,EAAIR,EACjD,CAAE,QAAAS,EAAS,eAAAC,CAAe,EAAIN,EAC9BO,EAAgBhB,EAAa,EAAK,EAKxC,GAJIW,IACFK,EAAc,QAAU,IAGtBL,GAAcK,EAAc,SAAWD,GAAkBX,EAAQ,CAEnE,IAAIa,EAAOtB,EAAS,QAAQW,CAAQ,EAGhCQ,GAAWJ,IACbO,EAAOA,EAAK,IAAKV,GACRV,EAAeU,CAAK,EACvBX,EACEW,EACA,OACAd,EAACS,EAAA,CAAM,KAAMQ,EAAa,MAAM,WAC5B,SAAAH,EAAc,MAAM,SACxB,CACF,EACAA,CACL,GAqBH,MAAMW,EACJzB,EAACM,EAAoB,SAApB,CAA6B,MAAOW,EAClC,SAAAO,EACH,EAGF,GAAIF,IAAmB,GACrB,OAAOG,EAGT,GAAIxB,GAAS,CAACe,EAAQ,oBAAqB,CAGzC,MAAMU,EAAa,CACjB,MAFiBN,GAASF,EAAab,EAAiBe,EAAM,KAAK,EAAI,EAGzE,EAEA,OACEpB,EAAC,QAAK,UAAW,GAAGmB,GAAa,mBAAoB,MAAOO,EACzD,SAAAD,EACH,CAEJ,CAEA,OAAOA,CACT,CAEA,OAAOZ,CACT",
6
- "names": ["jsx", "isWeb", "Children", "cloneElement", "isValidElement", "variableToString", "ThemeManagerContext", "useServerRef", "useChangeThemeEffect", "Theme", "props", "isRoot", "themeState", "children", "child", "useThemedChildren", "options", "themeManager", "isNewTheme", "className", "theme", "shallow", "forceClassName", "hasEverThemed", "next", "wrapped", "colorStyle"]
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,cAAAA,MAAA,oBA5BR,OAAS,SAAAC,MAAa,qBACtB,OAAS,YAAAC,EAAU,gBAAAC,EAAc,kBAAAC,EAAkC,WAAAC,MAAe,QAElF,OAAS,oBAAAC,MAAwB,uBACjC,OAAS,uBAAAC,MAA2B,oCACpC,OAAS,gBAAAC,MAAoB,6BAC7B,OAA+B,wBAAAC,MAA4B,uBAE3D,OAAS,cAAAC,MAAkB,eAEpB,SAASC,EAAMC,EAAmB,CAEvC,GAAIA,EAAM,QACR,OAAOA,EAAM,SAGf,MAAMC,EAAS,CAAC,CAACD,EAAM,QACjBE,EAAaL,EAAqBG,EAAOC,CAAM,EAErD,IAAIE,EAAWH,EAAM,gBAAgB,EACjCV,EAAS,IAAIU,EAAM,SAAWI,GAC5Bb,EAAaa,EAAO,CAAE,CAAC,gBAAgB,EAAG,EAAK,CAAC,CAClD,EACAJ,EAAM,SAEV,OAAI,QAAQ,IAAI,WAAa,eACvBA,EAAM,QAAa,cACrBG,EACEf,EAACU,EAAA,CAAW,WAAYI,EAAY,WAAYF,EAC7C,SAAAG,EACH,GAKCE,EAAkBH,EAAYC,EAAUH,EAAOC,CAAM,CAC9D,CAEO,SAASI,EACdH,EACAC,EACAH,EAMAC,EAAS,GACT,CACA,KAAM,CAAE,aAAAK,EAAc,UAAAC,EAAW,MAAAC,EAAO,WAAAC,CAAW,EAAIP,EACjD,CAAE,QAAAQ,EAAS,eAAAC,CAAe,EAAIX,EAC9BY,EAAgBhB,EAAa,EAAK,EACpCa,IACFG,EAAc,QAAU,IAG1B,MAAMC,EACJJ,GAAcG,EAAc,SAAWD,GAAkBV,EAE3D,OAAOR,EAAQ,IAAM,CACnB,GAAI,CAACoB,EACH,OAAOV,EAIT,IAAIW,EAAOxB,EAAS,QAAQa,CAAQ,EAGhCO,GAAWJ,IACbQ,EAAOA,EAAK,IAAKV,GACRZ,EAAeY,CAAK,EACvBb,EACEa,EACA,OACAhB,EAACW,EAAA,CAAM,KAAMO,EAAa,MAAM,WAC5B,SAAAF,EAAc,MAAM,SACxB,CACF,EACAA,CACL,GAGH,MAAMW,EACJ3B,EAACO,EAAoB,SAApB,CAA6B,MAAOW,EAClC,SAAAQ,EACH,EAGF,GAAIH,IAAmB,GACrB,OAAOI,EAGT,GAAI1B,GAAS,CAACW,EAAM,oBAAqB,CAGvC,MAAMgB,EAAa,CACjB,MAFiBR,GAASC,EAAaf,EAAiBc,EAAM,KAAK,EAAI,EAGzE,EAEA,OACEpB,EAAC,QAAK,UAAW,GAAGmB,GAAa,4BAA6B,MAAOS,EAClE,SAAAD,EACH,CAEJ,CAEA,OAAOA,CACT,EAAG,CACDJ,EACAX,EAAM,oBACNa,EACAP,EACAH,EACAK,EACAC,EACAF,CACF,CAAC,CACH",
6
+ "names": ["jsx", "isWeb", "Children", "cloneElement", "isValidElement", "useMemo", "variableToString", "ThemeManagerContext", "useServerRef", "useChangeThemeEffect", "ThemeDebug", "Theme", "props", "isRoot", "themeState", "children", "child", "useThemedChildren", "themeManager", "className", "theme", "isNewTheme", "shallow", "forceClassName", "hasEverThemed", "shouldRenderChildrenWithTheme", "next", "wrapped", "colorStyle"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{jsx as h}from"react/jsx-runtime";import{isWeb as b}from"@tamagui/constants";import{Children as d,cloneElement as u,isValidElement as g}from"react";import{variableToString as y}from"../createVariable.js";import{ThemeManagerContext as v}from"../helpers/ThemeManagerContext.js";import{useServerRef as N}from"../hooks/useServerHooks.js";import{useChangeThemeEffect as P}from"../hooks/useTheme.js";function R(e){if(e.disable)return e.children;const r=!!e._isRoot,n=P(e,r),a=e["data-themeable"]?d.map(e.children,t=>u(t,{["data-themeable"]:!0})):e.children;return w(n,a,e,r)}function w(e,r,n,a=!1){const{themeManager:t,isNewTheme:s,className:T,theme:i}=e,{shallow:p,forceClassName:f}=n,c=N(!1);if(s&&(c.current=!0),s||c.current||f||a){let m=d.toArray(r);p&&t&&(m=m.map(o=>g(o)?u(o,void 0,h(R,{name:t.state.parentName,children:o.props.children})):o));const l=h(v.Provider,{value:t,children:m});if(f===!1)return l;if(b&&!n.passPropsToChildren){const C={color:i&&s?y(i.color):""};return h("span",{className:`${T||""} _dsp_contents`,style:C,children:l})}return l}return r}export{R as Theme,w as useThemedChildren};
1
+ import{jsx as m}from"react/jsx-runtime";import{isWeb as g}from"@tamagui/constants";import{Children as T,cloneElement as p,isValidElement as P,useMemo as v}from"react";import{variableToString as N}from"../createVariable.js";import{ThemeManagerContext as y}from"../helpers/ThemeManagerContext.js";import{useServerRef as E}from"../hooks/useServerHooks.js";import{useChangeThemeEffect as R}from"../hooks/useTheme.js";import{ThemeDebug as D}from"./ThemeDebug";function S(e){if(e.disable)return e.children;const t=!!e._isRoot,r=R(e,t);let n=e["data-themeable"]?T.map(e.children,o=>p(o,{["data-themeable"]:!0})):e.children;return process.env.NODE_ENV==="development"&&e.debug==="visualize"&&(n=m(D,{themeState:r,themeProps:e,children:n})),_(r,n,e,t)}function _(e,t,r,n=!1){const{themeManager:o,className:u,theme:l,isNewTheme:s}=e,{shallow:C,forceClassName:h}=r,d=E(!1);s&&(d.current=!0);const c=s||d.current||h||n;return v(()=>{if(!c)return t;let i=T.toArray(t);C&&o&&(i=i.map(a=>P(a)?p(a,void 0,m(S,{name:o.state.parentName,children:a.props.children})):a));const f=m(y.Provider,{value:o,children:i});if(h===!1)return f;if(g&&!r.passPropsToChildren){const b={color:l&&s?N(l.color):""};return m("span",{className:`${u||""} _dsp_contents is_Theme`,style:b,children:f})}return f},[h,r.passPropsToChildren,c,o,t,l,s,u])}export{S as Theme,_ as useThemedChildren};
2
2
  //# sourceMappingURL=Theme.mjs.map
@@ -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 } 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 { ThemeProps } from '../types.js'\n\nexport function Theme(props: ThemeProps) {\n // @ts-expect-error only for internal views\n if (props.disable) return props.children\n const isRoot = !!props['_isRoot']\n const themeState = useChangeThemeEffect(props, isRoot)\n const children = props['data-themeable']\n ? Children.map(props.children, (child) =>\n cloneElement(child, { ['data-themeable']: true })\n )\n : props.children\n\n return useThemedChildren(themeState, children, props, isRoot)\n}\n\nexport function useThemedChildren(\n themeState: ChangedThemeResponse,\n children: any,\n options: {\n forceClassName?: boolean\n shallow?: boolean\n passPropsToChildren?: boolean\n },\n isRoot = false\n) {\n const { themeManager, isNewTheme, className, theme } = themeState\n const { shallow, forceClassName } = options\n const hasEverThemed = useServerRef(false)\n if (isNewTheme) {\n hasEverThemed.current = true\n }\n\n if (isNewTheme || hasEverThemed.current || forceClassName || isRoot) {\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 // tried this but themes css doesn't fully like it\n // if (shouldAttachClassName && options.passPropsToChildren) {\n // next = next.map((child: any) => {\n // const childStyle = child.props?.style\n // console.log('pass it down', className, child.props.className || '')\n // const newProps = {\n // className: (child.props.className || '') + ' ' + className,\n // style: Array.isArray(childStyle)\n // ? [colorStyle, ...childStyle]\n // : {\n // ...colorStyle,\n // ...childStyle,\n // },\n // }\n // return isValidElement(child) ? cloneElement(child as any, newProps) : 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 && !options.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`} style={colorStyle}>\n {wrapped}\n </span>\n )\n }\n\n return wrapped\n }\n\n return children\n}\n"],
5
- "mappings": "AAmDc,cAAAA,MAAA,oBAnDd,OAAS,SAAAC,MAAa,qBACtB,OAAS,YAAAC,EAAU,gBAAAC,EAAc,kBAAAC,MAAsB,QAEvD,OAAS,oBAAAC,MAAwB,uBACjC,OAAS,uBAAAC,MAA2B,oCACpC,OAAS,gBAAAC,MAAoB,6BAC7B,OAA+B,wBAAAC,MAA4B,uBAGpD,SAASC,EAAMC,EAAmB,CAEvC,GAAIA,EAAM,QAAS,OAAOA,EAAM,SAChC,MAAMC,EAAS,CAAC,CAACD,EAAM,QACjBE,EAAaJ,EAAqBE,EAAOC,CAAM,EAC/CE,EAAWH,EAAM,gBAAgB,EACnCR,EAAS,IAAIQ,EAAM,SAAWI,GAC5BX,EAAaW,EAAO,CAAE,CAAC,gBAAgB,EAAG,EAAK,CAAC,CAClD,EACAJ,EAAM,SAEV,OAAOK,EAAkBH,EAAYC,EAAUH,EAAOC,CAAM,CAC9D,CAEO,SAASI,EACdH,EACAC,EACAG,EAKAL,EAAS,GACT,CACA,KAAM,CAAE,aAAAM,EAAc,WAAAC,EAAY,UAAAC,EAAW,MAAAC,CAAM,EAAIR,EACjD,CAAE,QAAAS,EAAS,eAAAC,CAAe,EAAIN,EAC9BO,EAAgBhB,EAAa,EAAK,EAKxC,GAJIW,IACFK,EAAc,QAAU,IAGtBL,GAAcK,EAAc,SAAWD,GAAkBX,EAAQ,CAEnE,IAAIa,EAAOtB,EAAS,QAAQW,CAAQ,EAGhCQ,GAAWJ,IACbO,EAAOA,EAAK,IAAKV,GACRV,EAAeU,CAAK,EACvBX,EACEW,EACA,OACAd,EAACS,EAAA,CAAM,KAAMQ,EAAa,MAAM,WAC5B,SAAAH,EAAc,MAAM,SACxB,CACF,EACAA,CACL,GAqBH,MAAMW,EACJzB,EAACM,EAAoB,SAApB,CAA6B,MAAOW,EAClC,SAAAO,EACH,EAGF,GAAIF,IAAmB,GACrB,OAAOG,EAGT,GAAIxB,GAAS,CAACe,EAAQ,oBAAqB,CAGzC,MAAMU,EAAa,CACjB,MAFiBN,GAASF,EAAab,EAAiBe,EAAM,KAAK,EAAI,EAGzE,EAEA,OACEpB,EAAC,QAAK,UAAW,GAAGmB,GAAa,mBAAoB,MAAOO,EACzD,SAAAD,EACH,CAEJ,CAEA,OAAOA,CACT,CAEA,OAAOZ,CACT",
6
- "names": ["jsx", "isWeb", "Children", "cloneElement", "isValidElement", "variableToString", "ThemeManagerContext", "useServerRef", "useChangeThemeEffect", "Theme", "props", "isRoot", "themeState", "children", "child", "useThemedChildren", "options", "themeManager", "isNewTheme", "className", "theme", "shallow", "forceClassName", "hasEverThemed", "next", "wrapped", "colorStyle"]
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,cAAAA,MAAA,oBA5BR,OAAS,SAAAC,MAAa,qBACtB,OAAS,YAAAC,EAAU,gBAAAC,EAAc,kBAAAC,EAAkC,WAAAC,MAAe,QAElF,OAAS,oBAAAC,MAAwB,uBACjC,OAAS,uBAAAC,MAA2B,oCACpC,OAAS,gBAAAC,MAAoB,6BAC7B,OAA+B,wBAAAC,MAA4B,uBAE3D,OAAS,cAAAC,MAAkB,eAEpB,SAASC,EAAMC,EAAmB,CAEvC,GAAIA,EAAM,QACR,OAAOA,EAAM,SAGf,MAAMC,EAAS,CAAC,CAACD,EAAM,QACjBE,EAAaL,EAAqBG,EAAOC,CAAM,EAErD,IAAIE,EAAWH,EAAM,gBAAgB,EACjCV,EAAS,IAAIU,EAAM,SAAWI,GAC5Bb,EAAaa,EAAO,CAAE,CAAC,gBAAgB,EAAG,EAAK,CAAC,CAClD,EACAJ,EAAM,SAEV,OAAI,QAAQ,IAAI,WAAa,eACvBA,EAAM,QAAa,cACrBG,EACEf,EAACU,EAAA,CAAW,WAAYI,EAAY,WAAYF,EAC7C,SAAAG,EACH,GAKCE,EAAkBH,EAAYC,EAAUH,EAAOC,CAAM,CAC9D,CAEO,SAASI,EACdH,EACAC,EACAH,EAMAC,EAAS,GACT,CACA,KAAM,CAAE,aAAAK,EAAc,UAAAC,EAAW,MAAAC,EAAO,WAAAC,CAAW,EAAIP,EACjD,CAAE,QAAAQ,EAAS,eAAAC,CAAe,EAAIX,EAC9BY,EAAgBhB,EAAa,EAAK,EACpCa,IACFG,EAAc,QAAU,IAG1B,MAAMC,EACJJ,GAAcG,EAAc,SAAWD,GAAkBV,EAE3D,OAAOR,EAAQ,IAAM,CACnB,GAAI,CAACoB,EACH,OAAOV,EAIT,IAAIW,EAAOxB,EAAS,QAAQa,CAAQ,EAGhCO,GAAWJ,IACbQ,EAAOA,EAAK,IAAKV,GACRZ,EAAeY,CAAK,EACvBb,EACEa,EACA,OACAhB,EAACW,EAAA,CAAM,KAAMO,EAAa,MAAM,WAC5B,SAAAF,EAAc,MAAM,SACxB,CACF,EACAA,CACL,GAGH,MAAMW,EACJ3B,EAACO,EAAoB,SAApB,CAA6B,MAAOW,EAClC,SAAAQ,EACH,EAGF,GAAIH,IAAmB,GACrB,OAAOI,EAGT,GAAI1B,GAAS,CAACW,EAAM,oBAAqB,CAGvC,MAAMgB,EAAa,CACjB,MAFiBR,GAASC,EAAaf,EAAiBc,EAAM,KAAK,EAAI,EAGzE,EAEA,OACEpB,EAAC,QAAK,UAAW,GAAGmB,GAAa,4BAA6B,MAAOS,EAClE,SAAAD,EACH,CAEJ,CAEA,OAAOA,CACT,EAAG,CACDJ,EACAX,EAAM,oBACNa,EACAP,EACAH,EACAK,EACAC,EACAF,CACF,CAAC,CACH",
6
+ "names": ["jsx", "isWeb", "Children", "cloneElement", "isValidElement", "useMemo", "variableToString", "ThemeManagerContext", "useServerRef", "useChangeThemeEffect", "ThemeDebug", "Theme", "props", "isRoot", "themeState", "children", "child", "useThemedChildren", "themeManager", "className", "theme", "isNewTheme", "shallow", "forceClassName", "hasEverThemed", "shouldRenderChildrenWithTheme", "next", "wrapped", "colorStyle"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ import{jsxs as m}from"react/jsx-runtime";function h({themeState:e,themeProps:n,children:r,onChangeCount:p}){var a,s,o,i;return process.env.NODE_ENV==="development"?m("div",{style:{whiteSpace:"pre",background:"green",display:"inline",border:"1px solid #ccc",margin:20},children:[m("code",{children:["<Theme />\xA0",JSON.stringify({name:e.name,className:e.className,inverse:n.inverse,forceClassName:n.forceClassName,parent:(a=e.themeManager)==null?void 0:a.state.parentName,id:(s=e.themeManager)==null?void 0:s.id,parentId:(i=(o=e.themeManager)==null?void 0:o.parentManager)==null?void 0:i.id,isNew:e.isNewTheme,onChangeCount:p},null,2)]}),r]}):r}export{h as ThemeDebug};
2
+ //# sourceMappingURL=ThemeDebug.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/views/ThemeDebug.tsx"],
4
+ "sourcesContent": ["import { ChangedThemeResponse } from '../hooks/useTheme.js'\nimport { ThemeProps } from '../types.js'\n\nexport function ThemeDebug({\n themeState,\n themeProps,\n children,\n onChangeCount,\n}: {\n themeState: ChangedThemeResponse\n themeProps: ThemeProps\n onChangeCount?: number\n children: any\n}) {\n if (process.env.NODE_ENV === 'development') {\n return (\n <div\n style={{\n whiteSpace: 'pre',\n background: 'green',\n display: 'inline',\n border: '1px solid #ccc',\n margin: 20,\n }}\n >\n <code>\n &lt;Theme /&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 },\n null,\n 2\n )}\n </code>\n {children}\n </div>\n )\n }\n return children\n}\n"],
5
+ "mappings": "AAyBQ,eAAAA,MAAA,oBAtBD,SAASC,EAAW,CACzB,WAAAC,EACA,WAAAC,EACA,SAAAC,EACA,cAAAC,CACF,EAKG,CAbH,IAAAC,EAAAC,EAAAC,EAAAC,EAcE,OAAI,QAAQ,IAAI,WAAa,cAEzBT,EAAC,OACC,MAAO,CACL,WAAY,MACZ,WAAY,QACZ,QAAS,SACT,OAAQ,iBACR,OAAQ,EACV,EAEA,UAAAA,EAAC,QAAK,0BAEH,KAAK,UACJ,CACE,KAAME,EAAW,KACjB,UAAWA,EAAW,UACtB,QAASC,EAAW,QACpB,eAAgBA,EAAW,eAC3B,QAAQG,EAAAJ,EAAW,eAAX,YAAAI,EAAyB,MAAM,WACvC,IAAIC,EAAAL,EAAW,eAAX,YAAAK,EAAyB,GAC7B,UAAUE,GAAAD,EAAAN,EAAW,eAAX,YAAAM,EAAyB,gBAAzB,YAAAC,EAAwC,GAClD,MAAOP,EAAW,WAClB,cAAAG,CACF,EACA,KACA,CACF,GACF,EACCD,GACH,EAGGA,CACT",
6
+ "names": ["jsxs", "ThemeDebug", "themeState", "themeProps", "children", "onChangeCount", "_a", "_b", "_c", "_d"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{jsxs as m}from"react/jsx-runtime";function h({themeState:e,themeProps:n,children:r,onChangeCount:p}){var a,s,o,i;return process.env.NODE_ENV==="development"?m("div",{style:{whiteSpace:"pre",background:"green",display:"inline",border:"1px solid #ccc",margin:20},children:[m("code",{children:["<Theme />\xA0",JSON.stringify({name:e.name,className:e.className,inverse:n.inverse,forceClassName:n.forceClassName,parent:(a=e.themeManager)==null?void 0:a.state.parentName,id:(s=e.themeManager)==null?void 0:s.id,parentId:(i=(o=e.themeManager)==null?void 0:o.parentManager)==null?void 0:i.id,isNew:e.isNewTheme,onChangeCount:p},null,2)]}),r]}):r}export{h as ThemeDebug};
2
+ //# sourceMappingURL=ThemeDebug.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/views/ThemeDebug.tsx"],
4
+ "sourcesContent": ["import { ChangedThemeResponse } from '../hooks/useTheme.js'\nimport { ThemeProps } from '../types.js'\n\nexport function ThemeDebug({\n themeState,\n themeProps,\n children,\n onChangeCount,\n}: {\n themeState: ChangedThemeResponse\n themeProps: ThemeProps\n onChangeCount?: number\n children: any\n}) {\n if (process.env.NODE_ENV === 'development') {\n return (\n <div\n style={{\n whiteSpace: 'pre',\n background: 'green',\n display: 'inline',\n border: '1px solid #ccc',\n margin: 20,\n }}\n >\n <code>\n &lt;Theme /&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 },\n null,\n 2\n )}\n </code>\n {children}\n </div>\n )\n }\n return children\n}\n"],
5
+ "mappings": "AAyBQ,eAAAA,MAAA,oBAtBD,SAASC,EAAW,CACzB,WAAAC,EACA,WAAAC,EACA,SAAAC,EACA,cAAAC,CACF,EAKG,CAbH,IAAAC,EAAAC,EAAAC,EAAAC,EAcE,OAAI,QAAQ,IAAI,WAAa,cAEzBT,EAAC,OACC,MAAO,CACL,WAAY,MACZ,WAAY,QACZ,QAAS,SACT,OAAQ,iBACR,OAAQ,EACV,EAEA,UAAAA,EAAC,QAAK,0BAEH,KAAK,UACJ,CACE,KAAME,EAAW,KACjB,UAAWA,EAAW,UACtB,QAASC,EAAW,QACpB,eAAgBA,EAAW,eAC3B,QAAQG,EAAAJ,EAAW,eAAX,YAAAI,EAAyB,MAAM,WACvC,IAAIC,EAAAL,EAAW,eAAX,YAAAK,EAAyB,GAC7B,UAAUE,GAAAD,EAAAN,EAAW,eAAX,YAAAM,EAAyB,gBAAzB,YAAAC,EAAwC,GAClD,MAAOP,EAAW,WAClB,cAAAG,CACF,EACA,KACA,CACF,GACF,EACCD,GACH,EAGGA,CACT",
6
+ "names": ["jsxs", "ThemeDebug", "themeState", "themeProps", "children", "onChangeCount", "_a", "_b", "_c", "_d"]
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/web",
3
- "version": "1.13.4",
3
+ "version": "1.14.1",
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.13.4",
31
- "@tamagui/constants": "1.13.4",
32
- "@tamagui/helpers": "1.13.4",
33
- "@tamagui/normalize-css-color": "1.13.4",
34
- "@tamagui/use-did-finish-ssr": "1.13.4",
35
- "@tamagui/use-event": "1.13.4",
36
- "@tamagui/use-force-update": "1.13.4"
30
+ "@tamagui/compose-refs": "1.14.1",
31
+ "@tamagui/constants": "1.14.1",
32
+ "@tamagui/helpers": "1.14.1",
33
+ "@tamagui/normalize-css-color": "1.14.1",
34
+ "@tamagui/use-did-finish-ssr": "1.14.1",
35
+ "@tamagui/use-event": "1.14.1",
36
+ "@tamagui/use-force-update": "1.14.1"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "react": "*"
40
40
  },
41
41
  "devDependencies": {
42
- "@tamagui/build": "1.13.4",
42
+ "@tamagui/build": "1.14.1",
43
43
  "@testing-library/react": "^13.4.0",
44
44
  "csstype": "^3.0.10",
45
45
  "react": "^18.2.0",
@@ -12,6 +12,7 @@ import React, {
12
12
  useEffect,
13
13
  useId,
14
14
  useRef,
15
+ useState,
15
16
  } from 'react'
16
17
 
17
18
  import { onConfiguredOnce } from './config.js'
@@ -50,6 +51,7 @@ import { Slot } from './views/Slot.js'
50
51
  import { Stack } from './views/Stack.js'
51
52
  import { Text } from './views/Text.js'
52
53
  import { useThemedChildren } from './views/Theme.js'
54
+ import { ThemeDebug } from './views/ThemeDebug.js'
53
55
 
54
56
  // let t
55
57
  // import { timer } from '@tamagui/timer'
@@ -183,7 +185,9 @@ export function createComponent<
183
185
  didAccessThemeVariableValue?: boolean
184
186
  }
185
187
  )
186
- stateRef.current ??= {}
188
+ stateRef.current ||= {}
189
+
190
+ const hostRef = useServerRef<TamaguiElement>(null)
187
191
 
188
192
  /**
189
193
  * Component state for tracking animations, pseudos
@@ -290,9 +294,10 @@ export function createComponent<
290
294
  componentName,
291
295
  reset: props.reset,
292
296
  inverse: props.themeInverse,
293
- // @ts-expect-error
297
+ // @ts-ignore this is internal use only
294
298
  disable: props['data-themeable'],
295
- debug: props.debug,
299
+ debug:
300
+ process.env.NODE_ENV === 'development' && props.debug ? { hostRef } : undefined,
296
301
  shouldUpdate: () => !!stateRef.current.didAccessThemeVariableValue,
297
302
  })!
298
303
 
@@ -342,8 +347,6 @@ export function createComponent<
342
347
  keys: noClassNames && isMediaSpaced ? (splitStyles.hasMedia as any) : null,
343
348
  })
344
349
 
345
- const hostRef = useServerRef<TamaguiElement>(null)
346
-
347
350
  // animation setup
348
351
  const isAnimatedReactNativeWeb = isAnimated && avoidClassesWhileAnimating
349
352
 
@@ -730,6 +733,29 @@ export function createComponent<
730
733
  // passPropsToChildren: true,
731
734
  })
732
735
 
736
+ if (process.env.NODE_ENV === 'development') {
737
+ if (props['debug'] === 'visualize') {
738
+ const [onChangeCount, setOnChangeCount] = useState(0)
739
+
740
+ useEffect(() => {
741
+ themeState.themeManager?.onChangeTheme((name, manager) => {
742
+ setOnChangeCount((p) => ++p)
743
+ console.warn(`🖤`, name)
744
+ })
745
+ }, [themeState.themeManager])
746
+
747
+ content = (
748
+ <ThemeDebug
749
+ themeState={themeState}
750
+ themeProps={props}
751
+ onChangeCount={onChangeCount}
752
+ >
753
+ {content}
754
+ </ThemeDebug>
755
+ )
756
+ }
757
+ }
758
+
733
759
  if (process.env.TAMAGUI_TARGET === 'web') {
734
760
  if (events || isAnimatedReactNativeWeb) {
735
761
  content = (
@@ -26,7 +26,10 @@ export function hasNoThemeUpdatingProps(props: ThemeProps) {
26
26
  return !(props.name || props.componentName || props.inverse || props.reset)
27
27
  }
28
28
 
29
+ let uid = 0
30
+
29
31
  export class ThemeManager {
32
+ id = uid++
30
33
  themeListeners = new Set<ThemeListener>()
31
34
  parentManager: ThemeManager | null = null
32
35
  state: ThemeManagerState = emptyState
@@ -41,26 +44,28 @@ export class ThemeManager {
41
44
  }
42
45
  if (!parentManager) {
43
46
  if (process.env.NODE_ENV !== 'production') {
44
- console.trace()
45
- throw new Error(`No parent manager given`)
47
+ throw new Error(
48
+ `No parent manager given, this is likely due to duplicated Tamagui dependencies. Check your lockfile for mis-matched versions.`
49
+ )
46
50
  }
47
51
  throw `❌`
48
52
  }
49
- // copy over listeners
50
- this.themeListeners = parentManager.themeListeners
51
53
 
52
54
  // no change no props
53
55
  if (hasNoThemeUpdatingProps(props)) {
54
56
  return parentManager
55
57
  }
58
+
56
59
  if (parentManager) {
57
60
  this.parentManager = parentManager
58
61
  }
62
+
59
63
  const updatedState = this.getStateIfChanged(props)
60
64
  if (updatedState) {
61
65
  this.state = updatedState
62
66
  return
63
67
  }
68
+
64
69
  return parentManager || this
65
70
  }
66
71
 
@@ -76,6 +81,7 @@ export class ThemeManager {
76
81
  }
77
82
  const nextState = this.getStateIfChanged(props)
78
83
  if (nextState) {
84
+ this.props = props
79
85
  this.state = nextState
80
86
  return true
81
87
  }
@@ -159,9 +165,9 @@ export class ThemeManager {
159
165
  }
160
166
  }
161
167
 
162
- function getNextThemeClassName(name: string, isInverting = false) {
168
+ function getNextThemeClassName(name: string, props: ThemeProps) {
163
169
  const next = `t_sub_theme ${THEME_CLASSNAME_PREFIX}${name}`
164
- if (isInverting) {
170
+ if (props.inverse || props.forceClassName) {
165
171
  return (
166
172
  next +
167
173
  // ensure you invert to base dark as well as specific dark
@@ -172,24 +178,20 @@ function getNextThemeClassName(name: string, isInverting = false) {
172
178
  return next.replace('light_', '').replace('dark_', '')
173
179
  }
174
180
 
175
- const cache = new WeakMap<ThemeProps, [ThemeManager, ThemeManagerState | null]>()
176
-
177
181
  function getState(
178
182
  props: ThemeProps,
179
183
  parentManager?: ThemeManager | null
180
184
  ): ThemeManagerState | null {
181
- const cached = cache.get(props)
182
- if (cached && cached[0] === parentManager) {
183
- return cached[1]
184
- }
185
-
186
185
  const themes = getThemes()
187
186
 
188
187
  if (props.name && props.reset) {
189
188
  throw new Error('Cannot reset + set new name')
190
189
  }
190
+
191
191
  if (props.reset && !parentManager?.parentManager) {
192
- console.warn('Cannot reset no grandparent exists')
192
+ if (process.env.NODE_ENV === 'development') {
193
+ console.warn('Cannot reset no grandparent exists')
194
+ }
193
195
  return null
194
196
  }
195
197
 
@@ -204,12 +206,12 @@ function getState(
204
206
  // components look for most specific, fallback upwards
205
207
  const base = parentName.split(THEME_NAME_SEPARATOR)
206
208
  const lastSegment = base[base.length - 1]
207
- const isParentAComponentTheme =
209
+ const isParentComponentTheme =
208
210
  parentName && lastSegment[0].toUpperCase() === lastSegment[0]
209
- if (isParentAComponentTheme) {
211
+ if (isParentComponentTheme) {
210
212
  base.pop() // always remove componentName they can't nest
211
213
  }
212
- const parentBaseTheme = isParentAComponentTheme
214
+ const parentBaseTheme = isParentComponentTheme
213
215
  ? base.slice(0, base.length).join(THEME_NAME_SEPARATOR)
214
216
  : parentName
215
217
  const max = base.length
@@ -218,9 +220,18 @@ function getState(
218
220
  ? max // component name only don't search upwards
219
221
  : 0
220
222
 
221
- // prettier-ignore
222
223
  // eslint-disable-next-line no-console
223
- if (process.env.NODE_ENV === 'development' && props.debug === 'verbose') [ console.groupCollapsed('ThemeManager.getState()', props, { parentName, parentBaseTheme, base, min, max, isParentAComponentTheme }), console.trace(), console.groupEnd() ]
224
+ if (process.env.NODE_ENV === 'development' && typeof props.debug === 'string') {
225
+ console.groupCollapsed('ThemeManager.getState()')
226
+ console.log({
227
+ parentName,
228
+ parentBaseTheme,
229
+ base,
230
+ min,
231
+ max,
232
+ isParentComponentTheme,
233
+ })
234
+ }
224
235
 
225
236
  for (let i = max; i >= min; i--) {
226
237
  let prefix = base.slice(0, i).join(THEME_NAME_SEPARATOR)
@@ -243,12 +254,8 @@ function getState(
243
254
  if (componentName) {
244
255
  // components only look for component themes
245
256
  if (nextName) {
246
- potentials.push(
247
- `${prefix.slice(
248
- 0,
249
- prefix.indexOf(THEME_NAME_SEPARATOR)
250
- )}_${nextName}_${componentName}`
251
- )
257
+ const beforeSeparator = prefix.slice(0, prefix.indexOf(THEME_NAME_SEPARATOR))
258
+ potentials.push(`${beforeSeparator}_${nextName}_${componentName}`)
252
259
  }
253
260
  potentials.push(`${prefix}_${componentName}`)
254
261
  if (nextName) {
@@ -258,27 +265,28 @@ function getState(
258
265
 
259
266
  const found = potentials.find((t) => t in themes)
260
267
 
261
- // eslint-disable-next-line no-console
262
- if (process.env.NODE_ENV === 'development' && props.debug === 'verbose')
263
- console.log('getState found', found, 'from', potentials, 'parentName', parentName)
268
+ if (process.env.NODE_ENV === 'development' && typeof props.debug === 'string') {
269
+ console.log(' - ', { found, potentials })
270
+ }
264
271
 
265
272
  if (found) {
266
- // optimization return null if not changed
267
- if (found === parentName) {
268
- break
269
- }
270
273
  result = {
271
274
  name: found,
272
275
  theme: getThemeUnwrapped(themes[found]),
273
- className: getNextThemeClassName(found, props.inverse),
276
+ className: getNextThemeClassName(found, props),
274
277
  parentName,
275
278
  }
276
279
  break
277
280
  }
278
281
  }
279
282
 
280
- if (parentManager) {
281
- cache.set(props, [parentManager, result])
283
+ // eslint-disable-next-line no-console
284
+ if (process.env.NODE_ENV === 'development' && typeof props.debug === 'string') {
285
+ console.log({
286
+ result,
287
+ })
288
+ console.trace()
289
+ console.groupEnd()
282
290
  }
283
291
 
284
292
  return result
@@ -881,14 +881,6 @@ export const getSplitStyles: StyleSplitter = (
881
881
  // always do this at the very end to preserve the order strictly (animations, origin)
882
882
  // and allow proper merging of all pseudos before applying
883
883
  if (flatTransforms) {
884
- if (process.env.NODE_ENV === 'development' && debug) {
885
- // eslint-disable-next-line no-console
886
- console.log(
887
- 'Merging flat transforms, transform before',
888
- [...(style.transform || [])],
889
- flatTransforms
890
- )
891
- }
892
884
  mergeTransforms(style, flatTransforms, true)
893
885
  }
894
886