@stylexjs/shared 0.2.0-beta.9 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +3 -3
- package/lib/common-types.d.ts +49 -0
- package/lib/common-types.js.flow +64 -0
- package/lib/convert-to-className.d.ts +16 -0
- package/lib/convert-to-className.js +17 -26
- package/lib/convert-to-className.js.flow +23 -0
- package/lib/generate-css-rule.d.ts +17 -0
- package/lib/generate-css-rule.js +6 -17
- package/lib/generate-css-rule.js.flow +17 -0
- package/lib/hash.d.ts +11 -0
- package/lib/hash.js +3 -27
- package/lib/hash.js.flow +10 -0
- package/lib/index.d.ts +42 -85
- package/lib/index.js +21 -29
- package/lib/index.js.flow +57 -3
- package/lib/messages.d.ts +41 -0
- package/lib/messages.js +33 -53
- package/lib/messages.js.flow +44 -0
- package/lib/physical-rtl/generate-ltr.d.ts +11 -0
- package/lib/physical-rtl/generate-ltr.js +18 -46
- package/lib/physical-rtl/generate-ltr.js.flow +12 -0
- package/lib/physical-rtl/generate-rtl.d.ts +13 -0
- package/lib/physical-rtl/generate-rtl.js +18 -50
- package/lib/physical-rtl/generate-rtl.js.flow +12 -0
- package/lib/preprocess-rules/PreRule.d.ts +52 -0
- package/lib/preprocess-rules/PreRule.js +87 -0
- package/lib/preprocess-rules/PreRule.js.flow +64 -0
- package/lib/preprocess-rules/application-order.d.ts +290 -0
- package/lib/preprocess-rules/application-order.js +60 -133
- package/lib/preprocess-rules/application-order.js.flow +241 -0
- package/lib/preprocess-rules/basic-validation.d.ts +13 -0
- package/lib/preprocess-rules/basic-validation.js +83 -0
- package/lib/preprocess-rules/basic-validation.js.flow +13 -0
- package/lib/preprocess-rules/flatten-raw-style-obj.d.ts +25 -0
- package/lib/preprocess-rules/flatten-raw-style-obj.js +120 -0
- package/lib/preprocess-rules/flatten-raw-style-obj.js.flow +27 -0
- package/lib/preprocess-rules/index.d.ts +18 -0
- package/lib/preprocess-rules/index.js +0 -9
- package/lib/preprocess-rules/index.js.flow +19 -0
- package/lib/preprocess-rules/legacy-expand-shorthands.d.ts +200 -0
- package/lib/preprocess-rules/legacy-expand-shorthands.js +90 -123
- package/lib/preprocess-rules/legacy-expand-shorthands.js.flow +179 -0
- package/lib/preprocess-rules/property-specificity.d.ts +89 -0
- package/lib/preprocess-rules/property-specificity.js +46 -74
- package/lib/preprocess-rules/property-specificity.js.flow +98 -0
- package/lib/properties/CSS Animations.json +445 -0
- package/lib/properties/CSS Backgrounds and Borders.json +1085 -0
- package/lib/properties/CSS Basic User Interface.json +365 -0
- package/lib/properties/CSS Box Alignment.json +245 -0
- package/lib/properties/CSS Box Model.json +501 -0
- package/lib/properties/CSS Color.json +100 -0
- package/lib/properties/CSS Columns.json +185 -0
- package/lib/properties/CSS Containment.json +203 -0
- package/lib/properties/CSS Counter Styles.json +56 -0
- package/lib/properties/CSS Display.json +20 -0
- package/lib/properties/CSS Flexible Box Layout.json +167 -0
- package/lib/properties/CSS Fonts.json +684 -0
- package/lib/properties/CSS Fragmentation.json +110 -0
- package/lib/properties/CSS Generated Content.json +38 -0
- package/lib/properties/CSS Grid Layout.json +500 -0
- package/lib/properties/CSS Images.json +91 -0
- package/lib/properties/CSS Inline.json +38 -0
- package/lib/properties/CSS Lists and Counters.json +86 -0
- package/lib/properties/CSS Logical Properties.json +1086 -0
- package/lib/properties/CSS Masking.json +399 -0
- package/lib/properties/CSS Miscellaneous.json +38 -0
- package/lib/properties/CSS Motion Path.json +132 -0
- package/lib/properties/CSS Overflow.json +216 -0
- package/lib/properties/CSS Pages.json +83 -0
- package/lib/properties/CSS Positioning.json +166 -0
- package/lib/properties/CSS Ruby.json +55 -0
- package/lib/properties/CSS Scroll Anchoring.json +19 -0
- package/lib/properties/CSS Scroll Snap.json +604 -0
- package/lib/properties/CSS Scrollbars.json +38 -0
- package/lib/properties/CSS Shapes.json +56 -0
- package/lib/properties/CSS Speech.json +20 -0
- package/lib/properties/CSS Table.json +115 -0
- package/lib/properties/CSS Text Decoration.json +312 -0
- package/lib/properties/CSS Text.json +415 -0
- package/lib/properties/CSS Transforms.json +188 -0
- package/lib/properties/CSS Transitions.json +122 -0
- package/lib/properties/CSS Variables.json +20 -0
- package/lib/properties/CSS View Transitions.json +20 -0
- package/lib/properties/CSS Will Change.json +20 -0
- package/lib/properties/CSS Writing Modes.json +92 -0
- package/lib/properties/Compositing and Blending.json +62 -0
- package/lib/properties/Filter Effects.json +38 -0
- package/lib/properties/MathML.json +56 -0
- package/lib/properties/Microsoft Extensions.json +885 -0
- package/lib/properties/Mozilla Extensions.json +607 -0
- package/lib/properties/Pointer Events.json +20 -0
- package/lib/properties/WebKit Extensions.json +707 -0
- package/lib/properties.json +10122 -0
- package/lib/stylex-create-theme.d.ts +26 -0
- package/lib/stylex-create-theme.js +67 -0
- package/lib/stylex-create-theme.js.flow +19 -0
- package/lib/stylex-create.d.ts +23 -0
- package/lib/stylex-create.js +30 -146
- package/lib/stylex-create.js.flow +30 -0
- package/lib/stylex-define-vars.d.ts +29 -0
- package/lib/stylex-define-vars.js +73 -0
- package/lib/stylex-define-vars.js.flow +26 -0
- package/lib/stylex-first-that-works.d.ts +13 -0
- package/lib/stylex-first-that-works.js +0 -10
- package/lib/stylex-first-that-works.js.flow +12 -0
- package/lib/stylex-include.d.ts +18 -0
- package/lib/stylex-include.js +2 -12
- package/lib/stylex-include.js.flow +20 -0
- package/lib/stylex-keyframes.d.ts +17 -0
- package/lib/stylex-keyframes.js +6 -26
- package/lib/stylex-keyframes.js.flow +20 -0
- package/lib/transform-value.d.ts +22 -0
- package/lib/transform-value.js +9 -23
- package/lib/transform-value.js.flow +25 -0
- package/lib/types/index.d.ts +205 -0
- package/lib/types/index.js +191 -0
- package/lib/types/index.js.flow +241 -0
- package/lib/utils/Rule.d.ts +58 -0
- package/lib/utils/Rule.js +0 -21
- package/lib/utils/Rule.js.flow +64 -0
- package/lib/utils/dashify.d.ts +11 -0
- package/lib/utils/dashify.js +0 -8
- package/lib/utils/dashify.js.flow +10 -0
- package/lib/utils/default-options.d.ts +11 -0
- package/lib/utils/default-options.js +13 -0
- package/lib/utils/default-options.js.flow +25 -0
- package/lib/utils/file-based-identifier.d.ts +15 -0
- package/lib/utils/file-based-identifier.js +14 -0
- package/lib/utils/file-based-identifier.js.flow +14 -0
- package/lib/utils/genCSSRule.d.ts +15 -0
- package/lib/utils/genCSSRule.js +9 -18
- package/lib/utils/genCSSRule.js.flow +15 -0
- package/lib/utils/normalize-value.d.ts +16 -0
- package/lib/utils/normalize-value.js +8 -15
- package/lib/utils/normalize-value.js.flow +16 -0
- package/lib/utils/normalizers/convert-camel-case-transition-props.d.ts +14 -0
- package/lib/utils/normalizers/convert-camel-case-transition-props.js +23 -0
- package/lib/utils/normalizers/convert-camel-case-transition-props.js.flow +13 -0
- package/lib/utils/normalizers/convert-camel-case-values.d.ts +14 -0
- package/lib/utils/normalizers/convert-camel-case-values.js +23 -0
- package/lib/utils/normalizers/convert-camel-case-values.js.flow +13 -0
- package/lib/utils/normalizers/detect-unclosed-fns.d.ts +17 -0
- package/lib/utils/normalizers/detect-unclosed-fns.js +2 -14
- package/lib/utils/normalizers/detect-unclosed-fns.js.flow +16 -0
- package/lib/utils/normalizers/font-size-px-to-rem.d.ts +19 -0
- package/lib/utils/normalizers/font-size-px-to-rem.js +9 -19
- package/lib/utils/normalizers/font-size-px-to-rem.js.flow +18 -0
- package/lib/utils/normalizers/leading-zero.d.ts +17 -0
- package/lib/utils/normalizers/leading-zero.js +0 -12
- package/lib/utils/normalizers/leading-zero.js.flow +16 -0
- package/lib/utils/normalizers/quotes.d.ts +18 -0
- package/lib/utils/normalizers/quotes.js +0 -13
- package/lib/utils/normalizers/quotes.js.flow +17 -0
- package/lib/utils/normalizers/timings.d.ts +18 -0
- package/lib/utils/normalizers/timings.js +0 -14
- package/lib/utils/normalizers/timings.js.flow +17 -0
- package/lib/utils/normalizers/whitespace.d.ts +19 -0
- package/lib/utils/normalizers/whitespace.js +0 -15
- package/lib/utils/normalizers/whitespace.js.flow +18 -0
- package/lib/utils/normalizers/zero-dimensions.d.ts +19 -0
- package/lib/utils/normalizers/zero-dimensions.js +0 -15
- package/lib/utils/normalizers/zero-dimensions.js.flow +18 -0
- package/lib/utils/object-utils.d.ts +66 -0
- package/lib/utils/object-utils.js +21 -13
- package/lib/utils/object-utils.js.flow +77 -0
- package/lib/utils/property-priorities.d.ts +11 -0
- package/lib/utils/property-priorities.js +516 -101
- package/lib/utils/property-priorities.js.flow +10 -0
- package/lib/utils/split-css-value.d.ts +14 -0
- package/lib/utils/split-css-value.js +0 -14
- package/lib/utils/split-css-value.js.flow +15 -0
- package/lib/validate.d.ts +12 -0
- package/lib/validate.js +1 -10
- package/lib/validate.js.flow +12 -0
- package/package.json +4 -5
- package/lib/expand-shorthands.d.ts +0 -5
- package/lib/expand-shorthands.js +0 -330
- package/lib/namespace-transforms/__tests__/preflatten.test.js +0 -120
- package/lib/namespace-transforms/preflatten.js +0 -89
- package/lib/preprocess-rules/expand-shorthands.js +0 -156
- package/lib/preprocess-rules/null-out-longhand.js +0 -310
- package/lib/preprocess-rules/react-native-web.js +0 -142
- package/lib/stylex-defaultValue.js +0 -397
@@ -0,0 +1,241 @@
|
|
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 { Color as ColorType } from './stylex-types-color';
|
11
|
+
|
12
|
+
// We want all in one file?
|
13
|
+
// option 1, create interface an implement it in the class
|
14
|
+
// why? All the types have a single base definition of props
|
15
|
+
// We want on type that defines CSS Types
|
16
|
+
// Option 2: Do a union type and make
|
17
|
+
|
18
|
+
// interface ICSSType {
|
19
|
+
// toString(): string;
|
20
|
+
// }
|
21
|
+
|
22
|
+
type ValueWithDefault<+T> =
|
23
|
+
| T
|
24
|
+
| $ReadOnly<{
|
25
|
+
default: T,
|
26
|
+
[string]: ValueWithDefault<T>,
|
27
|
+
}>;
|
28
|
+
|
29
|
+
type CSSSyntax =
|
30
|
+
| '*'
|
31
|
+
| '<length>'
|
32
|
+
| '<number>'
|
33
|
+
| '<percentage>'
|
34
|
+
| '<length-percentage>'
|
35
|
+
| '<color>'
|
36
|
+
| '<image>'
|
37
|
+
| '<url>'
|
38
|
+
| '<integer>'
|
39
|
+
| '<angle>'
|
40
|
+
| '<time>'
|
41
|
+
| '<resolution>'
|
42
|
+
| '<transform-function>'
|
43
|
+
| '<custom-ident>'
|
44
|
+
| '<transform-list>';
|
45
|
+
|
46
|
+
type CSSSyntaxType = CSSSyntax | $ReadOnlyArray<CSSSyntax>;
|
47
|
+
|
48
|
+
declare export class CSSType {}
|
49
|
+
|
50
|
+
export interface ICSSType<+T: string | number> {
|
51
|
+
+value: ValueWithDefault<T>;
|
52
|
+
+syntax: CSSSyntaxType;
|
53
|
+
}
|
54
|
+
|
55
|
+
type AnguleValue = string;
|
56
|
+
declare export class Angle<+T: AnguleValue>
|
57
|
+
extends CSSType
|
58
|
+
implements ICSSType<T>
|
59
|
+
{
|
60
|
+
+value: ValueWithDefault<T>;
|
61
|
+
+syntax: CSSSyntaxType;
|
62
|
+
static +syntax: CSSSyntaxType;
|
63
|
+
constructor(value: ValueWithDefault<T>): void;
|
64
|
+
static create<T: AnguleValue = AnguleValue>(
|
65
|
+
value: ValueWithDefault<T>,
|
66
|
+
): Angle<T>;
|
67
|
+
}
|
68
|
+
declare export const angle: $FlowFixMe;
|
69
|
+
|
70
|
+
type ColorValue = string;
|
71
|
+
declare export class Color<+T: ColorValue>
|
72
|
+
extends CSSType
|
73
|
+
implements ICSSType<T>
|
74
|
+
{
|
75
|
+
+value: ValueWithDefault<T>;
|
76
|
+
+syntax: CSSSyntaxType;
|
77
|
+
constructor(value: ValueWithDefault<T>): void;
|
78
|
+
static create<T: ColorValue = ColorValue>(
|
79
|
+
value: ValueWithDefault<T>,
|
80
|
+
): Color<T>;
|
81
|
+
}
|
82
|
+
declare export const color: $FlowFixMe;
|
83
|
+
|
84
|
+
type URLValue = string;
|
85
|
+
|
86
|
+
declare export class Url<+T: URLValue> extends CSSType implements ICSSType<T> {
|
87
|
+
+value: ValueWithDefault<T>;
|
88
|
+
+syntax: CSSSyntaxType;
|
89
|
+
constructor(value: ValueWithDefault<T>): void;
|
90
|
+
static create<T: URLValue = URLValue>(value: ValueWithDefault<T>): Url<T>;
|
91
|
+
}
|
92
|
+
declare export const url: $FlowFixMe;
|
93
|
+
|
94
|
+
type ImageValue = string;
|
95
|
+
|
96
|
+
declare export class Image<+T: ImageValue>
|
97
|
+
extends Url<T>
|
98
|
+
implements ICSSType<T>
|
99
|
+
{
|
100
|
+
+value: ValueWithDefault<T>;
|
101
|
+
+syntax: CSSSyntaxType;
|
102
|
+
constructor(value: ValueWithDefault<T>): void;
|
103
|
+
static create<T: ImageValue = ImageValue>(
|
104
|
+
value: ValueWithDefault<T>,
|
105
|
+
): Image<T>;
|
106
|
+
}
|
107
|
+
declare export const image: $FlowFixMe;
|
108
|
+
|
109
|
+
type IntegerValue = number;
|
110
|
+
|
111
|
+
declare export class Integer<+T: IntegerValue>
|
112
|
+
extends CSSType
|
113
|
+
implements ICSSType<T>
|
114
|
+
{
|
115
|
+
+value: ValueWithDefault<T>;
|
116
|
+
+syntax: CSSSyntaxType;
|
117
|
+
constructor(value: ValueWithDefault<T>): void;
|
118
|
+
static create<T: IntegerValue = IntegerValue>(value: T): Integer<T>;
|
119
|
+
}
|
120
|
+
declare export const integer: $FlowFixMe;
|
121
|
+
|
122
|
+
type LengthPercentageValue = string;
|
123
|
+
|
124
|
+
declare export class LengthPercentage<+T: LengthPercentageValue>
|
125
|
+
extends CSSType
|
126
|
+
implements ICSSType<string>
|
127
|
+
{
|
128
|
+
+value: ValueWithDefault<T>;
|
129
|
+
+syntax: CSSSyntaxType;
|
130
|
+
constructor(value: ValueWithDefault<T>): void;
|
131
|
+
static createLength<T: LengthPercentageValue | number>(
|
132
|
+
value: ValueWithDefault<T>,
|
133
|
+
): LengthPercentage<string>;
|
134
|
+
static createPercentage<T: LengthPercentageValue | number>(
|
135
|
+
value: ValueWithDefault<T>,
|
136
|
+
): LengthPercentage<string>;
|
137
|
+
}
|
138
|
+
declare export const lengthPercentage: $FlowFixMe;
|
139
|
+
|
140
|
+
type LengthValue = number | string;
|
141
|
+
|
142
|
+
declare export class Length<+T: LengthValue>
|
143
|
+
extends LengthPercentage<string>
|
144
|
+
implements ICSSType<string>
|
145
|
+
{
|
146
|
+
+value: ValueWithDefault<string>;
|
147
|
+
+syntax: CSSSyntaxType;
|
148
|
+
constructor(value: ValueWithDefault<T>): void;
|
149
|
+
static create<T: LengthValue = LengthValue>(
|
150
|
+
value: ValueWithDefault<T>,
|
151
|
+
): Length<T>;
|
152
|
+
}
|
153
|
+
declare export const length: $FlowFixMe;
|
154
|
+
|
155
|
+
type PercentageValue = string | number;
|
156
|
+
|
157
|
+
declare export class Percentage<+T: PercentageValue>
|
158
|
+
extends LengthPercentage<string>
|
159
|
+
implements ICSSType<string>
|
160
|
+
{
|
161
|
+
+value: ValueWithDefault<string>;
|
162
|
+
+syntax: CSSSyntaxType;
|
163
|
+
constructor(value: ValueWithDefault<T>): void;
|
164
|
+
static create<T: PercentageValue = PercentageValue>(
|
165
|
+
value: ValueWithDefault<T>,
|
166
|
+
): Percentage<T>;
|
167
|
+
}
|
168
|
+
declare export const percentage: $FlowFixMe;
|
169
|
+
|
170
|
+
type NumberValue = number;
|
171
|
+
|
172
|
+
declare export class Num<+T: NumberValue>
|
173
|
+
extends CSSType
|
174
|
+
implements ICSSType<T>
|
175
|
+
{
|
176
|
+
+value: ValueWithDefault<T>;
|
177
|
+
+syntax: CSSSyntaxType;
|
178
|
+
constructor(value: ValueWithDefault<T>): void;
|
179
|
+
static create<T: NumberValue = NumberValue>(
|
180
|
+
value: ValueWithDefault<T>,
|
181
|
+
): Num<T>;
|
182
|
+
}
|
183
|
+
declare export const number: $FlowFixMe;
|
184
|
+
|
185
|
+
type ResolutionValue = string | 0;
|
186
|
+
|
187
|
+
declare export class Resolution<+T: ResolutionValue>
|
188
|
+
extends CSSType
|
189
|
+
implements ICSSType<T>
|
190
|
+
{
|
191
|
+
+value: ValueWithDefault<T>;
|
192
|
+
+syntax: CSSSyntaxType;
|
193
|
+
constructor(value: ValueWithDefault<T>): void;
|
194
|
+
static create<T: ResolutionValue = ResolutionValue>(
|
195
|
+
value: ValueWithDefault<T>,
|
196
|
+
): Resolution<T>;
|
197
|
+
}
|
198
|
+
declare export const resolution: $FlowFixMe;
|
199
|
+
|
200
|
+
type TimeValue = string | 0;
|
201
|
+
|
202
|
+
declare export class Time<+T: TimeValue>
|
203
|
+
extends CSSType
|
204
|
+
implements ICSSType<T>
|
205
|
+
{
|
206
|
+
+value: ValueWithDefault<T>;
|
207
|
+
+syntax: CSSSyntaxType;
|
208
|
+
constructor(value: ValueWithDefault<T>): void;
|
209
|
+
static create<T: TimeValue = TimeValue>(value: ValueWithDefault<T>): Time<T>;
|
210
|
+
}
|
211
|
+
declare export const time: $FlowFixMe;
|
212
|
+
|
213
|
+
type TransformFunctionValue = string;
|
214
|
+
|
215
|
+
declare export class TransformFunction<+T: TransformFunctionValue>
|
216
|
+
extends CSSType
|
217
|
+
implements ICSSType<T>
|
218
|
+
{
|
219
|
+
+value: ValueWithDefault<T>;
|
220
|
+
+syntax: CSSSyntaxType;
|
221
|
+
constructor(value: ValueWithDefault<T>): void;
|
222
|
+
static create<T: TransformFunctionValue = TransformFunctionValue>(
|
223
|
+
value: ValueWithDefault<T>,
|
224
|
+
): TransformFunction<T>;
|
225
|
+
}
|
226
|
+
declare export const transformFunction: $FlowFixMe;
|
227
|
+
|
228
|
+
type TransformListValue = string;
|
229
|
+
|
230
|
+
declare export class TransformList<T: TransformListValue>
|
231
|
+
extends CSSType
|
232
|
+
implements ICSSType<T>
|
233
|
+
{
|
234
|
+
+value: ValueWithDefault<T>;
|
235
|
+
+syntax: CSSSyntaxType;
|
236
|
+
constructor(value: ValueWithDefault<T>): void;
|
237
|
+
static create<T: TransformListValue = TransformListValue>(
|
238
|
+
value: ValueWithDefault<T>,
|
239
|
+
): TransformList<T>;
|
240
|
+
}
|
241
|
+
declare export const transformList: $FlowFixMe;
|
@@ -0,0 +1,58 @@
|
|
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
|
+
*
|
8
|
+
*/
|
9
|
+
|
10
|
+
/**
|
11
|
+
* This could be an interface, but we use a class so that we can
|
12
|
+
* use instanceof to check for it.
|
13
|
+
*/
|
14
|
+
export declare class Rule<V> {}
|
15
|
+
/**
|
16
|
+
* This is a class that represents a raw style rule.
|
17
|
+
*
|
18
|
+
* It exists to track the actual CSS rule that should be compiled
|
19
|
+
* even as we transform the structure of the RawStyles object.
|
20
|
+
*/
|
21
|
+
export declare class RawRule<V> extends Rule<V> {
|
22
|
+
readonly key: string;
|
23
|
+
readonly value: V;
|
24
|
+
readonly psuedos: null | undefined | ReadonlyArray<string>;
|
25
|
+
readonly atRules: null | undefined | ReadonlyArray<string>;
|
26
|
+
constructor(
|
27
|
+
key: string,
|
28
|
+
value: V,
|
29
|
+
psuedos: null | undefined | ReadonlyArray<string>,
|
30
|
+
atRules: null | undefined | ReadonlyArray<string>,
|
31
|
+
);
|
32
|
+
}
|
33
|
+
export declare class RawRuleList<V> extends Rule<V> {
|
34
|
+
readonly rules: ReadonlyArray<Rule<V>>;
|
35
|
+
constructor(rules: ReadonlyArray<Rule<V>>);
|
36
|
+
}
|
37
|
+
export declare class RawRuleRTLTuple<V1, V2> extends Rule<V1 | V2> {
|
38
|
+
readonly rules: [RawRule<V1>, RawRule<V2>];
|
39
|
+
constructor(rule1: RawRule<V1>, rule2: RawRule<V2>);
|
40
|
+
}
|
41
|
+
export declare class CompiledRule<V> extends Rule<V> {
|
42
|
+
readonly key: string;
|
43
|
+
readonly value: V;
|
44
|
+
readonly psuedos: null | undefined | ReadonlyArray<string>;
|
45
|
+
readonly atRules: null | undefined | ReadonlyArray<string>;
|
46
|
+
readonly className: string;
|
47
|
+
constructor(
|
48
|
+
key: string,
|
49
|
+
value: V,
|
50
|
+
psuedos: null | undefined | ReadonlyArray<string>,
|
51
|
+
atRules: null | undefined | ReadonlyArray<string>,
|
52
|
+
className: string,
|
53
|
+
);
|
54
|
+
}
|
55
|
+
export declare class CompiledRuleTuple2<V1, V2> extends Rule<V1 | V2> {
|
56
|
+
readonly rules: [CompiledRule<V1>, CompiledRule<V2>];
|
57
|
+
constructor(rule1: CompiledRule<V1>, rule2: CompiledRule<V2>);
|
58
|
+
}
|
package/lib/utils/Rule.js
CHANGED
@@ -4,28 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.Rule = exports.RawRuleRTLTuple = exports.RawRuleList = exports.RawRule = exports.CompiledRuleTuple2 = exports.CompiledRule = void 0;
|
7
|
-
/**
|
8
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
9
|
-
*
|
10
|
-
* This source code is licensed under the MIT license found in the
|
11
|
-
* LICENSE file in the root directory of this source tree.
|
12
|
-
*
|
13
|
-
*
|
14
|
-
*/
|
15
|
-
|
16
|
-
/**
|
17
|
-
* This could be an interface, but we use a class so that we can
|
18
|
-
* use instanceof to check for it.
|
19
|
-
*/
|
20
|
-
// eslint-disable-next-line no-unused-vars
|
21
7
|
class Rule {}
|
22
|
-
|
23
|
-
/**
|
24
|
-
* This is a class that represents a raw style rule.
|
25
|
-
*
|
26
|
-
* It exists to track the actual CSS rule that should be compiled
|
27
|
-
* even as we transform the structure of the RawStyles object.
|
28
|
-
*/
|
29
8
|
exports.Rule = Rule;
|
30
9
|
class RawRule extends Rule {
|
31
10
|
constructor(key, value, psuedos, atRules) {
|
@@ -0,0 +1,64 @@
|
|
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
|
+
/**
|
11
|
+
* This could be an interface, but we use a class so that we can
|
12
|
+
* use instanceof to check for it.
|
13
|
+
*/
|
14
|
+
// eslint-disable-next-line no-unused-vars
|
15
|
+
declare export class Rule<+V> {}
|
16
|
+
|
17
|
+
/**
|
18
|
+
* This is a class that represents a raw style rule.
|
19
|
+
*
|
20
|
+
* It exists to track the actual CSS rule that should be compiled
|
21
|
+
* even as we transform the structure of the RawStyles object.
|
22
|
+
*/
|
23
|
+
declare export class RawRule<V> extends Rule<V> {
|
24
|
+
+key: string;
|
25
|
+
+value: V;
|
26
|
+
+psuedos: ?$ReadOnlyArray<string>;
|
27
|
+
+atRules: ?$ReadOnlyArray<string>;
|
28
|
+
constructor(
|
29
|
+
key: string,
|
30
|
+
value: V,
|
31
|
+
psuedos: ?$ReadOnlyArray<string>,
|
32
|
+
atRules: ?$ReadOnlyArray<string>,
|
33
|
+
): void;
|
34
|
+
}
|
35
|
+
|
36
|
+
declare export class RawRuleList<V> extends Rule<V> {
|
37
|
+
+rules: $ReadOnlyArray<Rule<V>>;
|
38
|
+
constructor(rules: $ReadOnlyArray<Rule<V>>): void;
|
39
|
+
}
|
40
|
+
|
41
|
+
declare export class RawRuleRTLTuple<V1, V2> extends Rule<V1 | V2> {
|
42
|
+
+rules: [RawRule<V1>, RawRule<V2>];
|
43
|
+
constructor(rule1: RawRule<V1>, rule2: RawRule<V2>): void;
|
44
|
+
}
|
45
|
+
|
46
|
+
declare export class CompiledRule<V> extends Rule<V> {
|
47
|
+
+key: string;
|
48
|
+
+value: V;
|
49
|
+
+psuedos: ?$ReadOnlyArray<string>;
|
50
|
+
+atRules: ?$ReadOnlyArray<string>;
|
51
|
+
+className: string;
|
52
|
+
constructor(
|
53
|
+
key: string,
|
54
|
+
value: V,
|
55
|
+
psuedos: ?$ReadOnlyArray<string>,
|
56
|
+
atRules: ?$ReadOnlyArray<string>,
|
57
|
+
className: string,
|
58
|
+
): void;
|
59
|
+
}
|
60
|
+
|
61
|
+
declare export class CompiledRuleTuple2<V1, V2> extends Rule<V1 | V2> {
|
62
|
+
+rules: [CompiledRule<V1>, CompiledRule<V2>];
|
63
|
+
constructor(rule1: CompiledRule<V1>, rule2: CompiledRule<V2>): void;
|
64
|
+
}
|
@@ -0,0 +1,11 @@
|
|
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
|
+
*
|
8
|
+
*/
|
9
|
+
|
10
|
+
declare function dashify(str: string): string;
|
11
|
+
export default dashify;
|
package/lib/utils/dashify.js
CHANGED
@@ -4,14 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = dashify;
|
7
|
-
/**
|
8
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
9
|
-
*
|
10
|
-
* This source code is licensed under the MIT license found in the
|
11
|
-
* LICENSE file in the root directory of this source tree.
|
12
|
-
*
|
13
|
-
*/
|
14
|
-
|
15
7
|
function dashify(str) {
|
16
8
|
return str.replace(/(^|[a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
17
9
|
}
|
@@ -0,0 +1,10 @@
|
|
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
|
+
declare export default function dashify(str: string): string;
|
@@ -0,0 +1,11 @@
|
|
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
|
+
*
|
8
|
+
*/
|
9
|
+
|
10
|
+
import type { StyleXOptions } from '../common-types';
|
11
|
+
export declare const defaultOptions: StyleXOptions;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.defaultOptions = void 0;
|
7
|
+
const defaultOptions = exports.defaultOptions = {
|
8
|
+
dev: false,
|
9
|
+
useRemForFontSize: true,
|
10
|
+
test: false,
|
11
|
+
classNamePrefix: 'x',
|
12
|
+
styleResolution: 'application-order'
|
13
|
+
};
|
@@ -0,0 +1,25 @@
|
|
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 { StyleXOptions } from '../common-types';
|
11
|
+
|
12
|
+
// {
|
13
|
+
// ...options,
|
14
|
+
// dev: !!(options as any).dev,
|
15
|
+
// test: !!(options as any).test,
|
16
|
+
// stylexSheetName: (options as any).stylexSheetName ?? undefined,
|
17
|
+
// classNamePrefix: (options as any).classNamePrefix ?? 'x',
|
18
|
+
// importSources: (options as any).importSources ?? [name, 'stylex'],
|
19
|
+
// definedStylexCSSVariables:
|
20
|
+
// (options as any).definedStylexCSSVariables ?? {},
|
21
|
+
// genConditionalClasses: !!(options as any).genConditionalClasses,
|
22
|
+
// skipShorthandExpansion: !!(options as any).skipShorthandExpansion,
|
23
|
+
// } as StyleXOptions;
|
24
|
+
|
25
|
+
declare export const defaultOptions: StyleXOptions;
|
@@ -0,0 +1,15 @@
|
|
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
|
+
*
|
8
|
+
*/
|
9
|
+
|
10
|
+
declare function genFileBasedIdentifier($$PARAM_0$$: {
|
11
|
+
readonly fileName: string;
|
12
|
+
readonly exportName: string;
|
13
|
+
readonly key?: string;
|
14
|
+
}): string;
|
15
|
+
export default genFileBasedIdentifier;
|
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = genFileBasedIdentifier;
|
7
|
+
function genFileBasedIdentifier(_ref) {
|
8
|
+
let {
|
9
|
+
fileName,
|
10
|
+
exportName,
|
11
|
+
key
|
12
|
+
} = _ref;
|
13
|
+
return `${fileName}//${exportName}${key != null ? `.${key}` : ''}`;
|
14
|
+
}
|
@@ -0,0 +1,14 @@
|
|
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
|
+
declare export default function genFileBasedIdentifier({
|
11
|
+
+fileName: string,
|
12
|
+
+exportName: string,
|
13
|
+
+key?: string,
|
14
|
+
}): string;
|
@@ -0,0 +1,15 @@
|
|
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
|
+
*
|
8
|
+
*/
|
9
|
+
|
10
|
+
export declare function genCSSRule(
|
11
|
+
className: string,
|
12
|
+
decls: string,
|
13
|
+
pseudos: ReadonlyArray<string>,
|
14
|
+
atRules: ReadonlyArray<string>,
|
15
|
+
): string;
|
package/lib/utils/genCSSRule.js
CHANGED
@@ -1,24 +1,15 @@
|
|
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
|
-
*
|
8
|
-
*
|
9
|
-
*/
|
10
|
-
|
11
1
|
'use strict';
|
12
2
|
|
13
3
|
Object.defineProperty(exports, "__esModule", {
|
14
4
|
value: true
|
15
5
|
});
|
16
|
-
exports.
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
6
|
+
exports.genCSSRule = genCSSRule;
|
7
|
+
const THUMB_VARIANTS = ['::-webkit-slider-thumb', '::-moz-range-thumb', '::-ms-thumb'];
|
8
|
+
function genCSSRule(className, decls, pseudos, atRules) {
|
9
|
+
const pseudo = pseudos.filter(p => p !== '::thumb').join('');
|
10
|
+
let selectorForAtRules = `.${className}` + atRules.map(() => `.${className}`).join('') + pseudo;
|
11
|
+
if (pseudos.includes('::thumb')) {
|
12
|
+
selectorForAtRules = THUMB_VARIANTS.map(suffix => selectorForAtRules + suffix).join(', ');
|
21
13
|
}
|
22
|
-
return
|
23
|
-
}
|
24
|
-
const THUMB_VARIANTS = ['::-webkit-slider-thumb', '::-moz-range-thumb', '::-ms-thumb'];
|
14
|
+
return atRules.reduce((acc, atRule) => `${atRule}{${acc}}`, `${selectorForAtRules}{${decls}}`);
|
15
|
+
}
|
@@ -0,0 +1,15 @@
|
|
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
|
+
declare export function genCSSRule(
|
11
|
+
className: string,
|
12
|
+
decls: string,
|
13
|
+
pseudos: $ReadOnlyArray<string>,
|
14
|
+
atRules: $ReadOnlyArray<string>,
|
15
|
+
): string;
|
@@ -0,0 +1,16 @@
|
|
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
|
+
*
|
8
|
+
*/
|
9
|
+
|
10
|
+
import type { StyleXOptions } from '../common-types';
|
11
|
+
declare function normalizeValue(
|
12
|
+
value: string,
|
13
|
+
key: string,
|
14
|
+
$$PARAM_2$$: StyleXOptions,
|
15
|
+
): string;
|
16
|
+
export default normalizeValue;
|
@@ -1,13 +1,3 @@
|
|
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
|
-
*
|
8
|
-
*
|
9
|
-
*/
|
10
|
-
|
11
1
|
'use strict';
|
12
2
|
|
13
3
|
Object.defineProperty(exports, "__esModule", {
|
@@ -22,14 +12,17 @@ var _whitespace = _interopRequireDefault(require("./normalizers/whitespace"));
|
|
22
12
|
var _zeroDimensions = _interopRequireDefault(require("./normalizers/zero-dimensions"));
|
23
13
|
var _detectUnclosedFns = _interopRequireDefault(require("./normalizers/detect-unclosed-fns"));
|
24
14
|
var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
|
15
|
+
var _convertCamelCaseValues = _interopRequireDefault(require("./normalizers/convert-camel-case-values"));
|
25
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
17
|
+
const normalizers = [_detectUnclosedFns.default, _whitespace.default, _timings.default, _zeroDimensions.default, _leadingZero.default, _quotes.default, _convertCamelCaseValues.default];
|
18
|
+
function normalizeValue(value, key, _ref) {
|
19
|
+
let {
|
20
|
+
useRemForFontSize
|
21
|
+
} = _ref;
|
30
22
|
if (value == null) {
|
31
23
|
return value;
|
32
24
|
}
|
33
25
|
const parsedAST = (0, _postcssValueParser.default)(value);
|
34
|
-
|
26
|
+
const relevantNormalizers = useRemForFontSize ? [...normalizers, _fontSizePxToRem.default] : normalizers;
|
27
|
+
return relevantNormalizers.reduce((ast, fn) => fn(ast, key), parsedAST).toString();
|
35
28
|
}
|
@@ -0,0 +1,16 @@
|
|
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 { StyleXOptions } from '../common-types';
|
11
|
+
|
12
|
+
declare export default function normalizeValue(
|
13
|
+
value: string,
|
14
|
+
key: string,
|
15
|
+
StyleXOptions,
|
16
|
+
): string;
|