@tamagui/web 1.14.0 → 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 (34) 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/views/Theme.js +1 -1
  6. package/dist/cjs/views/Theme.js.map +3 -3
  7. package/dist/cjs/views/ThemeDebug.js +2 -0
  8. package/dist/cjs/views/ThemeDebug.js.map +7 -0
  9. package/dist/esm/createComponent.js +2 -2
  10. package/dist/esm/createComponent.js.map +3 -3
  11. package/dist/esm/createComponent.mjs +2 -2
  12. package/dist/esm/createComponent.mjs.map +3 -3
  13. package/dist/esm/helpers/ThemeManager.js +1 -1
  14. package/dist/esm/helpers/ThemeManager.js.map +3 -3
  15. package/dist/esm/helpers/ThemeManager.mjs +1 -1
  16. package/dist/esm/helpers/ThemeManager.mjs.map +3 -3
  17. package/dist/esm/views/Theme.js +1 -1
  18. package/dist/esm/views/Theme.js.map +3 -3
  19. package/dist/esm/views/Theme.mjs +1 -1
  20. package/dist/esm/views/Theme.mjs.map +3 -3
  21. package/dist/esm/views/ThemeDebug.js +2 -0
  22. package/dist/esm/views/ThemeDebug.js.map +7 -0
  23. package/dist/esm/views/ThemeDebug.mjs +2 -0
  24. package/dist/esm/views/ThemeDebug.mjs.map +7 -0
  25. package/package.json +9 -9
  26. package/src/createComponent.tsx +7 -14
  27. package/src/helpers/ThemeManager.tsx +3 -3
  28. package/src/views/Theme.tsx +10 -20
  29. package/src/views/ThemeDebug.tsx +49 -0
  30. package/types/createComponent.d.ts.map +1 -1
  31. package/types/views/Theme.d.ts +3 -2
  32. package/types/views/Theme.d.ts.map +1 -1
  33. package/types/views/ThemeDebug.d.ts +9 -0
  34. 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, 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 { ThemeProps } from '../types.js'\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 <div style={{ display: 'inline', border: '1px solid #ccc' }}>\n <code>\n <pre>\n &lt;Theme /&gt;&nbsp;\n {JSON.stringify({\n name: themeState.themeManager?.state.name,\n parent: themeState.themeManager?.state.parentName,\n id: themeState.themeManager?.id,\n parentId: themeState.themeManager?.parentManager?.id,\n isNew: themeState.isNewTheme,\n })}\n </pre>\n </code>\n {children}\n </div>\n )\n }\n }\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, className, theme, isNewTheme } = themeState\n const { shallow, forceClassName } = options\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 // console.warn(`re-render Theme`)\n\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 && !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 is_Theme`} style={colorStyle}>\n {wrapped}\n </span>\n )\n }\n\n return wrapped\n }, [\n shouldRenderChildrenWithTheme,\n themeManager,\n children,\n theme,\n isNewTheme,\n className,\n ])\n}\n"],
5
- "mappings": "AA4BU,cAAAA,EACE,QAAAC,MADF,oBA5BV,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,uBAGpD,SAASC,EAAMC,EAAmB,CATzC,IAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAWE,GAAIL,EAAM,QACR,OAAOA,EAAM,SAGf,MAAMM,EAAS,CAAC,CAACN,EAAM,QACjBO,EAAaT,EAAqBE,EAAOM,CAAM,EAErD,IAAIE,EAAWR,EAAM,gBAAgB,EACjCT,EAAS,IAAIS,EAAM,SAAWS,GAC5BjB,EAAaiB,EAAO,CAAE,CAAC,gBAAgB,EAAG,EAAK,CAAC,CAClD,EACAT,EAAM,SAEV,OAAI,QAAQ,IAAI,WAAa,eACvBA,EAAM,QAAa,cACrBQ,EACEnB,EAAC,OAAI,MAAO,CAAE,QAAS,SA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AAK,UAAW,GAAGyB,GAAa,4BAA6B,MAAOS,EAClE,SAAAD,EACH,CAEJ,CAEA,OAAOA,CACT,EAAG,CACDF,EACAP,EACAJ,EACAM,EACAC,EACAF,CACF,CAAC,CACH",
6
- "names": ["jsx", "jsxs", "isWeb", "Children", "cloneElement", "isValidElement", "useMemo", "variableToString", "ThemeManagerContext", "useServerRef", "useChangeThemeEffect", "Theme", "props", "_a", "_b", "_c", "_d", "_e", "isRoot", "themeState", "children", "child", "useThemedChildren", "options", "themeManager", "className", "theme", "isNewTheme", "shallow", "forceClassName", "hasEverThemed", "shouldRenderChildrenWithTheme", "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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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.14.0",
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.14.0",
31
- "@tamagui/constants": "1.14.0",
32
- "@tamagui/helpers": "1.14.0",
33
- "@tamagui/normalize-css-color": "1.14.0",
34
- "@tamagui/use-did-finish-ssr": "1.14.0",
35
- "@tamagui/use-event": "1.14.0",
36
- "@tamagui/use-force-update": "1.14.0"
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.14.0",
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",
@@ -51,6 +51,7 @@ import { Slot } from './views/Slot.js'
51
51
  import { Stack } from './views/Stack.js'
52
52
  import { Text } from './views/Text.js'
53
53
  import { useThemedChildren } from './views/Theme.js'
54
+ import { ThemeDebug } from './views/ThemeDebug.js'
54
55
 
55
56
  // let t
56
57
  // import { timer } from '@tamagui/timer'
@@ -744,21 +745,13 @@ export function createComponent<
744
745
  }, [themeState.themeManager])
745
746
 
746
747
  content = (
747
- <>
748
+ <ThemeDebug
749
+ themeState={themeState}
750
+ themeProps={props}
751
+ onChangeCount={onChangeCount}
752
+ >
748
753
  {content}
749
- <code>
750
- <pre>
751
- {JSON.stringify({
752
- name: themeState.themeManager?.state.name,
753
- parent: themeState.themeManager?.state.parentName,
754
- id: themeState.themeManager?.id,
755
- parentId: themeState.themeManager?.parentManager?.id,
756
- isNew: themeState.isNewTheme,
757
- onChangeCount,
758
- })}
759
- </pre>
760
- </code>
761
- </>
754
+ </ThemeDebug>
762
755
  )
763
756
  }
764
757
  }
@@ -165,9 +165,9 @@ export class ThemeManager {
165
165
  }
166
166
  }
167
167
 
168
- function getNextThemeClassName(name: string, isInverting = false) {
168
+ function getNextThemeClassName(name: string, props: ThemeProps) {
169
169
  const next = `t_sub_theme ${THEME_CLASSNAME_PREFIX}${name}`
170
- if (isInverting) {
170
+ if (props.inverse || props.forceClassName) {
171
171
  return (
172
172
  next +
173
173
  // ensure you invert to base dark as well as specific dark
@@ -273,7 +273,7 @@ function getState(
273
273
  result = {
274
274
  name: found,
275
275
  theme: getThemeUnwrapped(themes[found]),
276
- className: getNextThemeClassName(found, props.inverse),
276
+ className: getNextThemeClassName(found, props),
277
277
  parentName,
278
278
  }
279
279
  break
@@ -5,7 +5,8 @@ import { variableToString } from '../createVariable.js'
5
5
  import { ThemeManagerContext } from '../helpers/ThemeManagerContext.js'
6
6
  import { useServerRef } from '../hooks/useServerHooks.js'
7
7
  import { ChangedThemeResponse, useChangeThemeEffect } from '../hooks/useTheme.js'
8
- import type { ThemeProps } from '../types.js'
8
+ import type { DebugProp, ThemeProps } from '../types.js'
9
+ import { ThemeDebug } from './ThemeDebug'
9
10
 
10
11
  export function Theme(props: ThemeProps) {
11
12
  // @ts-expect-error only for internal views
@@ -25,21 +26,9 @@ export function Theme(props: ThemeProps) {
25
26
  if (process.env.NODE_ENV === 'development') {
26
27
  if (props['debug'] === 'visualize') {
27
28
  children = (
28
- <div style={{ display: 'inline', border: '1px solid #ccc' }}>
29
- <code>
30
- <pre>
31
- &lt;Theme /&gt;&nbsp;
32
- {JSON.stringify({
33
- name: themeState.themeManager?.state.name,
34
- parent: themeState.themeManager?.state.parentName,
35
- id: themeState.themeManager?.id,
36
- parentId: themeState.themeManager?.parentManager?.id,
37
- isNew: themeState.isNewTheme,
38
- })}
39
- </pre>
40
- </code>
29
+ <ThemeDebug themeState={themeState} themeProps={props}>
41
30
  {children}
42
- </div>
31
+ </ThemeDebug>
43
32
  )
44
33
  }
45
34
  }
@@ -50,15 +39,16 @@ export function Theme(props: ThemeProps) {
50
39
  export function useThemedChildren(
51
40
  themeState: ChangedThemeResponse,
52
41
  children: any,
53
- options: {
42
+ props: {
54
43
  forceClassName?: boolean
55
44
  shallow?: boolean
56
45
  passPropsToChildren?: boolean
46
+ debug?: DebugProp
57
47
  },
58
48
  isRoot = false
59
49
  ) {
60
50
  const { themeManager, className, theme, isNewTheme } = themeState
61
- const { shallow, forceClassName } = options
51
+ const { shallow, forceClassName } = props
62
52
  const hasEverThemed = useServerRef(false)
63
53
  if (isNewTheme) {
64
54
  hasEverThemed.current = true
@@ -68,8 +58,6 @@ export function useThemedChildren(
68
58
  isNewTheme || hasEverThemed.current || forceClassName || isRoot
69
59
 
70
60
  return useMemo(() => {
71
- // console.warn(`re-render Theme`)
72
-
73
61
  if (!shouldRenderChildrenWithTheme) {
74
62
  return children
75
63
  }
@@ -102,7 +90,7 @@ export function useThemedChildren(
102
90
  return wrapped
103
91
  }
104
92
 
105
- if (isWeb && !options.passPropsToChildren) {
93
+ if (isWeb && !props.passPropsToChildren) {
106
94
  // in order to provide currentColor, set color by default
107
95
  const themeColor = theme && isNewTheme ? variableToString(theme.color) : ''
108
96
  const colorStyle = {
@@ -118,6 +106,8 @@ export function useThemedChildren(
118
106
 
119
107
  return wrapped
120
108
  }, [
109
+ forceClassName,
110
+ props.passPropsToChildren,
121
111
  shouldRenderChildrenWithTheme,
122
112
  themeManager,
123
113
  children,
@@ -0,0 +1,49 @@
1
+ import { ChangedThemeResponse } from '../hooks/useTheme.js'
2
+ import { ThemeProps } from '../types.js'
3
+
4
+ export function ThemeDebug({
5
+ themeState,
6
+ themeProps,
7
+ children,
8
+ onChangeCount,
9
+ }: {
10
+ themeState: ChangedThemeResponse
11
+ themeProps: ThemeProps
12
+ onChangeCount?: number
13
+ children: any
14
+ }) {
15
+ if (process.env.NODE_ENV === 'development') {
16
+ return (
17
+ <div
18
+ style={{
19
+ whiteSpace: 'pre',
20
+ background: 'green',
21
+ display: 'inline',
22
+ border: '1px solid #ccc',
23
+ margin: 20,
24
+ }}
25
+ >
26
+ <code>
27
+ &lt;Theme /&gt;&nbsp;
28
+ {JSON.stringify(
29
+ {
30
+ name: themeState.name,
31
+ className: themeState.className,
32
+ inverse: themeProps.inverse,
33
+ forceClassName: themeProps.forceClassName,
34
+ parent: themeState.themeManager?.state.parentName,
35
+ id: themeState.themeManager?.id,
36
+ parentId: themeState.themeManager?.parentManager?.id,
37
+ isNew: themeState.isNewTheme,
38
+ onChangeCount,
39
+ },
40
+ null,
41
+ 2
42
+ )}
43
+ </code>
44
+ {children}
45
+ </div>
46
+ )
47
+ }
48
+ return children
49
+ }
@@ -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;AAqBhB,eAAO,MAAM,qBAAqB,EAAE,qBAMnC,CAAA;AAeD,eAAO,MAAM,QAAQ,eAAsB,CAAA;AA8B3C,wBAAgB,eAAe,CAC7B,kBAAkB,SAA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CAAC,GAAG,kBAAkB,EACpD,eAAe,CAAC,EAAE,iBAAiB,4DA8xBpC;AAGD,eAAO,MAAM,QAAQ;YAAW;QAAE,QAAQ,CAAC,EAAE,GAAG,CAAA;KAAE;;CAAmB,CAAA;AAMrE,eAAO,MAAM,MAAM,0DA8CjB,CAAA;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,KAAK,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CAAA;IACnC,SAAS,CAAC,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,9 +1,10 @@
1
1
  import { ChangedThemeResponse } from '../hooks/useTheme.js';
2
- import type { ThemeProps } from '../types.js';
2
+ import type { DebugProp, ThemeProps } from '../types.js';
3
3
  export declare function Theme(props: ThemeProps): any;
4
- export declare function useThemedChildren(themeState: ChangedThemeResponse, children: any, options: {
4
+ export declare function useThemedChildren(themeState: ChangedThemeResponse, children: any, props: {
5
5
  forceClassName?: boolean;
6
6
  shallow?: boolean;
7
7
  passPropsToChildren?: boolean;
8
+ debug?: DebugProp;
8
9
  }, isRoot?: boolean): any;
9
10
  //# sourceMappingURL=Theme.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Theme.d.ts","sourceRoot":"","sources":["../../src/views/Theme.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,oBAAoB,EAAwB,MAAM,sBAAsB,CAAA;AACjF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7C,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,OAsCtC;AAED,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,oBAAoB,EAChC,QAAQ,EAAE,GAAG,EACb,OAAO,EAAE;IACP,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAC9B,EACD,MAAM,UAAQ,OAsEf"}
1
+ {"version":3,"file":"Theme.d.ts","sourceRoot":"","sources":["../../src/views/Theme.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,oBAAoB,EAAwB,MAAM,sBAAsB,CAAA;AACjF,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAGxD,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,OA0BtC;AAED,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,oBAAoB,EAChC,QAAQ,EAAE,GAAG,EACb,KAAK,EAAE;IACL,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,KAAK,CAAC,EAAE,SAAS,CAAA;CAClB,EACD,MAAM,UAAQ,OAsEf"}
@@ -0,0 +1,9 @@
1
+ import { ChangedThemeResponse } from '../hooks/useTheme.js';
2
+ import { ThemeProps } from '../types.js';
3
+ export declare function ThemeDebug({ themeState, themeProps, children, onChangeCount, }: {
4
+ themeState: ChangedThemeResponse;
5
+ themeProps: ThemeProps;
6
+ onChangeCount?: number;
7
+ children: any;
8
+ }): any;
9
+ //# sourceMappingURL=ThemeDebug.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThemeDebug.d.ts","sourceRoot":"","sources":["../../src/views/ThemeDebug.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,wBAAgB,UAAU,CAAC,EACzB,UAAU,EACV,UAAU,EACV,QAAQ,EACR,aAAa,GACd,EAAE;IACD,UAAU,EAAE,oBAAoB,CAAA;IAChC,UAAU,EAAE,UAAU,CAAA;IACtB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,EAAE,GAAG,CAAA;CACd,OAmCA"}