@stylexjs/shared 0.1.0-beta.7 → 0.2.0-beta.8
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/lib/expand-shorthands.d.ts +5 -0
- package/lib/expand-shorthands.js +251 -54
- package/lib/index.d.ts +1 -0
- package/lib/messages.js +6 -2
- package/lib/stylex-create.js +34 -12
- package/lib/stylex-defaultValue.js +230 -98
- package/package.json +1 -1
package/lib/expand-shorthands.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.BANNED_PROPERTIES = void 0;
|
|
6
7
|
exports.default = flatMapExpandedShorthands;
|
|
8
|
+
exports.expandedKeys = void 0;
|
|
7
9
|
var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
|
|
8
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
11
|
/**
|
|
@@ -65,70 +67,236 @@ function splitValue(str) {
|
|
|
65
67
|
|
|
66
68
|
/**
|
|
67
69
|
* Shorthand properties:
|
|
68
|
-
* - [
|
|
69
|
-
* - [
|
|
70
|
-
* - [
|
|
71
|
-
* - [
|
|
72
|
-
*
|
|
73
|
-
* - [
|
|
74
|
-
* - [
|
|
75
|
-
* - [
|
|
76
|
-
* - [
|
|
77
|
-
* - [
|
|
78
|
-
* - [
|
|
79
|
-
* - [
|
|
70
|
+
* - [!] all - BANNED
|
|
71
|
+
* - [!] animation - BANNED
|
|
72
|
+
* - [!] background - BANNED
|
|
73
|
+
* - [x] border - Expanded to border-{direction}. Not to border-*-(width|style|color).
|
|
74
|
+
* This is to limit the number of atoms to 4 instead of 12.
|
|
75
|
+
* - [o] border-top - Only the shorthand is allowed.
|
|
76
|
+
* - [o] border-end - Only the shorthand is allowed.
|
|
77
|
+
* - [o] border-bottom - Only the shorthand is allowed.
|
|
78
|
+
* - [o] border-start - Only the shorthand is allowed.
|
|
79
|
+
* - [!] border-left - BANNED
|
|
80
|
+
* - [!] border-right
|
|
81
|
+
* - [!] border-*-width - BANNED
|
|
82
|
+
* - [!] border-*-style - BANNED
|
|
83
|
+
* - [!] border-*-color - BANNED
|
|
84
|
+
* - [ ] border-block-end
|
|
85
|
+
* - [ ] border-block-start
|
|
86
|
+
* - [ ] border-inline-start
|
|
87
|
+
* - [ ] border-inline-end
|
|
88
|
+
* - [!] border-image - BANNED
|
|
80
89
|
* - [x] border-radius
|
|
81
|
-
* - [
|
|
82
|
-
* - [
|
|
83
|
-
* - [
|
|
84
|
-
* - [
|
|
85
|
-
* - [
|
|
86
|
-
* - [
|
|
87
|
-
* - [
|
|
88
|
-
* - [
|
|
89
|
-
* - [
|
|
90
|
-
* - [
|
|
91
|
-
* - [
|
|
92
|
-
* - [
|
|
93
|
-
*
|
|
94
|
-
* - [
|
|
95
|
-
* - [ ] grid-template
|
|
96
|
-
* - [ ] list-style
|
|
90
|
+
* - [o] column-rule - Only the shorthand is allowed.
|
|
91
|
+
* - [!] columns - BANNED
|
|
92
|
+
* - [!] flex - BANNED
|
|
93
|
+
* - [!] flex-flow - BANNED
|
|
94
|
+
* - [!] font - BANNED
|
|
95
|
+
* - [x] gap
|
|
96
|
+
* - [!] grid - BANNED
|
|
97
|
+
* - [!] grid-area - BANNED
|
|
98
|
+
* - [!] grid-column - BANNED
|
|
99
|
+
* - [!] grid-row - BANNED
|
|
100
|
+
* - [!] grid-template - BANNED
|
|
101
|
+
* - [!] grid-template-areas - BANNED
|
|
102
|
+
*
|
|
103
|
+
* - [o] list-style - Only the shorthand is allowed.
|
|
97
104
|
* - [x] margin
|
|
98
|
-
* - [
|
|
99
|
-
* - [
|
|
100
|
-
* - [
|
|
105
|
+
* - [o] mask - Only the shorthand is allowed.
|
|
106
|
+
* - [o] offset - Only the shorthand is allowed.
|
|
107
|
+
* - [o] outline - Only the shorthand is allowed.
|
|
101
108
|
* - [x] overflow
|
|
102
109
|
* - [x] padding
|
|
103
|
-
* - [
|
|
104
|
-
* - [
|
|
105
|
-
* - [
|
|
106
|
-
* - [
|
|
107
|
-
* - [
|
|
108
|
-
* - [
|
|
109
|
-
* - [
|
|
110
|
-
* - [
|
|
110
|
+
* - [x] place-content
|
|
111
|
+
* - [x] place-items
|
|
112
|
+
* - [x] place-self
|
|
113
|
+
* - [X] scroll-margin
|
|
114
|
+
* - [x] scroll-padding
|
|
115
|
+
* - [o] text-decoration - Only the shorthand is allowed.
|
|
116
|
+
* - [o] text-emphasis - Only the shorthand is allowed.
|
|
117
|
+
* - [!] transition - BANNED
|
|
111
118
|
*/
|
|
112
119
|
|
|
120
|
+
const BANNED_PROPERTIES = {
|
|
121
|
+
all: '`all` is not supported. Use individual properties instead.',
|
|
122
|
+
animation: '`animation` is not supported. Use individual properties like `animationName`, `animationDuration`, etc. instead.',
|
|
123
|
+
background: '`background` is not supported. Use individual properties like `backgroundImage`, `backgroundPosition`, etc. instead.',
|
|
124
|
+
borderColor: '`borderColor` is not supported. Use `border`, `borderTop`, `borderEnd`, `borderBottom` or `borderStart` instead.',
|
|
125
|
+
borderStyle: '`borderStyle` is not supported. Use `border`, `borderTop`, `borderEnd`, `borderBottom` or `borderStart` instead.',
|
|
126
|
+
borderWidth: '`borderWidth` is not supported. Use `border`, `borderTop`, `borderEnd`, `borderBottom` or `borderStart` instead.',
|
|
127
|
+
borderTopColor: '`borderTopColor` is not supported. Use `borderTop` instead.',
|
|
128
|
+
borderTopStyle: '`borderTopStyle` is not supported. Use `borderTop` instead.',
|
|
129
|
+
borderTopWidth: '`borderTopWidth` is not supported. Use `borderTop` instead.',
|
|
130
|
+
borderEndColor: '`borderEndColor` is not supported. Use `borderEnd` instead.',
|
|
131
|
+
borderEndStyle: '`borderEndStyle` is not supported. Use `borderEnd` instead.',
|
|
132
|
+
borderEndWidth: '`borderEndWidth` is not supported. Use `borderEnd` instead.',
|
|
133
|
+
borderBottomColor: '`borderBottomColor` is not supported. Use `borderBottom` instead.',
|
|
134
|
+
borderBottomStyle: '`borderBottomStyle` is not supported. Use `borderBottom` instead.',
|
|
135
|
+
borderBottomWidth: '`borderBottomWidth` is not supported. Use `borderBottom` instead.',
|
|
136
|
+
borderStartColor: '`borderStartColor` is not supported. Use `borderStart` instead.',
|
|
137
|
+
borderStartStyle: '`borderStartStyle` is not supported. Use `borderStart` instead.',
|
|
138
|
+
borderStartWidth: '`borderStartWidth` is not supported. Use `borderStart` instead.',
|
|
139
|
+
borderBlockStartColor: '`borderBlockStartColor` is not supported. Use `borderTop` instead.',
|
|
140
|
+
borderBlockStartStyle: '`borderBlockStartStyle` is not supported. Use `borderTop` instead.',
|
|
141
|
+
borderBlockStartWidth: '`borderBlockStartWidth` is not supported. Use `borderTop` instead.',
|
|
142
|
+
borderBlockEndColor: '`borderBlockEndColor` is not supported. Use `borderBottom` instead.',
|
|
143
|
+
borderBlockEndStyle: '`borderBlockEndStyle` is not supported. Use `borderBottom` instead.',
|
|
144
|
+
borderBlockEndWidth: '`borderBlockEndWidth` is not supported. Use `borderBottom` instead.',
|
|
145
|
+
borderInlineStartColor: '`borderInlineStartColor` is not supported. Use `borderStart` instead.',
|
|
146
|
+
borderInlineStartStyle: '`borderInlineStartStyle` is not supported. Use `borderStart` instead.',
|
|
147
|
+
borderInlineStartWidth: '`borderInlineStartWidth` is not supported. Use `borderStart` instead.',
|
|
148
|
+
borderInlineEndColor: '`borderInlineEndColor` is not supported. Use `borderEnd` instead.',
|
|
149
|
+
borderInlineEndStyle: '`borderInlineEndStyle` is not supported. Use `borderEnd` instead.',
|
|
150
|
+
borderInlineEndWidth: '`borderInlineEndWidth` is not supported. Use `borderEnd` instead.',
|
|
151
|
+
borderLeft: '`borderLeft` is not supported. Use `borderStart` instead.',
|
|
152
|
+
borderLeftColor: '`borderLeftColor` is not supported. Use `borderStart` instead.',
|
|
153
|
+
borderLeftStyle: '`borderLeftStyle` is not supported. Use `borderStart` instead.',
|
|
154
|
+
borderLeftWidth: '`borderLeftWidth` is not supported. Use `borderStart` instead.',
|
|
155
|
+
borderRight: '`borderRight` is not supported. Use `borderEnd` instead.',
|
|
156
|
+
borderRightColor: '`borderRightColor` is not supported. Use `borderEnd` instead.',
|
|
157
|
+
borderRightStyle: '`borderRightStyle` is not supported. Use `borderEnd` instead.',
|
|
158
|
+
borderRightWidth: '`borderRightWidth` is not supported. Use `borderEnd` instead.',
|
|
159
|
+
borderTopLeftRadius: '`borderTopLeftRadius` is not supported. Use `borderTopStartRadius` instead.',
|
|
160
|
+
borderTopRightRadius: '`borderTopRightRadius` is not supported. Use `borderTopEndRadius` instead.',
|
|
161
|
+
borderBottomLeftRadius: '`borderBottomLeftRadius` is not supported. Use `borderBottomStartRadius` instead.',
|
|
162
|
+
borderBottomRightRadius: '`borderBottomRightRadius` is not supported. Use `borderBottomEndRadius` instead.',
|
|
163
|
+
borderImageSource: '`borderImageSource` is not supported. Use `borderImage` instead.',
|
|
164
|
+
borderImageSlice: '`borderImageSlice` is not supported. Use `borderImage` instead.',
|
|
165
|
+
borderImageWidth: '`borderImageWidth` is not supported. Use `borderImage` instead.',
|
|
166
|
+
borderImageOutset: '`borderImageOutset` is not supported. Use `borderImage` instead.',
|
|
167
|
+
borderImageRepeat: '`borderImageRepeat` is not supported. Use `borderImage` instead.',
|
|
168
|
+
marginLeft: '`marginLeft` is not supported. Use `marginStart` instead.',
|
|
169
|
+
marginRight: '`marginRight` is not supported. Use `marginEnd` instead.',
|
|
170
|
+
paddingLeft: '`paddingLeft` is not supported. Use `paddingStart` instead.',
|
|
171
|
+
paddingRight: '`paddingRight` is not supported. Use `paddingEnd` instead.',
|
|
172
|
+
columnRuleWidth: '`columnRuleWidth` is not supported. Use `columnRule` instead.',
|
|
173
|
+
columnRuleStyle: '`columnRuleStyle` is not supported. Use `columnRule` instead.',
|
|
174
|
+
columnRuleColor: '`columnRuleColor` is not supported. Use `columnRule` instead.',
|
|
175
|
+
columns: '`columns` is not supported. Use `columnCount` and `columnWidth` instead.',
|
|
176
|
+
flex: '`flex` is not supported. Use `flexGrow`, `flexShrink`, and `flexBasis` instead.',
|
|
177
|
+
flexFlow: '`flexFlow` is not supported. Use `flexDirection` and `flexWrap` instead.',
|
|
178
|
+
font: '`font` is not supported. Use individual properties like `fontFamily`, `fontSize`, etc. instead.',
|
|
179
|
+
grid: '`grid` is not supported. Use individual properties like `gridTemplateColumns`, `gridTemplateRows`, etc. instead.',
|
|
180
|
+
gridColumn: '`gridColumn` is not supported. Use `gridColumnStart` and `gridColumnEnd` instead.',
|
|
181
|
+
gridRow: '`gridRow` is not supported. Use `gridRowStart` and `gridRowEnd` instead.',
|
|
182
|
+
gridArea: '`gridArea` is not supported. Use `gridRowStart`, `gridColumnStart`, `gridRowEnd`, and `gridColumnEnd` instead.',
|
|
183
|
+
gridTemplate: '`gridTemplate` is not supported. Use individual properties like `gridTemplateColumns`, `gridTemplateRows`, etc. instead.',
|
|
184
|
+
gridTemplateAreas: '`gridTemplateAreas` is not supported. Use `gridTemplateRows` and `gridTemplateColumns` instead.',
|
|
185
|
+
listStyleImage: '`listStyleImage` is not supported. Use `listStyle` instead.',
|
|
186
|
+
listStylePosition: '`listStylePosition` is not supported. Use `listStyle` instead.',
|
|
187
|
+
listStyleType: '`listStyleType` is not supported. Use `listStyle` instead.',
|
|
188
|
+
maskClip: '`maskClip` is not supported. Use `mask` instead.',
|
|
189
|
+
maskComposite: '`maskComposite` is not supported. Use `mask` instead.',
|
|
190
|
+
maskImage: '`maskImage` is not supported. Use `mask` instead.',
|
|
191
|
+
maskMode: '`maskMode` is not supported. Use `mask` instead.',
|
|
192
|
+
maskOrigin: '`maskOrigin` is not supported. Use `mask` instead.',
|
|
193
|
+
maskPosition: '`maskPosition` is not supported. Use `mask` instead.',
|
|
194
|
+
maskRepeat: '`maskRepeat` is not supported. Use `mask` instead.',
|
|
195
|
+
maskSize: '`maskSize` is not supported. Use `mask` instead.',
|
|
196
|
+
offsetAnchor: '`offsetAnchor` is not supported. Use `offset` instead.',
|
|
197
|
+
offsetDistance: '`offsetDistance` is not supported. Use `offset` instead.',
|
|
198
|
+
offsetPath: '`offsetPath` is not supported. Use `offset` instead.',
|
|
199
|
+
offsetPosition: '`offsetPosition` is not supported. Use `offset` instead.',
|
|
200
|
+
offsetRotate: '`offsetRotate` is not supported. Use `offset` instead.',
|
|
201
|
+
outlineColor: '`outlineColor` is not supported. Use `outline` instead.',
|
|
202
|
+
outlineStyle: '`outlineStyle` is not supported. Use `outline` instead.',
|
|
203
|
+
outlineWidth: '`outlineWidth` is not supported. Use `outline` instead.',
|
|
204
|
+
textDecorationColor: '`textDecorationColor` is not supported. Use `textDecoration` instead.',
|
|
205
|
+
textDecorationLine: '`textDecorationLine` is not supported. Use `textDecoration` instead.',
|
|
206
|
+
textDecorationStyle: '`textDecorationStyle` is not supported. Use `textDecoration` instead.',
|
|
207
|
+
textDecorationThickness: '`textDecorationThickness` is not supported. Use `textDecoration` instead.',
|
|
208
|
+
textEmphasisColor: '`textEmphasisColor` is not supported. Use `textEmphasis` instead.',
|
|
209
|
+
textEmphasisStyle: '`textEmphasisStyle` is not supported. Use `textEmphasis` instead.',
|
|
210
|
+
transition: '`transition` is not supported. Use individual properties like `transitionProperty`, `transitionDuration`, etc. instead.'
|
|
211
|
+
};
|
|
212
|
+
exports.BANNED_PROPERTIES = BANNED_PROPERTIES;
|
|
113
213
|
const expansions = {
|
|
114
|
-
// ...aliases,
|
|
115
214
|
border: rawValue => {
|
|
116
215
|
return [['borderTop', rawValue], ['borderEnd', rawValue], ['borderBottom', rawValue], ['borderStart', rawValue]];
|
|
117
216
|
},
|
|
118
|
-
|
|
119
|
-
//
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
217
|
+
// border: (rawValue: string) => {
|
|
218
|
+
// if (typeof rawValue === 'number') {
|
|
219
|
+
// return expansions.borderWidth(rawValue);
|
|
220
|
+
// }
|
|
221
|
+
// const [width, style, color, more] = splitValue(rawValue);
|
|
222
|
+
// if (more != null) {
|
|
223
|
+
// throw new Error(messages.MULTIPLE_DIRECTIONS_IN_SHORTHAND);
|
|
224
|
+
// }
|
|
225
|
+
// if (style == null || color == null) {
|
|
226
|
+
// throw new Error(
|
|
227
|
+
// 'Border shorthand requires at least 2 values - width, style and color.'
|
|
228
|
+
// );
|
|
229
|
+
// }
|
|
230
|
+
// return [
|
|
231
|
+
// ...expansions.borderWidth(width),
|
|
232
|
+
// ...expansions.borderStyle(style),
|
|
233
|
+
// ...expansions.borderColor(color),
|
|
234
|
+
// ];
|
|
235
|
+
// },
|
|
236
|
+
// borderTop: (rawValue: string) => {
|
|
237
|
+
// if (typeof rawValue === 'number') {
|
|
238
|
+
// return [['borderTopWidth', rawValue + 'px']];
|
|
239
|
+
// }
|
|
240
|
+
// const [width, style, color] = splitValue(rawValue);
|
|
241
|
+
// if (style == null || color == null) {
|
|
242
|
+
// throw new Error(
|
|
243
|
+
// 'BorderTop shorthand requires at least 2 values - width, style and color.'
|
|
244
|
+
// );
|
|
245
|
+
// }
|
|
246
|
+
// return [
|
|
247
|
+
// ['borderTopWidth', width],
|
|
248
|
+
// ['borderTopStyle', style],
|
|
249
|
+
// ['borderTopColor', color],
|
|
250
|
+
// ];
|
|
251
|
+
// },
|
|
252
|
+
// borderEnd: (rawValue: string) => {
|
|
253
|
+
// if (typeof rawValue === 'number') {
|
|
254
|
+
// return [['borderEndWidth', rawValue + 'px']];
|
|
255
|
+
// }
|
|
256
|
+
// const [width, style, color] = splitValue(rawValue);
|
|
257
|
+
// if (style == null || color == null) {
|
|
258
|
+
// throw new Error(
|
|
259
|
+
// 'BorderEnd shorthand requires at least 2 values - width, style and color.'
|
|
260
|
+
// );
|
|
261
|
+
// }
|
|
262
|
+
// return [
|
|
263
|
+
// ['borderEndWidth', width],
|
|
264
|
+
// ['borderEndStyle', style],
|
|
265
|
+
// ['borderEndColor', color],
|
|
266
|
+
// ];
|
|
267
|
+
// },
|
|
268
|
+
// borderBottom: (rawValue: string) => {
|
|
269
|
+
// if (typeof rawValue === 'number') {
|
|
270
|
+
// return [['borderBottomWidth', rawValue + 'px']];
|
|
271
|
+
// }
|
|
272
|
+
// const [width, style, color] = splitValue(rawValue);
|
|
273
|
+
// if (style == null || color == null) {
|
|
274
|
+
// throw new Error(
|
|
275
|
+
// 'BorderBottom shorthand requires at least 2 values - width, style and color.'
|
|
276
|
+
// );
|
|
277
|
+
// }
|
|
278
|
+
// return [
|
|
279
|
+
// ['borderBottomWidth', width],
|
|
280
|
+
// ['borderBottomStyle', style],
|
|
281
|
+
// ['borderBottomColor', color],
|
|
282
|
+
// ];
|
|
283
|
+
// },
|
|
284
|
+
// borderStart: (rawValue: string) => {
|
|
285
|
+
// if (typeof rawValue === 'number') {
|
|
286
|
+
// return [['borderStartWidth', rawValue + 'px']];
|
|
287
|
+
// }
|
|
288
|
+
// const [width, style, color] = splitValue(rawValue);
|
|
289
|
+
// if (style == null || color == null) {
|
|
290
|
+
// throw new Error(
|
|
291
|
+
// 'BorderStart shorthand requires at least 2 values - width, style and color.'
|
|
292
|
+
// );
|
|
293
|
+
// }
|
|
294
|
+
// return [
|
|
295
|
+
// ['borderStartWidth', width],
|
|
296
|
+
// ['borderStartStyle', style],
|
|
297
|
+
// ['borderStartColor', color],
|
|
298
|
+
// ];
|
|
299
|
+
// },
|
|
132
300
|
borderColor: rawValue => {
|
|
133
301
|
const [top, right = top, bottom = top, left = right] = splitValue(rawValue);
|
|
134
302
|
return [['borderTopColor', top], ['borderEndColor', right], ['borderBottomColor', bottom], ['borderStartColor', left]];
|
|
@@ -175,8 +343,37 @@ const expansions = {
|
|
|
175
343
|
},
|
|
176
344
|
paddingVertical: rawValue => {
|
|
177
345
|
return [['paddingTop', rawValue], ['paddingBottom', rawValue]];
|
|
346
|
+
},
|
|
347
|
+
gap: rawValue => {
|
|
348
|
+
if (typeof rawValue === 'number') {
|
|
349
|
+
return [['rowGap', rawValue], ['columnGap', rawValue]];
|
|
350
|
+
}
|
|
351
|
+
const [row, column = row] = splitValue(rawValue);
|
|
352
|
+
return [['rowGap', row], ['columnGap', column]];
|
|
353
|
+
},
|
|
354
|
+
placeContent: rawValue => {
|
|
355
|
+
const [align, justify = align] = splitValue(rawValue);
|
|
356
|
+
return [['alignContent', align], ['justifyContent', justify]];
|
|
357
|
+
},
|
|
358
|
+
placeItems: rawValue => {
|
|
359
|
+
const [align, justify = align] = splitValue(rawValue);
|
|
360
|
+
return [['alignItems', align], ['justifyItems', justify]];
|
|
361
|
+
},
|
|
362
|
+
placeSelf: rawValue => {
|
|
363
|
+
const [align, justify = align] = splitValue(rawValue);
|
|
364
|
+
return [['alignSelf', align], ['justifySelf', justify]];
|
|
365
|
+
},
|
|
366
|
+
scrollMargin: rawValue => {
|
|
367
|
+
const [top, right = top, bottom = top, left = right] = typeof rawValue === 'number' ? [rawValue] : splitValue(rawValue);
|
|
368
|
+
return [['scrollMarginTop', top], ['scrollMarginEnd', right], ['scrollMarginBottom', bottom], ['scrollMarginStart', left]];
|
|
369
|
+
},
|
|
370
|
+
scrollPadding: rawValue => {
|
|
371
|
+
const [top, right = top, bottom = top, left = right] = typeof rawValue === 'number' ? [rawValue] : splitValue(rawValue);
|
|
372
|
+
return [['scrollPaddingTop', top], ['scrollPaddingEnd', right], ['scrollPaddingBottom', bottom], ['scrollPaddingStart', left]];
|
|
178
373
|
}
|
|
179
374
|
};
|
|
375
|
+
const expandedKeys = [...Object.keys(expansions), ...Object.keys(BANNED_PROPERTIES)];
|
|
376
|
+
exports.expandedKeys = expandedKeys;
|
|
180
377
|
function flatMapExpandedShorthands(objEntry) {
|
|
181
378
|
const [key, value] = objEntry;
|
|
182
379
|
const expansion = expansions[key];
|
package/lib/index.d.ts
CHANGED
package/lib/messages.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", {
|
|
14
14
|
value: true
|
|
15
15
|
});
|
|
16
|
-
exports.UNKNOWN_PROP_KEY = exports.UNKNOWN_NAMESPACE = exports.UNEXPECTED_ARGUMENT = exports.UNBOUND_STYLEX_CALL_VALUE = exports.ONLY_TOP_LEVEL = exports.NO_PARENT_PATH = exports.NON_STATIC_VALUE = exports.NON_OBJECT_FOR_STYLEX_CALL = exports.LOCAL_ONLY = exports.LINT_UNCLOSED_FUNCTION = exports.INVALID_SPREAD = exports.INVALID_PSEUDO = exports.ILLEGAL_PROP_VALUE = exports.ILLEGAL_PROP_ARRAY_VALUE = exports.ILLEGAL_NESTED_PSEUDO = exports.ILLEGAL_NAMESPACE_VALUE = exports.ILLEGAL_NAMESPACE_TYPE = exports.ILLEGAL_ARGUMENT_LENGTH = exports.EXPECTED_FUNCTION_CALL = exports.ESCAPED_STYLEX_VALUE = void 0;
|
|
16
|
+
exports.UNKNOWN_PROP_KEY = exports.UNKNOWN_NAMESPACE = exports.UNEXPECTED_ARGUMENT = exports.UNBOUND_STYLEX_CALL_VALUE = exports.ONLY_TOP_LEVEL = exports.NO_PARENT_PATH = exports.NO_CONDITIONAL_SHORTHAND = exports.NON_STATIC_VALUE = exports.NON_OBJECT_FOR_STYLEX_CALL = exports.MULTIPLE_DIRECTIONS_IN_SHORTHAND = exports.LOCAL_ONLY = exports.LINT_UNCLOSED_FUNCTION = exports.INVALID_SPREAD = exports.INVALID_PSEUDO = exports.ILLEGAL_PROP_VALUE = exports.ILLEGAL_PROP_ARRAY_VALUE = exports.ILLEGAL_NESTED_PSEUDO = exports.ILLEGAL_NAMESPACE_VALUE = exports.ILLEGAL_NAMESPACE_TYPE = exports.ILLEGAL_ARGUMENT_LENGTH = exports.EXPECTED_FUNCTION_CALL = exports.ESCAPED_STYLEX_VALUE = void 0;
|
|
17
17
|
const ILLEGAL_ARGUMENT_LENGTH = 'stylex() should have 1 argument.';
|
|
18
18
|
exports.ILLEGAL_ARGUMENT_LENGTH = ILLEGAL_ARGUMENT_LENGTH;
|
|
19
19
|
const NON_STATIC_VALUE = 'Only static values are allowed inside of a stylex.create() call.';
|
|
@@ -30,6 +30,8 @@ const UNKNOWN_PROP_KEY = 'Unknown property key';
|
|
|
30
30
|
exports.UNKNOWN_PROP_KEY = UNKNOWN_PROP_KEY;
|
|
31
31
|
const INVALID_PSEUDO = 'Invalid pseudo selector, not on the whitelist.';
|
|
32
32
|
exports.INVALID_PSEUDO = INVALID_PSEUDO;
|
|
33
|
+
const NO_CONDITIONAL_SHORTHAND = 'You cannot use conditional style values for a shorthand property.';
|
|
34
|
+
exports.NO_CONDITIONAL_SHORTHAND = NO_CONDITIONAL_SHORTHAND;
|
|
33
35
|
const ILLEGAL_NAMESPACE_TYPE = 'Only a string literal namespace is allowed here.';
|
|
34
36
|
exports.ILLEGAL_NAMESPACE_TYPE = ILLEGAL_NAMESPACE_TYPE;
|
|
35
37
|
const UNKNOWN_NAMESPACE = 'Unknown namespace';
|
|
@@ -53,4 +55,6 @@ exports.UNEXPECTED_ARGUMENT = UNEXPECTED_ARGUMENT;
|
|
|
53
55
|
const EXPECTED_FUNCTION_CALL = 'Expected a simple function call but found something else.';
|
|
54
56
|
exports.EXPECTED_FUNCTION_CALL = EXPECTED_FUNCTION_CALL;
|
|
55
57
|
const NO_PARENT_PATH = 'Unexpected AST node without a parent path.';
|
|
56
|
-
exports.NO_PARENT_PATH = NO_PARENT_PATH;
|
|
58
|
+
exports.NO_PARENT_PATH = NO_PARENT_PATH;
|
|
59
|
+
const MULTIPLE_DIRECTIONS_IN_SHORTHAND = 'Shorthand properties cannot contain different values for different directions.';
|
|
60
|
+
exports.MULTIPLE_DIRECTIONS_IN_SHORTHAND = MULTIPLE_DIRECTIONS_IN_SHORTHAND;
|
package/lib/stylex-create.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = styleXCreateSet;
|
|
7
7
|
var _convertToClassName = _interopRequireDefault(require("./convert-to-className"));
|
|
8
|
-
var _expandShorthands =
|
|
8
|
+
var _expandShorthands = _interopRequireWildcard(require("./expand-shorthands"));
|
|
9
9
|
var _objectUtils = require("./utils/object-utils");
|
|
10
10
|
var messages = _interopRequireWildcard(require("./messages"));
|
|
11
11
|
var _stylexInclude = require("./stylex-include");
|
|
@@ -81,7 +81,7 @@ function styleXCreateNamespace(style, options) {
|
|
|
81
81
|
return [[key, value]];
|
|
82
82
|
}
|
|
83
83
|
if (value != null && typeof value === 'object' && !Array.isArray(value)) {
|
|
84
|
-
if (!key.startsWith(':') && !key.startsWith('@')) {
|
|
84
|
+
if (!key.startsWith(':') && !key.startsWith('@') && _expandShorthands.expandedKeys.includes(key)) {
|
|
85
85
|
throw new Error(messages.INVALID_PSEUDO);
|
|
86
86
|
}
|
|
87
87
|
return [[key, (0, _objectUtils.objFromEntries)((0, _objectUtils.objEntries)(value).flatMap(_ref2 => {
|
|
@@ -89,6 +89,9 @@ function styleXCreateNamespace(style, options) {
|
|
|
89
89
|
if (innerValue != null && typeof innerValue === 'object' && !Array.isArray(innerValue)) {
|
|
90
90
|
throw new Error(messages.ILLEGAL_NESTED_PSEUDO);
|
|
91
91
|
}
|
|
92
|
+
if (!options.allowUnsafeProperties && _expandShorthands.BANNED_PROPERTIES[key]) {
|
|
93
|
+
throw new Error(_expandShorthands.BANNED_PROPERTIES[key]);
|
|
94
|
+
}
|
|
92
95
|
return (0, _expandShorthands.default)([innerKey, innerValue]);
|
|
93
96
|
}))]];
|
|
94
97
|
} else {
|
|
@@ -98,6 +101,9 @@ function styleXCreateNamespace(style, options) {
|
|
|
98
101
|
if (Array.isArray(value) && value.some(val => typeof val === 'object')) {
|
|
99
102
|
throw new Error(messages.ILLEGAL_PROP_ARRAY_VALUE);
|
|
100
103
|
}
|
|
104
|
+
if (!options.allowUnsafeProperties && _expandShorthands.BANNED_PROPERTIES[key]) {
|
|
105
|
+
throw new Error(_expandShorthands.BANNED_PROPERTIES[key]);
|
|
106
|
+
}
|
|
101
107
|
return (0, _expandShorthands.default)([key, value]);
|
|
102
108
|
}
|
|
103
109
|
});
|
|
@@ -113,18 +119,34 @@ function styleXCreateNamespace(style, options) {
|
|
|
113
119
|
if (val instanceof _stylexInclude.IncludedStyles) {
|
|
114
120
|
resolvedNamespace[key] = val;
|
|
115
121
|
} else if (val != null && typeof val === 'object' && !Array.isArray(val)) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
122
|
+
if (key.startsWith(':') || key.startsWith('@')) {
|
|
123
|
+
const pseudo = key;
|
|
124
|
+
const innerObj = {};
|
|
125
|
+
for (const [innerKey, innerVal] of (0, _objectUtils.objEntries)(val)) {
|
|
126
|
+
if (innerVal === null) {
|
|
127
|
+
innerObj[innerKey] = null;
|
|
128
|
+
} else {
|
|
129
|
+
const [updatedKey, className, cssRule] = (0, _convertToClassName.default)([innerKey, innerVal], pseudo, options);
|
|
130
|
+
innerObj[updatedKey] = className;
|
|
131
|
+
injectedStyles[updatedKey + pseudo] = [className, cssRule];
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
resolvedNamespace[key] = innerObj;
|
|
135
|
+
} else {
|
|
136
|
+
const propKey = key;
|
|
137
|
+
const classNames = [];
|
|
138
|
+
for (const [pseudo, innerVal] of (0, _objectUtils.objEntries)(val)) {
|
|
139
|
+
if (pseudo !== 'default' && !pseudo.startsWith(':') && !pseudo.startsWith('@')) {
|
|
140
|
+
throw new Error(messages.INVALID_PSEUDO);
|
|
141
|
+
}
|
|
142
|
+
if (innerVal !== null) {
|
|
143
|
+
const [updatedKey, className, cssRule] = (0, _convertToClassName.default)([propKey, innerVal], pseudo === 'default' ? undefined : pseudo, options);
|
|
144
|
+
injectedStyles[updatedKey + pseudo] = [className, cssRule];
|
|
145
|
+
classNames.push(className);
|
|
146
|
+
}
|
|
125
147
|
}
|
|
148
|
+
resolvedNamespace[key] = classNames.join(' ');
|
|
126
149
|
}
|
|
127
|
-
resolvedNamespace[key] = innerObj;
|
|
128
150
|
} else {
|
|
129
151
|
if (val === null) {
|
|
130
152
|
resolvedNamespace[key] = null;
|
|
@@ -10,22 +10,38 @@ var _dashify = _interopRequireDefault(require("./utils/dashify"));
|
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
11
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
12
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
13
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
13
14
|
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
14
15
|
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
15
16
|
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
|
17
|
+
function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
|
|
18
|
+
function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
|
|
19
|
+
function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
|
|
16
20
|
var _set = /*#__PURE__*/new WeakSet();
|
|
21
|
+
var _mediaWidths = /*#__PURE__*/new WeakMap();
|
|
22
|
+
var _mediaHeights = /*#__PURE__*/new WeakMap();
|
|
17
23
|
class StylexValueBuilder {
|
|
18
24
|
constructor(defaultValue) {
|
|
19
25
|
_classPrivateMethodInitSpec(this, _set);
|
|
26
|
+
_classPrivateFieldInitSpec(this, _mediaWidths, {
|
|
27
|
+
writable: true,
|
|
28
|
+
value: []
|
|
29
|
+
});
|
|
30
|
+
_classPrivateFieldInitSpec(this, _mediaHeights, {
|
|
31
|
+
writable: true,
|
|
32
|
+
value: []
|
|
33
|
+
});
|
|
20
34
|
this.default = defaultValue;
|
|
21
35
|
}
|
|
22
|
-
// @media Queries
|
|
23
|
-
|
|
24
|
-
mediaPrint(value) {
|
|
25
|
-
return _classPrivateMethodGet(this, _set, _set2).call(this, '@media print', value);
|
|
26
|
-
}
|
|
27
36
|
mediaWidth(_ref, value) {
|
|
28
37
|
let [min, max] = _ref;
|
|
38
|
+
if (_classPrivateFieldGet(this, _mediaWidths).some(_ref2 => {
|
|
39
|
+
let [m, M] = _ref2;
|
|
40
|
+
return m <= min && min < M || m < max && max <= M || min <= m && max >= M;
|
|
41
|
+
})) {
|
|
42
|
+
throw new Error(messages.OVERLAPPING_MEDIA_WIDTHS);
|
|
43
|
+
}
|
|
44
|
+
_classPrivateFieldGet(this, _mediaWidths).push([min, max]);
|
|
29
45
|
if (min > 0 && max < Infinity) {
|
|
30
46
|
return _classPrivateMethodGet(this, _set, _set2).call(this, `@media (min-width: ${min}px and max-width: ${max}px)`, value);
|
|
31
47
|
} else if (min === 0) {
|
|
@@ -35,8 +51,15 @@ class StylexValueBuilder {
|
|
|
35
51
|
}
|
|
36
52
|
throw new Error(messages.INVALID_MEDIA_QUERY);
|
|
37
53
|
}
|
|
38
|
-
mediaHeight(
|
|
39
|
-
let [min, max] =
|
|
54
|
+
mediaHeight(_ref3, value) {
|
|
55
|
+
let [min, max] = _ref3;
|
|
56
|
+
if (_classPrivateFieldGet(this, _mediaHeights).some(_ref4 => {
|
|
57
|
+
let [m, M] = _ref4;
|
|
58
|
+
return m <= min && min < M || m < max && max <= M || min <= m && max >= M;
|
|
59
|
+
})) {
|
|
60
|
+
throw new Error(messages.OVERLAPPING_MEDIA_HEIGHTS);
|
|
61
|
+
}
|
|
62
|
+
_classPrivateFieldGet(this, _mediaHeights).push([min, max]);
|
|
40
63
|
if (min > 0 && max < Infinity) {
|
|
41
64
|
return _classPrivateMethodGet(this, _set, _set2).call(this, `@media (min-height: ${min}px and max-height: ${max}px)`, value);
|
|
42
65
|
} else if (min === 0) {
|
|
@@ -46,110 +69,184 @@ class StylexValueBuilder {
|
|
|
46
69
|
}
|
|
47
70
|
throw new Error(messages.INVALID_MEDIA_QUERY);
|
|
48
71
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
72
|
+
|
|
73
|
+
// mediaAspectRatio<TAddedValue>(
|
|
74
|
+
// [min, max]: [number, number],
|
|
75
|
+
// value: TAddedValue
|
|
76
|
+
// ): StylexValueBuilder<TValue | TAddedValue> {
|
|
77
|
+
// if (min > 0 && max < Infinity) {
|
|
78
|
+
// return this.#set(
|
|
79
|
+
// `@media (min-aspect-ratio: ${min} and max-aspect-ratio: $, })`,
|
|
80
|
+
// value
|
|
81
|
+
// );
|
|
82
|
+
// } else if (min === 0) {
|
|
83
|
+
// return this.#set(`@media (max-aspect-ratio: ${max})`, value);
|
|
84
|
+
// } else if (max === Infinity) {
|
|
85
|
+
// return this.#set(`@media (min-aspect-ratio: ${min})`, value);
|
|
86
|
+
// }
|
|
87
|
+
// throw new Error(messages.INVALID_MEDIA_QUERY);
|
|
88
|
+
// }
|
|
89
|
+
|
|
90
|
+
// mediaPortrait<TAddedValue>(
|
|
91
|
+
// value: TAddedValue
|
|
92
|
+
// ): StylexValueBuilder<TValue | TAddedValue> {
|
|
93
|
+
// return this.#set('@media (orientation: portrait)', value);
|
|
94
|
+
// }
|
|
95
|
+
|
|
96
|
+
// mediaLandscape<TAddedValue>(
|
|
97
|
+
// value: TAddedValue
|
|
98
|
+
// ): StylexValueBuilder<TValue | TAddedValue> {
|
|
99
|
+
// return this.#set('@media (orientation: landscape)', value);
|
|
100
|
+
// }
|
|
101
|
+
|
|
102
|
+
// mediaSRGBDisplay<TAddedValue>(
|
|
103
|
+
// value: TAddedValue
|
|
104
|
+
// ): StylexValueBuilder<TValue | TAddedValue> {
|
|
105
|
+
// return this.#set('@media (color-gamut: srgb)', value);
|
|
106
|
+
// }
|
|
107
|
+
|
|
108
|
+
// mediaP3Display<TAddedValue>(
|
|
109
|
+
// value: TAddedValue
|
|
110
|
+
// ): StylexValueBuilder<TValue | TAddedValue> {
|
|
111
|
+
// return this.#set('@media (color-gamut: p3)', value);
|
|
112
|
+
// }
|
|
113
|
+
|
|
114
|
+
// mediaRec2020Display<TAddedValue>(
|
|
115
|
+
// value: TAddedValue
|
|
116
|
+
// ): StylexValueBuilder<TValue | TAddedValue> {
|
|
117
|
+
// return this.#set('@media (color-gamut: rec2020)', value);
|
|
118
|
+
// }
|
|
119
|
+
|
|
120
|
+
// mediaIsFullscreen<TAddedValue>(
|
|
121
|
+
// value: TAddedValue
|
|
122
|
+
// ): StylexValueBuilder<TValue | TAddedValue> {
|
|
123
|
+
// return this.#set('@media (display-mode: fullscreen)', value);
|
|
124
|
+
// }
|
|
78
125
|
|
|
79
126
|
// These are confusing, so skipping them for now
|
|
80
127
|
// mediaIsStandalone
|
|
81
128
|
// mediaIsMinimalUI
|
|
82
129
|
|
|
83
|
-
mediaSDRDisplay(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
130
|
+
// mediaSDRDisplay<TAddedValue>(
|
|
131
|
+
// value: TAddedValue
|
|
132
|
+
// ): StylexValueBuilder<TValue | TAddedValue> {
|
|
133
|
+
// return this.#set('@media (dynamic-range: standard)', value);
|
|
134
|
+
// }
|
|
135
|
+
|
|
136
|
+
// mediaHDRDisplay<TAddedValue>(
|
|
137
|
+
// value: TAddedValue
|
|
138
|
+
// ): StylexValueBuilder<TValue | TAddedValue> {
|
|
139
|
+
// return this.#set('@media (dynamic-range: high)', value);
|
|
140
|
+
// }
|
|
141
|
+
|
|
142
|
+
// mediaSupportsHDRVideo<TAddedValue>(
|
|
143
|
+
// value: TAddedValue
|
|
144
|
+
// ): StylexValueBuilder<TValue | TAddedValue> {
|
|
145
|
+
// return this.#set('@media (video-dynamic-range: high)', value);
|
|
146
|
+
// }
|
|
92
147
|
|
|
93
148
|
//<TAddedValue> mediaHasColor(value: TAddedValue): StylexValueBuilder<TValue | TAddedValue> {
|
|
94
149
|
// return this.#set('@media (color)', value);
|
|
95
150
|
// }
|
|
96
151
|
|
|
97
|
-
primaryInputCanHover(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
152
|
+
// primaryInputCanHover<TAddedValue>(
|
|
153
|
+
// value: TAddedValue
|
|
154
|
+
// ): StylexValueBuilder<TValue | TAddedValue> {
|
|
155
|
+
// return this.#set('@media (hover: hover)', value);
|
|
156
|
+
// }
|
|
157
|
+
// primaryInputCanNotHover<TAddedValue>(
|
|
158
|
+
// value: TAddedValue
|
|
159
|
+
// ): StylexValueBuilder<TValue | TAddedValue> {
|
|
160
|
+
// return this.#set('@media (hover: none)', value);
|
|
161
|
+
// }
|
|
162
|
+
|
|
163
|
+
// someInputCanHover<TAddedValue>(
|
|
164
|
+
// value: TAddedValue
|
|
165
|
+
// ): StylexValueBuilder<TValue | TAddedValue> {
|
|
166
|
+
// return this.#set('@media (any-hover: hover)', value);
|
|
167
|
+
// }
|
|
168
|
+
|
|
169
|
+
// noInputCanHover<TAddedValue>(
|
|
170
|
+
// value: TAddedValue
|
|
171
|
+
// ): StylexValueBuilder<TValue | TAddedValue> {
|
|
172
|
+
// return this.#set('@media (any-hover: none)', value);
|
|
173
|
+
// }
|
|
174
|
+
|
|
175
|
+
// somePointerIsFine<TAddedValue>(
|
|
176
|
+
// value: TAddedValue
|
|
177
|
+
// ): StylexValueBuilder<TValue | TAddedValue> {
|
|
178
|
+
// return this.#set('@media (any-pointer: fine)', value);
|
|
179
|
+
// }
|
|
180
|
+
|
|
181
|
+
// somePointerIsCoarse<TAddedValue>(
|
|
182
|
+
// value: TAddedValue
|
|
183
|
+
// ): StylexValueBuilder<TValue | TAddedValue> {
|
|
184
|
+
// return this.#set('@media (any-pointer: coarse)', value);
|
|
185
|
+
// }
|
|
186
|
+
|
|
187
|
+
// primaryPointerIsFine<TAddedValue>(
|
|
188
|
+
// value: TAddedValue
|
|
189
|
+
// ): StylexValueBuilder<TValue | TAddedValue> {
|
|
190
|
+
// return this.#set('@media (pointer: fine)', value);
|
|
191
|
+
// }
|
|
192
|
+
|
|
193
|
+
// primaryPointerIsCoarse<TAddedValue>(
|
|
194
|
+
// value: TAddedValue
|
|
195
|
+
// ): StylexValueBuilder<TValue | TAddedValue> {
|
|
196
|
+
// return this.#set('@media (pointer: coarse)', value);
|
|
197
|
+
// }
|
|
198
|
+
|
|
199
|
+
// lightMode<TAddedValue>(
|
|
200
|
+
// value: TAddedValue
|
|
201
|
+
// ): StylexValueBuilder<TValue | TAddedValue> {
|
|
202
|
+
// return this.#set('@media (prefers-color-scheme: light)', value);
|
|
203
|
+
// }
|
|
204
|
+
|
|
205
|
+
// darkMode<TAddedValue>(
|
|
206
|
+
// value: TAddedValue
|
|
207
|
+
// ): StylexValueBuilder<TValue | TAddedValue> {
|
|
208
|
+
// return this.#set('@media (prefers-color-scheme: dark)', value);
|
|
209
|
+
// }
|
|
210
|
+
|
|
211
|
+
// userPrefersMoreContrast<TAddedValue>(
|
|
212
|
+
// value: TAddedValue
|
|
213
|
+
// ): StylexValueBuilder<TValue | TAddedValue> {
|
|
214
|
+
// return this.#set('@media (prefers-contrast: more)', value);
|
|
215
|
+
// }
|
|
216
|
+
|
|
217
|
+
// userPrefersLessContrast<TAddedValue>(
|
|
218
|
+
// value: TAddedValue
|
|
219
|
+
// ): StylexValueBuilder<TValue | TAddedValue> {
|
|
220
|
+
// return this.#set('@media (prefers-contrast: less)', value);
|
|
221
|
+
// }
|
|
222
|
+
|
|
223
|
+
// userPrefersReducedMotion<TAddedValue>(
|
|
224
|
+
// value: TAddedValue
|
|
225
|
+
// ): StylexValueBuilder<TValue | TAddedValue> {
|
|
226
|
+
// return this.#set('@media (prefers-reduced-motion)', value);
|
|
227
|
+
// }
|
|
228
|
+
|
|
229
|
+
// noScript<TAddedValue>(
|
|
230
|
+
// value: TAddedValue
|
|
231
|
+
// ): StylexValueBuilder<TValue | TAddedValue> {
|
|
232
|
+
// return this.#set('@media (scripting: none)', value);
|
|
233
|
+
// }
|
|
234
|
+
|
|
235
|
+
// Choosing a catch-all for now for familiarity
|
|
236
|
+
matchMedia(query, value) {
|
|
140
237
|
return _classPrivateMethodGet(this, _set, _set2).call(this, `@media ${query}`, value);
|
|
141
238
|
}
|
|
142
239
|
supports(selector, value) {
|
|
143
|
-
const toSelector =
|
|
144
|
-
let [k, v] =
|
|
240
|
+
const toSelector = _ref5 => {
|
|
241
|
+
let [k, v] = _ref5;
|
|
145
242
|
return `(${(0, _dashify.default)(k)}: ${String(v)})`;
|
|
146
243
|
};
|
|
147
244
|
const query = Object.entries(selector).map(toSelector).join(' and ');
|
|
148
245
|
return _classPrivateMethodGet(this, _set, _set2).call(this, `@supports ${query}`, value);
|
|
149
246
|
}
|
|
150
247
|
supportsNot(selector, value) {
|
|
151
|
-
const toSelector =
|
|
152
|
-
let [k, v] =
|
|
248
|
+
const toSelector = _ref6 => {
|
|
249
|
+
let [k, v] = _ref6;
|
|
153
250
|
return `(not (${(0, _dashify.default)(k)}: ${String(v)}))`;
|
|
154
251
|
};
|
|
155
252
|
const query = Object.entries(selector).map(toSelector).join(' and ');
|
|
@@ -203,12 +300,6 @@ class StylexValueBuilder {
|
|
|
203
300
|
invalid(value) {
|
|
204
301
|
return _classPrivateMethodGet(this, _set, _set2).call(this, ':invalid', value);
|
|
205
302
|
}
|
|
206
|
-
isUNSAFE(selector, value) {
|
|
207
|
-
return _classPrivateMethodGet(this, _set, _set2).call(this, `:is(${selector})`, value);
|
|
208
|
-
}
|
|
209
|
-
notUNSAFE(selector, value) {
|
|
210
|
-
return _classPrivateMethodGet(this, _set, _set2).call(this, `:not(${selector})`, value);
|
|
211
|
-
}
|
|
212
303
|
lang(value) {
|
|
213
304
|
return _classPrivateMethodGet(this, _set, _set2).call(this, ':lang', value);
|
|
214
305
|
}
|
|
@@ -251,9 +342,50 @@ class StylexValueBuilder {
|
|
|
251
342
|
visited(value) {
|
|
252
343
|
return _classPrivateMethodGet(this, _set, _set2).call(this, ':visited', value);
|
|
253
344
|
}
|
|
345
|
+
get not() {
|
|
346
|
+
return {
|
|
347
|
+
hover: value => _classPrivateMethodGet(this, _set, _set2).call(this, ':not(:hover)', value),
|
|
348
|
+
focus: value => _classPrivateMethodGet(this, _set, _set2).call(this, ':not(:focus)', value),
|
|
349
|
+
focusVisible: value => _classPrivateMethodGet(this, _set, _set2).call(this, ':not(:focus-visible)', value),
|
|
350
|
+
focusWithin: value => _classPrivateMethodGet(this, _set, _set2).call(this, ':not(:focus-within)', value),
|
|
351
|
+
active: value => _classPrivateMethodGet(this, _set, _set2).call(this, ':not(:active)', value),
|
|
352
|
+
anyLink: value => _classPrivateMethodGet(this, _set, _set2).call(this, ':not(:any-link)', value),
|
|
353
|
+
autofill: value => _classPrivateMethodGet(this, _set, _set2).call(this, ':not(:autofill)', value),
|
|
354
|
+
checked: value => _classPrivateMethodGet(this, _set, _set2).call(this, ':not(:checked)', value),
|
|
355
|
+
defaultSelection: value => _classPrivateMethodGet(this, _set, _set2).call(this, ':not(:default)', value),
|
|
356
|
+
disabled: value => _classPrivateMethodGet(this, _set, _set2).call(this, ':not(:disabled)', value),
|
|
357
|
+
empty: value => _classPrivateMethodGet(this, _set, _set2).call(this, ':not(:empty)', value),
|
|
358
|
+
enabled: value => _classPrivateMethodGet(this, _set, _set2).call(this, ':not(:enabled)', value),
|
|
359
|
+
fullscreen: value => _classPrivateMethodGet(this, _set, _set2).call(this, ':not(:fullscreen)', value),
|
|
360
|
+
indeterminate: value => _classPrivateMethodGet(this, _set, _set2).call(this, ':not(:indeterminate)', value),
|
|
361
|
+
invalid: value => _classPrivateMethodGet(this, _set, _set2).call(this, ':not(:invalid)', value),
|
|
362
|
+
lang: value => _classPrivateMethodGet(this, _set, _set2).call(this, ':not(:lang)', value),
|
|
363
|
+
dirRTLUNSFAE: value => _classPrivateMethodGet(this, _set, _set2).call(this, ':not(:dir-rtlunsfae)', value),
|
|
364
|
+
link: value => _classPrivateMethodGet(this, _set, _set2).call(this, ':not(:link)', value),
|
|
365
|
+
optional: value => _classPrivateMethodGet(this, _set, _set2).call(this, ':not(:optional)', value),
|
|
366
|
+
pictureInPicture: value => _classPrivateMethodGet(this, _set, _set2).call(this, ':not(:picture-in-picture)', value),
|
|
367
|
+
placeholderShown: value => _classPrivateMethodGet(this, _set, _set2).call(this, ':not(:placeholder-shown)', value),
|
|
368
|
+
paused: value => _classPrivateMethodGet(this, _set, _set2).call(this, ':not(:paused)', value),
|
|
369
|
+
playing: value => _classPrivateMethodGet(this, _set, _set2).call(this, ':not(:playing)', value),
|
|
370
|
+
readOnly: value => _classPrivateMethodGet(this, _set, _set2).call(this, ':not(:read-only)', value),
|
|
371
|
+
readWrite: value => _classPrivateMethodGet(this, _set, _set2).call(this, ':not(:read-write)', value),
|
|
372
|
+
required: value => _classPrivateMethodGet(this, _set, _set2).call(this, ':not(:required)', value),
|
|
373
|
+
target: value => _classPrivateMethodGet(this, _set, _set2).call(this, ':not(:target)', value),
|
|
374
|
+
valid: value => _classPrivateMethodGet(this, _set, _set2).call(this, ':not(:valid)', value),
|
|
375
|
+
visited: value => _classPrivateMethodGet(this, _set, _set2).call(this, ':not(:visited)', value)
|
|
376
|
+
};
|
|
377
|
+
}
|
|
254
378
|
pseudoUNSAFE(selector, value) {
|
|
255
379
|
return _classPrivateMethodGet(this, _set, _set2).call(this, `:${selector}`, value);
|
|
256
380
|
}
|
|
381
|
+
// These can be used to write arbitrary CSS selectors
|
|
382
|
+
// Which is UNSAFE!
|
|
383
|
+
_isUNSAFE(selector, value) {
|
|
384
|
+
return _classPrivateMethodGet(this, _set, _set2).call(this, `:is(${selector})`, value);
|
|
385
|
+
}
|
|
386
|
+
_notUNSAFE(selector, value) {
|
|
387
|
+
return _classPrivateMethodGet(this, _set, _set2).call(this, `:not(${selector})`, value);
|
|
388
|
+
}
|
|
257
389
|
}
|
|
258
390
|
exports.StylexValueBuilder = StylexValueBuilder;
|
|
259
391
|
function _set2(key, value) {
|
package/package.json
CHANGED