@tamagui/core 1.0.1-beta.91 → 1.0.1-beta.94

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 (112) hide show
  1. package/dist/cjs/constants/rnw.native.js +0 -0
  2. package/dist/cjs/constants/rnw.native.js.map +0 -0
  3. package/dist/cjs/createComponent.js +39 -49
  4. package/dist/cjs/createComponent.js.map +2 -2
  5. package/dist/cjs/helpers/createPropMapper.js +24 -17
  6. package/dist/cjs/helpers/createPropMapper.js.map +2 -2
  7. package/dist/cjs/helpers/expandStyle.js +120 -0
  8. package/dist/cjs/helpers/expandStyle.js.map +7 -0
  9. package/dist/cjs/helpers/expandStyles.js +126 -0
  10. package/dist/cjs/helpers/expandStyles.js.map +7 -0
  11. package/dist/cjs/helpers/extendStaticConfig.js +5 -3
  12. package/dist/cjs/helpers/extendStaticConfig.js.map +2 -2
  13. package/dist/cjs/helpers/{getTextSize.js → getFont.js} +14 -8
  14. package/dist/cjs/helpers/getFont.js.map +7 -0
  15. package/dist/cjs/helpers/getSplitStyles.js +113 -108
  16. package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
  17. package/dist/cjs/helpers/getStylesAtomic.js +165 -4
  18. package/dist/cjs/helpers/getStylesAtomic.js.map +2 -2
  19. package/dist/cjs/helpers/normalizeColor.js +76 -0
  20. package/dist/cjs/helpers/normalizeColor.js.map +7 -0
  21. package/dist/cjs/helpers/normalizeValueWithProperty.js +90 -0
  22. package/dist/cjs/helpers/normalizeValueWithProperty.js.map +7 -0
  23. package/dist/cjs/hooks/useFeatures.js +5 -2
  24. package/dist/cjs/hooks/useFeatures.js.map +2 -2
  25. package/dist/cjs/hooks/useTheme.js +1 -1
  26. package/dist/cjs/hooks/useTheme.js.map +2 -2
  27. package/dist/cjs/index.js +2 -4
  28. package/dist/cjs/index.js.map +2 -2
  29. package/dist/cjs/static.js +1 -1
  30. package/dist/cjs/static.js.map +2 -2
  31. package/dist/esm/constants/rnw.native.js +0 -0
  32. package/dist/esm/constants/rnw.native.js.map +0 -0
  33. package/dist/esm/createComponent.js +39 -49
  34. package/dist/esm/createComponent.js.map +2 -2
  35. package/dist/esm/helpers/createPropMapper.js +22 -15
  36. package/dist/esm/helpers/createPropMapper.js.map +2 -2
  37. package/dist/esm/helpers/expandStyle.js +99 -0
  38. package/dist/esm/helpers/expandStyle.js.map +7 -0
  39. package/dist/esm/helpers/expandStyles.js +103 -0
  40. package/dist/esm/helpers/expandStyles.js.map +7 -0
  41. package/dist/esm/helpers/extendStaticConfig.js +5 -3
  42. package/dist/esm/helpers/extendStaticConfig.js.map +2 -2
  43. package/dist/esm/helpers/{getTextSize.js → getFont.js} +10 -4
  44. package/dist/esm/helpers/getFont.js.map +7 -0
  45. package/dist/esm/helpers/getSplitStyles.js +114 -108
  46. package/dist/esm/helpers/getSplitStyles.js.map +2 -2
  47. package/dist/esm/helpers/getStylesAtomic.js +158 -2
  48. package/dist/esm/helpers/getStylesAtomic.js.map +2 -2
  49. package/dist/esm/helpers/normalizeColor.js +49 -0
  50. package/dist/esm/helpers/normalizeColor.js.map +7 -0
  51. package/dist/esm/helpers/normalizeValueWithProperty.js +67 -0
  52. package/dist/esm/helpers/normalizeValueWithProperty.js.map +7 -0
  53. package/dist/esm/hooks/useFeatures.js +5 -2
  54. package/dist/esm/hooks/useFeatures.js.map +2 -2
  55. package/dist/esm/hooks/useTheme.js +1 -1
  56. package/dist/esm/hooks/useTheme.js.map +2 -2
  57. package/dist/esm/index.js +2 -3
  58. package/dist/esm/index.js.map +1 -1
  59. package/dist/esm/static.js +1 -1
  60. package/dist/esm/static.js.map +1 -1
  61. package/package.json +8 -8
  62. package/reset.css +2 -2
  63. package/types/constants/rnw.native.d.ts +0 -0
  64. package/types/constants/rnw.native.d.ts.map +0 -0
  65. package/types/createComponent.d.ts.map +1 -1
  66. package/types/helpers/createPropMapper.d.ts +2 -2
  67. package/types/helpers/createPropMapper.d.ts.map +1 -1
  68. package/types/helpers/createTamaguiProvider.d.ts +1 -0
  69. package/types/helpers/createTamaguiProvider.d.ts.map +1 -1
  70. package/types/helpers/expandStyle.d.ts +2 -0
  71. package/types/helpers/expandStyle.d.ts.map +1 -0
  72. package/types/helpers/expandStyles.d.ts +7 -0
  73. package/types/helpers/expandStyles.d.ts.map +1 -0
  74. package/types/helpers/extendStaticConfig.d.ts.map +1 -1
  75. package/types/helpers/getFont.d.ts +3 -0
  76. package/types/helpers/getFont.d.ts.map +1 -0
  77. package/types/helpers/getSplitStyles.d.ts +2 -3
  78. package/types/helpers/getSplitStyles.d.ts.map +1 -1
  79. package/types/helpers/getStylesAtomic.d.ts +6 -0
  80. package/types/helpers/getStylesAtomic.d.ts.map +1 -1
  81. package/types/helpers/normalizeColor.d.ts +3 -0
  82. package/types/helpers/normalizeColor.d.ts.map +1 -0
  83. package/types/helpers/normalizeValueWithProperty.d.ts +2 -0
  84. package/types/helpers/normalizeValueWithProperty.d.ts.map +1 -0
  85. package/types/hooks/useFeatures.d.ts.map +1 -1
  86. package/types/hooks/useTheme.d.ts.map +1 -1
  87. package/types/index.d.ts +2 -2
  88. package/types/index.d.ts.map +1 -1
  89. package/types/static.d.ts +1 -1
  90. package/types/static.d.ts.map +1 -1
  91. package/dist/cjs/assignNativePropsToWeb.js +0 -187
  92. package/dist/cjs/assignNativePropsToWeb.js.map +0 -7
  93. package/dist/cjs/helpers/fixNativeShadow.native.js +0 -51
  94. package/dist/cjs/helpers/fixNativeShadow.native.js.map +0 -7
  95. package/dist/cjs/helpers/generateAtomicStyles.js +0 -437
  96. package/dist/cjs/helpers/generateAtomicStyles.js.map +0 -7
  97. package/dist/cjs/helpers/getTextSize.js.map +0 -7
  98. package/dist/esm/assignNativePropsToWeb.js +0 -164
  99. package/dist/esm/assignNativePropsToWeb.js.map +0 -7
  100. package/dist/esm/helpers/fixNativeShadow.native.js +0 -28
  101. package/dist/esm/helpers/fixNativeShadow.native.js.map +0 -7
  102. package/dist/esm/helpers/generateAtomicStyles.js +0 -410
  103. package/dist/esm/helpers/generateAtomicStyles.js.map +0 -7
  104. package/dist/esm/helpers/getTextSize.js.map +0 -7
  105. package/types/assignNativePropsToWeb.d.ts +0 -2
  106. package/types/assignNativePropsToWeb.d.ts.map +0 -1
  107. package/types/helpers/fixNativeShadow.native.d.ts +0 -3
  108. package/types/helpers/fixNativeShadow.native.d.ts.map +0 -1
  109. package/types/helpers/generateAtomicStyles.d.ts +0 -12
  110. package/types/helpers/generateAtomicStyles.d.ts.map +0 -1
  111. package/types/helpers/getTextSize.d.ts +0 -3
  112. package/types/helpers/getTextSize.d.ts.map +0 -1
@@ -1,437 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
- var __spreadValues = (a, b) => {
11
- for (var prop in b || (b = {}))
12
- if (__hasOwnProp.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- if (__getOwnPropSymbols)
15
- for (var prop of __getOwnPropSymbols(b)) {
16
- if (__propIsEnum.call(b, prop))
17
- __defNormalProp(a, prop, b[prop]);
18
- }
19
- return a;
20
- };
21
- var __export = (target, all) => {
22
- for (var name in all)
23
- __defProp(target, name, { get: all[name], enumerable: true });
24
- };
25
- var __copyProps = (to, from, except, desc) => {
26
- if (from && typeof from === "object" || typeof from === "function") {
27
- for (let key of __getOwnPropNames(from))
28
- if (!__hasOwnProp.call(to, key) && key !== except)
29
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
30
- }
31
- return to;
32
- };
33
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
34
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
- var generateAtomicStyles_exports = {};
36
- __export(generateAtomicStyles_exports, {
37
- expandStyle: () => expandStyle,
38
- expandStyles: () => expandStyles,
39
- generateAtomicStyles: () => generateAtomicStyles
40
- });
41
- module.exports = __toCommonJS(generateAtomicStyles_exports);
42
- var import_helpers = require("@tamagui/helpers");
43
- var import_hyphenate_style_name = __toESM(require("hyphenate-style-name"));
44
- var import_normalize_css_color = __toESM(require("normalize-css-color"));
45
- var import_conf = require("../conf");
46
- var import_platform = require("../constants/platform");
47
- var import_createTamagui = require("../createTamagui");
48
- var import_pseudoDescriptors = require("./pseudoDescriptors");
49
- class Cache {
50
- constructor() {
51
- this.values = {};
52
- }
53
- get(key, valStr) {
54
- var _a;
55
- return (_a = this.values[key]) == null ? void 0 : _a[valStr];
56
- }
57
- set(key, valStr, object) {
58
- var _a;
59
- (_a = this.values)[key] ?? (_a[key] = {});
60
- this.values[key][valStr] = object;
61
- }
62
- }
63
- const cache = new Cache();
64
- const generateAtomicStyles = (style, pseudo) => {
65
- const res = expandStyles(style);
66
- const out = [];
67
- for (const key in res) {
68
- const value = res[key];
69
- if (value != null && value != void 0) {
70
- const valueString = normalizeValueWithProperty(value, key);
71
- const uid = key + ((pseudo == null ? void 0 : pseudo.name) || "");
72
- const cachedResult = cache.get(uid, valueString);
73
- if (cachedResult != void 0) {
74
- out.push(cachedResult);
75
- } else {
76
- const hash = (0, import_helpers.simpleHash)(uid + valueString);
77
- const pseudoPrefix = pseudo ? `0${pseudo.name}-` : "";
78
- const shortProp = import_createTamagui.reversedShorthands[key] || key;
79
- const identifier = `_${shortProp}-${pseudoPrefix}${hash}`;
80
- const rules = createAtomicRules(identifier, key, valueString, pseudo);
81
- const styleObject = {
82
- property: key,
83
- pseudo: pseudo == null ? void 0 : pseudo.name,
84
- value,
85
- identifier,
86
- rules
87
- };
88
- cache.set(uid, valueString, styleObject);
89
- out.push(styleObject);
90
- }
91
- }
92
- }
93
- return out;
94
- };
95
- const reducedStyleKeys = {
96
- shadowColor: true,
97
- shadowOffset: true,
98
- shadowOpacity: true,
99
- shadowRadius: true,
100
- textShadowColor: true,
101
- textShadowOffset: true,
102
- textShadowRadius: true
103
- };
104
- let shorthands = null;
105
- function expandStyles(style) {
106
- const res = {};
107
- const { boxShadow, shadowColor, shadowOffset, shadowOpacity, shadowRadius } = style;
108
- if (shadowRadius !== void 0) {
109
- const { height, width } = shadowOffset || defaultOffset;
110
- const offsetX = normalizeValueWithProperty(width || 0);
111
- const offsetY = normalizeValueWithProperty(height || 0);
112
- const blurRadius = normalizeValueWithProperty(shadowRadius || 0);
113
- const color = normalizeColor(String(shadowColor || "black"), shadowOpacity);
114
- const shadow = `${offsetX} ${offsetY} ${blurRadius} ${color}`;
115
- res.boxShadow = boxShadow ? `${boxShadow}, ${shadow}` : shadow;
116
- } else if (boxShadow) {
117
- res.boxShadow = boxShadow;
118
- }
119
- const { textShadowColor, textShadowOffset, textShadowRadius } = style;
120
- if (textShadowColor || textShadowOffset || textShadowRadius) {
121
- const { height, width } = textShadowOffset || defaultOffset;
122
- const radius = textShadowRadius || 0;
123
- const color = normalizeValueWithProperty(textShadowColor, "textShadowColor");
124
- if (color && (height !== 0 || width !== 0 || radius !== 0)) {
125
- const blurRadius = normalizeValueWithProperty(radius);
126
- const offsetX = normalizeValueWithProperty(width);
127
- const offsetY = normalizeValueWithProperty(height);
128
- res.textShadow = `${offsetX} ${offsetY} ${blurRadius} ${color}`;
129
- }
130
- }
131
- for (const key in borderDefaults) {
132
- if (key in style) {
133
- res[borderDefaults[key]] = style[borderDefaults[key]] || "solid";
134
- }
135
- }
136
- for (let key in style) {
137
- shorthands = shorthands || (0, import_conf.getConfig)().shorthands;
138
- if (shorthands) {
139
- key = shorthands[key] || key;
140
- }
141
- if (reducedStyleKeys[key])
142
- continue;
143
- if (key in import_pseudoDescriptors.pseudoDescriptors) {
144
- res[key] = expandStyles(style[key]);
145
- } else {
146
- const val = normalizeValueWithProperty(style[key], key);
147
- const out = expandStyle(key, val);
148
- if (out) {
149
- Object.assign(res, Object.fromEntries(out));
150
- } else {
151
- res[key] = val;
152
- }
153
- }
154
- }
155
- return res;
156
- }
157
- const borderDefaults = {
158
- borderWidth: "borderStyle",
159
- borderBottomWidth: "borderBottomStyle",
160
- borderTopWidth: "borderTopStyle",
161
- borderLeftWidth: "borderLeftStyle",
162
- borderRightWidth: "borderRightStyle"
163
- };
164
- function createDeclarationBlock(style, important = false) {
165
- let declarations = "";
166
- for (const key in style) {
167
- const prop = (0, import_hyphenate_style_name.default)(key);
168
- const value = style[key];
169
- declarations += `${prop}:${value}`;
170
- }
171
- return `{${declarations}${important ? ` !important` : ""};}`;
172
- }
173
- const pseudoSelectorPrefixes = (() => {
174
- const res = {};
175
- for (const key in import_pseudoDescriptors.pseudoDescriptors) {
176
- const pseudo = import_pseudoDescriptors.pseudoDescriptors[key];
177
- res[pseudo.name] = [...Array(pseudo.priority)].map(() => ":root").join("") + " ";
178
- }
179
- return res;
180
- })();
181
- function createAtomicRules(identifier, property, value, pseudo) {
182
- const selector = pseudo ? `${pseudoSelectorPrefixes[pseudo.name]} .${identifier}:${pseudo.name}` : `.${identifier}`;
183
- const important = !!pseudo;
184
- let rules = [];
185
- switch (property) {
186
- case "placeholderTextColor": {
187
- const block = createDeclarationBlock({ color: value, opacity: 1 }, important);
188
- rules.push(`${selector}::placeholder${block}`);
189
- break;
190
- }
191
- case "pointerEvents": {
192
- let finalValue = value;
193
- if (value === "auto" || value === "box-only") {
194
- finalValue = "auto!important";
195
- if (value === "box-only") {
196
- const block2 = createDeclarationBlock({ pointerEvents: "none" }, important);
197
- rules.push(`${selector}>*${block2}`);
198
- }
199
- } else if (value === "none" || value === "box-none") {
200
- finalValue = "none!important";
201
- if (value === "box-none") {
202
- const block2 = createDeclarationBlock({ pointerEvents: "auto" }, important);
203
- rules.push(`${selector}>*${block2}`);
204
- }
205
- }
206
- const block = createDeclarationBlock({ pointerEvents: finalValue }, important);
207
- rules.push(`${selector}${block}`);
208
- break;
209
- }
210
- case "scrollbarWidth": {
211
- if (value === "none") {
212
- rules.push(`${selector}::-webkit-scrollbar{display:none}`);
213
- }
214
- const block = createDeclarationBlock({ scrollbarWidth: value }, important);
215
- rules.push(`${selector}${block}`);
216
- break;
217
- }
218
- default: {
219
- const block = createDeclarationBlock({ [property]: value }, important);
220
- rules.push(`${selector}${block}`);
221
- break;
222
- }
223
- }
224
- if ((pseudo == null ? void 0 : pseudo.name) === "hover") {
225
- rules = rules.map((r) => `@media not all and (hover: none) { ${r} }`);
226
- }
227
- return rules;
228
- }
229
- function expandStyle(key, value) {
230
- if (key === "flex") {
231
- if (value <= -1) {
232
- return [
233
- ["flexGrow", 0],
234
- ["flexShrink", 1],
235
- ["flexBasis", "auto"]
236
- ];
237
- }
238
- if (value >= 0) {
239
- return [
240
- ["flexGrow", value],
241
- ["flexShrink", 1]
242
- ];
243
- }
244
- return;
245
- }
246
- switch (key) {
247
- case "elevation":
248
- case "overlayColor":
249
- case "resizeMode":
250
- case "tintColor": {
251
- break;
252
- }
253
- case "aspectRatio": {
254
- return [[key, value.toString()]];
255
- }
256
- case "backgroundClip": {
257
- if (value === "text") {
258
- return [
259
- ["backgroundClip", value],
260
- ["WebkitBackgroundClip", value]
261
- ];
262
- }
263
- break;
264
- }
265
- case "textAlignVertical": {
266
- return [["verticalAlign", value === "center" ? "middle" : value]];
267
- }
268
- case "textDecorationLine": {
269
- return [["textDecorationLine", value]];
270
- }
271
- case "transform": {
272
- if (Array.isArray(value)) {
273
- return [[key, value.map(mapTransform).join(" ")]];
274
- }
275
- break;
276
- }
277
- case "writingDirection": {
278
- return [["direction", value]];
279
- }
280
- }
281
- const longKey = STYLE_SHORT_FORM_EXPANSIONS[key];
282
- if (longKey) {
283
- return longKey.map((key2) => {
284
- return [key2, value];
285
- });
286
- } else {
287
- if (import_platform.isWeb && Array.isArray(value)) {
288
- return [[key, value.join(",")]];
289
- }
290
- }
291
- }
292
- const mapTransform = (transform) => {
293
- const type = Object.keys(transform)[0];
294
- const value = transform[type];
295
- if (type === "matrix" || type === "matrix3d") {
296
- return `${type}(${value.join(",")})`;
297
- } else {
298
- const normalizedValue = normalizeValueWithProperty(value, type);
299
- return `${type}(${normalizedValue})`;
300
- }
301
- };
302
- const colorProps = {
303
- backgroundColor: true,
304
- borderColor: true,
305
- borderTopColor: true,
306
- borderRightColor: true,
307
- borderBottomColor: true,
308
- borderLeftColor: true,
309
- color: true,
310
- shadowColor: true,
311
- textDecorationColor: true,
312
- textShadowColor: true
313
- };
314
- function normalizeValueWithProperty(value, property) {
315
- if (process.env.TAMAGUI_TARGET === "web") {
316
- const shouldCoerceToPx = typeof value === "number" && (property === void 0 || property === null || !unitlessNumbers[property]);
317
- if (shouldCoerceToPx) {
318
- return `${value}px`;
319
- }
320
- }
321
- if (property && colorProps[property]) {
322
- return normalizeColor(value);
323
- }
324
- return value;
325
- }
326
- const normalizeColor = (color, opacity = 1) => {
327
- if (color == null || color == void 0) {
328
- return;
329
- }
330
- if (process.env.TAMAGUI_TARGET === "web") {
331
- if (typeof color === "string" && isWebColor(color)) {
332
- return color;
333
- }
334
- }
335
- const colorInt = processColor(color);
336
- if (colorInt != null) {
337
- const r = colorInt >> 16 & 255;
338
- const g = colorInt >> 8 & 255;
339
- const b = colorInt & 255;
340
- const a = (colorInt >> 24 & 255) / 255;
341
- const alpha = (a * opacity).toFixed(2);
342
- return `rgba(${r},${g},${b},${alpha})`;
343
- }
344
- return `${color}`;
345
- };
346
- const webColors = {
347
- currentColor: true,
348
- currentcolor: true,
349
- transparent: true,
350
- inherit: true
351
- };
352
- const isWebColor = (color) => webColors[color] || color.indexOf("var(") === 0;
353
- const processColor = (color) => {
354
- if (color === void 0 || color === null) {
355
- return color;
356
- }
357
- let intColor = (0, import_normalize_css_color.default)(color);
358
- if (intColor === void 0 || intColor === null) {
359
- return void 0;
360
- }
361
- return (+intColor << 24 | +intColor >>> 8) >>> 0;
362
- };
363
- const unitlessNumbers = {
364
- animationIterationCount: true,
365
- aspectRatio: true,
366
- borderImageOutset: true,
367
- borderImageSlice: true,
368
- borderImageWidth: true,
369
- boxFlex: true,
370
- boxFleGroup: true,
371
- boxOrdinalGroup: true,
372
- columnCount: true,
373
- flex: true,
374
- flexGrow: true,
375
- flexOrder: true,
376
- flexPositive: true,
377
- flexShrink: true,
378
- flexNegative: true,
379
- fontWeight: true,
380
- gridRow: true,
381
- gridRowEnd: true,
382
- gridRowGap: true,
383
- gridRowStart: true,
384
- gridColumn: true,
385
- gridColumnEnd: true,
386
- gridColumnGap: true,
387
- gridColumnStart: true,
388
- lineClamp: true,
389
- opacity: true,
390
- order: true,
391
- orphans: true,
392
- tabSize: true,
393
- widows: true,
394
- zIndex: true,
395
- zoom: true,
396
- fillOpacity: true,
397
- floodOpacity: true,
398
- stopOpacity: true,
399
- strokeDasharray: true,
400
- strokeDashoffset: true,
401
- strokeMiterlimit: true,
402
- strokeOpacity: true,
403
- strokeWidth: true,
404
- scale: true,
405
- scaleX: true,
406
- scaleY: true,
407
- scaleZ: true,
408
- shadowOpacity: true
409
- };
410
- const defaultOffset = { height: 0, width: 0 };
411
- const STYLE_SHORT_FORM_EXPANSIONS = __spreadValues({
412
- borderColor: ["borderTopColor", "borderRightColor", "borderBottomColor", "borderLeftColor"],
413
- borderRadius: [
414
- "borderTopLeftRadius",
415
- "borderTopRightRadius",
416
- "borderBottomRightRadius",
417
- "borderBottomLeftRadius"
418
- ],
419
- borderStyle: ["borderTopStyle", "borderRightStyle", "borderBottomStyle", "borderLeftStyle"],
420
- borderWidth: ["borderTopWidth", "borderRightWidth", "borderBottomWidth", "borderLeftWidth"],
421
- margin: ["marginTop", "marginRight", "marginBottom", "marginLeft"],
422
- marginHorizontal: ["marginRight", "marginLeft"],
423
- marginVertical: ["marginTop", "marginBottom"],
424
- overscrollBehavior: ["overscrollBehaviorX", "overscrollBehaviorY"],
425
- padding: ["paddingTop", "paddingRight", "paddingBottom", "paddingLeft"],
426
- paddingHorizontal: ["paddingRight", "paddingLeft"],
427
- paddingVertical: ["paddingTop", "paddingBottom"]
428
- }, import_platform.isWeb && {
429
- overflow: ["overflowX", "overflowY"]
430
- });
431
- // Annotate the CommonJS export names for ESM import in node:
432
- 0 && (module.exports = {
433
- expandStyle,
434
- expandStyles,
435
- generateAtomicStyles
436
- });
437
- //# sourceMappingURL=generateAtomicStyles.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/helpers/generateAtomicStyles.ts"],
4
- "sourcesContent": ["/**\n * Some parts adapted from react-native-web\n * Copyright (c) Nicolas Gallagher licensed under the MIT license.\n */\n\nimport { StyleObject, simpleHash } from '@tamagui/helpers'\nimport hyphenateStyleName from 'hyphenate-style-name'\nimport normalizeCSSColor from 'normalize-css-color'\nimport { TextStyle, ViewStyle } from 'react-native'\n\nimport { getConfig } from '../conf'\nimport { isWeb } from '../constants/platform'\nimport { reversedShorthands } from '../createTamagui'\nimport { PseudoDescriptor, pseudoDescriptors } from './pseudoDescriptors'\n\ntype Value = Object | Array<any> | string | number\nexport type Style = { [key: string]: Value }\n\nclass Cache {\n values: Record<string, any> = {}\n\n get(key: string, valStr: string) {\n return this.values[key]?.[valStr]\n }\n\n set(key: string, valStr: string, object: any) {\n this.values[key] ??= {}\n this.values[key][valStr] = object\n }\n}\n\nconst cache = new Cache()\n\nexport const generateAtomicStyles = (\n style: ViewStyle & TextStyle,\n pseudo?: PseudoDescriptor\n): StyleObject[] => {\n const res = expandStyles(style)\n const out: StyleObject[] = []\n for (const key in res) {\n const value = res[key]\n if (value != null && value != undefined) {\n const valueString = normalizeValueWithProperty(value, key)\n const uid = key + (pseudo?.name || '')\n const cachedResult = cache.get(uid, valueString)\n if (cachedResult != undefined) {\n out.push(cachedResult)\n } else {\n const hash = simpleHash(uid + valueString)\n const pseudoPrefix = pseudo ? `0${pseudo.name}-` : ''\n const shortProp = reversedShorthands[key] || key\n const identifier = `_${shortProp}-${pseudoPrefix}${hash}`\n const rules = createAtomicRules(identifier, key, valueString, pseudo)\n const styleObject: StyleObject = {\n property: key,\n pseudo: pseudo?.name,\n value,\n identifier,\n rules,\n }\n cache.set(uid, valueString, styleObject)\n out.push(styleObject)\n }\n }\n }\n return out\n}\n\nconst reducedStyleKeys = {\n shadowColor: true,\n shadowOffset: true,\n shadowOpacity: true,\n shadowRadius: true,\n textShadowColor: true,\n textShadowOffset: true,\n textShadowRadius: true,\n}\n\nlet shorthands: Record<string, string> | null = null\n\n// can likely remove this and include in other loops\nexport function expandStyles(style: any) {\n const res: Record<string, any> = {}\n\n // box-shadow\n const { boxShadow, shadowColor, shadowOffset, shadowOpacity, shadowRadius } = style\n if (shadowRadius !== undefined) {\n const { height, width } = shadowOffset || defaultOffset\n const offsetX = normalizeValueWithProperty(width || 0)\n const offsetY = normalizeValueWithProperty(height || 0)\n const blurRadius = normalizeValueWithProperty(shadowRadius || 0)\n const color = normalizeColor(String(shadowColor || 'black'), shadowOpacity)\n const shadow = `${offsetX} ${offsetY} ${blurRadius} ${color}`\n res.boxShadow = boxShadow ? `${boxShadow}, ${shadow}` : shadow\n } else if (boxShadow) {\n res.boxShadow = boxShadow\n }\n\n // text-shadow\n const { textShadowColor, textShadowOffset, textShadowRadius } = style\n if (textShadowColor || textShadowOffset || textShadowRadius) {\n const { height, width } = textShadowOffset || defaultOffset\n const radius = textShadowRadius || 0\n const color = normalizeValueWithProperty(textShadowColor, 'textShadowColor')\n if (color && (height !== 0 || width !== 0 || radius !== 0)) {\n const blurRadius = normalizeValueWithProperty(radius)\n const offsetX = normalizeValueWithProperty(width)\n const offsetY = normalizeValueWithProperty(height)\n res.textShadow = `${offsetX} ${offsetY} ${blurRadius} ${color}`\n }\n }\n\n // ensure border style set by default to solid\n for (const key in borderDefaults) {\n if (key in style) {\n res[borderDefaults[key]] = style[borderDefaults[key]] || 'solid'\n }\n }\n\n for (let key in style) {\n shorthands = shorthands || getConfig().shorthands\n if (shorthands) {\n key = shorthands[key] || key\n }\n if (reducedStyleKeys[key]) continue\n if (key in pseudoDescriptors) {\n res[key] = expandStyles(style[key])\n } else {\n const val = normalizeValueWithProperty(style[key], key)\n const out = expandStyle(key, val)\n if (out) {\n Object.assign(res, Object.fromEntries(out))\n } else {\n res[key] = val\n }\n }\n }\n return res\n}\n\nconst borderDefaults = {\n borderWidth: 'borderStyle',\n borderBottomWidth: 'borderBottomStyle',\n borderTopWidth: 'borderTopStyle',\n borderLeftWidth: 'borderLeftStyle',\n borderRightWidth: 'borderRightStyle',\n}\n\nfunction createDeclarationBlock(style: Style, important = false) {\n let declarations = ''\n for (const key in style) {\n const prop = hyphenateStyleName(key)\n const value = style[key]\n declarations += `${prop}:${value}`\n }\n return `{${declarations}${important ? ` !important` : ''};}`\n}\n\nconst pseudoSelectorPrefixes = (() => {\n const res: Record<string, string> = {}\n for (const key in pseudoDescriptors) {\n const pseudo = pseudoDescriptors[key]\n res[pseudo.name] = [...Array(pseudo.priority)].map(() => ':root').join('') + ' '\n }\n return res\n})()\n\nfunction createAtomicRules(\n identifier: string,\n property: string,\n value: any,\n pseudo?: PseudoDescriptor\n): string[] {\n const selector = pseudo\n ? `${pseudoSelectorPrefixes[pseudo.name]} .${identifier}:${pseudo.name}`\n : `.${identifier}`\n const important = !!pseudo\n\n let rules: string[] = []\n\n // Handle non-standard properties and object values that require multiple\n // CSS rules to be created.\n switch (property) {\n // Equivalent to using '::placeholder'\n case 'placeholderTextColor': {\n const block = createDeclarationBlock({ color: value, opacity: 1 }, important)\n rules.push(`${selector}::placeholder${block}`)\n break\n }\n\n // Polyfill for additional 'pointer-events' values\n // See d13f78622b233a0afc0c7a200c0a0792c8ca9e58\n case 'pointerEvents': {\n let finalValue = value\n if (value === 'auto' || value === 'box-only') {\n finalValue = 'auto!important'\n if (value === 'box-only') {\n const block = createDeclarationBlock({ pointerEvents: 'none' }, important)\n rules.push(`${selector}>*${block}`)\n }\n } else if (value === 'none' || value === 'box-none') {\n finalValue = 'none!important'\n if (value === 'box-none') {\n const block = createDeclarationBlock({ pointerEvents: 'auto' }, important)\n rules.push(`${selector}>*${block}`)\n }\n }\n const block = createDeclarationBlock({ pointerEvents: finalValue }, important)\n rules.push(`${selector}${block}`)\n break\n }\n\n // Polyfill for draft spec\n // https://drafts.csswg.org/css-scrollbars-1/\n case 'scrollbarWidth': {\n if (value === 'none') {\n rules.push(`${selector}::-webkit-scrollbar{display:none}`)\n }\n const block = createDeclarationBlock({ scrollbarWidth: value }, important)\n rules.push(`${selector}${block}`)\n break\n }\n\n default: {\n const block = createDeclarationBlock({ [property]: value }, important)\n rules.push(`${selector}${block}`)\n break\n }\n }\n\n // hover styles need to be conditional\n // perhaps this can be generalized but for now lets just shortcut\n // and hardcode for hover styles, if we need to later we can\n // WEIRD SYNTAX, SEE:\n // https://stackoverflow.com/questions/40532204/media-query-for-devices-supporting-hover\n if (pseudo?.name === 'hover') {\n rules = rules.map((r) => `@media not all and (hover: none) { ${r} }`)\n }\n\n return rules\n}\n\nexport function expandStyle(key: string, value: any) {\n if (key === 'flex') {\n // The 'flex' property value in React Native must be a positive integer,\n // 0, or -1.\n if (value <= -1) {\n return [\n ['flexGrow', 0],\n ['flexShrink', 1],\n ['flexBasis', 'auto'],\n ]\n }\n // normalizing to better align with native\n // see spec for flex shorthand https://developer.mozilla.org/en-US/docs/Web/CSS/flex\n if (value >= 0) {\n return [\n ['flexGrow', value],\n ['flexShrink', 1],\n ]\n }\n return\n }\n\n // web only\n switch (key) {\n // Ignore some React Native styles\n case 'elevation':\n case 'overlayColor':\n case 'resizeMode':\n case 'tintColor': {\n break\n }\n\n case 'aspectRatio': {\n return [[key, value.toString()]]\n }\n\n // TODO: remove once this issue is fixed\n // https://github.com/rofrischmann/inline-style-prefixer/issues/159\n case 'backgroundClip': {\n if (value === 'text') {\n return [\n ['backgroundClip', value],\n ['WebkitBackgroundClip', value],\n ]\n }\n break\n }\n\n case 'textAlignVertical': {\n return [['verticalAlign', value === 'center' ? 'middle' : value]]\n }\n\n case 'textDecorationLine': {\n return [['textDecorationLine', value]]\n }\n\n case 'transform': {\n if (Array.isArray(value)) {\n return [[key, value.map(mapTransform).join(' ')]]\n }\n break\n }\n\n case 'writingDirection': {\n return [['direction', value]]\n }\n }\n\n const longKey = STYLE_SHORT_FORM_EXPANSIONS[key]\n if (longKey) {\n return longKey.map((key) => {\n return [key, value]\n })\n } else {\n if (isWeb && Array.isArray(value)) {\n return [[key, value.join(',')]]\n }\n }\n}\n\n// { scale: 2 } => 'scale(2)'\n// { translateX: 20 } => 'translateX(20px)'\n// { matrix: [1,2,3,4,5,6] } => 'matrix(1,2,3,4,5,6)'\nconst mapTransform = (transform) => {\n const type = Object.keys(transform)[0]\n const value = transform[type]\n if (type === 'matrix' || type === 'matrix3d') {\n return `${type}(${value.join(',')})`\n } else {\n const normalizedValue = normalizeValueWithProperty(value, type)\n return `${type}(${normalizedValue})`\n }\n}\n\nconst colorProps = {\n backgroundColor: true,\n borderColor: true,\n borderTopColor: true,\n borderRightColor: true,\n borderBottomColor: true,\n borderLeftColor: true,\n color: true,\n shadowColor: true,\n textDecorationColor: true,\n textShadowColor: true,\n}\n\nfunction normalizeValueWithProperty(value: any, property?: string): any {\n if (process.env.TAMAGUI_TARGET === 'web') {\n const shouldCoerceToPx =\n typeof value === 'number' &&\n (property === undefined || property === null || !unitlessNumbers[property])\n if (shouldCoerceToPx) {\n return `${value}px`\n }\n }\n if (property && colorProps[property]) {\n return normalizeColor(value)\n }\n return value\n}\n\nconst normalizeColor = (color?: number | string, opacity = 1): void | string => {\n if (color == null || color == undefined) {\n return\n }\n if (process.env.TAMAGUI_TARGET === 'web') {\n if (typeof color === 'string' && isWebColor(color)) {\n return color\n }\n }\n const colorInt = processColor(color)\n if (colorInt != null) {\n const r = (colorInt >> 16) & 255\n const g = (colorInt >> 8) & 255\n const b = colorInt & 255\n const a = ((colorInt >> 24) & 255) / 255\n const alpha = (a * opacity).toFixed(2)\n return `rgba(${r},${g},${b},${alpha})`\n }\n return `${color}`\n}\n\nconst webColors = {\n currentColor: true,\n currentcolor: true,\n transparent: true,\n inherit: true,\n}\n\nconst isWebColor = (color: string): boolean => webColors[color] || color.indexOf('var(') === 0\n\nconst processColor = (color?: number | string): number | undefined | null => {\n if (color === undefined || color === null) {\n return color\n }\n let intColor = normalizeCSSColor(color)\n if (intColor === undefined || intColor === null) {\n return undefined\n }\n return ((+intColor << 24) | (+intColor >>> 8)) >>> 0\n}\n\nconst unitlessNumbers = {\n animationIterationCount: true,\n aspectRatio: true,\n borderImageOutset: true,\n borderImageSlice: true,\n borderImageWidth: true,\n boxFlex: true,\n boxFleGroup: true,\n boxOrdinalGroup: true,\n columnCount: true,\n flex: true,\n flexGrow: true,\n flexOrder: true,\n flexPositive: true,\n flexShrink: true,\n flexNegative: true,\n fontWeight: true,\n gridRow: true,\n gridRowEnd: true,\n gridRowGap: true,\n gridRowStart: true,\n gridColumn: true,\n gridColumnEnd: true,\n gridColumnGap: true,\n gridColumnStart: true,\n lineClamp: true,\n opacity: true,\n order: true,\n orphans: true,\n tabSize: true,\n widows: true,\n zIndex: true,\n zoom: true,\n fillOpacity: true,\n floodOpacity: true,\n stopOpacity: true,\n strokeDasharray: true,\n strokeDashoffset: true,\n strokeMiterlimit: true,\n strokeOpacity: true,\n strokeWidth: true,\n scale: true,\n scaleX: true,\n scaleY: true,\n scaleZ: true,\n shadowOpacity: true,\n}\n\nconst defaultOffset = { height: 0, width: 0 }\n\nconst STYLE_SHORT_FORM_EXPANSIONS = {\n borderColor: ['borderTopColor', 'borderRightColor', 'borderBottomColor', 'borderLeftColor'],\n borderRadius: [\n 'borderTopLeftRadius',\n 'borderTopRightRadius',\n 'borderBottomRightRadius',\n 'borderBottomLeftRadius',\n ],\n borderStyle: ['borderTopStyle', 'borderRightStyle', 'borderBottomStyle', 'borderLeftStyle'],\n borderWidth: ['borderTopWidth', 'borderRightWidth', 'borderBottomWidth', 'borderLeftWidth'],\n margin: ['marginTop', 'marginRight', 'marginBottom', 'marginLeft'],\n marginHorizontal: ['marginRight', 'marginLeft'],\n marginVertical: ['marginTop', 'marginBottom'],\n overscrollBehavior: ['overscrollBehaviorX', 'overscrollBehaviorY'],\n padding: ['paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft'],\n paddingHorizontal: ['paddingRight', 'paddingLeft'],\n paddingVertical: ['paddingTop', 'paddingBottom'],\n ...(isWeb && {\n // react-native doesn't support X / Y\n overflow: ['overflowX', 'overflowY'],\n }),\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,qBAAwC;AACxC,kCAA+B;AAC/B,iCAA8B;AAG9B,kBAA0B;AAC1B,sBAAsB;AACtB,2BAAmC;AACnC,+BAAoD;AAKpD,MAAM,MAAM;AAAA,EAAZ;AACE,kBAA8B,CAAC;AAAA;AAAA,EAE/B,IAAI,KAAa,QAAgB;AArBnC;AAsBI,WAAO,WAAK,OAAO,SAAZ,mBAAmB;AAAA,EAC5B;AAAA,EAEA,IAAI,KAAa,QAAgB,QAAa;AAzBhD;AA0BI,eAAK,QAAL,mBAAqB,CAAC;AACtB,SAAK,OAAO,KAAK,UAAU;AAAA,EAC7B;AACF;AAEA,MAAM,QAAQ,IAAI,MAAM;AAEjB,MAAM,uBAAuB,CAClC,OACA,WACkB;AAClB,QAAM,MAAM,aAAa,KAAK;AAC9B,QAAM,MAAqB,CAAC;AAC5B,aAAW,OAAO,KAAK;AACrB,UAAM,QAAQ,IAAI;AAClB,QAAI,SAAS,QAAQ,SAAS,QAAW;AACvC,YAAM,cAAc,2BAA2B,OAAO,GAAG;AACzD,YAAM,MAAM,MAAO,mCAAQ,SAAQ;AACnC,YAAM,eAAe,MAAM,IAAI,KAAK,WAAW;AA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1
- {
2
- "version": 3,
3
- "sources": ["../../../src/helpers/getTextSize.tsx"],
4
- "sourcesContent": ["import { getVariableValue } from '../createVariable'\nimport { FontSizeTokens, TextProps, VariantSpreadFunction } from '../types'\n\nexport const getTextSize: VariantSpreadFunction<TextProps, FontSizeTokens> = (\n val = '$4',\n { fonts, theme, props }\n) => {\n const family = getVariableValue(props.fontFamily) || '$body'\n const font = fonts[family] || fonts['$body']\n if (!font) {\n console.warn('\u26A0\uFE0F no font found', { family, fontTokens: Object.keys(fonts), val })\n return {} as any\n }\n const fontFamily = font.family\n const fontSize = props.fontSize || font.size[val]\n const lineHeight = props.lineHeight || font.lineHeight[val]\n const fontWeight = props.fontWeight || font.weight[val]\n const letterSpacing = props.letterSpacing || font.letterSpacing[val]\n const fontStyle = props.fontStyle || font.style?.[val]\n const textTransform = props.textTransform || font.transform?.[val]\n const color = props.color || font.color?.[val] || theme.color\n return {\n color,\n fontStyle,\n textTransform,\n fontFamily,\n fontWeight,\n letterSpacing,\n fontSize,\n lineHeight,\n } as any\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAAiC;AAG1B,MAAM,cAAgE,CAC3E,MAAM,MACN,EAAE,OAAO,OAAO,YACb;AANL;AAOE,QAAM,SAAS,4CAAiB,MAAM,UAAU,KAAK;AACrD,QAAM,OAAO,MAAM,WAAW,MAAM;AACpC,MAAI,CAAC,MAAM;AACT,YAAQ,KAAK,8BAAoB,EAAE,QAAQ,YAAY,OAAO,KAAK,KAAK,GAAG,IAAI,CAAC;AAChF,WAAO,CAAC;AAAA,EACV;AACA,QAAM,aAAa,KAAK;AACxB,QAAM,WAAW,MAAM,YAAY,KAAK,KAAK;AAC7C,QAAM,aAAa,MAAM,cAAc,KAAK,WAAW;AACvD,QAAM,aAAa,MAAM,cAAc,KAAK,OAAO;AACnD,QAAM,gBAAgB,MAAM,iBAAiB,KAAK,cAAc;AAChE,QAAM,YAAY,MAAM,aAAa,YAAK,UAAL,mBAAa;AAClD,QAAM,gBAAgB,MAAM,iBAAiB,YAAK,cAAL,mBAAiB;AAC9D,QAAM,QAAQ,MAAM,SAAS,YAAK,UAAL,mBAAa,SAAQ,MAAM;AACxD,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
6
- "names": []
7
- }
@@ -1,164 +0,0 @@
1
- import { accessibilityRoleToWebRole, processIDRefList } from "./createComponent";
2
- function assignNativePropsToWeb(elementType, viewProps, nativeProps) {
3
- if (!viewProps.role && nativeProps.accessibilityRole) {
4
- if (nativeProps.accessibilityRole === "none") {
5
- viewProps.role = "presentation";
6
- } else {
7
- const webRole = accessibilityRoleToWebRole[nativeProps.accessibilityRole];
8
- if (webRole != null) {
9
- viewProps.role = webRole || nativeProps.accessibilityRole;
10
- }
11
- }
12
- }
13
- if (nativeProps.accessibilityActiveDescendant != null) {
14
- viewProps["aria-activedescendant"] = nativeProps.accessibilityActiveDescendant;
15
- }
16
- if (nativeProps.accessibilityAtomic != null) {
17
- viewProps["aria-atomic"] = nativeProps.accessibilityAtomic;
18
- }
19
- if (nativeProps.accessibilityAutoComplete != null) {
20
- viewProps["aria-autocomplete"] = nativeProps.accessibilityAutoComplete;
21
- }
22
- if (nativeProps.accessibilityBusy != null) {
23
- viewProps["aria-busy"] = nativeProps.accessibilityBusy;
24
- }
25
- if (nativeProps.accessibilityChecked != null) {
26
- viewProps["aria-checked"] = nativeProps.accessibilityChecked;
27
- }
28
- if (nativeProps.accessibilityColumnCount != null) {
29
- viewProps["aria-colcount"] = nativeProps.accessibilityColumnCount;
30
- }
31
- if (nativeProps.accessibilityColumnIndex != null) {
32
- viewProps["aria-colindex"] = nativeProps.accessibilityColumnIndex;
33
- }
34
- if (nativeProps.accessibilityColumnSpan != null) {
35
- viewProps["aria-colspan"] = nativeProps.accessibilityColumnSpan;
36
- }
37
- if (nativeProps.accessibilityControls != null) {
38
- viewProps["aria-controls"] = processIDRefList(nativeProps.accessibilityControls);
39
- }
40
- if (nativeProps.accessibilityCurrent != null) {
41
- viewProps["aria-current"] = nativeProps.accessibilityCurrent;
42
- }
43
- if (nativeProps.accessibilityDescribedBy != null) {
44
- viewProps["aria-describedby"] = processIDRefList(nativeProps.accessibilityDescribedBy);
45
- }
46
- if (nativeProps.accessibilityDetails != null) {
47
- viewProps["aria-details"] = nativeProps.accessibilityDetails;
48
- }
49
- if (nativeProps.disabled === true) {
50
- viewProps["aria-disabled"] = true;
51
- if (elementType === "button" || elementType === "form" || elementType === "input" || elementType === "select" || elementType === "textarea") {
52
- viewProps.disabled = true;
53
- }
54
- }
55
- if (nativeProps.accessibilityErrorMessage != null) {
56
- viewProps["aria-errormessage"] = nativeProps.accessibilityErrorMessage;
57
- }
58
- if (nativeProps.accessibilityExpanded != null) {
59
- viewProps["aria-expanded"] = nativeProps.accessibilityExpanded;
60
- }
61
- if (nativeProps.accessibilityFlowTo != null) {
62
- viewProps["aria-flowto"] = processIDRefList(nativeProps.accessibilityFlowTo);
63
- }
64
- if (nativeProps.accessibilityHasPopup != null) {
65
- viewProps["aria-haspopup"] = nativeProps.accessibilityHasPopup;
66
- }
67
- if (nativeProps.accessibilityHidden === true) {
68
- viewProps["aria-hidden"] = nativeProps.accessibilityHidden;
69
- }
70
- if (nativeProps.accessibilityInvalid != null) {
71
- viewProps["aria-invalid"] = nativeProps.accessibilityInvalid;
72
- }
73
- if (nativeProps.accessibilityKeyShortcuts != null && Array.isArray(nativeProps.accessibilityKeyShortcuts)) {
74
- viewProps["aria-keyshortcuts"] = nativeProps.accessibilityKeyShortcuts.join(" ");
75
- }
76
- if (nativeProps.accessibilityLabel != null) {
77
- viewProps["aria-label"] = nativeProps.accessibilityLabel;
78
- }
79
- if (nativeProps.accessibilityLabelledBy != null) {
80
- viewProps["aria-labelledby"] = processIDRefList(nativeProps.accessibilityLabelledBy);
81
- }
82
- if (nativeProps.accessibilityLevel != null) {
83
- viewProps["aria-level"] = nativeProps.accessibilityLevel;
84
- }
85
- if (nativeProps.accessibilityLiveRegion != null) {
86
- viewProps["aria-live"] = nativeProps.accessibilityLiveRegion === "none" ? "off" : nativeProps.accessibilityLiveRegion;
87
- }
88
- if (nativeProps.accessibilityModal != null) {
89
- viewProps["aria-modal"] = nativeProps.accessibilityModal;
90
- }
91
- if (nativeProps.accessibilityMultiline != null) {
92
- viewProps["aria-multiline"] = nativeProps.accessibilityMultiline;
93
- }
94
- if (nativeProps.accessibilityMultiSelectable != null) {
95
- viewProps["aria-multiselectable"] = nativeProps.accessibilityMultiSelectable;
96
- }
97
- if (nativeProps.accessibilityOrientation != null) {
98
- viewProps["aria-orientation"] = nativeProps.accessibilityOrientation;
99
- }
100
- if (nativeProps.accessibilityOwns != null) {
101
- viewProps["aria-owns"] = processIDRefList(nativeProps.accessibilityOwns);
102
- }
103
- if (nativeProps.accessibilityPlaceholder != null) {
104
- viewProps["aria-placeholder"] = nativeProps.accessibilityPlaceholder;
105
- }
106
- if (nativeProps.accessibilityPosInSet != null) {
107
- viewProps["aria-posinset"] = nativeProps.accessibilityPosInSet;
108
- }
109
- if (nativeProps.accessibilityPressed != null) {
110
- viewProps["aria-pressed"] = nativeProps.accessibilityPressed;
111
- }
112
- if (nativeProps.accessibilityReadOnly != null) {
113
- viewProps["aria-readonly"] = nativeProps.accessibilityReadOnly;
114
- if (elementType === "input" || elementType === "select" || elementType === "textarea") {
115
- viewProps.readOnly = true;
116
- }
117
- }
118
- if (nativeProps.accessibilityRequired != null) {
119
- viewProps["aria-required"] = nativeProps.accessibilityRequired;
120
- if (elementType === "input" || elementType === "select" || elementType === "textarea") {
121
- viewProps.required = true;
122
- }
123
- }
124
- if (nativeProps.accessibilityRoleDescription != null) {
125
- viewProps["aria-roledescription"] = nativeProps.accessibilityRoleDescription;
126
- }
127
- if (nativeProps.accessibilityRowCount != null) {
128
- viewProps["aria-rowcount"] = nativeProps.accessibilityRowCount;
129
- }
130
- if (nativeProps.accessibilityRowIndex != null) {
131
- viewProps["aria-rowindex"] = nativeProps.accessibilityRowIndex;
132
- }
133
- if (nativeProps.accessibilityRowSpan != null) {
134
- viewProps["aria-rowspan"] = nativeProps.accessibilityRowSpan;
135
- }
136
- if (nativeProps.accessibilitySelected != null) {
137
- viewProps["aria-selected"] = nativeProps.accessibilitySelected;
138
- }
139
- if (nativeProps.accessibilitySetSize != null) {
140
- viewProps["aria-setsize"] = nativeProps.accessibilitySetSize;
141
- }
142
- if (nativeProps.accessibilitySort != null) {
143
- viewProps["aria-sort"] = nativeProps.accessibilitySort;
144
- }
145
- if (nativeProps.accessibilityValueMax != null) {
146
- viewProps["aria-valuemax"] = nativeProps.accessibilityValueMax;
147
- }
148
- if (nativeProps.accessibilityValueMin != null) {
149
- viewProps["aria-valuemin"] = nativeProps.accessibilityValueMin;
150
- }
151
- if (nativeProps.accessibilityValueNow != null) {
152
- viewProps["aria-valuenow"] = nativeProps.accessibilityValueNow;
153
- }
154
- if (nativeProps.accessibilityValueText != null) {
155
- viewProps["aria-valuetext"] = nativeProps.accessibilityValueText;
156
- }
157
- if (nativeProps.nativeID) {
158
- viewProps.id = nativeProps.nativeID;
159
- }
160
- }
161
- export {
162
- assignNativePropsToWeb
163
- };
164
- //# sourceMappingURL=assignNativePropsToWeb.js.map