@tamagui/web 1.88.13 → 1.89.0-1706308641099

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 (105) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/createComponent.js +1 -1
  3. package/dist/cjs/createComponent.js.map +1 -1
  4. package/dist/cjs/helpers/getSplitStyles.js +1 -1
  5. package/dist/cjs/helpers/getSplitStyles.js.map +1 -1
  6. package/dist/cjs/helpers/getSplitStyles.native.js +1 -1
  7. package/dist/cjs/helpers/getSplitStyles.native.js.map +1 -1
  8. package/dist/esm/Tamagui.mjs +43 -0
  9. package/dist/esm/config.mjs +51 -0
  10. package/dist/esm/constants/accessibilityDirectMap.mjs +50 -0
  11. package/dist/esm/constants/constants.mjs +16 -0
  12. package/dist/esm/constants/isDevTools.mjs +7 -0
  13. package/dist/esm/contexts/ComponentContext.mjs +13 -0
  14. package/dist/esm/createComponent.js +1 -1
  15. package/dist/esm/createComponent.js.map +1 -1
  16. package/dist/esm/createComponent.mjs +771 -0
  17. package/dist/esm/createFont.mjs +18 -0
  18. package/dist/esm/createShorthands.mjs +4 -0
  19. package/dist/esm/createTamagui.mjs +206 -0
  20. package/dist/esm/createTheme.mjs +2 -0
  21. package/dist/esm/createTokens.mjs +5 -0
  22. package/dist/esm/createVariable.mjs +48 -0
  23. package/dist/esm/createVariables.mjs +35 -0
  24. package/dist/esm/defaultComponentState.mjs +16 -0
  25. package/dist/esm/helpers/ThemeManager.mjs +156 -0
  26. package/dist/esm/helpers/ThemeManagerContext.mjs +3 -0
  27. package/dist/esm/helpers/createMediaStyle.mjs +71 -0
  28. package/dist/esm/helpers/createShallowSetState.mjs +17 -0
  29. package/dist/esm/helpers/createStyledContext.mjs +35 -0
  30. package/dist/esm/helpers/defaultOffset.mjs +5 -0
  31. package/dist/esm/helpers/expandStyle.mjs +38 -0
  32. package/dist/esm/helpers/expandStyles.mjs +15 -0
  33. package/dist/esm/helpers/getExpandedShorthands.mjs +9 -0
  34. package/dist/esm/helpers/getFontLanguage.mjs +2 -0
  35. package/dist/esm/helpers/getGroupPropParts.mjs +13 -0
  36. package/dist/esm/helpers/getSplitStyles.js +1 -1
  37. package/dist/esm/helpers/getSplitStyles.js.map +1 -1
  38. package/dist/esm/helpers/getSplitStyles.mjs +643 -0
  39. package/dist/esm/helpers/getSplitStyles.native.js +1 -1
  40. package/dist/esm/helpers/getSplitStyles.native.js.map +1 -1
  41. package/dist/esm/helpers/getStylesAtomic.mjs +150 -0
  42. package/dist/esm/helpers/getThemeCSSRules.mjs +87 -0
  43. package/dist/esm/helpers/getVariantExtras.mjs +43 -0
  44. package/dist/esm/helpers/insertStyleRule.mjs +177 -0
  45. package/dist/esm/helpers/isObj.mjs +2 -0
  46. package/dist/esm/helpers/isTamaguiComponent.mjs +5 -0
  47. package/dist/esm/helpers/isTamaguiElement.mjs +4 -0
  48. package/dist/esm/helpers/log.mjs +4 -0
  49. package/dist/esm/helpers/matchMedia.mjs +11 -0
  50. package/dist/esm/helpers/mergeProps.mjs +21 -0
  51. package/dist/esm/helpers/mergeVariants.mjs +16 -0
  52. package/dist/esm/helpers/normalizeColor.mjs +17 -0
  53. package/dist/esm/helpers/normalizeShadow.mjs +23 -0
  54. package/dist/esm/helpers/normalizeStyle.mjs +23 -0
  55. package/dist/esm/helpers/normalizeStylePropKeys.mjs +2 -0
  56. package/dist/esm/helpers/normalizeValueWithProperty.mjs +32 -0
  57. package/dist/esm/helpers/objectIdentityKey.mjs +15 -0
  58. package/dist/esm/helpers/propMapper.mjs +239 -0
  59. package/dist/esm/helpers/proxyThemeToParents.mjs +36 -0
  60. package/dist/esm/helpers/proxyThemeVariables.mjs +12 -0
  61. package/dist/esm/helpers/pseudoDescriptors.mjs +34 -0
  62. package/dist/esm/helpers/registerCSSVariable.mjs +7 -0
  63. package/dist/esm/helpers/themeable.mjs +33 -0
  64. package/dist/esm/helpers/themes.mjs +14 -0
  65. package/dist/esm/helpers/timer.mjs +8 -0
  66. package/dist/esm/hooks/useConfiguration.mjs +20 -0
  67. package/dist/esm/hooks/useDisableSSR.mjs +5 -0
  68. package/dist/esm/hooks/useIsTouchDevice.mjs +4 -0
  69. package/dist/esm/hooks/useMedia.mjs +146 -0
  70. package/dist/esm/hooks/useProps.mjs +40 -0
  71. package/dist/esm/hooks/useTheme.mjs +222 -0
  72. package/dist/esm/hooks/useThemeName.mjs +15 -0
  73. package/dist/esm/index.mjs +61 -0
  74. package/dist/esm/inject-styles.mjs +13 -0
  75. package/dist/esm/insertFont.mjs +44 -0
  76. package/dist/esm/interfaces/CSSColorNames.mjs +0 -0
  77. package/dist/esm/interfaces/GetRef.mjs +0 -0
  78. package/dist/esm/interfaces/KeyTypes.mjs +0 -0
  79. package/dist/esm/interfaces/RNExclusiveTypes.mjs +0 -0
  80. package/dist/esm/interfaces/Role.mjs +0 -0
  81. package/dist/esm/interfaces/TamaguiComponentEvents.mjs +0 -0
  82. package/dist/esm/interfaces/TamaguiComponentPropsBaseBase.mjs +0 -0
  83. package/dist/esm/interfaces/TamaguiComponentState.mjs +0 -0
  84. package/dist/esm/interfaces/WebOnlyPressEvents.mjs +0 -0
  85. package/dist/esm/internalWithTheme.mjs +14 -0
  86. package/dist/esm/setupHooks.mjs +5 -0
  87. package/dist/esm/setupReactNative.mjs +24 -0
  88. package/dist/esm/styled.mjs +56 -0
  89. package/dist/esm/type-utils.mjs +0 -0
  90. package/dist/esm/types.mjs +2 -0
  91. package/dist/esm/views/Configuration.mjs +12 -0
  92. package/dist/esm/views/FontLanguage.mjs +13 -0
  93. package/dist/esm/views/FontLanguage.types.mjs +0 -0
  94. package/dist/esm/views/Slot.mjs +53 -0
  95. package/dist/esm/views/Stack.mjs +10 -0
  96. package/dist/esm/views/TamaguiProvider.mjs +32 -0
  97. package/dist/esm/views/Text.mjs +64 -0
  98. package/dist/esm/views/Theme.mjs +104 -0
  99. package/dist/esm/views/ThemeDebug.mjs +57 -0
  100. package/dist/esm/views/ThemeProvider.mjs +20 -0
  101. package/dist/esm/views/View.mjs +9 -0
  102. package/package.json +10 -10
  103. package/src/createComponent.tsx +1 -1
  104. package/src/helpers/getSplitStyles.tsx +5 -0
  105. package/types/helpers/getSplitStyles.d.ts.map +1 -1
@@ -0,0 +1,643 @@
1
+ import { currentPlatform, isClient, isServer, isWeb, useIsomorphicLayoutEffect } from "@tamagui/constants";
2
+ import { stylePropsText, stylePropsTransform, validPseudoKeys, validStyles, validStylesOnBaseProps } from "@tamagui/helpers";
3
+ import { useInsertionEffect } from "react";
4
+ import { getConfig } from "../config.mjs";
5
+ import { accessibilityDirectMap } from "../constants/accessibilityDirectMap.mjs";
6
+ import { webViewFlexCompatStyles } from "../constants/constants.mjs";
7
+ import { isDevTools } from "../constants/isDevTools.mjs";
8
+ import { getMediaImportanceIfMoreImportant, mediaState as globalMediaState, isMediaKey, mediaKeyMatch, mediaQueryConfig, mergeMediaByImportance } from "../hooks/useMedia.mjs";
9
+ import { createMediaStyle } from "./createMediaStyle.mjs";
10
+ import { fixStyles } from "./expandStyles.mjs";
11
+ import { getGroupPropParts } from "./getGroupPropParts.mjs";
12
+ import { generateAtomicStyles, getStylesAtomic, styleToCSS, transformsToString } from "./getStylesAtomic.mjs";
13
+ import { insertStyleRules, insertedTransforms, scanAllSheets, shouldInsertStyleRules, updateRules } from "./insertStyleRule.mjs";
14
+ import { log } from "./log.mjs";
15
+ import { normalizeValueWithProperty, reverseMapClassNameToValue } from "./normalizeValueWithProperty.mjs";
16
+ import { getPropMappedFontFamily, propMapper } from "./propMapper.mjs";
17
+ import { pseudoDescriptors, pseudoPriorities } from "./pseudoDescriptors.mjs";
18
+ const IS_STATIC = process.env.IS_STATIC === "is_static";
19
+ let conf;
20
+ const PROP_SPLIT = "-";
21
+ function isValidStyleKey(key, staticConfig) {
22
+ return (staticConfig.validStyles || (staticConfig.isText || staticConfig.isInput ? stylePropsText : validStyles))[key] || staticConfig.acceptTokens && staticConfig.acceptTokens[key];
23
+ }
24
+ const getSplitStyles = (props, staticConfig, theme, themeName, componentState, styleProps, parentSplitStyles, context, elementType, debug) => {
25
+ conf = conf || getConfig(), isWeb && styleProps.isAnimated && conf.animations.isReactNative && !styleProps.noNormalize && (styleProps.noNormalize = "values");
26
+ const {
27
+ shorthands
28
+ } = conf,
29
+ {
30
+ isHOC,
31
+ isText,
32
+ isInput,
33
+ variants,
34
+ isReactNative,
35
+ inlineProps,
36
+ inlineWhenUnflattened,
37
+ parentStaticConfig,
38
+ acceptsClassName
39
+ } = staticConfig,
40
+ viewProps = {},
41
+ mediaState = styleProps.mediaState || globalMediaState,
42
+ usedKeys = {},
43
+ shouldDoClasses = acceptsClassName && isWeb && !styleProps.noClassNames,
44
+ rulesToInsert = [],
45
+ classNames = {},
46
+ transforms = {};
47
+ let pseudos = null,
48
+ space = props.space,
49
+ hasMedia = !1,
50
+ dynamicThemeAccess,
51
+ pseudoGroups,
52
+ mediaGroups,
53
+ style = {},
54
+ className = props.className ?? "",
55
+ mediaStylesSeen = 0;
56
+ const styleState = {
57
+ curProps: {
58
+ ...props
59
+ },
60
+ classNames,
61
+ conf,
62
+ props,
63
+ styleProps,
64
+ componentState,
65
+ staticConfig,
66
+ style,
67
+ theme,
68
+ usedKeys,
69
+ viewProps,
70
+ context,
71
+ debug
72
+ };
73
+ process.env.NODE_ENV === "development" && debug && debug !== "profile" && isClient && (console.groupCollapsed("getSplitStyles (collapsed)"), log({
74
+ props,
75
+ staticConfig,
76
+ shouldDoClasses,
77
+ styleProps,
78
+ componentState,
79
+ styleState,
80
+ theme: {
81
+ ...theme
82
+ }
83
+ }), console.groupEnd());
84
+ for (const keyOg in props) {
85
+ process.env.NODE_ENV === "development" && console.groupEnd();
86
+ let keyInit = keyOg,
87
+ valInit = props[keyOg];
88
+ if (styleProps.disableExpandShorthands || keyInit in shorthands && (keyInit = shorthands[keyInit]), keyInit === "className" || keyInit in usedKeys || props.asChild && webViewFlexCompatStyles[keyInit] === valInit) continue;
89
+ if (keyInit in skipProps && !styleProps.noSkip && !isHOC) {
90
+ if (keyInit === "group") {
91
+ const identifier = `t_group_${valInit}`,
92
+ containerType = conf.settings.webContainerType || "inline-size",
93
+ containerCSS = {
94
+ identifier,
95
+ property: "container",
96
+ rules: [`.${identifier} { container-name: ${valInit}; container-type: ${containerType}; }`]
97
+ };
98
+ addStyleToInsertRules(rulesToInsert, containerCSS);
99
+ }
100
+ continue;
101
+ }
102
+ const valInitType = typeof valInit,
103
+ isValidStyleKeyInit = isValidStyleKey(keyInit, staticConfig);
104
+ if (isValidStyleKeyInit && valInitType === "string" && valInit[0] === "_") {
105
+ const isValidClassName = (keyInit in validStyles),
106
+ isMediaOrPseudo2 = !isValidClassName &&
107
+ // media are flattened for some reason to color-hover keys,
108
+ // we should probably just leave them in place to avoid extra complexity
109
+ keyInit.includes(PROP_SPLIT) && validStyles[keyInit.split(PROP_SPLIT)[0]];
110
+ if (isValidClassName || isMediaOrPseudo2) {
111
+ shouldDoClasses ? (mergeClassName(transforms, classNames, keyInit, valInit, isMediaOrPseudo2), delete style[keyInit]) : (style[keyInit] = reverseMapClassNameToValue(keyInit, valInit), delete classNames[keyInit]);
112
+ continue;
113
+ }
114
+ }
115
+ if (styleState.curProps[keyInit] = valInit, keyInit === "dataSet") {
116
+ for (const keyInit2 in valInit) viewProps[`data-${hyphenate(keyInit2)}`] = valInit[keyInit2];
117
+ continue;
118
+ }
119
+ if (keyInit[0] === "_" && keyInit.startsWith("_style")) {
120
+ mergeStylePropIntoStyle(styleState, valInit);
121
+ continue;
122
+ }
123
+ if (!styleProps.noExpand) {
124
+ if (keyInit === "disabled" && valInit === !0 && (viewProps["aria-disabled"] = !0, (elementType === "button" || elementType === "form" || elementType === "input" || elementType === "select" || elementType === "textarea") && (viewProps.disabled = !0), !variants?.disabled)) continue;
125
+ if (keyInit === "testID") {
126
+ viewProps[isReactNative ? keyInit : "data-testid"] = valInit;
127
+ continue;
128
+ }
129
+ if (keyInit === "id" || keyInit === "nativeID") {
130
+ viewProps.id = valInit;
131
+ continue;
132
+ }
133
+ let didUseKeyInit = !1;
134
+ if (isReactNative) {
135
+ if (keyInit in accessibilityDirectMap || keyInit.startsWith("accessibility")) {
136
+ viewProps[keyInit] = valInit;
137
+ continue;
138
+ }
139
+ } else {
140
+ if (didUseKeyInit = !0, keyInit in accessibilityDirectMap) {
141
+ viewProps[accessibilityDirectMap[keyInit]] = valInit;
142
+ continue;
143
+ }
144
+ switch (keyInit) {
145
+ case "accessibilityRole":
146
+ {
147
+ valInit === "none" ? viewProps.role = "presentation" : viewProps.role = accessibilityRoleToWebRole[valInit] || valInit;
148
+ continue;
149
+ }
150
+ case "accessibilityLabelledBy":
151
+ case "accessibilityFlowTo":
152
+ case "accessibilityControls":
153
+ case "accessibilityDescribedBy":
154
+ {
155
+ viewProps[`aria-${keyInit.replace("accessibility", "").toLowerCase()}`] = processIDRefList(valInit);
156
+ continue;
157
+ }
158
+ case "accessibilityKeyShortcuts":
159
+ {
160
+ Array.isArray(valInit) && (viewProps["aria-keyshortcuts"] = valInit.join(" "));
161
+ continue;
162
+ }
163
+ case "accessibilityLiveRegion":
164
+ {
165
+ viewProps["aria-live"] = valInit === "none" ? "off" : valInit;
166
+ continue;
167
+ }
168
+ case "accessibilityReadOnly":
169
+ {
170
+ viewProps["aria-readonly"] = valInit, (elementType === "input" || elementType === "select" || elementType === "textarea") && (viewProps.readOnly = !0);
171
+ continue;
172
+ }
173
+ case "accessibilityRequired":
174
+ {
175
+ viewProps["aria-required"] = valInit, (elementType === "input" || elementType === "select" || elementType === "textarea") && (viewProps.required = valInit);
176
+ continue;
177
+ }
178
+ default:
179
+ didUseKeyInit = !1;
180
+ }
181
+ }
182
+ if (didUseKeyInit) continue;
183
+ }
184
+ const isShorthand = (keyInit in shorthands);
185
+ let isVariant = !isValidStyleKeyInit && variants && keyInit in variants;
186
+ const isStyleLikeKey = isShorthand || isValidStyleKeyInit || isVariant;
187
+ let isPseudo = (keyInit in validPseudoKeys),
188
+ isMedia = !isStyleLikeKey && !isPseudo && isMediaKey(keyInit),
189
+ isMediaOrPseudo = !!(isMedia || isPseudo);
190
+ const isStyleProp = isMediaOrPseudo || isVariant && !styleProps.noExpand || isValidStyleKeyInit || isShorthand;
191
+ if (isStyleProp && (props.asChild === "except-style" || props.asChild === "except-style-web")) continue;
192
+ const shouldPassProp = !isStyleProp ||
193
+ // is in parent variants
194
+ isHOC && parentStaticConfig?.variants && keyInit in parentStaticConfig.variants || inlineProps?.has(keyInit),
195
+ parentVariant = parentStaticConfig?.variants?.[keyInit],
196
+ isHOCShouldPassThrough = !!(isHOC && (isShorthand || isValidStyleKeyInit || isMediaOrPseudo || parentVariant || keyInit in skipProps)),
197
+ shouldPassThrough = shouldPassProp || isHOCShouldPassThrough;
198
+ if (process.env.NODE_ENV === "development" && debug === "verbose" && (console.groupEnd(), console.groupEnd(), console.groupCollapsed(` \u{1F511} ${keyOg}${keyInit !== keyOg ? ` (shorthand for ${keyInit})` : ""} ${shouldPassThrough ? "(pass)" : ""}`), log({
199
+ isVariant,
200
+ valInit,
201
+ shouldPassProp
202
+ }), isClient && log({
203
+ variants,
204
+ variant: variants?.[keyInit],
205
+ isVariant,
206
+ isHOCShouldPassThrough,
207
+ curProps: {
208
+ ...styleState.curProps
209
+ },
210
+ parentStaticConfig
211
+ })), shouldPassThrough && (passDownProp(viewProps, keyInit, valInit, isMediaOrPseudo), !isVariant) || !styleProps.noSkip && keyInit in skipProps) continue;
212
+ (isText || isInput) && valInit && (keyInit === "fontFamily" || keyInit === shorthands.fontFamily) && valInit in conf.fontsParsed && (styleState.fontFamily = valInit);
213
+ const expanded = isMediaOrPseudo || !isVariant && !isValidStyleKeyInit ? [[keyInit, valInit]] : propMapper(keyInit, valInit, styleState),
214
+ next = getPropMappedFontFamily(expanded);
215
+ if (next && (styleState.fontFamily = next), process.env.NODE_ENV === "development" && debug === "verbose") {
216
+ console.groupCollapsed(" \u{1F4A0} expanded", keyInit, valInit);
217
+ try {
218
+ !isServer && isDevTools && (log({
219
+ expanded,
220
+ styleProps,
221
+ componentState,
222
+ isVariant,
223
+ variant: variants?.[keyInit],
224
+ shouldPassProp,
225
+ isHOCShouldPassThrough,
226
+ theme,
227
+ usedKeys: {
228
+ ...usedKeys
229
+ },
230
+ curProps: {
231
+ ...styleState.curProps
232
+ }
233
+ }), log("expanded", expanded, `
234
+ usedKeys`, {
235
+ ...usedKeys
236
+ }, `
237
+ current`, {
238
+ ...style
239
+ }));
240
+ } catch {}
241
+ console.groupEnd();
242
+ }
243
+ if (expanded) {
244
+ for (const [key, val] of expanded) {
245
+ if (val == null || key in usedKeys) continue;
246
+ if (isPseudo = key in validPseudoKeys, isMedia = !isPseudo && !isValidStyleKeyInit && isMediaKey(key), isMediaOrPseudo = !!(isMedia || isPseudo), isVariant = variants && key in variants, (inlineProps?.has(key) || IS_STATIC && inlineWhenUnflattened?.has(key)) && (viewProps[key] = props[key] ?? val), styleProps.noExpand && isPseudo || isHOC && (isMediaOrPseudo || parentStaticConfig?.variants?.[keyInit])) {
247
+ passDownProp(viewProps, key, val, isMediaOrPseudo), process.env.NODE_ENV === "development" && debug === "verbose" && (console.groupCollapsed(` - passing down prop ${key}`), log({
248
+ val,
249
+ after: {
250
+ ...viewProps[key]
251
+ }
252
+ }), console.groupEnd());
253
+ continue;
254
+ }
255
+ if (isPseudo) {
256
+ if (!val) continue;
257
+ const pseudoStyleObject = getSubStyle(styleState, key, val, styleProps.noClassNames),
258
+ descriptor = pseudoDescriptors[key],
259
+ isEnter = key === "enterStyle",
260
+ isExit = key === "exitStyle";
261
+ if (!descriptor) continue;
262
+ if ((!shouldDoClasses || IS_STATIC) && (pseudos ||= {}, pseudos[key] ||= {}, IS_STATIC)) {
263
+ Object.assign(pseudos[key], pseudoStyleObject);
264
+ continue;
265
+ }
266
+ if (shouldDoClasses && !isExit) {
267
+ const pseudoStyles = generateAtomicStyles(pseudoStyleObject, descriptor);
268
+ process.env.NODE_ENV === "development" && debug === "verbose" && (console.groupCollapsed("pseudo (classes)", key), log({
269
+ pseudoStyleObject,
270
+ pseudoStyles
271
+ }), console.groupEnd());
272
+ for (const psuedoStyle of pseudoStyles) {
273
+ const fullKey = `${psuedoStyle.property}${PROP_SPLIT}${descriptor.name}`;
274
+ fullKey in usedKeys || (addStyleToInsertRules(rulesToInsert, psuedoStyle), mergeClassName(transforms, classNames, fullKey, psuedoStyle.identifier, isMediaOrPseudo, !0));
275
+ }
276
+ }
277
+ if (!shouldDoClasses || isExit || isEnter) {
278
+ const descriptorKey = descriptor.stateKey || descriptor.name;
279
+ let isDisabled = componentState[descriptorKey] === !1;
280
+ isExit && (isDisabled = !styleProps.isExiting), isEnter && (isDisabled = componentState.unmounted === "should-enter" ? !0 : !componentState.unmounted), process.env.NODE_ENV === "development" && debug === "verbose" && (console.groupCollapsed("pseudo", key, {
281
+ isDisabled
282
+ }), log({
283
+ pseudoStyleObject,
284
+ isDisabled,
285
+ descriptor,
286
+ componentState
287
+ }), console.groupEnd());
288
+ const importance = descriptor.priority;
289
+ for (const pkey in pseudoStyleObject) {
290
+ const val2 = pseudoStyleObject[pkey];
291
+ if (isDisabled) {
292
+ const defaultValues = animatableDefaults[pkey];
293
+ defaultValues != null && !(pkey in usedKeys) && mergeStyle(styleState, pkey, defaultValues);
294
+ } else {
295
+ const curImportance = usedKeys[pkey] || 0,
296
+ shouldMerge = importance >= curImportance;
297
+ shouldMerge && (pseudos ||= {}, pseudos[key] ||= {}, pseudos[key][pkey] = val2, mergeStyle(styleState, pkey, val2)), process.env.NODE_ENV === "development" && debug === "verbose" && log(" subKey", pkey, shouldMerge, {
298
+ importance,
299
+ curImportance,
300
+ pkey,
301
+ val: val2,
302
+ transforms: {
303
+ ...styleState.transforms
304
+ }
305
+ });
306
+ }
307
+ }
308
+ if (!isDisabled) for (const key2 in val) {
309
+ const k = shorthands[key2] || key2;
310
+ usedKeys[k] = Math.max(importance, usedKeys[k] || 0);
311
+ }
312
+ }
313
+ continue;
314
+ }
315
+ if (isMedia) {
316
+ if (!val) continue;
317
+ if (isMedia === "platform") {
318
+ const platform = key.slice(10);
319
+ if (
320
+ // supports web, ios, android
321
+ platform !== currentPlatform &&
322
+ // supports web, native
323
+ platform !== "web") continue;
324
+ }
325
+ hasMedia ||= !0;
326
+ const mediaStyle = getSubStyle(styleState, key, val,
327
+ // TODO try true like pseudo
328
+ !1),
329
+ mediaKeyShort = key.slice(1);
330
+ process.env.NODE_ENV === "development" && debug === "verbose" && log(` \u{1F4FA} ${key}`, {
331
+ key,
332
+ val,
333
+ mediaStyle,
334
+ props,
335
+ shouldDoClasses,
336
+ componentState
337
+ });
338
+ const hasSpace = val.space;
339
+ if ((hasSpace || !shouldDoClasses) && (Array.isArray(hasMedia) || (hasMedia = []), hasMedia.push(mediaKeyShort)), shouldDoClasses) {
340
+ if (hasSpace && (delete mediaStyle.space, mediaState[mediaKeyShort])) {
341
+ const importance = getMediaImportanceIfMoreImportant(mediaKeyShort, "space", usedKeys, !0);
342
+ importance && (space = val.space, usedKeys.space = importance, process.env.NODE_ENV === "development" && debug === "verbose" && log(`Found more important space for current media ${mediaKeyShort}: ${val} (importance: ${importance})`));
343
+ }
344
+ const mediaStyles = getStylesAtomic(mediaStyle, debug),
345
+ priority = mediaStylesSeen;
346
+ mediaStylesSeen += 1;
347
+ for (const style2 of mediaStyles) {
348
+ const out = createMediaStyle(style2, mediaKeyShort, mediaQueryConfig, isMedia, !1, priority);
349
+ process.env.NODE_ENV === "development" && debug === "verbose" && log("\u{1F4FA} media style:", out);
350
+ const fullKey = `${style2.property}${PROP_SPLIT}${mediaKeyShort}`;
351
+ fullKey in usedKeys || (addStyleToInsertRules(rulesToInsert, out), mergeClassName(transforms, classNames, fullKey, out.identifier, !0, !0));
352
+ }
353
+ } else {
354
+ const isThemeMedia = isMedia === "theme",
355
+ isGroupMedia = isMedia === "group";
356
+ if (!isThemeMedia && !(isMedia === "platform") && !isGroupMedia && !mediaState[mediaKeyShort]) continue;
357
+ let importanceBump = 0;
358
+ if (isThemeMedia) {
359
+ dynamicThemeAccess = !0;
360
+ const mediaThemeName = mediaKeyShort.slice(6);
361
+ if (!(themeName === mediaThemeName || themeName.startsWith(mediaThemeName))) continue;
362
+ } else if (isGroupMedia) {
363
+ const groupInfo = getGroupPropParts(mediaKeyShort),
364
+ groupName = groupInfo.name,
365
+ groupContext = context?.groups.state[groupName];
366
+ if (!groupContext) {
367
+ process.env.NODE_ENV === "development" && debug && console.warn(`No parent with group prop, skipping styles: ${groupName}`);
368
+ continue;
369
+ }
370
+ const groupPseudoKey = groupInfo.pseudo,
371
+ groupMediaKey = groupInfo.media,
372
+ componentGroupState = componentState.group?.[groupName];
373
+ if (groupMediaKey) {
374
+ mediaGroups ||= /* @__PURE__ */new Set(), mediaGroups.add(groupMediaKey);
375
+ const mediaState2 = componentGroupState?.media;
376
+ let isActive = mediaState2?.[groupMediaKey];
377
+ if (!mediaState2 && groupContext.layout && (isActive = mediaKeyMatch(groupMediaKey, groupContext.layout)), !isActive) continue;
378
+ importanceBump = 2;
379
+ }
380
+ if (groupPseudoKey) {
381
+ if (pseudoGroups ||= /* @__PURE__ */new Set(), pseudoGroups.add(groupName), !(componentGroupState ||
382
+ // fallback to context initially
383
+ context.groups.state[groupName]).pseudo?.[groupPseudoKey]) continue;
384
+ importanceBump = pseudoPriorities[groupPseudoKey];
385
+ }
386
+ }
387
+ for (const subKey in mediaStyle) {
388
+ if (subKey === "space") {
389
+ space = valInit.space;
390
+ continue;
391
+ }
392
+ mergeMediaByImportance(style, mediaKeyShort, subKey, mediaStyle[subKey], usedKeys, mediaState[mediaKeyShort], importanceBump), key === "fontFamily" && (styleState.fontFamily = mediaStyle.fontFamily);
393
+ }
394
+ }
395
+ continue;
396
+ }
397
+ if (
398
+ // is HOC we can just pass through the styles as props
399
+ // this fixes issues where style prop got merged with wrong priority
400
+ !isHOC && isValidStyleKey(key, staticConfig)) {
401
+ mergeStyle(styleState, key, val);
402
+ continue;
403
+ }
404
+ isVariant || (viewProps[key] = val);
405
+ }
406
+ if (process.env.NODE_ENV === "development" && debug === "verbose") {
407
+ console.groupCollapsed(" \u2714\uFE0F expand complete", keyInit);
408
+ try {
409
+ log("style", {
410
+ ...style
411
+ }), log("transforms", {
412
+ ...transforms
413
+ }), log("viewProps", {
414
+ ...viewProps
415
+ });
416
+ } catch {}
417
+ console.groupEnd();
418
+ }
419
+ }
420
+ }
421
+ if (process.env.NODE_ENV === "development" && console.groupEnd(), props.style && mergeStylePropIntoStyle(styleState, props.style), !(styleProps.noNormalize === !1) && (fixStyles(style), isWeb && !staticConfig.isReactNative && styleToCSS(style), styleState.transforms && (Object.entries(styleState.transforms).sort(([a], [b]) => a.localeCompare(b)).forEach(([key, val]) => {
422
+ mergeTransform(style, key, val, !0);
423
+ }), !staticConfig.isReactNative && !styleProps.isAnimated && Array.isArray(style.transform) && (style.transform = transformsToString(style.transform))), parentSplitStyles)) {
424
+ if (shouldDoClasses) for (const key in parentSplitStyles.classNames) {
425
+ const val = parentSplitStyles.classNames[key];
426
+ key in style || key in classNames || (classNames[key] = val);
427
+ }
428
+ if (!shouldDoClasses) for (const key in parentSplitStyles.style) key in classNames || key in style || (style[key] = parentSplitStyles.style[key]);
429
+ }
430
+ if (shouldDoClasses) {
431
+ let retainedStyles,
432
+ shouldRetain = !1;
433
+ if (!style.$$css) {
434
+ const atomic = getStylesAtomic(style);
435
+ for (const atomicStyle of atomic) {
436
+ const key = atomicStyle.property,
437
+ isAnimatedAndAnimateOnly = styleProps.isAnimated && styleProps.noClassNames && (!props.animateOnly || props.animateOnly.includes(key)),
438
+ nonAnimatedAnimateOnly = !isAnimatedAndAnimateOnly && !styleProps.isAnimated && props.animateOnly?.includes(key);
439
+ isAnimatedAndAnimateOnly ? (retainedStyles ||= {}, retainedStyles[key] = style[key]) : nonAnimatedAnimateOnly ? (retainedStyles ||= {}, retainedStyles[key] = atomicStyle.value, shouldRetain = !0) : (addStyleToInsertRules(rulesToInsert, atomicStyle), mergeClassName(transforms, classNames, key, atomicStyle.identifier, !1, !0));
440
+ }
441
+ process.env.NODE_ENV === "development" && props.debug === "verbose" && (console.groupCollapsed("\u{1F539} getSplitStyles final style object"), console.info(style), console.groupEnd()), (shouldRetain || !IS_STATIC) && (style = retainedStyles || {});
442
+ }
443
+ if (transforms) for (const namespace in transforms) {
444
+ if (!transforms[namespace]) {
445
+ process.env.NODE_ENV === "development" && console.warn("Error no transform", transforms, namespace);
446
+ continue;
447
+ }
448
+ const [hash, val] = transforms[namespace],
449
+ identifier = `_transform${hash}`;
450
+ if (isClient && !insertedTransforms[identifier]) {
451
+ const rule = `.${identifier} { transform: ${val}; }`;
452
+ addStyleToInsertRules(rulesToInsert, {
453
+ identifier,
454
+ rules: [rule],
455
+ property: namespace
456
+ });
457
+ }
458
+ classNames[namespace] = identifier;
459
+ }
460
+ }
461
+ if (isWeb && !isReactNative && viewProps.tabIndex == null) {
462
+ const isFocusable = viewProps.focusable ?? viewProps.accessible;
463
+ viewProps.focusable && delete viewProps.focusable;
464
+ const role = viewProps.role;
465
+ isFocusable === !1 && (viewProps.tabIndex = "-1"),
466
+ // These native elements are focusable by default
467
+ elementType === "a" || elementType === "button" || elementType === "input" || elementType === "select" || elementType === "textarea" ? (isFocusable === !1 || props.accessibilityDisabled === !0) && (viewProps.tabIndex = "-1") :
468
+ // These roles are made focusable by default
469
+ (role === "button" || role === "checkbox" || role === "link" || role === "radio" ||
470
+ // @ts-expect-error (consistent with RNW)
471
+ role === "textbox" || role === "switch") && isFocusable !== !1 && (viewProps.tabIndex = "0"), isFocusable && (viewProps.tabIndex = "0", delete viewProps.focusable);
472
+ }
473
+ const result = {
474
+ space,
475
+ hasMedia,
476
+ fontFamily: styleState.fontFamily,
477
+ viewProps,
478
+ // @ts-expect-error
479
+ style,
480
+ pseudos,
481
+ classNames,
482
+ rulesToInsert,
483
+ dynamicThemeAccess,
484
+ pseudoGroups,
485
+ mediaGroups
486
+ };
487
+ if (className && (classNames.className = className), process.env.NODE_ENV === "development" && debug === "verbose" && isDevTools) {
488
+ console.groupCollapsed("\u{1F539} getSplitStyles ===>");
489
+ try {
490
+ const logs = {
491
+ ...result,
492
+ className,
493
+ componentState,
494
+ transforms,
495
+ viewProps,
496
+ viewPropsOrder: Object.keys(viewProps),
497
+ rulesToInsert,
498
+ parentSplitStyles
499
+ };
500
+ for (const key in logs) log(key, logs[key]);
501
+ } catch {}
502
+ console.groupEnd();
503
+ }
504
+ return result;
505
+ };
506
+ function mergeClassName(transforms, classNames, key, val, isMediaOrPseudo = !1, isInsertingNow = !1) {
507
+ if (val) if (!isInsertingNow && val[0] === "_" && val.startsWith("_transform-")) {
508
+ const ns = isMediaOrPseudo ? key : "transform";
509
+ let transform = insertedTransforms[val];
510
+ isClient && !transform && (scanAllSheets(), transform = insertedTransforms[val], !transform && isWeb && val[0] !== "_" && (transform = val)), transforms[ns] ||= ["", ""], transforms[ns][0] += val.replace("_transform", ""), transform && (transforms[ns][1] += transform);
511
+ } else classNames[key] = val;
512
+ }
513
+ function mergeStyle(styleState, key, val, disableNormalize = !1) {
514
+ const {
515
+ classNames,
516
+ viewProps,
517
+ style,
518
+ usedKeys,
519
+ styleProps
520
+ } = styleState;
521
+ if (isWeb && val?.[0] === "_") classNames[key] = val, usedKeys[key] ||= 1;else if (key in stylePropsTransform) styleState.transforms ||= {}, styleState.transforms[key] = val;else {
522
+ const out = isWeb && !disableNormalize && !styleProps.noNormalize ? normalizeValueWithProperty(val, key) : val;
523
+ key in validStylesOnBaseProps ? viewProps[key] = out : style[key] = out;
524
+ }
525
+ }
526
+ const getSubStyle = (styleState, subKey, styleIn, avoidMergeTransform) => {
527
+ const {
528
+ staticConfig,
529
+ props,
530
+ conf: conf2,
531
+ styleProps
532
+ } = styleState,
533
+ styleOut = {};
534
+ for (let key in styleIn) {
535
+ const val = styleIn[key];
536
+ key = conf2.shorthands[key] || key;
537
+ const expanded = propMapper(key, val, styleState, {
538
+ ...props,
539
+ ...props[subKey]
540
+ });
541
+ if (!(!expanded || !staticConfig.isHOC && key in skipProps && !styleProps.noSkip)) for (const [skey, sval] of expanded) !avoidMergeTransform && skey in stylePropsTransform ? mergeTransform(styleOut, skey, sval) : styleOut[skey] = styleProps.noNormalize ? sval : normalizeValueWithProperty(sval, key);
542
+ }
543
+ return styleProps.noNormalize || fixStyles(styleOut), styleOut;
544
+ };
545
+ function mergeStylePropIntoStyle(styleState, cur) {
546
+ if (!cur) return;
547
+ const styles = Array.isArray(cur) ? cur : [cur];
548
+ for (const style of styles) {
549
+ if (!style) continue;
550
+ const isRNW = style.$$css;
551
+ Object.assign(isRNW ? styleState.classNames : styleState.style, style);
552
+ }
553
+ }
554
+ const useInsertEffectCompat = isWeb ? useInsertionEffect || useIsomorphicLayoutEffect : () => {},
555
+ useSplitStyles = (...args) => {
556
+ const res = getSplitStyles(...args);
557
+ return useInsertEffectCompat(() => {
558
+ insertStyleRules(res.rulesToInsert);
559
+ }, [res.rulesToInsert]), res;
560
+ };
561
+ function addStyleToInsertRules(rulesToInsert, styleObject) {
562
+ shouldInsertStyleRules(styleObject.identifier) && (updateRules(styleObject.identifier, styleObject.rules), rulesToInsert.push(styleObject));
563
+ }
564
+ function processIDRefList(idRefList) {
565
+ return Array.isArray(idRefList) ? idRefList.join(" ") : idRefList;
566
+ }
567
+ const animatableDefaults = {
568
+ opacity: 1,
569
+ scale: 1,
570
+ rotate: "0deg",
571
+ rotateY: "0deg",
572
+ rotateX: "0deg",
573
+ x: 0,
574
+ y: 0
575
+ },
576
+ lowercaseHyphenate = match => `-${match.toLowerCase()}`,
577
+ hyphenate = str => str.replace(/[A-Z]/g, lowercaseHyphenate),
578
+ mergeTransform = (obj, key, val, backwards = !1) => {
579
+ typeof obj.transform != "string" && (obj.transform ||= [], obj.transform[backwards ? "unshift" : "push"]({
580
+ [mapTransformKeys[key] || key]: val
581
+ }));
582
+ },
583
+ mapTransformKeys = {
584
+ x: "translateX",
585
+ y: "translateY"
586
+ },
587
+ skipProps = {
588
+ untilMeasured: 1,
589
+ animation: 1,
590
+ space: 1,
591
+ animateOnly: 1,
592
+ disableClassName: 1,
593
+ debug: 1,
594
+ componentName: 1,
595
+ disableOptimization: 1,
596
+ tag: 1,
597
+ style: 1,
598
+ // handled after loop so pseudos set usedKeys and override it if necessary
599
+ group: 1
600
+ };
601
+ process.env.NODE_ENV === "test" && (skipProps["data-test-renders"] = 1);
602
+ process.env.NODE_ENV !== "production" && Object.assign(skipProps, {
603
+ accessibilityElementsHidden: 1,
604
+ accessibilityIgnoresInvertColors: 1,
605
+ accessibilityLanguage: 1,
606
+ adjustsFontSizeToFit: 1,
607
+ allowFontScaling: 1,
608
+ dataDetectorType: 1,
609
+ dynamicTypeRamp: 1,
610
+ elevationAndroid: 1,
611
+ importantForAccessibility: 1,
612
+ lineBreakStrategyIOS: 1,
613
+ minimumFontScale: 1,
614
+ needsOffscreenAlphaCompositing: 1,
615
+ nextFocusDown: 1,
616
+ nextFocusForward: 1,
617
+ nextFocusLeft: 1,
618
+ nextFocusRight: 1,
619
+ nextFocusUp: 1,
620
+ onMagicTap: 1,
621
+ selectionColor: 1,
622
+ shouldRasterizeIOS: 1,
623
+ suppressHighlighting: 1,
624
+ textBreakStrategy: 1
625
+ });
626
+ const accessibilityRoleToWebRole = {
627
+ adjustable: "slider",
628
+ header: "heading",
629
+ image: "img",
630
+ link: "link",
631
+ none: "presentation",
632
+ summary: "region"
633
+ };
634
+ function passDownProp(viewProps, key, val, shouldMergeObject = !1) {
635
+ if (shouldMergeObject) {
636
+ const next = {
637
+ ...viewProps[key],
638
+ ...val
639
+ };
640
+ delete viewProps[key], viewProps[key] = next;
641
+ } else viewProps[key] = val;
642
+ }
643
+ export { PROP_SPLIT, getSplitStyles, getSubStyle, useSplitStyles };
@@ -131,7 +131,7 @@ const getSplitStyles = (props, staticConfig, theme, themeName, componentState, s
131
131
  continue;
132
132
  const shouldPassProp = !isStyleProp || // is in parent variants
133
133
  isHOC && (parentStaticConfig == null ? void 0 : parentStaticConfig.variants) && keyInit in parentStaticConfig.variants || (inlineProps == null ? void 0 : inlineProps.has(keyInit)), parentVariant = (_a = parentStaticConfig == null ? void 0 : parentStaticConfig.variants) == null ? void 0 : _a[keyInit], isHOCShouldPassThrough = !!(isHOC && (isShorthand || isValidStyleKeyInit || isMediaOrPseudo || parentVariant || keyInit in skipProps)), shouldPassThrough = shouldPassProp || isHOCShouldPassThrough;
134
- if (process.env.NODE_ENV === "development" && debug === "verbose" && (console.groupCollapsed(
134
+ if (process.env.NODE_ENV === "development" && debug === "verbose" && (console.groupEnd(), console.groupEnd(), console.groupCollapsed(
135
135
  ` \u{1F511} ${keyOg}${keyInit !== keyOg ? ` (shorthand for ${keyInit})` : ""} ${shouldPassThrough ? "(pass)" : ""}`
136
136
  ), (0, import_log.log)({ isVariant, valInit, shouldPassProp }), import_constants.isClient && (0, import_log.log)({
137
137
  variants,