@tamagui/core 1.0.0-beta.187 → 1.0.0-beta.230

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 (133) hide show
  1. package/dist/cjs/constants/pseudos.js +37 -0
  2. package/dist/cjs/constants/pseudos.js.map +7 -0
  3. package/dist/cjs/createComponent.js +63 -86
  4. package/dist/cjs/createComponent.js.map +2 -2
  5. package/dist/cjs/createShallowUpdate.js +1 -0
  6. package/dist/cjs/createShallowUpdate.js.map +7 -0
  7. package/dist/cjs/defaultComponentState.js +0 -30
  8. package/dist/cjs/defaultComponentState.js.map +3 -3
  9. package/dist/cjs/devtools.js +32 -0
  10. package/dist/cjs/devtools.js.map +7 -0
  11. package/dist/cjs/helpers/RNComponents.js +34 -0
  12. package/dist/cjs/helpers/RNComponents.js.map +7 -0
  13. package/dist/cjs/helpers/createMediaStyle.js +2 -0
  14. package/dist/cjs/helpers/createMediaStyle.js.map +2 -2
  15. package/dist/cjs/helpers/createPropMapper.js +24 -25
  16. package/dist/cjs/helpers/createPropMapper.js.map +2 -2
  17. package/dist/cjs/helpers/createShallowUpdate.js +51 -0
  18. package/dist/cjs/helpers/createShallowUpdate.js.map +7 -0
  19. package/dist/cjs/helpers/createTamaguiProvider.js +1 -5
  20. package/dist/cjs/helpers/createTamaguiProvider.js.map +2 -2
  21. package/dist/cjs/helpers/getSplitStyles.js +22 -14
  22. package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
  23. package/dist/cjs/helpers/getStylesAtomic.js +1 -0
  24. package/dist/cjs/helpers/getStylesAtomic.js.map +2 -2
  25. package/dist/cjs/helpers/insertStyleRule.js +11 -6
  26. package/dist/cjs/helpers/insertStyleRule.js.map +2 -2
  27. package/dist/cjs/hooks/useFeatures.js +93 -7
  28. package/dist/cjs/hooks/useFeatures.js.map +2 -2
  29. package/dist/cjs/hooks/useTheme.js +7 -7
  30. package/dist/cjs/hooks/useTheme.js.map +2 -2
  31. package/dist/cjs/styled.js +2 -12
  32. package/dist/cjs/styled.js.map +2 -2
  33. package/dist/cjs/tamagui-base.css +8 -0
  34. package/dist/cjs/tamagui-base.css.map +7 -0
  35. package/dist/cjs/types-rnw.js.map +1 -1
  36. package/dist/cjs/types.js.map +1 -1
  37. package/dist/cjs/views/Stack.js +1 -0
  38. package/dist/cjs/views/Stack.js.map +2 -2
  39. package/dist/cjs/views/Text.js +1 -0
  40. package/dist/cjs/views/Text.js.map +2 -2
  41. package/dist/cjs/views/Theme.js +4 -1
  42. package/dist/cjs/views/Theme.js.map +2 -2
  43. package/dist/esm/constants/pseudos.js +18 -0
  44. package/dist/esm/constants/pseudos.js.map +7 -0
  45. package/dist/esm/createComponent.js +63 -89
  46. package/dist/esm/createComponent.js.map +2 -2
  47. package/dist/esm/createShallowUpdate.js +1 -0
  48. package/dist/esm/createShallowUpdate.js.map +7 -0
  49. package/dist/esm/defaultComponentState.js +0 -11
  50. package/dist/esm/defaultComponentState.js.map +3 -3
  51. package/dist/esm/devtools.js +14 -0
  52. package/dist/esm/devtools.js.map +7 -0
  53. package/dist/esm/helpers/RNComponents.js +12 -0
  54. package/dist/esm/helpers/RNComponents.js.map +7 -0
  55. package/dist/esm/helpers/createMediaStyle.js +2 -0
  56. package/dist/esm/helpers/createMediaStyle.js.map +2 -2
  57. package/dist/esm/helpers/createPropMapper.js +24 -25
  58. package/dist/esm/helpers/createPropMapper.js.map +2 -2
  59. package/dist/esm/helpers/createShallowUpdate.js +19 -0
  60. package/dist/esm/helpers/createShallowUpdate.js.map +7 -0
  61. package/dist/esm/helpers/createTamaguiProvider.js +1 -4
  62. package/dist/esm/helpers/createTamaguiProvider.js.map +2 -2
  63. package/dist/esm/helpers/getSplitStyles.js +22 -14
  64. package/dist/esm/helpers/getSplitStyles.js.map +2 -2
  65. package/dist/esm/helpers/getStylesAtomic.js +1 -0
  66. package/dist/esm/helpers/getStylesAtomic.js.map +2 -2
  67. package/dist/esm/helpers/insertStyleRule.js +11 -6
  68. package/dist/esm/helpers/insertStyleRule.js.map +2 -2
  69. package/dist/esm/hooks/useFeatures.js +93 -12
  70. package/dist/esm/hooks/useFeatures.js.map +2 -2
  71. package/dist/esm/hooks/useTheme.js +7 -7
  72. package/dist/esm/hooks/useTheme.js.map +2 -2
  73. package/dist/esm/styled.js +1 -8
  74. package/dist/esm/styled.js.map +2 -2
  75. package/dist/esm/tamagui-base.css +8 -0
  76. package/dist/esm/tamagui-base.css.map +7 -0
  77. package/dist/esm/views/Stack.js +1 -0
  78. package/dist/esm/views/Stack.js.map +2 -2
  79. package/dist/esm/views/Text.js +1 -0
  80. package/dist/esm/views/Text.js.map +2 -2
  81. package/dist/esm/views/Theme.js +4 -1
  82. package/dist/esm/views/Theme.js.map +2 -2
  83. package/dist/jsx/constants/pseudos.js +17 -0
  84. package/dist/jsx/createComponent.js +59 -86
  85. package/dist/jsx/createShallowUpdate.js +0 -0
  86. package/dist/jsx/defaultComponentState.js +0 -11
  87. package/dist/jsx/devtools.js +13 -0
  88. package/dist/jsx/helpers/RNComponents.js +11 -0
  89. package/dist/jsx/helpers/createMediaStyle.js +2 -0
  90. package/dist/jsx/helpers/createPropMapper.js +24 -25
  91. package/dist/jsx/helpers/createShallowUpdate.js +18 -0
  92. package/dist/jsx/helpers/createTamaguiProvider.js +1 -2
  93. package/dist/jsx/helpers/getSplitStyles.js +22 -14
  94. package/dist/jsx/helpers/getStylesAtomic.js +1 -0
  95. package/dist/jsx/helpers/insertStyleRule.js +11 -6
  96. package/dist/jsx/hooks/useFeatures.js +93 -12
  97. package/dist/jsx/hooks/useTheme.js +7 -7
  98. package/dist/jsx/styled.js +1 -8
  99. package/dist/jsx/tamagui-base.css +7 -0
  100. package/dist/jsx/views/Stack.js +1 -0
  101. package/dist/jsx/views/Text.js +1 -0
  102. package/dist/jsx/views/Theme.js +4 -1
  103. package/package.json +6 -6
  104. package/types/createComponent.d.ts +5 -6
  105. package/types/createComponent.d.ts.map +1 -1
  106. package/types/defaultComponentState.d.ts +0 -12
  107. package/types/defaultComponentState.d.ts.map +1 -1
  108. package/types/helpers/RNComponents.d.ts +2 -0
  109. package/types/helpers/RNComponents.d.ts.map +1 -0
  110. package/types/helpers/createMediaStyle.d.ts.map +1 -1
  111. package/types/helpers/createPropMapper.d.ts +2 -2
  112. package/types/helpers/createPropMapper.d.ts.map +1 -1
  113. package/types/helpers/createShallowUpdate.d.ts +4 -0
  114. package/types/helpers/createShallowUpdate.d.ts.map +1 -0
  115. package/types/helpers/createTamaguiProvider.d.ts +1 -1
  116. package/types/helpers/createTamaguiProvider.d.ts.map +1 -1
  117. package/types/helpers/getSplitStyles.d.ts +3 -14
  118. package/types/helpers/getSplitStyles.d.ts.map +1 -1
  119. package/types/helpers/getStylesAtomic.d.ts.map +1 -1
  120. package/types/helpers/insertStyleRule.d.ts.map +1 -1
  121. package/types/hooks/useFeatures.d.ts +7 -5
  122. package/types/hooks/useFeatures.d.ts.map +1 -1
  123. package/types/styled.d.ts +3 -7
  124. package/types/styled.d.ts.map +1 -1
  125. package/types/types-rnw.d.ts +0 -5
  126. package/types/types-rnw.d.ts.map +1 -1
  127. package/types/types.d.ts +77 -64
  128. package/types/types.d.ts.map +1 -1
  129. package/types/views/Stack.d.ts +2 -2
  130. package/types/views/Stack.d.ts.map +1 -1
  131. package/types/views/Text.d.ts +2 -2
  132. package/types/views/Text.d.ts.map +1 -1
  133. package/types/views/Theme.d.ts.map +1 -1
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
  import { stylePropsView } from "@tamagui/helpers";
4
4
  import { useForceUpdate } from "@tamagui/use-force-update";
5
- import {
5
+ import React, {
6
6
  Children,
7
7
  Fragment,
8
8
  createElement,
@@ -10,26 +10,33 @@ import {
10
10
  memo,
11
11
  useCallback,
12
12
  useContext,
13
- useEffect,
14
13
  useRef,
15
14
  useState
16
15
  } from "react";
17
16
  import { StyleSheet, Text, View } from "react-native";
18
17
  import { onConfiguredOnce } from "./conf";
19
18
  import { stackDefaultStyles } from "./constants/constants";
20
- import { isAndroid, isTouchDevice, isWeb } from "./constants/platform";
19
+ import { isAndroid, isTouchDevice, isWeb, useIsomorphicLayoutEffect } from "./constants/platform";
21
20
  import { rnw } from "./constants/rnw";
22
21
  import { isVariable } from "./createVariable";
23
- import { defaultComponentState } from "./defaultComponentState";
22
+ import { createShallowUpdate } from "./helpers/createShallowUpdate";
24
23
  import { extendStaticConfig, parseStaticConfig } from "./helpers/extendStaticConfig";
25
- import {
26
- getSplitStyles
27
- } from "./helpers/getSplitStyles";
24
+ import { getSplitStyles } from "./helpers/getSplitStyles";
25
+ import { getAllSelectors } from "./helpers/insertStyleRule";
28
26
  import { wrapThemeManagerContext } from "./helpers/wrapThemeManagerContext";
29
27
  import { useFeatures } from "./hooks/useFeatures";
30
28
  import { usePressable } from "./hooks/usePressable";
31
29
  import { getThemeManagerIfChanged, useTheme } from "./hooks/useTheme";
32
30
  import { TextAncestorContext } from "./views/TextAncestorContext";
31
+ React["keep"];
32
+ const defaultComponentState = {
33
+ hover: false,
34
+ press: false,
35
+ pressIn: false,
36
+ focus: false,
37
+ mounted: false,
38
+ animation: null
39
+ };
33
40
  const mouseUps = /* @__PURE__ */ new Set();
34
41
  if (typeof document !== "undefined") {
35
42
  document.addEventListener("mouseup", () => {
@@ -37,19 +44,6 @@ if (typeof document !== "undefined") {
37
44
  mouseUps.clear();
38
45
  });
39
46
  }
40
- function createShallowUpdate(setter) {
41
- return (next) => {
42
- setter((prev) => {
43
- for (const key in next) {
44
- if (prev[key] !== next[key]) {
45
- return { ...prev, ...next };
46
- }
47
- }
48
- return prev;
49
- });
50
- };
51
- }
52
- __name(createShallowUpdate, "createShallowUpdate");
53
47
  function createComponent(configIn) {
54
48
  let staticConfig;
55
49
  if ("parsed" in configIn) {
@@ -63,13 +57,13 @@ function createComponent(configIn) {
63
57
  let tamaguiConfig;
64
58
  let AnimatedText;
65
59
  let AnimatedView;
66
- let avoidClasses = false;
60
+ let avoidClasses = true;
67
61
  let defaultPseudos = {};
68
62
  let defaultNativeStyle;
69
63
  let defaultNativeStyleSheet = null;
70
64
  let defaultsClassName = null;
71
65
  let initialTheme;
72
- let splitStyleResult = null;
66
+ let defaultSplitStyleResult = null;
73
67
  function addPseudoToStyles(styles, name, pseudos) {
74
68
  const pseudoStyle = pseudos[name];
75
69
  if (pseudoStyle) {
@@ -94,19 +88,22 @@ function createComponent(configIn) {
94
88
  const theme = useTheme(props.theme, componentName, props, forceUpdate);
95
89
  const [state, set_] = useState(defaultComponentState);
96
90
  const setStateShallow = createShallowUpdate(set_);
97
- const shouldAvoidClasses = !!(state.animation && avoidClasses);
98
- const splitInfo = getSplitStyles(props, staticConfig, theme, shouldAvoidClasses ? { ...state, noClassNames: true, resolveVariablesAs: "value" } : state, defaultsClassName);
99
- const { viewProps: viewPropsIn, pseudos, medias, style, classNames } = splitInfo;
91
+ const shouldAvoidClasses = !!(props.animation && avoidClasses);
92
+ const splitStyles = getSplitStyles(props, staticConfig, theme, shouldAvoidClasses ? { ...state, noClassNames: true, resolveVariablesAs: "value" } : state, shouldAvoidClasses ? null : defaultsClassName);
93
+ const { viewProps: viewPropsIn, pseudos, medias, style, classNames } = splitStyles;
100
94
  const useAnimations = (_a = tamaguiConfig.animations) == null ? void 0 : _a.useAnimations;
101
95
  const isAnimated = !!(useAnimations && props.animation);
102
- const styleWithPseudos = props.animation ? merge({ ...defaultNativeStyle, ...style }, state.hover && pseudos.hoverStyle, state.press && pseudos.pressStyle, state.focus && pseudos.focusStyle, ...Object.values(medias)) : null;
96
+ const hasEnterStyle = !!props.enterStyle;
103
97
  const features = useFeatures(props, {
104
98
  forceUpdate,
105
99
  setStateShallow,
106
100
  useAnimations,
107
101
  state,
108
- style: styleWithPseudos,
109
- pseudos
102
+ style: props.animation ? { ...defaultNativeStyle, ...style } : null,
103
+ pseudos,
104
+ staticConfig,
105
+ theme,
106
+ onDidAnimate: props.onDidAnimate
110
107
  });
111
108
  const {
112
109
  tag,
@@ -160,25 +157,22 @@ function createComponent(configIn) {
160
157
  }
161
158
  const hasTextAncestor = isWeb ? useContext(TextAncestorContext) : false;
162
159
  const hostRef = useRef(null);
163
- const hasEnterStyle = !!props.enterStyle;
164
160
  const internal = useRef();
165
161
  if (!internal.current) {
166
162
  internal.current = {
167
163
  isMounted: true
168
164
  };
169
165
  }
170
- useEffect(() => {
171
- if (hasEnterStyle) {
172
- setStateShallow({
173
- mounted: true
174
- });
175
- }
166
+ useIsomorphicLayoutEffect(() => {
167
+ setStateShallow({
168
+ mounted: true
169
+ });
176
170
  internal.current.isMounted = true;
177
171
  return () => {
178
172
  mouseUps.delete(unPress);
179
173
  internal.current.isMounted = false;
180
174
  };
181
- }, []);
175
+ }, [hasEnterStyle]);
182
176
  if (nativeID) {
183
177
  viewProps.id = nativeID;
184
178
  }
@@ -254,10 +248,11 @@ function createComponent(configIn) {
254
248
  const className = classList.join(" ");
255
249
  if (process.env.NODE_ENV === "development") {
256
250
  if (props["debug"]) {
257
- console.log(" \xBB className", { isStringElement, pseudos, state, defaultsClassName, classNames, propsClassName: props.className, style, classList, className: className.trim().split(" "), themeClassName: theme.className });
251
+ console.log(" \xBB className", { isStringElement, pseudos, state, defaultsClassName, classNames, propsClassName: props.className, style, classList, className: className.trim().split(" "), themeClassName: theme.className, values: Object.fromEntries(Object.entries(classNames).map(([k, v]) => [v, getAllSelectors()[v]])) });
258
252
  }
259
253
  }
260
254
  viewProps.className = className;
255
+ viewProps.style = animationStyles;
261
256
  } else {
262
257
  viewProps.style = styles;
263
258
  }
@@ -377,18 +372,6 @@ function createComponent(configIn) {
377
372
  } : {
378
373
  disabled: true
379
374
  });
380
- if (events) {
381
- if (!isStringElement) {
382
- Object.assign(viewProps, pressProps);
383
- } else {
384
- Object.assign(viewProps, events);
385
- }
386
- if (isWeb && isHoverable) {
387
- childEls = <span style={{
388
- display: "contents"
389
- }} onMouseEnter={events.onMouseEnter} onMouseLeave={events.onMouseLeave}>{children}</span>;
390
- }
391
- }
392
375
  let content;
393
376
  if (isWeb) {
394
377
  if (staticConfig.isReactNativeWeb) {
@@ -405,11 +388,23 @@ function createComponent(configIn) {
405
388
  }
406
389
  }
407
390
  }
391
+ if (events) {
392
+ if (!isStringElement) {
393
+ Object.assign(viewProps, pressProps);
394
+ } else {
395
+ Object.assign(viewProps, events);
396
+ }
397
+ }
408
398
  content = createElement(ViewComponent, viewProps, childEls);
399
+ if (isWeb && events && attachHover) {
400
+ content = <span className="tui_Hoverable" style={{
401
+ display: "contents"
402
+ }} onMouseEnter={events.onMouseEnter} onMouseLeave={events.onMouseLeave}>{content}</span>;
403
+ }
409
404
  if (process.env.NODE_ENV === "development") {
410
405
  if (props["debug"]) {
411
406
  viewProps["debug"] = true;
412
- console.log(" \xBB ", { propsIn: { ...props }, propsOut: { ...viewProps }, animationStyles, isStringElement, classNamesIn: (_c = props.className) == null ? void 0 : _c.split(" "), classNamesOut: (_d = viewProps.className) == null ? void 0 : _d.split(" "), pressProps, events, shouldAttach, ViewComponent, viewProps, state, styles, pseudos, content, childEls, shouldAvoidClasses, animation: props.animation, style, defaultNativeStyle, splitStyleResult, ...typeof window !== "undefined" ? { theme, themeState: theme.__state, themeClassName: theme.className, staticConfig, tamaguiConfig } : null });
407
+ console.log(" \xBB ", { propsIn: { ...props }, propsOut: { ...viewProps }, state, splitStyles, defaultsClassName, animationStyles, isStringElement, classNamesIn: (_c = props.className) == null ? void 0 : _c.split(" "), classNamesOut: (_d = viewProps.className) == null ? void 0 : _d.split(" "), pressProps, events, shouldAttach, ViewComponent, viewProps, styles, pseudos, content, childEls, shouldAvoidClasses, avoidClasses, animation: props.animation, style, defaultNativeStyle, defaultSplitStyleResult, ...typeof window !== "undefined" ? { theme, themeState: theme.__state, themeClassName: theme.className, staticConfig, tamaguiConfig } : null });
413
408
  }
414
409
  }
415
410
  if (features.length) {
@@ -422,17 +417,24 @@ function createComponent(configIn) {
422
417
  });
423
418
  onConfiguredOnce((conf) => {
424
419
  var _a, _b, _c, _d;
420
+ if (process.env.IS_STATIC === "is_static") {
421
+ return;
422
+ }
425
423
  const shouldDebug = (_a = staticConfig.defaultProps) == null ? void 0 : _a.debug;
426
424
  tamaguiConfig = conf;
427
425
  avoidClasses = !!((_b = tamaguiConfig.animations) == null ? void 0 : _b.avoidClasses);
428
426
  AnimatedText = (_c = tamaguiConfig.animations) == null ? void 0 : _c.Text;
429
427
  AnimatedView = (_d = tamaguiConfig == null ? void 0 : tamaguiConfig.animations) == null ? void 0 : _d.View;
430
428
  initialTheme = conf.themes[conf.defaultTheme || Object.keys(conf.themes)[0]];
431
- splitStyleResult = getSplitStyles(staticConfig.defaultProps, staticConfig, initialTheme, {
429
+ defaultSplitStyleResult = getSplitStyles(staticConfig.defaultProps, staticConfig, initialTheme, {
432
430
  mounted: true,
433
- resolveVariablesAs: "variable"
431
+ hover: false,
432
+ press: false,
433
+ pressIn: false,
434
+ focus: false,
435
+ resolveVariablesAs: "both"
434
436
  });
435
- const { classNames, pseudos, style, viewProps } = splitStyleResult;
437
+ const { classNames, pseudos, style, viewProps } = defaultSplitStyleResult;
436
438
  if (isWeb) {
437
439
  defaultsClassName = classNames;
438
440
  }
@@ -451,13 +453,14 @@ function createComponent(configIn) {
451
453
  ...component.defaultProps
452
454
  };
453
455
  if (process.env.NODE_ENV === "development" && shouldDebug && process.env.IS_STATIC !== "is_static") {
454
- console.log(`\u{1F41B} [${staticConfig.componentName || "Component"}]`, { staticConfig, ...splitStyleResult });
456
+ console.log(`\u{1F41B} [${staticConfig.componentName || "Component"}]`, { staticConfig, ...defaultSplitStyleResult });
455
457
  }
456
458
  });
457
459
  let res = component;
458
460
  if (configIn.memo) {
459
461
  res = memo(res);
460
462
  }
463
+ res["whyDidYouRender"] = true;
461
464
  res["staticConfig"] = {
462
465
  validStyles: validStyleProps,
463
466
  ...staticConfig
@@ -478,6 +481,7 @@ function createComponent(configIn) {
478
481
  __name(createComponent, "createComponent");
479
482
  const Spacer = createComponent({
480
483
  memo: true,
484
+ componentName: "Spacer",
481
485
  defaultProps: {
482
486
  ...stackDefaultStyles,
483
487
  size: true
@@ -550,38 +554,6 @@ function spacedChildren({
550
554
  return next;
551
555
  }
552
556
  __name(spacedChildren, "spacedChildren");
553
- const merge = /* @__PURE__ */ __name((...styles) => {
554
- if (!styles[0])
555
- return;
556
- const res = {};
557
- const len = styles.length;
558
- for (let i = len - 1; i >= 0; i--) {
559
- const cur = styles[i];
560
- if (!cur)
561
- continue;
562
- for (const key in cur) {
563
- const val = cur[key];
564
- if (key !== "transform") {
565
- if (!(key in res)) {
566
- res[key] = val;
567
- }
568
- continue;
569
- }
570
- if (!res.transform) {
571
- res.transform = val;
572
- continue;
573
- }
574
- for (const t of val) {
575
- const tkey = Object.keys(t)[0];
576
- if (res.transform.find((existing) => tkey in existing)) {
577
- continue;
578
- }
579
- res.transform.push(t);
580
- }
581
- }
582
- }
583
- return res;
584
- }, "merge");
585
557
  const AbsoluteFill = /* @__PURE__ */ __name((props) => isWeb ? <div style={{
586
558
  position: "absolute",
587
559
  top: 0,
@@ -593,6 +565,7 @@ export {
593
565
  AbsoluteFill,
594
566
  Spacer,
595
567
  createComponent,
568
+ defaultComponentState,
596
569
  mouseUps,
597
570
  spacedChildren
598
571
  };
File without changes
@@ -1,11 +0,0 @@
1
- const defaultComponentState = {
2
- hover: false,
3
- press: false,
4
- pressIn: false,
5
- focus: false,
6
- mounted: false,
7
- animation: null
8
- };
9
- export {
10
- defaultComponentState
11
- };
@@ -0,0 +1,13 @@
1
+ import { onConfiguredOnce } from "./conf";
2
+ import { insertedSelectors } from "./helpers/insertStyleRule";
3
+ onConfiguredOnce((conf) => {
4
+ if (globalThis["Tamagui"]) {
5
+ return;
6
+ }
7
+ globalThis["Tamagui"] = {
8
+ ...conf,
9
+ get insertedCSS() {
10
+ return insertedSelectors;
11
+ }
12
+ };
13
+ });
@@ -0,0 +1,11 @@
1
+ import * as ReactNative from "react-native";
2
+ const RNComponents = /* @__PURE__ */ new WeakMap();
3
+ for (const key of ["Image", "TextInput", "Text", "View"]) {
4
+ const val = ReactNative[key];
5
+ if (val && typeof val === "object") {
6
+ RNComponents.set(val, true);
7
+ }
8
+ }
9
+ export {
10
+ RNComponents
11
+ };
@@ -13,6 +13,8 @@ const createMediaStyle = /* @__PURE__ */ __name(({ identifier, rules }, mediaKey
13
13
  const mediaSelector = mediaObjectToString(mediaQueries[mediaKey]);
14
14
  const mediaQuery = `${screenStr} and ${mediaSelector}`;
15
15
  const styleInner = rules[0].replace(identifier, nextIdentifier);
16
+ if (styleInner.includes("2:r;"))
17
+ debugger;
16
18
  let styleRule = "";
17
19
  if (styleInner.includes("@media")) {
18
20
  styleRule = styleInner.replace("{", ` and ${mediaQuery} {`);
@@ -4,8 +4,8 @@ import { getConfig } from "../conf";
4
4
  import { isWeb } from "../constants/platform";
5
5
  import { isVariable } from "../createVariable";
6
6
  import { isObj } from "./isObj";
7
- const createPropMapper = /* @__PURE__ */ __name((c) => {
8
- const variants = c.variants || {};
7
+ const createPropMapper = /* @__PURE__ */ __name((staticConfig) => {
8
+ const variants = staticConfig.variants || {};
9
9
  function getVariantFunction(variant, key, value) {
10
10
  for (const cat in tokenCategories) {
11
11
  if (key in tokenCategories[cat]) {
@@ -27,8 +27,8 @@ const createPropMapper = /* @__PURE__ */ __name((c) => {
27
27
  return fn || variant["..."] || variant["...size"];
28
28
  }
29
29
  __name(getVariantFunction, "getVariantFunction");
30
- const defaultProps = c.defaultProps || {};
31
- return (key, value, theme, props, staticConfig, returnVariablesAs = !!props.animation ? "value" : "auto", avoidDefaultProps = false) => {
30
+ const defaultProps = staticConfig.defaultProps || {};
31
+ return (key, value, theme, props, returnVariablesAs = !!props.animation ? "value" : "auto", avoidDefaultProps = false) => {
32
32
  const conf = getConfig();
33
33
  if (!conf) {
34
34
  console.trace("no conf! err");
@@ -38,29 +38,28 @@ const createPropMapper = /* @__PURE__ */ __name((c) => {
38
38
  const variant = variants && variants[key];
39
39
  if (variant && value !== void 0) {
40
40
  let variantValue = getVariantFunction(variant, key, value);
41
- if (!variantValue) {
42
- return value;
43
- }
44
- if (typeof variantValue === "function") {
45
- variantValue = variantValue(value, {
46
- tokens: conf.tokensParsed,
47
- theme,
48
- props: avoidDefaultProps ? props : new Proxy(props, {
49
- get(target, key2) {
50
- if (Reflect.has(target, key2)) {
51
- return Reflect.get(target, key2);
52
- }
53
- if (staticConfig.defaultProps) {
54
- return Reflect.get(staticConfig.defaultProps, key2);
41
+ if (variantValue) {
42
+ if (typeof variantValue === "function") {
43
+ variantValue = variantValue(value, {
44
+ tokens: conf.tokensParsed,
45
+ theme,
46
+ props: avoidDefaultProps ? props : new Proxy(props, {
47
+ get(target, key2) {
48
+ if (Reflect.has(target, key2)) {
49
+ return Reflect.get(target, key2);
50
+ }
51
+ if (staticConfig.defaultProps) {
52
+ return Reflect.get(staticConfig.defaultProps, key2);
53
+ }
55
54
  }
56
- }
57
- })
58
- });
59
- }
60
- if (isObj(variantValue)) {
61
- variantValue = resolveTokens(variantValue, conf, theme, fontFamily, returnVariablesAs);
55
+ })
56
+ });
57
+ }
58
+ if (isObj(variantValue)) {
59
+ variantValue = resolveTokens(variantValue, conf, theme, fontFamily, returnVariablesAs);
60
+ }
61
+ return variantValue;
62
62
  }
63
- return variantValue;
64
63
  }
65
64
  let shouldReturn = false;
66
65
  if (conf.shorthands[key]) {
@@ -0,0 +1,18 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ function createShallowUpdate(setter) {
4
+ return (next) => {
5
+ setter((prev) => {
6
+ for (const key in next) {
7
+ if (prev[key] !== next[key]) {
8
+ return { ...prev, ...next };
9
+ }
10
+ }
11
+ return prev;
12
+ });
13
+ };
14
+ }
15
+ __name(createShallowUpdate, "createShallowUpdate");
16
+ export {
17
+ createShallowUpdate
18
+ };
@@ -10,7 +10,6 @@ function createTamaguiProvider({
10
10
  }) {
11
11
  return /* @__PURE__ */ __name(function TamaguiProvider({
12
12
  injectCSS,
13
- fallback,
14
13
  children,
15
14
  ...themePropsProvider
16
15
  }) {
@@ -26,7 +25,7 @@ function createTamaguiProvider({
26
25
  };
27
26
  }, []);
28
27
  }
29
- return <ButtonInsideButtonContext.Provider value={false}><TextAncestorProvider><ThemeProvider {...themeProps} {...themePropsProvider}><React.Suspense fallback={fallback || null}>{children}</React.Suspense></ThemeProvider></TextAncestorProvider></ButtonInsideButtonContext.Provider>;
28
+ return <ButtonInsideButtonContext.Provider value={false}><TextAncestorProvider><ThemeProvider {...themeProps} {...themePropsProvider}>{children}</ThemeProvider></TextAncestorProvider></ButtonInsideButtonContext.Provider>;
30
29
  }, "TamaguiProvider");
31
30
  }
32
31
  __name(createTamaguiProvider, "createTamaguiProvider");
@@ -34,7 +34,6 @@ function normalizeStyleObject(style) {
34
34
  }
35
35
  __name(normalizeStyleObject, "normalizeStyleObject");
36
36
  const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state, defaultClassNames) => {
37
- var _a, _b, _c;
38
37
  const validStyleProps = staticConfig.isText ? stylePropsText : validStyles;
39
38
  const viewProps = {};
40
39
  const style = {};
@@ -51,12 +50,16 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
51
50
  if (val.startsWith("_transform-")) {
52
51
  const isMediaOrPseudo = key !== "transform";
53
52
  const isMedia = isMediaOrPseudo && key[11] === "_";
54
- const isPsuedo = isMediaOrPseudo && !isMedia;
53
+ const isPsuedo = isMediaOrPseudo && key[11] === "0";
55
54
  const namespace = isMedia ? key.split("_")[2] : isPsuedo ? key.split("-")[1] : "transform";
56
55
  if (!insertedTransforms[val]) {
57
56
  updateInserted();
58
57
  }
59
58
  const transform = insertedTransforms[val];
59
+ if (!transform || transform === "undefined") {
60
+ console.trace("NO TRANSFORM", { key, val }, state);
61
+ return;
62
+ }
60
63
  transforms[namespace] = transforms[namespace] || ["", ""];
61
64
  transforms[namespace][0] += val.replace("_transform", "");
62
65
  transforms[namespace][1] += transform;
@@ -79,7 +82,8 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
79
82
  style[atomicStyle.property] = atomicStyle.value;
80
83
  }
81
84
  }
82
- } else {
85
+ }
86
+ if (state.noClassNames || state.resolveVariablesAs === "value" || state.resolveVariablesAs === "both") {
83
87
  for (const key in cur) {
84
88
  if (key in stylePropsTransform) {
85
89
  mergeTransform(style, key, cur[key]);
@@ -109,13 +113,16 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
109
113
  }
110
114
  let isMedia = keyInit[0] === "$";
111
115
  let isPseudo = validPseudoKeys[keyInit];
112
- const out = isMedia || isPseudo ? true : staticConfig.propMapper(keyInit, valInit, theme, props, staticConfig, state.resolveVariablesAs);
116
+ const out = isMedia || isPseudo ? true : staticConfig.propMapper(keyInit, valInit, theme, state.fallbackProps || props, state.resolveVariablesAs);
113
117
  const expanded = out === true || !out ? [[keyInit, valInit]] : Object.entries(out);
118
+ if (process.env.NODE_ENV === "development" && props["debug"] === "verbose") {
119
+ console.log("split style", keyInit, expanded);
120
+ }
114
121
  for (const [key, val] of expanded) {
115
122
  if (val === void 0) {
116
123
  continue;
117
124
  }
118
- if (val && val[0] === "_") {
125
+ if (key !== "target" && val && val[0] === "_") {
119
126
  mergeClassName(key, val);
120
127
  continue;
121
128
  }
@@ -131,12 +138,9 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
131
138
  continue;
132
139
  }
133
140
  pseudos[key] = pseudos[key] || {};
134
- pseudos[key] = getSubStyle(val, staticConfig, theme, props, state.resolveVariablesAs, true);
141
+ pseudos[key] = getSubStyle(val, staticConfig, theme, props, state, true);
135
142
  if (isWeb && !state.noClassNames) {
136
143
  const pseudoStyles = getStylesAtomic({ [key]: pseudos[key] });
137
- if ((_b = (_a = pseudoStyles[0]) == null ? void 0 : _a.identifier) == null ? void 0 : _b.includes("undefined")) {
138
- console.warn("undefined bug?", (_c = pseudoStyles[0]) == null ? void 0 : _c.identifier);
139
- }
140
144
  for (const style2 of pseudoStyles) {
141
145
  mergeClassName(`${style2.property}-${key}`, style2.identifier);
142
146
  insertStyleRule(style2.identifier, style2.rules[0]);
@@ -147,10 +151,10 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
147
151
  if (isMedia) {
148
152
  const mediaKey = key.slice(1);
149
153
  if (!mediaQueryConfig[mediaKey]) {
150
- viewProps[key] = valInit;
154
+ viewProps[key] = val;
151
155
  continue;
152
156
  }
153
- const mediaStyle = getSubStyle(valInit, staticConfig, theme, props, state.resolveVariablesAs, true);
157
+ const mediaStyle = getSubStyle(val, staticConfig, theme, props, state, true);
154
158
  if (isWeb) {
155
159
  const mediaStyles = getStylesAtomic(mediaStyle);
156
160
  for (const style2 of mediaStyles) {
@@ -202,6 +206,9 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
202
206
  classNames[namespace] = identifier;
203
207
  }
204
208
  }
209
+ if (process.env.NODE_ENV === "development" && props["debug"] === "verbose") {
210
+ console.log("out", pseudos);
211
+ }
205
212
  return {
206
213
  viewProps,
207
214
  style,
@@ -210,11 +217,11 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
210
217
  classNames
211
218
  };
212
219
  }, "getSplitStyles");
213
- const getSubStyle = /* @__PURE__ */ __name((styleIn, staticConfig, theme, props, resolveVariablesAs, avoidDefaultProps) => {
220
+ const getSubStyle = /* @__PURE__ */ __name((styleIn, staticConfig, theme, props, state, avoidDefaultProps) => {
214
221
  const styleOut = {};
215
222
  for (const key in styleIn) {
216
223
  const val = styleIn[key];
217
- const out = staticConfig.propMapper(key, val, theme, props, staticConfig, resolveVariablesAs, avoidDefaultProps);
224
+ const out = staticConfig.propMapper(key, val, theme, state.fallbackProps || props, state.resolveVariablesAs, avoidDefaultProps);
218
225
  const expanded = out === true || !out ? [[key, val]] : Object.entries(out);
219
226
  for (const [skey, sval] of expanded) {
220
227
  if (skey in stylePropsTransform) {
@@ -228,5 +235,6 @@ const getSubStyle = /* @__PURE__ */ __name((styleIn, staticConfig, theme, props,
228
235
  return styleOut;
229
236
  }, "getSubStyle");
230
237
  export {
231
- getSplitStyles
238
+ getSplitStyles,
239
+ getSubStyle
232
240
  };
@@ -56,6 +56,7 @@ function getAtomicStyle(style, pseudo, options) {
56
56
  ...out[key],
57
57
  transformProperty
58
58
  };
59
+ console.log("got", JSON.stringify({ t, tKey, out, key, atomicStyles }, null, 2));
59
60
  }
60
61
  } else {
61
62
  atomicStyles = generateAtomicStyles(style);
@@ -19,8 +19,9 @@ function addTransform(identifier, rule) {
19
19
  }
20
20
  __name(addTransform, "addTransform");
21
21
  let hasInsertedSinceUpdate = true;
22
+ const isClient = typeof document !== "undefined";
22
23
  function updateInserted() {
23
- if (typeof document === "undefined") {
24
+ if (!isClient) {
24
25
  return;
25
26
  }
26
27
  if (!hasInsertedSinceUpdate) {
@@ -33,17 +34,18 @@ function updateInserted() {
33
34
  for (let i = 0; i < sheets.length; i++) {
34
35
  const rules = sheets[i].cssRules;
35
36
  const firstRule = rules[0];
36
- if (!firstRule)
37
+ if (!(firstRule instanceof CSSStyleRule))
37
38
  continue;
38
- const firstSelector = firstRule["selectorText"];
39
+ const firstSelector = firstRule.selectorText;
39
40
  if (!firstSelector)
40
41
  continue;
41
42
  if (firstSelector === ":root" || firstSelector.startsWith("._")) {
42
- for (const rule of rules) {
43
- if (!rule.selectorText)
43
+ for (let i2 = 0; i2 < rules.length; i2++) {
44
+ const rule = rules.item(i2);
45
+ if (!(rule instanceof CSSStyleRule))
44
46
  continue;
45
47
  const identifier = rule.selectorText.slice(1);
46
- allSelectors[identifier] = true;
48
+ allSelectors[identifier] = process.env.NODE_ENV === "development" ? rule.cssText : true;
47
49
  if (identifier.startsWith("_transform")) {
48
50
  addTransform(identifier, rule.cssText);
49
51
  }
@@ -60,6 +62,9 @@ function insertStyleRule(identifier, rule) {
60
62
  return;
61
63
  }
62
64
  hasInsertedSinceUpdate = true;
65
+ if (identifier === "_transform-1abwpjw") {
66
+ console.trace("inserting", identifier, rule);
67
+ }
63
68
  insertedSelectors[identifier] = rule;
64
69
  allSelectors[identifier] = process.env.NODE_ENV === "development" ? rule : true;
65
70
  if (identifier.startsWith("_transform")) {