@tamagui/web 1.5.21 → 1.5.23

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.
@@ -1,6 +1,6 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { isWeb } from "@tamagui/constants";
3
- import { Children, cloneElement } from "react";
3
+ import { Children, cloneElement, isValidElement } from "react";
4
4
  import { variableToString } from "../createVariable.js";
5
5
  import { ThemeManagerContext } from "../helpers/ThemeManagerContext.js";
6
6
  import { useServerRef } from "../hooks/useServerHooks.js";
@@ -14,47 +14,40 @@ function Theme(props) {
14
14
  props.children,
15
15
  (child) => cloneElement(child, { ["data-themeable"]: true })
16
16
  ) : props.children;
17
- return useThemedChildren(themeState, children, props);
17
+ return useThemedChildren(themeState, children, props, isRoot);
18
18
  }
19
- function useThemedChildren(themeState, children, options) {
19
+ function useThemedChildren(themeState, children, options, isRoot = false) {
20
20
  const { themeManager, isNewTheme, className, theme } = themeState;
21
21
  const { shallow, forceClassName } = options;
22
22
  const hasEverThemed = useServerRef(false);
23
23
  if (isNewTheme) {
24
24
  hasEverThemed.current = true;
25
25
  }
26
- if (!isNewTheme && !hasEverThemed.current && !forceClassName && !shallow) {
27
- return children;
26
+ if (isNewTheme || hasEverThemed.current || forceClassName || isRoot) {
27
+ let next = Children.toArray(children);
28
+ if (shallow && themeManager) {
29
+ next = next.map((child) => {
30
+ return isValidElement(child) ? cloneElement(
31
+ child,
32
+ void 0,
33
+ /* @__PURE__ */ jsx(Theme, { name: themeManager.state.parentName, children: child.props.children })
34
+ ) : child;
35
+ });
36
+ }
37
+ const wrapped = /* @__PURE__ */ jsx(ThemeManagerContext.Provider, { value: themeManager, children: next });
38
+ if (forceClassName === false) {
39
+ return wrapped;
40
+ }
41
+ if (isWeb && !options.passPropsToChildren) {
42
+ const themeColor = theme && isNewTheme ? variableToString(theme.color) : "";
43
+ const colorStyle = {
44
+ color: themeColor
45
+ };
46
+ return /* @__PURE__ */ jsx("span", { className: `${className || ""} _dsp_contents`, style: colorStyle, children: wrapped });
47
+ }
48
+ return wrapped;
28
49
  }
29
- let next = children;
30
- if (shallow && themeManager) {
31
- next = Children.map(next, (child) => {
32
- return cloneElement(
33
- child,
34
- void 0,
35
- /* @__PURE__ */ jsx(Theme, { name: themeManager.state.parentName, children: child.props.children })
36
- );
37
- });
38
- }
39
- next = /* @__PURE__ */ jsx(ThemeManagerContext.Provider, { value: themeManager, children: next });
40
- if (isWeb) {
41
- const enableClassName = forceClassName ?? (forceClassName !== false && isNewTheme);
42
- return /* @__PURE__ */ jsx(
43
- "span",
44
- {
45
- className: "_dsp_contents",
46
- ...theme && enableClassName && {
47
- className: `${className} _dsp_contents`,
48
- style: {
49
- // in order to provide currentColor, set color by default
50
- color: variableToString(theme.color)
51
- }
52
- },
53
- children: next
54
- }
55
- );
56
- }
57
- return next;
50
+ return children;
58
51
  }
59
52
  export {
60
53
  Theme,
@@ -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 } 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)\n}\n\nexport function useThemedChildren(\n themeState: ChangedThemeResponse,\n children: any,\n options: { forceClassName?: boolean; shallow?: boolean }\n) {\n const { themeManager, isNewTheme, className, theme } = themeState\n const { shallow, forceClassName } = options\n\n const hasEverThemed = useServerRef(false)\n if (isNewTheme) {\n hasEverThemed.current = true\n }\n\n // once a theme is set it always passes the context to avoid reparenting\n // until then no context to avoid lots of context\n if (!isNewTheme && !hasEverThemed.current && !forceClassName && !shallow) {\n return children\n }\n\n // be sure to memoize shouldReset to avoid reparenting\n let next = children\n\n if (shallow && themeManager) {\n next = Children.map(next, (child) => {\n return cloneElement(\n child,\n undefined,\n <Theme name={themeManager.state.parentName}>{child.props.children}</Theme>\n )\n })\n }\n\n next = (\n <ThemeManagerContext.Provider value={themeManager}>\n {next}\n </ThemeManagerContext.Provider>\n )\n\n if (isWeb) {\n const enableClassName = forceClassName ?? (forceClassName !== false && isNewTheme)\n return (\n <span\n className=\"_dsp_contents\"\n {...(theme &&\n enableClassName && {\n className: `${className} _dsp_contents`,\n style: {\n // in order to provide currentColor, set color by default\n color: variableToString(theme.color),\n },\n })}\n >\n {next}\n </span>\n )\n }\n\n return next\n}\n"],
5
- "mappings": "AAkDQ;AAlDR,SAAS,aAAa;AACtB,SAAS,UAAU,oBAAoB;AAEvC,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AACpC,SAAS,oBAAoB;AAC7B,SAA+B,4BAA4B;AAGpD,SAAS,MAAM,OAAmB;AAEvC,MAAI,MAAM;AAAS,WAAO,MAAM;AAChC,QAAM,SAAS,CAAC,CAAC,MAAM,SAAS;AAChC,QAAM,aAAa,qBAAqB,OAAO,MAAM;AACrD,QAAM,WAAW,MAAM,gBAAgB,IACnC,SAAS;AAAA,IAAI,MAAM;AAAA,IAAU,CAAC,UAC5B,aAAa,OAAO,EAAE,CAAC,gBAAgB,GAAG,KAAK,CAAC;AAAA,EAClD,IACA,MAAM;AAEV,SAAO,kBAAkB,YAAY,UAAU,KAAK;AACtD;AAEO,SAAS,kBACd,YACA,UACA,SACA;AACA,QAAM,EAAE,cAAc,YAAY,WAAW,MAAM,IAAI;AACvD,QAAM,EAAE,SAAS,eAAe,IAAI;AAEpC,QAAM,gBAAgB,aAAa,KAAK;AACxC,MAAI,YAAY;AACd,kBAAc,UAAU;AAAA,EAC1B;AAIA,MAAI,CAAC,cAAc,CAAC,cAAc,WAAW,CAAC,kBAAkB,CAAC,SAAS;AACxE,WAAO;AAAA,EACT;AAGA,MAAI,OAAO;AAEX,MAAI,WAAW,cAAc;AAC3B,WAAO,SAAS,IAAI,MAAM,CAAC,UAAU;AACnC,aAAO;AAAA,QACL;AAAA,QACA;AAAA,QACA,oBAAC,SAAM,MAAM,aAAa,MAAM,YAAa,gBAAM,MAAM,UAAS;AAAA,MACpE;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SACE,oBAAC,oBAAoB,UAApB,EAA6B,OAAO,cAClC,gBACH;AAGF,MAAI,OAAO;AACT,UAAM,kBAAkB,mBAAmB,mBAAmB,SAAS;AACvE,WACE;AAAA,MAAC;AAAA;AAAA,QACC,WAAU;AAAA,QACT,GAAI,SACH,mBAAmB;AAAA,UACjB,WAAW,GAAG;AAAA,UACd,OAAO;AAAA;AAAA,YAEL,OAAO,iBAAiB,MAAM,KAAK;AAAA,UACrC;AAAA,QACF;AAAA,QAED;AAAA;AAAA,IACH;AAAA,EAEJ;AAEA,SAAO;AACT;",
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;AAnDd,SAAS,aAAa;AACtB,SAAS,UAAU,cAAc,sBAAsB;AAEvD,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AACpC,SAAS,oBAAoB;AAC7B,SAA+B,4BAA4B;AAGpD,SAAS,MAAM,OAAmB;AAEvC,MAAI,MAAM;AAAS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
@@ -1,6 +1,6 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { isWeb } from "@tamagui/constants";
3
- import { Children, cloneElement } from "react";
3
+ import { Children, cloneElement, isValidElement } from "react";
4
4
  import { variableToString } from "../createVariable.js";
5
5
  import { ThemeManagerContext } from "../helpers/ThemeManagerContext.js";
6
6
  import { useServerRef } from "../hooks/useServerHooks.js";
@@ -14,47 +14,40 @@ function Theme(props) {
14
14
  props.children,
15
15
  (child) => cloneElement(child, { ["data-themeable"]: true })
16
16
  ) : props.children;
17
- return useThemedChildren(themeState, children, props);
17
+ return useThemedChildren(themeState, children, props, isRoot);
18
18
  }
19
- function useThemedChildren(themeState, children, options) {
19
+ function useThemedChildren(themeState, children, options, isRoot = false) {
20
20
  const { themeManager, isNewTheme, className, theme } = themeState;
21
21
  const { shallow, forceClassName } = options;
22
22
  const hasEverThemed = useServerRef(false);
23
23
  if (isNewTheme) {
24
24
  hasEverThemed.current = true;
25
25
  }
26
- if (!isNewTheme && !hasEverThemed.current && !forceClassName && !shallow) {
27
- return children;
26
+ if (isNewTheme || hasEverThemed.current || forceClassName || isRoot) {
27
+ let next = Children.toArray(children);
28
+ if (shallow && themeManager) {
29
+ next = next.map((child) => {
30
+ return isValidElement(child) ? cloneElement(
31
+ child,
32
+ void 0,
33
+ /* @__PURE__ */ jsx(Theme, { name: themeManager.state.parentName, children: child.props.children })
34
+ ) : child;
35
+ });
36
+ }
37
+ const wrapped = /* @__PURE__ */ jsx(ThemeManagerContext.Provider, { value: themeManager, children: next });
38
+ if (forceClassName === false) {
39
+ return wrapped;
40
+ }
41
+ if (isWeb && !options.passPropsToChildren) {
42
+ const themeColor = theme && isNewTheme ? variableToString(theme.color) : "";
43
+ const colorStyle = {
44
+ color: themeColor
45
+ };
46
+ return /* @__PURE__ */ jsx("span", { className: `${className || ""} _dsp_contents`, style: colorStyle, children: wrapped });
47
+ }
48
+ return wrapped;
28
49
  }
29
- let next = children;
30
- if (shallow && themeManager) {
31
- next = Children.map(next, (child) => {
32
- return cloneElement(
33
- child,
34
- void 0,
35
- /* @__PURE__ */ jsx(Theme, { name: themeManager.state.parentName, children: child.props.children })
36
- );
37
- });
38
- }
39
- next = /* @__PURE__ */ jsx(ThemeManagerContext.Provider, { value: themeManager, children: next });
40
- if (isWeb) {
41
- const enableClassName = forceClassName ?? (forceClassName !== false && isNewTheme);
42
- return /* @__PURE__ */ jsx(
43
- "span",
44
- {
45
- className: "_dsp_contents",
46
- ...theme && enableClassName && {
47
- className: `${className} _dsp_contents`,
48
- style: {
49
- // in order to provide currentColor, set color by default
50
- color: variableToString(theme.color)
51
- }
52
- },
53
- children: next
54
- }
55
- );
56
- }
57
- return next;
50
+ return children;
58
51
  }
59
52
  export {
60
53
  Theme,
@@ -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 } 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)\n}\n\nexport function useThemedChildren(\n themeState: ChangedThemeResponse,\n children: any,\n options: { forceClassName?: boolean; shallow?: boolean }\n) {\n const { themeManager, isNewTheme, className, theme } = themeState\n const { shallow, forceClassName } = options\n\n const hasEverThemed = useServerRef(false)\n if (isNewTheme) {\n hasEverThemed.current = true\n }\n\n // once a theme is set it always passes the context to avoid reparenting\n // until then no context to avoid lots of context\n if (!isNewTheme && !hasEverThemed.current && !forceClassName && !shallow) {\n return children\n }\n\n // be sure to memoize shouldReset to avoid reparenting\n let next = children\n\n if (shallow && themeManager) {\n next = Children.map(next, (child) => {\n return cloneElement(\n child,\n undefined,\n <Theme name={themeManager.state.parentName}>{child.props.children}</Theme>\n )\n })\n }\n\n next = (\n <ThemeManagerContext.Provider value={themeManager}>\n {next}\n </ThemeManagerContext.Provider>\n )\n\n if (isWeb) {\n const enableClassName = forceClassName ?? (forceClassName !== false && isNewTheme)\n return (\n <span\n className=\"_dsp_contents\"\n {...(theme &&\n enableClassName && {\n className: `${className} _dsp_contents`,\n style: {\n // in order to provide currentColor, set color by default\n color: variableToString(theme.color),\n },\n })}\n >\n {next}\n </span>\n )\n }\n\n return next\n}\n"],
5
- "mappings": "AAkDQ;AAlDR,SAAS,aAAa;AACtB,SAAS,UAAU,oBAAoB;AAEvC,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AACpC,SAAS,oBAAoB;AAC7B,SAA+B,4BAA4B;AAGpD,SAAS,MAAM,OAAmB;AAEvC,MAAI,MAAM;AAAS,WAAO,MAAM;AAChC,QAAM,SAAS,CAAC,CAAC,MAAM,SAAS;AAChC,QAAM,aAAa,qBAAqB,OAAO,MAAM;AACrD,QAAM,WAAW,MAAM,gBAAgB,IACnC,SAAS;AAAA,IAAI,MAAM;AAAA,IAAU,CAAC,UAC5B,aAAa,OAAO,EAAE,CAAC,gBAAgB,GAAG,KAAK,CAAC;AAAA,EAClD,IACA,MAAM;AAEV,SAAO,kBAAkB,YAAY,UAAU,KAAK;AACtD;AAEO,SAAS,kBACd,YACA,UACA,SACA;AACA,QAAM,EAAE,cAAc,YAAY,WAAW,MAAM,IAAI;AACvD,QAAM,EAAE,SAAS,eAAe,IAAI;AAEpC,QAAM,gBAAgB,aAAa,KAAK;AACxC,MAAI,YAAY;AACd,kBAAc,UAAU;AAAA,EAC1B;AAIA,MAAI,CAAC,cAAc,CAAC,cAAc,WAAW,CAAC,kBAAkB,CAAC,SAAS;AACxE,WAAO;AAAA,EACT;AAGA,MAAI,OAAO;AAEX,MAAI,WAAW,cAAc;AAC3B,WAAO,SAAS,IAAI,MAAM,CAAC,UAAU;AACnC,aAAO;AAAA,QACL;AAAA,QACA;AAAA,QACA,oBAAC,SAAM,MAAM,aAAa,MAAM,YAAa,gBAAM,MAAM,UAAS;AAAA,MACpE;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SACE,oBAAC,oBAAoB,UAApB,EAA6B,OAAO,cAClC,gBACH;AAGF,MAAI,OAAO;AACT,UAAM,kBAAkB,mBAAmB,mBAAmB,SAAS;AACvE,WACE;AAAA,MAAC;AAAA;AAAA,QACC,WAAU;AAAA,QACT,GAAI,SACH,mBAAmB;AAAA,UACjB,WAAW,GAAG;AAAA,UACd,OAAO;AAAA;AAAA,YAEL,OAAO,iBAAiB,MAAM,KAAK;AAAA,UACrC;AAAA,QACF;AAAA,QAED;AAAA;AAAA,IACH;AAAA,EAEJ;AAEA,SAAO;AACT;",
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;AAnDd,SAAS,aAAa;AACtB,SAAS,UAAU,cAAc,sBAAsB;AAEvD,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AACpC,SAAS,oBAAoB;AAC7B,SAA+B,4BAA4B;AAGpD,SAAS,MAAM,OAAmB;AAEvC,MAAI,MAAM;AAAS,WAAO,MAAM;AAChC,QAAM,SAAS,CAAC,CAAC,MAAM,SAAS;AAChC,QAAM,aAAa,qBAAqB,OAAO,MAAM;AACrD,QAAM,WA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"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.5.21",
31
- "@tamagui/constants": "^1.5.21",
32
- "@tamagui/helpers": "^1.5.21",
33
- "@tamagui/normalize-css-color": "^1.5.21",
34
- "@tamagui/use-did-finish-ssr": "^1.5.21",
35
- "@tamagui/use-event": "^1.5.21",
36
- "@tamagui/use-force-update": "^1.5.21"
30
+ "@tamagui/compose-refs": "^1.5.23",
31
+ "@tamagui/constants": "^1.5.23",
32
+ "@tamagui/helpers": "^1.5.23",
33
+ "@tamagui/normalize-css-color": "^1.5.23",
34
+ "@tamagui/use-did-finish-ssr": "^1.5.23",
35
+ "@tamagui/use-event": "^1.5.23",
36
+ "@tamagui/use-force-update": "^1.5.23"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "react": "*"
40
40
  },
41
41
  "devDependencies": {
42
- "@tamagui/build": "^1.5.21",
42
+ "@tamagui/build": "^1.5.23",
43
43
  "@testing-library/react": "^13.4.0",
44
44
  "csstype": "^3.0.10",
45
45
  "react": "^18.2.0",
@@ -720,6 +720,7 @@ export function createComponent<
720
720
 
721
721
  content = useThemedChildren(themeState, content, {
722
722
  shallow: stateRef.current.themeShallow,
723
+ // passPropsToChildren: true,
723
724
  })
724
725
 
725
726
  if (process.env.TAMAGUI_TARGET === 'web') {
@@ -1066,7 +1067,6 @@ type CreateSpacerProps = SpacedChildrenProps & { key: string }
1066
1067
 
1067
1068
  function createSpacer({ key, direction, space, spaceFlex }: CreateSpacerProps) {
1068
1069
  return (
1069
- // @ts-ignore this one blew up but the types seem better
1070
1070
  <Spacer
1071
1071
  key={key}
1072
1072
  size={space}
@@ -1079,8 +1079,8 @@ function createSpacer({ key, direction, space, spaceFlex }: CreateSpacerProps) {
1079
1079
  }
1080
1080
 
1081
1081
  function isUnspaced(child: React.ReactNode) {
1082
- // console.log('unspaced?', child, getMedia())
1083
- return child?.['type']?.['isVisuallyHidden'] || child?.['type']?.['isUnspaced']
1082
+ const t = child?.['type']
1083
+ return t?.['isVisuallyHidden'] || t?.['isUnspaced']
1084
1084
  }
1085
1085
 
1086
1086
  const DefaultProps = new Map()
@@ -1122,7 +1122,6 @@ function mergeConfigDefaultProps(
1122
1122
  }
1123
1123
 
1124
1124
  const AbsoluteFill: any = createComponent({
1125
- componentName: 'AbsoluteFill',
1126
1125
  defaultProps: {
1127
1126
  ...stackDefaultStyles,
1128
1127
  flexDirection: 'column',
@@ -1,5 +1,5 @@
1
1
  import { isWeb } from '@tamagui/constants'
2
- import { Children, cloneElement } from 'react'
2
+ import { Children, cloneElement, isValidElement } from 'react'
3
3
 
4
4
  import { variableToString } from '../createVariable.js'
5
5
  import { ThemeManagerContext } from '../helpers/ThemeManagerContext.js'
@@ -18,65 +18,89 @@ export function Theme(props: ThemeProps) {
18
18
  )
19
19
  : props.children
20
20
 
21
- return useThemedChildren(themeState, children, props)
21
+ return useThemedChildren(themeState, children, props, isRoot)
22
22
  }
23
23
 
24
24
  export function useThemedChildren(
25
25
  themeState: ChangedThemeResponse,
26
26
  children: any,
27
- options: { forceClassName?: boolean; shallow?: boolean }
27
+ options: {
28
+ forceClassName?: boolean
29
+ shallow?: boolean
30
+ passPropsToChildren?: boolean
31
+ },
32
+ isRoot = false
28
33
  ) {
29
34
  const { themeManager, isNewTheme, className, theme } = themeState
30
35
  const { shallow, forceClassName } = options
31
-
32
36
  const hasEverThemed = useServerRef(false)
33
37
  if (isNewTheme) {
34
38
  hasEverThemed.current = true
35
39
  }
36
40
 
37
- // once a theme is set it always passes the context to avoid reparenting
38
- // until then no context to avoid lots of context
39
- if (!isNewTheme && !hasEverThemed.current && !forceClassName && !shallow) {
40
- return children
41
- }
42
-
43
- // be sure to memoize shouldReset to avoid reparenting
44
- let next = children
41
+ if (isNewTheme || hasEverThemed.current || forceClassName || isRoot) {
42
+ // be sure to memoize shouldReset to avoid reparenting
43
+ let next = Children.toArray(children)
45
44
 
46
- if (shallow && themeManager) {
47
- next = Children.map(next, (child) => {
48
- return cloneElement(
49
- child,
50
- undefined,
51
- <Theme name={themeManager.state.parentName}>{child.props.children}</Theme>
52
- )
53
- })
54
- }
45
+ // each children of these children wont get the theme
46
+ if (shallow && themeManager) {
47
+ next = next.map((child) => {
48
+ return isValidElement(child)
49
+ ? cloneElement(
50
+ child,
51
+ undefined,
52
+ <Theme name={themeManager.state.parentName}>
53
+ {(child as any).props.children}
54
+ </Theme>
55
+ )
56
+ : child
57
+ })
58
+ }
55
59
 
56
- next = (
57
- <ThemeManagerContext.Provider value={themeManager}>
58
- {next}
59
- </ThemeManagerContext.Provider>
60
- )
60
+ // tried this but themes css doesn't fully like it
61
+ // if (shouldAttachClassName && options.passPropsToChildren) {
62
+ // next = next.map((child: any) => {
63
+ // const childStyle = child.props?.style
64
+ // console.log('pass it down', className, child.props.className || '')
65
+ // const newProps = {
66
+ // className: (child.props.className || '') + ' ' + className,
67
+ // style: Array.isArray(childStyle)
68
+ // ? [colorStyle, ...childStyle]
69
+ // : {
70
+ // ...colorStyle,
71
+ // ...childStyle,
72
+ // },
73
+ // }
74
+ // return isValidElement(child) ? cloneElement(child as any, newProps) : child
75
+ // })
76
+ // }
61
77
 
62
- if (isWeb) {
63
- const enableClassName = forceClassName ?? (forceClassName !== false && isNewTheme)
64
- return (
65
- <span
66
- className="_dsp_contents"
67
- {...(theme &&
68
- enableClassName && {
69
- className: `${className} _dsp_contents`,
70
- style: {
71
- // in order to provide currentColor, set color by default
72
- color: variableToString(theme.color),
73
- },
74
- })}
75
- >
78
+ const wrapped = (
79
+ <ThemeManagerContext.Provider value={themeManager}>
76
80
  {next}
77
- </span>
81
+ </ThemeManagerContext.Provider>
78
82
  )
83
+
84
+ if (forceClassName === false) {
85
+ return wrapped
86
+ }
87
+
88
+ if (isWeb && !options.passPropsToChildren) {
89
+ // in order to provide currentColor, set color by default
90
+ const themeColor = theme && isNewTheme ? variableToString(theme.color) : ''
91
+ const colorStyle = {
92
+ color: themeColor,
93
+ }
94
+
95
+ return (
96
+ <span className={`${className || ''} _dsp_contents`} style={colorStyle}>
97
+ {wrapped}
98
+ </span>
99
+ )
100
+ }
101
+
102
+ return wrapped
79
103
  }
80
104
 
81
- return next
105
+ return children
82
106
  }
@@ -1 +1 @@
1
- {"version":3,"file":"createComponent.d.ts","sourceRoot":"","sources":["../src/createComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,KAUN,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;AAmBhB,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,4DAswBpC;AAGD,eAAO,MAAM,QAAQ;YAAW;QAAE,QAAQ,CAAC,EAAE,GAAG,CAAA;KAAE;;CAEjD,CAAA;AAMD,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,C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@@ export declare function Theme(props: ThemeProps): any;
4
4
  export declare function useThemedChildren(themeState: ChangedThemeResponse, children: any, options: {
5
5
  forceClassName?: boolean;
6
6
  shallow?: boolean;
7
- }): any;
7
+ passPropsToChildren?: boolean;
8
+ }, isRoot?: boolean): any;
8
9
  //# 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,OAYtC;AAED,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,oBAAoB,EAChC,QAAQ,EAAE,GAAG,EACb,OAAO,EAAE;IAAE,cAAc,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,OAuDzD"}
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,OAYtC;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,OA0Ef"}
@@ -1,47 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var mergeTransform_exports = {};
20
- __export(mergeTransform_exports, {
21
- mapTransformKeys: () => mapTransformKeys,
22
- mergeTransform: () => mergeTransform,
23
- mergeTransforms: () => mergeTransforms
24
- });
25
- module.exports = __toCommonJS(mergeTransform_exports);
26
- const mergeTransform = (obj, key, val, backwards = false) => {
27
- obj.transform || (obj.transform = []);
28
- obj.transform[backwards ? "unshift" : "push"]({
29
- [mapTransformKeys[key] || key]: val
30
- });
31
- };
32
- const mergeTransforms = (obj, flatTransforms, backwards = false) => {
33
- Object.entries(flatTransforms).forEach(([key, val]) => {
34
- mergeTransform(obj, key, val, backwards);
35
- });
36
- };
37
- const mapTransformKeys = {
38
- x: "translateX",
39
- y: "translateY"
40
- };
41
- // Annotate the CommonJS export names for ESM import in node:
42
- 0 && (module.exports = {
43
- mapTransformKeys,
44
- mergeTransform,
45
- mergeTransforms
46
- });
47
- //# sourceMappingURL=mergeTransform.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/helpers/mergeTransform.ts"],
4
- "sourcesContent": ["import type { ViewStyle } from 'react-native'\n\nexport type FlatTransforms = Record<string, any>\n\nexport const mergeTransform = (\n obj: ViewStyle,\n key: string,\n val: any,\n backwards = false\n) => {\n obj.transform ||= []\n obj.transform[backwards ? 'unshift' : 'push']({\n [mapTransformKeys[key] || key]: val,\n } as any)\n}\n\nexport const mergeTransforms = (\n obj: ViewStyle,\n flatTransforms: FlatTransforms,\n backwards = false\n) => {\n Object.entries(flatTransforms).forEach(([key, val]) => {\n mergeTransform(obj, key, val, backwards)\n })\n}\n\nexport const mapTransformKeys = {\n x: 'translateX',\n y: 'translateY',\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIO,MAAM,iBAAiB,CAC5B,KACA,KACA,KACA,YAAY,UACT;AACH,MAAI,cAAJ,IAAI,YAAc,CAAC;AACnB,MAAI,UAAU,YAAY,YAAY,MAAM,EAAE;AAAA,IAC5C,CAAC,iBAAiB,GAAG,KAAK,GAAG,GAAG;AAAA,EAClC,CAAQ;AACV;AAEO,MAAM,kBAAkB,CAC7B,KACA,gBACA,YAAY,UACT;AACH,SAAO,QAAQ,cAAc,EAAE,QAAQ,CAAC,CAAC,KAAK,GAAG,MAAM;AACrD,mBAAe,KAAK,KAAK,KAAK,SAAS;AAAA,EACzC,CAAC;AACH;AAEO,MAAM,mBAAmB;AAAA,EAC9B,GAAG;AAAA,EACH,GAAG;AACL;",
6
- "names": []
7
- }
@@ -1,21 +0,0 @@
1
- const mergeTransform = (obj, key, val, backwards = false) => {
2
- obj.transform ||= [];
3
- obj.transform[backwards ? "unshift" : "push"]({
4
- [mapTransformKeys[key] || key]: val
5
- });
6
- };
7
- const mergeTransforms = (obj, flatTransforms, backwards = false) => {
8
- Object.entries(flatTransforms).forEach(([key, val]) => {
9
- mergeTransform(obj, key, val, backwards);
10
- });
11
- };
12
- const mapTransformKeys = {
13
- x: "translateX",
14
- y: "translateY"
15
- };
16
- export {
17
- mapTransformKeys,
18
- mergeTransform,
19
- mergeTransforms
20
- };
21
- //# sourceMappingURL=mergeTransform.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/helpers/mergeTransform.ts"],
4
- "sourcesContent": ["import type { ViewStyle } from 'react-native'\n\nexport type FlatTransforms = Record<string, any>\n\nexport const mergeTransform = (\n obj: ViewStyle,\n key: string,\n val: any,\n backwards = false\n) => {\n obj.transform ||= []\n obj.transform[backwards ? 'unshift' : 'push']({\n [mapTransformKeys[key] || key]: val,\n } as any)\n}\n\nexport const mergeTransforms = (\n obj: ViewStyle,\n flatTransforms: FlatTransforms,\n backwards = false\n) => {\n Object.entries(flatTransforms).forEach(([key, val]) => {\n mergeTransform(obj, key, val, backwards)\n })\n}\n\nexport const mapTransformKeys = {\n x: 'translateX',\n y: 'translateY',\n}\n"],
5
- "mappings": "AAIO,MAAM,iBAAiB,CAC5B,KACA,KACA,KACA,YAAY,UACT;AACH,MAAI,cAAc,CAAC;AACnB,MAAI,UAAU,YAAY,YAAY,MAAM,EAAE;AAAA,IAC5C,CAAC,iBAAiB,GAAG,KAAK,GAAG,GAAG;AAAA,EAClC,CAAQ;AACV;AAEO,MAAM,kBAAkB,CAC7B,KACA,gBACA,YAAY,UACT;AACH,SAAO,QAAQ,cAAc,EAAE,QAAQ,CAAC,CAAC,KAAK,GAAG,MAAM;AACrD,mBAAe,KAAK,KAAK,KAAK,SAAS;AAAA,EACzC,CAAC;AACH;AAEO,MAAM,mBAAmB;AAAA,EAC9B,GAAG;AAAA,EACH,GAAG;AACL;",
6
- "names": []
7
- }
@@ -1,21 +0,0 @@
1
- const mergeTransform = (obj, key, val, backwards = false) => {
2
- obj.transform ||= [];
3
- obj.transform[backwards ? "unshift" : "push"]({
4
- [mapTransformKeys[key] || key]: val
5
- });
6
- };
7
- const mergeTransforms = (obj, flatTransforms, backwards = false) => {
8
- Object.entries(flatTransforms).forEach(([key, val]) => {
9
- mergeTransform(obj, key, val, backwards);
10
- });
11
- };
12
- const mapTransformKeys = {
13
- x: "translateX",
14
- y: "translateY"
15
- };
16
- export {
17
- mapTransformKeys,
18
- mergeTransform,
19
- mergeTransforms
20
- };
21
- //# sourceMappingURL=mergeTransform.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/helpers/mergeTransform.ts"],
4
- "sourcesContent": ["import type { ViewStyle } from 'react-native'\n\nexport type FlatTransforms = Record<string, any>\n\nexport const mergeTransform = (\n obj: ViewStyle,\n key: string,\n val: any,\n backwards = false\n) => {\n obj.transform ||= []\n obj.transform[backwards ? 'unshift' : 'push']({\n [mapTransformKeys[key] || key]: val,\n } as any)\n}\n\nexport const mergeTransforms = (\n obj: ViewStyle,\n flatTransforms: FlatTransforms,\n backwards = false\n) => {\n Object.entries(flatTransforms).forEach(([key, val]) => {\n mergeTransform(obj, key, val, backwards)\n })\n}\n\nexport const mapTransformKeys = {\n x: 'translateX',\n y: 'translateY',\n}\n"],
5
- "mappings": "AAIO,MAAM,iBAAiB,CAC5B,KACA,KACA,KACA,YAAY,UACT;AACH,MAAI,cAAc,CAAC;AACnB,MAAI,UAAU,YAAY,YAAY,MAAM,EAAE;AAAA,IAC5C,CAAC,iBAAiB,GAAG,KAAK,GAAG,GAAG;AAAA,EAClC,CAAQ;AACV;AAEO,MAAM,kBAAkB,CAC7B,KACA,gBACA,YAAY,UACT;AACH,SAAO,QAAQ,cAAc,EAAE,QAAQ,CAAC,CAAC,KAAK,GAAG,MAAM;AACrD,mBAAe,KAAK,KAAK,KAAK,SAAS;AAAA,EACzC,CAAC;AACH;AAEO,MAAM,mBAAmB;AAAA,EAC9B,GAAG;AAAA,EACH,GAAG;AACL;",
6
- "names": []
7
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"mergeTransform.d.ts","sourceRoot":"","sources":["../../src/helpers/mergeTransform.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAEhD,eAAO,MAAM,cAAc,QACpB,SAAS,OACT,MAAM,OACN,GAAG,8BAOT,CAAA;AAED,eAAO,MAAM,eAAe,QACrB,SAAS,kBACE,cAAc,8BAM/B,CAAA;AAED,eAAO,MAAM,gBAAgB;;;CAG5B,CAAA"}