@tamagui/web 1.36.6 → 1.37.0

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 (58) 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/getSplitStyles.js +169 -223
  12. package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
  13. package/dist/cjs/helpers/getStylesAtomic.js +1 -1
  14. package/dist/cjs/helpers/getStylesAtomic.js.map +1 -1
  15. package/dist/cjs/helpers/getThemeCSSRules.js +1 -1
  16. package/dist/cjs/helpers/getThemeCSSRules.js.map +1 -1
  17. package/dist/cjs/hooks/useMedia.js +3 -2
  18. package/dist/cjs/hooks/useMedia.js.map +1 -1
  19. package/dist/esm/constants/accessibilityDirectMap.native.js +2 -0
  20. package/dist/esm/constants/accessibilityDirectMap.native.js.map +1 -1
  21. package/dist/esm/createComponent.js +29 -25
  22. package/dist/esm/createComponent.js.map +1 -1
  23. package/dist/esm/createTamagui.js +8 -9
  24. package/dist/esm/createTamagui.js.map +1 -1
  25. package/dist/esm/helpers/ThemeManager.js +2 -2
  26. package/dist/esm/helpers/ThemeManager.js.map +1 -1
  27. package/dist/esm/helpers/createPropMapper.js +7 -6
  28. package/dist/esm/helpers/createPropMapper.js.map +1 -1
  29. package/dist/esm/helpers/getSplitStyles.js +169 -224
  30. package/dist/esm/helpers/getSplitStyles.js.map +2 -2
  31. package/dist/esm/helpers/getStylesAtomic.js +1 -1
  32. package/dist/esm/helpers/getStylesAtomic.js.map +1 -1
  33. package/dist/esm/helpers/getThemeCSSRules.js +1 -1
  34. package/dist/esm/helpers/getThemeCSSRules.js.map +1 -1
  35. package/dist/esm/hooks/useMedia.js +3 -2
  36. package/dist/esm/hooks/useMedia.js.map +1 -1
  37. package/package.json +9 -9
  38. package/src/constants/accessibilityDirectMap.native.tsx +3 -0
  39. package/src/createComponent.tsx +36 -25
  40. package/src/createTamagui.ts +16 -9
  41. package/src/helpers/ThemeManager.tsx +2 -2
  42. package/src/helpers/createPropMapper.ts +7 -12
  43. package/src/helpers/getSplitStyles.tsx +248 -272
  44. package/src/helpers/getStylesAtomic.ts +1 -1
  45. package/src/helpers/getThemeCSSRules.ts +4 -1
  46. package/src/hooks/useMedia.tsx +6 -3
  47. package/src/types.tsx +4 -2
  48. package/types/constants/accessibilityDirectMap.native.d.ts +1 -0
  49. package/types/constants/accessibilityDirectMap.native.d.ts.map +1 -1
  50. package/types/createComponent.d.ts.map +1 -1
  51. package/types/createTamagui.d.ts.map +1 -1
  52. package/types/helpers/createPropMapper.d.ts.map +1 -1
  53. package/types/helpers/getSplitStyles.d.ts +1 -1
  54. package/types/helpers/getSplitStyles.d.ts.map +1 -1
  55. package/types/helpers/getThemeCSSRules.d.ts.map +1 -1
  56. package/types/hooks/useMedia.d.ts.map +1 -1
  57. package/types/types.d.ts +4 -3
  58. package/types/types.d.ts.map +1 -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,58 @@ 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 (keyInit in skipProps)
125
+ continue;
126
+ if (process.env.TAMAGUI_TARGET === "web") {
127
+ if (typeof valInit === "string" && valInit[0] === "_") {
128
+ if (keyInit in validStyleProps || keyInit.includes("-")) {
129
+ if (process.env.NODE_ENV === "development" && debug) {
130
+ console.log(`Adding compiled style ${keyInit}: ${valInit}`);
131
+ }
132
+ if (shouldDoClasses) {
133
+ classNames[keyInit] = valInit;
134
+ delete style[keyInit];
135
+ } else {
136
+ style[keyInit] = reverseMapClassNameToValue(keyInit, valInit);
137
+ delete className[keyInit];
138
+ }
139
+ continue;
140
+ }
141
+ }
137
142
  }
138
143
  if (process.env.TAMAGUI_TARGET === "native") {
139
144
  if (!isAndroid) {
140
145
  if (keyInit === "elevationAndroid")
141
- return;
146
+ continue;
142
147
  }
143
148
  if (keyInit === "userSelect") {
144
149
  keyInit = "selectable";
145
150
  valInit = valInit === "none" ? false : true;
146
- } else if (keyInit.startsWith("aria-") || keyInit === "role") {
151
+ } else if (keyInit === "role") {
152
+ if (valInit === "list") {
153
+ viewProps[keyInit] = valInit;
154
+ } else if (accessibilityWebRoleToNativeRole[valInit]) {
155
+ viewProps["accessibilityRole"] = accessibilityWebRoleToNativeRole[valInit];
156
+ }
157
+ continue;
158
+ } else if (keyInit.startsWith("aria-")) {
147
159
  if (webToNativeAccessibilityDirectMap[keyInit]) {
148
160
  const nativeA11yProp = webToNativeAccessibilityDirectMap[keyInit];
149
161
  if (keyInit === "aria-hidden") {
150
162
  viewProps["aria-hidden"] = valInit;
151
163
  }
152
164
  viewProps[nativeA11yProp] = valInit;
153
- usedKeys[keyInit] = 1;
154
- return;
165
+ continue;
155
166
  } else if (nativeAccessibilityValue[keyInit]) {
156
167
  let field = nativeAccessibilityValue[keyInit];
157
168
  if (viewProps["accessibilityValue"]) {
@@ -161,7 +172,6 @@ const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, la
161
172
  [field]: valInit
162
173
  };
163
174
  }
164
- usedKeys[keyInit] = 1;
165
175
  } else if (nativeAccessibilityState[keyInit]) {
166
176
  let field = nativeAccessibilityState[keyInit];
167
177
  if (viewProps["accessibilityState"]) {
@@ -171,56 +181,30 @@ const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, la
171
181
  [field]: valInit
172
182
  };
173
183
  }
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
184
  }
183
- return;
185
+ continue;
184
186
  } else if (keyInit.startsWith("data-")) {
185
- return;
187
+ continue;
186
188
  }
187
189
  }
188
- if (process.env.TAMAGUI_TARGET === "web") {
189
- if (keyInit === "elevationAndroid")
190
- return;
191
- }
192
190
  if (!staticConfig.isHOC) {
193
191
  if (keyInit in skipProps) {
194
192
  if (process.env.NODE_ENV === "development" && debug && keyInit === "debug") {
195
193
  } 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);
194
+ continue;
209
195
  }
210
- usedKeys[keyInit] = 1;
211
- return;
212
196
  }
213
197
  }
214
198
  if (keyInit === "dataSet") {
215
- for (const key in valInit) {
216
- viewProps[`data-${hyphenate(key)}`] = valInit[key];
199
+ for (const keyInit2 in valInit) {
200
+ viewProps[`data-${hyphenate(keyInit2)}`] = valInit[keyInit2];
217
201
  }
218
- return;
202
+ continue;
219
203
  }
220
204
  const isMainStyle = keyInit === "style";
221
205
  if (isMainStyle || keyInit.startsWith("_style")) {
222
206
  if (!valInit)
223
- return;
207
+ continue;
224
208
  const styles = [].concat(valInit).flat();
225
209
  const styleLen = styles.length;
226
210
  for (let j = styleLen; j >= 0; j--) {
@@ -235,44 +219,41 @@ const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, la
235
219
  style[key] = cur[key];
236
220
  }
237
221
  }
238
- return;
222
+ continue;
239
223
  }
240
224
  if (process.env.TAMAGUI_TARGET === "web") {
241
225
  if (keyInit === "disabled" && valInit === true) {
242
- usedKeys[keyInit] = 1;
243
226
  viewProps["aria-disabled"] = true;
244
227
  if (elementType === "button" || elementType === "form" || elementType === "input" || elementType === "select" || elementType === "textarea") {
245
228
  viewProps.disabled = true;
246
229
  }
247
230
  if (!(variants == null ? void 0 : variants.disabled)) {
248
- return;
231
+ continue;
249
232
  }
250
233
  }
251
234
  if (keyInit === "testID") {
252
- usedKeys[keyInit] = 1;
253
235
  viewProps[isReactNative ? "testId" : "data-testid"] = valInit;
254
- return;
236
+ continue;
255
237
  }
256
238
  if (keyInit === "id" || keyInit === "nativeID") {
257
- usedKeys[keyInit] = 1;
258
239
  if (isReactNative) {
259
240
  viewProps.nativeID = valInit;
260
241
  } else {
261
242
  viewProps.id = valInit;
262
243
  }
263
- return;
244
+ continue;
264
245
  }
265
246
  let didUseKeyInit = false;
266
247
  if (isReactNative) {
267
- if (accessibilityDirectMap[keyInit] || keyInit.startsWith("accessibility")) {
248
+ if (keyInit in accessibilityDirectMap || keyInit.startsWith("accessibility")) {
268
249
  viewProps[keyInit] = valInit;
269
- usedKeys[keyInit] = 1;
270
- return;
250
+ continue;
271
251
  }
272
252
  } else {
273
253
  didUseKeyInit = true;
274
254
  if (keyInit in accessibilityDirectMap) {
275
255
  viewProps[accessibilityDirectMap[keyInit]] = valInit;
256
+ continue;
276
257
  } else {
277
258
  switch (keyInit) {
278
259
  case "accessibilityRole": {
@@ -281,38 +262,38 @@ const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, la
281
262
  } else {
282
263
  viewProps.role = accessibilityRoleToWebRole[valInit] || valInit;
283
264
  }
284
- return;
265
+ continue;
285
266
  }
286
267
  case "accessibilityLabelledBy":
287
268
  case "accessibilityFlowTo":
288
269
  case "accessibilityControls":
289
270
  case "accessibilityDescribedBy": {
290
271
  viewProps[`aria-${keyInit.replace("accessibility", "").toLowerCase()}`] = processIDRefList(valInit);
291
- return;
272
+ continue;
292
273
  }
293
274
  case "accessibilityKeyShortcuts": {
294
275
  if (Array.isArray(valInit)) {
295
276
  viewProps["aria-keyshortcuts"] = valInit.join(" ");
296
277
  }
297
- return;
278
+ continue;
298
279
  }
299
280
  case "accessibilityLiveRegion": {
300
281
  viewProps["aria-live"] = valInit === "none" ? "off" : valInit;
301
- return;
282
+ continue;
302
283
  }
303
284
  case "accessibilityReadOnly": {
304
285
  viewProps["aria-readonly"] = valInit;
305
286
  if (elementType === "input" || elementType === "select" || elementType === "textarea") {
306
287
  viewProps.readOnly = true;
307
288
  }
308
- return;
289
+ continue;
309
290
  }
310
291
  case "accessibilityRequired": {
311
292
  viewProps["aria-required"] = valInit;
312
293
  if (elementType === "input" || elementType === "select" || elementType === "textarea") {
313
294
  viewProps.required = valInit;
314
295
  }
315
- return;
296
+ continue;
316
297
  }
317
298
  default: {
318
299
  didUseKeyInit = false;
@@ -321,71 +302,53 @@ const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, la
321
302
  }
322
303
  }
323
304
  if (didUseKeyInit) {
324
- usedKeys[keyInit] = 1;
325
- return;
305
+ continue;
326
306
  }
327
307
  if (valInit && valInit[0] === "_") {
328
308
  const isValidClassName = keyInit in validStyles;
329
309
  const isMediaOrPseudo2 = !isValidClassName && keyInit.includes(PROP_SPLIT) && validStyles[keyInit.split(PROP_SPLIT)[0]];
330
310
  if (isValidClassName || isMediaOrPseudo2) {
331
- usedKeys[keyInit] = 1;
332
311
  if (process.env.NODE_ENV === "development" && debug) {
333
312
  console.log("tamagui classname props", keyInit, valInit);
334
313
  }
335
314
  mergeClassName(transforms, classNames, keyInit, valInit, isMediaOrPseudo2);
336
- return;
315
+ continue;
337
316
  }
338
317
  }
339
318
  }
340
319
  let isMedia = isMediaKey(keyInit);
341
320
  let isPseudo = keyInit in validPseudoKeys;
342
321
  let isMediaOrPseudo = isMedia || isPseudo;
343
- const isVariant = variants && keyInit in variants;
322
+ let isVariant = variants && keyInit in variants;
344
323
  const isStyleProp = isMediaOrPseudo || isVariant || keyInit in validStyleProps || keyInit in shorthands;
345
324
  if (isStyleProp && props.asChild === "except-style") {
346
- return;
325
+ continue;
347
326
  }
348
- const shouldPassProp = !isStyleProp;
349
- const isHOCShouldPassThrough = staticConfig.isHOC && (isMediaOrPseudo || ((_b2 = (_a2 = staticConfig.parentStaticConfig) == null ? void 0 : _a2.variants) == null ? void 0 : _b2[keyInit]));
327
+ const shouldPassProp = !isStyleProp && !(keyInit in handledProps);
328
+ const isHOCShouldPassThrough = Boolean(
329
+ staticConfig.isHOC && (isMediaOrPseudo || ((_b = (_a = staticConfig.parentStaticConfig) == null ? void 0 : _a.variants) == null ? void 0 : _b[keyInit]))
330
+ );
350
331
  const shouldPassThrough = shouldPassProp || isHOCShouldPassThrough;
351
332
  if (shouldPassThrough) {
352
333
  if (process.env.NODE_ENV === "development" && debug === "verbose") {
353
334
  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
- });
335
+ console.log({ valInit, variants, variant: variants == null ? void 0 : variants[keyInit], isVariant, shouldPassProp, isHOCShouldPassThrough });
362
336
  console.groupEnd();
363
337
  }
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
+ defaultFontVariable ||= `$${conf.defaultFont}`;
344
+ fontFamily ||= props[conf.inverseShorthands.fontFamily] || props.fontFamily || defaultFontVariable;
383
345
  const expanded = isMediaOrPseudo ? [[keyInit, valInit]] : propMapper(
384
346
  keyInit,
385
347
  valInit,
386
348
  theme,
387
- special ? { ...props, fontFamily: fontFamilyOverride } : props,
349
+ props,
388
350
  state,
351
+ fontFamily,
389
352
  languageContext,
390
353
  void 0,
391
354
  debug
@@ -393,17 +356,9 @@ const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, la
393
356
  if (!fontFamily) {
394
357
  fontFamily = getPropMappedFontFamily(expanded);
395
358
  }
396
- if (process.env.NODE_ENV === "development" && debug === "verbose") {
359
+ if (process.env.NODE_ENV === "development" && debug === "verbose" && isClient) {
397
360
  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
- });
361
+ console.log({ expanded, state: { ...state }, isVariant, variant: variants == null ? void 0 : variants[keyInit], shouldPassProp, isHOCShouldPassThrough, theme, usedKeys: { ...usedKeys } });
407
362
  if (!isServer && isDevTools) {
408
363
  console.log("expanded", expanded, "\nusedKeys", { ...usedKeys }, "\ncurrent", {
409
364
  ...style
@@ -412,30 +367,27 @@ const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, la
412
367
  console.groupEnd();
413
368
  }
414
369
  if (!expanded)
415
- return;
370
+ continue;
416
371
  for (const [key, val] of expanded) {
417
- if (val === void 0)
372
+ if (val == null)
418
373
  continue;
419
- if (key in stylePropsFont && !special && key !== "fontFamily") {
420
- specialProps.push([key, val]);
374
+ if (key in usedKeys)
421
375
  continue;
422
- }
423
376
  isMedia = isMediaKey(key);
424
377
  isPseudo = key in validPseudoKeys;
425
378
  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
379
  if ((inlineProps == null ? void 0 : inlineProps.has(key)) || (inlineWhenUnflattened == null ? void 0 : inlineWhenUnflattened.has(key))) {
433
- usedKeys[key] = 1;
434
380
  viewProps[key] = props[key] ?? val;
435
381
  }
436
- const isHOCShouldPassThrough2 = staticConfig.isHOC && (isMediaOrPseudo || ((_d = (_c2 = staticConfig.parentStaticConfig) == null ? void 0 : _c2.variants) == null ? void 0 : _d[keyInit]));
382
+ const isHOCShouldPassThrough2 = staticConfig.isHOC && (isMediaOrPseudo || ((_d = (_c = staticConfig.parentStaticConfig) == null ? void 0 : _c.variants) == null ? void 0 : _d[keyInit]));
437
383
  if (isHOCShouldPassThrough2) {
438
- passDownProp(key, val);
384
+ isVariant = variants && key in variants;
385
+ passDownProp(viewProps, key, val, isMediaOrPseudo);
386
+ if (process.env.NODE_ENV === "development" && debug === "verbose") {
387
+ console.groupCollapsed(` - passing down prop ${key}`);
388
+ console.log({ val, after: { ...viewProps[key] } });
389
+ console.groupEnd();
390
+ }
439
391
  if (!isVariant) {
440
392
  continue;
441
393
  }
@@ -447,6 +399,7 @@ const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, la
447
399
  styleState,
448
400
  key,
449
401
  val,
402
+ fontFamily,
450
403
  true,
451
404
  state.noClassNames
452
405
  );
@@ -454,68 +407,67 @@ const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, la
454
407
  const isEnter = descriptor.name === "enter";
455
408
  const isExit = descriptor.name === "exit";
456
409
  if (!descriptor || isExit && !state.isExiting) {
410
+ if (process.env.NODE_ENV === "development" && debug === "verbose") {
411
+ console.log("skip exit");
412
+ }
457
413
  continue;
458
414
  }
459
415
  if (!shouldDoClasses || IS_STATIC) {
460
416
  pseudos ||= {};
461
417
  pseudos[key] ||= {};
462
- Object.assign(pseudos[key], pseudoStyleObject);
463
418
  }
464
419
  if (shouldDoClasses && !isEnter && !isExit) {
465
420
  const pseudoStyles = generateAtomicStyles(pseudoStyleObject, descriptor);
466
421
  for (const psuedoStyle of pseudoStyles) {
467
422
  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
- }
423
+ addStyleToInsertRules(rulesToInsert, psuedoStyle);
424
+ mergeClassName(
425
+ transforms,
426
+ classNames,
427
+ fullKey,
428
+ psuedoStyle.identifier,
429
+ isMediaOrPseudo
430
+ );
479
431
  }
480
432
  } else {
481
- if (key in usedKeys) {
482
- continue;
483
- }
484
- let isDisabled = !state[descriptor.stateKey || descriptor.name];
433
+ const descriptorKey = descriptor.stateKey || descriptor.name;
434
+ const pseudoState = state[descriptorKey];
435
+ let isDisabled = !pseudoState;
485
436
  if (isWeb && !isClient && isEnter) {
486
437
  isDisabled = false;
487
438
  }
439
+ if (process.env.NODE_ENV === "development" && debug === "verbose") {
440
+ console.groupCollapsed("pseudo", keyInit, !isDisabled);
441
+ console.log(pseudoStyleObject, { isDisabled, descriptorKey, descriptor, pseudoState, state: { ...state } });
442
+ console.groupEnd();
443
+ }
444
+ const importance = descriptor.priority;
488
445
  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
- }
446
+ for (const key2 in val) {
447
+ const k = shorthands[key2] || key2;
448
+ usedKeys[k] = Math.max(importance, usedKeys[k] || 0);
495
449
  }
496
450
  }
497
- psuedosUsed ||= {};
498
- const importance = descriptor.priority;
499
451
  for (const pkey in pseudoStyleObject) {
500
452
  const val2 = pseudoStyleObject[pkey];
501
453
  if (isDisabled) {
502
- if (!(pkey in usedKeys) && pkey in animatableDefaults) {
454
+ if (pkey in animatableDefaults && !(pkey in usedKeys)) {
503
455
  const defaultVal = animatableDefaults[pkey];
504
- mergeStyle(styleState, flatTransforms, pkey, defaultVal, true);
456
+ mergeStyle(styleState, flatTransforms, pkey, defaultVal);
457
+ }
458
+ } else {
459
+ const curImportance = usedKeys[importance] || 0;
460
+ const shouldMerge = importance >= curImportance;
461
+ if (shouldMerge) {
462
+ pseudos ||= {};
463
+ pseudos[key] ||= {};
464
+ pseudos[key][pkey] = val2;
465
+ mergeStyle(styleState, flatTransforms, pkey, val2);
466
+ usedKeys[pkey] ||= 1;
467
+ }
468
+ if (process.env.NODE_ENV === "development" && debug === "verbose") {
469
+ console.log(" subKey", pkey, shouldMerge, { importance, curImportance, pkey, val: val2 });
505
470
  }
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
471
  }
520
472
  }
521
473
  }
@@ -529,6 +481,7 @@ const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, la
529
481
  styleState,
530
482
  key,
531
483
  val,
484
+ fontFamily,
532
485
  // TODO try true like pseudo
533
486
  false
534
487
  );
@@ -567,11 +520,8 @@ const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, la
567
520
  for (const style2 of mediaStyles) {
568
521
  const out = createMediaStyle(style2, mediaKeyShort, mediaQueryConfig);
569
522
  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
- }
523
+ addStyleToInsertRules(rulesToInsert, out);
524
+ mergeClassName(transforms, classNames, fullKey, out.identifier, true);
575
525
  }
576
526
  } else if (mediaState[mediaKeyShort]) {
577
527
  for (const subKey in mediaStyle) {
@@ -602,7 +552,6 @@ const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, la
602
552
  }
603
553
  if (process.env.TAMAGUI_TARGET === "native") {
604
554
  if (key === "pointerEvents") {
605
- usedKeys[key] = 1;
606
555
  viewProps[key] = val;
607
556
  continue;
608
557
  }
@@ -613,38 +562,25 @@ const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, la
613
562
  fontFamily = fam;
614
563
  }
615
564
  }
616
- if (key in validStyleProps) {
617
- mergeStyle(styleState, flatTransforms, key, val);
618
- continue;
619
- } else if (process.env.TAMAGUI_TARGET === "native" && isAndroid && key === "elevation") {
565
+ if (key in validStyleProps || process.env.TAMAGUI_TARGET === "native" && isAndroid && key === "elevation") {
620
566
  mergeStyle(styleState, flatTransforms, key, val);
621
567
  continue;
622
568
  }
623
569
  if (!isVariant && !(key in skipProps)) {
624
570
  viewProps[key] = val;
625
- usedKeys[key] = 1;
626
571
  }
627
572
  }
628
573
  }
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
574
  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
575
  fixStyles(style);
640
576
  if (isWeb) {
641
577
  styleToCSS(style);
642
578
  }
643
579
  if (process.env.TAMAGUI_TARGET === "native") {
644
580
  if ("fontFamily" in style && style.fontFamily) {
645
- const faceInfo = (_a = getFont(style.fontFamily)) == null ? void 0 : _a.face;
581
+ const faceInfo = (_e = getFont(style.fontFamily)) == null ? void 0 : _e.face;
646
582
  if (faceInfo) {
647
- const overrideFace = (_c = (_b = faceInfo[style.fontWeight]) == null ? void 0 : _b[style.fontStyle || "normal"]) == null ? void 0 : _c.val;
583
+ const overrideFace = (_g = (_f = faceInfo[style.fontWeight]) == null ? void 0 : _f[style.fontStyle || "normal"]) == null ? void 0 : _g.val;
648
584
  if (overrideFace) {
649
585
  style.fontFamily = overrideFace;
650
586
  fontFamily = overrideFace;
@@ -664,7 +600,7 @@ const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, la
664
600
  }
665
601
  }
666
602
  if (flatTransforms) {
667
- mergeTransforms(style, flatTransforms, true);
603
+ mergeFlatTransforms(style, flatTransforms, true);
668
604
  }
669
605
  if (parentSplitStyles) {
670
606
  if (process.env.TAMAGUI_TARGET === "web") {
@@ -693,7 +629,7 @@ const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, la
693
629
  const atomic = getStylesAtomic(style);
694
630
  for (const atomicStyle of atomic) {
695
631
  const key = atomicStyle.property;
696
- if (props.animateOnly && props.animateOnly.includes(key)) {
632
+ if (state.isAnimated && props.animateOnly && props.animateOnly.includes(key)) {
697
633
  retainedStyles[key] = style[key];
698
634
  } else {
699
635
  addStyleToInsertRules(rulesToInsert, atomicStyle);
@@ -757,18 +693,11 @@ const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, la
757
693
  }
758
694
  }
759
695
  }
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
696
  const result = {
768
697
  space,
769
698
  hasMedia,
770
699
  fontFamily,
771
- viewProps: nextViewProps,
700
+ viewProps,
772
701
  // @ts-expect-error
773
702
  style,
774
703
  pseudos,
@@ -780,8 +709,8 @@ const getSplitStyles = (props, staticConfig, theme, state, parentSplitStyles, la
780
709
  }
781
710
  if (process.env.NODE_ENV === "development" && debug === "verbose") {
782
711
  if (isDevTools) {
783
- console.groupCollapsed(" \u{1F539} =>");
784
- const logs = { ...result, state, etc: { transforms, viewProps, rulesToInsert, parentSplitStyles, flatTransforms } };
712
+ console.groupCollapsed(" \u{1F539} ===>");
713
+ const logs = { ...result, state, transforms, viewProps, viewPropsOrder: Object.keys(viewProps), rulesToInsert, parentSplitStyles, flatTransforms };
785
714
  for (const key in logs) {
786
715
  console.log(key, logs[key]);
787
716
  }
@@ -821,12 +750,10 @@ function getSubStyleProps(defaultProps, baseProps, specificProps) {
821
750
  ...specificProps
822
751
  };
823
752
  }
824
- function mergeStyle({ usedKeys, classNames, viewProps, style }, flatTransforms, key, val, dontSetUsed = false) {
825
- if (!dontSetUsed) {
826
- usedKeys[key] ||= 1;
827
- }
753
+ function mergeStyle({ classNames, viewProps, style, usedKeys }, flatTransforms, key, val) {
828
754
  if (val && val[0] === "_") {
829
755
  classNames[key] = val;
756
+ usedKeys[key] ||= 1;
830
757
  } else if (key in stylePropsTransform) {
831
758
  flatTransforms ||= {};
832
759
  flatTransforms[key] = val;
@@ -839,7 +766,7 @@ function mergeStyle({ usedKeys, classNames, viewProps, style }, flatTransforms,
839
766
  }
840
767
  }
841
768
  }
842
- const getSubStyle = (styleState, subKey, styleIn, avoidDefaultProps, avoidMergeTransform) => {
769
+ const getSubStyle = (styleState, subKey, styleIn, fontFamily, avoidDefaultProps, avoidMergeTransform) => {
843
770
  const { staticConfig, theme, props, state, conf: conf2, languageContext } = styleState;
844
771
  const styleOut = {};
845
772
  for (let key in styleIn) {
@@ -851,16 +778,13 @@ const getSubStyle = (styleState, subKey, styleIn, avoidDefaultProps, avoidMergeT
851
778
  theme,
852
779
  getSubStyleProps(staticConfig.defaultProps, props, props[subKey]),
853
780
  state,
781
+ fontFamily,
854
782
  languageContext,
855
783
  avoidDefaultProps
856
784
  );
857
- if (!staticConfig.isHOC) {
858
- if (key in skipProps) {
859
- continue;
860
- }
861
- }
862
- if (!expanded)
785
+ if (!expanded || !staticConfig.isHOC && key in skipProps) {
863
786
  continue;
787
+ }
864
788
  for (const [skey, sval] of expanded) {
865
789
  if (!avoidMergeTransform && skey in stylePropsTransform) {
866
790
  mergeTransform(styleOut, skey, sval);
@@ -900,7 +824,9 @@ const animatableDefaults = {
900
824
  scale: 1,
901
825
  rotate: "0deg",
902
826
  rotateY: "0deg",
903
- rotateX: "0deg"
827
+ rotateX: "0deg",
828
+ x: 0,
829
+ y: 0
904
830
  };
905
831
  const lowercaseHyphenate = (match) => `-${match.toLowerCase()}`;
906
832
  const hyphenate = (str) => str.replace(/[A-Z]/g, lowercaseHyphenate);
@@ -910,8 +836,8 @@ const mergeTransform = (obj, key, val, backwards = false) => {
910
836
  [mapTransformKeys[key] || key]: val
911
837
  });
912
838
  };
913
- const mergeTransforms = (obj, flatTransforms, backwards = false) => {
914
- Object.entries(flatTransforms).forEach(([key, val]) => {
839
+ const mergeFlatTransforms = (obj, flatTransforms, backwards = false) => {
840
+ Object.entries(flatTransforms).sort(([a], [b]) => a.localeCompare(b)).forEach(([key, val]) => {
915
841
  mergeTransform(obj, key, val, backwards);
916
842
  });
917
843
  };
@@ -927,6 +853,9 @@ const skipProps = {
927
853
  componentName: true,
928
854
  tag: true
929
855
  };
856
+ const handledProps = {
857
+ role: true
858
+ };
930
859
  if (process.env.NODE_ENV === "test") {
931
860
  skipProps["data-test-renders"] = true;
932
861
  }
@@ -946,6 +875,10 @@ if (process.env.TAMAGUI_TARGET === "native") {
946
875
  outlineWidth: true,
947
876
  outlineColor: true
948
877
  });
878
+ } else {
879
+ Object.assign(skipProps, {
880
+ elevationAndroid: true
881
+ });
949
882
  }
950
883
  const accessibilityRoleToWebRole = {
951
884
  adjustable: "slider",
@@ -955,6 +888,18 @@ const accessibilityRoleToWebRole = {
955
888
  none: "presentation",
956
889
  summary: "region"
957
890
  };
891
+ function passDownProp(viewProps, key, val, shouldMergeObject = false) {
892
+ if (shouldMergeObject) {
893
+ const next = {
894
+ ...viewProps[key],
895
+ ...val
896
+ };
897
+ delete viewProps[key];
898
+ viewProps[key] = next;
899
+ } else {
900
+ viewProps[key] = val;
901
+ }
902
+ }
958
903
  export {
959
904
  PROP_SPLIT,
960
905
  getSplitStyles,