@tamagui/core 1.0.1-beta.226 → 1.0.1-beta.228

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/dist/cjs/constants/platform.js +65 -0
  2. package/dist/cjs/constants/platform.js.map +7 -0
  3. package/dist/cjs/constants/platform.native.js +62 -0
  4. package/dist/cjs/constants/platform.native.js.map +7 -0
  5. package/dist/cjs/createComponent.js +22 -38
  6. package/dist/cjs/createComponent.js.map +2 -2
  7. package/dist/cjs/createVariable.js +1 -1
  8. package/dist/cjs/createVariable.js.map +2 -2
  9. package/dist/cjs/helpers/ThemeManager.js +19 -12
  10. package/dist/cjs/helpers/ThemeManager.js.map +3 -3
  11. package/dist/cjs/helpers/ThemeManager.test.js +16 -0
  12. package/dist/cjs/helpers/ThemeManager.test.js.map +2 -2
  13. package/dist/cjs/helpers/assignNativePropsToWeb.js +188 -0
  14. package/dist/cjs/helpers/assignNativePropsToWeb.js.map +7 -0
  15. package/dist/cjs/helpers/assignNativePropsToWeb.native.js +30 -0
  16. package/dist/cjs/helpers/assignNativePropsToWeb.native.js.map +7 -0
  17. package/dist/cjs/helpers/calc.js +71 -0
  18. package/dist/cjs/helpers/calc.js.map +7 -0
  19. package/dist/cjs/helpers/createPropMapper.js +3 -5
  20. package/dist/cjs/helpers/createPropMapper.js.map +2 -2
  21. package/dist/cjs/helpers/createShallowUpdate.js +44 -0
  22. package/dist/cjs/helpers/createShallowUpdate.js.map +7 -0
  23. package/dist/cjs/helpers/getFont.js +66 -0
  24. package/dist/cjs/helpers/getFont.js.map +7 -0
  25. package/dist/cjs/helpers/getSplitStyles.js +85 -67
  26. package/dist/cjs/helpers/getSplitStyles.js.map +3 -3
  27. package/dist/cjs/helpers/getStackSize.js +46 -0
  28. package/dist/cjs/helpers/getStackSize.js.map +7 -0
  29. package/dist/cjs/helpers/normalizeColor.js +2 -2
  30. package/dist/cjs/helpers/normalizeColor.js.map +2 -2
  31. package/dist/cjs/helpers/startTransition.js +36 -0
  32. package/dist/cjs/helpers/startTransition.js.map +7 -0
  33. package/dist/cjs/helpers/timer.js +35 -0
  34. package/dist/cjs/helpers/timer.js.map +7 -0
  35. package/dist/cjs/helpers/validate.js +2 -0
  36. package/dist/cjs/helpers/validate.js.map +7 -0
  37. package/dist/cjs/hooks/useConstant.js +39 -0
  38. package/dist/cjs/hooks/useConstant.js.map +7 -0
  39. package/dist/cjs/hooks/useIsMounted.js +40 -0
  40. package/dist/cjs/hooks/useIsMounted.js.map +7 -0
  41. package/dist/cjs/hooks/useIsSSR.js +46 -0
  42. package/dist/cjs/hooks/useIsSSR.js.map +7 -0
  43. package/dist/cjs/hooks/usePressable.js +36 -0
  44. package/dist/cjs/hooks/usePressable.js.map +7 -0
  45. package/dist/cjs/hooks/useTheme.js +24 -20
  46. package/dist/cjs/hooks/useTheme.js.map +3 -3
  47. package/dist/cjs/hooks/useUnmountEffect.js +32 -0
  48. package/dist/cjs/hooks/useUnmountEffect.js.map +7 -0
  49. package/dist/cjs/injectStyles.js +40 -0
  50. package/dist/cjs/injectStyles.js.map +7 -0
  51. package/dist/cjs/styled.js +0 -10
  52. package/dist/cjs/styled.js.map +2 -2
  53. package/dist/cjs/types.js.map +1 -1
  54. package/dist/cjs/views/Theme.js +5 -9
  55. package/dist/cjs/views/Theme.js.map +2 -2
  56. package/dist/cjs/views/ThemeInverse.js +18 -25
  57. package/dist/cjs/views/ThemeInverse.js.map +2 -2
  58. package/dist/cjs/views/ThemeReset.js +12 -12
  59. package/dist/cjs/views/ThemeReset.js.map +2 -2
  60. package/dist/esm/constants/platform.js +30 -0
  61. package/dist/esm/constants/platform.js.map +7 -0
  62. package/dist/esm/constants/platform.native.js +28 -0
  63. package/dist/esm/constants/platform.native.js.map +7 -0
  64. package/dist/esm/createComponent.js +22 -38
  65. package/dist/esm/createComponent.js.map +2 -2
  66. package/dist/esm/createVariable.js +1 -1
  67. package/dist/esm/createVariable.js.map +2 -2
  68. package/dist/esm/helpers/ThemeManager.js +14 -7
  69. package/dist/esm/helpers/ThemeManager.js.map +2 -2
  70. package/dist/esm/helpers/ThemeManager.test.js +16 -0
  71. package/dist/esm/helpers/ThemeManager.test.js.map +2 -2
  72. package/dist/esm/helpers/assignNativePropsToWeb.js +164 -0
  73. package/dist/esm/helpers/assignNativePropsToWeb.js.map +7 -0
  74. package/dist/esm/helpers/assignNativePropsToWeb.native.js +6 -0
  75. package/dist/esm/helpers/assignNativePropsToWeb.native.js.map +7 -0
  76. package/dist/esm/helpers/calc.js +47 -0
  77. package/dist/esm/helpers/calc.js.map +7 -0
  78. package/dist/esm/helpers/createPropMapper.js +3 -5
  79. package/dist/esm/helpers/createPropMapper.js.map +2 -2
  80. package/dist/esm/helpers/createShallowUpdate.js +20 -0
  81. package/dist/esm/helpers/createShallowUpdate.js.map +7 -0
  82. package/dist/esm/helpers/getFont.js +42 -0
  83. package/dist/esm/helpers/getFont.js.map +7 -0
  84. package/dist/esm/helpers/getSplitStyles.js +85 -67
  85. package/dist/esm/helpers/getSplitStyles.js.map +3 -3
  86. package/dist/esm/helpers/getStackSize.js +22 -0
  87. package/dist/esm/helpers/getStackSize.js.map +7 -0
  88. package/dist/esm/helpers/normalizeColor.js +1 -1
  89. package/dist/esm/helpers/normalizeColor.js.map +1 -1
  90. package/dist/esm/helpers/startTransition.js +6 -0
  91. package/dist/esm/helpers/startTransition.js.map +7 -0
  92. package/dist/esm/helpers/timer.js +11 -0
  93. package/dist/esm/helpers/timer.js.map +7 -0
  94. package/dist/esm/helpers/validate.js +1 -0
  95. package/dist/esm/helpers/validate.js.map +7 -0
  96. package/dist/esm/hooks/useConstant.js +15 -0
  97. package/dist/esm/hooks/useConstant.js.map +7 -0
  98. package/dist/esm/hooks/useIsMounted.js +16 -0
  99. package/dist/esm/hooks/useIsMounted.js.map +7 -0
  100. package/dist/esm/hooks/useIsSSR.js +22 -0
  101. package/dist/esm/hooks/useIsSSR.js.map +7 -0
  102. package/dist/esm/hooks/usePressable.js +12 -0
  103. package/dist/esm/hooks/usePressable.js.map +7 -0
  104. package/dist/esm/hooks/useTheme.js +24 -20
  105. package/dist/esm/hooks/useTheme.js.map +3 -3
  106. package/dist/esm/hooks/useUnmountEffect.js +8 -0
  107. package/dist/esm/hooks/useUnmountEffect.js.map +7 -0
  108. package/dist/esm/injectStyles.js +16 -0
  109. package/dist/esm/injectStyles.js.map +7 -0
  110. package/dist/esm/styled.js +0 -10
  111. package/dist/esm/styled.js.map +2 -2
  112. package/dist/esm/views/Theme.js +5 -9
  113. package/dist/esm/views/Theme.js.map +2 -2
  114. package/dist/esm/views/ThemeInverse.js +17 -23
  115. package/dist/esm/views/ThemeInverse.js.map +2 -2
  116. package/dist/esm/views/ThemeReset.js +12 -12
  117. package/dist/esm/views/ThemeReset.js.map +2 -2
  118. package/package.json +13 -13
  119. package/src/createComponent.tsx +22 -81
  120. package/src/createVariable.ts +1 -1
  121. package/src/helpers/ThemeManager.test.tsx +17 -0
  122. package/src/helpers/ThemeManager.tsx +29 -14
  123. package/src/helpers/createPropMapper.ts +4 -5
  124. package/src/helpers/getSplitStyles.tsx +130 -91
  125. package/src/helpers/normalizeColor.ts +1 -1
  126. package/src/helpers/timer.ts +9 -0
  127. package/src/hooks/useTheme.tsx +29 -22
  128. package/src/styled.tsx +0 -12
  129. package/src/types.tsx +2 -5
  130. package/src/views/Theme.tsx +5 -9
  131. package/types/helpers/ThemeManager.d.ts +2 -2
  132. package/types/helpers/getSplitStyles.d.ts +22 -6
  133. package/types/helpers/timer.d.ts +2 -0
  134. package/types/hooks/useTheme.d.ts +0 -1
  135. package/types/types.d.ts +1 -5
@@ -18,46 +18,39 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var ThemeInverse_exports = {};
20
20
  __export(ThemeInverse_exports, {
21
- ThemeInverse: () => ThemeInverse,
22
- useThemeInverse: () => useThemeInverse
21
+ ThemeInverse: () => ThemeInverse
23
22
  });
24
23
  module.exports = __toCommonJS(ThemeInverse_exports);
25
24
  var import_jsx_runtime = require("react/jsx-runtime");
26
- var import_constants = require("@tamagui/constants");
27
25
  var import_react = require("react");
26
+ var import_platform = require("../constants/platform");
28
27
  var import_useTheme = require("../hooks/useTheme");
29
28
  var import_Theme = require("./Theme");
30
- const toggleTheme = (themeName) => {
31
- return themeName.startsWith("light") ? "dark" : "light";
32
- };
33
- const useThemeInverse = (props = {}) => {
34
- const themeName = (0, import_useTheme.useThemeName)();
35
- const defaultTheme = (0, import_useTheme.useDefaultThemeName)();
36
- const [name, setName] = (0, import_react.useState)(null);
37
- const curName = themeName || defaultTheme || "";
38
- if (import_constants.isWeb) {
39
- (0, import_constants.useIsomorphicLayoutEffect)(() => {
40
- setName(toggleTheme(curName));
41
- }, [defaultTheme, themeName]);
42
- return props.disable ? null : name;
43
- }
44
- return props.disable ? null : toggleTheme(curName);
45
- };
46
29
  const ThemeInverse = ({
47
30
  children,
48
31
  disable
49
32
  }) => {
50
- const inverseTheme = useThemeInverse({
51
- disable
52
- });
33
+ const themeName = (0, import_useTheme.useThemeName)();
34
+ const defaultTheme = (0, import_useTheme.useDefaultThemeName)();
35
+ const [name, setName] = (0, import_react.useState)(null);
36
+ (0, import_platform.useIsomorphicLayoutEffect)(() => {
37
+ if (themeName.startsWith("dark")) {
38
+ setName("light");
39
+ }
40
+ if (themeName.startsWith("light")) {
41
+ setName("dark");
42
+ }
43
+ }, [defaultTheme, themeName]);
44
+ if (disable) {
45
+ return children;
46
+ }
53
47
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Theme.Theme, {
54
- name: inverseTheme,
48
+ name,
55
49
  children
56
50
  });
57
51
  };
58
52
  // Annotate the CommonJS export names for ESM import in node:
59
53
  0 && (module.exports = {
60
- ThemeInverse,
61
- useThemeInverse
54
+ ThemeInverse
62
55
  });
63
56
  //# sourceMappingURL=ThemeInverse.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/views/ThemeInverse.tsx"],
4
- "sourcesContent": ["import { isWeb, useIsomorphicLayoutEffect } from '@tamagui/constants'\nimport React, { useState } from 'react'\n\nimport { useDefaultThemeName, useThemeName } from '../hooks/useTheme'\nimport { Theme } from './Theme'\n\nexport type ThemeInverseProps = {\n disable?: boolean\n}\n\nconst toggleTheme = (themeName: string) => {\n return themeName.startsWith('light') ? 'dark' : 'light'\n}\n\nexport const useThemeInverse = (props: ThemeInverseProps = {}) => {\n const themeName = useThemeName()\n const defaultTheme = useDefaultThemeName()\n const [name, setName] = useState<null | string>(null)\n const curName = themeName || defaultTheme || ''\n\n if (isWeb) {\n // for SSR must be in effect\n useIsomorphicLayoutEffect(() => {\n setName(toggleTheme(curName))\n }, [defaultTheme, themeName])\n\n return props.disable ? null : name\n }\n\n return props.disable ? null : toggleTheme(curName)\n}\n\nexport const ThemeInverse = ({\n children,\n disable,\n}: ThemeInverseProps & {\n children: React.ReactNode\n}) => {\n const inverseTheme = useThemeInverse({\n disable,\n })\n return <Theme name={inverseTheme}>{children}</Theme>\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyCS;AAzCT,uBAAiD;AACjD,mBAAgC;AAEhC,sBAAkD;AAClD,mBAAsB;AAMtB,MAAM,cAAc,CAAC,cAAsB;AACzC,SAAO,UAAU,WAAW,OAAO,IAAI,SAAS;AAClD;AAEO,MAAM,kBAAkB,CAAC,QAA2B,CAAC,MAAM;AAChE,QAAM,gBAAY,8BAAa;AAC/B,QAAM,mBAAe,qCAAoB;AACzC,QAAM,CAAC,MAAM,OAAO,QAAI,uBAAwB,IAAI;AACpD,QAAM,UAAU,aAAa,gBAAgB;AAE7C,MAAI,wBAAO;AAET,oDAA0B,MAAM;AAC9B,cAAQ,YAAY,OAAO,CAAC;AAAA,IAC9B,GAAG,CAAC,cAAc,SAAS,CAAC;AAE5B,WAAO,MAAM,UAAU,OAAO;AAAA,EAChC;AAEA,SAAO,MAAM,UAAU,OAAO,YAAY,OAAO;AACnD;AAEO,MAAM,eAAe,CAAC;AAAA,EAC3B;AAAA,EACA;AACF,MAEM;AACJ,QAAM,eAAe,gBAAgB;AAAA,IACnC;AAAA,EACF,CAAC;AACD,SAAO,4CAAC;AAAA,IAAM,MAAM;AAAA,IAAe;AAAA,GAAS;AAC9C;",
4
+ "sourcesContent": ["import React, { useState } from 'react'\n\nimport { useIsomorphicLayoutEffect } from '../constants/platform'\nimport { useDefaultThemeName, useThemeName } from '../hooks/useTheme'\nimport { Theme } from './Theme'\n\nexport const ThemeInverse = ({\n children,\n disable,\n}: {\n children: React.ReactNode\n disable?: boolean\n}) => {\n const themeName = useThemeName()\n const defaultTheme = useDefaultThemeName()\n const [name, setName] = useState<null | string>(null)\n\n // ssr\n useIsomorphicLayoutEffect(() => {\n if (themeName.startsWith('dark')) {\n setName('light')\n }\n if (themeName.startsWith('light')) {\n setName('dark')\n }\n }, [defaultTheme, themeName])\n\n if (disable) {\n return children as JSX.Element\n }\n\n return <Theme name={name}>{children}</Theme>\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA+BS;AA/BT,mBAAgC;AAEhC,sBAA0C;AAC1C,sBAAkD;AAClD,mBAAsB;AAEf,MAAM,eAAe,CAAC;AAAA,EAC3B;AAAA,EACA;AACF,MAGM;AACJ,QAAM,gBAAY,8BAAa;AAC/B,QAAM,mBAAe,qCAAoB;AACzC,QAAM,CAAC,MAAM,OAAO,QAAI,uBAAwB,IAAI;AAGpD,iDAA0B,MAAM;AAC9B,QAAI,UAAU,WAAW,MAAM,GAAG;AAChC,cAAQ,OAAO;AAAA,IACjB;AACA,QAAI,UAAU,WAAW,OAAO,GAAG;AACjC,cAAQ,MAAM;AAAA,IAChB;AAAA,EACF,GAAG,CAAC,cAAc,SAAS,CAAC;AAE5B,MAAI,SAAS;AACX,WAAO;AAAA,EACT;AAEA,SAAO,4CAAC;AAAA,IAAM;AAAA,IAAa;AAAA,GAAS;AACtC;",
6
6
  "names": []
7
7
  }
@@ -28,31 +28,31 @@ __export(ThemeReset_exports, {
28
28
  });
29
29
  module.exports = __toCommonJS(ThemeReset_exports);
30
30
  var import_jsx_runtime = require("react/jsx-runtime");
31
- var import_constants = require("@tamagui/constants");
32
31
  var import_react = __toESM(require("react"));
32
+ var import_platform = require("../constants/platform");
33
33
  var import_ThemeManager = require("../helpers/ThemeManager");
34
34
  var import_Theme = require("./Theme");
35
35
  import_react.default["createElement"];
36
36
  const ThemeReset = (props) => {
37
- const manager = (0, import_react.useContext)(import_ThemeManager.ThemeManagerContext);
37
+ const themeManager = (0, import_react.useContext)(import_ThemeManager.ThemeManagerContext);
38
38
  const [name, setName] = (0, import_react.useState)(null);
39
- if (import_constants.isClient) {
39
+ if (!import_platform.isWeb || typeof document !== "undefined") {
40
40
  (0, import_react.useLayoutEffect)(() => {
41
- if (!manager)
41
+ if (!themeManager)
42
42
  return;
43
- if (name !== manager.parentName) {
44
- setName(manager.parentName);
43
+ if (name !== themeManager.parentName) {
44
+ setName(themeManager.parentName);
45
45
  }
46
- }, [name, manager, manager == null ? void 0 : manager.parentName]);
46
+ }, [themeManager == null ? void 0 : themeManager.parentName]);
47
47
  (0, import_react.useLayoutEffect)(() => {
48
- if (!manager)
48
+ if (!themeManager)
49
49
  return;
50
- return manager.onChangeTheme(() => {
51
- setName(manager.parentName);
50
+ return themeManager.onChangeTheme(() => {
51
+ setName(themeManager.parentName);
52
52
  });
53
- }, [manager]);
53
+ }, []);
54
54
  }
55
- if (!manager || !props.children) {
55
+ if (!themeManager || !props.children) {
56
56
  return props.children || null;
57
57
  }
58
58
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Theme.Theme, {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/views/ThemeReset.tsx"],
4
- "sourcesContent": ["import { isClient } from '@tamagui/constants'\nimport React, { useContext, useLayoutEffect, useState } from 'react'\n\nimport { ThemeManagerContext } from '../helpers/ThemeManager'\nimport { Theme } from './Theme'\n\n// bugfix esbuild strips react jsx: 'preserve'\nReact['createElement']\n\n// resets the theme to the parent theme\nexport const ThemeReset = (props: { children?: any }) => {\n const manager = useContext(ThemeManagerContext)\n const [name, setName] = useState<string | null>(null)\n\n // this component doesn't work with SSR, so must run only client side\n // we could at least prevent more flickering by having the ssr head script\n // that changes to dark initially also go through and change all of these\n if (isClient) {\n useLayoutEffect(() => {\n if (!manager) return\n if (name !== manager.parentName) {\n setName(manager.parentName)\n }\n }, [name, manager, manager?.parentName])\n\n useLayoutEffect(() => {\n if (!manager) return\n return manager.onChangeTheme(() => {\n setName(manager.parentName)\n })\n }, [manager])\n }\n\n if (!manager || !props.children) {\n return props.children || null\n }\n\n return (\n <Theme className=\"tui-theme-reset\" reset name={name}>\n {props.children}\n </Theme>\n )\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAsCI;AAtCJ,uBAAyB;AACzB,mBAA6D;AAE7D,0BAAoC;AACpC,mBAAsB;AAGtB,aAAAA,QAAM;AAGC,MAAM,aAAa,CAAC,UAA8B;AACvD,QAAM,cAAU,yBAAW,uCAAmB;AAC9C,QAAM,CAAC,MAAM,OAAO,QAAI,uBAAwB,IAAI;AAKpD,MAAI,2BAAU;AACZ,sCAAgB,MAAM;AACpB,UAAI,CAAC;AAAS;AACd,UAAI,SAAS,QAAQ,YAAY;AAC/B,gBAAQ,QAAQ,UAAU;AAAA,MAC5B;AAAA,IACF,GAAG,CAAC,MAAM,SAAS,mCAAS,UAAU,CAAC;AAEvC,sCAAgB,MAAM;AACpB,UAAI,CAAC;AAAS;AACd,aAAO,QAAQ,cAAc,MAAM;AACjC,gBAAQ,QAAQ,UAAU;AAAA,MAC5B,CAAC;AAAA,IACH,GAAG,CAAC,OAAO,CAAC;AAAA,EACd;AAEA,MAAI,CAAC,WAAW,CAAC,MAAM,UAAU;AAC/B,WAAO,MAAM,YAAY;AAAA,EAC3B;AAEA,SACE,4CAAC;AAAA,IAAM,WAAU;AAAA,IAAkB,OAAK;AAAA,IAAC;AAAA,IACtC,gBAAM;AAAA,GACT;AAEJ;",
4
+ "sourcesContent": ["import React, { useContext, useLayoutEffect, useState } from 'react'\n\nimport { isWeb } from '../constants/platform'\nimport { ThemeManagerContext } from '../helpers/ThemeManager'\nimport { Theme } from './Theme'\n\n// bugfix esbuild strips react jsx: 'preserve'\nReact['createElement']\n\n// resets the theme to the parent theme\nexport const ThemeReset = (props: { children?: any }) => {\n const themeManager = useContext(ThemeManagerContext)\n const [name, setName] = useState<string | null>(null)\n\n // this component doesn't work with SSR, so must run only client side\n // we could at least prevent more flickering by having the ssr head script\n // that changes to dark initially also go through and change all of these\n if (!isWeb || typeof document !== 'undefined') {\n useLayoutEffect(() => {\n if (!themeManager) return\n if (name !== themeManager.parentName) {\n setName(themeManager.parentName)\n }\n }, [themeManager?.parentName])\n\n useLayoutEffect(() => {\n if (!themeManager) return\n return themeManager.onChangeTheme(() => {\n setName(themeManager.parentName)\n })\n }, [])\n }\n\n if (!themeManager || !props.children) {\n return props.children || null\n }\n\n return (\n <Theme className=\"tui-theme-reset\" reset name={name}>\n {props.children}\n </Theme>\n )\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAsCI;AAtCJ,mBAA6D;AAE7D,sBAAsB;AACtB,0BAAoC;AACpC,mBAAsB;AAGtB,aAAAA,QAAM;AAGC,MAAM,aAAa,CAAC,UAA8B;AACvD,QAAM,mBAAe,yBAAW,uCAAmB;AACnD,QAAM,CAAC,MAAM,OAAO,QAAI,uBAAwB,IAAI;AAKpD,MAAI,CAAC,yBAAS,OAAO,aAAa,aAAa;AAC7C,sCAAgB,MAAM;AACpB,UAAI,CAAC;AAAc;AACnB,UAAI,SAAS,aAAa,YAAY;AACpC,gBAAQ,aAAa,UAAU;AAAA,MACjC;AAAA,IACF,GAAG,CAAC,6CAAc,UAAU,CAAC;AAE7B,sCAAgB,MAAM;AACpB,UAAI,CAAC;AAAc;AACnB,aAAO,aAAa,cAAc,MAAM;AACtC,gBAAQ,aAAa,UAAU;AAAA,MACjC,CAAC;AAAA,IACH,GAAG,CAAC,CAAC;AAAA,EACP;AAEA,MAAI,CAAC,gBAAgB,CAAC,MAAM,UAAU;AACpC,WAAO,MAAM,YAAY;AAAA,EAC3B;AAEA,SACE,4CAAC;AAAA,IAAM,WAAU;AAAA,IAAkB,OAAK;AAAA,IAAC;AAAA,IACtC,gBAAM;AAAA,GACT;AAEJ;",
6
6
  "names": ["React"]
7
7
  }
@@ -0,0 +1,30 @@
1
+ var _a, _b;
2
+ import { useEffect, useLayoutEffect } from "react";
3
+ import { Platform } from "react-native";
4
+ const isAndroid = ((_a = Platform) == null ? void 0 : _a.OS) === "android";
5
+ const isIOS = ((_b = Platform) == null ? void 0 : _b.OS) === "ios";
6
+ const isWeb = process.env.TAMAGUI_TARGET === "web";
7
+ const isWindowDefined = typeof window !== "undefined";
8
+ const isServer = isWeb && !isWindowDefined;
9
+ const isClient = isWeb && isWindowDefined;
10
+ const isRSC = process.env.ENABLE_RSC ? import.meta.env ? import.meta.env.SSR : false : false;
11
+ const idFn = () => {
12
+ };
13
+ const useIsomorphicLayoutEffect = isRSC ? idFn : isServer ? useEffect : useLayoutEffect;
14
+ const isChrome = typeof navigator !== "undefined" && /Chrome/.test(navigator.userAgent || "");
15
+ const isWebTouchable = isClient && "ontouchstart" in window;
16
+ const isTouchable = !isWeb || isWebTouchable;
17
+ export {
18
+ isAndroid,
19
+ isChrome,
20
+ isClient,
21
+ isIOS,
22
+ isRSC,
23
+ isServer,
24
+ isTouchable,
25
+ isWeb,
26
+ isWebTouchable,
27
+ isWindowDefined,
28
+ useIsomorphicLayoutEffect
29
+ };
30
+ //# sourceMappingURL=platform.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/constants/platform.ts"],
4
+ "sourcesContent": ["import { useEffect, useLayoutEffect } from 'react'\nimport { Platform } from 'react-native'\n\nexport const isAndroid = Platform?.OS === 'android'\nexport const isIOS = Platform?.OS === 'ios'\nexport const isWeb = process.env.TAMAGUI_TARGET === 'web'\nexport const isWindowDefined = typeof window !== 'undefined'\nexport const isServer = isWeb && !isWindowDefined\nexport const isClient = isWeb && isWindowDefined\n\n// may want to move to VITE_RSC_BUILD\nexport const isRSC = process.env.ENABLE_RSC\n ? // note this is statically analyzed so no funny business, just access it without optional chaining\n // @ts-ignore\n import.meta.env\n ? // @ts-ignore\n import.meta.env.SSR\n : false\n : false\n\nconst idFn = () => {}\nexport const useIsomorphicLayoutEffect = isRSC ? idFn : isServer ? useEffect : useLayoutEffect\nexport const isChrome = typeof navigator !== 'undefined' && /Chrome/.test(navigator.userAgent || '')\nexport const isWebTouchable = isClient && 'ontouchstart' in window\nexport const isTouchable = !isWeb || isWebTouchable\n"],
5
+ "mappings": "AAAA;AAAA,SAAS,WAAW,uBAAuB;AAC3C,SAAS,gBAAgB;AAElB,MAAM,cAAY,qCAAU,QAAO;AACnC,MAAM,UAAQ,qCAAU,QAAO;AAC/B,MAAM,QAAQ,QAAQ,IAAI,mBAAmB;AAC7C,MAAM,kBAAkB,OAAO,WAAW;AAC1C,MAAM,WAAW,SAAS,CAAC;AAC3B,MAAM,WAAW,SAAS;AAG1B,MAAM,QAAQ,QAAQ,IAAI,aAG7B,YAAY,MAEV,YAAY,IAAI,MAChB,QACF;AAEJ,MAAM,OAAO,MAAM;AAAC;AACb,MAAM,4BAA4B,QAAQ,OAAO,WAAW,YAAY;AACxE,MAAM,WAAW,OAAO,cAAc,eAAe,SAAS,KAAK,UAAU,aAAa,EAAE;AAC5F,MAAM,iBAAiB,YAAY,kBAAkB;AACrD,MAAM,cAAc,CAAC,SAAS;",
6
+ "names": []
7
+ }
@@ -0,0 +1,28 @@
1
+ var _a, _b;
2
+ import { useLayoutEffect } from "react";
3
+ import { Platform } from "react-native";
4
+ const isAndroid = ((_a = Platform) == null ? void 0 : _a.OS) === "android";
5
+ const isIOS = ((_b = Platform) == null ? void 0 : _b.OS) === "ios";
6
+ const isWeb = false;
7
+ const isWindowDefined = false;
8
+ const isSSR = false;
9
+ const isClient = false;
10
+ const isRSC = false;
11
+ const useIsomorphicLayoutEffect = useLayoutEffect;
12
+ const isChrome = false;
13
+ const isWebTouchable = false;
14
+ const isTouchable = true;
15
+ export {
16
+ isAndroid,
17
+ isChrome,
18
+ isClient,
19
+ isIOS,
20
+ isRSC,
21
+ isSSR,
22
+ isTouchable,
23
+ isWeb,
24
+ isWebTouchable,
25
+ isWindowDefined,
26
+ useIsomorphicLayoutEffect
27
+ };
28
+ //# sourceMappingURL=platform.native.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/constants/platform.native.ts"],
4
+ "sourcesContent": ["import { useLayoutEffect } from 'react'\nimport { Platform } from 'react-native'\n\nexport const isAndroid = Platform?.OS === 'android'\nexport const isIOS = Platform?.OS === 'ios'\nexport const isWeb = false\nexport const isWindowDefined = false\nexport const isSSR = false\nexport const isClient = false\nexport const isRSC = false\nexport const useIsomorphicLayoutEffect = useLayoutEffect\nexport const isChrome = false\nexport const isWebTouchable = false\nexport const isTouchable = true\n"],
5
+ "mappings": "AAAA;AAAA,SAAS,uBAAuB;AAChC,SAAS,gBAAgB;AAElB,MAAM,cAAY,qCAAU,QAAO;AACnC,MAAM,UAAQ,qCAAU,QAAO;AAC/B,MAAM,QAAQ;AACd,MAAM,kBAAkB;AACxB,MAAM,QAAQ;AACd,MAAM,WAAW;AACjB,MAAM,QAAQ;AACd,MAAM,4BAA4B;AAClC,MAAM,WAAW;AACjB,MAAM,iBAAiB;AACvB,MAAM,cAAc;",
6
+ "names": []
7
+ }
@@ -118,10 +118,12 @@ function createComponent(configIn, ParentComponent) {
118
118
  if (isAnimated && presence) {
119
119
  const presenceState = presence[2];
120
120
  if (presenceState) {
121
- if (presenceState.enterVariant)
121
+ if (state.unmounted && presenceState.enterVariant) {
122
122
  props[presenceState.enterVariant] = true;
123
- if (presenceState.exitVariant)
123
+ }
124
+ if (!presenceState.isPresent && presenceState.exitVariant) {
124
125
  props[presenceState.exitVariant] = true;
126
+ }
125
127
  }
126
128
  }
127
129
  const isReactNative = Boolean(
@@ -237,31 +239,24 @@ function createComponent(configIn, ParentComponent) {
237
239
  }
238
240
  }
239
241
  useIsomorphicLayoutEffect(() => {
240
- if (!mediaKeys.length)
241
- return;
242
- const disposers = [];
243
- for (const key of mediaKeys) {
244
- disposers.push(
245
- addMediaQueryListener(key, (next) => {
246
- setState((prev) => {
247
- if (prev.mediaState[key] !== next) {
248
- return {
249
- ...prev,
250
- mediaState: getMediaStateObject({
251
- ...prev.mediaState,
252
- [key]: next
253
- })
254
- };
255
- }
256
- return prev;
257
- });
258
- })
259
- );
260
- }
242
+ const disposers = mediaKeys.map((key) => {
243
+ return addMediaQueryListener(key, (next) => {
244
+ setState((prev) => {
245
+ if (prev.mediaState[key] !== next) {
246
+ return {
247
+ ...prev,
248
+ mediaState: getMediaStateObject({
249
+ ...prev.mediaState,
250
+ [key]: next
251
+ })
252
+ };
253
+ }
254
+ return prev;
255
+ });
256
+ });
257
+ });
261
258
  return () => {
262
- for (const disposer of disposers) {
263
- disposer();
264
- }
259
+ disposers.forEach((d) => d());
265
260
  };
266
261
  }, [mediaKeys.join(",")]);
267
262
  const {
@@ -372,7 +367,7 @@ function createComponent(configIn, ParentComponent) {
372
367
  viewProps = nonTamaguiProps;
373
368
  }
374
369
  viewProps.ref = useComposedRefs(hostRef, forwardedRef, setMounted);
375
- if (process.env.NODE_ENV === "development" && !isText && isWeb && !staticConfig.isHOC) {
370
+ if (process.env.NODE_ENV === "development" && !isText && isWeb) {
376
371
  Children.toArray(props.children).forEach((item) => {
377
372
  if (typeof item === "string") {
378
373
  console.error(`Unexpected text node: ${item}. A text node cannot be a child of a <View>.`);
@@ -728,7 +723,6 @@ function createComponent(configIn, ParentComponent) {
728
723
  Component,
729
724
  ...conf,
730
725
  neverFlatten: true,
731
- isHOC: true,
732
726
  defaultProps: {
733
727
  ...Component.defaultProps,
734
728
  ...conf == null ? void 0 : conf.defaultProps
@@ -936,16 +930,6 @@ const dontComposePressabilityKeys = {
936
930
  function getMediaStateObject(obj) {
937
931
  return Object.fromEntries(Object.entries(obj).flatMap(([k, v]) => v ? [[`$${k}`, v]] : []));
938
932
  }
939
- const baseDefaults = {
940
- opacity: 1
941
- };
942
- const transformDefaults = {
943
- opacity: 1,
944
- scale: 1,
945
- rotate: "0deg",
946
- rotateY: "0deg",
947
- rotateX: "0deg"
948
- };
949
933
  export {
950
934
  Spacer,
951
935
  Unspaced,