react-native-css 3.0.0-nightly.27bd5e2 → 3.0.0-nightly.4af17f5
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 +6 -2
- package/dist/commonjs/compiler/atRules.js.map +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 +57 -18
- package/dist/commonjs/compiler/compiler.js.map +1 -1
- package/dist/commonjs/compiler/declarations.js +177 -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 +125 -40
- package/dist/commonjs/compiler/stylesheet.js.map +1 -1
- package/dist/commonjs/jest/index.js +24 -25
- package/dist/commonjs/jest/index.js.map +1 -1
- package/dist/commonjs/metro/index.js +7 -5
- 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 +6 -2
- package/dist/module/compiler/atRules.js.map +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 +57 -18
- 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 +172 -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 +124 -39
- package/dist/module/compiler/stylesheet.js.map +1 -1
- package/dist/module/jest/index.js +25 -10
- package/dist/module/jest/index.js.map +1 -1
- package/dist/module/metro/index.js +7 -5
- 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/example/app.config.d.ts +4 -0
- package/dist/typescript/commonjs/example/app.config.d.ts.map +1 -0
- 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 +23 -5
- package/dist/typescript/commonjs/src/compiler/stylesheet.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/jest/index.d.ts +11 -5
- 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/example/app.config.d.ts +4 -0
- package/dist/typescript/module/example/app.config.d.ts.map +1 -0
- 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 +23 -5
- package/dist/typescript/module/src/compiler/stylesheet.d.ts.map +1 -1
- package/dist/typescript/module/src/jest/index.d.ts +11 -5
- 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 +28 -4
- package/src/compiler/atRules.ts +7 -2
- package/src/compiler/attributes.test.ts +1 -1
- package/src/compiler/compiler.ts +63 -33
- package/src/compiler/compiler.types.ts +7 -5
- package/src/compiler/declarations.ts +300 -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 +168 -38
- package/src/jest/index.ts +34 -11
- package/src/metro/index.ts +12 -6
- 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
- package/types.d.ts +70 -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
|
}
|
|
@@ -1060,6 +1202,8 @@ export function parseUnparsed(
|
|
|
1060
1202
|
return true;
|
|
1061
1203
|
} else if (value === "false") {
|
|
1062
1204
|
return false;
|
|
1205
|
+
} else if (value === "infinity") {
|
|
1206
|
+
return Number.MAX_SAFE_INTEGER;
|
|
1063
1207
|
} else {
|
|
1064
1208
|
return value;
|
|
1065
1209
|
}
|
|
@@ -1076,11 +1220,16 @@ export function parseUnparsed(
|
|
|
1076
1220
|
return parseDimension(tokenOrValue.value, builder);
|
|
1077
1221
|
case "comma":
|
|
1078
1222
|
return CommaSeparator as unknown as StyleDescriptor;
|
|
1223
|
+
case "delim": {
|
|
1224
|
+
if (property === "aspect-ratio" && tokenOrValue.value.value === "/") {
|
|
1225
|
+
return tokenOrValue.value.value;
|
|
1226
|
+
}
|
|
1227
|
+
return;
|
|
1228
|
+
}
|
|
1079
1229
|
case "at-keyword":
|
|
1080
1230
|
case "hash":
|
|
1081
1231
|
case "id-hash":
|
|
1082
1232
|
case "unquoted-url":
|
|
1083
|
-
case "delim":
|
|
1084
1233
|
case "white-space":
|
|
1085
1234
|
case "comment":
|
|
1086
1235
|
case "colon":
|
|
@@ -1151,23 +1300,35 @@ export function parseLength(
|
|
|
1151
1300
|
const { inlineRem = 14 } = builder.getOptions();
|
|
1152
1301
|
|
|
1153
1302
|
if (typeof length === "number") {
|
|
1154
|
-
return length;
|
|
1303
|
+
return round(length);
|
|
1155
1304
|
}
|
|
1156
1305
|
|
|
1157
1306
|
if ("unit" in length) {
|
|
1158
1307
|
switch (length.unit) {
|
|
1159
|
-
case "px":
|
|
1160
|
-
|
|
1308
|
+
case "px": {
|
|
1309
|
+
if (length.value === Infinity) {
|
|
1310
|
+
return 9999;
|
|
1311
|
+
} else if (length.value === -Infinity) {
|
|
1312
|
+
return -9999;
|
|
1313
|
+
} else {
|
|
1314
|
+
// Normalize large values to safe integers, e.g. `calc(infinity * 1px)`
|
|
1315
|
+
const value = Math.max(
|
|
1316
|
+
Math.min(length.value, Number.MAX_SAFE_INTEGER),
|
|
1317
|
+
Number.MIN_SAFE_INTEGER,
|
|
1318
|
+
);
|
|
1319
|
+
return round(value);
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1161
1322
|
case "rem":
|
|
1162
1323
|
if (typeof inlineRem === "number") {
|
|
1163
1324
|
return length.value * inlineRem;
|
|
1164
1325
|
} else {
|
|
1165
|
-
return [{}, "rem", length.value];
|
|
1326
|
+
return [{}, "rem", round(length.value)];
|
|
1166
1327
|
}
|
|
1167
1328
|
case "vw":
|
|
1168
1329
|
case "vh":
|
|
1169
1330
|
case "em":
|
|
1170
|
-
return [{}, length.unit, length.value, 1];
|
|
1331
|
+
return [{}, length.unit, round(length.value), 1];
|
|
1171
1332
|
case "in":
|
|
1172
1333
|
case "cm":
|
|
1173
1334
|
case "mm":
|
|
@@ -1250,7 +1411,7 @@ export function parseAngle(angle: Angle | number, builder: StylesheetBuilder) {
|
|
|
1250
1411
|
case "rad":
|
|
1251
1412
|
return `${angle.value}${angle.type}`;
|
|
1252
1413
|
default:
|
|
1253
|
-
builder.addWarning("value", angle.value);
|
|
1414
|
+
builder.addWarning("value", `${angle.value} ${angle.type}`);
|
|
1254
1415
|
return undefined;
|
|
1255
1416
|
}
|
|
1256
1417
|
}
|
|
@@ -1333,7 +1494,7 @@ export function parseSize(
|
|
|
1333
1494
|
return;
|
|
1334
1495
|
}
|
|
1335
1496
|
|
|
1336
|
-
export function
|
|
1497
|
+
export function parseColorOrAutoDeclaration(
|
|
1337
1498
|
{ value }: { value: ColorOrAuto },
|
|
1338
1499
|
builder: StylesheetBuilder,
|
|
1339
1500
|
) {
|
|
@@ -1835,7 +1996,13 @@ export function parseOverflow(
|
|
|
1835
1996
|
}
|
|
1836
1997
|
|
|
1837
1998
|
export function parseBorderStyleDeclaration(
|
|
1838
|
-
declaration: DeclarationType<
|
|
1999
|
+
declaration: DeclarationType<
|
|
2000
|
+
| "border-style"
|
|
2001
|
+
| "border-left-style"
|
|
2002
|
+
| "border-right-style"
|
|
2003
|
+
| "border-top-style"
|
|
2004
|
+
| "border-bottom-style"
|
|
2005
|
+
>,
|
|
1839
2006
|
builder: StylesheetBuilder,
|
|
1840
2007
|
) {
|
|
1841
2008
|
return parseBorderStyle(declaration.value, builder);
|
|
@@ -1868,17 +2035,8 @@ export function parseBorderStyle(
|
|
|
1868
2035
|
return undefined;
|
|
1869
2036
|
}
|
|
1870
2037
|
|
|
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
2038
|
export function parseBorderBlockWidth(
|
|
1881
|
-
declaration: DeclarationType<"border-block-width"
|
|
2039
|
+
declaration: DeclarationType<"border-block-width">,
|
|
1882
2040
|
builder: StylesheetBuilder,
|
|
1883
2041
|
) {
|
|
1884
2042
|
builder.addDescriptor(
|
|
@@ -1891,11 +2049,48 @@ export function parseBorderBlockWidth(
|
|
|
1891
2049
|
);
|
|
1892
2050
|
}
|
|
1893
2051
|
|
|
2052
|
+
function parseBorderBlockStyle(
|
|
2053
|
+
declaration: DeclarationType<"border-block-style">,
|
|
2054
|
+
builder: StylesheetBuilder,
|
|
2055
|
+
) {
|
|
2056
|
+
if (declaration.value.start === declaration.value.end) {
|
|
2057
|
+
builder.addDescriptor(
|
|
2058
|
+
"border-style",
|
|
2059
|
+
parseBorderStyle(declaration.value.start, builder),
|
|
2060
|
+
);
|
|
2061
|
+
} else {
|
|
2062
|
+
builder.addWarning("property", "border-block-style");
|
|
2063
|
+
}
|
|
2064
|
+
}
|
|
2065
|
+
|
|
1894
2066
|
export function parseBorderSideWidthDeclaration(
|
|
1895
|
-
declaration:
|
|
2067
|
+
declaration: DeclarationType<
|
|
2068
|
+
| "border-block-end-width"
|
|
2069
|
+
| "border-block-start-width"
|
|
2070
|
+
| "border-bottom-width"
|
|
2071
|
+
| "border-inline-end-width"
|
|
2072
|
+
| "border-inline-start-width"
|
|
2073
|
+
| "border-left-width"
|
|
2074
|
+
| "border-right-width"
|
|
2075
|
+
| "border-top-width"
|
|
2076
|
+
>,
|
|
1896
2077
|
builder: StylesheetBuilder,
|
|
1897
2078
|
) {
|
|
1898
|
-
|
|
2079
|
+
if (declaration.property.includes("block")) {
|
|
2080
|
+
builder.addDescriptor(
|
|
2081
|
+
`border-${declaration.property.includes("start") ? "top" : "bottom"}-width`,
|
|
2082
|
+
parseBorderSideWidth(declaration.value, builder),
|
|
2083
|
+
);
|
|
2084
|
+
return;
|
|
2085
|
+
} else if (declaration.property.includes("inline")) {
|
|
2086
|
+
builder.addDescriptor(
|
|
2087
|
+
`border-${declaration.property.includes("start") ? "left" : "right"}-width`,
|
|
2088
|
+
parseBorderSideWidth(declaration.value, builder),
|
|
2089
|
+
);
|
|
2090
|
+
return;
|
|
2091
|
+
} else {
|
|
2092
|
+
return parseBorderSideWidth(declaration.value, builder);
|
|
2093
|
+
}
|
|
1899
2094
|
}
|
|
1900
2095
|
|
|
1901
2096
|
export function parseBorderSideWidth(
|
|
@@ -1958,7 +2153,8 @@ export function parseLineHeight(
|
|
|
1958
2153
|
case "percentage":
|
|
1959
2154
|
case "calc":
|
|
1960
2155
|
builder.addWarning(
|
|
1961
|
-
"
|
|
2156
|
+
"style",
|
|
2157
|
+
"line-height",
|
|
1962
2158
|
typeof length.value === "number"
|
|
1963
2159
|
? length.value
|
|
1964
2160
|
: JSON.stringify(length.value),
|
|
@@ -2065,8 +2261,14 @@ export function parseGap(
|
|
|
2065
2261
|
builder: StylesheetBuilder,
|
|
2066
2262
|
) {
|
|
2067
2263
|
if ("column" in declaration.value) {
|
|
2068
|
-
builder.addDescriptor(
|
|
2069
|
-
|
|
2264
|
+
builder.addDescriptor(
|
|
2265
|
+
"row-gap",
|
|
2266
|
+
parseGapValue(declaration.value.row, builder),
|
|
2267
|
+
);
|
|
2268
|
+
builder.addDescriptor(
|
|
2269
|
+
"column-gap",
|
|
2270
|
+
parseGapValue(declaration.value.column, builder),
|
|
2271
|
+
);
|
|
2070
2272
|
|
|
2071
2273
|
return;
|
|
2072
2274
|
} else {
|
|
@@ -2079,6 +2281,17 @@ export function parseGap(
|
|
|
2079
2281
|
}
|
|
2080
2282
|
}
|
|
2081
2283
|
|
|
2284
|
+
function parseGapValue(
|
|
2285
|
+
value: GapValue,
|
|
2286
|
+
builder: StylesheetBuilder,
|
|
2287
|
+
): StyleDescriptor {
|
|
2288
|
+
if (value.type === "normal") {
|
|
2289
|
+
return;
|
|
2290
|
+
} else {
|
|
2291
|
+
return parseLength(value.value, builder);
|
|
2292
|
+
}
|
|
2293
|
+
}
|
|
2294
|
+
|
|
2082
2295
|
export function parseTextAlign(
|
|
2083
2296
|
{ value }: DeclarationType<"text-align">,
|
|
2084
2297
|
builder: StylesheetBuilder,
|
|
@@ -2204,7 +2417,11 @@ export function parseDimension(
|
|
|
2204
2417
|
): StyleDescriptor {
|
|
2205
2418
|
switch (unit) {
|
|
2206
2419
|
case "px":
|
|
2207
|
-
|
|
2420
|
+
if (value === Infinity) {
|
|
2421
|
+
return 9999;
|
|
2422
|
+
} else {
|
|
2423
|
+
return value;
|
|
2424
|
+
}
|
|
2208
2425
|
case "%":
|
|
2209
2426
|
return `${value}%`;
|
|
2210
2427
|
case "rnh":
|
|
@@ -2231,20 +2448,25 @@ export function parseUserSelect(
|
|
|
2231
2448
|
}
|
|
2232
2449
|
|
|
2233
2450
|
export function parseSVGPaint(
|
|
2234
|
-
{ value }: DeclarationType<"fill" | "stroke">,
|
|
2451
|
+
{ value, property }: DeclarationType<"fill" | "stroke">,
|
|
2235
2452
|
builder: StylesheetBuilder,
|
|
2236
2453
|
) {
|
|
2454
|
+
let parsedValue: StyleDescriptor | undefined;
|
|
2455
|
+
|
|
2237
2456
|
if (value.type === "none") {
|
|
2238
|
-
|
|
2457
|
+
parsedValue = "transparent";
|
|
2239
2458
|
} else if (value.type === "color") {
|
|
2240
|
-
|
|
2459
|
+
parsedValue = parseColor(value.value, builder);
|
|
2460
|
+
} else {
|
|
2461
|
+
return;
|
|
2241
2462
|
}
|
|
2242
2463
|
|
|
2243
|
-
|
|
2464
|
+
builder.addMapping({ [property]: [property] });
|
|
2465
|
+
builder.addDescriptor(property, parsedValue);
|
|
2244
2466
|
}
|
|
2245
2467
|
|
|
2246
2468
|
export function round(number: number) {
|
|
2247
|
-
return Math.round((number + Number.EPSILON) *
|
|
2469
|
+
return Math.round((number + Number.EPSILON) * 10000) / 10000;
|
|
2248
2470
|
}
|
|
2249
2471
|
|
|
2250
2472
|
export function parseDimensionPercentageFor_LengthValue(
|
|
@@ -2260,7 +2482,7 @@ export function parseDimensionPercentageFor_LengthValue(
|
|
|
2260
2482
|
}
|
|
2261
2483
|
}
|
|
2262
2484
|
|
|
2263
|
-
const
|
|
2485
|
+
const allowAutoProperties = new Set(["pointer-events"]);
|
|
2264
2486
|
|
|
2265
2487
|
export function parseEnv(
|
|
2266
2488
|
value: EnvironmentVariable,
|
|
@@ -2278,7 +2500,7 @@ export function parseEnv(
|
|
|
2278
2500
|
"var",
|
|
2279
2501
|
[
|
|
2280
2502
|
`--react-native-css-${value.name.value}`,
|
|
2281
|
-
parseUnparsed(value.fallback, builder),
|
|
2503
|
+
parseUnparsed(value.fallback, builder, value.name.value),
|
|
2282
2504
|
],
|
|
2283
2505
|
1,
|
|
2284
2506
|
];
|
|
@@ -2301,8 +2523,9 @@ export function parseCalcFn(
|
|
|
2301
2523
|
name: string,
|
|
2302
2524
|
tokens: TokenOrValue[],
|
|
2303
2525
|
builder: StylesheetBuilder,
|
|
2526
|
+
property: string,
|
|
2304
2527
|
): StyleDescriptor {
|
|
2305
|
-
const args = parseCalcArguments(tokens, builder);
|
|
2528
|
+
const args = parseCalcArguments(tokens, builder, property);
|
|
2306
2529
|
if (args) {
|
|
2307
2530
|
return [{}, name, args];
|
|
2308
2531
|
}
|
|
@@ -2313,6 +2536,7 @@ export function parseCalcFn(
|
|
|
2313
2536
|
export function parseCalcArguments(
|
|
2314
2537
|
[...args]: TokenOrValue[],
|
|
2315
2538
|
builder: StylesheetBuilder,
|
|
2539
|
+
property: string,
|
|
2316
2540
|
) {
|
|
2317
2541
|
const parsed: StyleDescriptor[] = [];
|
|
2318
2542
|
|
|
@@ -2327,7 +2551,7 @@ export function parseCalcArguments(
|
|
|
2327
2551
|
case "var":
|
|
2328
2552
|
case "function":
|
|
2329
2553
|
case "unresolved-color": {
|
|
2330
|
-
const value = parseUnparsed(arg, builder);
|
|
2554
|
+
const value = parseUnparsed(arg, builder, property);
|
|
2331
2555
|
|
|
2332
2556
|
if (value === undefined) {
|
|
2333
2557
|
return undefined;
|
|
@@ -2403,7 +2627,7 @@ export function parseCalcArguments(
|
|
|
2403
2627
|
// Then drop the surrounding parenthesis
|
|
2404
2628
|
.slice(1, -1);
|
|
2405
2629
|
|
|
2406
|
-
parsed.push(parseCalcFn("calc", innerCalcArgs, builder));
|
|
2630
|
+
parsed.push(parseCalcFn("calc", innerCalcArgs, builder, property));
|
|
2407
2631
|
|
|
2408
2632
|
break;
|
|
2409
2633
|
}
|
|
@@ -2456,6 +2680,8 @@ export function parseTranslateProp(
|
|
|
2456
2680
|
export function parseUnresolvedColor(
|
|
2457
2681
|
color: UnresolvedColor,
|
|
2458
2682
|
builder: StylesheetBuilder,
|
|
2683
|
+
property: string,
|
|
2684
|
+
allowAuto: boolean,
|
|
2459
2685
|
): StyleDescriptor {
|
|
2460
2686
|
switch (color.type) {
|
|
2461
2687
|
case "rgb":
|
|
@@ -2466,26 +2692,31 @@ export function parseUnresolvedColor(
|
|
|
2466
2692
|
round(color.r * 255),
|
|
2467
2693
|
round(color.g * 255),
|
|
2468
2694
|
round(color.b * 255),
|
|
2469
|
-
parseUnparsed(color.alpha, builder),
|
|
2695
|
+
parseUnparsed(color.alpha, builder, property),
|
|
2470
2696
|
],
|
|
2471
2697
|
];
|
|
2472
2698
|
case "hsl":
|
|
2473
2699
|
return [
|
|
2474
2700
|
{},
|
|
2475
2701
|
color.type,
|
|
2476
|
-
[
|
|
2702
|
+
[
|
|
2703
|
+
color.h,
|
|
2704
|
+
color.s,
|
|
2705
|
+
color.l,
|
|
2706
|
+
parseUnparsed(color.alpha, builder, property),
|
|
2707
|
+
],
|
|
2477
2708
|
];
|
|
2478
2709
|
case "light-dark": {
|
|
2479
2710
|
const extraRule = builder.extendRule({
|
|
2480
2711
|
m: [["=", "prefers-color-scheme", "dark"]],
|
|
2481
2712
|
});
|
|
2482
2713
|
builder.addUnnamedDescriptor(
|
|
2483
|
-
reduceParseUnparsed(color.dark, builder),
|
|
2714
|
+
reduceParseUnparsed(color.dark, builder, property, allowAuto),
|
|
2484
2715
|
false,
|
|
2485
2716
|
extraRule,
|
|
2486
2717
|
);
|
|
2487
2718
|
builder.addExtraRule(extraRule);
|
|
2488
|
-
return reduceParseUnparsed(color.light, builder);
|
|
2719
|
+
return reduceParseUnparsed(color.light, builder, property, allowAuto);
|
|
2489
2720
|
}
|
|
2490
2721
|
default:
|
|
2491
2722
|
color satisfies never;
|