react-native-css 3.0.0-nightly.61014be → 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 +173 -74
- 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 +23 -7
- 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 +168 -70
- 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 +23 -7
- 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 +10 -3
- 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 +10 -3
- 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 +4 -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 +293 -69
- 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 +30 -6
- 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,
|
|
@@ -15,6 +14,7 @@ import type {
|
|
|
15
14
|
FontStyle,
|
|
16
15
|
FontVariantCaps,
|
|
17
16
|
FontWeight,
|
|
17
|
+
GapValue,
|
|
18
18
|
Gradient,
|
|
19
19
|
GradientItemFor_DimensionPercentageFor_LengthValue,
|
|
20
20
|
Length,
|
|
@@ -91,37 +91,44 @@ const parsers: {
|
|
|
91
91
|
"block-size": parseSizeDeclaration,
|
|
92
92
|
"border": parseBorder,
|
|
93
93
|
"border-block": parseBorderBlock,
|
|
94
|
-
"border-block-color":
|
|
94
|
+
"border-block-color": parseBorderColor,
|
|
95
95
|
"border-block-end": parseBorderBlockEnd,
|
|
96
96
|
"border-block-end-color": parseColorDeclaration,
|
|
97
97
|
"border-block-end-width": parseBorderSideWidthDeclaration,
|
|
98
98
|
"border-block-start": parseBorderBlockStart,
|
|
99
99
|
"border-block-start-color": parseColorDeclaration,
|
|
100
100
|
"border-block-start-width": parseBorderSideWidthDeclaration,
|
|
101
|
+
"border-block-style": parseBorderBlockStyle,
|
|
101
102
|
"border-block-width": parseBorderBlockWidth,
|
|
102
103
|
"border-bottom": parseBorderSide,
|
|
103
104
|
"border-bottom-color": parseColorDeclaration,
|
|
104
105
|
"border-bottom-left-radius": parseSize2DDimensionPercentageDeclaration,
|
|
105
106
|
"border-bottom-right-radius": parseSize2DDimensionPercentageDeclaration,
|
|
107
|
+
"border-bottom-style": parseBorderStyleDeclaration,
|
|
106
108
|
"border-bottom-width": parseBorderSideWidthDeclaration,
|
|
107
109
|
"border-color": parseBorderColor,
|
|
108
110
|
"border-end-end-radius": parseSize2DDimensionPercentageDeclaration,
|
|
109
111
|
"border-end-start-radius": parseSize2DDimensionPercentageDeclaration,
|
|
110
112
|
"border-inline": parseBorderInline,
|
|
111
|
-
"border-inline-color":
|
|
113
|
+
"border-inline-color": parseBorderColor,
|
|
112
114
|
"border-inline-end": parseBorderInlineEnd,
|
|
113
115
|
"border-inline-end-color": parseColorDeclaration,
|
|
116
|
+
"border-inline-end-style": parseBorderInlineStyle,
|
|
114
117
|
"border-inline-end-width": parseBorderSideWidthDeclaration,
|
|
115
118
|
"border-inline-start": parseBorderInlineStart,
|
|
116
119
|
"border-inline-start-color": parseColorDeclaration,
|
|
120
|
+
"border-inline-start-style": parseBorderInlineStyle,
|
|
117
121
|
"border-inline-start-width": parseBorderSideWidthDeclaration,
|
|
118
|
-
"border-inline-
|
|
122
|
+
"border-inline-style": parseBorderInlineStyle,
|
|
123
|
+
"border-inline-width": parseBorderInlineWidth,
|
|
119
124
|
"border-left": parseBorderSide,
|
|
120
125
|
"border-left-color": parseColorDeclaration,
|
|
126
|
+
"border-left-style": parseBorderStyleDeclaration,
|
|
121
127
|
"border-left-width": parseBorderSideWidthDeclaration,
|
|
122
128
|
"border-radius": parseBorderRadius,
|
|
123
129
|
"border-right": parseBorderSide,
|
|
124
130
|
"border-right-color": parseColorDeclaration,
|
|
131
|
+
"border-right-style": parseBorderStyleDeclaration,
|
|
125
132
|
"border-right-width": parseBorderSideWidthDeclaration,
|
|
126
133
|
"border-start-end-radius": parseSize2DDimensionPercentageDeclaration,
|
|
127
134
|
"border-start-start-radius": parseSize2DDimensionPercentageDeclaration,
|
|
@@ -130,11 +137,12 @@ const parsers: {
|
|
|
130
137
|
"border-top-color": parseColorDeclaration,
|
|
131
138
|
"border-top-left-radius": parseSize2DDimensionPercentageDeclaration,
|
|
132
139
|
"border-top-right-radius": parseSize2DDimensionPercentageDeclaration,
|
|
140
|
+
"border-top-style": parseBorderStyleDeclaration,
|
|
133
141
|
"border-top-width": parseBorderSideWidthDeclaration,
|
|
134
142
|
"border-width": parseBorderWidth,
|
|
135
143
|
"bottom": parseSizeDeclaration,
|
|
136
144
|
"box-shadow": parseBoxShadow,
|
|
137
|
-
"caret-color":
|
|
145
|
+
"caret-color": parseCaretColor,
|
|
138
146
|
"color": parseFontColorDeclaration,
|
|
139
147
|
"column-gap": parseGap,
|
|
140
148
|
"container": parseContainer,
|
|
@@ -236,6 +244,17 @@ const parsers: {
|
|
|
236
244
|
|
|
237
245
|
const validProperties = new Set(Object.keys(parsers));
|
|
238
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
|
+
|
|
239
258
|
export function parseDeclaration(
|
|
240
259
|
declaration: Declaration,
|
|
241
260
|
builder: StylesheetBuilder,
|
|
@@ -255,9 +274,9 @@ export function parseDeclaration(
|
|
|
255
274
|
}
|
|
256
275
|
|
|
257
276
|
if (declaration.property === "unparsed") {
|
|
258
|
-
|
|
277
|
+
parseUnparsedDeclaration(declaration, builder);
|
|
259
278
|
} else if (declaration.property === "custom") {
|
|
260
|
-
|
|
279
|
+
parseCustomDeclaration(declaration, builder);
|
|
261
280
|
} else {
|
|
262
281
|
parseWithParser(declaration, builder);
|
|
263
282
|
}
|
|
@@ -269,6 +288,7 @@ function parseWithParser(declaration: Declaration, builder: StylesheetBuilder) {
|
|
|
269
288
|
|
|
270
289
|
builder.descriptorProperty = declaration.property;
|
|
271
290
|
|
|
291
|
+
builder.setWarningProperty(declaration.property);
|
|
272
292
|
const value = parser(declaration, builder, declaration.property);
|
|
273
293
|
|
|
274
294
|
if (value !== undefined) {
|
|
@@ -342,15 +362,41 @@ function parseBorderRadius(
|
|
|
342
362
|
}
|
|
343
363
|
|
|
344
364
|
function parseBorderColor(
|
|
345
|
-
|
|
365
|
+
declaration: DeclarationType<
|
|
366
|
+
"border-color" | "border-block-color" | "border-inline-color"
|
|
367
|
+
>,
|
|
346
368
|
builder: StylesheetBuilder,
|
|
347
369
|
) {
|
|
348
|
-
|
|
349
|
-
"border-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
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
|
+
}
|
|
354
400
|
}
|
|
355
401
|
|
|
356
402
|
function parseBorderWidth(
|
|
@@ -474,6 +520,43 @@ function parseBorderInlineEnd(
|
|
|
474
520
|
);
|
|
475
521
|
}
|
|
476
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
|
+
|
|
477
560
|
function parseFlexFlow(
|
|
478
561
|
{ value }: DeclarationType<"flex-flow">,
|
|
479
562
|
builder: StylesheetBuilder,
|
|
@@ -742,7 +825,17 @@ function parseLetterSpacing(
|
|
|
742
825
|
if (value.type === "normal") {
|
|
743
826
|
return;
|
|
744
827
|
}
|
|
745
|
-
|
|
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;
|
|
746
839
|
}
|
|
747
840
|
|
|
748
841
|
function parseTextDecoration(
|
|
@@ -771,7 +864,11 @@ function parseZIndex(
|
|
|
771
864
|
}
|
|
772
865
|
}
|
|
773
866
|
|
|
774
|
-
function parseContainerType(
|
|
867
|
+
function parseContainerType(
|
|
868
|
+
_declaration: DeclarationType<"container-type">,
|
|
869
|
+
builder: StylesheetBuilder,
|
|
870
|
+
) {
|
|
871
|
+
builder.addContainer(["___default___"]);
|
|
775
872
|
return;
|
|
776
873
|
}
|
|
777
874
|
|
|
@@ -791,7 +888,7 @@ function parseContainer(
|
|
|
791
888
|
return;
|
|
792
889
|
}
|
|
793
890
|
|
|
794
|
-
export function
|
|
891
|
+
export function parseUnparsedDeclaration(
|
|
795
892
|
declaration: Extract<Declaration, { property: "unparsed" }>,
|
|
796
893
|
builder: StylesheetBuilder,
|
|
797
894
|
) {
|
|
@@ -802,6 +899,8 @@ export function parseDeclarationUnparsed(
|
|
|
802
899
|
return;
|
|
803
900
|
}
|
|
804
901
|
|
|
902
|
+
builder.setWarningProperty(property);
|
|
903
|
+
|
|
805
904
|
/**
|
|
806
905
|
* React Native doesn't support all the logical properties
|
|
807
906
|
*/
|
|
@@ -816,7 +915,7 @@ export function parseDeclarationUnparsed(
|
|
|
816
915
|
builder.descriptorProperty = property;
|
|
817
916
|
|
|
818
917
|
if (unparsedRuntimeParsing.has(property)) {
|
|
819
|
-
const args = parseUnparsed(declaration.value.value, builder);
|
|
918
|
+
const args = parseUnparsed(declaration.value.value, builder, property);
|
|
820
919
|
|
|
821
920
|
if (property === "animation") {
|
|
822
921
|
builder.addDescriptor("animation", [
|
|
@@ -833,7 +932,7 @@ export function parseDeclarationUnparsed(
|
|
|
833
932
|
]);
|
|
834
933
|
}
|
|
835
934
|
} else {
|
|
836
|
-
const value = parseUnparsed(declaration.value.value, builder);
|
|
935
|
+
const value = parseUnparsed(declaration.value.value, builder, property);
|
|
837
936
|
|
|
838
937
|
builder.addDescriptor(property, value);
|
|
839
938
|
|
|
@@ -847,7 +946,7 @@ export function parseDeclarationUnparsed(
|
|
|
847
946
|
}
|
|
848
947
|
}
|
|
849
948
|
|
|
850
|
-
export function
|
|
949
|
+
export function parseCustomDeclaration(
|
|
851
950
|
declaration: Extract<Declaration, { property: "custom" }>,
|
|
852
951
|
builder: StylesheetBuilder,
|
|
853
952
|
) {
|
|
@@ -859,7 +958,13 @@ export function parseDeclarationCustom(
|
|
|
859
958
|
) {
|
|
860
959
|
builder.addDescriptor(
|
|
861
960
|
property,
|
|
862
|
-
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),
|
|
863
968
|
);
|
|
864
969
|
} else {
|
|
865
970
|
builder.addWarning("property", declaration.value.name);
|
|
@@ -869,9 +974,13 @@ export function parseDeclarationCustom(
|
|
|
869
974
|
export function reduceParseUnparsed(
|
|
870
975
|
tokenOrValues: TokenOrValue[],
|
|
871
976
|
builder: StylesheetBuilder,
|
|
977
|
+
property: string,
|
|
978
|
+
allowAuto: boolean,
|
|
872
979
|
): StyleDescriptor {
|
|
873
980
|
const result = tokenOrValues
|
|
874
|
-
.map((tokenOrValue) =>
|
|
981
|
+
.map((tokenOrValue) =>
|
|
982
|
+
parseUnparsed(tokenOrValue, builder, property, allowAuto),
|
|
983
|
+
)
|
|
875
984
|
.filter((v) => v !== undefined);
|
|
876
985
|
|
|
877
986
|
if (result.length === 0) {
|
|
@@ -890,6 +999,8 @@ export function reduceParseUnparsed(
|
|
|
890
999
|
}
|
|
891
1000
|
}
|
|
892
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
|
|
893
1004
|
groups = groups.flatMap((group): StyleDescriptor[] => {
|
|
894
1005
|
if (!Array.isArray(group)) {
|
|
895
1006
|
return [];
|
|
@@ -905,6 +1016,17 @@ export function reduceParseUnparsed(
|
|
|
905
1016
|
} else {
|
|
906
1017
|
return [first];
|
|
907
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(" ")];
|
|
908
1030
|
} else {
|
|
909
1031
|
return [group];
|
|
910
1032
|
}
|
|
@@ -916,11 +1038,13 @@ export function reduceParseUnparsed(
|
|
|
916
1038
|
export function unparsedFunction(
|
|
917
1039
|
token: Extract<TokenOrValue, { type: "function" }>,
|
|
918
1040
|
builder: StylesheetBuilder,
|
|
1041
|
+
property: string,
|
|
1042
|
+
allowAuto: boolean,
|
|
919
1043
|
): StyleFunction {
|
|
920
1044
|
return [
|
|
921
1045
|
{},
|
|
922
1046
|
token.value.name,
|
|
923
|
-
reduceParseUnparsed(token.value.arguments, builder),
|
|
1047
|
+
reduceParseUnparsed(token.value.arguments, builder, property, allowAuto),
|
|
924
1048
|
];
|
|
925
1049
|
}
|
|
926
1050
|
|
|
@@ -937,7 +1061,8 @@ export function parseUnparsed(
|
|
|
937
1061
|
| undefined
|
|
938
1062
|
| null,
|
|
939
1063
|
builder: StylesheetBuilder,
|
|
940
|
-
|
|
1064
|
+
property: string,
|
|
1065
|
+
allowAuto = allowAutoProperties.has(property),
|
|
941
1066
|
): StyleDescriptor {
|
|
942
1067
|
if (tokenOrValue === undefined || tokenOrValue === null) {
|
|
943
1068
|
return;
|
|
@@ -960,7 +1085,12 @@ export function parseUnparsed(
|
|
|
960
1085
|
}
|
|
961
1086
|
|
|
962
1087
|
if (Array.isArray(tokenOrValue)) {
|
|
963
|
-
const args = reduceParseUnparsed(
|
|
1088
|
+
const args = reduceParseUnparsed(
|
|
1089
|
+
tokenOrValue,
|
|
1090
|
+
builder,
|
|
1091
|
+
property,
|
|
1092
|
+
allowAuto,
|
|
1093
|
+
);
|
|
964
1094
|
if (!args) return;
|
|
965
1095
|
if (Array.isArray(args) && args.length === 1) return args[0];
|
|
966
1096
|
return args;
|
|
@@ -968,11 +1098,21 @@ export function parseUnparsed(
|
|
|
968
1098
|
|
|
969
1099
|
switch (tokenOrValue.type) {
|
|
970
1100
|
case "unresolved-color": {
|
|
971
|
-
return parseUnresolvedColor(
|
|
1101
|
+
return parseUnresolvedColor(
|
|
1102
|
+
tokenOrValue.value,
|
|
1103
|
+
builder,
|
|
1104
|
+
property,
|
|
1105
|
+
allowAuto,
|
|
1106
|
+
);
|
|
972
1107
|
}
|
|
973
1108
|
case "var": {
|
|
974
1109
|
let args: StyleDescriptor = tokenOrValue.value.name.ident.slice(2);
|
|
975
|
-
const fallback = parseUnparsed(
|
|
1110
|
+
const fallback = parseUnparsed(
|
|
1111
|
+
tokenOrValue.value.fallback,
|
|
1112
|
+
builder,
|
|
1113
|
+
property,
|
|
1114
|
+
allowAuto,
|
|
1115
|
+
);
|
|
976
1116
|
if (fallback !== undefined) {
|
|
977
1117
|
args = [args, fallback];
|
|
978
1118
|
}
|
|
@@ -993,7 +1133,8 @@ export function parseUnparsed(
|
|
|
993
1133
|
case "translateX":
|
|
994
1134
|
case "translateY":
|
|
995
1135
|
tokenOrValue.value.name = `@${tokenOrValue.value.name}`;
|
|
996
|
-
return unparsedFunction(tokenOrValue, builder);
|
|
1136
|
+
return unparsedFunction(tokenOrValue, builder, property, allowAuto);
|
|
1137
|
+
case "blur":
|
|
997
1138
|
case "brightness":
|
|
998
1139
|
case "contrast":
|
|
999
1140
|
case "cubic-bezier":
|
|
@@ -1017,7 +1158,7 @@ export function parseUnparsed(
|
|
|
1017
1158
|
case "sepia":
|
|
1018
1159
|
case "shadow":
|
|
1019
1160
|
case "steps":
|
|
1020
|
-
return unparsedFunction(tokenOrValue, builder);
|
|
1161
|
+
return unparsedFunction(tokenOrValue, builder, property, allowAuto);
|
|
1021
1162
|
case "hairlineWidth":
|
|
1022
1163
|
return [{}, tokenOrValue.value.name, []];
|
|
1023
1164
|
case "calc":
|
|
@@ -1028,9 +1169,10 @@ export function parseUnparsed(
|
|
|
1028
1169
|
tokenOrValue.value.name,
|
|
1029
1170
|
tokenOrValue.value.arguments,
|
|
1030
1171
|
builder,
|
|
1172
|
+
property,
|
|
1031
1173
|
);
|
|
1032
1174
|
default: {
|
|
1033
|
-
builder.addWarning("
|
|
1175
|
+
builder.addWarning("value", `${tokenOrValue.value.name}()`);
|
|
1034
1176
|
return;
|
|
1035
1177
|
}
|
|
1036
1178
|
}
|
|
@@ -1076,11 +1218,16 @@ export function parseUnparsed(
|
|
|
1076
1218
|
return parseDimension(tokenOrValue.value, builder);
|
|
1077
1219
|
case "comma":
|
|
1078
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
|
+
}
|
|
1079
1227
|
case "at-keyword":
|
|
1080
1228
|
case "hash":
|
|
1081
1229
|
case "id-hash":
|
|
1082
1230
|
case "unquoted-url":
|
|
1083
|
-
case "delim":
|
|
1084
1231
|
case "white-space":
|
|
1085
1232
|
case "comment":
|
|
1086
1233
|
case "colon":
|
|
@@ -1151,23 +1298,30 @@ export function parseLength(
|
|
|
1151
1298
|
const { inlineRem = 14 } = builder.getOptions();
|
|
1152
1299
|
|
|
1153
1300
|
if (typeof length === "number") {
|
|
1154
|
-
return length;
|
|
1301
|
+
return round(length);
|
|
1155
1302
|
}
|
|
1156
1303
|
|
|
1157
1304
|
if ("unit" in length) {
|
|
1158
1305
|
switch (length.unit) {
|
|
1159
|
-
case "px":
|
|
1160
|
-
|
|
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
|
+
}
|
|
1161
1315
|
case "rem":
|
|
1162
1316
|
if (typeof inlineRem === "number") {
|
|
1163
1317
|
return length.value * inlineRem;
|
|
1164
1318
|
} else {
|
|
1165
|
-
return [{}, "rem", length.value];
|
|
1319
|
+
return [{}, "rem", round(length.value)];
|
|
1166
1320
|
}
|
|
1167
1321
|
case "vw":
|
|
1168
1322
|
case "vh":
|
|
1169
1323
|
case "em":
|
|
1170
|
-
return [{}, length.unit, length.value, 1];
|
|
1324
|
+
return [{}, length.unit, round(length.value), 1];
|
|
1171
1325
|
case "in":
|
|
1172
1326
|
case "cm":
|
|
1173
1327
|
case "mm":
|
|
@@ -1250,7 +1404,7 @@ export function parseAngle(angle: Angle | number, builder: StylesheetBuilder) {
|
|
|
1250
1404
|
case "rad":
|
|
1251
1405
|
return `${angle.value}${angle.type}`;
|
|
1252
1406
|
default:
|
|
1253
|
-
builder.addWarning("value", angle.value);
|
|
1407
|
+
builder.addWarning("value", `${angle.value} ${angle.type}`);
|
|
1254
1408
|
return undefined;
|
|
1255
1409
|
}
|
|
1256
1410
|
}
|
|
@@ -1333,7 +1487,7 @@ export function parseSize(
|
|
|
1333
1487
|
return;
|
|
1334
1488
|
}
|
|
1335
1489
|
|
|
1336
|
-
export function
|
|
1490
|
+
export function parseColorOrAutoDeclaration(
|
|
1337
1491
|
{ value }: { value: ColorOrAuto },
|
|
1338
1492
|
builder: StylesheetBuilder,
|
|
1339
1493
|
) {
|
|
@@ -1835,7 +1989,13 @@ export function parseOverflow(
|
|
|
1835
1989
|
}
|
|
1836
1990
|
|
|
1837
1991
|
export function parseBorderStyleDeclaration(
|
|
1838
|
-
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
|
+
>,
|
|
1839
1999
|
builder: StylesheetBuilder,
|
|
1840
2000
|
) {
|
|
1841
2001
|
return parseBorderStyle(declaration.value, builder);
|
|
@@ -1868,17 +2028,8 @@ export function parseBorderStyle(
|
|
|
1868
2028
|
return undefined;
|
|
1869
2029
|
}
|
|
1870
2030
|
|
|
1871
|
-
export function parseBorderBlockColor(
|
|
1872
|
-
{ value }: { value: BorderBlockColor },
|
|
1873
|
-
builder: StylesheetBuilder,
|
|
1874
|
-
) {
|
|
1875
|
-
builder.addDescriptor("border-top-color", parseColor(value.start, builder));
|
|
1876
|
-
builder.addDescriptor("border-bottom-color", parseColor(value.end, builder));
|
|
1877
|
-
return;
|
|
1878
|
-
}
|
|
1879
|
-
|
|
1880
2031
|
export function parseBorderBlockWidth(
|
|
1881
|
-
declaration: DeclarationType<"border-block-width"
|
|
2032
|
+
declaration: DeclarationType<"border-block-width">,
|
|
1882
2033
|
builder: StylesheetBuilder,
|
|
1883
2034
|
) {
|
|
1884
2035
|
builder.addDescriptor(
|
|
@@ -1891,11 +2042,48 @@ export function parseBorderBlockWidth(
|
|
|
1891
2042
|
);
|
|
1892
2043
|
}
|
|
1893
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
|
+
|
|
1894
2059
|
export function parseBorderSideWidthDeclaration(
|
|
1895
|
-
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
|
+
>,
|
|
1896
2070
|
builder: StylesheetBuilder,
|
|
1897
2071
|
) {
|
|
1898
|
-
|
|
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
|
+
}
|
|
1899
2087
|
}
|
|
1900
2088
|
|
|
1901
2089
|
export function parseBorderSideWidth(
|
|
@@ -1958,7 +2146,8 @@ export function parseLineHeight(
|
|
|
1958
2146
|
case "percentage":
|
|
1959
2147
|
case "calc":
|
|
1960
2148
|
builder.addWarning(
|
|
1961
|
-
"
|
|
2149
|
+
"style",
|
|
2150
|
+
"line-height",
|
|
1962
2151
|
typeof length.value === "number"
|
|
1963
2152
|
? length.value
|
|
1964
2153
|
: JSON.stringify(length.value),
|
|
@@ -2065,8 +2254,14 @@ export function parseGap(
|
|
|
2065
2254
|
builder: StylesheetBuilder,
|
|
2066
2255
|
) {
|
|
2067
2256
|
if ("column" in declaration.value) {
|
|
2068
|
-
builder.addDescriptor(
|
|
2069
|
-
|
|
2257
|
+
builder.addDescriptor(
|
|
2258
|
+
"row-gap",
|
|
2259
|
+
parseGapValue(declaration.value.row, builder),
|
|
2260
|
+
);
|
|
2261
|
+
builder.addDescriptor(
|
|
2262
|
+
"column-gap",
|
|
2263
|
+
parseGapValue(declaration.value.column, builder),
|
|
2264
|
+
);
|
|
2070
2265
|
|
|
2071
2266
|
return;
|
|
2072
2267
|
} else {
|
|
@@ -2079,6 +2274,17 @@ export function parseGap(
|
|
|
2079
2274
|
}
|
|
2080
2275
|
}
|
|
2081
2276
|
|
|
2277
|
+
function parseGapValue(
|
|
2278
|
+
value: GapValue,
|
|
2279
|
+
builder: StylesheetBuilder,
|
|
2280
|
+
): StyleDescriptor {
|
|
2281
|
+
if (value.type === "normal") {
|
|
2282
|
+
return;
|
|
2283
|
+
} else {
|
|
2284
|
+
return parseLength(value.value, builder);
|
|
2285
|
+
}
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2082
2288
|
export function parseTextAlign(
|
|
2083
2289
|
{ value }: DeclarationType<"text-align">,
|
|
2084
2290
|
builder: StylesheetBuilder,
|
|
@@ -2204,7 +2410,11 @@ export function parseDimension(
|
|
|
2204
2410
|
): StyleDescriptor {
|
|
2205
2411
|
switch (unit) {
|
|
2206
2412
|
case "px":
|
|
2207
|
-
|
|
2413
|
+
if (value === Infinity) {
|
|
2414
|
+
return 9999;
|
|
2415
|
+
} else {
|
|
2416
|
+
return value;
|
|
2417
|
+
}
|
|
2208
2418
|
case "%":
|
|
2209
2419
|
return `${value}%`;
|
|
2210
2420
|
case "rnh":
|
|
@@ -2231,20 +2441,25 @@ export function parseUserSelect(
|
|
|
2231
2441
|
}
|
|
2232
2442
|
|
|
2233
2443
|
export function parseSVGPaint(
|
|
2234
|
-
{ value }: DeclarationType<"fill" | "stroke">,
|
|
2444
|
+
{ value, property }: DeclarationType<"fill" | "stroke">,
|
|
2235
2445
|
builder: StylesheetBuilder,
|
|
2236
2446
|
) {
|
|
2447
|
+
let parsedValue: StyleDescriptor | undefined;
|
|
2448
|
+
|
|
2237
2449
|
if (value.type === "none") {
|
|
2238
|
-
|
|
2450
|
+
parsedValue = "transparent";
|
|
2239
2451
|
} else if (value.type === "color") {
|
|
2240
|
-
|
|
2452
|
+
parsedValue = parseColor(value.value, builder);
|
|
2453
|
+
} else {
|
|
2454
|
+
return;
|
|
2241
2455
|
}
|
|
2242
2456
|
|
|
2243
|
-
|
|
2457
|
+
builder.addMapping({ [property]: [property] });
|
|
2458
|
+
builder.addDescriptor(property, parsedValue);
|
|
2244
2459
|
}
|
|
2245
2460
|
|
|
2246
2461
|
export function round(number: number) {
|
|
2247
|
-
return Math.round((number + Number.EPSILON) *
|
|
2462
|
+
return Math.round((number + Number.EPSILON) * 10000) / 10000;
|
|
2248
2463
|
}
|
|
2249
2464
|
|
|
2250
2465
|
export function parseDimensionPercentageFor_LengthValue(
|
|
@@ -2260,7 +2475,7 @@ export function parseDimensionPercentageFor_LengthValue(
|
|
|
2260
2475
|
}
|
|
2261
2476
|
}
|
|
2262
2477
|
|
|
2263
|
-
const
|
|
2478
|
+
const allowAutoProperties = new Set(["pointer-events"]);
|
|
2264
2479
|
|
|
2265
2480
|
export function parseEnv(
|
|
2266
2481
|
value: EnvironmentVariable,
|
|
@@ -2278,7 +2493,7 @@ export function parseEnv(
|
|
|
2278
2493
|
"var",
|
|
2279
2494
|
[
|
|
2280
2495
|
`--react-native-css-${value.name.value}`,
|
|
2281
|
-
parseUnparsed(value.fallback, builder),
|
|
2496
|
+
parseUnparsed(value.fallback, builder, value.name.value),
|
|
2282
2497
|
],
|
|
2283
2498
|
1,
|
|
2284
2499
|
];
|
|
@@ -2301,8 +2516,9 @@ export function parseCalcFn(
|
|
|
2301
2516
|
name: string,
|
|
2302
2517
|
tokens: TokenOrValue[],
|
|
2303
2518
|
builder: StylesheetBuilder,
|
|
2519
|
+
property: string,
|
|
2304
2520
|
): StyleDescriptor {
|
|
2305
|
-
const args = parseCalcArguments(tokens, builder);
|
|
2521
|
+
const args = parseCalcArguments(tokens, builder, property);
|
|
2306
2522
|
if (args) {
|
|
2307
2523
|
return [{}, name, args];
|
|
2308
2524
|
}
|
|
@@ -2313,6 +2529,7 @@ export function parseCalcFn(
|
|
|
2313
2529
|
export function parseCalcArguments(
|
|
2314
2530
|
[...args]: TokenOrValue[],
|
|
2315
2531
|
builder: StylesheetBuilder,
|
|
2532
|
+
property: string,
|
|
2316
2533
|
) {
|
|
2317
2534
|
const parsed: StyleDescriptor[] = [];
|
|
2318
2535
|
|
|
@@ -2327,7 +2544,7 @@ export function parseCalcArguments(
|
|
|
2327
2544
|
case "var":
|
|
2328
2545
|
case "function":
|
|
2329
2546
|
case "unresolved-color": {
|
|
2330
|
-
const value = parseUnparsed(arg, builder);
|
|
2547
|
+
const value = parseUnparsed(arg, builder, property);
|
|
2331
2548
|
|
|
2332
2549
|
if (value === undefined) {
|
|
2333
2550
|
return undefined;
|
|
@@ -2403,7 +2620,7 @@ export function parseCalcArguments(
|
|
|
2403
2620
|
// Then drop the surrounding parenthesis
|
|
2404
2621
|
.slice(1, -1);
|
|
2405
2622
|
|
|
2406
|
-
parsed.push(parseCalcFn("calc", innerCalcArgs, builder));
|
|
2623
|
+
parsed.push(parseCalcFn("calc", innerCalcArgs, builder, property));
|
|
2407
2624
|
|
|
2408
2625
|
break;
|
|
2409
2626
|
}
|
|
@@ -2456,6 +2673,8 @@ export function parseTranslateProp(
|
|
|
2456
2673
|
export function parseUnresolvedColor(
|
|
2457
2674
|
color: UnresolvedColor,
|
|
2458
2675
|
builder: StylesheetBuilder,
|
|
2676
|
+
property: string,
|
|
2677
|
+
allowAuto: boolean,
|
|
2459
2678
|
): StyleDescriptor {
|
|
2460
2679
|
switch (color.type) {
|
|
2461
2680
|
case "rgb":
|
|
@@ -2466,26 +2685,31 @@ export function parseUnresolvedColor(
|
|
|
2466
2685
|
round(color.r * 255),
|
|
2467
2686
|
round(color.g * 255),
|
|
2468
2687
|
round(color.b * 255),
|
|
2469
|
-
parseUnparsed(color.alpha, builder),
|
|
2688
|
+
parseUnparsed(color.alpha, builder, property),
|
|
2470
2689
|
],
|
|
2471
2690
|
];
|
|
2472
2691
|
case "hsl":
|
|
2473
2692
|
return [
|
|
2474
2693
|
{},
|
|
2475
2694
|
color.type,
|
|
2476
|
-
[
|
|
2695
|
+
[
|
|
2696
|
+
color.h,
|
|
2697
|
+
color.s,
|
|
2698
|
+
color.l,
|
|
2699
|
+
parseUnparsed(color.alpha, builder, property),
|
|
2700
|
+
],
|
|
2477
2701
|
];
|
|
2478
2702
|
case "light-dark": {
|
|
2479
2703
|
const extraRule = builder.extendRule({
|
|
2480
2704
|
m: [["=", "prefers-color-scheme", "dark"]],
|
|
2481
2705
|
});
|
|
2482
2706
|
builder.addUnnamedDescriptor(
|
|
2483
|
-
reduceParseUnparsed(color.dark, builder),
|
|
2707
|
+
reduceParseUnparsed(color.dark, builder, property, allowAuto),
|
|
2484
2708
|
false,
|
|
2485
2709
|
extraRule,
|
|
2486
2710
|
);
|
|
2487
2711
|
builder.addExtraRule(extraRule);
|
|
2488
|
-
return reduceParseUnparsed(color.light, builder);
|
|
2712
|
+
return reduceParseUnparsed(color.light, builder, property, allowAuto);
|
|
2489
2713
|
}
|
|
2490
2714
|
default:
|
|
2491
2715
|
color satisfies never;
|