@stylexjs/stylex 0.2.0-beta.18 → 0.2.0-beta.20
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/StyleXTypes.d.ts +54 -11
- package/lib/StyleXTypes.js.flow +5 -1
- package/lib/native/CSSLengthUnitValue.d.ts +1 -1
- package/lib/native/CSSLengthUnitValue.js +1 -1
- package/lib/native/CSSLengthUnitValue.js.flow +1 -1
- package/lib/native/__tests__/__snapshots__/stylex-test.js.snap +559 -51
- package/lib/native/__tests__/stylex-test.js +317 -32
- package/lib/native/fixContentBox.d.ts +11 -0
- package/lib/native/fixContentBox.js +55 -0
- package/lib/native/fixContentBox.js.flow +11 -0
- package/lib/native/stylex.js +144 -50
- package/lib/stylex.d.ts +54 -1
- package/lib/stylex.js +48 -4
- package/lib/stylex.js.flow +52 -2
- package/package.json +3 -3
package/lib/StyleXTypes.d.ts
CHANGED
|
@@ -21,6 +21,42 @@ export type StyleXClassName = StyleXClassNameFor<unknown, unknown>;
|
|
|
21
21
|
// Type for arbitrarily nested Array.
|
|
22
22
|
export type StyleXArray<T> = T | ReadonlyArray<StyleXArray<T>>;
|
|
23
23
|
|
|
24
|
+
type lowerCaseAlphabet =
|
|
25
|
+
| 'a'
|
|
26
|
+
| 'b'
|
|
27
|
+
| 'c'
|
|
28
|
+
| 'd'
|
|
29
|
+
| 'e'
|
|
30
|
+
| 'f'
|
|
31
|
+
| 'g'
|
|
32
|
+
| 'h'
|
|
33
|
+
| 'i'
|
|
34
|
+
| 'j'
|
|
35
|
+
| 'k'
|
|
36
|
+
| 'l'
|
|
37
|
+
| 'm'
|
|
38
|
+
| 'n'
|
|
39
|
+
| 'o'
|
|
40
|
+
| 'p'
|
|
41
|
+
| 'q'
|
|
42
|
+
| 'r'
|
|
43
|
+
| 's'
|
|
44
|
+
| 't'
|
|
45
|
+
| 'u'
|
|
46
|
+
| 'v'
|
|
47
|
+
| 'w'
|
|
48
|
+
| 'x'
|
|
49
|
+
| 'y'
|
|
50
|
+
| 'z'
|
|
51
|
+
| '-'
|
|
52
|
+
| '_'
|
|
53
|
+
| '@'
|
|
54
|
+
| ':';
|
|
55
|
+
|
|
56
|
+
// Strings that don't start with a dollar sign.
|
|
57
|
+
// So that we can `&` with {$$css: true} without type errors.
|
|
58
|
+
type NonDollarStr = `${lowerCaseAlphabet}${string}`;
|
|
59
|
+
|
|
24
60
|
type CSSPropTypes = {
|
|
25
61
|
[Key in keyof CSSProperties]: StyleXClassNameFor<Key, CSSProperties[Key]>;
|
|
26
62
|
};
|
|
@@ -70,18 +106,23 @@ export type StyleXSingleStyle = false | (null | undefined | NestedCSSPropTypes);
|
|
|
70
106
|
export type XStyle<T = NestedCSSPropTypes> = StyleXArray<
|
|
71
107
|
false | (null | undefined | T)
|
|
72
108
|
>;
|
|
73
|
-
export type XStyleWithout<T extends { [$$Key$$:
|
|
109
|
+
export type XStyleWithout<T extends { [$$Key$$: NonDollarStr]: void }> = XStyle<
|
|
74
110
|
Readonly<Pick<NestedCSSPropTypes, Exclude<keyof NestedCSSPropTypes, keyof T>>>
|
|
75
111
|
>;
|
|
76
112
|
|
|
77
|
-
export type Keyframes = Readonly<{ [name:
|
|
78
|
-
export type LegacyTheme = Readonly<{ [constantName:
|
|
113
|
+
export type Keyframes = Readonly<{ [name: NonDollarStr]: CSSProperties }>;
|
|
114
|
+
export type LegacyTheme = Readonly<{ [constantName: NonDollarStr]: string }>;
|
|
79
115
|
|
|
80
116
|
type RawStyles = {
|
|
81
|
-
[key:
|
|
117
|
+
[key: NonDollarStr]:
|
|
118
|
+
| null
|
|
119
|
+
| string
|
|
120
|
+
| number
|
|
121
|
+
| Array<string | number>
|
|
122
|
+
| RawStyles;
|
|
82
123
|
};
|
|
83
124
|
|
|
84
|
-
type CompiledNamespace<N extends RawStyles> = {
|
|
125
|
+
type CompiledNamespace<const N extends RawStyles> = {
|
|
85
126
|
[K in keyof N]: N[K] extends string | number | null
|
|
86
127
|
? StyleXClassNameFor<K, N[K]>
|
|
87
128
|
: N[K] extends ReadonlyArray<infer T>
|
|
@@ -95,23 +136,25 @@ type CompiledNamespace<N extends RawStyles> = {
|
|
|
95
136
|
: never;
|
|
96
137
|
};
|
|
97
138
|
|
|
98
|
-
export type Stylex$Create = <const S extends { [n:
|
|
139
|
+
export type Stylex$Create = <const S extends { [n: NonDollarStr]: RawStyles }>(
|
|
99
140
|
styles: S,
|
|
100
141
|
) => Readonly<{
|
|
101
|
-
[N in keyof S]: CompiledNamespace<S[N]
|
|
142
|
+
[N in keyof S]: CompiledNamespace<S[N]> & { $$css: true };
|
|
102
143
|
}>;
|
|
103
144
|
|
|
104
145
|
export type CompiledStyles = Readonly<{
|
|
105
|
-
[key:
|
|
106
|
-
|
|
146
|
+
[key: NonDollarStr]:
|
|
147
|
+
| StyleXClassName
|
|
148
|
+
| Readonly<{ [key: NonDollarStr]: StyleXClassName }>;
|
|
149
|
+
}> & { $$css: true };
|
|
107
150
|
|
|
108
151
|
type TTokens = {
|
|
109
|
-
[key:
|
|
152
|
+
[key: NonDollarStr]: string | { default: string; [key: string]: string };
|
|
110
153
|
};
|
|
111
154
|
|
|
112
155
|
export type FlattenTokens<
|
|
113
156
|
T extends {
|
|
114
|
-
[key:
|
|
157
|
+
[key: NonDollarStr]: string | { default: string; [key: string]: string };
|
|
115
158
|
},
|
|
116
159
|
> = {
|
|
117
160
|
[Key in keyof T]: T[Key] extends { default: infer X } & {
|
package/lib/StyleXTypes.js.flow
CHANGED
|
@@ -107,7 +107,11 @@ export type MapNamespace<CSS: { ... }> = $ReadOnly<{
|
|
|
107
107
|
// Rule,
|
|
108
108
|
// ) => $ObjMap<Rule, MapCSSValueToClassName>) &
|
|
109
109
|
// MapCSSValueToClassName;
|
|
110
|
-
|
|
110
|
+
|
|
111
|
+
export type MapNamespaces = (<CSS: { ... }>(CSS) => MapNamespace<CSS>) &
|
|
112
|
+
(<Args: $ReadOnlyArray<mixed>, CSS: { ... }>(
|
|
113
|
+
fn: (...args: Args) => CSS,
|
|
114
|
+
) => MapNamespace<CSS>);
|
|
111
115
|
|
|
112
116
|
export type Stylex$Create = <S: { ... }>(
|
|
113
117
|
styles: S,
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
type CSSLengthUnitType = 'em' | 'px' | 'rem' | 'vh' | 'vmax' | 'vmin' | 'vw';
|
|
11
11
|
export declare class CSSLengthUnitValue {
|
|
12
|
-
static parse(inp: string):
|
|
12
|
+
static parse(inp: string): [number, CSSLengthUnitType] | null;
|
|
13
13
|
value: number;
|
|
14
14
|
unit: CSSLengthUnitType;
|
|
15
15
|
constructor(value: number, unit: CSSLengthUnitType);
|
|
@@ -11,7 +11,7 @@ type CSSLengthUnitType = 'em' | 'px' | 'rem' | 'vh' | 'vmax' | 'vmin' | 'vw';
|
|
|
11
11
|
|
|
12
12
|
// TODO: this only works on simple values
|
|
13
13
|
declare export class CSSLengthUnitValue {
|
|
14
|
-
static parse(inp: string):
|
|
14
|
+
static parse(inp: string): [number, CSSLengthUnitType] | null;
|
|
15
15
|
value: number;
|
|
16
16
|
unit: CSSLengthUnitType;
|
|
17
17
|
constructor(value: number, unit: CSSLengthUnitType): void;
|