@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.
- package/dist/cjs/createComponent.js +2 -2
- package/dist/cjs/createComponent.js.map +3 -3
- package/dist/cjs/helpers/ThemeManager.js +1 -1
- package/dist/cjs/helpers/ThemeManager.js.map +3 -3
- package/dist/cjs/views/Theme.js +1 -1
- package/dist/cjs/views/Theme.js.map +3 -3
- package/dist/cjs/views/ThemeDebug.js +2 -0
- package/dist/cjs/views/ThemeDebug.js.map +7 -0
- package/dist/esm/createComponent.js +2 -2
- package/dist/esm/createComponent.js.map +3 -3
- package/dist/esm/createComponent.mjs +2 -2
- package/dist/esm/createComponent.mjs.map +3 -3
- package/dist/esm/helpers/ThemeManager.js +1 -1
- package/dist/esm/helpers/ThemeManager.js.map +3 -3
- package/dist/esm/helpers/ThemeManager.mjs +1 -1
- package/dist/esm/helpers/ThemeManager.mjs.map +3 -3
- package/dist/esm/views/Theme.js +1 -1
- package/dist/esm/views/Theme.js.map +3 -3
- package/dist/esm/views/Theme.mjs +1 -1
- package/dist/esm/views/Theme.mjs.map +3 -3
- package/dist/esm/views/ThemeDebug.js +2 -0
- package/dist/esm/views/ThemeDebug.js.map +7 -0
- package/dist/esm/views/ThemeDebug.mjs +2 -0
- package/dist/esm/views/ThemeDebug.mjs.map +7 -0
- package/package.json +9 -9
- package/src/createComponent.tsx +7 -14
- package/src/helpers/ThemeManager.tsx +3 -3
- package/src/views/Theme.tsx +10 -20
- package/src/views/ThemeDebug.tsx +49 -0
- package/types/createComponent.d.ts.map +1 -1
- package/types/views/Theme.d.ts +3 -2
- package/types/views/Theme.d.ts.map +1 -1
- package/types/views/ThemeDebug.d.ts +9 -0
- 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 <
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["jsx", "
|
|
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 <Theme /> \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 <Theme /> \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.
|
|
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.
|
|
31
|
-
"@tamagui/constants": "1.14.
|
|
32
|
-
"@tamagui/helpers": "1.14.
|
|
33
|
-
"@tamagui/normalize-css-color": "1.14.
|
|
34
|
-
"@tamagui/use-did-finish-ssr": "1.14.
|
|
35
|
-
"@tamagui/use-event": "1.14.
|
|
36
|
-
"@tamagui/use-force-update": "1.14.
|
|
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.
|
|
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",
|
package/src/createComponent.tsx
CHANGED
|
@@ -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
|
-
|
|
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,
|
|
168
|
+
function getNextThemeClassName(name: string, props: ThemeProps) {
|
|
169
169
|
const next = `t_sub_theme ${THEME_CLASSNAME_PREFIX}${name}`
|
|
170
|
-
if (
|
|
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
|
|
276
|
+
className: getNextThemeClassName(found, props),
|
|
277
277
|
parentName,
|
|
278
278
|
}
|
|
279
279
|
break
|
package/src/views/Theme.tsx
CHANGED
|
@@ -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
|
-
<
|
|
29
|
-
<code>
|
|
30
|
-
<pre>
|
|
31
|
-
<Theme />
|
|
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
|
-
</
|
|
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
|
-
|
|
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 } =
|
|
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 && !
|
|
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
|
+
<Theme />
|
|
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;
|
|
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,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"}
|
package/types/views/Theme.d.ts
CHANGED
|
@@ -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,
|
|
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;
|
|
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"}
|