react-native-css 3.0.0-nightly.df0f885 → 3.0.0-nightly.fa5e95b
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/declarations.js +21 -9
- package/dist/commonjs/compiler/declarations.js.map +1 -1
- package/dist/commonjs/compiler/stylesheet.js +43 -19
- package/dist/commonjs/compiler/stylesheet.js.map +1 -1
- package/dist/commonjs/runtime/native/conditions/media-query.js +1 -1
- package/dist/commonjs/runtime/native/conditions/media-query.js.map +1 -1
- 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/units.js +6 -3
- package/dist/commonjs/runtime/native/styles/units.js.map +1 -1
- package/dist/module/compiler/atRules.js +1 -1
- package/dist/module/compiler/declarations.js +21 -9
- package/dist/module/compiler/declarations.js.map +1 -1
- package/dist/module/compiler/stylesheet.js +43 -19
- package/dist/module/compiler/stylesheet.js.map +1 -1
- package/dist/module/runtime/native/conditions/media-query.js +1 -1
- package/dist/module/runtime/native/conditions/media-query.js.map +1 -1
- 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/units.js +6 -3
- package/dist/module/runtime/native/styles/units.js.map +1 -1
- package/dist/typescript/commonjs/src/compiler/compiler.d.ts +3 -3
- package/dist/typescript/commonjs/src/compiler/declarations.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/compiler/stylesheet.d.ts +9 -5
- package/dist/typescript/commonjs/src/compiler/stylesheet.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/jest/index.d.ts +3 -3
- 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/module/src/compiler/compiler.d.ts +3 -3
- package/dist/typescript/module/src/compiler/declarations.d.ts.map +1 -1
- package/dist/typescript/module/src/compiler/stylesheet.d.ts +9 -5
- package/dist/typescript/module/src/compiler/stylesheet.d.ts.map +1 -1
- package/dist/typescript/module/src/jest/index.d.ts +3 -3
- 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/package.json +2 -2
- package/src/compiler/atRules.ts +1 -1
- package/src/compiler/declarations.ts +29 -9
- package/src/compiler/stylesheet.ts +58 -24
- package/src/runtime/native/conditions/media-query.ts +1 -1
- package/src/runtime/native/styles/calculate-props.ts +59 -49
- package/src/runtime/native/styles/units.ts +7 -3
|
@@ -57,15 +57,16 @@ export class StylesheetBuilder {
|
|
|
57
57
|
animations?: AnimationRecord;
|
|
58
58
|
rem: number;
|
|
59
59
|
ruleOrder: number;
|
|
60
|
+
warningProperty?: string;
|
|
60
61
|
warningProperties: string[];
|
|
61
|
-
warningValues:
|
|
62
|
+
warningValues: Record<string, unknown[]>;
|
|
62
63
|
warningFunctions: string[];
|
|
63
64
|
} = {
|
|
64
65
|
ruleSets: {},
|
|
65
66
|
rem: 14,
|
|
66
67
|
ruleOrder: 0,
|
|
67
68
|
warningProperties: [],
|
|
68
|
-
warningValues:
|
|
69
|
+
warningValues: {},
|
|
69
70
|
warningFunctions: [],
|
|
70
71
|
},
|
|
71
72
|
private selectors?: NormalizeSelector[],
|
|
@@ -172,8 +173,14 @@ export class StylesheetBuilder {
|
|
|
172
173
|
);
|
|
173
174
|
}
|
|
174
175
|
|
|
176
|
+
setWarningProperty(property: string) {
|
|
177
|
+
this.shared.warningProperty = property;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
addWarning(type: "property" | "value", property: string): void;
|
|
181
|
+
addWarning(type: "style", property: string, value: unknown): void;
|
|
175
182
|
addWarning(
|
|
176
|
-
type: "property" | "
|
|
183
|
+
type: "property" | "style" | "value",
|
|
177
184
|
property: string,
|
|
178
185
|
value?: unknown,
|
|
179
186
|
): void {
|
|
@@ -181,21 +188,49 @@ export class StylesheetBuilder {
|
|
|
181
188
|
case "property":
|
|
182
189
|
this.shared.warningProperties.push(property);
|
|
183
190
|
break;
|
|
184
|
-
case "value":
|
|
185
|
-
|
|
191
|
+
case "value": {
|
|
192
|
+
value = property;
|
|
193
|
+
property = this.shared.warningProperty ?? "";
|
|
194
|
+
|
|
195
|
+
if (!property) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
this.shared.warningValues[property] ??= [];
|
|
200
|
+
this.shared.warningValues[property]?.push(value);
|
|
186
201
|
break;
|
|
187
|
-
|
|
188
|
-
|
|
202
|
+
}
|
|
203
|
+
case "style":
|
|
204
|
+
this.shared.warningValues[property] ??= [];
|
|
205
|
+
this.shared.warningValues[property]?.push(value);
|
|
189
206
|
break;
|
|
190
207
|
}
|
|
191
208
|
}
|
|
192
209
|
|
|
193
210
|
getWarnings() {
|
|
194
|
-
|
|
195
|
-
properties
|
|
196
|
-
values
|
|
197
|
-
functions
|
|
198
|
-
};
|
|
211
|
+
const result: {
|
|
212
|
+
properties?: string[];
|
|
213
|
+
values?: Record<string, unknown[]>;
|
|
214
|
+
functions?: string[];
|
|
215
|
+
} = {};
|
|
216
|
+
|
|
217
|
+
if (this.shared.warningProperties.length) {
|
|
218
|
+
result.properties = this.shared.warningProperties;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
if (Object.keys(this.shared.warningValues).length) {
|
|
222
|
+
result.values = this.shared.warningValues;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (this.shared.warningFunctions.length) {
|
|
226
|
+
result.functions = this.shared.warningFunctions;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return result;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
addMapping(mapping: StyleRuleMapping) {
|
|
233
|
+
this.mapping = { ...this.mapping, ...mapping };
|
|
199
234
|
}
|
|
200
235
|
|
|
201
236
|
newRule(mapping = this.mapping, { important = false } = {}) {
|
|
@@ -331,30 +366,29 @@ export class StylesheetBuilder {
|
|
|
331
366
|
}
|
|
332
367
|
|
|
333
368
|
private pushDescriptor(
|
|
334
|
-
|
|
369
|
+
rawProperty: string,
|
|
335
370
|
value: StyleDescriptor,
|
|
336
371
|
declarations: StyleDeclaration[],
|
|
337
372
|
forceTuple = false,
|
|
338
373
|
delayed = false,
|
|
339
374
|
) {
|
|
340
|
-
property = toRNProperty(
|
|
375
|
+
const property = toRNProperty(rawProperty);
|
|
341
376
|
|
|
342
|
-
let propPath: string | string[] =
|
|
343
|
-
this.mapping[property] ?? this.mapping["*"]
|
|
377
|
+
let propPath: string | string[] | undefined =
|
|
378
|
+
this.mapping[rawProperty] ?? this.mapping[property] ?? this.mapping["*"];
|
|
344
379
|
|
|
345
380
|
if (Array.isArray(propPath)) {
|
|
346
|
-
const first = propPath
|
|
381
|
+
const [first, second] = propPath;
|
|
347
382
|
|
|
348
|
-
if (
|
|
349
|
-
|
|
350
|
-
return;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
if (propPath.length === 1) {
|
|
354
|
-
propPath = first;
|
|
383
|
+
if (propPath.length === 2 && first === "*" && second) {
|
|
384
|
+
propPath = second;
|
|
355
385
|
} else {
|
|
356
386
|
forceTuple = true;
|
|
357
387
|
}
|
|
388
|
+
} else if (propPath) {
|
|
389
|
+
forceTuple = true;
|
|
390
|
+
} else {
|
|
391
|
+
propPath = property;
|
|
358
392
|
}
|
|
359
393
|
|
|
360
394
|
if (isStyleFunction(value)) {
|
|
@@ -39,7 +39,7 @@ function testComparison(mediaQuery: MediaCondition, get: Getter): Boolean {
|
|
|
39
39
|
|
|
40
40
|
switch (mediaQuery[1]) {
|
|
41
41
|
case "platform":
|
|
42
|
-
return right === Platform.OS;
|
|
42
|
+
return right === "native" || right === Platform.OS;
|
|
43
43
|
case "prefers-color-scheme": {
|
|
44
44
|
return right === get(colorScheme);
|
|
45
45
|
}
|
|
@@ -103,63 +103,73 @@ export function applyDeclarations(
|
|
|
103
103
|
// Dynamic styles
|
|
104
104
|
let value: any = declaration[0];
|
|
105
105
|
let propPath = declaration[1];
|
|
106
|
-
let prop
|
|
106
|
+
let prop: string;
|
|
107
107
|
|
|
108
|
-
if (
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
108
|
+
if (Array.isArray(propPath)) {
|
|
109
|
+
const [first, ...rest] = propPath;
|
|
110
|
+
|
|
111
|
+
if (!first) {
|
|
112
|
+
continue;
|
|
112
113
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
114
|
+
|
|
115
|
+
const final = rest.pop();
|
|
116
|
+
|
|
117
|
+
if (final) {
|
|
118
|
+
if (first !== "*") {
|
|
119
|
+
topLevelTarget[first] ??= {};
|
|
120
|
+
target = topLevelTarget[first];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
for (prop of rest) {
|
|
124
|
+
target[prop] ??= {};
|
|
125
|
+
target = target[prop];
|
|
121
126
|
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
127
|
|
|
125
|
-
|
|
126
|
-
const shouldDelay = declaration[2];
|
|
127
|
-
|
|
128
|
-
if (shouldDelay) {
|
|
129
|
-
/**
|
|
130
|
-
* We need to delay the resolution of this value until after all
|
|
131
|
-
* styles have been calculated. But another style might override
|
|
132
|
-
* this value. So we set a placeholder value and only override
|
|
133
|
-
* if the placeholder is preserved
|
|
134
|
-
*
|
|
135
|
-
* This also ensures the props exist, so setValue will properly
|
|
136
|
-
* mutate the props object and not create a new one
|
|
137
|
-
*/
|
|
138
|
-
const originalValue = value;
|
|
139
|
-
value = {};
|
|
140
|
-
delayedStyles.push(() => {
|
|
141
|
-
if (target[prop] === value) {
|
|
142
|
-
delete target[prop];
|
|
143
|
-
value = resolveValue(originalValue, get, {
|
|
144
|
-
inlineVariables,
|
|
145
|
-
inheritedVariables,
|
|
146
|
-
renderGuards: guards,
|
|
147
|
-
calculateProps,
|
|
148
|
-
});
|
|
149
|
-
applyValue(target, prop, value);
|
|
150
|
-
}
|
|
151
|
-
});
|
|
128
|
+
prop = final;
|
|
152
129
|
} else {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
inheritedVariables,
|
|
156
|
-
renderGuards: guards,
|
|
157
|
-
calculateProps,
|
|
158
|
-
});
|
|
130
|
+
target = topLevelTarget;
|
|
131
|
+
prop = first;
|
|
159
132
|
}
|
|
133
|
+
} else {
|
|
134
|
+
prop = propPath;
|
|
135
|
+
}
|
|
160
136
|
|
|
161
|
-
|
|
137
|
+
const shouldDelay = declaration[2];
|
|
138
|
+
|
|
139
|
+
if (shouldDelay) {
|
|
140
|
+
/**
|
|
141
|
+
* We need to delay the resolution of this value until after all
|
|
142
|
+
* styles have been calculated. But another style might override
|
|
143
|
+
* this value. So we set a placeholder value and only override
|
|
144
|
+
* if the placeholder is preserved
|
|
145
|
+
*
|
|
146
|
+
* This also ensures the props exist, so setValue will properly
|
|
147
|
+
* mutate the props object and not create a new one
|
|
148
|
+
*/
|
|
149
|
+
const originalValue = value;
|
|
150
|
+
value = {};
|
|
151
|
+
delayedStyles.push(() => {
|
|
152
|
+
if (target[prop] === value) {
|
|
153
|
+
delete target[prop];
|
|
154
|
+
value = resolveValue(originalValue, get, {
|
|
155
|
+
inlineVariables,
|
|
156
|
+
inheritedVariables,
|
|
157
|
+
renderGuards: guards,
|
|
158
|
+
calculateProps,
|
|
159
|
+
});
|
|
160
|
+
applyValue(target, prop, value);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
} else {
|
|
164
|
+
value = resolveValue(value, get, {
|
|
165
|
+
inlineVariables,
|
|
166
|
+
inheritedVariables,
|
|
167
|
+
renderGuards: guards,
|
|
168
|
+
calculateProps,
|
|
169
|
+
});
|
|
162
170
|
}
|
|
171
|
+
|
|
172
|
+
applyValue(target, prop, value);
|
|
163
173
|
}
|
|
164
174
|
}
|
|
165
175
|
}
|
|
@@ -2,17 +2,21 @@
|
|
|
2
2
|
import { rem as remObs, vh as vhObs, vw as vwObs } from "../reactivity";
|
|
3
3
|
import type { StyleFunctionResolver } from "./resolve";
|
|
4
4
|
|
|
5
|
-
export const em: StyleFunctionResolver = (resolve, func) => {
|
|
5
|
+
export const em: StyleFunctionResolver = (resolve, func, get) => {
|
|
6
6
|
let value = func[2];
|
|
7
7
|
|
|
8
8
|
if (!value) {
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
let emValue = resolve([{}, "var", ["__rn-css-em"]]);
|
|
13
13
|
|
|
14
14
|
if (typeof emValue !== "number") {
|
|
15
|
-
|
|
15
|
+
emValue = get(remObs);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (typeof emValue !== "number") {
|
|
19
|
+
return;
|
|
16
20
|
}
|
|
17
21
|
|
|
18
22
|
return round(Number(value) * emValue);
|