react-native-css 3.0.0-nightly.75f8b74 → 3.0.0-nightly.d8cb1bc
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.
- package/dist/commonjs/compiler/atRules.js +1 -1
- package/dist/commonjs/compiler/attributes.test.js +1 -1
- package/dist/commonjs/compiler/attributes.test.js.map +1 -1
- package/dist/commonjs/compiler/compiler.js +26 -17
- package/dist/commonjs/compiler/compiler.js.map +1 -1
- package/dist/commonjs/compiler/declarations.js +164 -72
- package/dist/commonjs/compiler/declarations.js.map +1 -1
- package/dist/commonjs/compiler/inheritance.test.js +7 -7
- package/dist/commonjs/compiler/inheritance.test.js.map +1 -1
- package/dist/commonjs/compiler/selector-builder.js +457 -0
- package/dist/commonjs/compiler/selector-builder.js.map +1 -0
- package/dist/commonjs/compiler/selectors.js +10 -6
- package/dist/commonjs/compiler/selectors.js.map +1 -1
- package/dist/commonjs/compiler/stylesheet.js +113 -39
- package/dist/commonjs/compiler/stylesheet.js.map +1 -1
- package/dist/commonjs/jest/index.js +16 -5
- package/dist/commonjs/jest/index.js.map +1 -1
- package/dist/commonjs/metro/index.js +1 -1
- package/dist/commonjs/metro/index.js.map +1 -1
- package/dist/commonjs/poison.pill.js +4 -1
- package/dist/commonjs/poison.pill.js.map +1 -1
- package/dist/commonjs/runtime/native/conditions/attributes.js +42 -0
- package/dist/commonjs/runtime/native/conditions/attributes.js.map +1 -0
- package/dist/commonjs/runtime/native/conditions/container-query.js +28 -21
- package/dist/commonjs/runtime/native/conditions/container-query.js.map +1 -1
- package/dist/commonjs/runtime/native/conditions/guards.js.map +1 -1
- package/dist/commonjs/runtime/native/conditions/index.js +10 -46
- package/dist/commonjs/runtime/native/conditions/index.js.map +1 -1
- package/dist/commonjs/runtime/native/conditions/media-query.js +17 -17
- package/dist/commonjs/runtime/native/conditions/media-query.js.map +1 -1
- package/dist/commonjs/runtime/native/injection.js +3 -2
- package/dist/commonjs/runtime/native/injection.js.map +1 -1
- package/dist/commonjs/runtime/native/react/interaction.js +10 -10
- package/dist/commonjs/runtime/native/react/interaction.js.map +1 -1
- package/dist/commonjs/runtime/native/react/rules.js +9 -9
- package/dist/commonjs/runtime/native/react/rules.js.map +1 -1
- package/dist/commonjs/runtime/native/react/useNativeCss.js +1 -0
- package/dist/commonjs/runtime/native/react/useNativeCss.js.map +1 -1
- package/dist/commonjs/runtime/native/reactivity.js +1 -12
- package/dist/commonjs/runtime/native/reactivity.js.map +1 -1
- package/dist/commonjs/runtime/native/root.js +28 -0
- package/dist/commonjs/runtime/native/root.js.map +1 -0
- package/dist/commonjs/runtime/native/styles/calculate-props.js +53 -48
- package/dist/commonjs/runtime/native/styles/calculate-props.js.map +1 -1
- package/dist/commonjs/runtime/native/styles/index.js +12 -12
- package/dist/commonjs/runtime/native/styles/index.js.map +1 -1
- package/dist/commonjs/runtime/native/styles/units.js +6 -3
- package/dist/commonjs/runtime/native/styles/units.js.map +1 -1
- package/dist/commonjs/runtime/native/styles/variables.js +3 -2
- package/dist/commonjs/runtime/native/styles/variables.js.map +1 -1
- package/dist/commonjs/runtime/utils/specificity.js +2 -1
- package/dist/commonjs/runtime/utils/specificity.js.map +1 -1
- package/dist/module/compiler/atRules.js +1 -1
- package/dist/module/compiler/attributes.test.js +1 -1
- package/dist/module/compiler/attributes.test.js.map +1 -1
- package/dist/module/compiler/compiler.js +26 -17
- package/dist/module/compiler/compiler.js.map +1 -1
- package/dist/module/compiler/compiler.types.js.map +1 -1
- package/dist/module/compiler/declarations.js +159 -68
- package/dist/module/compiler/declarations.js.map +1 -1
- package/dist/module/compiler/inheritance.test.js +7 -7
- package/dist/module/compiler/inheritance.test.js.map +1 -1
- package/dist/module/compiler/selector-builder.js +452 -0
- package/dist/module/compiler/selector-builder.js.map +1 -0
- package/dist/module/compiler/selectors.js +10 -6
- package/dist/module/compiler/selectors.js.map +1 -1
- package/dist/module/compiler/stylesheet.js +112 -38
- package/dist/module/compiler/stylesheet.js.map +1 -1
- package/dist/module/jest/index.js +16 -4
- package/dist/module/jest/index.js.map +1 -1
- package/dist/module/metro/index.js +1 -1
- package/dist/module/metro/index.js.map +1 -1
- package/dist/module/poison.pill.js +4 -1
- package/dist/module/poison.pill.js.map +1 -1
- package/dist/module/runtime/native/conditions/attributes.js +38 -0
- package/dist/module/runtime/native/conditions/attributes.js.map +1 -0
- package/dist/module/runtime/native/conditions/container-query.js +28 -21
- package/dist/module/runtime/native/conditions/container-query.js.map +1 -1
- package/dist/module/runtime/native/conditions/guards.js.map +1 -1
- package/dist/module/runtime/native/conditions/index.js +10 -46
- package/dist/module/runtime/native/conditions/index.js.map +1 -1
- package/dist/module/runtime/native/conditions/media-query.js +17 -17
- package/dist/module/runtime/native/conditions/media-query.js.map +1 -1
- package/dist/module/runtime/native/injection.js +2 -1
- package/dist/module/runtime/native/injection.js.map +1 -1
- package/dist/module/runtime/native/react/interaction.js +10 -10
- package/dist/module/runtime/native/react/interaction.js.map +1 -1
- package/dist/module/runtime/native/react/rules.js +9 -9
- package/dist/module/runtime/native/react/rules.js.map +1 -1
- package/dist/module/runtime/native/react/useNativeCss.js +1 -0
- package/dist/module/runtime/native/react/useNativeCss.js.map +1 -1
- package/dist/module/runtime/native/reactivity.js +0 -11
- package/dist/module/runtime/native/reactivity.js.map +1 -1
- package/dist/module/runtime/native/root.js +24 -0
- package/dist/module/runtime/native/root.js.map +1 -0
- package/dist/module/runtime/native/styles/calculate-props.js +53 -48
- package/dist/module/runtime/native/styles/calculate-props.js.map +1 -1
- package/dist/module/runtime/native/styles/index.js +12 -12
- package/dist/module/runtime/native/styles/index.js.map +1 -1
- package/dist/module/runtime/native/styles/units.js +6 -3
- package/dist/module/runtime/native/styles/units.js.map +1 -1
- package/dist/module/runtime/native/styles/variables.js +2 -1
- package/dist/module/runtime/native/styles/variables.js.map +1 -1
- package/dist/module/runtime/utils/specificity.js +2 -1
- package/dist/module/runtime/utils/specificity.js.map +1 -1
- package/dist/typescript/commonjs/src/compiler/compiler.d.ts +9 -2
- package/dist/typescript/commonjs/src/compiler/compiler.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/compiler/compiler.types.d.ts +5 -4
- package/dist/typescript/commonjs/src/compiler/compiler.types.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/compiler/declarations.d.ts +16 -19
- package/dist/typescript/commonjs/src/compiler/declarations.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/compiler/selector-builder.d.ts +23 -0
- package/dist/typescript/commonjs/src/compiler/selector-builder.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/compiler/selectors.d.ts +3 -2
- package/dist/typescript/commonjs/src/compiler/selectors.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/compiler/stylesheet.d.ts +21 -7
- package/dist/typescript/commonjs/src/compiler/stylesheet.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/jest/index.d.ts +8 -1
- package/dist/typescript/commonjs/src/jest/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/metro/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/poison.pill.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/runtime/native/conditions/attributes.d.ts +5 -0
- package/dist/typescript/commonjs/src/runtime/native/conditions/attributes.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/conditions/container-query.d.ts +3 -3
- package/dist/typescript/commonjs/src/runtime/native/conditions/container-query.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/runtime/native/conditions/guards.d.ts +2 -2
- package/dist/typescript/commonjs/src/runtime/native/conditions/guards.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/runtime/native/conditions/index.d.ts +2 -2
- package/dist/typescript/commonjs/src/runtime/native/conditions/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/runtime/native/conditions/media-query.d.ts +2 -2
- package/dist/typescript/commonjs/src/runtime/native/conditions/media-query.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/runtime/native/injection.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/runtime/native/react/interaction.d.ts +2 -2
- package/dist/typescript/commonjs/src/runtime/native/react/interaction.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/runtime/native/react/useNativeCss.d.ts +2 -1
- package/dist/typescript/commonjs/src/runtime/native/react/useNativeCss.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/runtime/native/reactivity.d.ts +2 -10
- package/dist/typescript/commonjs/src/runtime/native/reactivity.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/runtime/native/root.d.ts +11 -0
- package/dist/typescript/commonjs/src/runtime/native/root.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/calculate-props.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/runtime/native/styles/units.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/runtime/native/styles/variables.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/runtime/utils/specificity.d.ts +1 -0
- package/dist/typescript/commonjs/src/runtime/utils/specificity.d.ts.map +1 -1
- package/dist/typescript/module/src/compiler/compiler.d.ts +9 -2
- package/dist/typescript/module/src/compiler/compiler.d.ts.map +1 -1
- package/dist/typescript/module/src/compiler/compiler.types.d.ts +5 -4
- package/dist/typescript/module/src/compiler/compiler.types.d.ts.map +1 -1
- package/dist/typescript/module/src/compiler/declarations.d.ts +16 -19
- package/dist/typescript/module/src/compiler/declarations.d.ts.map +1 -1
- package/dist/typescript/module/src/compiler/selector-builder.d.ts +23 -0
- package/dist/typescript/module/src/compiler/selector-builder.d.ts.map +1 -0
- package/dist/typescript/module/src/compiler/selectors.d.ts +3 -2
- package/dist/typescript/module/src/compiler/selectors.d.ts.map +1 -1
- package/dist/typescript/module/src/compiler/stylesheet.d.ts +21 -7
- package/dist/typescript/module/src/compiler/stylesheet.d.ts.map +1 -1
- package/dist/typescript/module/src/jest/index.d.ts +8 -1
- package/dist/typescript/module/src/jest/index.d.ts.map +1 -1
- package/dist/typescript/module/src/metro/index.d.ts.map +1 -1
- package/dist/typescript/module/src/poison.pill.d.ts.map +1 -1
- package/dist/typescript/module/src/runtime/native/conditions/attributes.d.ts +5 -0
- package/dist/typescript/module/src/runtime/native/conditions/attributes.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/conditions/container-query.d.ts +3 -3
- package/dist/typescript/module/src/runtime/native/conditions/container-query.d.ts.map +1 -1
- package/dist/typescript/module/src/runtime/native/conditions/guards.d.ts +2 -2
- package/dist/typescript/module/src/runtime/native/conditions/guards.d.ts.map +1 -1
- package/dist/typescript/module/src/runtime/native/conditions/index.d.ts +2 -2
- package/dist/typescript/module/src/runtime/native/conditions/index.d.ts.map +1 -1
- package/dist/typescript/module/src/runtime/native/conditions/media-query.d.ts +2 -2
- package/dist/typescript/module/src/runtime/native/conditions/media-query.d.ts.map +1 -1
- package/dist/typescript/module/src/runtime/native/injection.d.ts.map +1 -1
- package/dist/typescript/module/src/runtime/native/react/interaction.d.ts +2 -2
- package/dist/typescript/module/src/runtime/native/react/interaction.d.ts.map +1 -1
- package/dist/typescript/module/src/runtime/native/react/useNativeCss.d.ts +2 -1
- package/dist/typescript/module/src/runtime/native/react/useNativeCss.d.ts.map +1 -1
- package/dist/typescript/module/src/runtime/native/reactivity.d.ts +2 -10
- package/dist/typescript/module/src/runtime/native/reactivity.d.ts.map +1 -1
- package/dist/typescript/module/src/runtime/native/root.d.ts +11 -0
- package/dist/typescript/module/src/runtime/native/root.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/styles/calculate-props.d.ts.map +1 -1
- package/dist/typescript/module/src/runtime/native/styles/units.d.ts.map +1 -1
- package/dist/typescript/module/src/runtime/native/styles/variables.d.ts.map +1 -1
- package/dist/typescript/module/src/runtime/utils/specificity.d.ts +1 -0
- package/dist/typescript/module/src/runtime/utils/specificity.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/compiler/atRules.ts +1 -1
- package/src/compiler/attributes.test.ts +1 -1
- package/src/compiler/compiler.ts +30 -31
- package/src/compiler/compiler.types.ts +7 -5
- package/src/compiler/declarations.ts +273 -67
- package/src/compiler/inheritance.test.ts +6 -6
- package/src/compiler/selector-builder.ts +531 -0
- package/src/compiler/selectors.ts +20 -6
- package/src/compiler/stylesheet.ts +154 -45
- package/src/jest/index.ts +19 -4
- package/src/metro/index.ts +6 -3
- package/src/poison.pill.ts +5 -1
- package/src/runtime/native/conditions/attributes.ts +52 -0
- package/src/runtime/native/conditions/container-query.ts +27 -22
- package/src/runtime/native/conditions/guards.ts +1 -2
- package/src/runtime/native/conditions/index.ts +12 -66
- package/src/runtime/native/conditions/media-query.ts +18 -20
- package/src/runtime/native/injection.ts +1 -1
- package/src/runtime/native/react/interaction.ts +12 -12
- package/src/runtime/native/react/rules.ts +9 -9
- package/src/runtime/native/react/useNativeCss.ts +3 -0
- package/src/runtime/native/reactivity.ts +2 -21
- package/src/runtime/native/root.ts +31 -0
- package/src/runtime/native/styles/calculate-props.ts +59 -49
- package/src/runtime/native/styles/index.ts +12 -12
- package/src/runtime/native/styles/units.ts +7 -3
- package/src/runtime/native/styles/variables.ts +2 -6
- package/src/runtime/utils/specificity.ts +1 -0
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import Color from "colorjs.io";
|
|
4
4
|
import type {
|
|
5
5
|
Angle,
|
|
6
|
-
BorderBlockColor,
|
|
7
6
|
BorderSideWidth,
|
|
8
7
|
BorderStyle,
|
|
9
8
|
ColorOrAuto,
|
|
@@ -92,37 +91,44 @@ const parsers: {
|
|
|
92
91
|
"block-size": parseSizeDeclaration,
|
|
93
92
|
"border": parseBorder,
|
|
94
93
|
"border-block": parseBorderBlock,
|
|
95
|
-
"border-block-color":
|
|
94
|
+
"border-block-color": parseBorderColor,
|
|
96
95
|
"border-block-end": parseBorderBlockEnd,
|
|
97
96
|
"border-block-end-color": parseColorDeclaration,
|
|
98
97
|
"border-block-end-width": parseBorderSideWidthDeclaration,
|
|
99
98
|
"border-block-start": parseBorderBlockStart,
|
|
100
99
|
"border-block-start-color": parseColorDeclaration,
|
|
101
100
|
"border-block-start-width": parseBorderSideWidthDeclaration,
|
|
101
|
+
"border-block-style": parseBorderBlockStyle,
|
|
102
102
|
"border-block-width": parseBorderBlockWidth,
|
|
103
103
|
"border-bottom": parseBorderSide,
|
|
104
104
|
"border-bottom-color": parseColorDeclaration,
|
|
105
105
|
"border-bottom-left-radius": parseSize2DDimensionPercentageDeclaration,
|
|
106
106
|
"border-bottom-right-radius": parseSize2DDimensionPercentageDeclaration,
|
|
107
|
+
"border-bottom-style": parseBorderStyleDeclaration,
|
|
107
108
|
"border-bottom-width": parseBorderSideWidthDeclaration,
|
|
108
109
|
"border-color": parseBorderColor,
|
|
109
110
|
"border-end-end-radius": parseSize2DDimensionPercentageDeclaration,
|
|
110
111
|
"border-end-start-radius": parseSize2DDimensionPercentageDeclaration,
|
|
111
112
|
"border-inline": parseBorderInline,
|
|
112
|
-
"border-inline-color":
|
|
113
|
+
"border-inline-color": parseBorderColor,
|
|
113
114
|
"border-inline-end": parseBorderInlineEnd,
|
|
114
115
|
"border-inline-end-color": parseColorDeclaration,
|
|
116
|
+
"border-inline-end-style": parseBorderInlineStyle,
|
|
115
117
|
"border-inline-end-width": parseBorderSideWidthDeclaration,
|
|
116
118
|
"border-inline-start": parseBorderInlineStart,
|
|
117
119
|
"border-inline-start-color": parseColorDeclaration,
|
|
120
|
+
"border-inline-start-style": parseBorderInlineStyle,
|
|
118
121
|
"border-inline-start-width": parseBorderSideWidthDeclaration,
|
|
119
|
-
"border-inline-
|
|
122
|
+
"border-inline-style": parseBorderInlineStyle,
|
|
123
|
+
"border-inline-width": parseBorderInlineWidth,
|
|
120
124
|
"border-left": parseBorderSide,
|
|
121
125
|
"border-left-color": parseColorDeclaration,
|
|
126
|
+
"border-left-style": parseBorderStyleDeclaration,
|
|
122
127
|
"border-left-width": parseBorderSideWidthDeclaration,
|
|
123
128
|
"border-radius": parseBorderRadius,
|
|
124
129
|
"border-right": parseBorderSide,
|
|
125
130
|
"border-right-color": parseColorDeclaration,
|
|
131
|
+
"border-right-style": parseBorderStyleDeclaration,
|
|
126
132
|
"border-right-width": parseBorderSideWidthDeclaration,
|
|
127
133
|
"border-start-end-radius": parseSize2DDimensionPercentageDeclaration,
|
|
128
134
|
"border-start-start-radius": parseSize2DDimensionPercentageDeclaration,
|
|
@@ -131,11 +137,12 @@ const parsers: {
|
|
|
131
137
|
"border-top-color": parseColorDeclaration,
|
|
132
138
|
"border-top-left-radius": parseSize2DDimensionPercentageDeclaration,
|
|
133
139
|
"border-top-right-radius": parseSize2DDimensionPercentageDeclaration,
|
|
140
|
+
"border-top-style": parseBorderStyleDeclaration,
|
|
134
141
|
"border-top-width": parseBorderSideWidthDeclaration,
|
|
135
142
|
"border-width": parseBorderWidth,
|
|
136
143
|
"bottom": parseSizeDeclaration,
|
|
137
144
|
"box-shadow": parseBoxShadow,
|
|
138
|
-
"caret-color":
|
|
145
|
+
"caret-color": parseCaretColor,
|
|
139
146
|
"color": parseFontColorDeclaration,
|
|
140
147
|
"column-gap": parseGap,
|
|
141
148
|
"container": parseContainer,
|
|
@@ -237,6 +244,17 @@ const parsers: {
|
|
|
237
244
|
|
|
238
245
|
const validProperties = new Set(Object.keys(parsers));
|
|
239
246
|
|
|
247
|
+
function parseCaretColor(
|
|
248
|
+
declaration: DeclarationType<"caret-color">,
|
|
249
|
+
builder: StylesheetBuilder,
|
|
250
|
+
) {
|
|
251
|
+
builder.addMapping({ [declaration.property]: ["cursorColor"] });
|
|
252
|
+
builder.addDescriptor(
|
|
253
|
+
"caret-color",
|
|
254
|
+
parseColorOrAutoDeclaration(declaration, builder),
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
|
|
240
258
|
export function parseDeclaration(
|
|
241
259
|
declaration: Declaration,
|
|
242
260
|
builder: StylesheetBuilder,
|
|
@@ -256,9 +274,9 @@ export function parseDeclaration(
|
|
|
256
274
|
}
|
|
257
275
|
|
|
258
276
|
if (declaration.property === "unparsed") {
|
|
259
|
-
|
|
277
|
+
parseUnparsedDeclaration(declaration, builder);
|
|
260
278
|
} else if (declaration.property === "custom") {
|
|
261
|
-
|
|
279
|
+
parseCustomDeclaration(declaration, builder);
|
|
262
280
|
} else {
|
|
263
281
|
parseWithParser(declaration, builder);
|
|
264
282
|
}
|
|
@@ -270,6 +288,7 @@ function parseWithParser(declaration: Declaration, builder: StylesheetBuilder) {
|
|
|
270
288
|
|
|
271
289
|
builder.descriptorProperty = declaration.property;
|
|
272
290
|
|
|
291
|
+
builder.setWarningProperty(declaration.property);
|
|
273
292
|
const value = parser(declaration, builder, declaration.property);
|
|
274
293
|
|
|
275
294
|
if (value !== undefined) {
|
|
@@ -343,15 +362,41 @@ function parseBorderRadius(
|
|
|
343
362
|
}
|
|
344
363
|
|
|
345
364
|
function parseBorderColor(
|
|
346
|
-
|
|
365
|
+
declaration: DeclarationType<
|
|
366
|
+
"border-color" | "border-block-color" | "border-inline-color"
|
|
367
|
+
>,
|
|
347
368
|
builder: StylesheetBuilder,
|
|
348
369
|
) {
|
|
349
|
-
|
|
350
|
-
"border-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
370
|
+
switch (declaration.property) {
|
|
371
|
+
case "border-color":
|
|
372
|
+
builder.addShorthand("border-color", {
|
|
373
|
+
"border-top-color": parseColor(declaration.value.top, builder),
|
|
374
|
+
"border-bottom-color": parseColor(declaration.value.bottom, builder),
|
|
375
|
+
"border-left-color": parseColor(declaration.value.left, builder),
|
|
376
|
+
"border-right-color": parseColor(declaration.value.right, builder),
|
|
377
|
+
});
|
|
378
|
+
break;
|
|
379
|
+
case "border-block-color":
|
|
380
|
+
builder.addDescriptor(
|
|
381
|
+
"border-top-color",
|
|
382
|
+
parseColor(declaration.value.start, builder),
|
|
383
|
+
);
|
|
384
|
+
builder.addDescriptor(
|
|
385
|
+
"border-bottom-color",
|
|
386
|
+
parseColor(declaration.value.end, builder),
|
|
387
|
+
);
|
|
388
|
+
break;
|
|
389
|
+
case "border-inline-color":
|
|
390
|
+
builder.addDescriptor(
|
|
391
|
+
"border-left-color",
|
|
392
|
+
parseColor(declaration.value.start, builder),
|
|
393
|
+
);
|
|
394
|
+
builder.addDescriptor(
|
|
395
|
+
"border-right-color",
|
|
396
|
+
parseColor(declaration.value.end, builder),
|
|
397
|
+
);
|
|
398
|
+
break;
|
|
399
|
+
}
|
|
355
400
|
}
|
|
356
401
|
|
|
357
402
|
function parseBorderWidth(
|
|
@@ -475,6 +520,43 @@ function parseBorderInlineEnd(
|
|
|
475
520
|
);
|
|
476
521
|
}
|
|
477
522
|
|
|
523
|
+
export function parseBorderInlineWidth(
|
|
524
|
+
declaration: DeclarationType<"border-inline-width">,
|
|
525
|
+
builder: StylesheetBuilder,
|
|
526
|
+
) {
|
|
527
|
+
builder.addDescriptor(
|
|
528
|
+
"border-left-width",
|
|
529
|
+
parseBorderSideWidth(declaration.value.start, builder),
|
|
530
|
+
);
|
|
531
|
+
builder.addDescriptor(
|
|
532
|
+
"border-right-width",
|
|
533
|
+
parseBorderSideWidth(declaration.value.end, builder),
|
|
534
|
+
);
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
export function parseBorderInlineStyle(
|
|
538
|
+
declaration: DeclarationType<
|
|
539
|
+
| "border-inline-style"
|
|
540
|
+
| "border-inline-start-style"
|
|
541
|
+
| "border-inline-end-style"
|
|
542
|
+
>,
|
|
543
|
+
builder: StylesheetBuilder,
|
|
544
|
+
) {
|
|
545
|
+
if (typeof declaration.value === "string") {
|
|
546
|
+
builder.addDescriptor(
|
|
547
|
+
"border-style",
|
|
548
|
+
parseBorderStyle(declaration.value, builder),
|
|
549
|
+
);
|
|
550
|
+
} else if (declaration.value.start === declaration.value.end) {
|
|
551
|
+
builder.addDescriptor(
|
|
552
|
+
"border-style",
|
|
553
|
+
parseBorderStyle(declaration.value.start, builder),
|
|
554
|
+
);
|
|
555
|
+
} else {
|
|
556
|
+
builder.addWarning("property", "border-inline-style");
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
|
|
478
560
|
function parseFlexFlow(
|
|
479
561
|
{ value }: DeclarationType<"flex-flow">,
|
|
480
562
|
builder: StylesheetBuilder,
|
|
@@ -743,7 +825,17 @@ function parseLetterSpacing(
|
|
|
743
825
|
if (value.type === "normal") {
|
|
744
826
|
return;
|
|
745
827
|
}
|
|
746
|
-
|
|
828
|
+
const descriptor = parseLength(value.value, builder);
|
|
829
|
+
|
|
830
|
+
if (
|
|
831
|
+
Array.isArray(descriptor) &&
|
|
832
|
+
descriptor[1] === "em" &&
|
|
833
|
+
typeof descriptor[2] === "number"
|
|
834
|
+
) {
|
|
835
|
+
return descriptor[2];
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
return descriptor;
|
|
747
839
|
}
|
|
748
840
|
|
|
749
841
|
function parseTextDecoration(
|
|
@@ -772,7 +864,11 @@ function parseZIndex(
|
|
|
772
864
|
}
|
|
773
865
|
}
|
|
774
866
|
|
|
775
|
-
function parseContainerType(
|
|
867
|
+
function parseContainerType(
|
|
868
|
+
_declaration: DeclarationType<"container-type">,
|
|
869
|
+
builder: StylesheetBuilder,
|
|
870
|
+
) {
|
|
871
|
+
builder.addContainer(["___default___"]);
|
|
776
872
|
return;
|
|
777
873
|
}
|
|
778
874
|
|
|
@@ -792,7 +888,7 @@ function parseContainer(
|
|
|
792
888
|
return;
|
|
793
889
|
}
|
|
794
890
|
|
|
795
|
-
export function
|
|
891
|
+
export function parseUnparsedDeclaration(
|
|
796
892
|
declaration: Extract<Declaration, { property: "unparsed" }>,
|
|
797
893
|
builder: StylesheetBuilder,
|
|
798
894
|
) {
|
|
@@ -803,6 +899,8 @@ export function parseDeclarationUnparsed(
|
|
|
803
899
|
return;
|
|
804
900
|
}
|
|
805
901
|
|
|
902
|
+
builder.setWarningProperty(property);
|
|
903
|
+
|
|
806
904
|
/**
|
|
807
905
|
* React Native doesn't support all the logical properties
|
|
808
906
|
*/
|
|
@@ -817,7 +915,7 @@ export function parseDeclarationUnparsed(
|
|
|
817
915
|
builder.descriptorProperty = property;
|
|
818
916
|
|
|
819
917
|
if (unparsedRuntimeParsing.has(property)) {
|
|
820
|
-
const args = parseUnparsed(declaration.value.value, builder);
|
|
918
|
+
const args = parseUnparsed(declaration.value.value, builder, property);
|
|
821
919
|
|
|
822
920
|
if (property === "animation") {
|
|
823
921
|
builder.addDescriptor("animation", [
|
|
@@ -834,7 +932,7 @@ export function parseDeclarationUnparsed(
|
|
|
834
932
|
]);
|
|
835
933
|
}
|
|
836
934
|
} else {
|
|
837
|
-
const value = parseUnparsed(declaration.value.value, builder);
|
|
935
|
+
const value = parseUnparsed(declaration.value.value, builder, property);
|
|
838
936
|
|
|
839
937
|
builder.addDescriptor(property, value);
|
|
840
938
|
|
|
@@ -848,7 +946,7 @@ export function parseDeclarationUnparsed(
|
|
|
848
946
|
}
|
|
849
947
|
}
|
|
850
948
|
|
|
851
|
-
export function
|
|
949
|
+
export function parseCustomDeclaration(
|
|
852
950
|
declaration: Extract<Declaration, { property: "custom" }>,
|
|
853
951
|
builder: StylesheetBuilder,
|
|
854
952
|
) {
|
|
@@ -860,7 +958,13 @@ export function parseDeclarationCustom(
|
|
|
860
958
|
) {
|
|
861
959
|
builder.addDescriptor(
|
|
862
960
|
property,
|
|
863
|
-
parseUnparsed(declaration.value.value, builder,
|
|
961
|
+
parseUnparsed(declaration.value.value, builder, property),
|
|
962
|
+
);
|
|
963
|
+
} else if (property === "-webkit-line-clamp") {
|
|
964
|
+
builder.addMapping({ [property]: ["numberOfLines"] });
|
|
965
|
+
builder.addDescriptor(
|
|
966
|
+
property,
|
|
967
|
+
parseUnparsed(declaration.value.value, builder, property),
|
|
864
968
|
);
|
|
865
969
|
} else {
|
|
866
970
|
builder.addWarning("property", declaration.value.name);
|
|
@@ -870,9 +974,13 @@ export function parseDeclarationCustom(
|
|
|
870
974
|
export function reduceParseUnparsed(
|
|
871
975
|
tokenOrValues: TokenOrValue[],
|
|
872
976
|
builder: StylesheetBuilder,
|
|
977
|
+
property: string,
|
|
978
|
+
allowAuto: boolean,
|
|
873
979
|
): StyleDescriptor {
|
|
874
980
|
const result = tokenOrValues
|
|
875
|
-
.map((tokenOrValue) =>
|
|
981
|
+
.map((tokenOrValue) =>
|
|
982
|
+
parseUnparsed(tokenOrValue, builder, property, allowAuto),
|
|
983
|
+
)
|
|
876
984
|
.filter((v) => v !== undefined);
|
|
877
985
|
|
|
878
986
|
if (result.length === 0) {
|
|
@@ -891,6 +999,8 @@ export function reduceParseUnparsed(
|
|
|
891
999
|
}
|
|
892
1000
|
}
|
|
893
1001
|
|
|
1002
|
+
// Groups are the tokens grouped together by comma location
|
|
1003
|
+
// If a group only has 1 item, it shouldn't be an array
|
|
894
1004
|
groups = groups.flatMap((group): StyleDescriptor[] => {
|
|
895
1005
|
if (!Array.isArray(group)) {
|
|
896
1006
|
return [];
|
|
@@ -906,6 +1016,17 @@ export function reduceParseUnparsed(
|
|
|
906
1016
|
} else {
|
|
907
1017
|
return [first];
|
|
908
1018
|
}
|
|
1019
|
+
} else if (
|
|
1020
|
+
// This is a special case for <ratio> values
|
|
1021
|
+
group.includes("/") &&
|
|
1022
|
+
group.every((item) =>
|
|
1023
|
+
typeof item === "string" && item === "/"
|
|
1024
|
+
? item
|
|
1025
|
+
: typeof item === "number",
|
|
1026
|
+
)
|
|
1027
|
+
) {
|
|
1028
|
+
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
1029
|
+
return [group.join(" ")];
|
|
909
1030
|
} else {
|
|
910
1031
|
return [group];
|
|
911
1032
|
}
|
|
@@ -917,11 +1038,13 @@ export function reduceParseUnparsed(
|
|
|
917
1038
|
export function unparsedFunction(
|
|
918
1039
|
token: Extract<TokenOrValue, { type: "function" }>,
|
|
919
1040
|
builder: StylesheetBuilder,
|
|
1041
|
+
property: string,
|
|
1042
|
+
allowAuto: boolean,
|
|
920
1043
|
): StyleFunction {
|
|
921
1044
|
return [
|
|
922
1045
|
{},
|
|
923
1046
|
token.value.name,
|
|
924
|
-
reduceParseUnparsed(token.value.arguments, builder),
|
|
1047
|
+
reduceParseUnparsed(token.value.arguments, builder, property, allowAuto),
|
|
925
1048
|
];
|
|
926
1049
|
}
|
|
927
1050
|
|
|
@@ -938,7 +1061,8 @@ export function parseUnparsed(
|
|
|
938
1061
|
| undefined
|
|
939
1062
|
| null,
|
|
940
1063
|
builder: StylesheetBuilder,
|
|
941
|
-
|
|
1064
|
+
property: string,
|
|
1065
|
+
allowAuto = allowAutoProperties.has(property),
|
|
942
1066
|
): StyleDescriptor {
|
|
943
1067
|
if (tokenOrValue === undefined || tokenOrValue === null) {
|
|
944
1068
|
return;
|
|
@@ -961,7 +1085,12 @@ export function parseUnparsed(
|
|
|
961
1085
|
}
|
|
962
1086
|
|
|
963
1087
|
if (Array.isArray(tokenOrValue)) {
|
|
964
|
-
const args = reduceParseUnparsed(
|
|
1088
|
+
const args = reduceParseUnparsed(
|
|
1089
|
+
tokenOrValue,
|
|
1090
|
+
builder,
|
|
1091
|
+
property,
|
|
1092
|
+
allowAuto,
|
|
1093
|
+
);
|
|
965
1094
|
if (!args) return;
|
|
966
1095
|
if (Array.isArray(args) && args.length === 1) return args[0];
|
|
967
1096
|
return args;
|
|
@@ -969,11 +1098,21 @@ export function parseUnparsed(
|
|
|
969
1098
|
|
|
970
1099
|
switch (tokenOrValue.type) {
|
|
971
1100
|
case "unresolved-color": {
|
|
972
|
-
return parseUnresolvedColor(
|
|
1101
|
+
return parseUnresolvedColor(
|
|
1102
|
+
tokenOrValue.value,
|
|
1103
|
+
builder,
|
|
1104
|
+
property,
|
|
1105
|
+
allowAuto,
|
|
1106
|
+
);
|
|
973
1107
|
}
|
|
974
1108
|
case "var": {
|
|
975
1109
|
let args: StyleDescriptor = tokenOrValue.value.name.ident.slice(2);
|
|
976
|
-
const fallback = parseUnparsed(
|
|
1110
|
+
const fallback = parseUnparsed(
|
|
1111
|
+
tokenOrValue.value.fallback,
|
|
1112
|
+
builder,
|
|
1113
|
+
property,
|
|
1114
|
+
allowAuto,
|
|
1115
|
+
);
|
|
977
1116
|
if (fallback !== undefined) {
|
|
978
1117
|
args = [args, fallback];
|
|
979
1118
|
}
|
|
@@ -994,7 +1133,8 @@ export function parseUnparsed(
|
|
|
994
1133
|
case "translateX":
|
|
995
1134
|
case "translateY":
|
|
996
1135
|
tokenOrValue.value.name = `@${tokenOrValue.value.name}`;
|
|
997
|
-
return unparsedFunction(tokenOrValue, builder);
|
|
1136
|
+
return unparsedFunction(tokenOrValue, builder, property, allowAuto);
|
|
1137
|
+
case "blur":
|
|
998
1138
|
case "brightness":
|
|
999
1139
|
case "contrast":
|
|
1000
1140
|
case "cubic-bezier":
|
|
@@ -1018,7 +1158,7 @@ export function parseUnparsed(
|
|
|
1018
1158
|
case "sepia":
|
|
1019
1159
|
case "shadow":
|
|
1020
1160
|
case "steps":
|
|
1021
|
-
return unparsedFunction(tokenOrValue, builder);
|
|
1161
|
+
return unparsedFunction(tokenOrValue, builder, property, allowAuto);
|
|
1022
1162
|
case "hairlineWidth":
|
|
1023
1163
|
return [{}, tokenOrValue.value.name, []];
|
|
1024
1164
|
case "calc":
|
|
@@ -1029,9 +1169,10 @@ export function parseUnparsed(
|
|
|
1029
1169
|
tokenOrValue.value.name,
|
|
1030
1170
|
tokenOrValue.value.arguments,
|
|
1031
1171
|
builder,
|
|
1172
|
+
property,
|
|
1032
1173
|
);
|
|
1033
1174
|
default: {
|
|
1034
|
-
builder.addWarning("
|
|
1175
|
+
builder.addWarning("value", `${tokenOrValue.value.name}()`);
|
|
1035
1176
|
return;
|
|
1036
1177
|
}
|
|
1037
1178
|
}
|
|
@@ -1077,11 +1218,16 @@ export function parseUnparsed(
|
|
|
1077
1218
|
return parseDimension(tokenOrValue.value, builder);
|
|
1078
1219
|
case "comma":
|
|
1079
1220
|
return CommaSeparator as unknown as StyleDescriptor;
|
|
1221
|
+
case "delim": {
|
|
1222
|
+
if (property === "aspect-ratio" && tokenOrValue.value.value === "/") {
|
|
1223
|
+
return tokenOrValue.value.value;
|
|
1224
|
+
}
|
|
1225
|
+
return;
|
|
1226
|
+
}
|
|
1080
1227
|
case "at-keyword":
|
|
1081
1228
|
case "hash":
|
|
1082
1229
|
case "id-hash":
|
|
1083
1230
|
case "unquoted-url":
|
|
1084
|
-
case "delim":
|
|
1085
1231
|
case "white-space":
|
|
1086
1232
|
case "comment":
|
|
1087
1233
|
case "colon":
|
|
@@ -1152,23 +1298,30 @@ export function parseLength(
|
|
|
1152
1298
|
const { inlineRem = 14 } = builder.getOptions();
|
|
1153
1299
|
|
|
1154
1300
|
if (typeof length === "number") {
|
|
1155
|
-
return length;
|
|
1301
|
+
return round(length);
|
|
1156
1302
|
}
|
|
1157
1303
|
|
|
1158
1304
|
if ("unit" in length) {
|
|
1159
1305
|
switch (length.unit) {
|
|
1160
|
-
case "px":
|
|
1161
|
-
|
|
1306
|
+
case "px": {
|
|
1307
|
+
if (length.value === Infinity) {
|
|
1308
|
+
return 9999;
|
|
1309
|
+
} else if (length.value === -Infinity) {
|
|
1310
|
+
return -9999;
|
|
1311
|
+
} else {
|
|
1312
|
+
return round(length.value);
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1162
1315
|
case "rem":
|
|
1163
1316
|
if (typeof inlineRem === "number") {
|
|
1164
1317
|
return length.value * inlineRem;
|
|
1165
1318
|
} else {
|
|
1166
|
-
return [{}, "rem", length.value];
|
|
1319
|
+
return [{}, "rem", round(length.value)];
|
|
1167
1320
|
}
|
|
1168
1321
|
case "vw":
|
|
1169
1322
|
case "vh":
|
|
1170
1323
|
case "em":
|
|
1171
|
-
return [{}, length.unit, length.value, 1];
|
|
1324
|
+
return [{}, length.unit, round(length.value), 1];
|
|
1172
1325
|
case "in":
|
|
1173
1326
|
case "cm":
|
|
1174
1327
|
case "mm":
|
|
@@ -1251,7 +1404,7 @@ export function parseAngle(angle: Angle | number, builder: StylesheetBuilder) {
|
|
|
1251
1404
|
case "rad":
|
|
1252
1405
|
return `${angle.value}${angle.type}`;
|
|
1253
1406
|
default:
|
|
1254
|
-
builder.addWarning("value", angle.value);
|
|
1407
|
+
builder.addWarning("value", `${angle.value} ${angle.type}`);
|
|
1255
1408
|
return undefined;
|
|
1256
1409
|
}
|
|
1257
1410
|
}
|
|
@@ -1334,7 +1487,7 @@ export function parseSize(
|
|
|
1334
1487
|
return;
|
|
1335
1488
|
}
|
|
1336
1489
|
|
|
1337
|
-
export function
|
|
1490
|
+
export function parseColorOrAutoDeclaration(
|
|
1338
1491
|
{ value }: { value: ColorOrAuto },
|
|
1339
1492
|
builder: StylesheetBuilder,
|
|
1340
1493
|
) {
|
|
@@ -1836,7 +1989,13 @@ export function parseOverflow(
|
|
|
1836
1989
|
}
|
|
1837
1990
|
|
|
1838
1991
|
export function parseBorderStyleDeclaration(
|
|
1839
|
-
declaration: DeclarationType<
|
|
1992
|
+
declaration: DeclarationType<
|
|
1993
|
+
| "border-style"
|
|
1994
|
+
| "border-left-style"
|
|
1995
|
+
| "border-right-style"
|
|
1996
|
+
| "border-top-style"
|
|
1997
|
+
| "border-bottom-style"
|
|
1998
|
+
>,
|
|
1840
1999
|
builder: StylesheetBuilder,
|
|
1841
2000
|
) {
|
|
1842
2001
|
return parseBorderStyle(declaration.value, builder);
|
|
@@ -1869,17 +2028,8 @@ export function parseBorderStyle(
|
|
|
1869
2028
|
return undefined;
|
|
1870
2029
|
}
|
|
1871
2030
|
|
|
1872
|
-
export function parseBorderBlockColor(
|
|
1873
|
-
{ value }: { value: BorderBlockColor },
|
|
1874
|
-
builder: StylesheetBuilder,
|
|
1875
|
-
) {
|
|
1876
|
-
builder.addDescriptor("border-top-color", parseColor(value.start, builder));
|
|
1877
|
-
builder.addDescriptor("border-bottom-color", parseColor(value.end, builder));
|
|
1878
|
-
return;
|
|
1879
|
-
}
|
|
1880
|
-
|
|
1881
2031
|
export function parseBorderBlockWidth(
|
|
1882
|
-
declaration: DeclarationType<"border-block-width"
|
|
2032
|
+
declaration: DeclarationType<"border-block-width">,
|
|
1883
2033
|
builder: StylesheetBuilder,
|
|
1884
2034
|
) {
|
|
1885
2035
|
builder.addDescriptor(
|
|
@@ -1892,11 +2042,48 @@ export function parseBorderBlockWidth(
|
|
|
1892
2042
|
);
|
|
1893
2043
|
}
|
|
1894
2044
|
|
|
2045
|
+
function parseBorderBlockStyle(
|
|
2046
|
+
declaration: DeclarationType<"border-block-style">,
|
|
2047
|
+
builder: StylesheetBuilder,
|
|
2048
|
+
) {
|
|
2049
|
+
if (declaration.value.start === declaration.value.end) {
|
|
2050
|
+
builder.addDescriptor(
|
|
2051
|
+
"border-style",
|
|
2052
|
+
parseBorderStyle(declaration.value.start, builder),
|
|
2053
|
+
);
|
|
2054
|
+
} else {
|
|
2055
|
+
builder.addWarning("property", "border-block-style");
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2058
|
+
|
|
1895
2059
|
export function parseBorderSideWidthDeclaration(
|
|
1896
|
-
declaration:
|
|
2060
|
+
declaration: DeclarationType<
|
|
2061
|
+
| "border-block-end-width"
|
|
2062
|
+
| "border-block-start-width"
|
|
2063
|
+
| "border-bottom-width"
|
|
2064
|
+
| "border-inline-end-width"
|
|
2065
|
+
| "border-inline-start-width"
|
|
2066
|
+
| "border-left-width"
|
|
2067
|
+
| "border-right-width"
|
|
2068
|
+
| "border-top-width"
|
|
2069
|
+
>,
|
|
1897
2070
|
builder: StylesheetBuilder,
|
|
1898
2071
|
) {
|
|
1899
|
-
|
|
2072
|
+
if (declaration.property.includes("block")) {
|
|
2073
|
+
builder.addDescriptor(
|
|
2074
|
+
`border-${declaration.property.includes("start") ? "top" : "bottom"}-width`,
|
|
2075
|
+
parseBorderSideWidth(declaration.value, builder),
|
|
2076
|
+
);
|
|
2077
|
+
return;
|
|
2078
|
+
} else if (declaration.property.includes("inline")) {
|
|
2079
|
+
builder.addDescriptor(
|
|
2080
|
+
`border-${declaration.property.includes("start") ? "left" : "right"}-width`,
|
|
2081
|
+
parseBorderSideWidth(declaration.value, builder),
|
|
2082
|
+
);
|
|
2083
|
+
return;
|
|
2084
|
+
} else {
|
|
2085
|
+
return parseBorderSideWidth(declaration.value, builder);
|
|
2086
|
+
}
|
|
1900
2087
|
}
|
|
1901
2088
|
|
|
1902
2089
|
export function parseBorderSideWidth(
|
|
@@ -1959,7 +2146,8 @@ export function parseLineHeight(
|
|
|
1959
2146
|
case "percentage":
|
|
1960
2147
|
case "calc":
|
|
1961
2148
|
builder.addWarning(
|
|
1962
|
-
"
|
|
2149
|
+
"style",
|
|
2150
|
+
"line-height",
|
|
1963
2151
|
typeof length.value === "number"
|
|
1964
2152
|
? length.value
|
|
1965
2153
|
: JSON.stringify(length.value),
|
|
@@ -2222,7 +2410,11 @@ export function parseDimension(
|
|
|
2222
2410
|
): StyleDescriptor {
|
|
2223
2411
|
switch (unit) {
|
|
2224
2412
|
case "px":
|
|
2225
|
-
|
|
2413
|
+
if (value === Infinity) {
|
|
2414
|
+
return 9999;
|
|
2415
|
+
} else {
|
|
2416
|
+
return value;
|
|
2417
|
+
}
|
|
2226
2418
|
case "%":
|
|
2227
2419
|
return `${value}%`;
|
|
2228
2420
|
case "rnh":
|
|
@@ -2249,20 +2441,25 @@ export function parseUserSelect(
|
|
|
2249
2441
|
}
|
|
2250
2442
|
|
|
2251
2443
|
export function parseSVGPaint(
|
|
2252
|
-
{ value }: DeclarationType<"fill" | "stroke">,
|
|
2444
|
+
{ value, property }: DeclarationType<"fill" | "stroke">,
|
|
2253
2445
|
builder: StylesheetBuilder,
|
|
2254
2446
|
) {
|
|
2447
|
+
let parsedValue: StyleDescriptor | undefined;
|
|
2448
|
+
|
|
2255
2449
|
if (value.type === "none") {
|
|
2256
|
-
|
|
2450
|
+
parsedValue = "transparent";
|
|
2257
2451
|
} else if (value.type === "color") {
|
|
2258
|
-
|
|
2452
|
+
parsedValue = parseColor(value.value, builder);
|
|
2453
|
+
} else {
|
|
2454
|
+
return;
|
|
2259
2455
|
}
|
|
2260
2456
|
|
|
2261
|
-
|
|
2457
|
+
builder.addMapping({ [property]: [property] });
|
|
2458
|
+
builder.addDescriptor(property, parsedValue);
|
|
2262
2459
|
}
|
|
2263
2460
|
|
|
2264
2461
|
export function round(number: number) {
|
|
2265
|
-
return Math.round((number + Number.EPSILON) *
|
|
2462
|
+
return Math.round((number + Number.EPSILON) * 10000) / 10000;
|
|
2266
2463
|
}
|
|
2267
2464
|
|
|
2268
2465
|
export function parseDimensionPercentageFor_LengthValue(
|
|
@@ -2278,7 +2475,7 @@ export function parseDimensionPercentageFor_LengthValue(
|
|
|
2278
2475
|
}
|
|
2279
2476
|
}
|
|
2280
2477
|
|
|
2281
|
-
const
|
|
2478
|
+
const allowAutoProperties = new Set(["pointer-events"]);
|
|
2282
2479
|
|
|
2283
2480
|
export function parseEnv(
|
|
2284
2481
|
value: EnvironmentVariable,
|
|
@@ -2296,7 +2493,7 @@ export function parseEnv(
|
|
|
2296
2493
|
"var",
|
|
2297
2494
|
[
|
|
2298
2495
|
`--react-native-css-${value.name.value}`,
|
|
2299
|
-
parseUnparsed(value.fallback, builder),
|
|
2496
|
+
parseUnparsed(value.fallback, builder, value.name.value),
|
|
2300
2497
|
],
|
|
2301
2498
|
1,
|
|
2302
2499
|
];
|
|
@@ -2319,8 +2516,9 @@ export function parseCalcFn(
|
|
|
2319
2516
|
name: string,
|
|
2320
2517
|
tokens: TokenOrValue[],
|
|
2321
2518
|
builder: StylesheetBuilder,
|
|
2519
|
+
property: string,
|
|
2322
2520
|
): StyleDescriptor {
|
|
2323
|
-
const args = parseCalcArguments(tokens, builder);
|
|
2521
|
+
const args = parseCalcArguments(tokens, builder, property);
|
|
2324
2522
|
if (args) {
|
|
2325
2523
|
return [{}, name, args];
|
|
2326
2524
|
}
|
|
@@ -2331,6 +2529,7 @@ export function parseCalcFn(
|
|
|
2331
2529
|
export function parseCalcArguments(
|
|
2332
2530
|
[...args]: TokenOrValue[],
|
|
2333
2531
|
builder: StylesheetBuilder,
|
|
2532
|
+
property: string,
|
|
2334
2533
|
) {
|
|
2335
2534
|
const parsed: StyleDescriptor[] = [];
|
|
2336
2535
|
|
|
@@ -2345,7 +2544,7 @@ export function parseCalcArguments(
|
|
|
2345
2544
|
case "var":
|
|
2346
2545
|
case "function":
|
|
2347
2546
|
case "unresolved-color": {
|
|
2348
|
-
const value = parseUnparsed(arg, builder);
|
|
2547
|
+
const value = parseUnparsed(arg, builder, property);
|
|
2349
2548
|
|
|
2350
2549
|
if (value === undefined) {
|
|
2351
2550
|
return undefined;
|
|
@@ -2421,7 +2620,7 @@ export function parseCalcArguments(
|
|
|
2421
2620
|
// Then drop the surrounding parenthesis
|
|
2422
2621
|
.slice(1, -1);
|
|
2423
2622
|
|
|
2424
|
-
parsed.push(parseCalcFn("calc", innerCalcArgs, builder));
|
|
2623
|
+
parsed.push(parseCalcFn("calc", innerCalcArgs, builder, property));
|
|
2425
2624
|
|
|
2426
2625
|
break;
|
|
2427
2626
|
}
|
|
@@ -2474,6 +2673,8 @@ export function parseTranslateProp(
|
|
|
2474
2673
|
export function parseUnresolvedColor(
|
|
2475
2674
|
color: UnresolvedColor,
|
|
2476
2675
|
builder: StylesheetBuilder,
|
|
2676
|
+
property: string,
|
|
2677
|
+
allowAuto: boolean,
|
|
2477
2678
|
): StyleDescriptor {
|
|
2478
2679
|
switch (color.type) {
|
|
2479
2680
|
case "rgb":
|
|
@@ -2484,26 +2685,31 @@ export function parseUnresolvedColor(
|
|
|
2484
2685
|
round(color.r * 255),
|
|
2485
2686
|
round(color.g * 255),
|
|
2486
2687
|
round(color.b * 255),
|
|
2487
|
-
parseUnparsed(color.alpha, builder),
|
|
2688
|
+
parseUnparsed(color.alpha, builder, property),
|
|
2488
2689
|
],
|
|
2489
2690
|
];
|
|
2490
2691
|
case "hsl":
|
|
2491
2692
|
return [
|
|
2492
2693
|
{},
|
|
2493
2694
|
color.type,
|
|
2494
|
-
[
|
|
2695
|
+
[
|
|
2696
|
+
color.h,
|
|
2697
|
+
color.s,
|
|
2698
|
+
color.l,
|
|
2699
|
+
parseUnparsed(color.alpha, builder, property),
|
|
2700
|
+
],
|
|
2495
2701
|
];
|
|
2496
2702
|
case "light-dark": {
|
|
2497
2703
|
const extraRule = builder.extendRule({
|
|
2498
2704
|
m: [["=", "prefers-color-scheme", "dark"]],
|
|
2499
2705
|
});
|
|
2500
2706
|
builder.addUnnamedDescriptor(
|
|
2501
|
-
reduceParseUnparsed(color.dark, builder),
|
|
2707
|
+
reduceParseUnparsed(color.dark, builder, property, allowAuto),
|
|
2502
2708
|
false,
|
|
2503
2709
|
extraRule,
|
|
2504
2710
|
);
|
|
2505
2711
|
builder.addExtraRule(extraRule);
|
|
2506
|
-
return reduceParseUnparsed(color.light, builder);
|
|
2712
|
+
return reduceParseUnparsed(color.light, builder, property, allowAuto);
|
|
2507
2713
|
}
|
|
2508
2714
|
default:
|
|
2509
2715
|
color satisfies never;
|