react-native-css 0.0.0-nightly.61d67fe → 0.0.0-nightly.96f5ce2
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 +3 -1
- package/dist/commonjs/compiler/atRules.js.map +1 -1
- package/dist/commonjs/compiler/declarations.js +106 -25
- package/dist/commonjs/compiler/declarations.js.map +1 -1
- package/dist/commonjs/compiler/stylesheet.js +5 -0
- package/dist/commonjs/compiler/stylesheet.js.map +1 -1
- package/dist/commonjs/jest/index.js +0 -1
- package/dist/commonjs/jest/index.js.map +1 -1
- package/dist/commonjs/runtime/native/api.js +21 -2
- package/dist/commonjs/runtime/native/api.js.map +1 -1
- package/dist/commonjs/runtime/native/reactivity.js +1 -5
- package/dist/commonjs/runtime/native/reactivity.js.map +1 -1
- package/dist/commonjs/runtime/native/styles/units.js +10 -8
- package/dist/commonjs/runtime/native/styles/units.js.map +1 -1
- package/dist/commonjs/runtime/web/api.js +18 -0
- package/dist/commonjs/runtime/web/api.js.map +1 -1
- package/dist/commonjs/style-collection/root.js +1 -0
- package/dist/commonjs/style-collection/root.js.map +1 -1
- package/dist/module/compiler/atRules.js +3 -1
- package/dist/module/compiler/atRules.js.map +1 -1
- package/dist/module/compiler/declarations.js +101 -25
- package/dist/module/compiler/declarations.js.map +1 -1
- package/dist/module/compiler/stylesheet.js +5 -0
- package/dist/module/compiler/stylesheet.js.map +1 -1
- package/dist/module/jest/index.js +1 -2
- package/dist/module/jest/index.js.map +1 -1
- package/dist/module/runtime/native/api.js +21 -3
- package/dist/module/runtime/native/api.js.map +1 -1
- package/dist/module/runtime/native/reactivity.js +0 -4
- package/dist/module/runtime/native/reactivity.js.map +1 -1
- package/dist/module/runtime/native/styles/units.js +11 -8
- package/dist/module/runtime/native/styles/units.js.map +1 -1
- package/dist/module/runtime/web/api.js +18 -1
- package/dist/module/runtime/web/api.js.map +1 -1
- package/dist/module/style-collection/root.js +1 -0
- package/dist/module/style-collection/root.js.map +1 -1
- package/dist/typescript/commonjs/src/compiler/atRules.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/compiler/declarations.d.ts +12 -1
- package/dist/typescript/commonjs/src/compiler/declarations.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/compiler/stylesheet.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/jest/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/runtime/native/api.d.ts +13 -1
- package/dist/typescript/commonjs/src/runtime/native/api.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/runtime/native/reactivity.d.ts +0 -2
- package/dist/typescript/commonjs/src/runtime/native/reactivity.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/web/api.d.ts +8 -2
- package/dist/typescript/commonjs/src/runtime/web/api.d.ts.map +1 -1
- package/dist/typescript/module/src/compiler/atRules.d.ts.map +1 -1
- package/dist/typescript/module/src/compiler/declarations.d.ts +12 -1
- package/dist/typescript/module/src/compiler/declarations.d.ts.map +1 -1
- package/dist/typescript/module/src/compiler/stylesheet.d.ts.map +1 -1
- package/dist/typescript/module/src/jest/index.d.ts.map +1 -1
- package/dist/typescript/module/src/runtime/native/api.d.ts +13 -1
- package/dist/typescript/module/src/runtime/native/api.d.ts.map +1 -1
- package/dist/typescript/module/src/runtime/native/reactivity.d.ts +0 -2
- package/dist/typescript/module/src/runtime/native/reactivity.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/web/api.d.ts +8 -2
- package/dist/typescript/module/src/runtime/web/api.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/compiler/atRules.ts +2 -0
- package/src/compiler/declarations.ts +137 -37
- package/src/compiler/stylesheet.ts +6 -0
- package/src/jest/index.ts +1 -2
- package/src/runtime/native/{api.ts → api.tsx} +31 -4
- package/src/runtime/native/reactivity.ts +0 -4
- package/src/runtime/native/styles/units.ts +13 -8
- package/src/runtime/web/{api.ts → api.tsx} +28 -2
- package/src/style-collection/root.ts +2 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../../../../src/runtime/web/api.
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../../../../src/runtime/web/api.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACvB,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EACV,WAAW,EACX,KAAK,EACL,mBAAmB,EACnB,aAAa,EACb,WAAW,EACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG/C,eAAO,MAAM,MAAM,GACjB,KAAK,CAAC,CAAC,SAAS,cAAc,EAC9B,KAAK,CAAC,CAAC,SAAS,mBAAmB,CAAC,CAAC,CAAC,EAEtC,eAAe,CAAC,EAChB,SAAS,CAAC,EACV,WAAW,aAAa,MAEhB,OAAO,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,2FAGjD,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,cAAc,EACpD,WAAW,CAAC,EACZ,eAAe,KAAK,EACpB,SAAS,mBAAmB,CAAC,CAAC,CAAC,2FA4BhC,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,WAOzB,CAAC;AAEF;;GAEG;AACH,wBAAgB,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,0BAW9D;AAED,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,iBAAiB,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC,KAAK,MAAM,EAAE,EAAE,MAAM,CAAC,CAAA;CAAE,CAAC,2CAenE;AAED,eAAO,MAAM,iBAAiB,aAE7B,CAAC;AAEF,eAAO,MAAM,yBAAyB,aAErC,CAAC"}
|
package/package.json
CHANGED
package/src/compiler/atRules.ts
CHANGED
|
@@ -88,6 +88,8 @@ export function parsePropAtRule(rules?: (Rule | PropAtRule)[]) {
|
|
|
88
88
|
"-webkit-line-clamp": ["numberOfLines"],
|
|
89
89
|
"-rn-ripple-color": ["android_ripple", "color"],
|
|
90
90
|
"-rn-ripple-style": ["android_ripple", "borderless"],
|
|
91
|
+
"-rn-ripple-radius": ["android_ripple", "radius"],
|
|
92
|
+
"-rn-ripple-layer": ["android_ripple", "foreground"],
|
|
91
93
|
};
|
|
92
94
|
|
|
93
95
|
if (!rules) return mapping;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// cSpell:ignore rcap,vmin,svmin,lvmin,dvmin,cqmin,vmax,svmax,lvmax,dvmax,cqmax,currentcolor,oklab,oklch,prophoto
|
|
1
|
+
// cSpell:ignore rcap,vmin,svmin,lvmin,dvmin,cqmin,vmax,svmax,lvmax,dvmax,cqmax,currentcolor,oklab,oklch,prophoto,squircle,oldstyle,nums
|
|
2
2
|
|
|
3
3
|
import Color from "colorjs.io";
|
|
4
4
|
import type {
|
|
@@ -91,6 +91,7 @@ const parsers: {
|
|
|
91
91
|
"animation-play-state": addAnimationValue,
|
|
92
92
|
"animation-timing-function": addAnimationValue,
|
|
93
93
|
"aspect-ratio": parseAspectRatio,
|
|
94
|
+
"backface-visibility": parseBackfaceVisibility,
|
|
94
95
|
"background-color": parseColorDeclaration,
|
|
95
96
|
"background-image": parseBackgroundImage,
|
|
96
97
|
"block-size": parseSizeDeclaration,
|
|
@@ -146,8 +147,9 @@ const parsers: {
|
|
|
146
147
|
"border-top-style": parseBorderStyleDeclaration,
|
|
147
148
|
"border-top-width": parseBorderSideWidthDeclaration,
|
|
148
149
|
"border-width": parseBorderWidth,
|
|
149
|
-
"bottom":
|
|
150
|
+
"bottom": parseSizeWithAutoDeclaration,
|
|
150
151
|
"box-shadow": parseBoxShadow,
|
|
152
|
+
"box-sizing": parseBoxSizing,
|
|
151
153
|
"caret-color": parseColorOrAutoDeclaration,
|
|
152
154
|
"color": parseFontColorDeclaration,
|
|
153
155
|
"column-gap": parseGap,
|
|
@@ -155,10 +157,11 @@ const parsers: {
|
|
|
155
157
|
"container-name": parseContainerName,
|
|
156
158
|
"container-type": parseContainerType,
|
|
157
159
|
"display": parseDisplay,
|
|
160
|
+
"direction": parseDirection,
|
|
158
161
|
"fill": parseSVGPaint,
|
|
159
162
|
"filter": parseFilter,
|
|
160
163
|
"flex": parseFlex,
|
|
161
|
-
"flex-basis":
|
|
164
|
+
"flex-basis": parseLengthPercentageDeclaration,
|
|
162
165
|
"flex-direction": ({ value }) => value,
|
|
163
166
|
"flex-flow": parseFlexFlow,
|
|
164
167
|
"flex-grow": ({ value }) => value,
|
|
@@ -175,26 +178,26 @@ const parsers: {
|
|
|
175
178
|
"inline-size": parseSizeDeclaration,
|
|
176
179
|
"inset": parseInset,
|
|
177
180
|
"inset-block": parseInsetBlock,
|
|
178
|
-
"inset-block-end":
|
|
179
|
-
"inset-block-start":
|
|
181
|
+
"inset-block-end": parseLengthPercentageDeclaration,
|
|
182
|
+
"inset-block-start": parseLengthPercentageDeclaration,
|
|
180
183
|
"inset-inline": parseInsetInline,
|
|
181
|
-
"inset-inline-end":
|
|
182
|
-
"inset-inline-start":
|
|
184
|
+
"inset-inline-end": parseLengthPercentageDeclaration,
|
|
185
|
+
"inset-inline-start": parseLengthPercentageDeclaration,
|
|
183
186
|
"justify-content": parseJustifyContent,
|
|
184
|
-
"left":
|
|
187
|
+
"left": parseSizeWithAutoDeclaration,
|
|
185
188
|
"letter-spacing": parseLetterSpacing,
|
|
186
189
|
"line-height": parseLineHeightDeclaration,
|
|
187
190
|
"margin": parseMargin,
|
|
188
191
|
"margin-block": parseMarginBlock,
|
|
189
192
|
"margin-block-end": parseLengthPercentageOrAutoDeclaration,
|
|
190
193
|
"margin-block-start": parseLengthPercentageOrAutoDeclaration,
|
|
191
|
-
"margin-bottom":
|
|
194
|
+
"margin-bottom": parseSizeWithAutoDeclaration,
|
|
192
195
|
"margin-inline": parseMarginInline,
|
|
193
196
|
"margin-inline-end": parseLengthPercentageOrAutoDeclaration,
|
|
194
197
|
"margin-inline-start": parseLengthPercentageOrAutoDeclaration,
|
|
195
|
-
"margin-left":
|
|
196
|
-
"margin-right":
|
|
197
|
-
"margin-top":
|
|
198
|
+
"margin-left": parseSizeWithAutoDeclaration,
|
|
199
|
+
"margin-right": parseSizeWithAutoDeclaration,
|
|
200
|
+
"margin-top": parseSizeWithAutoDeclaration,
|
|
198
201
|
"max-block-size": parseSizeDeclaration,
|
|
199
202
|
"max-height": parseSizeDeclaration,
|
|
200
203
|
"max-inline-size": parseSizeDeclaration,
|
|
@@ -203,21 +206,24 @@ const parsers: {
|
|
|
203
206
|
"min-height": parseSizeDeclaration,
|
|
204
207
|
"min-inline-size": parseSizeDeclaration,
|
|
205
208
|
"min-width": parseSizeDeclaration,
|
|
206
|
-
"opacity": ({ value }) => value,
|
|
209
|
+
"opacity": ({ value }) => round(value),
|
|
210
|
+
"outline-color": parseColorDeclaration,
|
|
211
|
+
"outline-style": parseOutlineStyle,
|
|
212
|
+
"outline-width": parseBorderSideWidthDeclaration,
|
|
207
213
|
"overflow": parseOverflow,
|
|
208
214
|
"padding": parsePadding,
|
|
209
215
|
"padding-block": parsePaddingBlock,
|
|
210
|
-
"padding-block-end":
|
|
211
|
-
"padding-block-start":
|
|
216
|
+
"padding-block-end": parseLengthPercentageDeclaration,
|
|
217
|
+
"padding-block-start": parseLengthPercentageDeclaration,
|
|
212
218
|
"padding-bottom": parseSizeDeclaration,
|
|
213
219
|
"padding-inline": parsePaddingInline,
|
|
214
|
-
"padding-inline-end":
|
|
215
|
-
"padding-inline-start":
|
|
220
|
+
"padding-inline-end": parseLengthPercentageDeclaration,
|
|
221
|
+
"padding-inline-start": parseLengthPercentageDeclaration,
|
|
216
222
|
"padding-left": parseSizeDeclaration,
|
|
217
223
|
"padding-right": parseSizeDeclaration,
|
|
218
224
|
"padding-top": parseSizeDeclaration,
|
|
219
225
|
"position": parsePosition,
|
|
220
|
-
"right":
|
|
226
|
+
"right": parseSizeWithAutoDeclaration,
|
|
221
227
|
"rotate": parseRotate,
|
|
222
228
|
"row-gap": parseGap,
|
|
223
229
|
"scale": parseScale,
|
|
@@ -230,7 +236,7 @@ const parsers: {
|
|
|
230
236
|
"text-decoration-style": parseTextDecorationStyle,
|
|
231
237
|
"text-shadow": parseTextShadow,
|
|
232
238
|
"text-transform": ({ value }) => value.case,
|
|
233
|
-
"top":
|
|
239
|
+
"top": parseSizeWithAutoDeclaration,
|
|
234
240
|
"transform": parseTransform,
|
|
235
241
|
"transition": addTransitionValue,
|
|
236
242
|
"transition-delay": addTransitionValue,
|
|
@@ -611,8 +617,11 @@ function parseMarginBlock(
|
|
|
611
617
|
"margin-block-start": parseLengthPercentageOrAuto(
|
|
612
618
|
value.blockStart,
|
|
613
619
|
builder,
|
|
620
|
+
{ allowAuto: true },
|
|
614
621
|
),
|
|
615
|
-
"margin-block-end": parseLengthPercentageOrAuto(value.blockEnd, builder
|
|
622
|
+
"margin-block-end": parseLengthPercentageOrAuto(value.blockEnd, builder, {
|
|
623
|
+
allowAuto: true,
|
|
624
|
+
}),
|
|
616
625
|
});
|
|
617
626
|
}
|
|
618
627
|
|
|
@@ -624,8 +633,11 @@ function parseMarginInline(
|
|
|
624
633
|
"margin-inline-start": parseLengthPercentageOrAuto(
|
|
625
634
|
value.inlineStart,
|
|
626
635
|
builder,
|
|
636
|
+
{ allowAuto: true },
|
|
627
637
|
),
|
|
628
|
-
"margin-inline-end": parseLengthPercentageOrAuto(value.inlineEnd, builder
|
|
638
|
+
"margin-inline-end": parseLengthPercentageOrAuto(value.inlineEnd, builder, {
|
|
639
|
+
allowAuto: true,
|
|
640
|
+
}),
|
|
629
641
|
});
|
|
630
642
|
}
|
|
631
643
|
|
|
@@ -971,17 +983,31 @@ export function parseCustomDeclaration(
|
|
|
971
983
|
parseUnparsed(declaration.value.value, builder, property),
|
|
972
984
|
);
|
|
973
985
|
} else if (property === "-rn-ripple-style") {
|
|
974
|
-
|
|
975
|
-
property
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
986
|
+
if (
|
|
987
|
+
parseUnparsed(declaration.value.value, builder, property) === "borderless"
|
|
988
|
+
) {
|
|
989
|
+
builder.addDescriptor(property, true);
|
|
990
|
+
}
|
|
991
|
+
} else if (property === "-rn-ripple-layer") {
|
|
992
|
+
if (
|
|
993
|
+
parseUnparsed(declaration.value.value, builder, property) === "foreground"
|
|
994
|
+
) {
|
|
995
|
+
builder.addDescriptor(property, true);
|
|
996
|
+
}
|
|
979
997
|
} else if (property === "object-fit") {
|
|
980
998
|
// https://github.com/parcel-bundler/lightningcss/issues/1046
|
|
981
999
|
parseObjectFit(declaration.value, builder);
|
|
982
1000
|
} else if (property === "object-position") {
|
|
983
1001
|
// https://github.com/parcel-bundler/lightningcss/issues/1047
|
|
984
1002
|
parseObjectPosition(declaration.value, builder);
|
|
1003
|
+
} else if (property === "outline-offset") {
|
|
1004
|
+
// https://github.com/parcel-bundler/lightningcss/issues/1048
|
|
1005
|
+
builder.addDescriptor(
|
|
1006
|
+
property,
|
|
1007
|
+
parseUnparsed(declaration.value.value, builder, property),
|
|
1008
|
+
);
|
|
1009
|
+
} else if (property === "corner-shape") {
|
|
1010
|
+
parseCornerShape(declaration.value, builder);
|
|
985
1011
|
} else if (
|
|
986
1012
|
validProperties.has(property) ||
|
|
987
1013
|
property.startsWith("--") ||
|
|
@@ -1457,6 +1483,13 @@ export function parseSizeDeclaration(
|
|
|
1457
1483
|
return parseSize(declaration.value, builder);
|
|
1458
1484
|
}
|
|
1459
1485
|
|
|
1486
|
+
export function parseSizeWithAutoDeclaration(
|
|
1487
|
+
declaration: { value: Size | MaxSize },
|
|
1488
|
+
builder: StylesheetBuilder,
|
|
1489
|
+
) {
|
|
1490
|
+
return parseSize(declaration.value, builder, { allowAuto: true });
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1460
1493
|
export function parsePointerEvents(
|
|
1461
1494
|
{ value }: { value: string },
|
|
1462
1495
|
builder: StylesheetBuilder,
|
|
@@ -1709,13 +1742,20 @@ export function parseColor(cssColor: CssColor, builder: StylesheetBuilder) {
|
|
|
1709
1742
|
}
|
|
1710
1743
|
}
|
|
1711
1744
|
|
|
1712
|
-
export function
|
|
1745
|
+
export function parseLengthPercentageDeclaration(
|
|
1713
1746
|
value: { value: LengthPercentageOrAuto },
|
|
1714
1747
|
builder: StylesheetBuilder,
|
|
1715
1748
|
) {
|
|
1716
1749
|
return parseLengthPercentageOrAuto(value.value, builder);
|
|
1717
1750
|
}
|
|
1718
1751
|
|
|
1752
|
+
export function parseLengthPercentageOrAutoDeclaration(
|
|
1753
|
+
value: { value: LengthPercentageOrAuto },
|
|
1754
|
+
builder: StylesheetBuilder,
|
|
1755
|
+
) {
|
|
1756
|
+
return parseLengthPercentageOrAuto(value.value, builder, { allowAuto: true });
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1719
1759
|
export function parseLengthPercentageOrAuto(
|
|
1720
1760
|
lengthPercentageOrAuto: LengthPercentageOrAuto,
|
|
1721
1761
|
builder: StylesheetBuilder,
|
|
@@ -2097,16 +2137,7 @@ function parseBorderBlockStyle(
|
|
|
2097
2137
|
}
|
|
2098
2138
|
|
|
2099
2139
|
export function parseBorderSideWidthDeclaration(
|
|
2100
|
-
declaration:
|
|
2101
|
-
| "border-block-end-width"
|
|
2102
|
-
| "border-block-start-width"
|
|
2103
|
-
| "border-bottom-width"
|
|
2104
|
-
| "border-inline-end-width"
|
|
2105
|
-
| "border-inline-start-width"
|
|
2106
|
-
| "border-left-width"
|
|
2107
|
-
| "border-right-width"
|
|
2108
|
-
| "border-top-width"
|
|
2109
|
-
>,
|
|
2140
|
+
declaration: Extract<Declaration, { value: BorderSideWidth }>,
|
|
2110
2141
|
builder: StylesheetBuilder,
|
|
2111
2142
|
) {
|
|
2112
2143
|
builder.addDescriptor(
|
|
@@ -2359,6 +2390,18 @@ export function parseBoxShadow(
|
|
|
2359
2390
|
}
|
|
2360
2391
|
}
|
|
2361
2392
|
|
|
2393
|
+
export function parseBoxSizing(
|
|
2394
|
+
declaration: DeclarationType<"box-sizing">,
|
|
2395
|
+
builder: StylesheetBuilder,
|
|
2396
|
+
) {
|
|
2397
|
+
if (["border-box", "content-box"].includes(declaration.value)) {
|
|
2398
|
+
return declaration.value;
|
|
2399
|
+
}
|
|
2400
|
+
|
|
2401
|
+
builder.addWarning("value", declaration.value);
|
|
2402
|
+
return undefined;
|
|
2403
|
+
}
|
|
2404
|
+
|
|
2362
2405
|
export function parseDisplay(
|
|
2363
2406
|
{ value }: DeclarationType<"display">,
|
|
2364
2407
|
builder: StylesheetBuilder,
|
|
@@ -2416,6 +2459,19 @@ export function parseDisplay(
|
|
|
2416
2459
|
}
|
|
2417
2460
|
}
|
|
2418
2461
|
|
|
2462
|
+
export function parseDirection(
|
|
2463
|
+
declaration: DeclarationType<"direction">,
|
|
2464
|
+
builder: StylesheetBuilder,
|
|
2465
|
+
) {
|
|
2466
|
+
if (["ltr", "rtl"].includes(declaration.value)) {
|
|
2467
|
+
builder.addDescriptor("direction", declaration.value);
|
|
2468
|
+
builder.addDescriptor("--__rn-css-direction", declaration.value);
|
|
2469
|
+
}
|
|
2470
|
+
|
|
2471
|
+
builder.addWarning("value", declaration.value);
|
|
2472
|
+
return;
|
|
2473
|
+
}
|
|
2474
|
+
|
|
2419
2475
|
export function parseAspectRatio({
|
|
2420
2476
|
value,
|
|
2421
2477
|
}: DeclarationType<"aspect-ratio">): StyleDescriptor {
|
|
@@ -2433,6 +2489,18 @@ export function parseAspectRatio({
|
|
|
2433
2489
|
}
|
|
2434
2490
|
}
|
|
2435
2491
|
|
|
2492
|
+
export function parseBackfaceVisibility(
|
|
2493
|
+
{ value }: DeclarationType<"backface-visibility">,
|
|
2494
|
+
builder: StylesheetBuilder,
|
|
2495
|
+
): StyleDescriptor {
|
|
2496
|
+
if (["visible", "hidden"].includes(value)) {
|
|
2497
|
+
return value;
|
|
2498
|
+
} else {
|
|
2499
|
+
builder.addWarning("value", value);
|
|
2500
|
+
return;
|
|
2501
|
+
}
|
|
2502
|
+
}
|
|
2503
|
+
|
|
2436
2504
|
export function parseDimension(
|
|
2437
2505
|
{ unit, value }: Extract<Token, { type: "dimension" }>,
|
|
2438
2506
|
builder: StylesheetBuilder,
|
|
@@ -3031,6 +3099,19 @@ function parseObjectPosition(
|
|
|
3031
3099
|
]);
|
|
3032
3100
|
}
|
|
3033
3101
|
|
|
3102
|
+
function parseCornerShape(
|
|
3103
|
+
declaration: CustomProperty,
|
|
3104
|
+
builder: StylesheetBuilder,
|
|
3105
|
+
) {
|
|
3106
|
+
const shape = parseUnparsed(declaration.value, builder, "corner-shape");
|
|
3107
|
+
|
|
3108
|
+
if (shape === "round") {
|
|
3109
|
+
builder.addDescriptor("borderCurve", "circular");
|
|
3110
|
+
} else if (shape === "squircle") {
|
|
3111
|
+
builder.addDescriptor("borderCurve", "continuous");
|
|
3112
|
+
}
|
|
3113
|
+
}
|
|
3114
|
+
|
|
3034
3115
|
function parseVisibility(
|
|
3035
3116
|
declaration: DeclarationType<"visibility">,
|
|
3036
3117
|
builder: StylesheetBuilder,
|
|
@@ -3044,6 +3125,25 @@ function parseVisibility(
|
|
|
3044
3125
|
}
|
|
3045
3126
|
}
|
|
3046
3127
|
|
|
3128
|
+
function parseOutlineStyle(
|
|
3129
|
+
declaration: DeclarationType<"outline-style">,
|
|
3130
|
+
builder: StylesheetBuilder,
|
|
3131
|
+
) {
|
|
3132
|
+
const allowed = ["solid", "dotted", "dashed"];
|
|
3133
|
+
|
|
3134
|
+
if (
|
|
3135
|
+
declaration.value.type !== "auto" &&
|
|
3136
|
+
allowed.includes(declaration.value.value)
|
|
3137
|
+
) {
|
|
3138
|
+
builder.addDescriptor("outlineStyle", declaration.value.value);
|
|
3139
|
+
} else {
|
|
3140
|
+
builder.addWarning(
|
|
3141
|
+
"value",
|
|
3142
|
+
declaration.value.type === "auto" ? "auto" : declaration.value.value,
|
|
3143
|
+
);
|
|
3144
|
+
}
|
|
3145
|
+
}
|
|
3146
|
+
|
|
3047
3147
|
function parseFilter(
|
|
3048
3148
|
declaration: DeclarationType<"filter">,
|
|
3049
3149
|
builder: StylesheetBuilder,
|
|
@@ -568,6 +568,12 @@ export class StylesheetBuilder {
|
|
|
568
568
|
: [value];
|
|
569
569
|
// Append extra media queries if they exist
|
|
570
570
|
this.shared[type][name].push(variableValue);
|
|
571
|
+
|
|
572
|
+
if (type === "rootVariables" && name === "__rn-css-em") {
|
|
573
|
+
const remName = "__rn-css-rem";
|
|
574
|
+
this.shared[type][remName] ??= [];
|
|
575
|
+
this.shared[type][remName].push(variableValue);
|
|
576
|
+
}
|
|
571
577
|
}
|
|
572
578
|
}
|
|
573
579
|
}
|
package/src/jest/index.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { inspect } from "node:util";
|
|
|
5
5
|
import { compile, type CompilerOptions } from "react-native-css/compiler";
|
|
6
6
|
import { StyleCollection } from "react-native-css/style-collection";
|
|
7
7
|
|
|
8
|
-
import { colorScheme, dimensions
|
|
8
|
+
import { colorScheme, dimensions } from "../runtime/native/reactivity";
|
|
9
9
|
|
|
10
10
|
declare global {
|
|
11
11
|
/* eslint-disable @typescript-eslint/no-namespace */
|
|
@@ -21,7 +21,6 @@ export const testID = "react-native-css";
|
|
|
21
21
|
beforeEach(() => {
|
|
22
22
|
StyleCollection.styles.clear();
|
|
23
23
|
dimensions.set(Dimensions.get("window"));
|
|
24
|
-
rem.set(14);
|
|
25
24
|
Appearance.setColorScheme(null);
|
|
26
25
|
colorScheme.set(null);
|
|
27
26
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
|
-
import { useContext, useState } from "react";
|
|
2
|
+
import { useContext, useMemo, useState, type PropsWithChildren } from "react";
|
|
3
3
|
import { Appearance } from "react-native";
|
|
4
4
|
|
|
5
|
-
import type {
|
|
5
|
+
import type { StyleDescriptor } from "../../compiler";
|
|
6
6
|
import type {
|
|
7
7
|
ColorScheme,
|
|
8
8
|
Props,
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
VariableContext,
|
|
19
19
|
type Effect,
|
|
20
20
|
type Getter,
|
|
21
|
+
type VariableContextValue,
|
|
21
22
|
} from "./reactivity";
|
|
22
23
|
import { resolveValue } from "./styles/resolve";
|
|
23
24
|
|
|
@@ -102,7 +103,33 @@ export function useNativeVariable(name: string) {
|
|
|
102
103
|
return resolveValue([{}, "var", [name]], effect.get, { inheritedVariables });
|
|
103
104
|
}
|
|
104
105
|
|
|
106
|
+
/**
|
|
107
|
+
* @deprecated Use `<VariableContextProvider />` instead.
|
|
108
|
+
*/
|
|
105
109
|
export function vars(variables: Record<string, StyleDescriptor>) {
|
|
106
|
-
(
|
|
107
|
-
|
|
110
|
+
return Object.assign(
|
|
111
|
+
{ [VAR_SYMBOL]: "inline" },
|
|
112
|
+
Object.fromEntries(
|
|
113
|
+
Object.entries(variables).map(([k, v]) => [k.replace(/^--/, ""), v]),
|
|
114
|
+
),
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function VariableContextProvider(
|
|
119
|
+
props: PropsWithChildren<{ value: Record<`--${string}`, StyleDescriptor> }>,
|
|
120
|
+
) {
|
|
121
|
+
const inheritedVariables = useContext(VariableContext);
|
|
122
|
+
|
|
123
|
+
const value: VariableContextValue = useMemo(
|
|
124
|
+
() => ({
|
|
125
|
+
...inheritedVariables,
|
|
126
|
+
...Object.fromEntries(
|
|
127
|
+
Object.entries(props.value).map(([k, v]) => [k.replace(/^--/, ""), v]),
|
|
128
|
+
),
|
|
129
|
+
[VAR_SYMBOL]: true,
|
|
130
|
+
}),
|
|
131
|
+
[inheritedVariables, props.value],
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
return <VariableContext value={value}>{props.children}</VariableContext>;
|
|
108
135
|
}
|
|
@@ -189,10 +189,6 @@ export const VariableContext = createContext<VariableContextValue>({
|
|
|
189
189
|
[VAR_SYMBOL]: true,
|
|
190
190
|
});
|
|
191
191
|
|
|
192
|
-
/** Units *********************************************************************/
|
|
193
|
-
|
|
194
|
-
export const rem = observable(14);
|
|
195
|
-
|
|
196
192
|
/** Pseudo Classes ************************************************************/
|
|
197
193
|
|
|
198
194
|
export const hoverFamily = weakFamily(() => observable(false));
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import { rem as remObs, vh as vhObs, vw as vwObs } from "../reactivity";
|
|
1
|
+
import { vh as vhObs, vw as vwObs } from "../reactivity";
|
|
3
2
|
import type { StyleFunctionResolver } from "./resolve";
|
|
4
3
|
|
|
5
|
-
export const em: StyleFunctionResolver = (resolve, func
|
|
6
|
-
|
|
4
|
+
export const em: StyleFunctionResolver = (resolve, func) => {
|
|
5
|
+
const value = func[2];
|
|
7
6
|
|
|
8
7
|
if (typeof value !== "number") {
|
|
9
8
|
return;
|
|
@@ -12,14 +11,14 @@ export const em: StyleFunctionResolver = (resolve, func, get) => {
|
|
|
12
11
|
let emValue = resolve([{}, "var", ["__rn-css-em"]]);
|
|
13
12
|
|
|
14
13
|
if (typeof emValue !== "number") {
|
|
15
|
-
emValue =
|
|
14
|
+
emValue = resolve([{}, "var", ["__rn-css-rem"]]);
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
if (typeof emValue !== "number") {
|
|
19
18
|
return;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
return round(
|
|
21
|
+
return round(value * emValue);
|
|
23
22
|
};
|
|
24
23
|
|
|
25
24
|
export const vw: StyleFunctionResolver = (_, func, get) => {
|
|
@@ -42,14 +41,20 @@ export const vh: StyleFunctionResolver = (_, func, get) => {
|
|
|
42
41
|
return round((value / 100) * get(vhObs));
|
|
43
42
|
};
|
|
44
43
|
|
|
45
|
-
export const rem: StyleFunctionResolver = (
|
|
44
|
+
export const rem: StyleFunctionResolver = (resolve, func) => {
|
|
46
45
|
const value = func[2];
|
|
47
46
|
|
|
48
47
|
if (typeof value !== "number") {
|
|
49
48
|
return;
|
|
50
49
|
}
|
|
51
50
|
|
|
52
|
-
|
|
51
|
+
const remValue = resolve([{}, "var", ["__rn-css-rem"]]);
|
|
52
|
+
|
|
53
|
+
if (typeof remValue === "number") {
|
|
54
|
+
return round(value * remValue);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return;
|
|
53
58
|
};
|
|
54
59
|
|
|
55
60
|
function round(number: number) {
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
createElement,
|
|
3
|
+
useMemo,
|
|
4
|
+
type ComponentProps,
|
|
5
|
+
type PropsWithChildren,
|
|
6
|
+
} from "react";
|
|
2
7
|
import { Appearance } from "react-native";
|
|
3
8
|
|
|
4
9
|
import type {
|
|
@@ -24,7 +29,7 @@ export const styled = <
|
|
|
24
29
|
};
|
|
25
30
|
};
|
|
26
31
|
|
|
27
|
-
export const useCssElement = <
|
|
32
|
+
export const useCssElement = <C extends ReactComponent>(
|
|
28
33
|
component: C,
|
|
29
34
|
incomingProps: Props,
|
|
30
35
|
mapping: StyledConfiguration<C>,
|
|
@@ -66,6 +71,9 @@ export const colorScheme: ColorScheme = {
|
|
|
66
71
|
},
|
|
67
72
|
};
|
|
68
73
|
|
|
74
|
+
/**
|
|
75
|
+
* @deprecated Use `<VariableContextProvider />` instead.
|
|
76
|
+
*/
|
|
69
77
|
export function vars(variables: Record<string, string | number>) {
|
|
70
78
|
const $variables: Record<string, string> = {};
|
|
71
79
|
|
|
@@ -79,6 +87,24 @@ export function vars(variables: Record<string, string | number>) {
|
|
|
79
87
|
return $variables;
|
|
80
88
|
}
|
|
81
89
|
|
|
90
|
+
export function VariableContextProvider(
|
|
91
|
+
props: PropsWithChildren<{ value: Record<`--${string}`, string> }>,
|
|
92
|
+
) {
|
|
93
|
+
const style = useMemo(() => {
|
|
94
|
+
return {
|
|
95
|
+
display: "content",
|
|
96
|
+
...Object.fromEntries(
|
|
97
|
+
Object.entries(props.value).map(([key, value]) => [
|
|
98
|
+
key.startsWith("--") ? key : `--${key}`,
|
|
99
|
+
value,
|
|
100
|
+
]),
|
|
101
|
+
),
|
|
102
|
+
};
|
|
103
|
+
}, [props.value]);
|
|
104
|
+
|
|
105
|
+
return <div style={style}>{props.children}</div>;
|
|
106
|
+
}
|
|
107
|
+
|
|
82
108
|
export const useNativeVariable = () => {
|
|
83
109
|
throw new Error("useNativeVariable is not supported in web");
|
|
84
110
|
};
|