@tamagui/core 1.0.0-alpha.2 → 1.0.0-alpha.7

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 (145) hide show
  1. package/dist/createComponent.js +43 -29
  2. package/dist/createComponent.js.map +2 -2
  3. package/dist/createFont.js +4 -0
  4. package/dist/createFont.js.map +2 -2
  5. package/dist/createTamagui.js +7 -0
  6. package/dist/createTamagui.js.map +2 -2
  7. package/dist/createTokens.js +4 -0
  8. package/dist/createTokens.js.map +2 -2
  9. package/dist/createVariable.js +3 -0
  10. package/dist/createVariable.js.map +2 -2
  11. package/dist/helpers/getSplitStyles.js +1 -13
  12. package/dist/helpers/getSplitStyles.js.map +2 -2
  13. package/dist/helpers/isComponent.js +10 -0
  14. package/dist/helpers/isComponent.js.map +7 -0
  15. package/dist/helpers/isTamaguiComponent.js +10 -0
  16. package/dist/helpers/isTamaguiComponent.js.map +7 -0
  17. package/dist/helpers/isTamaguiElement.js +10 -0
  18. package/dist/helpers/isTamaguiElement.js.map +7 -0
  19. package/dist/helpers/validate.js +60 -0
  20. package/dist/helpers/validate.js.map +7 -0
  21. package/dist/helpers/validateConfig.js +46 -0
  22. package/dist/helpers/validateConfig.js.map +7 -0
  23. package/dist/helpers/validateTokens.js +29 -0
  24. package/dist/helpers/validateTokens.js.map +7 -0
  25. package/dist/hooks/useMedia.js +1 -1
  26. package/dist/hooks/useMedia.js.map +2 -2
  27. package/dist/hooks/useTheme.js +1 -1
  28. package/dist/hooks/useTheme.js.map +2 -2
  29. package/dist/index.cjs +223 -137
  30. package/dist/index.cjs.map +3 -3
  31. package/dist/index.js +1 -2
  32. package/dist/index.js.map +2 -2
  33. package/dist/views/Theme.js +16 -7
  34. package/dist/views/Theme.js.map +2 -2
  35. package/dist/views/ThemeInverse.js +0 -1
  36. package/dist/views/ThemeInverse.js.map +2 -2
  37. package/dist/views/ThemeManagerContext.js +7 -1
  38. package/dist/views/ThemeManagerContext.js.map +2 -2
  39. package/package.json +12 -5
  40. package/src/createComponent.tsx +49 -38
  41. package/src/createFont.ts +5 -0
  42. package/src/createTamagui.ts +8 -0
  43. package/src/createTokens.ts +6 -1
  44. package/src/createVariable.ts +4 -0
  45. package/src/helpers/getSplitStyles.tsx +3 -16
  46. package/src/helpers/isTamaguiElement.tsx +5 -0
  47. package/src/helpers/validate.ts +59 -0
  48. package/src/hooks/useMedia.tsx +1 -1
  49. package/src/hooks/useTheme.tsx +1 -1
  50. package/src/index.ts +1 -2
  51. package/src/types.tsx +1 -0
  52. package/src/views/Theme.tsx +26 -9
  53. package/src/views/ThemeInverse.tsx +0 -1
  54. package/src/views/ThemeManagerContext.tsx +11 -1
  55. package/types.d.ts +3 -5
  56. package/.ultra.cache.json +0 -1
  57. package/_/constants/constants.js +0 -14
  58. package/_/constants/constants.js.map +0 -7
  59. package/_/constants/platform.js +0 -20
  60. package/_/constants/platform.js.map +0 -7
  61. package/_/constants/pseudos.js +0 -18
  62. package/_/constants/pseudos.js.map +0 -7
  63. package/_/constants/rnw.js +0 -22
  64. package/_/constants/rnw.js.map +0 -7
  65. package/_/createComponent.js +0 -427
  66. package/_/createComponent.js.map +0 -7
  67. package/_/createShorthands.js +0 -10
  68. package/_/createShorthands.js.map +0 -7
  69. package/_/createTamagui.js +0 -122
  70. package/_/createTamagui.js.map +0 -7
  71. package/_/createTheme.js +0 -20
  72. package/_/createTheme.js.map +0 -7
  73. package/_/createTokens.js +0 -29
  74. package/_/createTokens.js.map +0 -7
  75. package/_/createVariable.js +0 -22
  76. package/_/createVariable.js.map +0 -7
  77. package/_/helpers/addStylesUsingClassname.js +0 -32
  78. package/_/helpers/addStylesUsingClassname.js.map +0 -7
  79. package/_/helpers/createMediaStyle.js +0 -34
  80. package/_/helpers/createMediaStyle.js.map +0 -7
  81. package/_/helpers/createTamaguiProvider.js +0 -42
  82. package/_/helpers/createTamaguiProvider.js.map +0 -7
  83. package/_/helpers/extendStaticConfig.js +0 -176
  84. package/_/helpers/extendStaticConfig.js.map +0 -7
  85. package/_/helpers/fixNativeShadow.js +0 -8
  86. package/_/helpers/fixNativeShadow.js.map +0 -7
  87. package/_/helpers/fixNativeShadow.native.js +0 -30
  88. package/_/helpers/fixNativeShadow.native.js.map +0 -7
  89. package/_/helpers/getSplitStyles.js +0 -160
  90. package/_/helpers/getSplitStyles.js.map +0 -7
  91. package/_/helpers/getStylesAtomic.js +0 -84
  92. package/_/helpers/getStylesAtomic.js.map +0 -7
  93. package/_/helpers/getStylesAtomic.native.js +0 -10
  94. package/_/helpers/getStylesAtomic.native.js.map +0 -7
  95. package/_/helpers/insertStyleRule.js +0 -24
  96. package/_/helpers/insertStyleRule.js.map +0 -7
  97. package/_/helpers/matchMedia.js +0 -15
  98. package/_/helpers/matchMedia.js.map +0 -7
  99. package/_/helpers/matchMedia.native.js +0 -8
  100. package/_/helpers/matchMedia.native.js.map +0 -7
  101. package/_/helpers/themeable.js +0 -26
  102. package/_/helpers/themeable.js.map +0 -7
  103. package/_/hooks/useConstant.js +0 -15
  104. package/_/hooks/useConstant.js.map +0 -7
  105. package/_/hooks/useFeatures.js +0 -75
  106. package/_/hooks/useFeatures.js.map +0 -7
  107. package/_/hooks/useForceUpdate.js +0 -28
  108. package/_/hooks/useForceUpdate.js.map +0 -7
  109. package/_/hooks/useMedia.js +0 -173
  110. package/_/hooks/useMedia.js.map +0 -7
  111. package/_/hooks/usePressable.js +0 -14
  112. package/_/hooks/usePressable.js.map +0 -7
  113. package/_/hooks/useTheme.js +0 -94
  114. package/_/hooks/useTheme.js.map +0 -7
  115. package/_/index.js +0 -30
  116. package/_/index.js.map +0 -7
  117. package/_/static/postProcessStyles.js +0 -18
  118. package/_/static/postProcessStyles.js.map +0 -7
  119. package/_/static.js +0 -12
  120. package/_/static.js.map +0 -7
  121. package/_/styled.js +0 -21
  122. package/_/styled.js.map +0 -7
  123. package/_/types.js +0 -1
  124. package/_/types.js.map +0 -7
  125. package/_/views/Animated.js +0 -79
  126. package/_/views/Animated.js.map +0 -7
  127. package/_/views/Stack.js +0 -12
  128. package/_/views/Stack.js.map +0 -7
  129. package/_/views/Text.js +0 -60
  130. package/_/views/Text.js.map +0 -7
  131. package/_/views/TextAncestorContext.js +0 -19
  132. package/_/views/TextAncestorContext.js.map +0 -7
  133. package/_/views/Theme.js +0 -57
  134. package/_/views/Theme.js.map +0 -7
  135. package/_/views/ThemeContext.js +0 -6
  136. package/_/views/ThemeContext.js.map +0 -7
  137. package/_/views/ThemeInverse.js +0 -27
  138. package/_/views/ThemeInverse.js.map +0 -7
  139. package/_/views/ThemeManagerContext.js +0 -56
  140. package/_/views/ThemeManagerContext.js.map +0 -7
  141. package/_/views/ThemeProvider.js +0 -45
  142. package/_/views/ThemeProvider.js.map +0 -7
  143. package/src/hooks/useForceUpdate.tsx +0 -26
  144. package/src/views/SafeAreaProvider.tsx +0 -33
  145. package/tsconfig.json +0 -8
@@ -2,15 +2,25 @@ import { createContext } from 'react'
2
2
 
3
3
  export class ThemeManager {
4
4
  name: string | null = 'light'
5
+ parentName: string | null = null
5
6
  keys = new Map<any, Set<string>>()
6
7
  listeners = new Map<any, Function>()
7
8
  callbacks = new Set<Function>()
8
9
  theme = null
9
10
 
10
- setActiveTheme(name: string | null, theme?: any) {
11
+ setActiveTheme({
12
+ name,
13
+ theme,
14
+ parentName,
15
+ }: {
16
+ parentName?: string | null
17
+ name: string | null
18
+ theme?: any
19
+ }) {
11
20
  if (name === this.name) return
12
21
  this.name = name
13
22
  this.theme = theme
23
+ this.parentName = parentName || null
14
24
  this.update()
15
25
  }
16
26
 
package/types.d.ts CHANGED
@@ -11,6 +11,7 @@ export declare class Variable {
11
11
  val: string | number;
12
12
  variable: string | number;
13
13
  constructor({ val, name }: VariableIn);
14
+ toString(): string | number;
14
15
  }
15
16
  export declare type VariableIn = {
16
17
  val: string | number;
@@ -96,6 +97,7 @@ export declare type TamaguiInternalConfig<A extends GenericTokens = GenericToken
96
97
  tokensParsed: CreateTokens<Variable>;
97
98
  themeConfig: any;
98
99
  getCSS: () => string;
100
+ parsed: boolean;
99
101
  };
100
102
  export declare type UnionableString = string & {};
101
103
  export declare type UnionableNumber = number & {};
@@ -491,8 +493,8 @@ export declare const themeable: ThemeableHOC;
491
493
  export interface ThemeableHOC {
492
494
  <R extends ReactElement<any, any> | null, P extends ThemeableProps = {}>(component: (props: P) => R): (props: P) => R;
493
495
  }
496
+ export declare const isTamaguiElement: (child: any) => child is React.ReactElement<any, string | React.JSXElementConstructor<any>>;
494
497
  export declare function useConstant<T>(fn: () => T): T;
495
- export declare function useForceUpdate(): Function;
496
498
  export declare const mediaState: {
497
499
  [key in keyof MediaQueryState]: boolean;
498
500
  };
@@ -550,9 +552,5 @@ export declare const ThemeInverse: (props: {
550
552
  }) => JSX.Element;
551
553
  export declare const TextAncestorContext: any;
552
554
  export declare const TextAncestorProvider: (props: any) => any;
553
- export declare const SafeAreaProvider: ({ initialWindowMetrics, children, }: {
554
- children?: any;
555
- initialWindowMetrics?: any;
556
- }) => JSX.Element;
557
555
 
558
556
  export {};
package/.ultra.cache.json DELETED
@@ -1 +0,0 @@
1
- {"files":{"_":"1637340237894.082","dist":"1637479554052.672",".npmignore":"e69de29bb2d1d6434b8b29ae775ad8c2e48c5391","package.json":"adf7cec75fc901122883d8d6a4cd32b04d410467","src/constants/constants.ts":"557e9930ddfa8fad6d74219ae7245c80551b8794","src/constants/platform.ts":"f6c5d92ce473942bb07bd3e799255dacbf88fe04","src/constants/pseudos.ts":"52c7655f92eaa265601eaf4a31b6db1688875321","src/constants/rnw.tsx":"ebc4ce292c30d344945b75e151a272023461f784","src/createComponent.tsx":"cccfd41966f4dde4e4c62e7b7d38f658088b7f01","src/createFont.ts":"819966bc37e24da3fe2d8c06a68520f0fe5d125e","src/createShorthands.ts":"7b5ce250bc5d049fcf9f5898efc60fdc91f2988d","src/createTamagui.ts":"6e79d67d36eac7a4f5edc8b97e3914eea89ee593","src/createTheme.ts":"aa9b7c08901c1dff621a371912f3cbf1c2507301","src/createTokens.ts":"e5b1ac5cc0a68ca0ec3753a1a0bd5a4af9b825b3","src/createVariable.ts":"da248891d943b04d940205762b1239751af6c7cc","src/helpers/addStylesUsingClassname.tsx":"eab83e8172210b5cea57a408f13cd20e6152d752","src/helpers/createMediaStyle.ts":"3c5ff33628b5cc8de55bdcedc3133b968b5fb210","src/helpers/createPropMapper.ts":"8c4cad2720fd04054a1bea055b674017ba4b0a22","src/helpers/createTamaguiProvider.tsx":"2b6006e2bf3140184789a8f13d3e138ebc22d7b7","src/helpers/extendStaticConfig.ts":"7402dca37f1de440471e3ac83ca6ab8eb4373dc3","src/helpers/fixNativeShadow.native.tsx":"ff1ed30ed9ace81433046e719939a04190b477cc","src/helpers/fixNativeShadow.tsx":"7fb6e7d9604025d2023469f23aab7280244bbb03","src/helpers/getSplitStyles.tsx":"fa6ce2cb0449918a575f02ac179d83de3637c0c6","src/helpers/getStylesAtomic.native.ts":"9054085df65d873432d974b369ac9dcb80f387ff","src/helpers/getStylesAtomic.ts":"e85e8ae07227d5b05f0f1aad7fae77b40e30c09d","src/helpers/insertStyleRule.tsx":"2fe177cb7efe1b2fb5b38c57835a6a3ea5e35443","src/helpers/isObj.ts":"8243865ff1705b549e1a10b398f45048709e2360","src/helpers/matchMedia.native.ts":"7e28a480a564ba5d341d5d559cf1ddcaf5f0b76b","src/helpers/matchMedia.ts":"071b4358b4a141c8f55645e478af1e2527e88b67","src/helpers/themeable.tsx":"16e605a7ae27cec3e4d725817370ac3c250c52a4","src/hooks/useConstant.tsx":"f23ca6031dd13f73f4c5eb7089b5745dc2cdaedd","src/hooks/useFeatures.tsx":"3b917df55d6478ef6f3b9c21d7bef3e5bdcefe1b","src/hooks/useForceUpdate.tsx":"bd991b41de300151e93b2d7e8cdca6a0accefacc","src/hooks/useMedia.tsx":"c50e9180f17ef1839875869eef071bf8a7965dae","src/hooks/usePressable.tsx":"4f55bdca7250e2d22d88f3578d8c8e62ce5c8453","src/hooks/useTheme.tsx":"9c11c3a5da0844cfb93ccbbfa861aedbe10b2552","src/index.ts":"9799059148a6bf1c14fd61120145f10cc40b1fcd","src/static.ts":"8023a4f2d9ee432df4084cc69260c01892f6dff8","src/static/postProcessStyles.tsx":"5e5579249eb99caab9f406af6ec801b7ff1db830","src/styled.ts":"6ccd48505b8118ac393344f475084c528ab83c94","src/types.tsx":"a80d45d21a1b69e54d00226b8f9f1f5de945f1cd","src/views/Animated.tsx":"eac498149091b087c84a5d92c4a9b57bafd6c149","src/views/SafeAreaProvider.tsx":"501c04bc1cb00c2a70ab4f13c5d9510b1f9245b8","src/views/Stack.tsx":"62ef6b9307bb434ad08f4ab7f3f6d0ccb975a359","src/views/Text.tsx":"476bdde93a89840681bf981cfc06e10fc0bc837d","src/views/TextAncestorContext.tsx":"73b13b84778bddb2b4198d32daf1de668132b0bb","src/views/Theme.tsx":"4e9357aac5fc201f2dc359a8f6fd4a8581ceb9bf","src/views/ThemeContext.tsx":"788e2d26d8727dd9493944b5ae9c7ea241fd7ed4","src/views/ThemeInverse.tsx":"614b626451a57955e896cc709d28043bc9bbf391","src/views/ThemeManagerContext.tsx":"30f5f195c2d4b326c5b44f587ff88a1dd1a848ff","src/views/ThemeProvider.tsx":"dcdd80d625e61e9598baf4cb10fc7921962efb50","tsconfig.json":"d3effa0a1380f9664793b92aefd77a1bc96ce071","types.d.ts":"ae74d3379aca7fc09fafc830bdbbc644fb099553"},"deps":{"@tamagui/helpers":1637643436658.3892,"@tamagui/build":1637643433595.8828}}
@@ -1,14 +0,0 @@
1
- import { isWeb } from "./platform";
2
- const stackDefaultStyles = {
3
- alignItems: "stretch",
4
- flexShrink: 0,
5
- ...isWeb && {
6
- display: "flex",
7
- flexBasis: "auto",
8
- boxSizing: "border-box"
9
- }
10
- };
11
- export {
12
- stackDefaultStyles
13
- };
14
- //# sourceMappingURL=constants.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/constants/constants.ts"],
4
- "sourcesContent": ["import { isWeb } from './platform'\n\nexport const stackDefaultStyles = {\n alignItems: 'stretch',\n flexShrink: 0,\n // more accurately match react-native defaults on web\n ...(isWeb && {\n display: 'flex',\n flexBasis: 'auto',\n boxSizing: 'border-box',\n }),\n}\n"],
5
- "mappings": "AAAA;AAEO,MAAM,qBAAqB;AAAA,EAChC,YAAY;AAAA,EACZ,YAAY;AAAA,KAER,SAAS;AAAA,IACX,SAAS;AAAA,IACT,WAAW;AAAA,IACX,WAAW;AAAA;AAAA;",
6
- "names": []
7
- }
@@ -1,20 +0,0 @@
1
- var _a;
2
- import { useEffect, useLayoutEffect } from "react";
3
- import { Platform } from "react-native";
4
- const isWeb = process.env.TAMAGUI_TARGET === "web" || ((_a = Platform) == null ? void 0 : _a.OS) === "web";
5
- const isSSR = isWeb && typeof window === "undefined";
6
- const useIsomorphicLayoutEffect = isSSR ? useEffect : useLayoutEffect;
7
- const isChrome = typeof navigator !== "undefined" && /Chrome/.test(navigator.userAgent || "");
8
- const supportsTouchWeb = typeof window !== "undefined" && "ontouchstart" in window;
9
- const isTouchDevice = !isWeb || supportsTouchWeb;
10
- const isWebIOS = isWeb && typeof navigator !== "undefined" && (/iPad|iPhone|iPod/.test(navigator.platform) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1) && !window["MSStream"];
11
- export {
12
- isChrome,
13
- isSSR,
14
- isTouchDevice,
15
- isWeb,
16
- isWebIOS,
17
- supportsTouchWeb,
18
- useIsomorphicLayoutEffect
19
- };
20
- //# sourceMappingURL=platform.js.map
@@ -1,7 +0,0 @@
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 isWeb = process.env.TAMAGUI_TARGET === 'web' || Platform?.OS === 'web'\nexport const isSSR = isWeb && typeof window === 'undefined'\nexport const useIsomorphicLayoutEffect = isSSR ? useEffect : useLayoutEffect\nexport const isChrome = typeof navigator !== 'undefined' && /Chrome/.test(navigator.userAgent || '')\nexport const supportsTouchWeb = typeof window !== 'undefined' && 'ontouchstart' in window\nexport const isTouchDevice = !isWeb || supportsTouchWeb\nexport const isWebIOS =\n isWeb &&\n typeof navigator !== 'undefined' &&\n (/iPad|iPhone|iPod/.test(navigator.platform) ||\n (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)) &&\n !window['MSStream']\n"],
5
- "mappings": "AAAA;AAAA;AACA;AAEO,MAAM,QAAQ,QAAQ,IAAI,mBAAmB,SAAS,uCAAU,QAAO;AACvE,MAAM,QAAQ,SAAS,OAAO,WAAW;AACzC,MAAM,4BAA4B,QAAQ,YAAY;AACtD,MAAM,WAAW,OAAO,cAAc,eAAe,SAAS,KAAK,UAAU,aAAa;AAC1F,MAAM,mBAAmB,OAAO,WAAW,eAAe,kBAAkB;AAC5E,MAAM,gBAAgB,CAAC,SAAS;AAChC,MAAM,WACX,SACA,OAAO,cAAc,eACpB,oBAAmB,KAAK,UAAU,aAChC,UAAU,aAAa,cAAc,UAAU,iBAAiB,MACnE,CAAC,OAAO;",
6
- "names": []
7
- }
@@ -1,18 +0,0 @@
1
- const pseudos = {
2
- focusStyle: {
3
- name: "focus",
4
- priority: 3
5
- },
6
- pressStyle: {
7
- name: "active",
8
- priority: 2
9
- },
10
- hoverStyle: {
11
- name: "hover",
12
- priority: 1
13
- }
14
- };
15
- export {
16
- pseudos
17
- };
18
- //# sourceMappingURL=pseudos.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/constants/pseudos.ts"],
4
- "sourcesContent": ["export const pseudos = {\n focusStyle: {\n name: 'focus',\n priority: 3,\n },\n pressStyle: {\n name: 'active',\n priority: 2,\n },\n hoverStyle: {\n name: 'hover',\n priority: 1,\n },\n}\n"],
5
- "mappings": "AAAO,MAAM,UAAU;AAAA,EACrB,YAAY;AAAA,IACV,MAAM;AAAA,IACN,UAAU;AAAA;AAAA,EAEZ,YAAY;AAAA,IACV,MAAM;AAAA,IACN,UAAU;AAAA;AAAA,EAEZ,YAAY;AAAA,IACV,MAAM;AAAA,IACN,UAAU;AAAA;AAAA;",
6
- "names": []
7
- }
@@ -1,22 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- const interopRequire = /* @__PURE__ */ __name((src) => "default" in src ? src.default : src, "interopRequire");
4
- const rnw = {};
5
- if (process.env.IS_STATIC === "is_static") {
6
- const createCompileableStyle = require("react-native-web/dist/cjs/exports/StyleSheet/createCompileableStyle");
7
- const createReactDOMStyle = require("react-native-web/dist/cjs/exports/StyleSheet/createReactDOMStyle");
8
- const i18Style = require("react-native-web/dist/cjs/exports/StyleSheet/i18nStyle");
9
- const atomic = require("react-native-web/dist/cjs/exports/StyleSheet/compile").atomic;
10
- Object.assign(rnw, {
11
- createCompileableStyle,
12
- createReactDOMStyle,
13
- i18Style,
14
- atomic
15
- });
16
- } else if (process.env.TAMAGUI_TARGET === "web") {
17
- Object.assign(rnw, interopRequire(require("react-native-web").TamaguiExports));
18
- }
19
- export {
20
- rnw
21
- };
22
- //# sourceMappingURL=rnw.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/constants/rnw.tsx"],
4
- "sourcesContent": ["const interopRequire = (src: any) => ('default' in src ? src.default : src)\n\nexport const rnw: Record<string, any> = {}\n\n// in static mode, require them directly since we can't import react-native-web at all (it has flow stuff in it)\nif (process.env.IS_STATIC === 'is_static') {\n const createCompileableStyle = require('react-native-web/dist/cjs/exports/StyleSheet/createCompileableStyle')\n const createReactDOMStyle = require('react-native-web/dist/cjs/exports/StyleSheet/createReactDOMStyle')\n const i18Style = require('react-native-web/dist/cjs/exports/StyleSheet/i18nStyle')\n const atomic = require('react-native-web/dist/cjs/exports/StyleSheet/compile').atomic\n Object.assign(rnw, {\n createCompileableStyle,\n createReactDOMStyle,\n i18Style,\n atomic,\n })\n} else if (process.env.TAMAGUI_TARGET === 'web') {\n // when targeting web (client) import it like so\n Object.assign(rnw, interopRequire(require('react-native-web').TamaguiExports))\n}\n"],
5
- "mappings": ";;AAAA,MAAM,iBAAiB,wBAAC,QAAc,aAAa,MAAM,IAAI,UAAU,KAAhD;AAEhB,MAAM,MAA2B;AAGxC,IAAI,QAAQ,IAAI,cAAc,aAAa;AACzC,QAAM,yBAAyB,QAAQ;AACvC,QAAM,sBAAsB,QAAQ;AACpC,QAAM,WAAW,QAAQ;AACzB,QAAM,SAAS,QAAQ,wDAAwD;AAC/E,SAAO,OAAO,KAAK;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,WAEO,QAAQ,IAAI,mBAAmB,OAAO;AAE/C,SAAO,OAAO,KAAK,eAAe,QAAQ,oBAAoB;AAAA;",
6
- "names": []
7
- }
@@ -1,427 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import { concatClassName, stylePropsView } from "@tamagui/helpers";
4
- import React, {
5
- Children,
6
- Fragment,
7
- createElement,
8
- forwardRef,
9
- useCallback,
10
- useContext,
11
- useEffect,
12
- useRef,
13
- useState
14
- } from "react";
15
- import { Text, View } from "react-native";
16
- import { stackDefaultStyles } from "./constants/constants";
17
- import { isTouchDevice, isWeb } from "./constants/platform";
18
- import { rnw } from "./constants/rnw";
19
- import { onConfiguredOnce } from "./createTamagui";
20
- import { addStylesUsingClassname } from "./helpers/addStylesUsingClassname";
21
- import { extendStaticConfig, parseStaticConfig } from "./helpers/extendStaticConfig";
22
- import { getSplitStyles } from "./helpers/getSplitStyles";
23
- import { useFeatures } from "./hooks/useFeatures";
24
- import { useForceUpdate } from "./hooks/useForceUpdate";
25
- import { usePressable } from "./hooks/usePressable";
26
- import { TextAncestorContext } from "./views/TextAncestorContext";
27
- import { ThemeManagerContext } from "./views/ThemeManagerContext";
28
- const mouseUps = new Set();
29
- if (typeof document !== "undefined") {
30
- document.addEventListener("mouseup", () => {
31
- mouseUps.forEach((x) => x());
32
- mouseUps.clear();
33
- });
34
- }
35
- function createComponent(configIn) {
36
- let staticConfig;
37
- if ("parsed" in configIn) {
38
- staticConfig = configIn;
39
- } else {
40
- staticConfig = parseStaticConfig(configIn);
41
- }
42
- const { Component, validStyles, isText } = staticConfig;
43
- const validStyleProps = validStyles != null ? validStyles : stylePropsView;
44
- let defaultProps = null;
45
- let tamaguiConfig;
46
- let defaultsStyle;
47
- let defaultsClassName = "";
48
- let initialTheme;
49
- const component = forwardRef((props, forwardedRef) => {
50
- var _a;
51
- const {
52
- tag,
53
- hitSlop,
54
- children,
55
- pointerEvents,
56
- onPress,
57
- onPressIn,
58
- onPressOut,
59
- onHoverIn,
60
- onHoverOut,
61
- space,
62
- disabled,
63
- onMouseEnter,
64
- onMouseLeave,
65
- hrefAttrs,
66
- onMoveShouldSetResponder,
67
- onMoveShouldSetResponderCapture,
68
- onResponderEnd,
69
- onResponderGrant,
70
- onResponderMove,
71
- onResponderReject,
72
- onResponderRelease,
73
- onResponderStart,
74
- onResponderTerminate,
75
- onResponderTerminationRequest,
76
- onScrollShouldSetResponder,
77
- onScrollShouldSetResponderCapture,
78
- onSelectionChangeShouldSetResponder,
79
- onSelectionChangeShouldSetResponderCapture,
80
- onStartShouldSetResponder,
81
- onStartShouldSetResponderCapture,
82
- onMouseDown,
83
- onClick,
84
- onLayout
85
- } = props;
86
- const forceUpdate = useForceUpdate();
87
- const features = useFeatures(props, { forceUpdate });
88
- const manager = useContext(ThemeManagerContext);
89
- const [state, set_] = useState(() => ({
90
- hover: false,
91
- press: false,
92
- pressIn: false,
93
- theme: manager.name
94
- }));
95
- const set = /* @__PURE__ */ __name((next) => set_((prev) => {
96
- for (const key in next) {
97
- if (prev[key] !== next[key]) {
98
- return { ...prev, ...next };
99
- }
100
- }
101
- return prev;
102
- }), "set");
103
- if (process.env.NODE_ENV === "development" && !isText && isWeb) {
104
- Children.toArray(props.children).forEach((item) => {
105
- if (typeof item === "string") {
106
- console.error(`Unexpected text node: ${item}. A text node cannot be a child of a <View>.`);
107
- }
108
- });
109
- }
110
- const hasTextAncestor = isWeb ? useContext(TextAncestorContext) : false;
111
- const hostRef = useRef(null);
112
- if (isWeb) {
113
- rnw.useResponderEvents(hostRef, {
114
- onMoveShouldSetResponder,
115
- onMoveShouldSetResponderCapture,
116
- onResponderEnd,
117
- onResponderGrant,
118
- onResponderMove,
119
- onResponderReject,
120
- onResponderRelease,
121
- onResponderStart,
122
- onResponderTerminate,
123
- onResponderTerminationRequest,
124
- onScrollShouldSetResponder,
125
- onScrollShouldSetResponderCapture,
126
- onSelectionChangeShouldSetResponder,
127
- onSelectionChangeShouldSetResponderCapture,
128
- onStartShouldSetResponder,
129
- onStartShouldSetResponderCapture
130
- });
131
- }
132
- const isTracking = useRef(false);
133
- const { viewProps, pseudos, style, classNames } = getSplitStyles(props, staticConfig, manager.theme || initialTheme);
134
- const internal = useRef();
135
- if (!internal.current) {
136
- internal.current = {
137
- isMounted: true
138
- };
139
- }
140
- useEffect(() => {
141
- internal.current.isMounted = true;
142
- const dispose = manager == null ? void 0 : manager.onChangeTheme((name) => {
143
- if (isTracking.current) {
144
- set({ theme: name });
145
- }
146
- });
147
- return () => {
148
- dispose();
149
- mouseUps.delete(unPress);
150
- isTracking.current = false;
151
- internal.current.isMounted = false;
152
- };
153
- }, [manager]);
154
- const element = isWeb ? !Component || typeof Component === "string" ? tag || Component : Component : Component;
155
- const ReactView = !isWeb ? View : element || (hasTextAncestor ? "span" : "div");
156
- const ReactText = !isWeb ? Text : element || "span";
157
- const ViewComponent = isText ? ReactText : ReactView;
158
- const isHovering = !isTouchDevice && !disabled && pseudos && state.hover;
159
- const isPressing = !disabled && pseudos && state.press;
160
- const styles = [
161
- style,
162
- isHovering ? pseudos.hoverStyle || null : null,
163
- isPressing ? pseudos.pressStyle || null : null
164
- ];
165
- if (isWeb) {
166
- const stylesClassNames = addStylesUsingClassname(styles);
167
- const classList = staticConfig.isText ? [
168
- defaultsClassName,
169
- classNames,
170
- stylesClassNames,
171
- props.className
172
- ] : [defaultsClassName, props.className, classNames, stylesClassNames];
173
- const classListFlat = classList.flat(1).filter(Boolean).join(" ");
174
- const className = concatClassName(classListFlat);
175
- if (process.env.NODE_ENV === "development") {
176
- if (props["debug"]) {
177
- console.log("\u{1F95A} className", { style, styles, stylesClassNames, classListFlat: classListFlat.split(" "), className });
178
- }
179
- }
180
- viewProps.className = className;
181
- } else {
182
- viewProps.style = styles;
183
- }
184
- if (pointerEvents) {
185
- viewProps.pointerEvents = pointerEvents;
186
- }
187
- if (isWeb) {
188
- const platformMethodsRef = rnw.usePlatformMethods(viewProps);
189
- const setRef = rnw.useMergeRefs(hostRef, platformMethodsRef, forwardedRef);
190
- viewProps.ref = setRef;
191
- if (props.href != null && hrefAttrs != null) {
192
- const { download, rel, target } = hrefAttrs;
193
- if (download != null) {
194
- viewProps.download = download;
195
- }
196
- if (rel != null) {
197
- viewProps.rel = rel;
198
- }
199
- if (typeof target === "string") {
200
- viewProps.target = target.charAt(0) !== "_" ? "_" + target : target;
201
- }
202
- }
203
- } else {
204
- if (forwardedRef) {
205
- viewProps.ref = forwardedRef;
206
- }
207
- }
208
- const attachPress = !!(pseudos && pseudos.pressStyle || onPress || onPressOut || onPressIn || onClick);
209
- const attachHover = isWeb && !isTouchDevice && !!(pseudos && pseudos.hoverStyle || onHoverIn || onHoverOut || onMouseEnter || onMouseLeave);
210
- const shouldAttach = internal.current.hasEverHadEvents || attachPress || attachHover || "pressStyle" in props || "onPress" in props || "onPressIn" in props || "onPressOut" in props || isWeb && ("hoverStyle" in props || "onClick" in props || "onHoverIn" in props || "onHoverOut" in props || "onMouseEnter" in props || "onMouseLeave" in props);
211
- if (shouldAttach) {
212
- internal.current.hasEverHadEvents = true;
213
- }
214
- const unPress = useCallback(() => {
215
- if (!internal.current.isMounted)
216
- return;
217
- set({
218
- press: false,
219
- pressIn: false
220
- });
221
- }, []);
222
- const events = shouldAttach ? {
223
- ...!isWeb && {
224
- onPressOut: (e) => {
225
- unPress();
226
- onPressOut == null ? void 0 : onPressOut(e);
227
- }
228
- },
229
- ...isWeb && !isTouchDevice && {
230
- onMouseEnter: attachHover || attachPress ? (e) => {
231
- let next = {};
232
- if (attachHover) {
233
- next.hover = true;
234
- }
235
- if (state.pressIn) {
236
- next.press = true;
237
- }
238
- if (Object.keys(next).length) {
239
- set(next);
240
- }
241
- onHoverIn == null ? void 0 : onHoverIn(e);
242
- onMouseEnter == null ? void 0 : onMouseEnter(e);
243
- } : void 0,
244
- onMouseLeave: attachHover || attachPress ? (e) => {
245
- let next = {};
246
- mouseUps.add(unPress);
247
- if (attachHover) {
248
- next.hover = false;
249
- }
250
- if (state.pressIn) {
251
- next.press = false;
252
- next.pressIn = false;
253
- }
254
- if (Object.keys(next).length) {
255
- set(next);
256
- }
257
- onHoverOut == null ? void 0 : onHoverOut(e);
258
- onMouseLeave == null ? void 0 : onMouseLeave(e);
259
- } : void 0
260
- },
261
- onMouseDown: attachPress ? (e) => {
262
- set({
263
- press: true,
264
- pressIn: true
265
- });
266
- onPressIn == null ? void 0 : onPressIn(e);
267
- onMouseDown == null ? void 0 : onMouseDown(e);
268
- } : onPressIn,
269
- onClick: attachPress ? (e) => {
270
- onPress == null ? void 0 : onPress(e);
271
- onClick == null ? void 0 : onClick(e);
272
- unPress();
273
- onPressOut == null ? void 0 : onPressOut(e);
274
- } : onPressOut
275
- } : null;
276
- if (events) {
277
- if (typeof ViewComponent !== "string") {
278
- const [pressProps] = usePressable({
279
- disabled,
280
- hitSlop,
281
- onPressIn: events.onMouseDown,
282
- onPressOut: events.onPressOut,
283
- onPress: events.onClick
284
- });
285
- Object.assign(viewProps, pressProps);
286
- } else {
287
- Object.assign(viewProps, events);
288
- }
289
- }
290
- const spacedChildrenEl = spacedChildren({
291
- children,
292
- space,
293
- flexDirection: props.flexDirection || (defaultProps == null ? void 0 : defaultProps.flexDirection)
294
- });
295
- let content;
296
- if (isWeb && rnw) {
297
- const domProps = rnw.createDOMProps(viewProps);
298
- const className = domProps.className && domProps.className !== viewProps.className ? `${domProps.className} ${viewProps.className}` : viewProps.className;
299
- Object.assign(viewProps, domProps);
300
- viewProps.className = className;
301
- content = createElement(ViewComponent, viewProps, spacedChildrenEl);
302
- } else {
303
- content = createElement(ViewComponent, viewProps, spacedChildrenEl);
304
- }
305
- const shouldWrapTextAncestor = isWeb && staticConfig.isText && !hasTextAncestor;
306
- if (shouldWrapTextAncestor) {
307
- content = createElement(TextAncestorContext.Provider, { value: true }, content);
308
- }
309
- if (process.env.NODE_ENV === "development") {
310
- if (props["debug"]) {
311
- viewProps["debug"] = true;
312
- console.log("\u{1F95A} props in:", props);
313
- console.log("\u{1F95A} props out:", viewProps);
314
- console.log((_a = props.onClick) == null ? void 0 : _a.toString());
315
- console.log("\u{1F95A} etc:", { shouldAttach, ViewComponent, viewProps, styles, pseudos, content, spacedChildrenEl });
316
- if (isWeb) {
317
- console.log("\u{1F95A} component info", { staticConfig, tamaguiConfig });
318
- }
319
- }
320
- }
321
- return /* @__PURE__ */ React.createElement(React.Fragment, null, features, content);
322
- });
323
- onConfiguredOnce((conf) => {
324
- var _a;
325
- tamaguiConfig = conf;
326
- initialTheme = conf.themes[conf.defaultTheme || Object.keys(conf.themes)[0]];
327
- const next = getSplitStyles(staticConfig.defaultProps, staticConfig, initialTheme, true);
328
- if (isWeb) {
329
- if (next.classNames) {
330
- defaultsClassName += next.classNames + " ";
331
- }
332
- defaultsClassName += addStylesUsingClassname([next.style, next.pseudos]);
333
- } else {
334
- console.log("we need to account for default styles for media queries", next);
335
- }
336
- component.defaultProps = {
337
- ...next.viewProps,
338
- ...component.defaultProps
339
- };
340
- if (process.env.NODE_ENV === "development") {
341
- if ((_a = staticConfig.defaultProps) == null ? void 0 : _a.debug) {
342
- console.log("tamagui debug component:", next, defaultsClassName, component.defaultProps);
343
- }
344
- }
345
- });
346
- component["staticConfig"] = {
347
- validStyles: validStyleProps,
348
- ...staticConfig
349
- };
350
- const res = component;
351
- res["extractable"] = (Component2) => {
352
- Component2["staticConfig"] = extendStaticConfig(res, {
353
- neverFlatten: true,
354
- defaultProps: Component2.defaultProps
355
- });
356
- return Component2;
357
- };
358
- return res;
359
- }
360
- __name(createComponent, "createComponent");
361
- const Spacer = createComponent({
362
- defaultProps: stackDefaultStyles,
363
- variants: {
364
- size: {
365
- "...size": (size, { tokens }) => {
366
- var _a, _b;
367
- return {
368
- width: (_a = tokens.size[size]) != null ? _a : size,
369
- height: (_b = tokens.size[size]) != null ? _b : size
370
- };
371
- }
372
- },
373
- direction: {
374
- horizontal: {
375
- height: 0
376
- },
377
- vertical: {
378
- width: 0
379
- }
380
- }
381
- }
382
- });
383
- function spacedChildren({
384
- children,
385
- space,
386
- flexDirection
387
- }) {
388
- var _a, _b;
389
- if (!space) {
390
- return children;
391
- }
392
- const childrenList = Children.toArray(children);
393
- const len = childrenList.length;
394
- if (len === 1) {
395
- return children;
396
- }
397
- const next = [];
398
- for (const [index, child] of childrenList.entries()) {
399
- if (child === null || child === void 0) {
400
- continue;
401
- }
402
- const key = `${(_a = child == null ? void 0 : child["key"]) != null ? _a : index}`;
403
- next.push(/* @__PURE__ */ React.createElement(Fragment, {
404
- key
405
- }, child));
406
- if ((_b = child == null ? void 0 : child["type"]) == null ? void 0 : _b["isVisuallyHidden"]) {
407
- continue;
408
- }
409
- if (index === len - 1) {
410
- break;
411
- }
412
- next.push(/* @__PURE__ */ React.createElement(Spacer, {
413
- key: `${key}_spacer`,
414
- direction: flexDirection === "row" || flexDirection === "row-reverse" ? "horizontal" : "vertical",
415
- size: space
416
- }));
417
- }
418
- return next;
419
- }
420
- __name(spacedChildren, "spacedChildren");
421
- export {
422
- Spacer,
423
- createComponent,
424
- mouseUps,
425
- spacedChildren
426
- };
427
- //# sourceMappingURL=createComponent.js.map