@stylexjs/shared 0.11.1 → 0.17.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/lib/index.d.ts +10 -36
- package/lib/index.js +8 -25
- package/lib/index.js.flow +10 -43
- package/lib/utils/property-priorities.d.ts +4 -0
- package/lib/utils/property-priorities.js +54 -8
- package/lib/utils/property-priorities.js.flow +8 -0
- package/package.json +9 -22
- package/README.md +0 -81
- package/lib/common-types.d.ts +0 -47
- package/lib/common-types.js +0 -1
- package/lib/common-types.js.flow +0 -60
- package/lib/convert-to-className.d.ts +0 -20
- package/lib/convert-to-className.js +0 -66
- package/lib/convert-to-className.js.flow +0 -27
- package/lib/generate-css-rule.d.ts +0 -17
- package/lib/generate-css-rule.js +0 -25
- package/lib/generate-css-rule.js.flow +0 -17
- package/lib/hash.d.ts +0 -11
- package/lib/hash.js +0 -37
- package/lib/hash.js.flow +0 -10
- package/lib/messages.d.ts +0 -41
- package/lib/messages.js +0 -38
- package/lib/messages.js.flow +0 -44
- package/lib/physical-rtl/generate-ltr.d.ts +0 -13
- package/lib/physical-rtl/generate-ltr.js +0 -103
- package/lib/physical-rtl/generate-ltr.js.flow +0 -12
- package/lib/physical-rtl/generate-rtl.d.ts +0 -13
- package/lib/physical-rtl/generate-rtl.js +0 -177
- package/lib/physical-rtl/generate-rtl.js.flow +0 -12
- package/lib/preprocess-rules/PreRule.d.ts +0 -50
- package/lib/preprocess-rules/PreRule.js +0 -76
- package/lib/preprocess-rules/PreRule.js.flow +0 -62
- package/lib/preprocess-rules/application-order.d.ts +0 -183
- package/lib/preprocess-rules/application-order.js +0 -186
- package/lib/preprocess-rules/application-order.js.flow +0 -134
- package/lib/preprocess-rules/basic-validation.d.ts +0 -13
- package/lib/preprocess-rules/basic-validation.js +0 -73
- package/lib/preprocess-rules/basic-validation.js.flow +0 -13
- package/lib/preprocess-rules/flatten-raw-style-obj.d.ts +0 -20
- package/lib/preprocess-rules/flatten-raw-style-obj.js +0 -98
- package/lib/preprocess-rules/flatten-raw-style-obj.js.flow +0 -23
- package/lib/preprocess-rules/index.d.ts +0 -18
- package/lib/preprocess-rules/index.js +0 -33
- package/lib/preprocess-rules/index.js.flow +0 -22
- package/lib/preprocess-rules/legacy-expand-shorthands.d.ts +0 -165
- package/lib/preprocess-rules/legacy-expand-shorthands.js +0 -147
- package/lib/preprocess-rules/legacy-expand-shorthands.js.flow +0 -144
- package/lib/preprocess-rules/property-specificity.d.ts +0 -78
- package/lib/preprocess-rules/property-specificity.js +0 -107
- package/lib/preprocess-rules/property-specificity.js.flow +0 -87
- package/lib/stylex-create-theme.d.ts +0 -26
- package/lib/stylex-create-theme.js +0 -58
- package/lib/stylex-create-theme.js.flow +0 -19
- package/lib/stylex-create.d.ts +0 -27
- package/lib/stylex-create.js +0 -57
- package/lib/stylex-create.js.flow +0 -38
- package/lib/stylex-define-vars.d.ts +0 -28
- package/lib/stylex-define-vars.js +0 -94
- package/lib/stylex-define-vars.js.flow +0 -27
- package/lib/stylex-first-that-works.d.ts +0 -13
- package/lib/stylex-first-that-works.js +0 -26
- package/lib/stylex-first-that-works.js.flow +0 -12
- package/lib/stylex-include.d.ts +0 -18
- package/lib/stylex-include.js +0 -28
- package/lib/stylex-include.js.flow +0 -20
- package/lib/stylex-keyframes.d.ts +0 -17
- package/lib/stylex-keyframes.js +0 -55
- package/lib/stylex-keyframes.js.flow +0 -20
- package/lib/stylex-vars-utils.d.ts +0 -27
- package/lib/stylex-vars-utils.js +0 -69
- package/lib/stylex-vars-utils.js.flow +0 -31
- package/lib/transform-value.d.ts +0 -22
- package/lib/transform-value.js +0 -50
- package/lib/transform-value.js.flow +0 -25
- package/lib/types/index.d.ts +0 -240
- package/lib/types/index.js +0 -147
- package/lib/types/index.js.flow +0 -280
- package/lib/utils/Rule.d.ts +0 -58
- package/lib/utils/Rule.js +0 -50
- package/lib/utils/Rule.js.flow +0 -64
- package/lib/utils/dashify.d.ts +0 -11
- package/lib/utils/dashify.js +0 -9
- package/lib/utils/dashify.js.flow +0 -10
- package/lib/utils/default-options.d.ts +0 -11
- package/lib/utils/default-options.js +0 -15
- package/lib/utils/default-options.js.flow +0 -12
- package/lib/utils/file-based-identifier.d.ts +0 -15
- package/lib/utils/file-based-identifier.js +0 -14
- package/lib/utils/file-based-identifier.js.flow +0 -14
- package/lib/utils/genCSSRule.d.ts +0 -15
- package/lib/utils/genCSSRule.js +0 -15
- package/lib/utils/genCSSRule.js.flow +0 -15
- package/lib/utils/normalize-value.d.ts +0 -16
- package/lib/utils/normalize-value.js +0 -28
- package/lib/utils/normalize-value.js.flow +0 -16
- package/lib/utils/normalizers/convert-camel-case-values.d.ts +0 -14
- package/lib/utils/normalizers/convert-camel-case-values.js +0 -23
- package/lib/utils/normalizers/convert-camel-case-values.js.flow +0 -13
- package/lib/utils/normalizers/detect-unclosed-fns.d.ts +0 -17
- package/lib/utils/normalizers/detect-unclosed-fns.js +0 -17
- package/lib/utils/normalizers/detect-unclosed-fns.js.flow +0 -16
- package/lib/utils/normalizers/font-size-px-to-rem.d.ts +0 -19
- package/lib/utils/normalizers/font-size-px-to-rem.js +0 -24
- package/lib/utils/normalizers/font-size-px-to-rem.js.flow +0 -18
- package/lib/utils/normalizers/leading-zero.d.ts +0 -17
- package/lib/utils/normalizers/leading-zero.js +0 -24
- package/lib/utils/normalizers/leading-zero.js.flow +0 -16
- package/lib/utils/normalizers/quotes.d.ts +0 -18
- package/lib/utils/normalizers/quotes.js +0 -17
- package/lib/utils/normalizers/quotes.js.flow +0 -17
- package/lib/utils/normalizers/timings.d.ts +0 -18
- package/lib/utils/normalizers/timings.js +0 -25
- package/lib/utils/normalizers/timings.js.flow +0 -17
- package/lib/utils/normalizers/whitespace.d.ts +0 -19
- package/lib/utils/normalizers/whitespace.js +0 -54
- package/lib/utils/normalizers/whitespace.js.flow +0 -18
- package/lib/utils/normalizers/zero-dimensions.d.ts +0 -19
- package/lib/utils/normalizers/zero-dimensions.js +0 -42
- package/lib/utils/normalizers/zero-dimensions.js.flow +0 -18
- package/lib/utils/object-utils.d.ts +0 -66
- package/lib/utils/object-utils.js +0 -99
- package/lib/utils/object-utils.js.flow +0 -78
- package/lib/utils/rule-utils.d.ts +0 -15
- package/lib/utils/rule-utils.js +0 -41
- package/lib/utils/rule-utils.js.flow +0 -16
- package/lib/utils/split-css-value.d.ts +0 -14
- package/lib/utils/split-css-value.js +0 -33
- package/lib/utils/split-css-value.js.flow +0 -15
- package/lib/validate.d.ts +0 -12
- package/lib/validate.js +0 -21
- package/lib/validate.js.flow +0 -12
package/lib/types/index.d.ts
DELETED
|
@@ -1,240 +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
|
-
*
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
type NestedWithNumbers =
|
|
11
|
-
| number
|
|
12
|
-
| string
|
|
13
|
-
| Readonly<{
|
|
14
|
-
default: NestedWithNumbers;
|
|
15
|
-
[$$Key$$: string]: NestedWithNumbers;
|
|
16
|
-
}>;
|
|
17
|
-
type ValueWithDefault =
|
|
18
|
-
| string
|
|
19
|
-
| Readonly<{
|
|
20
|
-
default: ValueWithDefault;
|
|
21
|
-
[$$Key$$: string]: ValueWithDefault;
|
|
22
|
-
}>;
|
|
23
|
-
type CSSSyntax =
|
|
24
|
-
| '*'
|
|
25
|
-
| '<length>'
|
|
26
|
-
| '<number>'
|
|
27
|
-
| '<percentage>'
|
|
28
|
-
| '<length-percentage>'
|
|
29
|
-
| '<color>'
|
|
30
|
-
| '<image>'
|
|
31
|
-
| '<url>'
|
|
32
|
-
| '<integer>'
|
|
33
|
-
| '<angle>'
|
|
34
|
-
| '<time>'
|
|
35
|
-
| '<resolution>'
|
|
36
|
-
| '<transform-function>'
|
|
37
|
-
| '<custom-ident>'
|
|
38
|
-
| '<transform-list>';
|
|
39
|
-
type CSSSyntaxType = CSSSyntax;
|
|
40
|
-
declare class BaseCSSType {
|
|
41
|
-
readonly value: ValueWithDefault;
|
|
42
|
-
readonly syntax: CSSSyntaxType;
|
|
43
|
-
constructor(value: ValueWithDefault);
|
|
44
|
-
}
|
|
45
|
-
export interface CSSType<_T extends string | number = string | number> {
|
|
46
|
-
readonly value: ValueWithDefault;
|
|
47
|
-
readonly syntax: CSSSyntaxType;
|
|
48
|
-
}
|
|
49
|
-
export declare const isCSSType: (
|
|
50
|
-
value: unknown,
|
|
51
|
-
) => value is CSSType<string | number>;
|
|
52
|
-
type AngleValue = string;
|
|
53
|
-
export declare class Angle<T extends AngleValue>
|
|
54
|
-
extends BaseCSSType
|
|
55
|
-
implements CSSType<T>
|
|
56
|
-
{
|
|
57
|
-
readonly value: ValueWithDefault;
|
|
58
|
-
readonly syntax: CSSSyntaxType;
|
|
59
|
-
static readonly syntax: CSSSyntaxType;
|
|
60
|
-
static create<T extends AngleValue = AngleValue>(
|
|
61
|
-
value: ValueWithDefault,
|
|
62
|
-
): Angle<T>;
|
|
63
|
-
}
|
|
64
|
-
export declare const angle: <T extends AngleValue = AngleValue>(
|
|
65
|
-
value: ValueWithDefault,
|
|
66
|
-
) => Angle<T>;
|
|
67
|
-
type ColorValue = string;
|
|
68
|
-
export declare class Color<T extends ColorValue>
|
|
69
|
-
extends BaseCSSType
|
|
70
|
-
implements CSSType<T>
|
|
71
|
-
{
|
|
72
|
-
readonly value: ValueWithDefault;
|
|
73
|
-
readonly syntax: CSSSyntaxType;
|
|
74
|
-
static create<T extends ColorValue = ColorValue>(
|
|
75
|
-
value: ValueWithDefault,
|
|
76
|
-
): Color<T>;
|
|
77
|
-
}
|
|
78
|
-
export declare const color: <T extends ColorValue = ColorValue>(
|
|
79
|
-
value: ValueWithDefault,
|
|
80
|
-
) => Color<T>;
|
|
81
|
-
type URLValue = string;
|
|
82
|
-
export declare class Url<T extends URLValue>
|
|
83
|
-
extends BaseCSSType
|
|
84
|
-
implements CSSType<T>
|
|
85
|
-
{
|
|
86
|
-
readonly value: ValueWithDefault;
|
|
87
|
-
readonly syntax: CSSSyntaxType;
|
|
88
|
-
static create<T extends URLValue = URLValue>(value: ValueWithDefault): Url<T>;
|
|
89
|
-
}
|
|
90
|
-
export declare const url: <T extends URLValue = URLValue>(
|
|
91
|
-
value: ValueWithDefault,
|
|
92
|
-
) => Url<T>;
|
|
93
|
-
type ImageValue = string;
|
|
94
|
-
export declare class Image<T extends ImageValue>
|
|
95
|
-
extends Url<T>
|
|
96
|
-
implements CSSType<T>
|
|
97
|
-
{
|
|
98
|
-
readonly value: ValueWithDefault;
|
|
99
|
-
readonly syntax: CSSSyntaxType;
|
|
100
|
-
constructor(value: ValueWithDefault);
|
|
101
|
-
static create<T extends ImageValue = ImageValue>(
|
|
102
|
-
value: ValueWithDefault,
|
|
103
|
-
): Image<T>;
|
|
104
|
-
}
|
|
105
|
-
export declare const image: <T extends ImageValue = ImageValue>(
|
|
106
|
-
value: ValueWithDefault,
|
|
107
|
-
) => Image<T>;
|
|
108
|
-
type IntegerValue = number;
|
|
109
|
-
export declare class Integer<T extends IntegerValue>
|
|
110
|
-
extends BaseCSSType
|
|
111
|
-
implements CSSType<T>
|
|
112
|
-
{
|
|
113
|
-
readonly value: ValueWithDefault;
|
|
114
|
-
readonly syntax: CSSSyntaxType;
|
|
115
|
-
static create<T extends IntegerValue = IntegerValue>(value: T): Integer<T>;
|
|
116
|
-
}
|
|
117
|
-
export declare const integer: <T extends IntegerValue = IntegerValue>(
|
|
118
|
-
value: T,
|
|
119
|
-
) => Integer<T>;
|
|
120
|
-
type LengthPercentageValue = string;
|
|
121
|
-
export declare class LengthPercentage<_T extends LengthPercentageValue>
|
|
122
|
-
extends BaseCSSType
|
|
123
|
-
implements CSSType<string>
|
|
124
|
-
{
|
|
125
|
-
readonly value: ValueWithDefault;
|
|
126
|
-
readonly syntax: CSSSyntaxType;
|
|
127
|
-
static createLength<_T extends LengthPercentageValue | number>(
|
|
128
|
-
value: ValueWithDefault,
|
|
129
|
-
): LengthPercentage<string>;
|
|
130
|
-
static createPercentage<_T extends LengthPercentageValue | number>(
|
|
131
|
-
value: ValueWithDefault,
|
|
132
|
-
): LengthPercentage<string>;
|
|
133
|
-
}
|
|
134
|
-
export declare const lengthPercentage: <
|
|
135
|
-
_T extends LengthPercentageValue | number,
|
|
136
|
-
>(
|
|
137
|
-
value: ValueWithDefault,
|
|
138
|
-
) => LengthPercentage<string>;
|
|
139
|
-
type LengthValue = number | string;
|
|
140
|
-
export declare class Length<_T extends LengthValue>
|
|
141
|
-
extends LengthPercentage<string>
|
|
142
|
-
implements CSSType<string>
|
|
143
|
-
{
|
|
144
|
-
readonly value: ValueWithDefault;
|
|
145
|
-
readonly syntax: CSSSyntaxType;
|
|
146
|
-
static create<T extends LengthValue = LengthValue>(
|
|
147
|
-
value: NestedWithNumbers,
|
|
148
|
-
): Length<T>;
|
|
149
|
-
}
|
|
150
|
-
export declare const length: <T extends LengthValue = LengthValue>(
|
|
151
|
-
value: NestedWithNumbers,
|
|
152
|
-
) => Length<T>;
|
|
153
|
-
type PercentageValue = string | number;
|
|
154
|
-
export declare class Percentage<_T extends PercentageValue>
|
|
155
|
-
extends LengthPercentage<string>
|
|
156
|
-
implements CSSType<string>
|
|
157
|
-
{
|
|
158
|
-
readonly value: ValueWithDefault;
|
|
159
|
-
readonly syntax: CSSSyntaxType;
|
|
160
|
-
static create<T extends PercentageValue = PercentageValue>(
|
|
161
|
-
value: NestedWithNumbers,
|
|
162
|
-
): Percentage<T>;
|
|
163
|
-
}
|
|
164
|
-
export declare const percentage: <T extends PercentageValue = PercentageValue>(
|
|
165
|
-
value: NestedWithNumbers,
|
|
166
|
-
) => Percentage<T>;
|
|
167
|
-
type NumberValue = number;
|
|
168
|
-
export declare class Num<T extends NumberValue>
|
|
169
|
-
extends BaseCSSType
|
|
170
|
-
implements CSSType<T>
|
|
171
|
-
{
|
|
172
|
-
readonly value: ValueWithDefault;
|
|
173
|
-
readonly syntax: CSSSyntaxType;
|
|
174
|
-
static create<T extends NumberValue = NumberValue>(
|
|
175
|
-
value: NestedWithNumbers,
|
|
176
|
-
): Num<T>;
|
|
177
|
-
}
|
|
178
|
-
export declare const number: <T extends NumberValue = NumberValue>(
|
|
179
|
-
value: NestedWithNumbers,
|
|
180
|
-
) => Num<T>;
|
|
181
|
-
type ResolutionValue = string | 0;
|
|
182
|
-
export declare class Resolution<T extends ResolutionValue>
|
|
183
|
-
extends BaseCSSType
|
|
184
|
-
implements CSSType<T>
|
|
185
|
-
{
|
|
186
|
-
readonly value: ValueWithDefault;
|
|
187
|
-
readonly syntax: CSSSyntaxType;
|
|
188
|
-
static create<T extends ResolutionValue = ResolutionValue>(
|
|
189
|
-
value: ValueWithDefault,
|
|
190
|
-
): Resolution<T>;
|
|
191
|
-
}
|
|
192
|
-
export declare const resolution: <T extends ResolutionValue = ResolutionValue>(
|
|
193
|
-
value: ValueWithDefault,
|
|
194
|
-
) => Resolution<T>;
|
|
195
|
-
type TimeValue = string | 0;
|
|
196
|
-
export declare class Time<T extends TimeValue>
|
|
197
|
-
extends BaseCSSType
|
|
198
|
-
implements CSSType<T>
|
|
199
|
-
{
|
|
200
|
-
readonly value: ValueWithDefault;
|
|
201
|
-
readonly syntax: CSSSyntaxType;
|
|
202
|
-
static create<T extends TimeValue = TimeValue>(
|
|
203
|
-
value: ValueWithDefault,
|
|
204
|
-
): Time<T>;
|
|
205
|
-
}
|
|
206
|
-
export declare const time: <T extends TimeValue = TimeValue>(
|
|
207
|
-
value: ValueWithDefault,
|
|
208
|
-
) => Time<T>;
|
|
209
|
-
type TransformFunctionValue = string;
|
|
210
|
-
export declare class TransformFunction<T extends TransformFunctionValue>
|
|
211
|
-
extends BaseCSSType
|
|
212
|
-
implements CSSType<T>
|
|
213
|
-
{
|
|
214
|
-
readonly value: ValueWithDefault;
|
|
215
|
-
readonly syntax: CSSSyntaxType;
|
|
216
|
-
static create<T extends TransformFunctionValue = TransformFunctionValue>(
|
|
217
|
-
value: ValueWithDefault,
|
|
218
|
-
): TransformFunction<T>;
|
|
219
|
-
}
|
|
220
|
-
export declare const transformFunction: <
|
|
221
|
-
T extends TransformFunctionValue = TransformFunctionValue,
|
|
222
|
-
>(
|
|
223
|
-
value: ValueWithDefault,
|
|
224
|
-
) => TransformFunction<T>;
|
|
225
|
-
type TransformListValue = string;
|
|
226
|
-
export declare class TransformList<T extends TransformListValue>
|
|
227
|
-
extends BaseCSSType
|
|
228
|
-
implements CSSType<T>
|
|
229
|
-
{
|
|
230
|
-
readonly value: ValueWithDefault;
|
|
231
|
-
readonly syntax: CSSSyntaxType;
|
|
232
|
-
static create<T extends TransformListValue = TransformListValue>(
|
|
233
|
-
value: ValueWithDefault,
|
|
234
|
-
): TransformList<T>;
|
|
235
|
-
}
|
|
236
|
-
export declare const transformList: <
|
|
237
|
-
T extends TransformListValue = TransformListValue,
|
|
238
|
-
>(
|
|
239
|
-
value: ValueWithDefault,
|
|
240
|
-
) => TransformList<T>;
|
package/lib/types/index.js
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.url = exports.transformList = exports.transformFunction = exports.time = exports.resolution = exports.percentage = exports.number = exports.lengthPercentage = exports.length = exports.isCSSType = exports.integer = exports.image = exports.color = exports.angle = exports.Url = exports.TransformList = exports.TransformFunction = exports.Time = exports.Resolution = exports.Percentage = exports.Num = exports.LengthPercentage = exports.Length = exports.Integer = exports.Image = exports.Color = exports.Angle = void 0;
|
|
7
|
-
class BaseCSSType {
|
|
8
|
-
constructor(value) {
|
|
9
|
-
this.value = value;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
const isCSSType = value => {
|
|
13
|
-
return value instanceof BaseCSSType && value.value != null && typeof value.syntax === 'string';
|
|
14
|
-
};
|
|
15
|
-
exports.isCSSType = isCSSType;
|
|
16
|
-
class Angle extends BaseCSSType {
|
|
17
|
-
syntax = '<angle>';
|
|
18
|
-
static syntax = '<angle>';
|
|
19
|
-
static create(value) {
|
|
20
|
-
return new Angle(value);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.Angle = Angle;
|
|
24
|
-
const angle = exports.angle = Angle.create;
|
|
25
|
-
class Color extends BaseCSSType {
|
|
26
|
-
syntax = '<color>';
|
|
27
|
-
static create(value) {
|
|
28
|
-
return new Color(value);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.Color = Color;
|
|
32
|
-
const color = exports.color = Color.create;
|
|
33
|
-
class Url extends BaseCSSType {
|
|
34
|
-
syntax = '<url>';
|
|
35
|
-
static create(value) {
|
|
36
|
-
return new Url(value);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
exports.Url = Url;
|
|
40
|
-
const url = exports.url = Url.create;
|
|
41
|
-
class Image extends Url {
|
|
42
|
-
syntax = '<image>';
|
|
43
|
-
constructor(value) {
|
|
44
|
-
super(value);
|
|
45
|
-
this.value = value;
|
|
46
|
-
}
|
|
47
|
-
static create(value) {
|
|
48
|
-
return new Image(value);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
exports.Image = Image;
|
|
52
|
-
const image = exports.image = Image.create;
|
|
53
|
-
class Integer extends BaseCSSType {
|
|
54
|
-
syntax = '<integer>';
|
|
55
|
-
static create(value) {
|
|
56
|
-
return new Integer(convertNumberToStringUsing(String, '0')(value));
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
exports.Integer = Integer;
|
|
60
|
-
const integer = exports.integer = Integer.create;
|
|
61
|
-
class LengthPercentage extends BaseCSSType {
|
|
62
|
-
syntax = '<length-percentage>';
|
|
63
|
-
static createLength(value) {
|
|
64
|
-
return new LengthPercentage(convertNumberToLength(value));
|
|
65
|
-
}
|
|
66
|
-
static createPercentage(value) {
|
|
67
|
-
return new LengthPercentage(convertNumberToPercentage(value));
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
exports.LengthPercentage = LengthPercentage;
|
|
71
|
-
const lengthPercentage = exports.lengthPercentage = LengthPercentage.createLength;
|
|
72
|
-
class Length extends LengthPercentage {
|
|
73
|
-
syntax = '<length>';
|
|
74
|
-
static create(value) {
|
|
75
|
-
return new Length(convertNumberToLength(value));
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
exports.Length = Length;
|
|
79
|
-
const length = exports.length = Length.create;
|
|
80
|
-
class Percentage extends LengthPercentage {
|
|
81
|
-
syntax = '<percentage>';
|
|
82
|
-
static create(value) {
|
|
83
|
-
return new Percentage(convertNumberToPercentage(value));
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
exports.Percentage = Percentage;
|
|
87
|
-
const percentage = exports.percentage = Percentage.create;
|
|
88
|
-
class Num extends BaseCSSType {
|
|
89
|
-
syntax = '<number>';
|
|
90
|
-
static create(value) {
|
|
91
|
-
return new Num(convertNumberToBareString(value));
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
exports.Num = Num;
|
|
95
|
-
const number = exports.number = Num.create;
|
|
96
|
-
class Resolution extends BaseCSSType {
|
|
97
|
-
syntax = '<resolution>';
|
|
98
|
-
static create(value) {
|
|
99
|
-
return new Resolution(value);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
exports.Resolution = Resolution;
|
|
103
|
-
const resolution = exports.resolution = Resolution.create;
|
|
104
|
-
class Time extends BaseCSSType {
|
|
105
|
-
syntax = '<time>';
|
|
106
|
-
static create(value) {
|
|
107
|
-
return new Time(value);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
exports.Time = Time;
|
|
111
|
-
const time = exports.time = Time.create;
|
|
112
|
-
class TransformFunction extends BaseCSSType {
|
|
113
|
-
syntax = '<transform-function>';
|
|
114
|
-
static create(value) {
|
|
115
|
-
return new TransformFunction(value);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
exports.TransformFunction = TransformFunction;
|
|
119
|
-
const transformFunction = exports.transformFunction = TransformFunction.create;
|
|
120
|
-
class TransformList extends BaseCSSType {
|
|
121
|
-
syntax = '<transform-list>';
|
|
122
|
-
static create(value) {
|
|
123
|
-
return new TransformList(value);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
exports.TransformList = TransformList;
|
|
127
|
-
const transformList = exports.transformList = TransformList.create;
|
|
128
|
-
const convertNumberToStringUsing = (transformNumber, defaultStr) => value => {
|
|
129
|
-
if (typeof value === 'number') {
|
|
130
|
-
return transformNumber(value);
|
|
131
|
-
}
|
|
132
|
-
if (typeof value === 'string') {
|
|
133
|
-
return value;
|
|
134
|
-
}
|
|
135
|
-
if (typeof value === 'object') {
|
|
136
|
-
const val = value;
|
|
137
|
-
const result = {};
|
|
138
|
-
for (const key of Object.keys(val)) {
|
|
139
|
-
result[key] = convertNumberToStringUsing(transformNumber, defaultStr)(val[key]);
|
|
140
|
-
}
|
|
141
|
-
return result;
|
|
142
|
-
}
|
|
143
|
-
return value;
|
|
144
|
-
};
|
|
145
|
-
const convertNumberToBareString = convertNumberToStringUsing(value => String(value), '0');
|
|
146
|
-
const convertNumberToLength = convertNumberToStringUsing(value => value === 0 ? '0' : `${value}px`, '0px');
|
|
147
|
-
const convertNumberToPercentage = convertNumberToStringUsing(value => value === 0 ? '0' : `${value * 100}%`, '0');
|
package/lib/types/index.js.flow
DELETED
|
@@ -1,280 +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 { 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 CSSType {
|
|
19
|
-
// toString(): string;
|
|
20
|
-
// }
|
|
21
|
-
|
|
22
|
-
type NestedWithNumbers =
|
|
23
|
-
| number
|
|
24
|
-
| string
|
|
25
|
-
| $ReadOnly<{
|
|
26
|
-
default: NestedWithNumbers,
|
|
27
|
-
[string]: NestedWithNumbers,
|
|
28
|
-
}>;
|
|
29
|
-
|
|
30
|
-
type ValueWithDefault =
|
|
31
|
-
| string
|
|
32
|
-
| $ReadOnly<{
|
|
33
|
-
default: ValueWithDefault,
|
|
34
|
-
[string]: ValueWithDefault,
|
|
35
|
-
}>;
|
|
36
|
-
|
|
37
|
-
type CSSSyntax =
|
|
38
|
-
| '*'
|
|
39
|
-
| '<length>'
|
|
40
|
-
| '<number>'
|
|
41
|
-
| '<percentage>'
|
|
42
|
-
| '<length-percentage>'
|
|
43
|
-
| '<color>'
|
|
44
|
-
| '<image>'
|
|
45
|
-
| '<url>'
|
|
46
|
-
| '<integer>'
|
|
47
|
-
| '<angle>'
|
|
48
|
-
| '<time>'
|
|
49
|
-
| '<resolution>'
|
|
50
|
-
| '<transform-function>'
|
|
51
|
-
| '<custom-ident>'
|
|
52
|
-
| '<transform-list>';
|
|
53
|
-
|
|
54
|
-
type CSSSyntaxType = CSSSyntax;
|
|
55
|
-
|
|
56
|
-
declare class BaseCSSType {
|
|
57
|
-
+value: ValueWithDefault;
|
|
58
|
-
+syntax: CSSSyntaxType;
|
|
59
|
-
constructor(value: ValueWithDefault): void;
|
|
60
|
-
}
|
|
61
|
-
export interface CSSType<+_T: string | number = string | number> {
|
|
62
|
-
+value: ValueWithDefault;
|
|
63
|
-
+syntax: CSSSyntaxType;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
declare export const isCSSType: (
|
|
67
|
-
value: mixed,
|
|
68
|
-
) => implies value is CSSType<string | number>;
|
|
69
|
-
|
|
70
|
-
type AngleValue = string;
|
|
71
|
-
declare export class Angle<+T: AngleValue>
|
|
72
|
-
extends BaseCSSType
|
|
73
|
-
implements CSSType<T>
|
|
74
|
-
{
|
|
75
|
-
+value: ValueWithDefault;
|
|
76
|
-
+syntax: CSSSyntaxType;
|
|
77
|
-
static +syntax: CSSSyntaxType;
|
|
78
|
-
static create<T: AngleValue = AngleValue>(value: ValueWithDefault): Angle<T>;
|
|
79
|
-
}
|
|
80
|
-
declare export const angle: <T: AngleValue = AngleValue>(
|
|
81
|
-
value: ValueWithDefault,
|
|
82
|
-
// $FlowIgnore[method-unbinding]
|
|
83
|
-
) => Angle<T>;
|
|
84
|
-
|
|
85
|
-
type ColorValue = string;
|
|
86
|
-
declare export class Color<+T: ColorValue>
|
|
87
|
-
extends BaseCSSType
|
|
88
|
-
implements CSSType<T>
|
|
89
|
-
{
|
|
90
|
-
+value: ValueWithDefault;
|
|
91
|
-
+syntax: CSSSyntaxType;
|
|
92
|
-
static create<T: ColorValue = ColorValue>(value: ValueWithDefault): Color<T>;
|
|
93
|
-
}
|
|
94
|
-
declare export const color: <T: ColorValue = ColorValue>(
|
|
95
|
-
value: ValueWithDefault,
|
|
96
|
-
// $FlowIgnore[method-unbinding]
|
|
97
|
-
) => Color<T>;
|
|
98
|
-
|
|
99
|
-
type URLValue = string;
|
|
100
|
-
|
|
101
|
-
declare export class Url<+T: URLValue>
|
|
102
|
-
extends BaseCSSType
|
|
103
|
-
implements CSSType<T>
|
|
104
|
-
{
|
|
105
|
-
+value: ValueWithDefault;
|
|
106
|
-
+syntax: CSSSyntaxType;
|
|
107
|
-
static create<T: URLValue = URLValue>(value: ValueWithDefault): Url<T>;
|
|
108
|
-
}
|
|
109
|
-
declare export const url: <T: URLValue = URLValue>(
|
|
110
|
-
value: ValueWithDefault,
|
|
111
|
-
) => Url<T>;
|
|
112
|
-
|
|
113
|
-
type ImageValue = string;
|
|
114
|
-
|
|
115
|
-
declare export class Image<+T: ImageValue>
|
|
116
|
-
extends Url<T>
|
|
117
|
-
implements CSSType<T>
|
|
118
|
-
{
|
|
119
|
-
+value: ValueWithDefault;
|
|
120
|
-
+syntax: CSSSyntaxType;
|
|
121
|
-
constructor(value: ValueWithDefault): void;
|
|
122
|
-
static create<T: ImageValue = ImageValue>(value: ValueWithDefault): Image<T>;
|
|
123
|
-
}
|
|
124
|
-
declare export const image: <T: ImageValue = ImageValue>(
|
|
125
|
-
value: ValueWithDefault,
|
|
126
|
-
// $FlowIgnore[method-unbinding]
|
|
127
|
-
) => Image<T>;
|
|
128
|
-
|
|
129
|
-
type IntegerValue = number;
|
|
130
|
-
|
|
131
|
-
declare export class Integer<+T: IntegerValue>
|
|
132
|
-
extends BaseCSSType
|
|
133
|
-
implements CSSType<T>
|
|
134
|
-
{
|
|
135
|
-
+value: ValueWithDefault;
|
|
136
|
-
+syntax: CSSSyntaxType;
|
|
137
|
-
static create<T: IntegerValue = IntegerValue>(value: T): Integer<T>;
|
|
138
|
-
}
|
|
139
|
-
declare export const integer: <T: IntegerValue = IntegerValue>(
|
|
140
|
-
value: T,
|
|
141
|
-
) => Integer<T>;
|
|
142
|
-
|
|
143
|
-
type LengthPercentageValue = string;
|
|
144
|
-
|
|
145
|
-
declare export class LengthPercentage<+_T: LengthPercentageValue>
|
|
146
|
-
extends BaseCSSType
|
|
147
|
-
implements CSSType<string>
|
|
148
|
-
{
|
|
149
|
-
+value: ValueWithDefault;
|
|
150
|
-
+syntax: CSSSyntaxType;
|
|
151
|
-
static createLength<_T: LengthPercentageValue | number>(
|
|
152
|
-
value: ValueWithDefault,
|
|
153
|
-
): LengthPercentage<string>;
|
|
154
|
-
static createPercentage<_T: LengthPercentageValue | number>(
|
|
155
|
-
value: ValueWithDefault,
|
|
156
|
-
): LengthPercentage<string>;
|
|
157
|
-
}
|
|
158
|
-
declare export const lengthPercentage: <_T: LengthPercentageValue | number>(
|
|
159
|
-
value: ValueWithDefault,
|
|
160
|
-
// $FlowIgnore[method-unbinding]
|
|
161
|
-
) => LengthPercentage<string>;
|
|
162
|
-
|
|
163
|
-
type LengthValue = number | string;
|
|
164
|
-
|
|
165
|
-
declare export class Length<+_T: LengthValue>
|
|
166
|
-
extends LengthPercentage<string>
|
|
167
|
-
implements CSSType<string>
|
|
168
|
-
{
|
|
169
|
-
+value: ValueWithDefault;
|
|
170
|
-
+syntax: CSSSyntaxType;
|
|
171
|
-
static create<T: LengthValue = LengthValue>(
|
|
172
|
-
value: NestedWithNumbers,
|
|
173
|
-
): Length<T>;
|
|
174
|
-
}
|
|
175
|
-
declare export const length: <T: LengthValue = LengthValue>(
|
|
176
|
-
value: NestedWithNumbers,
|
|
177
|
-
// $FlowIgnore[method-unbinding]
|
|
178
|
-
) => Length<T>;
|
|
179
|
-
|
|
180
|
-
type PercentageValue = string | number;
|
|
181
|
-
|
|
182
|
-
declare export class Percentage<+_T: PercentageValue>
|
|
183
|
-
extends LengthPercentage<string>
|
|
184
|
-
implements CSSType<string>
|
|
185
|
-
{
|
|
186
|
-
+value: ValueWithDefault;
|
|
187
|
-
+syntax: CSSSyntaxType;
|
|
188
|
-
static create<T: PercentageValue = PercentageValue>(
|
|
189
|
-
value: NestedWithNumbers,
|
|
190
|
-
): Percentage<T>;
|
|
191
|
-
}
|
|
192
|
-
declare export const percentage: <T: PercentageValue = PercentageValue>(
|
|
193
|
-
value: NestedWithNumbers,
|
|
194
|
-
// $FlowIgnore[method-unbinding]
|
|
195
|
-
) => Percentage<T>;
|
|
196
|
-
|
|
197
|
-
type NumberValue = number;
|
|
198
|
-
|
|
199
|
-
declare export class Num<+T: NumberValue>
|
|
200
|
-
extends BaseCSSType
|
|
201
|
-
implements CSSType<T>
|
|
202
|
-
{
|
|
203
|
-
+value: ValueWithDefault;
|
|
204
|
-
+syntax: CSSSyntaxType;
|
|
205
|
-
static create<T: NumberValue = NumberValue>(value: NestedWithNumbers): Num<T>;
|
|
206
|
-
}
|
|
207
|
-
declare export const number: <T: NumberValue = NumberValue>(
|
|
208
|
-
value: NestedWithNumbers,
|
|
209
|
-
// $FlowIgnore[method-unbinding]
|
|
210
|
-
) => Num<T>;
|
|
211
|
-
|
|
212
|
-
type ResolutionValue = string | 0;
|
|
213
|
-
|
|
214
|
-
declare export class Resolution<+T: ResolutionValue>
|
|
215
|
-
extends BaseCSSType
|
|
216
|
-
implements CSSType<T>
|
|
217
|
-
{
|
|
218
|
-
+value: ValueWithDefault;
|
|
219
|
-
+syntax: CSSSyntaxType;
|
|
220
|
-
static create<T: ResolutionValue = ResolutionValue>(
|
|
221
|
-
value: ValueWithDefault,
|
|
222
|
-
): Resolution<T>;
|
|
223
|
-
}
|
|
224
|
-
declare export const resolution: <T: ResolutionValue = ResolutionValue>(
|
|
225
|
-
value: ValueWithDefault,
|
|
226
|
-
// $FlowIgnore[method-unbinding]
|
|
227
|
-
) => Resolution<T>;
|
|
228
|
-
|
|
229
|
-
type TimeValue = string | 0;
|
|
230
|
-
|
|
231
|
-
declare export class Time<+T: TimeValue>
|
|
232
|
-
extends BaseCSSType
|
|
233
|
-
implements CSSType<T>
|
|
234
|
-
{
|
|
235
|
-
+value: ValueWithDefault;
|
|
236
|
-
+syntax: CSSSyntaxType;
|
|
237
|
-
static create<T: TimeValue = TimeValue>(value: ValueWithDefault): Time<T>;
|
|
238
|
-
}
|
|
239
|
-
declare export const time: <T: TimeValue = TimeValue>(
|
|
240
|
-
value: ValueWithDefault,
|
|
241
|
-
// $FlowIgnore[method-unbinding]
|
|
242
|
-
) => Time<T>;
|
|
243
|
-
|
|
244
|
-
type TransformFunctionValue = string;
|
|
245
|
-
|
|
246
|
-
declare export class TransformFunction<+T: TransformFunctionValue>
|
|
247
|
-
extends BaseCSSType
|
|
248
|
-
implements CSSType<T>
|
|
249
|
-
{
|
|
250
|
-
+value: ValueWithDefault;
|
|
251
|
-
+syntax: CSSSyntaxType;
|
|
252
|
-
static create<T: TransformFunctionValue = TransformFunctionValue>(
|
|
253
|
-
value: ValueWithDefault,
|
|
254
|
-
): TransformFunction<T>;
|
|
255
|
-
}
|
|
256
|
-
declare export const transformFunction: <
|
|
257
|
-
T: TransformFunctionValue = TransformFunctionValue,
|
|
258
|
-
>(
|
|
259
|
-
value: ValueWithDefault,
|
|
260
|
-
// $FlowIgnore[method-unbinding]
|
|
261
|
-
) => TransformFunction<T>;
|
|
262
|
-
|
|
263
|
-
type TransformListValue = string;
|
|
264
|
-
|
|
265
|
-
declare export class TransformList<T: TransformListValue>
|
|
266
|
-
extends BaseCSSType
|
|
267
|
-
implements CSSType<T>
|
|
268
|
-
{
|
|
269
|
-
+value: ValueWithDefault;
|
|
270
|
-
+syntax: CSSSyntaxType;
|
|
271
|
-
static create<T: TransformListValue = TransformListValue>(
|
|
272
|
-
value: ValueWithDefault,
|
|
273
|
-
): TransformList<T>;
|
|
274
|
-
}
|
|
275
|
-
declare export const transformList: <
|
|
276
|
-
T: TransformListValue = TransformListValue,
|
|
277
|
-
>(
|
|
278
|
-
value: ValueWithDefault,
|
|
279
|
-
// $FlowIgnore[method-unbinding]
|
|
280
|
-
) => TransformList<T>;
|