@tamagui/core 1.0.6 → 1.0.8

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 (192) hide show
  1. package/dist/cjs/createComponent.js.map +2 -2
  2. package/dist/cjs/helpers/ThemeManager.js +4 -24
  3. package/dist/cjs/helpers/ThemeManager.js.map +2 -2
  4. package/dist/cjs/helpers/createPropMapper.js +11 -16
  5. package/dist/cjs/helpers/createPropMapper.js.map +2 -2
  6. package/dist/cjs/helpers/expandStyles.js +10 -3
  7. package/dist/cjs/helpers/expandStyles.js.map +3 -3
  8. package/dist/cjs/helpers/getSplitStyles.js +8 -0
  9. package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
  10. package/dist/cjs/helpers/normalizeColor.js +16 -37
  11. package/dist/cjs/helpers/normalizeColor.js.map +3 -3
  12. package/dist/cjs/helpers/normalizeValueWithProperty.js +1 -1
  13. package/dist/cjs/helpers/normalizeValueWithProperty.js.map +2 -2
  14. package/dist/esm/createComponent.js.map +2 -2
  15. package/dist/esm/helpers/ThemeManager.js +4 -5
  16. package/dist/esm/helpers/ThemeManager.js.map +2 -2
  17. package/dist/esm/helpers/createPropMapper.js +11 -16
  18. package/dist/esm/helpers/createPropMapper.js.map +2 -2
  19. package/dist/esm/helpers/expandStyles.js +5 -4
  20. package/dist/esm/helpers/expandStyles.js.map +2 -2
  21. package/dist/esm/helpers/getSplitStyles.js +8 -0
  22. package/dist/esm/helpers/getSplitStyles.js.map +2 -2
  23. package/dist/esm/helpers/normalizeColor.js +14 -35
  24. package/dist/esm/helpers/normalizeColor.js.map +3 -3
  25. package/dist/esm/helpers/normalizeValueWithProperty.js +1 -1
  26. package/dist/esm/helpers/normalizeValueWithProperty.js.map +2 -2
  27. package/package.json +11 -11
  28. package/src/createComponent.tsx +1 -0
  29. package/src/helpers/ThemeManager.tsx +4 -4
  30. package/src/helpers/createPropMapper.ts +12 -16
  31. package/src/helpers/expandStyles.ts +5 -4
  32. package/src/helpers/getSplitStyles.tsx +10 -0
  33. package/src/helpers/normalizeColor.ts +14 -38
  34. package/src/helpers/normalizeValueWithProperty.ts +1 -1
  35. package/types/helpers/ThemeManager.d.ts +1 -1
  36. package/types/helpers/normalizeColor.d.ts +2 -2
  37. package/dist/cjs/Pressability.js +0 -32
  38. package/dist/cjs/Pressability.js.map +0 -7
  39. package/dist/cjs/Pressability.native.js +0 -32
  40. package/dist/cjs/Pressability.native.js.map +0 -7
  41. package/dist/cjs/ThemeContext.js +0 -30
  42. package/dist/cjs/ThemeContext.js.map +0 -7
  43. package/dist/cjs/ThemeManager.js +0 -211
  44. package/dist/cjs/ThemeManager.js.map +0 -7
  45. package/dist/cjs/conf.js +0 -70
  46. package/dist/cjs/conf.js.map +0 -7
  47. package/dist/cjs/constants/platform.js +0 -59
  48. package/dist/cjs/constants/platform.js.map +0 -7
  49. package/dist/cjs/constants/platform.native.js +0 -62
  50. package/dist/cjs/constants/platform.native.js.map +0 -7
  51. package/dist/cjs/constants/rnw.native.js +0 -28
  52. package/dist/cjs/constants/rnw.native.js.map +0 -7
  53. package/dist/cjs/contexts/ButtonInsideButtonContext.js +0 -30
  54. package/dist/cjs/contexts/ButtonInsideButtonContext.js.map +0 -7
  55. package/dist/cjs/contexts/ThemeContext.js +0 -30
  56. package/dist/cjs/contexts/ThemeContext.js.map +0 -7
  57. package/dist/cjs/defaultComponentState.js +0 -2
  58. package/dist/cjs/defaultComponentState.js.map +0 -7
  59. package/dist/cjs/helpers/Unwrap.js +0 -29
  60. package/dist/cjs/helpers/Unwrap.js.map +0 -7
  61. package/dist/cjs/helpers/areEqualSets.js +0 -38
  62. package/dist/cjs/helpers/areEqualSets.js.map +0 -7
  63. package/dist/cjs/helpers/assignNativePropsToWeb.js +0 -188
  64. package/dist/cjs/helpers/assignNativePropsToWeb.js.map +0 -7
  65. package/dist/cjs/helpers/assignNativePropsToWeb.native.js +0 -30
  66. package/dist/cjs/helpers/assignNativePropsToWeb.native.js.map +0 -7
  67. package/dist/cjs/helpers/cache.js +0 -39
  68. package/dist/cjs/helpers/cache.js.map +0 -7
  69. package/dist/cjs/helpers/calc.js +0 -71
  70. package/dist/cjs/helpers/calc.js.map +0 -7
  71. package/dist/cjs/helpers/createShallowUpdate.js +0 -41
  72. package/dist/cjs/helpers/createShallowUpdate.js.map +0 -7
  73. package/dist/cjs/helpers/createTamaguiProvider.js +0 -65
  74. package/dist/cjs/helpers/createTamaguiProvider.js.map +0 -7
  75. package/dist/cjs/helpers/cssHash.js +0 -51
  76. package/dist/cjs/helpers/cssHash.js.map +0 -7
  77. package/dist/cjs/helpers/expandStyle.test.js +0 -10
  78. package/dist/cjs/helpers/expandStyle.test.js.map +0 -7
  79. package/dist/cjs/helpers/getFont.js +0 -62
  80. package/dist/cjs/helpers/getFont.js.map +0 -7
  81. package/dist/cjs/helpers/getSize.js +0 -48
  82. package/dist/cjs/helpers/getSize.js.map +0 -7
  83. package/dist/cjs/helpers/getStackSize.js +0 -46
  84. package/dist/cjs/helpers/getStackSize.js.map +0 -7
  85. package/dist/cjs/helpers/nativeGestureHandler.native.js +0 -19
  86. package/dist/cjs/helpers/nativeGestureHandler.native.js.map +0 -7
  87. package/dist/cjs/helpers/startTransition.js +0 -33
  88. package/dist/cjs/helpers/startTransition.js.map +0 -7
  89. package/dist/cjs/helpers/validate.js +0 -2
  90. package/dist/cjs/helpers/validate.js.map +0 -7
  91. package/dist/cjs/helpers/wrapThemeManagerContext.js +0 -37
  92. package/dist/cjs/helpers/wrapThemeManagerContext.js.map +0 -7
  93. package/dist/cjs/hooks/useConstant.js +0 -36
  94. package/dist/cjs/hooks/useConstant.js.map +0 -7
  95. package/dist/cjs/hooks/useFeatures.js +0 -201
  96. package/dist/cjs/hooks/useFeatures.js.map +0 -7
  97. package/dist/cjs/hooks/useIsMounted.js +0 -40
  98. package/dist/cjs/hooks/useIsMounted.js.map +0 -7
  99. package/dist/cjs/hooks/useIsSSR.js +0 -42
  100. package/dist/cjs/hooks/useIsSSR.js.map +0 -7
  101. package/dist/cjs/hooks/usePressable.js +0 -36
  102. package/dist/cjs/hooks/usePressable.js.map +0 -7
  103. package/dist/cjs/hooks/usePrevious.js +0 -1
  104. package/dist/cjs/hooks/usePrevious.js.map +0 -7
  105. package/dist/cjs/hooks/useUnmountEffect.js +0 -32
  106. package/dist/cjs/hooks/useUnmountEffect.js.map +0 -7
  107. package/dist/cjs/injectStyles.js +0 -40
  108. package/dist/cjs/injectStyles.js.map +0 -7
  109. package/dist/cjs/views/TextAncestorContext.js +0 -44
  110. package/dist/cjs/views/TextAncestorContext.js.map +0 -7
  111. package/dist/cjs/views/ThemeInverse.js +0 -55
  112. package/dist/cjs/views/ThemeInverse.js.map +0 -7
  113. package/dist/cjs/views/ThemeReset.js +0 -64
  114. package/dist/cjs/views/ThemeReset.js.map +0 -7
  115. package/dist/esm/Pressability.js +0 -7
  116. package/dist/esm/Pressability.js.map +0 -7
  117. package/dist/esm/Pressability.native.js +0 -7
  118. package/dist/esm/Pressability.native.js.map +0 -7
  119. package/dist/esm/ThemeContext.js +0 -6
  120. package/dist/esm/ThemeContext.js.map +0 -7
  121. package/dist/esm/ThemeManager.js +0 -185
  122. package/dist/esm/ThemeManager.js.map +0 -7
  123. package/dist/esm/conf.js +0 -39
  124. package/dist/esm/conf.js.map +0 -7
  125. package/dist/esm/constants/platform.js +0 -26
  126. package/dist/esm/constants/platform.js.map +0 -7
  127. package/dist/esm/constants/platform.native.js +0 -28
  128. package/dist/esm/constants/platform.native.js.map +0 -7
  129. package/dist/esm/constants/rnw.native.js +0 -5
  130. package/dist/esm/constants/rnw.native.js.map +0 -7
  131. package/dist/esm/contexts/ButtonInsideButtonContext.js +0 -6
  132. package/dist/esm/contexts/ButtonInsideButtonContext.js.map +0 -7
  133. package/dist/esm/contexts/ThemeContext.js +0 -6
  134. package/dist/esm/contexts/ThemeContext.js.map +0 -7
  135. package/dist/esm/defaultComponentState.js +0 -1
  136. package/dist/esm/defaultComponentState.js.map +0 -7
  137. package/dist/esm/helpers/Unwrap.js +0 -5
  138. package/dist/esm/helpers/Unwrap.js.map +0 -7
  139. package/dist/esm/helpers/areEqualSets.js +0 -14
  140. package/dist/esm/helpers/areEqualSets.js.map +0 -7
  141. package/dist/esm/helpers/assignNativePropsToWeb.js +0 -164
  142. package/dist/esm/helpers/assignNativePropsToWeb.js.map +0 -7
  143. package/dist/esm/helpers/assignNativePropsToWeb.native.js +0 -6
  144. package/dist/esm/helpers/assignNativePropsToWeb.native.js.map +0 -7
  145. package/dist/esm/helpers/cache.js +0 -15
  146. package/dist/esm/helpers/cache.js.map +0 -7
  147. package/dist/esm/helpers/calc.js +0 -47
  148. package/dist/esm/helpers/calc.js.map +0 -7
  149. package/dist/esm/helpers/createShallowUpdate.js +0 -17
  150. package/dist/esm/helpers/createShallowUpdate.js.map +0 -7
  151. package/dist/esm/helpers/createTamaguiProvider.js +0 -38
  152. package/dist/esm/helpers/createTamaguiProvider.js.map +0 -7
  153. package/dist/esm/helpers/cssHash.js +0 -27
  154. package/dist/esm/helpers/cssHash.js.map +0 -7
  155. package/dist/esm/helpers/expandStyle.test.js +0 -9
  156. package/dist/esm/helpers/expandStyle.test.js.map +0 -7
  157. package/dist/esm/helpers/getFont.js +0 -38
  158. package/dist/esm/helpers/getFont.js.map +0 -7
  159. package/dist/esm/helpers/getSize.js +0 -23
  160. package/dist/esm/helpers/getSize.js.map +0 -7
  161. package/dist/esm/helpers/getStackSize.js +0 -22
  162. package/dist/esm/helpers/getStackSize.js.map +0 -7
  163. package/dist/esm/helpers/nativeGestureHandler.native.js +0 -2
  164. package/dist/esm/helpers/nativeGestureHandler.native.js.map +0 -7
  165. package/dist/esm/helpers/startTransition.js +0 -6
  166. package/dist/esm/helpers/startTransition.js.map +0 -7
  167. package/dist/esm/helpers/validate.js +0 -1
  168. package/dist/esm/helpers/validate.js.map +0 -7
  169. package/dist/esm/helpers/wrapThemeManagerContext.js +0 -11
  170. package/dist/esm/helpers/wrapThemeManagerContext.js.map +0 -7
  171. package/dist/esm/hooks/useConstant.js +0 -12
  172. package/dist/esm/hooks/useConstant.js.map +0 -7
  173. package/dist/esm/hooks/useFeatures.js +0 -174
  174. package/dist/esm/hooks/useFeatures.js.map +0 -7
  175. package/dist/esm/hooks/useIsMounted.js +0 -16
  176. package/dist/esm/hooks/useIsMounted.js.map +0 -7
  177. package/dist/esm/hooks/useIsSSR.js +0 -18
  178. package/dist/esm/hooks/useIsSSR.js.map +0 -7
  179. package/dist/esm/hooks/usePressable.js +0 -12
  180. package/dist/esm/hooks/usePressable.js.map +0 -7
  181. package/dist/esm/hooks/usePrevious.js +0 -1
  182. package/dist/esm/hooks/usePrevious.js.map +0 -7
  183. package/dist/esm/hooks/useUnmountEffect.js +0 -8
  184. package/dist/esm/hooks/useUnmountEffect.js.map +0 -7
  185. package/dist/esm/injectStyles.js +0 -16
  186. package/dist/esm/injectStyles.js.map +0 -7
  187. package/dist/esm/views/TextAncestorContext.js +0 -15
  188. package/dist/esm/views/TextAncestorContext.js.map +0 -7
  189. package/dist/esm/views/ThemeInverse.js +0 -27
  190. package/dist/esm/views/ThemeInverse.js.map +0 -7
  191. package/dist/esm/views/ThemeReset.js +0 -37
  192. package/dist/esm/views/ThemeReset.js.map +0 -7
@@ -1,54 +1,30 @@
1
1
  import { isWeb } from '@tamagui/constants'
2
- import normalizeCSSColor from 'normalize-css-color'
2
+ import normalizeCSSColor, { rgba } from '@tamagui/normalize-css-color'
3
3
 
4
- export const normalizeColor = (color?: number | string | null, opacity?: number) => {
5
- if (color == null || color === undefined) {
4
+ export { rgba } from '@tamagui/normalize-css-color'
5
+
6
+ export const normalizeColor = (color?: string | null, opacity?: number) => {
7
+ if (color === null || color === undefined) {
6
8
  return
7
9
  }
10
+ if (color === 'transparent') {
11
+ return `rgba(0,0,0,0)`
12
+ }
8
13
  if (
9
14
  color[0] === '$' ||
10
- (isWeb &&
11
- typeof color === 'string' &&
12
- (webColors[color] || color[0] === '_' || color.startsWith('var(')))
15
+ (isWeb && (webColors[color] || color[0] === '_' || color.startsWith('var(')))
13
16
  ) {
14
17
  return color
15
- } else {
16
- const rgba = colorToRGBA(color)
17
- if (rgba != null) {
18
- const [r, g, b, a] = rgba
19
- const alpha = (opacity ?? a).toFixed(2)
20
- return `rgba(${r},${g},${b},${alpha})`
21
- }
22
18
  }
23
- return color
19
+ const colorProcessed = normalizeCSSColor(color)
20
+ if (colorProcessed !== null) {
21
+ const { r, g, b, a } = rgba(colorProcessed)
22
+ return `rgba(${r},${g},${b},${a.toFixed(2)})`
23
+ }
24
24
  }
25
25
 
26
26
  const webColors = {
27
27
  currentColor: true,
28
28
  currentcolor: true,
29
- transparent: true,
30
29
  inherit: true,
31
30
  }
32
-
33
- export function colorToRGBA(color: string | number) {
34
- const ci = processColor(color)
35
- if (ci != null) {
36
- const r = (ci >> 16) & 255
37
- const g = (ci >> 8) & 255
38
- const b = ci & 255
39
- const a = ((ci >> 24) & 255) / 255
40
- return [r, g, b, a] as const
41
- }
42
- return null
43
- }
44
-
45
- const processColor = (color?: number | string) => {
46
- if (color === undefined || color === null) {
47
- return null
48
- }
49
- const intColor = normalizeCSSColor(color)
50
- if (intColor === undefined || intColor === null) {
51
- return null
52
- }
53
- return ((+intColor << 24) | (+intColor >>> 8)) >>> 0
54
- }
@@ -27,7 +27,7 @@ export function normalizeValueWithProperty(value: any, property?: string): any {
27
27
  res = `${value}px`
28
28
  } else if (isWeb && property !== undefined && stringNumbers[property]) {
29
29
  res = `${res}`
30
- } else if (property && colorProps[property]) {
30
+ } else if (property && property in colorProps) {
31
31
  res = normalizeColor(value)
32
32
  cache[value] = res
33
33
  }
@@ -15,7 +15,6 @@ export type ThemeManagerState = {
15
15
  };
16
16
  export declare function hasNoThemeUpdatingProps(props: ThemeProps): boolean;
17
17
  export declare class ThemeManager {
18
- #private;
19
18
  props: ThemeProps;
20
19
  themeListeners: Set<ThemeListener>;
21
20
  parentManager: ThemeManager | null;
@@ -27,6 +26,7 @@ export declare class ThemeManager {
27
26
  getStateIfChanged(props?: ThemeProps, state?: ThemeManagerState | null, parentManager?: ThemeManager | null): ThemeManagerState | null | undefined;
28
27
  getStateShouldChange(nextState: ThemeManagerState | null, state?: ThemeManagerState | null): boolean;
29
28
  getState(props?: ThemeProps, parentManager?: ThemeManager | null): ThemeManagerState | null;
29
+ _allKeys: Set<string> | null;
30
30
  get allKeys(): Set<string>;
31
31
  getValue(key: string, state?: ThemeManagerState): import("../types").VariableVal | undefined;
32
32
  notify(): void;
@@ -1,3 +1,3 @@
1
- export declare const normalizeColor: (color?: number | string | null, opacity?: number) => string | number | undefined;
2
- export declare function colorToRGBA(color: string | number): readonly [number, number, number, number] | null;
1
+ export { rgba } from '@tamagui/normalize-css-color';
2
+ export declare const normalizeColor: (color?: string | null, opacity?: number) => string | undefined;
3
3
  //# sourceMappingURL=normalizeColor.d.ts.map
@@ -1,32 +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 Pressability_exports = {};
20
- __export(Pressability_exports, {
21
- Pressability: () => Pressability,
22
- usePressability: () => usePressability
23
- });
24
- module.exports = __toCommonJS(Pressability_exports);
25
- const Pressability = {};
26
- const usePressability = {};
27
- // Annotate the CommonJS export names for ESM import in node:
28
- 0 && (module.exports = {
29
- Pressability,
30
- usePressability
31
- });
32
- //# sourceMappingURL=Pressability.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/Pressability.tsx"],
4
- "sourcesContent": ["export const Pressability = {} as any\nexport const usePressability = {} as Function\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,eAAe,CAAC;AACtB,MAAM,kBAAkB,CAAC;",
6
- "names": []
7
- }
@@ -1,32 +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 Pressability_native_exports = {};
20
- __export(Pressability_native_exports, {
21
- Pressability: () => Pressability,
22
- usePressability: () => usePressability
23
- });
24
- module.exports = __toCommonJS(Pressability_native_exports);
25
- const Pressability = require("react-native/Libraries/Pressability/Pressability").default;
26
- const usePressability = require("react-native/Libraries/Pressability/usePressability").default;
27
- // Annotate the CommonJS export names for ESM import in node:
28
- 0 && (module.exports = {
29
- Pressability,
30
- usePressability
31
- });
32
- //# sourceMappingURL=Pressability.native.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/Pressability.native.tsx"],
4
- "sourcesContent": ["export const Pressability = require('react-native/Libraries/Pressability/Pressability').default\nexport const usePressability =\n require('react-native/Libraries/Pressability/usePressability').default\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,eAAe,QAAQ,kDAAkD,EAAE;AACjF,MAAM,kBACX,QAAQ,qDAAqD,EAAE;",
6
- "names": []
7
- }
@@ -1,30 +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 ThemeContext_exports = {};
20
- __export(ThemeContext_exports, {
21
- ThemeContext: () => ThemeContext
22
- });
23
- module.exports = __toCommonJS(ThemeContext_exports);
24
- var import_react = require("react");
25
- const ThemeContext = (0, import_react.createContext)(null);
26
- // Annotate the CommonJS export names for ESM import in node:
27
- 0 && (module.exports = {
28
- ThemeContext
29
- });
30
- //# sourceMappingURL=ThemeContext.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/ThemeContext.tsx"],
4
- "sourcesContent": ["import { createContext } from 'react'\n\nimport { ThemeName, Themes } from './types'\n\nexport const ThemeContext = createContext<{ themes: Themes; defaultTheme: ThemeName } | null>(null)\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA8B;AAIvB,MAAM,eAAe,gCAAkE,IAAI;",
6
- "names": []
7
- }
@@ -1,211 +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 ThemeManager_exports = {};
20
- __export(ThemeManager_exports, {
21
- ThemeManager: () => ThemeManager,
22
- ThemeManagerContext: () => ThemeManagerContext,
23
- emptyManager: () => emptyManager
24
- });
25
- module.exports = __toCommonJS(ThemeManager_exports);
26
- var import_react = require("react");
27
- var import_conf = require("./conf");
28
- var import_constants = require("./constants/constants");
29
- var import_getThemeUnwrapped = require("./hooks/getThemeUnwrapped");
30
- class ThemeManager {
31
- constructor(name = "", theme = null, parentManager = null, reset = false) {
32
- this.name = name;
33
- this.theme = theme;
34
- this.parentManager = parentManager;
35
- this.reset = reset;
36
- this.keys = /* @__PURE__ */ new Map();
37
- this.listeners = /* @__PURE__ */ new Map();
38
- this.themeListeners = /* @__PURE__ */ new Set();
39
- this.className = null;
40
- let parent = parentManager;
41
- let tries = 0;
42
- while (true) {
43
- tries++;
44
- if (tries > 10) {
45
- throw new Error(`Nested 10 of the same theme in a row, likely error`);
46
- }
47
- if (!parent)
48
- break;
49
- if (parent.name === name) {
50
- parent = parent.parentManager;
51
- } else {
52
- this.parentManager = parent;
53
- break;
54
- }
55
- }
56
- }
57
- get didChangeTheme() {
58
- return this.parentManager && this.name !== this.parentManager.fullName;
59
- }
60
- get parentName() {
61
- var _a;
62
- return ((_a = this.parentManager) == null ? void 0 : _a.name) || null;
63
- }
64
- get fullName() {
65
- return this.getNextTheme().name || this.name || "";
66
- }
67
- getValue(key) {
68
- let theme = this.theme;
69
- let manager = this;
70
- while (true) {
71
- if (!theme)
72
- return;
73
- if (key in theme) {
74
- return theme[key];
75
- }
76
- manager = this.parentManager;
77
- if (!manager) {
78
- return;
79
- }
80
- if (manager.theme === theme) {
81
- return;
82
- }
83
- theme = manager.theme;
84
- }
85
- }
86
- update({ name, theme, className } = {}) {
87
- const nameChanged = name !== this.name;
88
- if (!nameChanged) {
89
- return false;
90
- }
91
- this.className = className || null;
92
- this.name = name || "";
93
- this.theme = theme;
94
- this.notifyListeners();
95
- return true;
96
- }
97
- getNextTheme(props = {}, debug) {
98
- var _a;
99
- const { themes = (0, import_conf.getThemes)(), name, componentName } = props;
100
- if (props.reset && name) {
101
- return {
102
- name,
103
- theme: themes[name],
104
- className: this.getClassName(name)
105
- };
106
- }
107
- const parentIsReset = (_a = this.parentManager) == null ? void 0 : _a.reset;
108
- if (!name) {
109
- if (componentName) {
110
- const names = [
111
- `${this.name}_${componentName}`,
112
- `${withoutComponentName(this.name)}_${componentName}`
113
- ];
114
- for (const name2 of names) {
115
- if (name2 in themes) {
116
- const className = this.getClassName(name2);
117
- return { name: name2, theme: themes[name2], className };
118
- }
119
- }
120
- }
121
- return {
122
- name: this.name,
123
- theme: this.theme
124
- };
125
- }
126
- let nextName = name || this.name || "";
127
- let parentName = parentIsReset ? this.parentName || this.fullName : this.fullName;
128
- while (true) {
129
- if (nextName in themes) {
130
- break;
131
- }
132
- nextName = `${parentName}_${name}`;
133
- if (nextName in themes) {
134
- break;
135
- }
136
- if (!parentName.includes(import_constants.THEME_NAME_SEPARATOR)) {
137
- console.warn("theme not found", name);
138
- break;
139
- }
140
- parentName = parentName.slice(0, parentName.lastIndexOf(import_constants.THEME_NAME_SEPARATOR));
141
- }
142
- if (componentName) {
143
- const names = [
144
- `${nextName}_${componentName}`,
145
- `${withoutComponentName(nextName)}_${componentName}`
146
- ];
147
- for (const name2 of names) {
148
- if (name2 in themes) {
149
- nextName = name2;
150
- }
151
- }
152
- }
153
- let theme = themes[nextName];
154
- if (!theme) {
155
- theme = themes[`light_${nextName}`];
156
- }
157
- if (process.env.NODE_ENV === "development") {
158
- if (debug) {
159
- console.log("getNextTheme", this.getClassName(nextName), { props, nextName, parentName });
160
- }
161
- }
162
- return {
163
- name: nextName,
164
- theme: (0, import_getThemeUnwrapped.getThemeUnwrapped)(theme),
165
- className: this.getClassName(nextName)
166
- };
167
- }
168
- getClassName(name) {
169
- return `${import_constants.THEME_CLASSNAME_PREFIX}${name} t_Theme`.replace("light_", "").replace("dark_", "");
170
- }
171
- track(uuid, keys) {
172
- if (!this.name)
173
- return;
174
- this.keys.set(uuid, keys);
175
- }
176
- notifyListeners() {
177
- var _a;
178
- if (!this.name) {
179
- this.keys.clear();
180
- }
181
- for (const [uuid, keys] of this.keys.entries()) {
182
- if (keys.size) {
183
- (_a = this.listeners.get(uuid)) == null ? void 0 : _a();
184
- }
185
- }
186
- this.themeListeners.forEach((cb) => cb(this.name, this));
187
- }
188
- onChangeTheme(cb) {
189
- this.themeListeners.add(cb);
190
- return () => {
191
- this.themeListeners.delete(cb);
192
- };
193
- }
194
- onUpdate(uuid, cb) {
195
- this.listeners.set(uuid, cb);
196
- return () => {
197
- this.listeners.delete(uuid);
198
- this.keys.delete(uuid);
199
- };
200
- }
201
- }
202
- const ThemeManagerContext = (0, import_react.createContext)(null);
203
- const emptyManager = new ThemeManager();
204
- const withoutComponentName = (name) => name.replace(/(\_[A-Z][a-zA-Z]+)+$/g, "");
205
- // Annotate the CommonJS export names for ESM import in node:
206
- 0 && (module.exports = {
207
- ThemeManager,
208
- ThemeManagerContext,
209
- emptyManager
210
- });
211
- //# sourceMappingURL=ThemeManager.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/ThemeManager.tsx"],
4
- "sourcesContent": ["import { createContext } from 'react'\n\nimport { getThemes } from './conf'\nimport { THEME_CLASSNAME_PREFIX, THEME_NAME_SEPARATOR } from './constants/constants'\nimport { getThemeUnwrapped } from './hooks/getThemeUnwrapped'\nimport { ThemeObject, Themes } from './types'\n\ntype ThemeListener = (name: string | null, themeManager: ThemeManager) => void\n\nexport type SetActiveThemeProps = {\n className?: string\n parentManager?: ThemeManager | null\n name?: string | null\n theme?: any\n}\n\nexport type GetNextThemeProps = {\n themes?: Themes\n name?: string | null\n componentName?: string | null\n reset?: boolean\n}\n\nexport class ThemeManager {\n keys = new Map<any, Set<string>>()\n listeners = new Map<any, Function>()\n themeListeners = new Set<ThemeListener>()\n className: string | null = null\n\n constructor(\n public name: string = '',\n public theme: ThemeObject | null = null,\n public parentManager: ThemeManager | null = null,\n public reset: boolean = false\n ) {\n // find the nearest different parentManager\n let parent = parentManager\n let tries = 0\n while (true) {\n tries++\n if (tries > 10) {\n throw new Error(`Nested 10 of the same theme in a row, likely error`)\n }\n if (!parent) break\n if (parent.name === name) {\n // go up if same\n parent = parent.parentManager\n } else {\n this.parentManager = parent\n break\n }\n }\n }\n\n get didChangeTheme() {\n return this.parentManager && this.name !== this.parentManager.fullName\n }\n\n get parentName() {\n return this.parentManager?.name || null\n }\n\n get fullName(): string {\n return this.getNextTheme().name || this.name || ''\n // const parentName = this.parentManager?.fullName || ''\n // const name = this.name || ''\n // const parts = [...new Set([...`${parentName}_${name}`.split('_')])].filter(Boolean)\n // return parts.join('_')\n }\n\n // gets value going up to parents\n getValue(key: string) {\n let theme = this.theme\n let manager = this as ThemeManager | null\n while (true) {\n if (!theme) return\n if (key in theme) {\n return theme[key]\n }\n manager = this.parentManager\n if (!manager) {\n return\n }\n if (manager.theme === theme) {\n return\n }\n theme = manager.theme\n }\n }\n\n update({ name, theme, className }: SetActiveThemeProps = {}) {\n // className compare on web, avoids light/dark re-renders\n const nameChanged = name !== this.name\n if (!nameChanged) {\n return false\n }\n this.className = className || null\n this.name = name || ''\n this.theme = theme\n this.notifyListeners()\n return true\n }\n\n getNextTheme(props: GetNextThemeProps = {}, debug?: any) {\n const { themes = getThemes(), name, componentName } = props\n\n if (props.reset && name) {\n return {\n name: name,\n theme: themes[name],\n className: this.getClassName(name),\n }\n }\n\n const parentIsReset = this.parentManager?.reset\n\n if (!name) {\n if (componentName) {\n // allow for _Card_Button or just _Button\n const names = [\n `${this.name}_${componentName}`,\n `${withoutComponentName(this.name)}_${componentName}`,\n ]\n for (const name of names) {\n if (name in themes) {\n const className = this.getClassName(name)\n return { name, theme: themes[name], className }\n }\n }\n }\n return {\n name: this.name,\n theme: this.theme,\n }\n }\n\n let nextName = name || this.name || ''\n let parentName = parentIsReset ? this.parentName || this.fullName : this.fullName\n\n while (true) {\n if (nextName in themes) {\n break\n }\n nextName = `${parentName}_${name}`\n if (nextName in themes) {\n break\n }\n if (!parentName.includes(THEME_NAME_SEPARATOR)) {\n // not found!\n console.warn('theme not found', name)\n // this happens in next during _document.getInitialProps and has a terrible/non-existent stack trace\n // throw new Error(`Theme not found: ${name}`)\n break\n }\n // go up one\n parentName = parentName.slice(0, parentName.lastIndexOf(THEME_NAME_SEPARATOR))\n }\n\n if (componentName) {\n // allow for _Card_Button or just _Button\n const names = [\n `${nextName}_${componentName}`,\n `${withoutComponentName(nextName)}_${componentName}`,\n ]\n for (const name of names) {\n if (name in themes) {\n nextName = name\n }\n }\n }\n\n let theme = themes[nextName]\n if (!theme) {\n theme = themes[`light_${nextName}`]\n }\n\n if (process.env.NODE_ENV === 'development') {\n if (debug) {\n console.log('getNextTheme', this.getClassName(nextName), { props, nextName, parentName })\n }\n }\n\n return {\n name: nextName,\n theme: getThemeUnwrapped(theme),\n className: this.getClassName(nextName),\n }\n }\n\n getClassName(name: string) {\n return `${THEME_CLASSNAME_PREFIX}${name} t_Theme`.replace('light_', '').replace('dark_', '')\n }\n\n track(uuid: any, keys: Set<string>) {\n if (!this.name) return\n this.keys.set(uuid, keys)\n }\n\n notifyListeners() {\n if (!this.name) {\n this.keys.clear()\n }\n for (const [uuid, keys] of this.keys.entries()) {\n if (keys.size) {\n this.listeners.get(uuid)?.()\n }\n }\n this.themeListeners.forEach((cb) => cb(this.name, this))\n }\n\n onChangeTheme(cb: ThemeListener) {\n this.themeListeners.add(cb)\n return () => {\n this.themeListeners.delete(cb)\n }\n }\n\n onUpdate(uuid: any, cb: Function) {\n this.listeners.set(uuid, cb)\n return () => {\n this.listeners.delete(uuid)\n this.keys.delete(uuid)\n }\n }\n}\n\nexport const ThemeManagerContext = createContext<ThemeManager | null>(null)\nexport const emptyManager = new ThemeManager()\n\nconst withoutComponentName = (name: string) => name.replace(/(\\_[A-Z][a-zA-Z]+)+$/g, '')\n"],
5
- "mappings": "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",
6
- "names": []
7
- }
package/dist/cjs/conf.js DELETED
@@ -1,70 +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 conf_exports = {};
20
- __export(conf_exports, {
21
- configListeners: () => configListeners,
22
- getConfig: () => getConfig,
23
- getHasConfigured: () => getHasConfigured,
24
- getThemes: () => getThemes,
25
- getTokens: () => getTokens,
26
- onConfiguredOnce: () => onConfiguredOnce,
27
- setConfig: () => setConfig,
28
- setConfigFont: () => setConfigFont
29
- });
30
- module.exports = __toCommonJS(conf_exports);
31
- let conf;
32
- const setConfig = (next) => {
33
- conf = next;
34
- if (configListeners.size) {
35
- configListeners.forEach((cb) => cb(conf));
36
- configListeners.clear();
37
- }
38
- };
39
- const setConfigFont = (name, font, fontParsed) => {
40
- if (process.env.NODE_ENV === "development") {
41
- if (!conf)
42
- throw new Error(`Haven't called createTamagui yet`);
43
- }
44
- Object.assign(conf.fonts, { [name]: font });
45
- Object.assign(conf.fontsParsed, { [`$${name}`]: fontParsed });
46
- };
47
- const getHasConfigured = () => !!conf;
48
- const getConfig = () => conf;
49
- const getTokens = () => conf.tokensParsed;
50
- const getThemes = () => conf.themes;
51
- const configListeners = /* @__PURE__ */ new Set();
52
- const onConfiguredOnce = (cb) => {
53
- if (conf) {
54
- cb(conf);
55
- } else {
56
- configListeners.add(cb);
57
- }
58
- };
59
- // Annotate the CommonJS export names for ESM import in node:
60
- 0 && (module.exports = {
61
- configListeners,
62
- getConfig,
63
- getHasConfigured,
64
- getThemes,
65
- getTokens,
66
- onConfiguredOnce,
67
- setConfig,
68
- setConfigFont
69
- });
70
- //# sourceMappingURL=conf.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/conf.ts"],
4
- "sourcesContent": ["import { ConfigListener, TamaguiInternalConfig } from './types'\n\nlet conf: TamaguiInternalConfig | null\n\nexport const setConfig = (next: TamaguiInternalConfig) => {\n conf = next\n if (configListeners.size) {\n configListeners.forEach((cb) => cb(conf!))\n configListeners.clear()\n }\n}\n\nexport const setConfigFont = (name: string, font: any, fontParsed: any) => {\n if (process.env.NODE_ENV === 'development') {\n if (!conf) throw new Error(`Haven't called createTamagui yet`)\n }\n Object.assign(conf!.fonts, { [name]: font })\n Object.assign(conf!.fontsParsed, { [`$${name}`]: fontParsed })\n}\n\nexport const getHasConfigured = () => !!conf\nexport const getConfig = () => conf!\nexport const getTokens = () => conf!.tokensParsed\nexport const getThemes = () => conf!.themes\n\nexport const configListeners = new Set<ConfigListener>()\n\nexport const onConfiguredOnce = (cb: ConfigListener) => {\n if (conf) {\n cb(conf!)\n } else {\n configListeners.add(cb)\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAI;AAEG,MAAM,YAAY,CAAC,SAAgC;AACxD,SAAO;AACP,MAAI,gBAAgB,MAAM;AACxB,oBAAgB,QAAQ,CAAC,OAAO,GAAG,IAAK,CAAC;AACzC,oBAAgB,MAAM;AAAA,EACxB;AACF;AAEO,MAAM,gBAAgB,CAAC,MAAc,MAAW,eAAoB;AACzE,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,CAAC;AAAM,YAAM,IAAI,MAAM,kCAAkC;AAAA,EAC/D;AACA,SAAO,OAAO,KAAM,OAAO,EAAE,CAAC,OAAO,KAAK,CAAC;AAC3C,SAAO,OAAO,KAAM,aAAa,EAAE,CAAC,IAAI,SAAS,WAAW,CAAC;AAC/D;AAEO,MAAM,mBAAmB,MAAM,CAAC,CAAC;AACjC,MAAM,YAAY,MAAM;AACxB,MAAM,YAAY,MAAM,KAAM;AAC9B,MAAM,YAAY,MAAM,KAAM;AAE9B,MAAM,kBAAkB,oBAAI,IAAoB;AAEhD,MAAM,mBAAmB,CAAC,OAAuB;AACtD,MAAI,MAAM;AACR,OAAG,IAAK;AAAA,EACV,OAAO;AACL,oBAAgB,IAAI,EAAE;AAAA,EACxB;AACF;",
6
- "names": []
7
- }
@@ -1,59 +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 platform_exports = {};
20
- __export(platform_exports, {
21
- isAndroid: () => isAndroid,
22
- isChrome: () => isChrome,
23
- isClient: () => isClient,
24
- isIOS: () => isIOS,
25
- isSSR: () => isSSR,
26
- isTouchable: () => isTouchable,
27
- isWeb: () => isWeb,
28
- isWebTouchable: () => isWebTouchable,
29
- isWindowDefined: () => isWindowDefined,
30
- useIsomorphicLayoutEffect: () => useIsomorphicLayoutEffect
31
- });
32
- module.exports = __toCommonJS(platform_exports);
33
- var import_react = require("react");
34
- var import_react_native = require("react-native");
35
- var _a, _b;
36
- const isAndroid = ((_a = import_react_native.Platform) == null ? void 0 : _a.OS) === "android";
37
- const isIOS = ((_b = import_react_native.Platform) == null ? void 0 : _b.OS) === "ios";
38
- const isWeb = process.env.TAMAGUI_TARGET === "web";
39
- const isWindowDefined = typeof window !== "undefined";
40
- const isSSR = isWeb && !isWindowDefined;
41
- const isClient = isWeb && isWindowDefined;
42
- const useIsomorphicLayoutEffect = isSSR ? import_react.useEffect : import_react.useLayoutEffect;
43
- const isChrome = typeof navigator !== "undefined" && /Chrome/.test(navigator.userAgent || "");
44
- const isWebTouchable = isClient && "ontouchstart" in window;
45
- const isTouchable = !isWeb || isWebTouchable;
46
- // Annotate the CommonJS export names for ESM import in node:
47
- 0 && (module.exports = {
48
- isAndroid,
49
- isChrome,
50
- isClient,
51
- isIOS,
52
- isSSR,
53
- isTouchable,
54
- isWeb,
55
- isWebTouchable,
56
- isWindowDefined,
57
- useIsomorphicLayoutEffect
58
- });
59
- //# 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 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 isSSR = isWeb && !isWindowDefined\nexport const isClient = isWeb && isWindowDefined\nexport const useIsomorphicLayoutEffect = isSSR ? 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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA2C;AAC3C,0BAAyB;AADzB;AAGO,MAAM,YAAY,2DAAU,QAAO;AACnC,MAAM,QAAQ,2DAAU,QAAO;AAC/B,MAAM,QAAQ,QAAQ,IAAI,mBAAmB;AAC7C,MAAM,kBAAkB,OAAO,WAAW;AAC1C,MAAM,QAAQ,SAAS,CAAC;AACxB,MAAM,WAAW,SAAS;AAC1B,MAAM,4BAA4B,QAAQ,yBAAY;AACtD,MAAM,WAAW,OAAO,cAAc,eAAe,SAAS,KAAK,UAAU,aAAa,EAAE;AAC5F,MAAM,iBAAiB,YAAY,kBAAkB;AACrD,MAAM,cAAc,CAAC,SAAS;",
6
- "names": []
7
- }