@tamagui/web 1.36.6 → 1.37.1

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 (151) hide show
  1. package/dist/cjs/constants/accessibilityDirectMap.native.js +3 -0
  2. package/dist/cjs/constants/accessibilityDirectMap.native.js.map +1 -1
  3. package/dist/cjs/createComponent.js +29 -25
  4. package/dist/cjs/createComponent.js.map +1 -1
  5. package/dist/cjs/createTamagui.js +8 -9
  6. package/dist/cjs/createTamagui.js.map +1 -1
  7. package/dist/cjs/helpers/ThemeManager.js +2 -2
  8. package/dist/cjs/helpers/ThemeManager.js.map +1 -1
  9. package/dist/cjs/helpers/createPropMapper.js +7 -6
  10. package/dist/cjs/helpers/createPropMapper.js.map +1 -1
  11. package/dist/cjs/helpers/extendStaticConfig.js +3 -2
  12. package/dist/cjs/helpers/extendStaticConfig.js.map +1 -1
  13. package/dist/cjs/helpers/getSplitStyles.js +178 -228
  14. package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
  15. package/dist/cjs/helpers/getStylesAtomic.js +1 -1
  16. package/dist/cjs/helpers/getStylesAtomic.js.map +1 -1
  17. package/dist/cjs/helpers/getThemeCSSRules.js +1 -1
  18. package/dist/cjs/helpers/getThemeCSSRules.js.map +1 -1
  19. package/dist/cjs/hooks/useMedia.js +3 -2
  20. package/dist/cjs/hooks/useMedia.js.map +1 -1
  21. package/dist/cjs/styled.js +10 -6
  22. package/dist/cjs/styled.js.map +1 -1
  23. package/dist/esm/constants/accessibilityDirectMap.native.js +2 -0
  24. package/dist/esm/constants/accessibilityDirectMap.native.js.map +1 -1
  25. package/dist/esm/createComponent.js +29 -25
  26. package/dist/esm/createComponent.js.map +1 -1
  27. package/dist/esm/createTamagui.js +8 -9
  28. package/dist/esm/createTamagui.js.map +1 -1
  29. package/dist/esm/helpers/ThemeManager.js +2 -2
  30. package/dist/esm/helpers/ThemeManager.js.map +1 -1
  31. package/dist/esm/helpers/createPropMapper.js +7 -6
  32. package/dist/esm/helpers/createPropMapper.js.map +1 -1
  33. package/dist/esm/helpers/extendStaticConfig.js +3 -2
  34. package/dist/esm/helpers/extendStaticConfig.js.map +1 -1
  35. package/dist/esm/helpers/getSplitStyles.js +178 -229
  36. package/dist/esm/helpers/getSplitStyles.js.map +2 -2
  37. package/dist/esm/helpers/getStylesAtomic.js +1 -1
  38. package/dist/esm/helpers/getStylesAtomic.js.map +1 -1
  39. package/dist/esm/helpers/getThemeCSSRules.js +1 -1
  40. package/dist/esm/helpers/getThemeCSSRules.js.map +1 -1
  41. package/dist/esm/hooks/useMedia.js +3 -2
  42. package/dist/esm/hooks/useMedia.js.map +1 -1
  43. package/dist/esm/styled.js +10 -6
  44. package/dist/esm/styled.js.map +1 -1
  45. package/package.json +9 -9
  46. package/src/constants/accessibilityDirectMap.native.tsx +3 -0
  47. package/src/createComponent.tsx +37 -25
  48. package/src/createTamagui.ts +16 -9
  49. package/src/helpers/ThemeManager.tsx +2 -2
  50. package/src/helpers/createPropMapper.ts +7 -12
  51. package/src/helpers/extendStaticConfig.ts +6 -2
  52. package/src/helpers/getSplitStyles.tsx +268 -281
  53. package/src/helpers/getStylesAtomic.ts +1 -1
  54. package/src/helpers/getThemeCSSRules.ts +4 -1
  55. package/src/hooks/useMedia.tsx +6 -3
  56. package/src/styled.tsx +8 -4
  57. package/src/types.tsx +7 -2
  58. package/types/constants/accessibilityDirectMap.native.d.ts +1 -0
  59. package/types/helpers/getSplitStyles.d.ts +1 -1
  60. package/types/types.d.ts +5 -3
  61. package/types/Tamagui.d.ts.map +0 -1
  62. package/types/config.d.ts.map +0 -1
  63. package/types/constants/accessibilityDirectMap.d.ts.map +0 -1
  64. package/types/constants/accessibilityDirectMap.native.d.ts.map +0 -1
  65. package/types/constants/constants.d.ts.map +0 -1
  66. package/types/constants/isDevTools.d.ts.map +0 -1
  67. package/types/contexts/AnimationDriverContext.d.ts.map +0 -1
  68. package/types/contexts/ButtonNestingContext.d.ts.map +0 -1
  69. package/types/contexts/FontLanguageContext.d.ts.map +0 -1
  70. package/types/contexts/TextAncestorContext.d.ts.map +0 -1
  71. package/types/createComponent.d.ts.map +0 -1
  72. package/types/createFont.d.ts.map +0 -1
  73. package/types/createShorthands.d.ts.map +0 -1
  74. package/types/createTamagui.d.ts.map +0 -1
  75. package/types/createTheme.d.ts.map +0 -1
  76. package/types/createTokens.d.ts.map +0 -1
  77. package/types/createVariable.d.ts.map +0 -1
  78. package/types/createVariables.d.ts.map +0 -1
  79. package/types/helpers/ThemeManager.d.ts.map +0 -1
  80. package/types/helpers/ThemeManagerContext.d.ts.map +0 -1
  81. package/types/helpers/createChainedWeakCache.d.ts.map +0 -1
  82. package/types/helpers/createMediaStyle.d.ts.map +0 -1
  83. package/types/helpers/createPropMapper.d.ts.map +0 -1
  84. package/types/helpers/createProxy.d.ts.map +0 -1
  85. package/types/helpers/createStyledContext.d.ts.map +0 -1
  86. package/types/helpers/defaultOffset.d.ts.map +0 -1
  87. package/types/helpers/expandStyle.d.ts.map +0 -1
  88. package/types/helpers/expandStyles.d.ts.map +0 -1
  89. package/types/helpers/extendStaticConfig.d.ts.map +0 -1
  90. package/types/helpers/getAnimationDriver.d.ts.map +0 -1
  91. package/types/helpers/getExpandedShorthands.d.ts.map +0 -1
  92. package/types/helpers/getFontLanguage.d.ts.map +0 -1
  93. package/types/helpers/getSplitStyles.d.ts.map +0 -1
  94. package/types/helpers/getStylesAtomic.d.ts.map +0 -1
  95. package/types/helpers/getStylesAtomic.native.d.ts.map +0 -1
  96. package/types/helpers/getThemeCSSRules.d.ts.map +0 -1
  97. package/types/helpers/getThemeCSSRules.native.d.ts.map +0 -1
  98. package/types/helpers/getVariantExtras.d.ts.map +0 -1
  99. package/types/helpers/insertStyleRule.d.ts.map +0 -1
  100. package/types/helpers/isObj.d.ts.map +0 -1
  101. package/types/helpers/isTamaguiComponent.d.ts.map +0 -1
  102. package/types/helpers/isTamaguiElement.d.ts.map +0 -1
  103. package/types/helpers/matchMedia.d.ts.map +0 -1
  104. package/types/helpers/matchMedia.native.d.ts.map +0 -1
  105. package/types/helpers/mergeProps.d.ts.map +0 -1
  106. package/types/helpers/normalizeColor.d.ts.map +0 -1
  107. package/types/helpers/normalizeShadow.d.ts.map +0 -1
  108. package/types/helpers/normalizeShadow.native.d.ts.map +0 -1
  109. package/types/helpers/normalizeStylePropKeys.d.ts.map +0 -1
  110. package/types/helpers/normalizeStylePropKeys.native.d.ts.map +0 -1
  111. package/types/helpers/normalizeValueWithProperty.d.ts.map +0 -1
  112. package/types/helpers/objectIdentityKey.d.ts.map +0 -1
  113. package/types/helpers/proxyThemeVariables.d.ts.map +0 -1
  114. package/types/helpers/pseudoDescriptors.d.ts.map +0 -1
  115. package/types/helpers/registerCSSVariable.d.ts.map +0 -1
  116. package/types/helpers/themeable.d.ts.map +0 -1
  117. package/types/helpers/themes.d.ts.map +0 -1
  118. package/types/helpers/timer.d.ts.map +0 -1
  119. package/types/helpers/useShallowSetState.d.ts.map +0 -1
  120. package/types/helpers/withStaticProperties.d.ts.map +0 -1
  121. package/types/hooks/getThemeUnwrapped.d.ts.map +0 -1
  122. package/types/hooks/useAnimationDriver.d.ts.map +0 -1
  123. package/types/hooks/useId.d.ts.map +0 -1
  124. package/types/hooks/useIsTouchDevice.d.ts.map +0 -1
  125. package/types/hooks/useMedia.d.ts.map +0 -1
  126. package/types/hooks/useProps.d.ts.map +0 -1
  127. package/types/hooks/useSafeRef.d.ts.map +0 -1
  128. package/types/hooks/useServerHooks.d.ts.map +0 -1
  129. package/types/hooks/useStyle.d.ts.map +0 -1
  130. package/types/hooks/useTheme.d.ts.map +0 -1
  131. package/types/hooks/useThemeName.d.ts.map +0 -1
  132. package/types/index.d.ts.map +0 -1
  133. package/types/inject-styles.d.ts.map +0 -1
  134. package/types/insertFont.d.ts.map +0 -1
  135. package/types/setupHooks.d.ts.map +0 -1
  136. package/types/setupReactNative.d.ts.map +0 -1
  137. package/types/styled.d.ts.map +0 -1
  138. package/types/types.d.ts.map +0 -1
  139. package/types/views/AnimationDriverProvider.d.ts.map +0 -1
  140. package/types/views/FontLanguage.d.ts.map +0 -1
  141. package/types/views/FontLanguage.native.d.ts.map +0 -1
  142. package/types/views/FontLanguage.types.d.ts.map +0 -1
  143. package/types/views/Slot.d.ts.map +0 -1
  144. package/types/views/Stack.d.ts.map +0 -1
  145. package/types/views/TamaguiProvider.d.ts.map +0 -1
  146. package/types/views/Text.d.ts.map +0 -1
  147. package/types/views/Theme.d.ts.map +0 -1
  148. package/types/views/ThemeDebug.d.ts.map +0 -1
  149. package/types/views/ThemeDebug.native.d.ts.map +0 -1
  150. package/types/views/ThemeProvider.d.ts.map +0 -1
  151. package/types/views/View.d.ts.map +0 -1
@@ -7,7 +7,6 @@ import {
7
7
  useIsomorphicLayoutEffect
8
8
  } from "@tamagui/constants";
9
9
  import {
10
- stylePropsFont,
11
10
  stylePropsText,
12
11
  stylePropsTransform,
13
12
  validPseudoKeys,
@@ -49,24 +48,24 @@ import {
49
48
  import { pseudoDescriptors } from "./pseudoDescriptors";
50
49
  let conf;
51
50
  const PROP_SPLIT = "-";
51
+ let defaultFontVariable = "";
52
52
  const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, languageContext, elementType, debug) => {
53
- var _a, _b, _c;
53
+ var _a, _b, _c, _d, _e, _f, _g;
54
54
  conf = conf || getConfig();
55
55
  const { shorthands } = conf;
56
56
  const { variants, propMapper, isReactNative, inlineProps, inlineWhenUnflattened } = staticConfig;
57
57
  const validStyleProps = staticConfig.isText ? stylePropsText : validStyles;
58
58
  const viewProps = {};
59
59
  let pseudos = null;
60
- let psuedosUsed = null;
61
60
  const mediaState = state.mediaState || globalMediaState;
62
61
  const usedKeys = {};
63
62
  const propKeys = Object.keys(props);
63
+ const numProps = propKeys.length;
64
64
  let space = props.space;
65
65
  let hasMedia = false;
66
66
  const shouldDoClasses = staticConfig.acceptsClassName && (isWeb || IS_STATIC) && !state.noClassNames;
67
67
  let style = {};
68
68
  const flatTransforms = {};
69
- const len = propKeys.length;
70
69
  const rulesToInsert = [];
71
70
  const classNames = {};
72
71
  let className = "";
@@ -84,12 +83,12 @@ const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, la
84
83
  viewProps,
85
84
  languageContext
86
85
  };
87
- if (process.env.NODE_ENV === "development" && debug) {
88
- console.groupCollapsed("getSplitStyles (looping backwards)");
86
+ if (process.env.NODE_ENV === "development" && debug && isClient) {
87
+ console.groupCollapsed("getSplitStyles (collapsed)");
89
88
  console.log({ props, staticConfig, shouldDoClasses, state, IS_STATIC, propKeys, styleState, theme: { ...theme } });
90
89
  console.groupEnd();
91
90
  }
92
- if (props.className) {
91
+ if (typeof props.className === "string") {
93
92
  for (const cn of props.className.split(" ")) {
94
93
  if (cn[0] === "_") {
95
94
  const [shorthand, mediaOrPseudo] = cn.slice(1).split("-");
@@ -112,46 +111,56 @@ const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, la
112
111
  }
113
112
  }
114
113
  }
115
- function passDownProp(key, val, shouldMergeObject = key in pseudoDescriptors) {
116
- if (shouldMergeObject) {
117
- viewProps[key] ||= {};
118
- viewProps[key] = {
119
- ...val,
120
- ...viewProps[key]
121
- };
122
- } else {
123
- usedKeys[key] = 1;
124
- viewProps[key] = val;
125
- }
126
- }
127
- const specialProps = [];
128
- function processProp(keyInit, valInit, special = false, fontFamilyOverride = null) {
129
- var _a2, _b2, _c2, _d;
130
- if (keyInit === "className")
131
- return;
114
+ for (let i = 0; i < numProps; i++) {
115
+ let keyInit = propKeys[i];
116
+ let valInit = props[keyInit];
132
117
  if (keyInit in shorthands) {
133
118
  keyInit = shorthands[keyInit];
134
119
  }
135
- if (keyInit === "accessibilityRole") {
136
- usedKeys["role"] = 1;
120
+ if (keyInit === "className")
121
+ continue;
122
+ if (keyInit in usedKeys)
123
+ continue;
124
+ if (process.env.TAMAGUI_TARGET === "web") {
125
+ if (typeof valInit === "string" && valInit[0] === "_") {
126
+ if (keyInit in validStyleProps || keyInit.includes("-")) {
127
+ if (process.env.NODE_ENV === "development" && debug) {
128
+ console.log(`Adding compiled style ${keyInit}: ${valInit}`);
129
+ }
130
+ if (shouldDoClasses) {
131
+ classNames[keyInit] = valInit;
132
+ delete style[keyInit];
133
+ } else {
134
+ style[keyInit] = reverseMapClassNameToValue(keyInit, valInit);
135
+ delete className[keyInit];
136
+ }
137
+ continue;
138
+ }
139
+ }
137
140
  }
138
141
  if (process.env.TAMAGUI_TARGET === "native") {
139
142
  if (!isAndroid) {
140
143
  if (keyInit === "elevationAndroid")
141
- return;
144
+ continue;
142
145
  }
143
146
  if (keyInit === "userSelect") {
144
147
  keyInit = "selectable";
145
148
  valInit = valInit === "none" ? false : true;
146
- } else if (keyInit.startsWith("aria-") || keyInit === "role") {
149
+ } else if (keyInit === "role") {
150
+ if (valInit === "list") {
151
+ viewProps[keyInit] = valInit;
152
+ } else if (accessibilityWebRoleToNativeRole[valInit]) {
153
+ viewProps["accessibilityRole"] = accessibilityWebRoleToNativeRole[valInit];
154
+ }
155
+ continue;
156
+ } else if (keyInit.startsWith("aria-")) {
147
157
  if (webToNativeAccessibilityDirectMap[keyInit]) {
148
158
  const nativeA11yProp = webToNativeAccessibilityDirectMap[keyInit];
149
159
  if (keyInit === "aria-hidden") {
150
160
  viewProps["aria-hidden"] = valInit;
151
161
  }
152
162
  viewProps[nativeA11yProp] = valInit;
153
- usedKeys[keyInit] = 1;
154
- return;
163
+ continue;
155
164
  } else if (nativeAccessibilityValue[keyInit]) {
156
165
  let field = nativeAccessibilityValue[keyInit];
157
166
  if (viewProps["accessibilityValue"]) {
@@ -161,7 +170,6 @@ const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, la
161
170
  [field]: valInit
162
171
  };
163
172
  }
164
- usedKeys[keyInit] = 1;
165
173
  } else if (nativeAccessibilityState[keyInit]) {
166
174
  let field = nativeAccessibilityState[keyInit];
167
175
  if (viewProps["accessibilityState"]) {
@@ -171,56 +179,30 @@ const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, la
171
179
  [field]: valInit
172
180
  };
173
181
  }
174
- usedKeys[keyInit] = 1;
175
- } else if (keyInit === "role") {
176
- if (valInit === "list") {
177
- viewProps[keyInit] = valInit;
178
- } else if (accessibilityWebRoleToNativeRole[valInit]) {
179
- viewProps["accessibilityRole"] = accessibilityWebRoleToNativeRole[valInit];
180
- }
181
- return;
182
182
  }
183
- return;
183
+ continue;
184
184
  } else if (keyInit.startsWith("data-")) {
185
- return;
185
+ continue;
186
186
  }
187
187
  }
188
- if (process.env.TAMAGUI_TARGET === "web") {
189
- if (keyInit === "elevationAndroid")
190
- return;
191
- }
192
188
  if (!staticConfig.isHOC) {
193
189
  if (keyInit in skipProps) {
194
190
  if (process.env.NODE_ENV === "development" && debug && keyInit === "debug") {
195
191
  } else {
196
- return;
197
- }
198
- }
199
- }
200
- if (keyInit in usedKeys) {
201
- return;
202
- }
203
- if (typeof valInit === "string" && valInit[0] === "_") {
204
- if (keyInit in validStyleProps || keyInit.includes("-")) {
205
- if (shouldDoClasses) {
206
- classNames[keyInit] = valInit;
207
- } else {
208
- style[keyInit] = reverseMapClassNameToValue(keyInit, valInit);
192
+ continue;
209
193
  }
210
- usedKeys[keyInit] = 1;
211
- return;
212
194
  }
213
195
  }
214
196
  if (keyInit === "dataSet") {
215
- for (const key in valInit) {
216
- viewProps[`data-${hyphenate(key)}`] = valInit[key];
197
+ for (const keyInit2 in valInit) {
198
+ viewProps[`data-${hyphenate(keyInit2)}`] = valInit[keyInit2];
217
199
  }
218
- return;
200
+ continue;
219
201
  }
220
202
  const isMainStyle = keyInit === "style";
221
203
  if (isMainStyle || keyInit.startsWith("_style")) {
222
204
  if (!valInit)
223
- return;
205
+ continue;
224
206
  const styles = [].concat(valInit).flat();
225
207
  const styleLen = styles.length;
226
208
  for (let j = styleLen; j >= 0; j--) {
@@ -235,44 +217,41 @@ const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, la
235
217
  style[key] = cur[key];
236
218
  }
237
219
  }
238
- return;
220
+ continue;
239
221
  }
240
222
  if (process.env.TAMAGUI_TARGET === "web") {
241
223
  if (keyInit === "disabled" && valInit === true) {
242
- usedKeys[keyInit] = 1;
243
224
  viewProps["aria-disabled"] = true;
244
225
  if (elementType === "button" || elementType === "form" || elementType === "input" || elementType === "select" || elementType === "textarea") {
245
226
  viewProps.disabled = true;
246
227
  }
247
228
  if (!(variants == null ? void 0 : variants.disabled)) {
248
- return;
229
+ continue;
249
230
  }
250
231
  }
251
232
  if (keyInit === "testID") {
252
- usedKeys[keyInit] = 1;
253
233
  viewProps[isReactNative ? "testId" : "data-testid"] = valInit;
254
- return;
234
+ continue;
255
235
  }
256
236
  if (keyInit === "id" || keyInit === "nativeID") {
257
- usedKeys[keyInit] = 1;
258
237
  if (isReactNative) {
259
238
  viewProps.nativeID = valInit;
260
239
  } else {
261
240
  viewProps.id = valInit;
262
241
  }
263
- return;
242
+ continue;
264
243
  }
265
244
  let didUseKeyInit = false;
266
245
  if (isReactNative) {
267
- if (accessibilityDirectMap[keyInit] || keyInit.startsWith("accessibility")) {
246
+ if (keyInit in accessibilityDirectMap || keyInit.startsWith("accessibility")) {
268
247
  viewProps[keyInit] = valInit;
269
- usedKeys[keyInit] = 1;
270
- return;
248
+ continue;
271
249
  }
272
250
  } else {
273
251
  didUseKeyInit = true;
274
252
  if (keyInit in accessibilityDirectMap) {
275
253
  viewProps[accessibilityDirectMap[keyInit]] = valInit;
254
+ continue;
276
255
  } else {
277
256
  switch (keyInit) {
278
257
  case "accessibilityRole": {
@@ -281,38 +260,38 @@ const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, la
281
260
  } else {
282
261
  viewProps.role = accessibilityRoleToWebRole[valInit] || valInit;
283
262
  }
284
- return;
263
+ continue;
285
264
  }
286
265
  case "accessibilityLabelledBy":
287
266
  case "accessibilityFlowTo":
288
267
  case "accessibilityControls":
289
268
  case "accessibilityDescribedBy": {
290
269
  viewProps[`aria-${keyInit.replace("accessibility", "").toLowerCase()}`] = processIDRefList(valInit);
291
- return;
270
+ continue;
292
271
  }
293
272
  case "accessibilityKeyShortcuts": {
294
273
  if (Array.isArray(valInit)) {
295
274
  viewProps["aria-keyshortcuts"] = valInit.join(" ");
296
275
  }
297
- return;
276
+ continue;
298
277
  }
299
278
  case "accessibilityLiveRegion": {
300
279
  viewProps["aria-live"] = valInit === "none" ? "off" : valInit;
301
- return;
280
+ continue;
302
281
  }
303
282
  case "accessibilityReadOnly": {
304
283
  viewProps["aria-readonly"] = valInit;
305
284
  if (elementType === "input" || elementType === "select" || elementType === "textarea") {
306
285
  viewProps.readOnly = true;
307
286
  }
308
- return;
287
+ continue;
309
288
  }
310
289
  case "accessibilityRequired": {
311
290
  viewProps["aria-required"] = valInit;
312
291
  if (elementType === "input" || elementType === "select" || elementType === "textarea") {
313
292
  viewProps.required = valInit;
314
293
  }
315
- return;
294
+ continue;
316
295
  }
317
296
  default: {
318
297
  didUseKeyInit = false;
@@ -321,71 +300,57 @@ const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, la
321
300
  }
322
301
  }
323
302
  if (didUseKeyInit) {
324
- usedKeys[keyInit] = 1;
325
- return;
303
+ continue;
326
304
  }
327
305
  if (valInit && valInit[0] === "_") {
328
306
  const isValidClassName = keyInit in validStyles;
329
307
  const isMediaOrPseudo2 = !isValidClassName && keyInit.includes(PROP_SPLIT) && validStyles[keyInit.split(PROP_SPLIT)[0]];
330
308
  if (isValidClassName || isMediaOrPseudo2) {
331
- usedKeys[keyInit] = 1;
332
309
  if (process.env.NODE_ENV === "development" && debug) {
333
310
  console.log("tamagui classname props", keyInit, valInit);
334
311
  }
335
312
  mergeClassName(transforms, classNames, keyInit, valInit, isMediaOrPseudo2);
336
- return;
313
+ continue;
337
314
  }
338
315
  }
339
316
  }
340
317
  let isMedia = isMediaKey(keyInit);
341
318
  let isPseudo = keyInit in validPseudoKeys;
342
319
  let isMediaOrPseudo = isMedia || isPseudo;
343
- const isVariant = variants && keyInit in variants;
320
+ let isVariant = variants && keyInit in variants;
344
321
  const isStyleProp = isMediaOrPseudo || isVariant || keyInit in validStyleProps || keyInit in shorthands;
345
322
  if (isStyleProp && props.asChild === "except-style") {
346
- return;
323
+ continue;
347
324
  }
348
325
  const shouldPassProp = !isStyleProp;
349
- const isHOCShouldPassThrough = staticConfig.isHOC && (isMediaOrPseudo || ((_b2 = (_a2 = staticConfig.parentStaticConfig) == null ? void 0 : _a2.variants) == null ? void 0 : _b2[keyInit]));
326
+ const isHOCShouldPassThrough = Boolean(
327
+ staticConfig.isHOC && (isMediaOrPseudo || ((_b = (_a = staticConfig.parentStaticConfig) == null ? void 0 : _a.variants) == null ? void 0 : _b[keyInit]) || keyInit in skipProps)
328
+ );
350
329
  const shouldPassThrough = shouldPassProp || isHOCShouldPassThrough;
330
+ if (process.env.NODE_ENV === "development" && debug === "verbose") {
331
+ console.groupCollapsed(
332
+ ` \u{1F539} prop ${keyInit} ${shouldPassThrough ? "pass through" : ""}`
333
+ );
334
+ console.log({ valInit, variants, variant: variants == null ? void 0 : variants[keyInit], isVariant, shouldPassProp, isHOCShouldPassThrough });
335
+ console.groupEnd();
336
+ }
351
337
  if (shouldPassThrough) {
352
- if (process.env.NODE_ENV === "development" && debug === "verbose") {
353
- console.groupCollapsed(` \u{1F539} pass through ${keyInit}`);
354
- console.log({
355
- valInit,
356
- variants,
357
- variant: variants == null ? void 0 : variants[keyInit],
358
- isVariant,
359
- shouldPassProp,
360
- isHOCShouldPassThrough
361
- });
362
- console.groupEnd();
363
- }
364
- if (isPseudo) {
365
- const pseudoStyleObject = getSubStyle(
366
- styleState,
367
- keyInit,
368
- valInit,
369
- true,
370
- state.noClassNames
371
- );
372
- const descriptor = pseudoDescriptors[keyInit];
373
- for (const key in pseudoStyleObject) {
374
- const fullKey = `${key}${PROP_SPLIT}${descriptor.name}`;
375
- usedKeys[fullKey] = 1;
376
- }
377
- }
378
- passDownProp(keyInit, valInit, isMediaOrPseudo);
338
+ passDownProp(viewProps, keyInit, valInit, isMediaOrPseudo);
379
339
  if (!isVariant) {
380
- return;
340
+ continue;
381
341
  }
382
342
  }
343
+ if (keyInit in skipProps)
344
+ continue;
345
+ defaultFontVariable ||= `$${conf.defaultFont}`;
346
+ fontFamily ||= props[conf.inverseShorthands.fontFamily] || props.fontFamily || defaultFontVariable;
383
347
  const expanded = isMediaOrPseudo ? [[keyInit, valInit]] : propMapper(
384
348
  keyInit,
385
349
  valInit,
386
350
  theme,
387
- special ? { ...props, fontFamily: fontFamilyOverride } : props,
351
+ props,
388
352
  state,
353
+ fontFamily,
389
354
  languageContext,
390
355
  void 0,
391
356
  debug
@@ -394,17 +359,9 @@ const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, la
394
359
  fontFamily = getPropMappedFontFamily(expanded);
395
360
  }
396
361
  if (process.env.NODE_ENV === "development" && debug === "verbose") {
397
- console.groupCollapsed(" \u{1F539} styles", keyInit, valInit);
398
- console.log({
399
- expanded,
400
- state,
401
- isVariant,
402
- variant: variants == null ? void 0 : variants[keyInit],
403
- shouldPassProp,
404
- isHOCShouldPassThrough,
405
- theme
406
- });
362
+ console.groupCollapsed(" \u{1F539} expanded", keyInit, valInit);
407
363
  if (!isServer && isDevTools) {
364
+ console.log({ expanded, state: { ...state }, isVariant, variant: variants == null ? void 0 : variants[keyInit], shouldPassProp, isHOCShouldPassThrough, theme, usedKeys: { ...usedKeys } });
408
365
  console.log("expanded", expanded, "\nusedKeys", { ...usedKeys }, "\ncurrent", {
409
366
  ...style
410
367
  });
@@ -412,30 +369,27 @@ const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, la
412
369
  console.groupEnd();
413
370
  }
414
371
  if (!expanded)
415
- return;
372
+ continue;
416
373
  for (const [key, val] of expanded) {
417
- if (val === void 0)
374
+ if (val == null)
418
375
  continue;
419
- if (key in stylePropsFont && !special && key !== "fontFamily") {
420
- specialProps.push([key, val]);
376
+ if (key in usedKeys)
421
377
  continue;
422
- }
423
378
  isMedia = isMediaKey(key);
424
379
  isPseudo = key in validPseudoKeys;
425
380
  isMediaOrPseudo = isMedia || isPseudo;
426
- if (!isMediaOrPseudo && key in usedKeys) {
427
- if (process.env.NODE_ENV === "development" && debug === "verbose") {
428
- console.log(`Used media/pseudo ${key}`);
429
- }
430
- continue;
431
- }
432
381
  if ((inlineProps == null ? void 0 : inlineProps.has(key)) || (inlineWhenUnflattened == null ? void 0 : inlineWhenUnflattened.has(key))) {
433
- usedKeys[key] = 1;
434
382
  viewProps[key] = props[key] ?? val;
435
383
  }
436
- const isHOCShouldPassThrough2 = staticConfig.isHOC && (isMediaOrPseudo || ((_d = (_c2 = staticConfig.parentStaticConfig) == null ? void 0 : _c2.variants) == null ? void 0 : _d[keyInit]));
384
+ const isHOCShouldPassThrough2 = staticConfig.isHOC && (isMediaOrPseudo || ((_d = (_c = staticConfig.parentStaticConfig) == null ? void 0 : _c.variants) == null ? void 0 : _d[keyInit]));
437
385
  if (isHOCShouldPassThrough2) {
438
- passDownProp(key, val);
386
+ isVariant = variants && key in variants;
387
+ passDownProp(viewProps, key, val, isMediaOrPseudo);
388
+ if (process.env.NODE_ENV === "development" && debug === "verbose") {
389
+ console.groupCollapsed(` - passing down prop ${key}`);
390
+ console.log({ val, after: { ...viewProps[key] } });
391
+ console.groupEnd();
392
+ }
439
393
  if (!isVariant) {
440
394
  continue;
441
395
  }
@@ -447,6 +401,7 @@ const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, la
447
401
  styleState,
448
402
  key,
449
403
  val,
404
+ fontFamily,
450
405
  true,
451
406
  state.noClassNames
452
407
  );
@@ -454,68 +409,72 @@ const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, la
454
409
  const isEnter = descriptor.name === "enter";
455
410
  const isExit = descriptor.name === "exit";
456
411
  if (!descriptor || isExit && !state.isExiting) {
412
+ if (process.env.NODE_ENV === "development" && debug === "verbose") {
413
+ console.log("skip exit");
414
+ }
457
415
  continue;
458
416
  }
459
417
  if (!shouldDoClasses || IS_STATIC) {
460
418
  pseudos ||= {};
461
419
  pseudos[key] ||= {};
462
- Object.assign(pseudos[key], pseudoStyleObject);
463
420
  }
464
421
  if (shouldDoClasses && !isEnter && !isExit) {
465
422
  const pseudoStyles = generateAtomicStyles(pseudoStyleObject, descriptor);
423
+ if (process.env.NODE_ENV === "development" && debug === "verbose") {
424
+ console.groupCollapsed("pseudo (classes)", key);
425
+ console.log({ pseudoStyleObject, pseudoStyles });
426
+ console.groupEnd();
427
+ }
466
428
  for (const psuedoStyle of pseudoStyles) {
467
429
  const fullKey = `${psuedoStyle.property}${PROP_SPLIT}${descriptor.name}`;
468
- if (!(fullKey in usedKeys)) {
469
- usedKeys[fullKey] = 1;
470
- addStyleToInsertRules(rulesToInsert, psuedoStyle);
471
- mergeClassName(
472
- transforms,
473
- classNames,
474
- fullKey,
475
- psuedoStyle.identifier,
476
- isMediaOrPseudo
477
- );
478
- }
430
+ addStyleToInsertRules(rulesToInsert, psuedoStyle);
431
+ mergeClassName(
432
+ transforms,
433
+ classNames,
434
+ fullKey,
435
+ psuedoStyle.identifier,
436
+ isMediaOrPseudo
437
+ );
479
438
  }
480
439
  } else {
481
- if (key in usedKeys) {
482
- continue;
483
- }
484
- let isDisabled = !state[descriptor.stateKey || descriptor.name];
440
+ const descriptorKey = descriptor.stateKey || descriptor.name;
441
+ const pseudoState = state[descriptorKey];
442
+ let isDisabled = !pseudoState;
485
443
  if (isWeb && !isClient && isEnter) {
486
444
  isDisabled = false;
487
445
  }
446
+ if (process.env.NODE_ENV === "development" && debug === "verbose") {
447
+ console.groupCollapsed("pseudo", key, !isDisabled);
448
+ console.log(pseudoStyleObject, { isDisabled, descriptorKey, descriptor, pseudoState, state: { ...state } });
449
+ console.groupEnd();
450
+ }
451
+ const importance = descriptor.priority;
488
452
  if (!isDisabled) {
489
- if (valInit === staticConfig.defaultProps[keyInit]) {
490
- } else {
491
- usedKeys[key] ||= 1;
492
- if (process.env.NODE_ENV === "development" && debug === "verbose") {
493
- console.log(`Setting used ${key}`);
494
- }
453
+ for (const key2 in val) {
454
+ const k = shorthands[key2] || key2;
455
+ usedKeys[k] = Math.max(importance, usedKeys[k] || 0);
495
456
  }
496
457
  }
497
- psuedosUsed ||= {};
498
- const importance = descriptor.priority;
499
458
  for (const pkey in pseudoStyleObject) {
500
459
  const val2 = pseudoStyleObject[pkey];
501
460
  if (isDisabled) {
502
- if (!(pkey in usedKeys) && pkey in animatableDefaults) {
461
+ if (pkey in animatableDefaults && !(pkey in usedKeys)) {
503
462
  const defaultVal = animatableDefaults[pkey];
504
- mergeStyle(styleState, flatTransforms, pkey, defaultVal, true);
463
+ mergeStyle(styleState, flatTransforms, pkey, defaultVal);
464
+ }
465
+ } else {
466
+ const curImportance = usedKeys[importance] || 0;
467
+ const shouldMerge = importance >= curImportance;
468
+ if (shouldMerge) {
469
+ pseudos ||= {};
470
+ pseudos[key] ||= {};
471
+ pseudos[key][pkey] = val2;
472
+ mergeStyle(styleState, flatTransforms, pkey, val2);
473
+ usedKeys[pkey] ||= 1;
474
+ }
475
+ if (process.env.NODE_ENV === "development" && debug === "verbose") {
476
+ console.log(" subKey", pkey, shouldMerge, { importance, curImportance, pkey, val: val2 });
505
477
  }
506
- continue;
507
- }
508
- const curImportance = psuedosUsed[importance] || 0;
509
- const shouldMerge = importance >= curImportance;
510
- if (shouldMerge) {
511
- psuedosUsed[pkey] = importance;
512
- pseudos ||= {};
513
- pseudos[key] ||= {};
514
- pseudos[key][pkey] = val2;
515
- mergeStyle(styleState, flatTransforms, pkey, val2);
516
- }
517
- if (process.env.NODE_ENV === "development" && debug === "verbose") {
518
- console.log(" merge pseudo?", keyInit, shouldMerge, { importance, curImportance, pkey, val: val2 });
519
478
  }
520
479
  }
521
480
  }
@@ -529,6 +488,7 @@ const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, la
529
488
  styleState,
530
489
  key,
531
490
  val,
491
+ fontFamily,
532
492
  // TODO try true like pseudo
533
493
  false
534
494
  );
@@ -567,11 +527,8 @@ const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, la
567
527
  for (const style2 of mediaStyles) {
568
528
  const out = createMediaStyle(style2, mediaKeyShort, mediaQueryConfig);
569
529
  const fullKey = `${style2.property}${PROP_SPLIT}${mediaKeyShort}`;
570
- if (!usedKeys[fullKey]) {
571
- usedKeys[fullKey] = 1;
572
- addStyleToInsertRules(rulesToInsert, out);
573
- mergeClassName(transforms, classNames, fullKey, out.identifier, true);
574
- }
530
+ addStyleToInsertRules(rulesToInsert, out);
531
+ mergeClassName(transforms, classNames, fullKey, out.identifier, true);
575
532
  }
576
533
  } else if (mediaState[mediaKeyShort]) {
577
534
  for (const subKey in mediaStyle) {
@@ -602,7 +559,6 @@ const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, la
602
559
  }
603
560
  if (process.env.TAMAGUI_TARGET === "native") {
604
561
  if (key === "pointerEvents") {
605
- usedKeys[key] = 1;
606
562
  viewProps[key] = val;
607
563
  continue;
608
564
  }
@@ -613,38 +569,25 @@ const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, la
613
569
  fontFamily = fam;
614
570
  }
615
571
  }
616
- if (key in validStyleProps) {
617
- mergeStyle(styleState, flatTransforms, key, val);
618
- continue;
619
- } else if (process.env.TAMAGUI_TARGET === "native" && isAndroid && key === "elevation") {
572
+ if (key in validStyleProps || process.env.TAMAGUI_TARGET === "native" && isAndroid && key === "elevation") {
620
573
  mergeStyle(styleState, flatTransforms, key, val);
621
574
  continue;
622
575
  }
623
- if (!isVariant && !(key in skipProps)) {
576
+ if (!isVariant) {
624
577
  viewProps[key] = val;
625
- usedKeys[key] = 1;
626
578
  }
627
579
  }
628
580
  }
629
- for (let i = len - 1; i >= 0; i--) {
630
- const keyInit = propKeys[i];
631
- const valInit = props[keyInit];
632
- processProp(keyInit, valInit);
633
- }
634
581
  fontFamily ||= conf.defaultFont;
635
- for (let i = 0; i < specialProps.length; i++) {
636
- const [key, value] = specialProps[i];
637
- processProp(key, value, true, fontFamily);
638
- }
639
582
  fixStyles(style);
640
583
  if (isWeb) {
641
584
  styleToCSS(style);
642
585
  }
643
586
  if (process.env.TAMAGUI_TARGET === "native") {
644
587
  if ("fontFamily" in style && style.fontFamily) {
645
- const faceInfo = (_a = getFont(style.fontFamily)) == null ? void 0 : _a.face;
588
+ const faceInfo = (_e = getFont(style.fontFamily)) == null ? void 0 : _e.face;
646
589
  if (faceInfo) {
647
- const overrideFace = (_c = (_b = faceInfo[style.fontWeight]) == null ? void 0 : _b[style.fontStyle || "normal"]) == null ? void 0 : _c.val;
590
+ const overrideFace = (_g = (_f = faceInfo[style.fontWeight]) == null ? void 0 : _f[style.fontStyle || "normal"]) == null ? void 0 : _g.val;
648
591
  if (overrideFace) {
649
592
  style.fontFamily = overrideFace;
650
593
  fontFamily = overrideFace;
@@ -664,7 +607,7 @@ const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, la
664
607
  }
665
608
  }
666
609
  if (flatTransforms) {
667
- mergeTransforms(style, flatTransforms, true);
610
+ mergeFlatTransforms(style, flatTransforms, true);
668
611
  }
669
612
  if (parentSplitStyles) {
670
613
  if (process.env.TAMAGUI_TARGET === "web") {
@@ -693,7 +636,7 @@ const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, la
693
636
  const atomic = getStylesAtomic(style);
694
637
  for (const atomicStyle of atomic) {
695
638
  const key = atomicStyle.property;
696
- if (props.animateOnly && props.animateOnly.includes(key)) {
639
+ if (state.isAnimated && props.animateOnly && props.animateOnly.includes(key)) {
697
640
  retainedStyles[key] = style[key];
698
641
  } else {
699
642
  addStyleToInsertRules(rulesToInsert, atomicStyle);
@@ -757,18 +700,11 @@ const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, la
757
700
  }
758
701
  }
759
702
  }
760
- const nextViewProps = {};
761
- const ks = Object.keys(viewProps);
762
- const l = ks.length;
763
- for (let i = l - 1; i >= 0; i--) {
764
- const key = ks[i];
765
- nextViewProps[key] = viewProps[key];
766
- }
767
703
  const result = {
768
704
  space,
769
705
  hasMedia,
770
706
  fontFamily,
771
- viewProps: nextViewProps,
707
+ viewProps,
772
708
  // @ts-expect-error
773
709
  style,
774
710
  pseudos,
@@ -780,8 +716,8 @@ const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, la
780
716
  }
781
717
  if (process.env.NODE_ENV === "development" && debug === "verbose") {
782
718
  if (isDevTools) {
783
- console.groupCollapsed(" \u{1F539} =>");
784
- const logs = { ...result, state, etc: { transforms, viewProps, rulesToInsert, parentSplitStyles, flatTransforms } };
719
+ console.groupCollapsed(" \u{1F539} ===>");
720
+ const logs = { ...result, state, transforms, viewProps, viewPropsOrder: Object.keys(viewProps), rulesToInsert, parentSplitStyles, flatTransforms };
785
721
  for (const key in logs) {
786
722
  console.log(key, logs[key]);
787
723
  }
@@ -821,12 +757,10 @@ function getSubStyleProps(defaultProps, baseProps, specificProps) {
821
757
  ...specificProps
822
758
  };
823
759
  }
824
- function mergeStyle({ usedKeys, classNames, viewProps, style }, flatTransforms, key, val, dontSetUsed = false) {
825
- if (!dontSetUsed) {
826
- usedKeys[key] ||= 1;
827
- }
828
- if (val && val[0] === "_") {
760
+ function mergeStyle({ classNames, viewProps, style, usedKeys }, flatTransforms, key, val) {
761
+ if ((val == null ? void 0 : val[0]) === "_") {
829
762
  classNames[key] = val;
763
+ usedKeys[key] ||= 1;
830
764
  } else if (key in stylePropsTransform) {
831
765
  flatTransforms ||= {};
832
766
  flatTransforms[key] = val;
@@ -839,7 +773,7 @@ function mergeStyle({ usedKeys, classNames, viewProps, style }, flatTransforms,
839
773
  }
840
774
  }
841
775
  }
842
- const getSubStyle = (styleState, subKey, styleIn, avoidDefaultProps, avoidMergeTransform) => {
776
+ const getSubStyle = (styleState, subKey, styleIn, fontFamily, avoidDefaultProps, avoidMergeTransform) => {
843
777
  const { staticConfig, theme, props, state, conf: conf2, languageContext } = styleState;
844
778
  const styleOut = {};
845
779
  for (let key in styleIn) {
@@ -851,16 +785,13 @@ const getSubStyle = (styleState, subKey, styleIn, avoidDefaultProps, avoidMergeT
851
785
  theme,
852
786
  getSubStyleProps(staticConfig.defaultProps, props, props[subKey]),
853
787
  state,
788
+ fontFamily,
854
789
  languageContext,
855
790
  avoidDefaultProps
856
791
  );
857
- if (!staticConfig.isHOC) {
858
- if (key in skipProps) {
859
- continue;
860
- }
861
- }
862
- if (!expanded)
792
+ if (!expanded || !staticConfig.isHOC && key in skipProps) {
863
793
  continue;
794
+ }
864
795
  for (const [skey, sval] of expanded) {
865
796
  if (!avoidMergeTransform && skey in stylePropsTransform) {
866
797
  mergeTransform(styleOut, skey, sval);
@@ -900,7 +831,9 @@ const animatableDefaults = {
900
831
  scale: 1,
901
832
  rotate: "0deg",
902
833
  rotateY: "0deg",
903
- rotateX: "0deg"
834
+ rotateX: "0deg",
835
+ x: 0,
836
+ y: 0
904
837
  };
905
838
  const lowercaseHyphenate = (match) => `-${match.toLowerCase()}`;
906
839
  const hyphenate = (str) => str.replace(/[A-Z]/g, lowercaseHyphenate);
@@ -910,8 +843,8 @@ const mergeTransform = (obj, key, val, backwards = false) => {
910
843
  [mapTransformKeys[key] || key]: val
911
844
  });
912
845
  };
913
- const mergeTransforms = (obj, flatTransforms, backwards = false) => {
914
- Object.entries(flatTransforms).forEach(([key, val]) => {
846
+ const mergeFlatTransforms = (obj, flatTransforms, backwards = false) => {
847
+ Object.entries(flatTransforms).sort(([a], [b]) => a.localeCompare(b)).forEach(([key, val]) => {
915
848
  mergeTransform(obj, key, val, backwards);
916
849
  });
917
850
  };
@@ -946,6 +879,10 @@ if (process.env.TAMAGUI_TARGET === "native") {
946
879
  outlineWidth: true,
947
880
  outlineColor: true
948
881
  });
882
+ } else {
883
+ Object.assign(skipProps, {
884
+ elevationAndroid: true
885
+ });
949
886
  }
950
887
  const accessibilityRoleToWebRole = {
951
888
  adjustable: "slider",
@@ -955,6 +892,18 @@ const accessibilityRoleToWebRole = {
955
892
  none: "presentation",
956
893
  summary: "region"
957
894
  };
895
+ function passDownProp(viewProps, key, val, shouldMergeObject = false) {
896
+ if (shouldMergeObject) {
897
+ const next = {
898
+ ...viewProps[key],
899
+ ...val
900
+ };
901
+ delete viewProps[key];
902
+ viewProps[key] = next;
903
+ } else {
904
+ viewProps[key] = val;
905
+ }
906
+ }
958
907
  export {
959
908
  PROP_SPLIT,
960
909
  getSplitStyles,