@tamagui/web 1.15.7 → 1.15.9
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 -1
- package/dist/cjs/createComponent.js.map +2 -2
- package/dist/cjs/helpers/ThemeManager.js +1 -1
- package/dist/cjs/helpers/ThemeManager.js.map +2 -2
- package/dist/cjs/helpers/getSplitStyles.js +1 -1
- package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
- package/dist/cjs/helpers/themeable.js +1 -1
- package/dist/cjs/helpers/themeable.js.map +2 -2
- package/dist/cjs/hooks/useTheme.js +8 -5
- package/dist/cjs/hooks/useTheme.js.map +2 -2
- package/dist/cjs/views/Theme.js +2 -2
- package/dist/cjs/views/Theme.js.map +2 -2
- package/dist/cjs/views/ThemeDebug.js +4 -1
- package/dist/cjs/views/ThemeDebug.js.map +2 -2
- package/dist/esm/createComponent.js +2 -1
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/esm/createComponent.mjs +2 -1
- package/dist/esm/createComponent.mjs.map +2 -2
- package/dist/esm/helpers/ThemeManager.js +1 -1
- package/dist/esm/helpers/ThemeManager.js.map +2 -2
- package/dist/esm/helpers/ThemeManager.mjs +1 -1
- package/dist/esm/helpers/ThemeManager.mjs.map +2 -2
- package/dist/esm/helpers/getSplitStyles.js +1 -1
- package/dist/esm/helpers/getSplitStyles.js.map +2 -2
- package/dist/esm/helpers/getSplitStyles.mjs +1 -1
- package/dist/esm/helpers/getSplitStyles.mjs.map +2 -2
- package/dist/esm/helpers/themeable.js +1 -1
- package/dist/esm/helpers/themeable.js.map +2 -2
- package/dist/esm/helpers/themeable.mjs +1 -1
- package/dist/esm/helpers/themeable.mjs.map +2 -2
- package/dist/esm/hooks/useTheme.js +8 -5
- package/dist/esm/hooks/useTheme.js.map +2 -2
- package/dist/esm/hooks/useTheme.mjs +8 -5
- package/dist/esm/hooks/useTheme.mjs.map +2 -2
- package/dist/esm/views/Theme.js +2 -2
- package/dist/esm/views/Theme.js.map +2 -2
- package/dist/esm/views/Theme.mjs +2 -2
- package/dist/esm/views/Theme.mjs.map +2 -2
- package/dist/esm/views/ThemeDebug.js +4 -1
- package/dist/esm/views/ThemeDebug.js.map +2 -2
- package/dist/esm/views/ThemeDebug.mjs +4 -1
- package/dist/esm/views/ThemeDebug.mjs.map +2 -2
- package/package.json +9 -9
- package/src/createComponent.tsx +4 -1
- package/src/helpers/ThemeManager.tsx +1 -1
- package/src/helpers/getSplitStyles.tsx +1 -1
- package/src/helpers/themeable.tsx +1 -1
- package/src/hooks/useTheme.tsx +10 -6
- package/src/views/Theme.tsx +2 -2
- package/src/views/ThemeDebug.tsx +6 -1
- package/types/createComponent.d.ts.map +1 -1
- package/types/helpers/ThemeManager.d.ts +1 -1
- package/types/helpers/ThemeManager.d.ts.map +1 -1
- package/types/hooks/useTheme.d.ts.map +1 -1
- package/types/views/ThemeDebug.d.ts.map +1 -1
package/dist/esm/views/Theme.js
CHANGED
|
@@ -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["
|
|
15
|
+
let children = props["disable-child-theme"] ? Children.map(
|
|
16
16
|
props.children,
|
|
17
|
-
(child) => cloneElement(child, { ["data-
|
|
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['
|
|
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,
|
|
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,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,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;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/views/Theme.mjs
CHANGED
|
@@ -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["
|
|
15
|
+
let children = props["disable-child-theme"] ? Children.map(
|
|
16
16
|
props.children,
|
|
17
|
-
(child) => cloneElement(child, { ["data-
|
|
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['
|
|
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,
|
|
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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ClE,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
|
}
|
|
@@ -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 <Theme {id} /> \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": "
|
|
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 <Theme {id} /> \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,eAA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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 <Theme {id} /> \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": "
|
|
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 <Theme {id} /> \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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,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
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/web",
|
|
3
|
-
"version": "1.15.
|
|
3
|
+
"version": "1.15.9",
|
|
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.
|
|
31
|
-
"@tamagui/constants": "1.15.
|
|
32
|
-
"@tamagui/helpers": "1.15.
|
|
33
|
-
"@tamagui/normalize-css-color": "1.15.
|
|
34
|
-
"@tamagui/use-did-finish-ssr": "1.15.
|
|
35
|
-
"@tamagui/use-event": "1.15.
|
|
36
|
-
"@tamagui/use-force-update": "1.15.
|
|
30
|
+
"@tamagui/compose-refs": "1.15.9",
|
|
31
|
+
"@tamagui/constants": "1.15.9",
|
|
32
|
+
"@tamagui/helpers": "1.15.9",
|
|
33
|
+
"@tamagui/normalize-css-color": "1.15.9",
|
|
34
|
+
"@tamagui/use-did-finish-ssr": "1.15.9",
|
|
35
|
+
"@tamagui/use-event": "1.15.9",
|
|
36
|
+
"@tamagui/use-force-update": "1.15.9"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"react": "*"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@tamagui/build": "1.15.
|
|
42
|
+
"@tamagui/build": "1.15.9",
|
|
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
|
@@ -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:
|
|
301
|
+
disable: disableTheme,
|
|
299
302
|
debug:
|
|
300
303
|
process.env.NODE_ENV === 'development' && props.debug ? { hostRef } : undefined,
|
|
301
304
|
shouldUpdate: () => !!stateRef.current.didAccessThemeVariableValue,
|
|
@@ -268,7 +268,7 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
268
268
|
console.groupCollapsed('getSplitStyles (looping backwards)')
|
|
269
269
|
// prettier-ignore
|
|
270
270
|
// eslint-disable-next-line no-console
|
|
271
|
-
console.log({ props, staticConfig, shouldDoClasses, state, IS_STATIC, propKeys, styleState })
|
|
271
|
+
console.log({ props, staticConfig, shouldDoClasses, state, IS_STATIC, propKeys, styleState, theme: { ...theme } })
|
|
272
272
|
// eslint-disable-next-line no-console
|
|
273
273
|
console.groupEnd()
|
|
274
274
|
}
|
|
@@ -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
|
-
|
|
27
|
+
disable-child-theme
|
|
28
28
|
debug={props.debug}
|
|
29
29
|
reset={props.themeReset}
|
|
30
30
|
>
|
package/src/hooks/useTheme.tsx
CHANGED
|
@@ -158,14 +158,18 @@ export const useChangeThemeEffect = (
|
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
const parentManager = getNonComponentParentManager(useContext(ThemeManagerContext))
|
|
162
|
-
|
|
163
161
|
const {
|
|
164
162
|
debug,
|
|
165
163
|
// @ts-expect-error internal use only
|
|
166
164
|
disable,
|
|
167
165
|
} = props
|
|
168
166
|
|
|
167
|
+
let parentManager = useContext(ThemeManagerContext)
|
|
168
|
+
|
|
169
|
+
if (!disable) {
|
|
170
|
+
parentManager = getNonComponentParentManager(parentManager)
|
|
171
|
+
}
|
|
172
|
+
|
|
169
173
|
if (disable) {
|
|
170
174
|
if (!parentManager) throw `❌`
|
|
171
175
|
return {
|
|
@@ -183,12 +187,13 @@ export const useChangeThemeEffect = (
|
|
|
183
187
|
function getShouldUpdateTheme(
|
|
184
188
|
manager = themeManager,
|
|
185
189
|
nextState?: ThemeManagerState | null,
|
|
190
|
+
prevState: ThemeManagerState = state,
|
|
186
191
|
forceShouldChange = false
|
|
187
192
|
) {
|
|
188
193
|
const next = nextState || manager.getState(props, parentManager)
|
|
189
194
|
if (!next) return
|
|
190
195
|
if (disableUpdate?.() === true) return
|
|
191
|
-
if (!forceShouldChange && !manager.getStateShouldChange(next,
|
|
196
|
+
if (!forceShouldChange && !manager.getStateShouldChange(next, prevState)) return
|
|
192
197
|
return next
|
|
193
198
|
}
|
|
194
199
|
|
|
@@ -210,7 +215,7 @@ export const useChangeThemeEffect = (
|
|
|
210
215
|
return () => {
|
|
211
216
|
activeThemeManagers.delete(themeManager)
|
|
212
217
|
}
|
|
213
|
-
}, [isNewTheme, themeManager, state
|
|
218
|
+
}, [isNewTheme, themeManager, state])
|
|
214
219
|
|
|
215
220
|
// listen for parent change + notify children change
|
|
216
221
|
useLayoutEffect(() => {
|
|
@@ -303,9 +308,8 @@ export const useChangeThemeEffect = (
|
|
|
303
308
|
// which is correct, potentially in the future we can avoid forceChange and just know to
|
|
304
309
|
// update if keys.length is set + onChangeTheme called
|
|
305
310
|
const forceChange = Boolean(keys?.length)
|
|
306
|
-
|
|
307
311
|
const next = themeManager.getState(props, parentManager)
|
|
308
|
-
const nextState = getShouldUpdateTheme(themeManager, next, forceChange)
|
|
312
|
+
const nextState = getShouldUpdateTheme(themeManager, next, prev.state, forceChange)
|
|
309
313
|
|
|
310
314
|
if (nextState) {
|
|
311
315
|
state = nextState
|
package/src/views/Theme.tsx
CHANGED
|
@@ -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['
|
|
20
|
+
let children = props['disable-child-theme']
|
|
21
21
|
? Children.map(props.children, (child) =>
|
|
22
|
-
cloneElement(child, { ['data-
|
|
22
|
+
cloneElement(child, { ['data-disable-theme']: true })
|
|
23
23
|
)
|
|
24
24
|
: props.children
|
|
25
25
|
|
package/src/views/ThemeDebug.tsx
CHANGED
|
@@ -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,
|
|
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,wDAoxBpC;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,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"}
|
|
@@ -34,6 +34,6 @@ export declare class ThemeManager {
|
|
|
34
34
|
notify(): void;
|
|
35
35
|
onChangeTheme(cb: ThemeListener, debugId?: number): () => void;
|
|
36
36
|
}
|
|
37
|
-
export declare function getNonComponentParentManager(themeManager?: ThemeManager | null): ThemeManager | null
|
|
37
|
+
export declare function getNonComponentParentManager(themeManager?: ThemeManager | null): ThemeManager | null;
|
|
38
38
|
export {};
|
|
39
39
|
//# sourceMappingURL=ThemeManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeManager.d.ts","sourceRoot":"","sources":["../../src/helpers/ThemeManager.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,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AED,eAAO,MAAM,mBAAmB,mBAA0B,CAAA;AAE1D,eAAO,MAAM,oBAAoB,UACxB,UAAU,yBAEV,MAAM,EAAE,kBACC,MAAM,OAAO,KAC5B,oBA0NF,CAAA"}
|
|
@@ -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,
|
|
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"}
|