@stylexjs/stylex 0.3.0 → 0.4.0
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/README.md +18 -43
- package/lib/StyleXCSSTypes.d.ts +3 -1
- package/lib/StyleXCSSTypes.js.flow +4 -2
- package/lib/StyleXSheet.js +17 -3
- package/lib/StyleXTypes.d.ts +10 -4
- package/lib/StyleXTypes.js.flow +9 -6
- package/lib/stylex.d.ts +0 -7
- package/lib/stylex.js +1 -5
- package/lib/stylex.js.flow +0 -4
- package/package.json +2 -2
- package/lib/native/CSSCustomPropertyValue.d.ts +0 -26
- package/lib/native/CSSCustomPropertyValue.js +0 -27
- package/lib/native/CSSCustomPropertyValue.js.flow +0 -27
- package/lib/native/CSSLengthUnitValue.d.ts +0 -18
- package/lib/native/CSSLengthUnitValue.js +0 -73
- package/lib/native/CSSLengthUnitValue.js.flow +0 -21
- package/lib/native/CSSMediaQuery.d.ts +0 -25
- package/lib/native/CSSMediaQuery.js +0 -55
- package/lib/native/CSSMediaQuery.js.flow +0 -26
- package/lib/native/SpreadOptions.d.ts +0 -19
- package/lib/native/SpreadOptions.js +0 -1
- package/lib/native/SpreadOptions.js.flow +0 -19
- package/lib/native/__tests__/__snapshots__/stylex-css-var-test.js.snap +0 -48
- package/lib/native/__tests__/__snapshots__/stylex-test.js.snap +0 -1046
- package/lib/native/__tests__/parseTimeValue-test.js +0 -11
- package/lib/native/__tests__/stylex-css-var-test.js +0 -148
- package/lib/native/__tests__/stylex-test.js +0 -924
- package/lib/native/errorMsg.d.ts +0 -11
- package/lib/native/errorMsg.js +0 -13
- package/lib/native/errorMsg.js.flow +0 -12
- package/lib/native/fixContentBox.d.ts +0 -11
- package/lib/native/fixContentBox.js +0 -59
- package/lib/native/fixContentBox.js.flow +0 -11
- package/lib/native/flattenStyle.d.ts +0 -15
- package/lib/native/flattenStyle.js +0 -20
- package/lib/native/flattenStyle.js.flow +0 -20
- package/lib/native/parseShadow.d.ts +0 -18
- package/lib/native/parseShadow.js +0 -36
- package/lib/native/parseShadow.js.flow +0 -19
- package/lib/native/parseTimeValue.d.ts +0 -11
- package/lib/native/parseTimeValue.js +0 -18
- package/lib/native/parseTimeValue.js.flow +0 -12
- package/lib/native/stylex.d.ts +0 -50
- package/lib/native/stylex.js +0 -393
- package/lib/native/stylex.js.flow +0 -60
package/lib/native/stylex.js
DELETED
|
@@ -1,393 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.__customProperties = void 0;
|
|
7
|
-
exports.create = create;
|
|
8
|
-
exports.firstThatWorks = exports.defineVars = exports.default = exports.createTheme = void 0;
|
|
9
|
-
exports.keyframes = keyframes;
|
|
10
|
-
exports.props = props;
|
|
11
|
-
exports.stylex = void 0;
|
|
12
|
-
var _CSSCustomPropertyValue = require("./CSSCustomPropertyValue");
|
|
13
|
-
var _CSSLengthUnitValue = require("./CSSLengthUnitValue");
|
|
14
|
-
var _CSSMediaQuery = require("./CSSMediaQuery");
|
|
15
|
-
var _errorMsg = require("./errorMsg");
|
|
16
|
-
var _fixContentBox = require("./fixContentBox");
|
|
17
|
-
var _flattenStyle = require("./flattenStyle");
|
|
18
|
-
var _parseShadow = require("./parseShadow");
|
|
19
|
-
var _parseTimeValue = require("./parseTimeValue");
|
|
20
|
-
const stylePropertyAllowlistSet = new Set(['alignContent', 'alignItems', 'alignSelf', 'animationDelay', 'animationDuration', 'aspectRatio', 'backfaceVisibility', 'backgroundColor', 'borderBottomColor', 'borderBottomLeftRadius', 'borderBottomRightRadius', 'borderBottomStyle', 'borderBottomWidth', 'borderColor', 'borderLeftColor', 'borderLeftStyle', 'borderLeftWidth', 'borderRadius', 'borderRightColor', 'borderRightStyle', 'borderRightWidth', 'borderStyle', 'borderTopColor', 'borderTopLeftRadius', 'borderTopRightRadius', 'borderTopStyle', 'borderTopWidth', 'borderWidth', 'bottom', 'boxSizing', 'color', 'direction', 'display', 'end', 'flex', 'flexBasis', 'flexDirection', 'flexGrow', 'flexShrink', 'flexWrap', 'fontFamily', 'fontSize', 'fontStyle', 'fontWeight', 'fontVariant', 'gap', 'gapColumn', 'gapRow', 'height', 'justifyContent', 'left', 'letterSpacing', 'lineHeight', 'margin', 'marginBottom', 'marginLeft', 'marginRight', 'marginTop', 'maxHeight', 'maxWidth', 'minHeight', 'minWidth', 'objectFit', 'opacity', 'overflow', 'padding', 'paddingBottom', 'paddingLeft', 'paddingRight', 'paddingTop', 'pointerEvents', 'position', 'resizeMode', 'right', 'shadowColor', 'shadowOffset', 'shadowOpacity', 'shadowRadius', 'shadowWidth', 'start', 'textAlign', 'textDecorationLine', 'textDecorationColor', 'textDecorationStyle', 'textShadowColor', 'textShadowOffset', 'textShadowRadius', 'textTransform', 'tintColor', 'transform', 'transitionDelay', 'transitionDuration', 'top', 'userSelect', 'verticalAlign', 'width', 'zIndex']);
|
|
21
|
-
function isReactNativeStyleProp(propName) {
|
|
22
|
-
return stylePropertyAllowlistSet.has(propName) || propName.startsWith('--');
|
|
23
|
-
}
|
|
24
|
-
function isReactNativeStyleValue(propValue) {
|
|
25
|
-
if (typeof propValue === 'string') {
|
|
26
|
-
if (propValue === 'inherit') {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
if (propValue === 'initial') {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
if (propValue.endsWith('px')) {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
if (propValue.includes('calc(')) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
function preprocessPropertyValue(propValue) {
|
|
42
|
-
if (typeof propValue === 'string') {
|
|
43
|
-
const customPropValue = (0, _CSSCustomPropertyValue.createCSSCustomPropertyValue)(propValue);
|
|
44
|
-
if (customPropValue != null) {
|
|
45
|
-
return customPropValue;
|
|
46
|
-
}
|
|
47
|
-
const maybeLengthUnitValue = _CSSLengthUnitValue.CSSLengthUnitValue.parse(propValue);
|
|
48
|
-
if (maybeLengthUnitValue != null) {
|
|
49
|
-
return maybeLengthUnitValue[1] === 'px' ? maybeLengthUnitValue[0] : new _CSSLengthUnitValue.CSSLengthUnitValue(...maybeLengthUnitValue);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return propValue;
|
|
53
|
-
}
|
|
54
|
-
function preprocessCreate(style) {
|
|
55
|
-
const processedStyle = {};
|
|
56
|
-
for (const propName in style) {
|
|
57
|
-
const styleValue = style[propName];
|
|
58
|
-
if (_CSSMediaQuery.CSSMediaQuery.isMediaQueryString(propName) && typeof styleValue === 'object' && styleValue != null) {
|
|
59
|
-
const processsedSubStyle = preprocessCreate({
|
|
60
|
-
...styleValue
|
|
61
|
-
});
|
|
62
|
-
processedStyle[propName] = new _CSSMediaQuery.CSSMediaQuery(propName, processsedSubStyle);
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
if (propName === 'boxShadow' && typeof styleValue === 'string') {
|
|
66
|
-
const parsedShadow = (0, _parseShadow.parseShadow)(styleValue);
|
|
67
|
-
if (parsedShadow.length > 1) {
|
|
68
|
-
(0, _errorMsg.warnMsg)('Multiple "boxShadow" values are not supported in React Native.');
|
|
69
|
-
}
|
|
70
|
-
const {
|
|
71
|
-
inset,
|
|
72
|
-
offsetX,
|
|
73
|
-
offsetY,
|
|
74
|
-
blurRadius,
|
|
75
|
-
color
|
|
76
|
-
} = parsedShadow[0];
|
|
77
|
-
if (inset) {
|
|
78
|
-
(0, _errorMsg.warnMsg)('"boxShadow" value of "inset" is not supported in React Native.');
|
|
79
|
-
}
|
|
80
|
-
processedStyle.shadowColor = color;
|
|
81
|
-
processedStyle.shadowOffset = {
|
|
82
|
-
height: offsetY,
|
|
83
|
-
width: offsetX
|
|
84
|
-
};
|
|
85
|
-
processedStyle.shadowOpacity = 1;
|
|
86
|
-
processedStyle.shadowRadius = blurRadius;
|
|
87
|
-
} else if (propName === 'textShadow' && typeof styleValue === 'string') {
|
|
88
|
-
const parsedShadow = (0, _parseShadow.parseShadow)(styleValue);
|
|
89
|
-
if (parsedShadow.length > 1) {
|
|
90
|
-
(0, _errorMsg.warnMsg)('Multiple "textShadow" values are not supported in React Native.');
|
|
91
|
-
}
|
|
92
|
-
const {
|
|
93
|
-
offsetX,
|
|
94
|
-
offsetY,
|
|
95
|
-
blurRadius,
|
|
96
|
-
color
|
|
97
|
-
} = parsedShadow[0];
|
|
98
|
-
processedStyle.textShadowColor = color;
|
|
99
|
-
processedStyle.textShadowOffset = {
|
|
100
|
-
height: offsetY,
|
|
101
|
-
width: offsetX
|
|
102
|
-
};
|
|
103
|
-
processedStyle.textShadowRadius = blurRadius;
|
|
104
|
-
} else {
|
|
105
|
-
processedStyle[propName] = styleValue;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
for (const prop in processedStyle) {
|
|
109
|
-
let value = processedStyle[prop];
|
|
110
|
-
if (prop === 'lineHeight') {
|
|
111
|
-
if (typeof value === 'number' || typeof value === 'string' && _CSSLengthUnitValue.CSSLengthUnitValue.parse(value) == null) {
|
|
112
|
-
value = value + 'em';
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
const processedStyleValue = preprocessPropertyValue(value);
|
|
116
|
-
processedStyle[prop] = processedStyleValue;
|
|
117
|
-
}
|
|
118
|
-
return processedStyle;
|
|
119
|
-
}
|
|
120
|
-
function finalizeValue(unfinalizedValue, options) {
|
|
121
|
-
let styleValue = unfinalizedValue;
|
|
122
|
-
if (typeof styleValue === 'object' && styleValue != null && Object.hasOwn(styleValue, 'default')) {
|
|
123
|
-
if (options.hover === true && Object.hasOwn(styleValue, ':hover')) {
|
|
124
|
-
styleValue = styleValue[':hover'];
|
|
125
|
-
} else {
|
|
126
|
-
styleValue = styleValue.default;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
while (styleValue instanceof _CSSCustomPropertyValue.CSSCustomPropertyValue) {
|
|
130
|
-
const customProperties = options.customProperties || {};
|
|
131
|
-
const resolvedValue = customProperties[styleValue.name] ?? styleValue.defaultValue;
|
|
132
|
-
if (resolvedValue == null) {
|
|
133
|
-
(0, _errorMsg.errorMsg)(`Unrecognized custom property "--${styleValue.name}"`);
|
|
134
|
-
return null;
|
|
135
|
-
}
|
|
136
|
-
styleValue = preprocessPropertyValue(resolvedValue);
|
|
137
|
-
}
|
|
138
|
-
if (styleValue instanceof _CSSLengthUnitValue.CSSLengthUnitValue) {
|
|
139
|
-
styleValue = styleValue.resolvePixelValue(options);
|
|
140
|
-
}
|
|
141
|
-
return styleValue;
|
|
142
|
-
}
|
|
143
|
-
function create(styles) {
|
|
144
|
-
const result = {};
|
|
145
|
-
for (const styleName in styles) {
|
|
146
|
-
const val = styles[styleName];
|
|
147
|
-
if (typeof val === 'function') {
|
|
148
|
-
result[styleName] = function () {
|
|
149
|
-
const style = val(...arguments);
|
|
150
|
-
return preprocessCreate(style);
|
|
151
|
-
};
|
|
152
|
-
} else {
|
|
153
|
-
result[styleName] = preprocessCreate(styles[styleName]);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
return result;
|
|
157
|
-
}
|
|
158
|
-
const firstThatWorks = function () {
|
|
159
|
-
return arguments.length <= 0 ? undefined : arguments[0];
|
|
160
|
-
};
|
|
161
|
-
exports.firstThatWorks = firstThatWorks;
|
|
162
|
-
function keyframes(k) {
|
|
163
|
-
(0, _errorMsg.errorMsg)('keyframes are not supported in React Native.');
|
|
164
|
-
return k;
|
|
165
|
-
}
|
|
166
|
-
const timeValuedProperties = ['animationDelay', 'animationDuration', 'transitionDelay', 'transitionDuration'];
|
|
167
|
-
function props() {
|
|
168
|
-
const options = this;
|
|
169
|
-
for (var _len = arguments.length, style = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
170
|
-
style[_key] = arguments[_key];
|
|
171
|
-
}
|
|
172
|
-
let {
|
|
173
|
-
lineClamp,
|
|
174
|
-
...flatStyle
|
|
175
|
-
} = (0, _flattenStyle.flattenStyle)(style);
|
|
176
|
-
let prevStyle = {
|
|
177
|
-
...flatStyle
|
|
178
|
-
};
|
|
179
|
-
const {
|
|
180
|
-
passthroughProperties = [],
|
|
181
|
-
viewportHeight,
|
|
182
|
-
viewportWidth,
|
|
183
|
-
writingDirection
|
|
184
|
-
} = options;
|
|
185
|
-
const nativeProps = {};
|
|
186
|
-
for (const styleProp in flatStyle) {
|
|
187
|
-
let styleValue = flatStyle[styleProp];
|
|
188
|
-
if (styleValue instanceof _CSSMediaQuery.CSSMediaQuery) {
|
|
189
|
-
const maybeExistingMediaQuery = flatStyle[styleProp];
|
|
190
|
-
if (maybeExistingMediaQuery instanceof _CSSMediaQuery.CSSMediaQuery) {
|
|
191
|
-
const s = (0, _flattenStyle.flattenStyle)([maybeExistingMediaQuery.matchedStyle, styleValue.matchedStyle]);
|
|
192
|
-
if (s != null) {
|
|
193
|
-
maybeExistingMediaQuery.matchedStyle = s;
|
|
194
|
-
}
|
|
195
|
-
continue;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
styleValue = finalizeValue(styleValue, options);
|
|
199
|
-
if (styleValue == null) {
|
|
200
|
-
delete flatStyle[styleProp];
|
|
201
|
-
continue;
|
|
202
|
-
}
|
|
203
|
-
if (!isReactNativeStyleProp(styleProp) && passthroughProperties.indexOf(styleProp) === -1) {
|
|
204
|
-
if (styleProp === 'blockSize') {
|
|
205
|
-
flatStyle.height = flatStyle.height ?? styleValue;
|
|
206
|
-
} else if (styleProp === 'inlineSize') {
|
|
207
|
-
flatStyle.width = flatStyle.width ?? styleValue;
|
|
208
|
-
} else if (styleProp === 'maxBlockSize') {
|
|
209
|
-
flatStyle.maxHeight = flatStyle.maxHeight ?? styleValue;
|
|
210
|
-
} else if (styleProp === 'minBlockSize') {
|
|
211
|
-
flatStyle.minHeight = flatStyle.minHeight ?? styleValue;
|
|
212
|
-
} else if (styleProp === 'maxInlineSize') {
|
|
213
|
-
flatStyle.maxWidth = flatStyle.maxWidth ?? styleValue;
|
|
214
|
-
} else if (styleProp === 'minInlineSize') {
|
|
215
|
-
flatStyle.minWidth = flatStyle.minWidth ?? styleValue;
|
|
216
|
-
} else if (styleProp === 'borderBlockColor') {
|
|
217
|
-
flatStyle.borderTopColor = flatStyle.borderTopColor ?? styleValue;
|
|
218
|
-
flatStyle.borderBottomColor = flatStyle.borderBottomColor ?? styleValue;
|
|
219
|
-
} else if (styleProp === 'borderBlockStyle') {
|
|
220
|
-
flatStyle.borderTopStyle = flatStyle.borderTopStyle ?? styleValue;
|
|
221
|
-
flatStyle.borderBottomStyle = flatStyle.borderBottomStyle ?? styleValue;
|
|
222
|
-
} else if (styleProp === 'borderBlockWidth') {
|
|
223
|
-
flatStyle.borderTopWidth = flatStyle.borderTopWidth ?? styleValue;
|
|
224
|
-
flatStyle.borderBottomWidth = flatStyle.borderBottomWidth ?? styleValue;
|
|
225
|
-
} else if (styleProp === 'borderBlockEndColor') {
|
|
226
|
-
flatStyle.borderBottomColor = prevStyle.borderBottomColor ?? styleValue;
|
|
227
|
-
} else if (styleProp === 'borderBlockEndStyle') {
|
|
228
|
-
flatStyle.borderBottomStyle = prevStyle.borderBottomStyle ?? styleValue;
|
|
229
|
-
} else if (styleProp === 'borderBlockEndWidth') {
|
|
230
|
-
flatStyle.borderBottomWidth = prevStyle.borderBottomWidth ?? styleValue;
|
|
231
|
-
} else if (styleProp === 'borderBlockStartColor') {
|
|
232
|
-
flatStyle.borderTopColor = prevStyle.borderTopColor ?? styleValue;
|
|
233
|
-
} else if (styleProp === 'borderBlockStartStyle') {
|
|
234
|
-
flatStyle.borderTopStyle = prevStyle.borderTopStyle ?? styleValue;
|
|
235
|
-
} else if (styleProp === 'borderBlockStartWidth') {
|
|
236
|
-
flatStyle.borderTopWidth = prevStyle.borderTopWidth ?? styleValue;
|
|
237
|
-
} else if (styleProp === 'borderInlineColor') {
|
|
238
|
-
flatStyle.borderStartColor = flatStyle.borderStartColor ?? styleValue;
|
|
239
|
-
flatStyle.borderEndColor = flatStyle.borderEndColor ?? styleValue;
|
|
240
|
-
} else if (styleProp === 'borderInlineStyle') {
|
|
241
|
-
flatStyle.borderStartStyle = flatStyle.borderStartStyle ?? styleValue;
|
|
242
|
-
flatStyle.borderEndStyle = flatStyle.borderEndStyle ?? styleValue;
|
|
243
|
-
} else if (styleProp === 'borderInlineWidth') {
|
|
244
|
-
flatStyle.borderStartWidth = flatStyle.borderStartWidth ?? styleValue;
|
|
245
|
-
flatStyle.borderEndWidth = flatStyle.borderEndWidth ?? styleValue;
|
|
246
|
-
} else if (styleProp === 'borderInlineEndColor') {
|
|
247
|
-
flatStyle.borderEndColor = styleValue;
|
|
248
|
-
} else if (styleProp === 'borderInlineEndStyle') {
|
|
249
|
-
flatStyle.borderEndStyle = styleValue;
|
|
250
|
-
} else if (styleProp === 'borderInlineEndWidth') {
|
|
251
|
-
flatStyle.borderEndWidth = styleValue;
|
|
252
|
-
} else if (styleProp === 'borderInlineStartColor') {
|
|
253
|
-
flatStyle.borderStartColor = styleValue;
|
|
254
|
-
} else if (styleProp === 'borderInlineStartStyle') {
|
|
255
|
-
flatStyle.borderStartStyle = styleValue;
|
|
256
|
-
} else if (styleProp === 'borderInlineStartWidth') {
|
|
257
|
-
flatStyle.borderStartWidth = styleValue;
|
|
258
|
-
} else if (styleProp === 'borderStartStartRadius') {
|
|
259
|
-
flatStyle.borderTopStartRadius = styleValue;
|
|
260
|
-
} else if (styleProp === 'borderEndStartRadius') {
|
|
261
|
-
flatStyle.borderBottomStartRadius = styleValue;
|
|
262
|
-
} else if (styleProp === 'borderStartEndRadius') {
|
|
263
|
-
flatStyle.borderTopEndRadius = styleValue;
|
|
264
|
-
} else if (styleProp === 'borderEndEndRadius') {
|
|
265
|
-
flatStyle.borderBottomEndRadius = styleValue;
|
|
266
|
-
} else if (styleProp === 'inset') {
|
|
267
|
-
flatStyle.top = flatStyle.top ?? styleValue;
|
|
268
|
-
flatStyle.start = flatStyle.start ?? styleValue;
|
|
269
|
-
flatStyle.end = flatStyle.end ?? styleValue;
|
|
270
|
-
flatStyle.bottom = flatStyle.bottom ?? styleValue;
|
|
271
|
-
} else if (styleProp === 'insetBlock') {
|
|
272
|
-
flatStyle.top = flatStyle.top ?? styleValue;
|
|
273
|
-
flatStyle.bottom = flatStyle.bottom ?? styleValue;
|
|
274
|
-
} else if (styleProp === 'insetBlockEnd') {
|
|
275
|
-
flatStyle.bottom = prevStyle.bottom ?? styleValue;
|
|
276
|
-
} else if (styleProp === 'insetBlockStart') {
|
|
277
|
-
flatStyle.top = prevStyle.top ?? styleValue;
|
|
278
|
-
} else if (styleProp === 'insetInline') {
|
|
279
|
-
flatStyle.end = flatStyle.end ?? styleValue;
|
|
280
|
-
flatStyle.start = flatStyle.start ?? styleValue;
|
|
281
|
-
} else if (styleProp === 'insetInlineEnd') {
|
|
282
|
-
flatStyle.end = prevStyle.end ?? styleValue;
|
|
283
|
-
} else if (styleProp === 'insetInlineStart') {
|
|
284
|
-
flatStyle.start = prevStyle.start ?? styleValue;
|
|
285
|
-
} else if (styleProp === 'marginBlock') {
|
|
286
|
-
flatStyle.marginVertical = styleValue;
|
|
287
|
-
} else if (styleProp === 'marginBlockStart') {
|
|
288
|
-
flatStyle.marginTop = flatStyle.marginTop ?? styleValue;
|
|
289
|
-
} else if (styleProp === 'marginBlockEnd') {
|
|
290
|
-
flatStyle.marginBottom = flatStyle.marginBottom ?? styleValue;
|
|
291
|
-
} else if (styleProp === 'marginInline') {
|
|
292
|
-
flatStyle.marginHorizontal = styleValue;
|
|
293
|
-
} else if (styleProp === 'marginInlineStart') {
|
|
294
|
-
flatStyle.marginStart = styleValue;
|
|
295
|
-
} else if (styleProp === 'marginInlineEnd') {
|
|
296
|
-
flatStyle.marginEnd = styleValue;
|
|
297
|
-
} else if (styleProp === 'paddingBlock') {
|
|
298
|
-
flatStyle.paddingVertical = styleValue;
|
|
299
|
-
} else if (styleProp === 'paddingBlockStart') {
|
|
300
|
-
flatStyle.paddingTop = flatStyle.paddingTop ?? styleValue;
|
|
301
|
-
} else if (styleProp === 'paddingBlockEnd') {
|
|
302
|
-
flatStyle.paddingBottom = flatStyle.paddingBottom ?? styleValue;
|
|
303
|
-
} else if (styleProp === 'paddingInline') {
|
|
304
|
-
flatStyle.paddingHorizontal = styleValue;
|
|
305
|
-
} else if (styleProp === 'paddingInlineStart') {
|
|
306
|
-
flatStyle.paddingStart = styleValue;
|
|
307
|
-
} else if (styleProp === 'paddingInlineEnd') {
|
|
308
|
-
flatStyle.paddingEnd = styleValue;
|
|
309
|
-
} else {
|
|
310
|
-
(0, _errorMsg.warnMsg)(`Ignoring unsupported style property "${styleProp}"`);
|
|
311
|
-
}
|
|
312
|
-
delete flatStyle[styleProp];
|
|
313
|
-
continue;
|
|
314
|
-
}
|
|
315
|
-
if (!isReactNativeStyleValue(styleValue)) {
|
|
316
|
-
(0, _errorMsg.warnMsg)(`Ignoring unsupported style value "${String(styleValue)}" for property "${styleProp}"`);
|
|
317
|
-
delete flatStyle[styleProp];
|
|
318
|
-
continue;
|
|
319
|
-
}
|
|
320
|
-
flatStyle[styleProp] = styleValue;
|
|
321
|
-
}
|
|
322
|
-
if (flatStyle != null && Object.keys(flatStyle).length > 0) {
|
|
323
|
-
flatStyle = _CSSMediaQuery.CSSMediaQuery.resolveMediaQueries(flatStyle, {
|
|
324
|
-
width: viewportWidth,
|
|
325
|
-
height: viewportHeight,
|
|
326
|
-
direction: writingDirection
|
|
327
|
-
});
|
|
328
|
-
if (flatStyle.borderStyle === 'none') {
|
|
329
|
-
flatStyle.borderWidth = 0;
|
|
330
|
-
delete flatStyle.borderStyle;
|
|
331
|
-
}
|
|
332
|
-
if (typeof flatStyle.fontWeight === 'number') {
|
|
333
|
-
flatStyle.fontWeight = flatStyle.fontWeight.toString();
|
|
334
|
-
}
|
|
335
|
-
const boxSizingValue = flatStyle.boxSizing;
|
|
336
|
-
if (boxSizingValue === 'content-box') {
|
|
337
|
-
flatStyle = (0, _fixContentBox.fixContentBox)(flatStyle);
|
|
338
|
-
}
|
|
339
|
-
delete flatStyle.boxSizing;
|
|
340
|
-
const positionValue = flatStyle.position;
|
|
341
|
-
if (positionValue === 'fixed') {
|
|
342
|
-
flatStyle.position = 'absolute';
|
|
343
|
-
(0, _errorMsg.warnMsg)('"position" value of "fixed" is not supported in React Native. Falling back to "absolute".');
|
|
344
|
-
} else if (positionValue === 'static') {
|
|
345
|
-
flatStyle.position = 'relative';
|
|
346
|
-
(0, _errorMsg.warnMsg)('"position" value of "static" is not supported in React Native. Falling back to "relative".');
|
|
347
|
-
} else if (positionValue === 'sticky') {
|
|
348
|
-
flatStyle.position = 'relative';
|
|
349
|
-
(0, _errorMsg.warnMsg)('"position" value of "sticky" is not supported in React Native. Falling back to "relative".');
|
|
350
|
-
}
|
|
351
|
-
for (const timeValuedProperty of timeValuedProperties) {
|
|
352
|
-
if (typeof flatStyle[timeValuedProperty] === 'string') {
|
|
353
|
-
flatStyle[timeValuedProperty] = (0, _parseTimeValue.parseTimeValue)(flatStyle[timeValuedProperty]);
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
nativeProps.style = flatStyle;
|
|
357
|
-
}
|
|
358
|
-
if (lineClamp != null) {
|
|
359
|
-
nativeProps.numberOfLines = lineClamp;
|
|
360
|
-
}
|
|
361
|
-
return nativeProps;
|
|
362
|
-
}
|
|
363
|
-
const __customProperties = exports.__customProperties = {};
|
|
364
|
-
let count = 1;
|
|
365
|
-
const defineVars = tokens => {
|
|
366
|
-
const result = {};
|
|
367
|
-
for (const key in tokens) {
|
|
368
|
-
const value = tokens[key];
|
|
369
|
-
result[key] = `var(--${key}-${count++})`;
|
|
370
|
-
__customProperties[result[key]] = value;
|
|
371
|
-
}
|
|
372
|
-
return result;
|
|
373
|
-
};
|
|
374
|
-
exports.defineVars = defineVars;
|
|
375
|
-
const createTheme = (baseTokens, overrides) => {
|
|
376
|
-
const result = {};
|
|
377
|
-
for (const key in baseTokens) {
|
|
378
|
-
const varName = baseTokens[key];
|
|
379
|
-
result[varName] = overrides[key];
|
|
380
|
-
}
|
|
381
|
-
return result;
|
|
382
|
-
};
|
|
383
|
-
exports.createTheme = createTheme;
|
|
384
|
-
const stylex = exports.stylex = {
|
|
385
|
-
create,
|
|
386
|
-
firstThatWorks,
|
|
387
|
-
keyframes,
|
|
388
|
-
props,
|
|
389
|
-
defineVars,
|
|
390
|
-
createTheme,
|
|
391
|
-
__customProperties
|
|
392
|
-
};
|
|
393
|
-
var _default = exports.default = stylex;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @flow strict
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { type SpreadOptions } from './SpreadOptions';
|
|
11
|
-
import type { StyleX$CreateTheme, StyleX$DefineVars } from '../StyleXTypes';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* The create method shim should do initial transforms like
|
|
15
|
-
* renaming/expanding/validating properties, essentially all the steps
|
|
16
|
-
* which can be done at initialization-time (could potentially be done at
|
|
17
|
-
* compile-time in the future).
|
|
18
|
-
*/
|
|
19
|
-
declare export function create<S: { [string]: { ... } }>(styles: S): {
|
|
20
|
-
[string]: { ... },
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
declare export const firstThatWorks: <T: string | number>(
|
|
24
|
-
...values: $ReadOnlyArray<T>
|
|
25
|
-
) => T;
|
|
26
|
-
|
|
27
|
-
type Keyframes = {
|
|
28
|
-
+[key: string]: { +[k: string]: string | number },
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
declare export function keyframes(k: Keyframes): Keyframes;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* The spread method shim
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
declare export function props(
|
|
38
|
-
this: SpreadOptions,
|
|
39
|
-
...style: $ReadOnlyArray<?{ [key: string]: mixed }>
|
|
40
|
-
): { [string]: { ... } };
|
|
41
|
-
|
|
42
|
-
declare export const __customProperties: { [string]: mixed };
|
|
43
|
-
|
|
44
|
-
declare export const defineVars: StyleX$DefineVars;
|
|
45
|
-
|
|
46
|
-
declare export const createTheme: $FlowFixMe;
|
|
47
|
-
|
|
48
|
-
export type IStyleX = $ReadOnly<{
|
|
49
|
-
create: typeof create,
|
|
50
|
-
firstThatWorks: typeof firstThatWorks,
|
|
51
|
-
keyframes: typeof keyframes,
|
|
52
|
-
props: typeof props,
|
|
53
|
-
defineVars: StyleX$DefineVars,
|
|
54
|
-
createTheme: StyleX$CreateTheme,
|
|
55
|
-
__customProperties?: { [string]: mixed },
|
|
56
|
-
}>;
|
|
57
|
-
|
|
58
|
-
declare export const stylex: IStyleX;
|
|
59
|
-
|
|
60
|
-
declare export default IStyleX;
|