@tamagui/core 1.0.1-beta.137 → 1.0.1-beta.140

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 (155) hide show
  1. package/dist/cjs/createComponent.js +8 -15
  2. package/dist/cjs/createComponent.js.map +2 -2
  3. package/dist/cjs/helpers/ThemeManager.js +0 -3
  4. package/dist/cjs/helpers/ThemeManager.js.map +2 -2
  5. package/dist/cjs/helpers/assignNativePropsToWeb.js +1 -0
  6. package/dist/cjs/helpers/assignNativePropsToWeb.js.map +2 -2
  7. package/dist/cjs/helpers/createPropMapper.js +2 -3
  8. package/dist/cjs/helpers/createPropMapper.js.map +2 -2
  9. package/dist/cjs/helpers/createTamaguiProvider.js +4 -0
  10. package/dist/cjs/helpers/createTamaguiProvider.js.map +2 -2
  11. package/dist/cjs/helpers/getSplitStyles.js +11 -2
  12. package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
  13. package/dist/cjs/helpers/getVariantExtras.js +6 -6
  14. package/dist/cjs/helpers/getVariantExtras.js.map +2 -2
  15. package/dist/cjs/helpers/insertStyleRule.js +6 -1
  16. package/dist/cjs/helpers/insertStyleRule.js.map +2 -2
  17. package/dist/cjs/helpers/mergeProps.js +18 -14
  18. package/dist/cjs/helpers/mergeProps.js.map +2 -2
  19. package/dist/cjs/hooks/useId.js +2 -32
  20. package/dist/cjs/hooks/useId.js.map +2 -2
  21. package/dist/cjs/hooks/useMedia.js +75 -92
  22. package/dist/cjs/hooks/useMedia.js.map +2 -2
  23. package/dist/cjs/hooks/useSafeRef.js +60 -0
  24. package/dist/cjs/hooks/useSafeRef.js.map +7 -0
  25. package/dist/cjs/hooks/useTheme.js +2 -2
  26. package/dist/cjs/hooks/useTheme.js.map +2 -2
  27. package/dist/cjs/index.js +20 -3
  28. package/dist/cjs/index.js.map +2 -2
  29. package/dist/cjs/types.js.map +1 -1
  30. package/dist/cjs/views/Slot.js +2 -2
  31. package/dist/cjs/views/Slot.js.map +2 -2
  32. package/dist/esm/createComponent.js +8 -15
  33. package/dist/esm/createComponent.js.map +2 -2
  34. package/dist/esm/helpers/ThemeManager.js +0 -3
  35. package/dist/esm/helpers/ThemeManager.js.map +2 -2
  36. package/dist/esm/helpers/assignNativePropsToWeb.js +1 -0
  37. package/dist/esm/helpers/assignNativePropsToWeb.js.map +2 -2
  38. package/dist/esm/helpers/createPropMapper.js +2 -3
  39. package/dist/esm/helpers/createPropMapper.js.map +2 -2
  40. package/dist/esm/helpers/createTamaguiProvider.js +5 -1
  41. package/dist/esm/helpers/createTamaguiProvider.js.map +2 -2
  42. package/dist/esm/helpers/getSplitStyles.js +11 -2
  43. package/dist/esm/helpers/getSplitStyles.js.map +2 -2
  44. package/dist/esm/helpers/getVariantExtras.js +6 -6
  45. package/dist/esm/helpers/getVariantExtras.js.map +2 -2
  46. package/dist/esm/helpers/insertStyleRule.js +6 -1
  47. package/dist/esm/helpers/insertStyleRule.js.map +2 -2
  48. package/dist/esm/helpers/mergeProps.js +18 -14
  49. package/dist/esm/helpers/mergeProps.js.map +2 -2
  50. package/dist/esm/hooks/useId.js +1 -28
  51. package/dist/esm/hooks/useId.js.map +2 -2
  52. package/dist/esm/hooks/useMedia.js +74 -92
  53. package/dist/esm/hooks/useMedia.js.map +2 -2
  54. package/dist/esm/hooks/useSafeRef.js +36 -0
  55. package/dist/esm/hooks/useSafeRef.js.map +7 -0
  56. package/dist/esm/hooks/useTheme.js +2 -2
  57. package/dist/esm/hooks/useTheme.js.map +2 -2
  58. package/dist/esm/index.js +20 -2
  59. package/dist/esm/index.js.map +2 -2
  60. package/dist/esm/views/Slot.js +2 -2
  61. package/dist/esm/views/Slot.js.map +2 -2
  62. package/package.json +8 -8
  63. package/types/Tamagui.d.ts +0 -0
  64. package/types/addTheme.d.ts +0 -0
  65. package/types/conf.d.ts +0 -0
  66. package/types/constants/constants.d.ts +0 -0
  67. package/types/constants/platform.d.ts +2 -2
  68. package/types/contexts/ButtonInsideButtonContext.d.ts +0 -0
  69. package/types/contexts/FontLanguageContext.d.ts +0 -0
  70. package/types/contexts/TextAncestorContext.d.ts +0 -0
  71. package/types/contexts/ThemeContext.d.ts +0 -0
  72. package/types/createComponent.d.ts +0 -0
  73. package/types/createFont.d.ts +0 -0
  74. package/types/createShorthands.d.ts +0 -0
  75. package/types/createTamagui.d.ts +0 -0
  76. package/types/createTheme.d.ts +0 -0
  77. package/types/createTokens.d.ts +0 -0
  78. package/types/createVariable.d.ts +0 -0
  79. package/types/createVariables.d.ts +0 -0
  80. package/types/helpers/RNComponents.d.ts +0 -0
  81. package/types/helpers/ThemeManager.d.ts +0 -0
  82. package/types/helpers/areEqualSets.d.ts +0 -0
  83. package/types/helpers/assignNativePropsToWeb.d.ts +0 -0
  84. package/types/helpers/assignNativePropsToWeb.native.d.ts +0 -0
  85. package/types/helpers/calc.d.ts +0 -0
  86. package/types/helpers/createMediaStyle.d.ts +0 -0
  87. package/types/helpers/createPropMapper.d.ts +0 -0
  88. package/types/helpers/createShallowUpdate.d.ts +0 -0
  89. package/types/helpers/createTamaguiProvider.d.ts +0 -1
  90. package/types/helpers/cssHash.d.ts +0 -0
  91. package/types/helpers/expandStyle.d.ts +0 -0
  92. package/types/helpers/expandStyles.d.ts +0 -0
  93. package/types/helpers/extendStaticConfig.d.ts +0 -0
  94. package/types/helpers/fixNativeShadow.d.ts +0 -0
  95. package/types/helpers/getExpandedShorthands.d.ts +0 -0
  96. package/types/helpers/getFont.d.ts +0 -0
  97. package/types/helpers/getFontLanguage.d.ts +0 -0
  98. package/types/helpers/getSize.d.ts +0 -0
  99. package/types/helpers/getSplitStyles.d.ts +1 -0
  100. package/types/helpers/getStackSize.d.ts +0 -0
  101. package/types/helpers/getStylesAtomic.d.ts +0 -0
  102. package/types/helpers/getStylesAtomic.native.d.ts +0 -0
  103. package/types/helpers/getThemeCSSRules.d.ts +0 -0
  104. package/types/helpers/getThemeCSSRules.native.d.ts +0 -0
  105. package/types/helpers/getVariantExtras.d.ts +0 -0
  106. package/types/helpers/insertStyleRule.d.ts +0 -0
  107. package/types/helpers/isObj.d.ts +0 -0
  108. package/types/helpers/isTamaguiComponent.d.ts +0 -0
  109. package/types/helpers/isTamaguiElement.d.ts +0 -0
  110. package/types/helpers/matchMedia.d.ts +0 -0
  111. package/types/helpers/matchMedia.native.d.ts +0 -0
  112. package/types/helpers/mergeProps.d.ts +3 -1
  113. package/types/helpers/mergeTransform.d.ts +0 -0
  114. package/types/helpers/normalizeColor.d.ts +0 -0
  115. package/types/helpers/normalizeValueWithProperty.d.ts +0 -0
  116. package/types/helpers/proxyThemeVariables.d.ts +0 -0
  117. package/types/helpers/pseudoDescriptors.d.ts +0 -0
  118. package/types/helpers/registerCSSVariable.d.ts +0 -0
  119. package/types/helpers/startTransition.d.ts +0 -0
  120. package/types/helpers/themeable.d.ts +0 -0
  121. package/types/helpers/themes.d.ts +0 -0
  122. package/types/helpers/validate.d.ts +0 -0
  123. package/types/helpers/withStaticProperties.d.ts +0 -0
  124. package/types/hooks/getThemeUnwrapped.d.ts +0 -0
  125. package/types/hooks/useConstant.d.ts +0 -0
  126. package/types/hooks/useFeatures.d.ts +0 -0
  127. package/types/hooks/useId.d.ts +1 -8
  128. package/types/hooks/useIsMounted.d.ts +0 -0
  129. package/types/hooks/useIsSSR.d.ts +0 -0
  130. package/types/hooks/useIsTouchDevice.d.ts +0 -0
  131. package/types/hooks/useMedia.d.ts +2 -1
  132. package/types/hooks/usePressable.d.ts +0 -0
  133. package/types/hooks/useSafeRef.d.ts +4 -0
  134. package/types/hooks/useTheme.d.ts +0 -0
  135. package/types/hooks/useUnmountEffect.d.ts +0 -0
  136. package/types/index.d.ts +2 -1
  137. package/types/insertFont.d.ts +0 -0
  138. package/types/static.d.ts +0 -0
  139. package/types/styled.d.ts +0 -0
  140. package/types/types-rnw.d.ts +0 -0
  141. package/types/types.d.ts +2 -2
  142. package/types/updateTheme.d.ts +0 -0
  143. package/types/vendor/Pressability.d.ts +0 -0
  144. package/types/vendor/Pressability.native.d.ts +0 -0
  145. package/types/views/FontLanguage.d.ts +0 -0
  146. package/types/views/FontLanguage.native.d.ts +0 -0
  147. package/types/views/FontLanguage.types.d.ts +0 -0
  148. package/types/views/Slot.d.ts +0 -0
  149. package/types/views/Stack.d.ts +0 -0
  150. package/types/views/Text.d.ts +0 -0
  151. package/types/views/Theme.d.ts +0 -0
  152. package/types/views/ThemeInverse.d.ts +0 -0
  153. package/types/views/ThemeProvider.d.ts +0 -0
  154. package/types/views/ThemeReset.d.ts +0 -0
  155. package/types/helpers/nativeGestureHandler.native.d.ts +0 -2
@@ -1,13 +1,13 @@
1
- import { useForceUpdate } from "@tamagui/use-force-update";
2
- import { useEffect, useRef } from "react";
1
+ import { useMemo, useState } from "react";
3
2
  import { useIsomorphicLayoutEffect } from "../constants/platform";
4
3
  import { matchMedia } from "../helpers/matchMedia";
5
- import { useConstant } from "./useConstant";
4
+ import { useSafeRef } from "./useSafeRef";
6
5
  const mediaState = {};
7
6
  const mediaQueryListeners = {};
8
7
  function addMediaQueryListener(key, cb) {
9
8
  mediaQueryListeners[key] = mediaQueryListeners[key] || /* @__PURE__ */ new Set();
10
9
  mediaQueryListeners[key].add(cb);
10
+ return () => removeMediaQueryListener(key, cb);
11
11
  }
12
12
  function removeMediaQueryListener(key, cb) {
13
13
  var _a;
@@ -18,114 +18,95 @@ const getMedia = () => {
18
18
  return mediaState;
19
19
  };
20
20
  const dispose = /* @__PURE__ */ new Set();
21
+ let initialMediaState;
21
22
  const configureMedia = ({
22
23
  queries,
23
- defaultActive = ["sm", "xs"]
24
+ defaultActive = {}
24
25
  } = {}) => {
25
26
  if (!queries)
26
27
  return;
27
- if (mediaQueryConfig) {
28
- if (JSON.stringify(queries) === JSON.stringify(mediaQueryConfig)) {
29
- return;
28
+ if (initialMediaState) {
29
+ if (process.env.NODE_ENV === "development") {
30
+ if (JSON.stringify(queries) === JSON.stringify(mediaQueryConfig)) {
31
+ return;
32
+ }
30
33
  }
31
- dispose.forEach((cb) => cb());
32
- dispose.clear();
34
+ setupMediaListeners();
33
35
  }
34
36
  Object.assign(mediaQueryConfig, queries);
35
37
  for (const key in queries) {
36
- const str = mediaObjectToString(queries[key]);
37
- const propKey = `$${key}`;
38
- try {
39
- let update2 = function() {
40
- const next = !!getMatch().matches;
41
- if (next === mediaState[propKey])
42
- return;
43
- mediaState[propKey] = next;
44
- const listeners = mediaQueryListeners[propKey];
45
- if (listeners == null ? void 0 : listeners.size) {
46
- for (const cb of [...listeners]) {
47
- cb();
48
- }
38
+ mediaState[key] = defaultActive[key] || false;
39
+ }
40
+ initialMediaState = { ...mediaState };
41
+ };
42
+ function unlisten() {
43
+ dispose.forEach((cb) => cb());
44
+ dispose.clear();
45
+ }
46
+ function setupMediaListeners() {
47
+ unlisten();
48
+ for (const key in mediaQueryConfig) {
49
+ let update2 = function() {
50
+ const next = !!getMatch().matches;
51
+ if (next === mediaState[key])
52
+ return;
53
+ mediaState[key] = next;
54
+ const listeners = mediaQueryListeners[key];
55
+ if (listeners == null ? void 0 : listeners.size) {
56
+ for (const cb of [...listeners]) {
57
+ cb();
49
58
  }
50
- };
51
- var update = update2;
52
- const getMatch = () => matchMedia(str);
53
- const match = getMatch();
54
- if (!match || typeof match.addListener !== "function") {
55
- throw new Error("\u26A0\uFE0F No match (seeing this in RN sometimes)");
56
59
  }
57
- mediaState[propKey] = !!match.matches;
58
- match.addListener(update2);
59
- dispose.add(() => match.removeListener(update2));
60
- update2();
61
- } catch (err) {
62
- console.error("Error running media query", str, err.message, err.stack);
63
- const isDefaultActive = (defaultActive == null ? void 0 : defaultActive.includes(key)) ?? true;
64
- mediaState[propKey] = isDefaultActive;
60
+ };
61
+ var update = update2;
62
+ const str = mediaObjectToString(mediaQueryConfig[key]);
63
+ const getMatch = () => matchMedia(str);
64
+ const match = getMatch();
65
+ if (!match) {
66
+ throw new Error("\u26A0\uFE0F No match");
65
67
  }
68
+ match.addListener(update2);
69
+ dispose.add(() => match.removeListener(update2));
70
+ update2();
66
71
  }
67
- };
72
+ }
73
+ function useMediaQueryListeners() {
74
+ useIsomorphicLayoutEffect(() => {
75
+ setupMediaListeners();
76
+ return unlisten;
77
+ }, []);
78
+ }
68
79
  function useMedia() {
69
- const forceUpdate = useForceUpdate();
70
- const state = useRef();
71
- if (!state.current) {
72
- state.current = {
73
- selections: {},
74
- nextSelections: {},
75
- isUnmounted: false,
76
- isRendering: true
77
- };
80
+ const [state, setState] = useState(initialMediaState);
81
+ const keys = useSafeRef({});
82
+ function updateState() {
83
+ setState((prev) => {
84
+ for (const key in keys.current) {
85
+ if (prev[key] !== mediaState[key]) {
86
+ return { ...mediaState };
87
+ }
88
+ }
89
+ return prev;
90
+ });
78
91
  }
79
- state.current.isRendering = true;
80
92
  useIsomorphicLayoutEffect(() => {
81
- const st = state.current;
82
- st.isRendering = false;
83
- for (const key in st.selections) {
84
- if (!(key in st.nextSelections)) {
85
- removeMediaQueryListener(key, forceUpdate);
86
- }
87
- }
88
- for (const key in st.nextSelections) {
89
- if (!(key in st.selections)) {
90
- addMediaQueryListener(key, forceUpdate);
91
- }
93
+ const listeners = [];
94
+ for (const key in keys.current) {
95
+ listeners.push(addMediaQueryListener(key, updateState));
92
96
  }
93
- });
94
- useEffect(() => {
97
+ updateState();
95
98
  return () => {
96
- const st = state.current;
97
- st.isUnmounted = true;
98
- const allKeys = {
99
- ...st.selections,
100
- ...st.nextSelections
101
- };
102
- for (const key in allKeys) {
103
- removeMediaQueryListener(key, forceUpdate);
104
- }
99
+ listeners.forEach((cb) => cb());
105
100
  };
106
- }, []);
107
- return useConstant(() => {
108
- const st = state.current;
109
- return new Proxy(mediaState, {
110
- get(target, key) {
111
- if (key[0] !== "$") {
112
- key = `$${key}`;
113
- }
114
- if (!(key in mediaState)) {
115
- return Reflect.get(target, key);
116
- }
117
- if (!st.isUnmounted) {
118
- if (st.isRendering) {
119
- st.nextSelections[key] = true;
120
- }
121
- }
122
- if (key in mediaState) {
123
- return mediaState[key];
124
- }
125
- return Reflect.get(mediaState, key);
126
- }
127
- });
128
101
  });
102
+ return useMemo(() => new Proxy(state, {
103
+ get(_, key) {
104
+ if (!keys.current[key]) {
105
+ keys.current = { ...keys.current, [key]: true };
106
+ }
107
+ return Reflect.get(state, key);
108
+ }
109
+ }), [state, keys]);
129
110
  }
130
111
  function camelToHyphen(str) {
131
112
  return str.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`).toLowerCase();
@@ -153,6 +134,7 @@ export {
153
134
  mediaQueryConfig,
154
135
  mediaState,
155
136
  removeMediaQueryListener,
156
- useMedia
137
+ useMedia,
138
+ useMediaQueryListeners
157
139
  };
158
140
  //# sourceMappingURL=useMedia.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/hooks/useMedia.tsx"],
4
- "sourcesContent": ["import { useForceUpdate } from '@tamagui/use-force-update'\nimport { useEffect, useRef } from 'react'\n\nimport { useIsomorphicLayoutEffect } from '../constants/platform'\nimport { matchMedia } from '../helpers/matchMedia'\nimport {\n ConfigureMediaQueryOptions,\n MediaQueries,\n MediaQueryKey,\n MediaQueryObject,\n MediaQueryState,\n} from '../types'\nimport { useConstant } from './useConstant'\n\nexport const mediaState: MediaQueryState = {} as any\nconst mediaQueryListeners: { [key: string]: Set<Function> } = {}\n\nexport function addMediaQueryListener(key: MediaQueryKey, cb: any) {\n mediaQueryListeners[key] = mediaQueryListeners[key] || new Set()\n mediaQueryListeners[key].add(cb)\n}\n\nexport function removeMediaQueryListener(key: MediaQueryKey, cb: any) {\n mediaQueryListeners[key]?.delete(cb)\n}\n\nexport const mediaQueryConfig: MediaQueries = {}\n\nexport const getMedia = () => {\n return mediaState\n}\n\nconst dispose = new Set<Function>()\n\nexport const configureMedia = ({\n queries,\n defaultActive = ['sm', 'xs'],\n}: ConfigureMediaQueryOptions = {}) => {\n if (!queries) return\n // support hot reload\n if (mediaQueryConfig) {\n if (JSON.stringify(queries) === JSON.stringify(mediaQueryConfig)) {\n // hmr avoid update\n return\n }\n dispose.forEach((cb) => cb())\n dispose.clear()\n }\n\n Object.assign(mediaQueryConfig, queries)\n\n // setup\n for (const key in queries) {\n const str = mediaObjectToString(queries[key])\n const propKey = `$${key}`\n try {\n const getMatch = () => matchMedia(str)\n const match = getMatch()\n if (!match || typeof match.addListener !== 'function') {\n // caught below\n throw new Error('\u26A0\uFE0F No match (seeing this in RN sometimes)')\n }\n mediaState[propKey] = !!match.matches\n // note this deprecated api works with polyfills we use now\n match.addListener(update)\n dispose.add(() => match.removeListener(update))\n\n function update() {\n const next = !!getMatch().matches\n if (next === mediaState[propKey]) return\n mediaState[propKey] = next\n const listeners = mediaQueryListeners[propKey]\n if (listeners?.size) {\n for (const cb of [...listeners]) {\n cb()\n }\n }\n }\n\n update()\n } catch (err: any) {\n console.error('Error running media query', str, err.message, err.stack)\n const isDefaultActive = defaultActive?.includes(key as any) ?? true\n mediaState[propKey] = isDefaultActive\n }\n }\n}\n\ntype UseMediaState = {\n selections: { [key: string]: boolean }\n nextSelections: { [key: string]: boolean }\n isRendering: boolean\n isUnmounted: boolean\n}\n\nexport function useMedia(): {\n [key in MediaQueryKey]: boolean\n} {\n const forceUpdate = useForceUpdate()\n const state = useRef() as React.MutableRefObject<UseMediaState>\n if (!state.current) {\n state.current = {\n selections: {},\n nextSelections: {},\n isUnmounted: false,\n isRendering: true,\n }\n }\n state.current.isRendering = true\n\n // track usage\n useIsomorphicLayoutEffect(() => {\n const st = state.current\n st.isRendering = false\n // delete old\n for (const key in st.selections) {\n if (!(key in st.nextSelections)) {\n removeMediaQueryListener(key, forceUpdate)\n }\n }\n // add new\n for (const key in st.nextSelections) {\n if (!(key in st.selections)) {\n addMediaQueryListener(key, forceUpdate)\n }\n }\n })\n\n // unmount\n useEffect(() => {\n return () => {\n const st = state.current\n st.isUnmounted = true\n const allKeys = {\n ...st.selections,\n ...st.nextSelections,\n }\n for (const key in allKeys) {\n removeMediaQueryListener(key, forceUpdate)\n }\n }\n }, [])\n\n return useConstant(() => {\n const st = state.current\n return new Proxy(mediaState, {\n get(target, key: string) {\n if (key[0] !== '$') {\n key = `$${key}`\n }\n if (!(key in mediaState)) {\n return Reflect.get(target, key)\n }\n if (!st.isUnmounted) {\n if (st.isRendering) {\n st.nextSelections[key] = true\n }\n }\n if (key in mediaState) {\n return mediaState[key]\n }\n return Reflect.get(mediaState, key)\n },\n })\n })\n}\n\nfunction camelToHyphen(str: string) {\n return str.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`).toLowerCase()\n}\n\nexport function mediaObjectToString(query: string | MediaQueryObject) {\n if (typeof query === 'string') {\n return query\n }\n return Object.entries(query)\n .map(([feature, value]) => {\n feature = camelToHyphen(feature)\n if (typeof value === 'string') {\n return `(${feature}: ${value})`\n }\n if (typeof value === 'number' && /[height|width]$/.test(feature)) {\n value = `${value}px`\n }\n return `(${feature}: ${value})`\n })\n .join(' and ')\n}\n"],
5
- "mappings": "AAAA;AACA;AAEA;AACA;AAQA;AAEO,MAAM,aAA8B,CAAC;AAC5C,MAAM,sBAAwD,CAAC;AAExD,+BAA+B,KAAoB,IAAS;AACjE,sBAAoB,OAAO,oBAAoB,QAAQ,oBAAI,IAAI;AAC/D,sBAAoB,KAAK,IAAI,EAAE;AACjC;AAEO,kCAAkC,KAAoB,IAAS;AAtBtE;AAuBE,4BAAoB,SAApB,mBAA0B,OAAO;AACnC;AAEO,MAAM,mBAAiC,CAAC;AAExC,MAAM,WAAW,MAAM;AAC5B,SAAO;AACT;AAEA,MAAM,UAAU,oBAAI,IAAc;AAE3B,MAAM,iBAAiB,CAAC;AAAA,EAC7B;AAAA,EACA,gBAAgB,CAAC,MAAM,IAAI;AAAA,IACG,CAAC,MAAM;AACrC,MAAI,CAAC;AAAS;AAEd,MAAI,kBAAkB;AACpB,QAAI,KAAK,UAAU,OAAO,MAAM,KAAK,UAAU,gBAAgB,GAAG;AAEhE;AAAA,IACF;AACA,YAAQ,QAAQ,CAAC,OAAO,GAAG,CAAC;AAC5B,YAAQ,MAAM;AAAA,E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;AAC7B,aAAO,IAAI,YAAY;AAAA,IACzB;AACA,QAAI,OAAO,UAAU,YAAY,kBAAkB,KAAK,OAAO,GAAG;AAChE,cAAQ,GAAG;AAAA,IACb;AACA,WAAO,IAAI,YAAY;AAAA,EACzB,CAAC,EACA,KAAK,OAAO;AACjB;",
4
+ "sourcesContent": ["import { useMemo, useState } from 'react'\n\nimport { useIsomorphicLayoutEffect } from '../constants/platform'\nimport { matchMedia } from '../helpers/matchMedia'\nimport {\n ConfigureMediaQueryOptions,\n MediaQueries,\n MediaQueryKey,\n MediaQueryObject,\n MediaQueryState,\n} from '../types'\nimport { useSafeRef } from './useSafeRef'\n\nexport const mediaState: MediaQueryState = {} as any\nconst mediaQueryListeners: { [key: string]: Set<Function> } = {}\n\nexport function addMediaQueryListener(key: MediaQueryKey, cb: any) {\n mediaQueryListeners[key] = mediaQueryListeners[key] || new Set()\n mediaQueryListeners[key].add(cb)\n return () => removeMediaQueryListener(key, cb)\n}\n\nexport function removeMediaQueryListener(key: MediaQueryKey, cb: any) {\n mediaQueryListeners[key]?.delete(cb)\n}\n\nexport const mediaQueryConfig: MediaQueries = {}\n\nexport const getMedia = () => {\n return mediaState\n}\n\nconst dispose = new Set<Function>()\n\n// for SSR capture it at time of startup\nlet initialMediaState: MediaQueryState | null\n\nexport const configureMedia = ({\n queries,\n defaultActive = {},\n}: ConfigureMediaQueryOptions = {}) => {\n if (!queries) return\n\n // support hot reload\n if (initialMediaState) {\n if (process.env.NODE_ENV === 'development') {\n if (JSON.stringify(queries) === JSON.stringify(mediaQueryConfig)) {\n // hmr avoid update\n return\n }\n }\n setupMediaListeners()\n }\n\n Object.assign(mediaQueryConfig, queries)\n // start in the initial state\n for (const key in queries) {\n mediaState[key] = defaultActive[key] || false\n }\n initialMediaState = { ...mediaState }\n}\n\nfunction unlisten() {\n dispose.forEach((cb) => cb())\n dispose.clear()\n}\n\nfunction setupMediaListeners() {\n // hmr, undo existing before re-binding\n unlisten()\n\n for (const key in mediaQueryConfig) {\n const str = mediaObjectToString(mediaQueryConfig[key])\n const getMatch = () => matchMedia(str)\n const match = getMatch()\n if (!match) {\n throw new Error('\u26A0\uFE0F No match')\n }\n // react native needs these deprecated apis for now\n match.addListener(update)\n dispose.add(() => match.removeListener(update))\n update()\n\n function update() {\n const next = !!getMatch().matches\n if (next === mediaState[key]) return\n mediaState[key] = next\n const listeners = mediaQueryListeners[key]\n if (listeners?.size) {\n for (const cb of [...listeners]) {\n cb()\n }\n }\n }\n }\n}\n\nexport function useMediaQueryListeners() {\n useIsomorphicLayoutEffect(() => {\n setupMediaListeners()\n return unlisten\n }, [])\n}\n\nexport function useMedia(): {\n [key in MediaQueryKey]: boolean\n} {\n const [state, setState] = useState(initialMediaState!)\n const keys = useSafeRef({} as Record<string, boolean>)\n\n function updateState() {\n setState((prev) => {\n for (const key in keys.current) {\n if (prev[key] !== mediaState[key]) {\n return { ...mediaState }\n }\n }\n return prev\n })\n }\n\n useIsomorphicLayoutEffect(() => {\n const listeners: Function[] = []\n for (const key in keys.current) {\n listeners.push(addMediaQueryListener(key, updateState))\n }\n updateState()\n return () => {\n listeners.forEach((cb) => cb())\n }\n })\n\n return useMemo(\n () =>\n new Proxy(state, {\n get(_, key: string) {\n if (!keys.current[key]) {\n keys.current = { ...keys.current, [key]: true }\n }\n return Reflect.get(state, key)\n },\n }),\n [state, keys]\n )\n}\n\nfunction camelToHyphen(str: string) {\n return str.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`).toLowerCase()\n}\n\nexport function mediaObjectToString(query: string | MediaQueryObject) {\n if (typeof query === 'string') {\n return query\n }\n return Object.entries(query)\n .map(([feature, value]) => {\n feature = camelToHyphen(feature)\n if (typeof value === 'string') {\n return `(${feature}: ${value})`\n }\n if (typeof value === 'number' && /[height|width]$/.test(feature)) {\n value = `${value}px`\n }\n return `(${feature}: ${value})`\n })\n .join(' and ')\n}\n"],
5
+ "mappings": "AAAA;AAEA;AACA;AAQA;AAEO,MAAM,aAA8B,CAAC;AA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Y,GAAG,EAAE,YAAY;AACzE;AAEO,6BAA6B,OAAkC;AACpE,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA,EACT;AACA,SAAO,OAAO,QAAQ,KAAK,EACxB,IAAI,CAAC,CAAC,SAAS,WAAW;AACzB,cAAU,cAAc,OAAO;AAC/B,QAAI,OAAO,UAAU,UAAU;AAC7B,aAAO,IAAI,YAAY;AAAA,IACzB;AACA,QAAI,OAAO,UAAU,YAAY,kBAAkB,KAAK,OAAO,GAAG;AAChE,cAAQ,GAAG;AAAA,IACb;AACA,WAAO,IAAI,YAAY;AAAA,EACzB,CAAC,EACA,KAAK,OAAO;AACjB;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,36 @@
1
+ import { useRef } from "react";
2
+ import { useIsomorphicLayoutEffect } from "../constants/platform";
3
+ const useSafeRef = (initialValue) => {
4
+ const rawRef = useRef();
5
+ const raw = rawRef.current ?? (rawRef.current = {
6
+ isRendering: true,
7
+ comittedValue: initialValue,
8
+ currentValue: initialValue,
9
+ ref: {
10
+ get current() {
11
+ if (raw.isRendering) {
12
+ return raw.currentValue;
13
+ } else {
14
+ return raw.comittedValue;
15
+ }
16
+ },
17
+ set current(v) {
18
+ if (!raw.isRendering) {
19
+ raw.comittedValue = v;
20
+ }
21
+ raw.currentValue = v;
22
+ }
23
+ }
24
+ });
25
+ raw.isRendering = true;
26
+ Promise.resolve().then(() => raw.isRendering = false);
27
+ raw.currentValue = raw.comittedValue;
28
+ useIsomorphicLayoutEffect(() => {
29
+ raw.comittedValue = raw.currentValue;
30
+ });
31
+ return raw.ref;
32
+ };
33
+ export {
34
+ useSafeRef
35
+ };
36
+ //# sourceMappingURL=useSafeRef.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/hooks/useSafeRef.ts"],
4
+ "sourcesContent": ["import { useRef } from 'react'\n\nimport { useIsomorphicLayoutEffect } from '../constants/platform'\n\n// dai-shi \uD83D\uDE4F\n// https://dev.to/uhyo_/a-concurrent-mode-safe-version-of-useref-1325\n\ntype Raw<T> = {\n isRendering: boolean\n comittedValue: T\n currentValue: T\n ref: { current: T }\n}\n\nexport const useSafeRef = <T>(initialValue: T) => {\n const rawRef = useRef<Raw<T>>()\n\n const raw: Raw<T> =\n rawRef.current ??\n (rawRef.current = {\n isRendering: true,\n comittedValue: initialValue,\n currentValue: initialValue,\n ref: {\n get current() {\n if (raw.isRendering) {\n return raw.currentValue\n } else {\n return raw.comittedValue\n }\n },\n set current(v) {\n if (!raw.isRendering) {\n raw.comittedValue = v\n }\n raw.currentValue = v\n },\n },\n })\n\n raw.isRendering = true\n Promise.resolve().then(() => (raw.isRendering = false))\n raw.currentValue = raw.comittedValue\n\n useIsomorphicLayoutEffect(() => {\n raw.comittedValue = raw.currentValue\n })\n\n return raw.ref\n}\n"],
5
+ "mappings": "AAAA;AAEA;AAYO,MAAM,aAAa,CAAI,iBAAoB;AAChD,QAAM,SAAS,OAAe;AAE9B,QAAM,MACJ,OAAO,WACN,QAAO,UAAU;AAAA,IAChB,aAAa;AAAA,IACb,eAAe;AAAA,IACf,cAAc;AAAA,IACd,KAAK;AAAA,MACH,IAAI,UAAU;AACZ,YAAI,IAAI,aAAa;AACnB,iBAAO,IAAI;AAAA,QACb,OAAO;AACL,iBAAO,IAAI;AAAA,QACb;AAAA,MACF;AAAA,MACA,IAAI,QAAQ,GAAG;AACb,YAAI,CAAC,IAAI,aAAa;AACpB,cAAI,gBAAgB;AAAA,QACtB;AACA,YAAI,eAAe;AAAA,MACrB;AAAA,IACF;AAAA,EACF;AAEF,MAAI,cAAc;AAClB,UAAQ,QAAQ,EAAE,KAAK,MAAO,IAAI,cAAc,KAAM;AACtD,MAAI,eAAe,IAAI;AAEvB,4BAA0B,MAAM;AAC9B,QAAI,gBAAgB,IAAI;AAAA,EAC1B,CAAC;AAED,SAAO,IAAI;AACb;",
6
+ "names": []
7
+ }
@@ -38,9 +38,9 @@ const useTheme = (themeName, componentName, props, forceUpdate) => {
38
38
  const debugProp = props && props["debug"];
39
39
  if (!theme) {
40
40
  if (process.env.NODE_ENV === "development") {
41
- console.warn("No theme", { themeName, theme, componentName, className });
41
+ console.warn("No theme with name", themeName);
42
42
  }
43
- return themes[getConfig().defaultTheme || Object.keys(themes)[0]];
43
+ return themes[getConfig().defaultTheme || "light"];
44
44
  }
45
45
  return useMemo(() => {
46
46
  return new Proxy(theme, {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/hooks/useTheme.tsx"],
4
- "sourcesContent": ["import { useForceUpdate } from '@tamagui/use-force-update'\nimport React, { useContext, useLayoutEffect, useMemo, useRef, useState } from 'react'\n\nimport { getConfig } from '../conf'\nimport { isWeb, useIsomorphicLayoutEffect } from '../constants/platform'\nimport { ThemeContext } from '../contexts/ThemeContext'\nimport { areEqualSets } from '../helpers/areEqualSets'\nimport {\n GetNextThemeProps,\n ThemeManager,\n ThemeManagerContext,\n emptyManager,\n} from '../helpers/ThemeManager'\nimport { ThemeName, ThemeObject } from '../types'\nimport { GetThemeUnwrapped } from './getThemeUnwrapped'\nimport { useConstant } from './useConstant'\n\nexport type ThemeProps = {\n className?: string\n disableThemeClass?: boolean\n name: Exclude<ThemeName, number> | null\n componentName?: string\n children?: any\n reset?: boolean\n debug?: boolean | 'verbose'\n}\n\ntype UseThemeState = {\n uuid: Object\n keys: Set<string>\n isRendering: boolean\n}\n\nexport const useTheme = (\n themeName?: string | null,\n componentName?: string,\n props?: ThemeProps,\n forceUpdate?: any\n): ThemeObject => {\n const { name, theme, themes, themeManager, className } = useChangeThemeEffect(\n themeName,\n componentName,\n props,\n forceUpdate\n )\n\n if (process.env.NODE_ENV === 'development') {\n if (props?.debug === 'verbose') {\n console.log(' \uD83D\uDD39 useTheme', { themeName, componentName, name, className })\n }\n }\n\n const state = useRef() as React.MutableRefObject<UseThemeState>\n if (!state.current) {\n state.current = {\n uuid: {},\n keys: new Set(),\n isRendering: true,\n }\n }\n state.current.isRendering = true\n\n // track usage\n useIsomorphicLayoutEffect(() => {\n const st = state.current\n st.isRendering = false\n const cur = themeManager?.keys.get(st.uuid)\n if (!cur || !areEqualSets(st.keys, cur)) {\n themeManager?.track(st.uuid, st.keys)\n }\n })\n\n const debugProp = props && props['debug']\n\n if (!theme) {\n if (process.env.NODE_ENV === 'development') {\n console.warn('No theme', { themeName, theme, componentName, className })\n }\n return themes[getConfig().defaultTheme || Object.keys(themes)[0]]\n }\n\n return useMemo(() => {\n return new Proxy(theme, {\n has(_, key) {\n if (typeof key === 'string') {\n if (key[0] === '$') {\n key = key.slice(1)\n }\n }\n return Reflect.has(theme, key)\n },\n get(_, key) {\n if (key === GetThemeUnwrapped) {\n return theme\n }\n if (key === GetThemeManager) {\n return themeManager\n }\n if (key === 'name') {\n return name\n }\n if (key === 'className') {\n return className\n }\n if (!name || key === '__proto__' || typeof key === 'symbol' || key === '$typeof') {\n return Reflect.get(_, key)\n }\n if (!themeManager) {\n console.error('No themeManager')\n return\n }\n // auto convert variables to plain\n if (key[0] === '$') {\n key = key.slice(1)\n }\n if (state.current.isRendering && !state.current.keys.has(key)) {\n state.current.keys.add(key)\n if (process.env.NODE_ENV === 'development' && debugProp === 'verbose') {\n console.log(' \uD83D\uDD38 tracking theme', key)\n }\n }\n return themeManager.getValue(key)\n },\n })\n }, [name, theme, componentName, className, debugProp])\n}\n\nconst GetThemeManager = Symbol()\n\nexport const getThemeManager = (theme: any): ThemeManager | undefined => {\n if (!theme) return\n return theme[GetThemeManager]\n}\n\nexport const useThemeName = (opts?: { parent?: true }) => {\n const parent = useContext(ThemeManagerContext)\n const [name, setName] = useState(parent?.name || '')\n\n useIsomorphicLayoutEffect(() => {\n if (!parent) return\n return parent.onChangeTheme((next, manager) => {\n const name = opts?.parent ? manager.parentName || next : next\n if (!name) return\n setName(name)\n })\n }, [parent])\n\n return name\n}\n\nexport const useDefaultThemeName = () => {\n return useContext(ThemeContext)?.defaultTheme\n}\n\nexport const activeThemeManagers = new Set<ThemeManager>()\n\nexport const useChangeThemeEffect = (\n name?: string | null,\n componentName?: string,\n props?: ThemeProps,\n forceUpdateProp?: any\n) => {\n const debug = props && props['debug']\n const parentManager = useContext(ThemeManagerContext) || emptyManager\n const { themes } = useContext(ThemeContext)!\n const reset = props?.reset || false\n const getThemeProps: GetNextThemeProps = { name, componentName, themes, reset }\n const next = parentManager.getNextTheme(getThemeProps, debug)\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const forceUpdate = forceUpdateProp || useForceUpdate()\n\n const themeManager = useConstant<ThemeManager | null>(() => {\n if (!next) return null\n return new ThemeManager(next.name, next.theme, parentManager, reset)\n })\n\n // if not SSR\n if (!isWeb || typeof document !== 'undefined') {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useLayoutEffect(() => {\n if (!themeManager) return\n\n activeThemeManagers.add(themeManager)\n\n if (next?.name) {\n themeManager.update(next)\n }\n\n const disposeParentOnChange = parentManager.onChangeTheme(() => {\n const next = parentManager.getNextTheme(getThemeProps, debug)\n if (!next) return\n if (themeManager.update(next)) {\n forceUpdate()\n }\n })\n\n return () => {\n activeThemeManagers.delete(themeManager)\n disposeParentOnChange()\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [themes, name, componentName, debug, next?.name])\n }\n\n return {\n ...(parentManager && {\n name: parentManager.name,\n theme: parentManager.theme,\n }),\n ...next,\n themes,\n themeManager,\n }\n}\n"],
5
- "mappings": "AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAOA;AACA;AAkBO,MAAM,WAAW,CACtB,WACA,eACA,OACA,gBACgB;AAChB,QAAM,EAAE,MAAM,OAAO,QAAQ,cAAc,cAAc,qBACvD,WACA,eACA,OACA,WACF;AAEA,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,gCAAO,WAAU,WAAW;AAC9B,cAAQ,IAAI,wBAAiB,EAAE,WAAW,eAAe,MAAM,UAAU,CAAC;AAAA,IAC5E;AAAA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BAAmB,KAAK;AACzD,QAAM,EAAE,WAAW,WAAW,YAAY;AAC1C,QAAM,QAAQ,gCAAO,UAAS;AAC9B,QAAM,gBAAmC,EAAE,MAAM,eAAe,QAAQ,MAAM;AAC9E,QAAM,OAAO,cAAc,aAAa,eAAe,KAAK;AAE5D,QAAM,cAAc,mBAAmB,eAAe;AAEtD,QAAM,eAAe,YAAiC,MAAM;AAC1D,QAAI,CAAC;AAAM,aAAO;AAClB,WAAO,IAAI,aAAa,KAAK,MAAM,KAAK,OAAO,eAAe,KAAK;AAAA,EACrE,CAAC;AAGD,MAAI,CAAC,SAAS,OAAO,aAAa,aAAa;AAE7C,oBAAgB,MAAM;AACpB,UAAI,CAAC;AAAc;AAEnB,0BAAoB,IAAI,YAAY;AAEpC,UAAI,6BAAM,MAAM;AACd,qBAAa,OAAO,IAAI;AAAA,MAC1B;AAEA,YAAM,wBAAwB,cAAc,cAAc,MAAM;AAC9D,cAAM,QAAO,cAAc,aAAa,eAAe,KAAK;AAC5D,YAAI,CAAC;AAAM;AACX,YAAI,aAAa,OAAO,KAAI,GAAG;AAC7B,sBAAY;AAAA,QACd;AAAA,MACF,CAAC;AAED,aAAO,MAAM;AACX,4BAAoB,OAAO,YAAY;AACvC,8BAAsB;AAAA,MACxB;AAAA,IAEF,GAAG,CAAC,QAAQ,MAAM,eAAe,OAAO,6BAAM,IAAI,CAAC;AAAA,EACrD;AAEA,SAAO;AAAA,IACL,GAAI,iBAAiB;AAAA,MACnB,MAAM,cAAc;AAAA,MACpB,OAAO,cAAc;AAAA,IACvB;AAAA,IACA,GAAG;AAAA,IACH;AAAA,IACA;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import { useForceUpdate } from '@tamagui/use-force-update'\nimport React, { useContext, useLayoutEffect, useMemo, useRef, useState } from 'react'\n\nimport { getConfig } from '../conf'\nimport { isWeb, useIsomorphicLayoutEffect } from '../constants/platform'\nimport { ThemeContext } from '../contexts/ThemeContext'\nimport { areEqualSets } from '../helpers/areEqualSets'\nimport {\n GetNextThemeProps,\n ThemeManager,\n ThemeManagerContext,\n emptyManager,\n} from '../helpers/ThemeManager'\nimport { ThemeName, ThemeObject } from '../types'\nimport { GetThemeUnwrapped } from './getThemeUnwrapped'\nimport { useConstant } from './useConstant'\n\nexport type ThemeProps = {\n className?: string\n disableThemeClass?: boolean\n name: Exclude<ThemeName, number> | null\n componentName?: string\n children?: any\n reset?: boolean\n debug?: boolean | 'verbose'\n}\n\ntype UseThemeState = {\n uuid: Object\n keys: Set<string>\n isRendering: boolean\n}\n\nexport const useTheme = (\n themeName?: string | null,\n componentName?: string,\n props?: ThemeProps,\n forceUpdate?: any\n): ThemeObject => {\n const { name, theme, themes, themeManager, className } = useChangeThemeEffect(\n themeName,\n componentName,\n props,\n forceUpdate\n )\n\n if (process.env.NODE_ENV === 'development') {\n if (props?.debug === 'verbose') {\n // eslint-disable-next-line no-console\n console.log(' \uD83D\uDD39 useTheme', { themeName, componentName, name, className })\n }\n }\n\n const state = useRef() as React.MutableRefObject<UseThemeState>\n if (!state.current) {\n state.current = {\n uuid: {},\n keys: new Set(),\n isRendering: true,\n }\n }\n state.current.isRendering = true\n\n // track usage\n useIsomorphicLayoutEffect(() => {\n const st = state.current\n st.isRendering = false\n const cur = themeManager?.keys.get(st.uuid)\n if (!cur || !areEqualSets(st.keys, cur)) {\n themeManager?.track(st.uuid, st.keys)\n }\n })\n\n const debugProp = props && props['debug']\n\n if (!theme) {\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.warn('No theme with name', themeName)\n }\n return themes[getConfig().defaultTheme || 'light']\n }\n\n return useMemo(() => {\n return new Proxy(theme, {\n has(_, key) {\n if (typeof key === 'string') {\n if (key[0] === '$') {\n key = key.slice(1)\n }\n }\n return Reflect.has(theme, key)\n },\n get(_, key) {\n if (key === GetThemeUnwrapped) {\n return theme\n }\n if (key === GetThemeManager) {\n return themeManager\n }\n if (key === 'name') {\n return name\n }\n if (key === 'className') {\n return className\n }\n if (!name || key === '__proto__' || typeof key === 'symbol' || key === '$typeof') {\n return Reflect.get(_, key)\n }\n if (!themeManager) {\n console.error('No themeManager')\n return\n }\n // auto convert variables to plain\n if (key[0] === '$') {\n key = key.slice(1)\n }\n if (state.current.isRendering && !state.current.keys.has(key)) {\n state.current.keys.add(key)\n if (process.env.NODE_ENV === 'development' && debugProp === 'verbose') {\n console.log(' \uD83D\uDD38 tracking theme', key)\n }\n }\n return themeManager.getValue(key)\n },\n })\n }, [name, theme, componentName, className, debugProp])\n}\n\nconst GetThemeManager = Symbol()\n\nexport const getThemeManager = (theme: any): ThemeManager | undefined => {\n if (!theme) return\n return theme[GetThemeManager]\n}\n\nexport const useThemeName = (opts?: { parent?: true }) => {\n const parent = useContext(ThemeManagerContext)\n const [name, setName] = useState(parent?.name || '')\n\n useIsomorphicLayoutEffect(() => {\n if (!parent) return\n return parent.onChangeTheme((next, manager) => {\n const name = opts?.parent ? manager.parentName || next : next\n if (!name) return\n setName(name)\n })\n }, [parent])\n\n return name\n}\n\nexport const useDefaultThemeName = () => {\n return useContext(ThemeContext)?.defaultTheme\n}\n\nexport const activeThemeManagers = new Set<ThemeManager>()\n\nexport const useChangeThemeEffect = (\n name?: string | null,\n componentName?: string,\n props?: ThemeProps,\n forceUpdateProp?: any\n) => {\n const debug = props && props['debug']\n const parentManager = useContext(ThemeManagerContext) || emptyManager\n const { themes } = useContext(ThemeContext)!\n const reset = props?.reset || false\n const getThemeProps: GetNextThemeProps = { name, componentName, themes, reset }\n const next = parentManager.getNextTheme(getThemeProps, debug)\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const forceUpdate = forceUpdateProp || useForceUpdate()\n\n const themeManager = useConstant<ThemeManager | null>(() => {\n if (!next) return null\n return new ThemeManager(next.name, next.theme, parentManager, reset)\n })\n\n // if not SSR\n if (!isWeb || typeof document !== 'undefined') {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useLayoutEffect(() => {\n if (!themeManager) return\n\n activeThemeManagers.add(themeManager)\n\n if (next?.name) {\n themeManager.update(next)\n }\n\n const disposeParentOnChange = parentManager.onChangeTheme(() => {\n const next = parentManager.getNextTheme(getThemeProps, debug)\n if (!next) return\n if (themeManager.update(next)) {\n forceUpdate()\n }\n })\n\n return () => {\n activeThemeManagers.delete(themeManager)\n disposeParentOnChange()\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [themes, name, componentName, debug, next?.name])\n }\n\n return {\n ...(parentManager && {\n name: parentManager.name,\n theme: parentManager.theme,\n }),\n ...next,\n themes,\n themeManager,\n }\n}\n"],
5
+ "mappings": "AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAOA;AACA;AAkBO,MAAM,WAAW,CACtB,WACA,eACA,OACA,gBACgB;AAChB,QAAM,EAAE,MAAM,OAAO,QAAQ,cAAc,cAAc,qBACvD,WACA,eACA,OACA,WACF;AAEA,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,gCAAO,WAAU,WAAW;AAE9B,cAAQ,IAAI,wBAAiB,EAAE,WAAW,eAAe,MAAM,UAAU,CAAC;AAAA,IAC5E;AAAA,EACF;AAEA,QAAM,QAAQ,OAAO;AACrB,MAAI,CAAC,MAAM,SAAS;AAClB,UAAM,UAAU;AAAA,MACd,MAAM,CAAC;AAAA,MACP,MAAM,oBAAI,IAAI;AAAA,MACd,aAAa;AAAA,IACf;AAAA,EACF;AACA,QAAM,QAAQ,cAAc;AAG5B,4BAA0B,MAAM;AAC9B,UAAM,KAAK,MAAM;AACjB,OAAG,cAAc;AACjB,UAAM,MAAM,6CAAc,KAAK,IAAI,GAAG;AACtC,QAAI,CAAC,OAAO,CAAC,aAAa,GAAG,MAAM,GAAG,GAAG;AACvC,mDAAc,MAAM,GAAG,MAAM,GAAG;AAAA,IAClC;AAAA,EACF,CAAC;AAED,QAAM,YAAY,SAAS,MAAM;AAEjC,MAAI,CAAC,OAAO;AACV,QAAI,QAAQ,IAAI,aAAa,eAAe;AAE1C,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9D,cAAM,QAAO,cAAc,aAAa,eAAe,KAAK;AAC5D,YAAI,CAAC;AAAM;AACX,YAAI,aAAa,OAAO,KAAI,GAAG;AAC7B,sBAAY;AAAA,QACd;AAAA,MACF,CAAC;AAED,aAAO,MAAM;AACX,4BAAoB,OAAO,YAAY;AACvC,8BAAsB;AAAA,MACxB;AAAA,IAEF,GAAG,CAAC,QAAQ,MAAM,eAAe,OAAO,6BAAM,IAAI,CAAC;AAAA,EACrD;AAEA,SAAO;AAAA,IACL,GAAI,iBAAiB;AAAA,MACnB,MAAM,cAAc;AAAA,MACpB,OAAO,cAAc;AAAA,IACvB;AAAA,IACA,GAAG;AAAA,IACH;AAAA,IACA;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
package/dist/esm/index.js CHANGED
@@ -40,11 +40,21 @@ export * from "./hooks/useConstant";
40
40
  export * from "./hooks/useId";
41
41
  export * from "./hooks/useIsMounted";
42
42
  export * from "./hooks/useIsTouchDevice";
43
- export * from "./hooks/useMedia";
43
+ import {
44
+ configureMedia,
45
+ getMedia,
46
+ mediaState,
47
+ useMedia,
48
+ mediaObjectToString,
49
+ addMediaQueryListener,
50
+ removeMediaQueryListener,
51
+ mediaQueryConfig
52
+ } from "./hooks/useMedia";
44
53
  export * from "./hooks/usePressable";
45
54
  export * from "./hooks/useTheme";
46
55
  export * from "./hooks/useIsSSR";
47
56
  export * from "./hooks/useUnmountEffect";
57
+ export * from "./hooks/useSafeRef";
48
58
  export * from "./views/Slot";
49
59
  export * from "./views/Stack";
50
60
  export * from "./views/Text";
@@ -60,11 +70,19 @@ export * from "@tamagui/helpers";
60
70
  export {
61
71
  TextAncestorContext,
62
72
  TextAncestorProvider,
73
+ addMediaQueryListener,
74
+ configureMedia,
63
75
  createDOMProps,
64
76
  getConfig,
65
77
  getHasConfigured,
78
+ getMedia,
66
79
  getThemes,
67
80
  getTokens,
68
- onConfiguredOnce
81
+ mediaObjectToString,
82
+ mediaQueryConfig,
83
+ mediaState,
84
+ onConfiguredOnce,
85
+ removeMediaQueryListener,
86
+ useMedia
69
87
  };
70
88
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["export * from './Tamagui'\nexport * from './createComponent'\nexport * from './createShorthands'\nexport * from './createTheme'\nexport * from './createTamagui'\nexport * from './createFont'\nexport * from './createTokens'\nexport * from './createVariable'\nexport * from './createVariables'\nexport * from './insertFont'\nexport * from './addTheme'\nexport * from './updateTheme'\nexport * from './styled'\nexport * from './types'\n\n// for type portability\nexport type { RNWTextProps, RNWViewProps } from './types-rnw'\nexport { getHasConfigured, getConfig, getThemes, getTokens, onConfiguredOnce } from './conf'\n\nexport * from './constants/constants'\nexport * from './constants/platform'\nexport { createDOMProps } from '@tamagui/rnw'\n\nexport * from './helpers/calc'\nexport * from './helpers/createShallowUpdate'\nexport * from './helpers/getStackSize'\nexport * from './helpers/getVariantExtras'\nexport * from './helpers/getExpandedShorthands'\nexport * from './helpers/getSize'\nexport * from './helpers/getSplitStyles'\nexport * from './helpers/getStylesAtomic'\nexport * from './helpers/pseudoDescriptors'\nexport * from './helpers/mergeProps'\nexport * from './helpers/expandStyles'\nexport * from './helpers/getFont'\nexport * from './helpers/isObj'\nexport * from './helpers/isTamaguiElement'\nexport * from './helpers/isTamaguiComponent'\nexport * from './helpers/matchMedia'\nexport * from './helpers/startTransition'\nexport * from './helpers/themeable'\nexport * from './helpers/withStaticProperties'\n\nexport * from './contexts/ButtonInsideButtonContext'\n\nexport * from './hooks/useConstant'\nexport * from './hooks/useId'\nexport * from './hooks/useIsMounted'\nexport * from './hooks/useIsTouchDevice'\nexport * from './hooks/useMedia'\nexport * from './hooks/usePressable'\nexport * from './hooks/useTheme'\nexport * from './hooks/useIsSSR'\nexport * from './hooks/useUnmountEffect'\n\nexport * from './views/Slot'\nexport * from './views/Stack'\nexport * from './views/Text'\nexport { TextAncestorProvider, TextAncestorContext } from './contexts/TextAncestorContext'\nexport * from './views/Theme'\nexport * from './views/ThemeInverse'\nexport * from './views/ThemeProvider'\nexport * from './views/ThemeReset'\nexport * from './views/FontLanguage'\n\nexport * from '@tamagui/use-force-update'\nexport * from '@tamagui/use-event'\nexport * from '@tamagui/helpers'\n"],
5
- "mappings": "AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;",
4
+ "sourcesContent": ["export * from './Tamagui'\nexport * from './createComponent'\nexport * from './createShorthands'\nexport * from './createTheme'\nexport * from './createTamagui'\nexport * from './createFont'\nexport * from './createTokens'\nexport * from './createVariable'\nexport * from './createVariables'\nexport * from './insertFont'\nexport * from './addTheme'\nexport * from './updateTheme'\nexport * from './styled'\nexport * from './types'\n\n// for type portability\nexport type { RNWTextProps, RNWViewProps } from './types-rnw'\nexport { getHasConfigured, getConfig, getThemes, getTokens, onConfiguredOnce } from './conf'\n\nexport * from './constants/constants'\nexport * from './constants/platform'\nexport { createDOMProps } from '@tamagui/rnw'\n\nexport * from './helpers/calc'\nexport * from './helpers/createShallowUpdate'\nexport * from './helpers/getStackSize'\nexport * from './helpers/getVariantExtras'\nexport * from './helpers/getExpandedShorthands'\nexport * from './helpers/getSize'\nexport * from './helpers/getSplitStyles'\nexport * from './helpers/getStylesAtomic'\nexport * from './helpers/pseudoDescriptors'\nexport * from './helpers/mergeProps'\nexport * from './helpers/expandStyles'\nexport * from './helpers/getFont'\nexport * from './helpers/isObj'\nexport * from './helpers/isTamaguiElement'\nexport * from './helpers/isTamaguiComponent'\nexport * from './helpers/matchMedia'\nexport * from './helpers/startTransition'\nexport * from './helpers/themeable'\nexport * from './helpers/withStaticProperties'\n\nexport * from './contexts/ButtonInsideButtonContext'\n\nexport * from './hooks/useConstant'\nexport * from './hooks/useId'\nexport * from './hooks/useIsMounted'\nexport * from './hooks/useIsTouchDevice'\nexport {\n configureMedia,\n getMedia,\n mediaState,\n useMedia,\n mediaObjectToString,\n addMediaQueryListener,\n removeMediaQueryListener,\n mediaQueryConfig,\n} from './hooks/useMedia'\nexport * from './hooks/usePressable'\nexport * from './hooks/useTheme'\nexport * from './hooks/useIsSSR'\nexport * from './hooks/useUnmountEffect'\nexport * from './hooks/useSafeRef'\n\nexport * from './views/Slot'\nexport * from './views/Stack'\nexport * from './views/Text'\nexport { TextAncestorProvider, TextAncestorContext } from './contexts/TextAncestorContext'\nexport * from './views/Theme'\nexport * from './views/ThemeInverse'\nexport * from './views/ThemeProvider'\nexport * from './views/ThemeReset'\nexport * from './views/FontLanguage'\n\nexport * from '@tamagui/use-force-update'\nexport * from '@tamagui/use-event'\nexport * from '@tamagui/helpers'\n"],
5
+ "mappings": "AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;",
6
6
  "names": []
7
7
  }
@@ -31,7 +31,7 @@ const SlotClone = React.forwardRef((props, forwardedRef) => {
31
31
  const { children, ...slotProps } = props;
32
32
  if (React.isValidElement(children)) {
33
33
  const childProps = {
34
- ...mergeProps(children, slotProps),
34
+ ...mergeSlotProps(children, slotProps),
35
35
  ref: composeRefs(forwardedRef, children.ref)
36
36
  };
37
37
  return React.cloneElement(children, childProps);
@@ -50,7 +50,7 @@ const pressMap = isWeb ? {
50
50
  onPressOut: "onMouseUp",
51
51
  onPressIn: "onMouseDown"
52
52
  } : {};
53
- function mergeProps(child, slotProps) {
53
+ function mergeSlotProps(child, slotProps) {
54
54
  const childProps = child.props;
55
55
  const overrideProps = { ...childProps };
56
56
  const isHTMLChild = typeof child.type === "string";
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/views/Slot.tsx"],
4
- "sourcesContent": ["// via radix\n\nimport { composeRefs } from '@tamagui/compose-refs'\nimport * as React from 'react'\n\nimport { isWeb } from '../constants/platform'\n\n/* -------------------------------------------------------------------------------------------------\n * Slot\n * -----------------------------------------------------------------------------------------------*/\n\nexport type SlotProps = {\n children?: React.ReactNode\n}\n\nexport const Slot = React.forwardRef<HTMLElement, SlotProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props\n const childrenArray = React.Children.toArray(children)\n const slottable = childrenArray.find(isSlottable)\n\n if (slottable) {\n // the new element to render is the one passed as a child of `Slottable`\n const newElement = slottable.props.children as React.ReactNode\n\n const newChildren = childrenArray.map((child) => {\n if (child === slottable) {\n // because the new element will be the one rendered, we are only interested\n // in grabbing its children (`newElement.props.children`)\n if (React.Children.count(newElement) > 1) return React.Children.only(null)\n return React.isValidElement(newElement)\n ? (newElement.props.children as React.ReactNode)\n : null\n } else {\n return child\n }\n })\n\n return (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {React.isValidElement(newElement)\n ? React.cloneElement(newElement, undefined, newChildren)\n : null}\n </SlotClone>\n )\n }\n\n return (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {children}\n </SlotClone>\n )\n})\n\nSlot.displayName = 'Slot'\n\n/* -------------------------------------------------------------------------------------------------\n * SlotClone\n * -----------------------------------------------------------------------------------------------*/\n\ninterface SlotCloneProps {\n children: React.ReactNode\n}\n\nconst SlotClone = React.forwardRef<any, SlotCloneProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props\n\n if (React.isValidElement(children)) {\n const childProps = {\n ...mergeProps(children, slotProps),\n ref: composeRefs(forwardedRef, (children as any).ref),\n }\n return React.cloneElement(children, childProps)\n }\n\n return React.Children.count(children) > 1 ? React.Children.only(null) : null\n})\n\nSlotClone.displayName = 'SlotClone'\n\n/* -------------------------------------------------------------------------------------------------\n * Slottable\n * -----------------------------------------------------------------------------------------------*/\n\nexport const Slottable = ({ children }: { children: React.ReactNode }) => {\n return <>{children}</>\n}\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype AnyProps = Record<string, any>\n\nfunction isSlottable(child: React.ReactNode): child is React.ReactElement {\n return React.isValidElement(child) && child.type === Slottable\n}\n\nconst pressMap = isWeb\n ? {\n onPress: 'onClick',\n onPressOut: 'onMouseUp',\n onPressIn: 'onMouseDown',\n }\n : {}\n\nfunction mergeProps(child: any, slotProps: AnyProps) {\n const childProps = child.props\n\n // all child props should override\n const overrideProps = { ...childProps }\n const isHTMLChild = typeof child.type === 'string'\n\n if (isHTMLChild) {\n for (const key in pressMap) {\n if (key in slotProps) {\n slotProps[pressMap[key]] = slotProps[key]\n delete slotProps[key]\n }\n }\n }\n\n for (let propName in childProps) {\n const slotPropValue = slotProps[propName]\n const childPropValue = childProps[propName]\n\n if (isHTMLChild && pressMap[propName]) {\n propName = pressMap[propName]\n delete overrideProps[propName]\n }\n\n const isHandler = handleRegex.test(propName)\n // if it's a handler, modify the override by composing the base handler\n if (isHandler) {\n overrideProps[propName] = mergeEvent(childPropValue, slotPropValue)\n }\n // if it's `style`, we merge them\n else if (propName === 'style') {\n overrideProps[propName] = { ...slotPropValue, ...childPropValue }\n } else if (propName === 'className') {\n overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(' ')\n }\n }\n\n return { ...slotProps, ...overrideProps }\n}\n\nconst handleRegex = /^on[A-Z]/\n\nexport function mergeEvent(a?: Function, b?: Function) {\n return (...args: unknown[]) => {\n a?.(...args)\n b?.(...args)\n }\n}\n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AACxE,SAAO,MAAM,eAAe,KAAK,KAAK,MAAM,SAAS;AACvD;AAEA,MAAM,WAAW,QACb;AAAA,EACE,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,WAAW;AACb,IACA,CAAC;AAEL,oBAAoB,OAAY,WAAqB;AACnD,QAAM,aAAa,MAAM;AAGzB,QAAM,gBAAgB,EAAE,GAAG,WAAW;AACtC,QAAM,cAAc,OAAO,MAAM,SAAS;AAE1C,MAAI,aAAa;AACf,eAAW,OAAO,UAAU;AAC1B,UAAI,OAAO,WAAW;AACpB,kBAAU,SAAS,QAAQ,UAAU;AACrC,eAAO,UAAU;AAAA,MACnB;AAAA,IACF;AAAA,EACF;AAEA,WAAS,YAAY,YAAY;AAC/B,UAAM,gBAAgB,UAAU;AAChC,UAAM,iBAAiB,WAAW;AAElC,QAAI,eAAe,SAAS,WAAW;AACrC,iBAAW,SAAS;AACpB,aAAO,cAAc;AAAA,IACvB;AAEA,UAAM,YAAY,YAAY,KAAK,QAAQ;AAE3C,QAAI,WAAW;AACb,oBAAc,YAAY,WAAW,gBAAgB,aAAa;AAAA,IACpE,WAES,aAAa,SAAS;AAC7B,oBAAc,YAAY,EAAE,GAAG,eAAe,GAAG,eAAe;AAAA,IAClE,WAAW,aAAa,aAAa;AACnC,oBAAc,YAAY,CAAC,eAAe,cAAc,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAAA,IACpF;AAAA,EACF;AAEA,SAAO,EAAE,GAAG,WAAW,GAAG,cAAc;AAC1C;AAEA,MAAM,cAAc;AAEb,oBAAoB,GAAc,GAAc;AACrD,SAAO,IAAI,SAAoB;AAC7B,2BAAI,GAAG;AACP,2BAAI,GAAG;AAAA,EACT;AACF;",
4
+ "sourcesContent": ["// via radix\n\nimport { composeRefs } from '@tamagui/compose-refs'\nimport * as React from 'react'\n\nimport { isWeb } from '../constants/platform'\n\n/* -------------------------------------------------------------------------------------------------\n * Slot\n * -----------------------------------------------------------------------------------------------*/\n\nexport type SlotProps = {\n children?: React.ReactNode\n}\n\nexport const Slot = React.forwardRef<HTMLElement, SlotProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props\n const childrenArray = React.Children.toArray(children)\n const slottable = childrenArray.find(isSlottable)\n\n if (slottable) {\n // the new element to render is the one passed as a child of `Slottable`\n const newElement = slottable.props.children as React.ReactNode\n\n const newChildren = childrenArray.map((child) => {\n if (child === slottable) {\n // because the new element will be the one rendered, we are only interested\n // in grabbing its children (`newElement.props.children`)\n if (React.Children.count(newElement) > 1) return React.Children.only(null)\n return React.isValidElement(newElement)\n ? (newElement.props.children as React.ReactNode)\n : null\n } else {\n return child\n }\n })\n\n return (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {React.isValidElement(newElement)\n ? React.cloneElement(newElement, undefined, newChildren)\n : null}\n </SlotClone>\n )\n }\n\n return (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {children}\n </SlotClone>\n )\n})\n\nSlot.displayName = 'Slot'\n\n/* -------------------------------------------------------------------------------------------------\n * SlotClone\n * -----------------------------------------------------------------------------------------------*/\n\ninterface SlotCloneProps {\n children: React.ReactNode\n}\n\nconst SlotClone = React.forwardRef<any, SlotCloneProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props\n\n if (React.isValidElement(children)) {\n const childProps = {\n ...mergeSlotProps(children, slotProps),\n ref: composeRefs(forwardedRef, (children as any).ref),\n }\n return React.cloneElement(children, childProps)\n }\n\n return React.Children.count(children) > 1 ? React.Children.only(null) : null\n})\n\nSlotClone.displayName = 'SlotClone'\n\n/* -------------------------------------------------------------------------------------------------\n * Slottable\n * -----------------------------------------------------------------------------------------------*/\n\nexport const Slottable = ({ children }: { children: React.ReactNode }) => {\n return <>{children}</>\n}\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype AnyProps = Record<string, any>\n\nfunction isSlottable(child: React.ReactNode): child is React.ReactElement {\n return React.isValidElement(child) && child.type === Slottable\n}\n\nconst pressMap = isWeb\n ? {\n onPress: 'onClick',\n onPressOut: 'onMouseUp',\n onPressIn: 'onMouseDown',\n }\n : {}\n\nfunction mergeSlotProps(child: any, slotProps: AnyProps) {\n const childProps = child.props\n\n // all child props should override\n const overrideProps = { ...childProps }\n const isHTMLChild = typeof child.type === 'string'\n\n if (isHTMLChild) {\n for (const key in pressMap) {\n if (key in slotProps) {\n slotProps[pressMap[key]] = slotProps[key]\n delete slotProps[key]\n }\n }\n }\n\n for (let propName in childProps) {\n const slotPropValue = slotProps[propName]\n const childPropValue = childProps[propName]\n\n if (isHTMLChild && pressMap[propName]) {\n propName = pressMap[propName]\n delete overrideProps[propName]\n }\n\n const isHandler = handleRegex.test(propName)\n // if it's a handler, modify the override by composing the base handler\n if (isHandler) {\n overrideProps[propName] = mergeEvent(childPropValue, slotPropValue)\n }\n // if it's `style`, we merge them\n else if (propName === 'style') {\n overrideProps[propName] = { ...slotPropValue, ...childPropValue }\n } else if (propName === 'className') {\n overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(' ')\n }\n }\n\n return { ...slotProps, ...overrideProps }\n}\n\nconst handleRegex = /^on[A-Z]/\n\nexport function mergeEvent(a?: Function, b?: Function) {\n return (...args: unknown[]) => {\n a?.(...args)\n b?.(...args)\n }\n}\n"],
5
+ "mappings": "AAEA;AACA;AAEA;AAUO,MAAM,OAAO,MAAM,WAAmC,CAAC,OAAO,iBAAiB;AACpF,QAAM,EAAE,aAAa,cAAc;AACnC,QAAM,gBAAgB,MAAM,SAAS,QAAQ,QAAQ;AACrD,QAAM,YAAY,cAAc,KAAK,WAAW;AAEhD,MAAI,WAAW;AAEb,UAAM,aAAa,UAAU,MAAM;AAEnC,UAAM,cAAc,cAAc,IAAI,CAAC,UAAU;AAC/C,UAAI,UAAU,WAAW;AAGvB,YAAI,MAAM,SAAS,MAAM,UAAU,IAAI;AAAG,iBAAO,MAAM,SAAS,KAAK,IAAI;AACzE,eAAO,MAAM,eAAe,UAAU,IACjC,WAAW,MAAM,WAClB;AAAA,MACN,OAAO;AACL,eAAO;AAAA,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AAM,iBAAiB,WAAW;AAElC,QAAI,eAAe,SAAS,WAAW;AACrC,iBAAW,SAAS;AACpB,aAAO,cAAc;AAAA,IACvB;AAEA,UAAM,YAAY,YAAY,KAAK,QAAQ;AAE3C,QAAI,WAAW;AACb,oBAAc,YAAY,WAAW,gBAAgB,aAAa;AAAA,IACpE,WAES,aAAa,SAAS;AAC7B,oBAAc,YAAY,EAAE,GAAG,eAAe,GAAG,eAAe;AAAA,IAClE,WAAW,aAAa,aAAa;AACnC,oBAAc,YAAY,CAAC,eAAe,cAAc,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAAA,IACpF;AAAA,EACF;AAEA,SAAO,EAAE,GAAG,WAAW,GAAG,cAAc;AAC1C;AAEA,MAAM,cAAc;AAEb,oBAAoB,GAAc,GAAc;AACrD,SAAO,IAAI,SAAoB;AAC7B,2BAAI,GAAG;AACP,2BAAI,GAAG;AAAA,EACT;AACF;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/core",
3
- "version": "1.0.1-beta.137",
3
+ "version": "1.0.1-beta.140",
4
4
  "source": "src/index.ts",
5
5
  "main": "dist/cjs",
6
6
  "module": "dist/esm",
@@ -22,12 +22,12 @@
22
22
  ],
23
23
  "dependencies": {
24
24
  "@expo/match-media": "^0.3.0",
25
- "@tamagui/compose-refs": "^1.0.1-beta.137",
26
- "@tamagui/helpers": "^1.0.1-beta.137",
27
- "@tamagui/rnw": "^1.0.1-beta.137",
28
- "@tamagui/use-debounce": "^1.0.1-beta.137",
29
- "@tamagui/use-event": "^1.0.1-beta.137",
30
- "@tamagui/use-force-update": "^1.0.1-beta.137",
25
+ "@tamagui/compose-refs": "^1.0.1-beta.140",
26
+ "@tamagui/helpers": "^1.0.1-beta.140",
27
+ "@tamagui/rnw": "^1.0.1-beta.140",
28
+ "@tamagui/use-debounce": "^1.0.1-beta.140",
29
+ "@tamagui/use-event": "^1.0.1-beta.140",
30
+ "@tamagui/use-force-update": "^1.0.1-beta.140",
31
31
  "expo-screen-orientation": "^4.3.0",
32
32
  "hyphenate-style-name": "^1.0.4",
33
33
  "normalize-css-color": "^1.0.2",
@@ -38,7 +38,7 @@
38
38
  "react-native-web": "*"
39
39
  },
40
40
  "devDependencies": {
41
- "@tamagui/build": "^1.0.1-beta.137",
41
+ "@tamagui/build": "^1.0.1-beta.140",
42
42
  "@types/react": "^18.0.15",
43
43
  "csstype": "^3.0.10",
44
44
  "esbuild": "^0.14.49",
File without changes
File without changes
package/types/conf.d.ts CHANGED
File without changes
File without changes
@@ -1,11 +1,11 @@
1
- import { useEffect } from 'react';
1
+ import { useLayoutEffect } from 'react';
2
2
  export declare const isAndroid: boolean;
3
3
  export declare const isIOS: boolean;
4
4
  export declare const isWeb: boolean;
5
5
  export declare const isWindowDefined: boolean;
6
6
  export declare const isSSR: boolean;
7
7
  export declare const isClient: boolean;
8
- export declare const useIsomorphicLayoutEffect: typeof useEffect;
8
+ export declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
9
9
  export declare const isChrome: boolean;
10
10
  export declare const isWebTouchable: boolean;
11
11
  export declare const isTouchable: boolean;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes