@stylexjs/stylex 0.2.0-beta.9 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +81 -67
- package/lib/StyleXCSSTypes.d.ts +1416 -0
- package/lib/StyleXCSSTypes.js +0 -9
- package/lib/StyleXCSSTypes.js.flow +1505 -0
- package/lib/StyleXSheet.d.ts +49 -0
- package/lib/StyleXSheet.js +22 -121
- package/lib/StyleXSheet.js.flow +49 -0
- package/lib/StyleXTypes.d.ts +218 -0
- package/lib/StyleXTypes.js +0 -9
- package/lib/StyleXTypes.js.flow +187 -0
- package/lib/stylex-inject.d.ts +15 -0
- package/lib/stylex-inject.js +0 -9
- package/lib/stylex-inject.js.flow +14 -0
- package/lib/stylex.d.ts +131 -63
- package/lib/stylex.js +116 -49
- package/lib/stylex.js.flow +147 -0
- package/package.json +11 -7
|
@@ -0,0 +1,147 @@
|
|
|
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 {
|
|
11
|
+
Keyframes,
|
|
12
|
+
Stylex$Create,
|
|
13
|
+
StyleX$DefineVars,
|
|
14
|
+
StyleX$CreateTheme,
|
|
15
|
+
StyleXArray,
|
|
16
|
+
CompiledStyles,
|
|
17
|
+
InlineStyles,
|
|
18
|
+
StyleXClassNameFor,
|
|
19
|
+
} from './StyleXTypes';
|
|
20
|
+
|
|
21
|
+
export type {
|
|
22
|
+
VarGroup,
|
|
23
|
+
Theme,
|
|
24
|
+
StyleXStyles,
|
|
25
|
+
StyleXStylesWithout,
|
|
26
|
+
StaticStyles,
|
|
27
|
+
StaticStylesWithout,
|
|
28
|
+
} from './StyleXTypes';
|
|
29
|
+
|
|
30
|
+
declare export function props(
|
|
31
|
+
this: ?mixed,
|
|
32
|
+
...styles: $ReadOnlyArray<
|
|
33
|
+
StyleXArray<
|
|
34
|
+
?CompiledStyles | boolean | $ReadOnly<[CompiledStyles, InlineStyles]>,
|
|
35
|
+
>,
|
|
36
|
+
>
|
|
37
|
+
): $ReadOnly<{
|
|
38
|
+
className?: string,
|
|
39
|
+
style?: $ReadOnly<{ [string]: string | number }>,
|
|
40
|
+
}>;
|
|
41
|
+
|
|
42
|
+
type Stylex$Include = <
|
|
43
|
+
TStyles: { +[string]: StyleXClassNameFor<string, mixed> },
|
|
44
|
+
>(
|
|
45
|
+
styles: TStyles,
|
|
46
|
+
) => {
|
|
47
|
+
+[Key in keyof TStyles]: TStyles[Key] extends StyleXClassNameFor<
|
|
48
|
+
mixed,
|
|
49
|
+
infer V,
|
|
50
|
+
>
|
|
51
|
+
? V
|
|
52
|
+
: string,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
declare export const create: Stylex$Create;
|
|
56
|
+
|
|
57
|
+
declare export const defineVars: StyleX$DefineVars;
|
|
58
|
+
|
|
59
|
+
declare export const createTheme: StyleX$CreateTheme;
|
|
60
|
+
|
|
61
|
+
declare export const include: Stylex$Include;
|
|
62
|
+
|
|
63
|
+
type ValueWithDefault<+T> =
|
|
64
|
+
| T
|
|
65
|
+
| $ReadOnly<{
|
|
66
|
+
+default: T,
|
|
67
|
+
+[string]: ValueWithDefault<T>,
|
|
68
|
+
}>;
|
|
69
|
+
|
|
70
|
+
type CSSSyntax =
|
|
71
|
+
| '*'
|
|
72
|
+
| '<length>'
|
|
73
|
+
| '<number>'
|
|
74
|
+
| '<percentage>'
|
|
75
|
+
| '<length-percentage>'
|
|
76
|
+
| '<color>'
|
|
77
|
+
| '<image>'
|
|
78
|
+
| '<url>'
|
|
79
|
+
| '<integer>'
|
|
80
|
+
| '<angle>'
|
|
81
|
+
| '<time>'
|
|
82
|
+
| '<resolution>'
|
|
83
|
+
| '<transform-function>'
|
|
84
|
+
| '<custom-ident>'
|
|
85
|
+
| '<transform-list>';
|
|
86
|
+
|
|
87
|
+
type CSSSyntaxType = CSSSyntax | $ReadOnlyArray<CSSSyntax>;
|
|
88
|
+
|
|
89
|
+
interface ICSSType<+T: string | number> {
|
|
90
|
+
+value: ValueWithDefault<T>;
|
|
91
|
+
+syntax: CSSSyntaxType;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
declare export const types: {
|
|
95
|
+
angle: <T: number | string>(_v: ValueWithDefault<T>) => ICSSType<T>,
|
|
96
|
+
color: <T: number | string>(_v: ValueWithDefault<T>) => ICSSType<T>,
|
|
97
|
+
url: <T: number | string>(_v: ValueWithDefault<T>) => ICSSType<T>,
|
|
98
|
+
image: <T: number | string>(_v: ValueWithDefault<T>) => ICSSType<T>,
|
|
99
|
+
integer: <T: number | string>(_v: ValueWithDefault<T>) => ICSSType<T>,
|
|
100
|
+
lengthPercentage: <T: number | string>(
|
|
101
|
+
_v: ValueWithDefault<T>,
|
|
102
|
+
) => ICSSType<T>,
|
|
103
|
+
length: <T: number | string>(_v: ValueWithDefault<T>) => ICSSType<T>,
|
|
104
|
+
percentage: <T: number | string>(_v: ValueWithDefault<T>) => ICSSType<T>,
|
|
105
|
+
number: <T: number | string>(_v: ValueWithDefault<T>) => ICSSType<T>,
|
|
106
|
+
resolution: <T: number | string>(_v: ValueWithDefault<T>) => ICSSType<T>,
|
|
107
|
+
time: <T: number | string>(_v: ValueWithDefault<T>) => ICSSType<T>,
|
|
108
|
+
transformFunction: <T: number | string>(
|
|
109
|
+
_v: ValueWithDefault<T>,
|
|
110
|
+
) => ICSSType<T>,
|
|
111
|
+
transformList: <T: number | string>(_v: ValueWithDefault<T>) => ICSSType<T>,
|
|
112
|
+
};
|
|
113
|
+
declare export const keyframes: (keyframes: Keyframes) => string;
|
|
114
|
+
|
|
115
|
+
declare export const firstThatWorks: <T: string | number>(
|
|
116
|
+
...styles: $ReadOnlyArray<T>
|
|
117
|
+
) => $ReadOnlyArray<T>;
|
|
118
|
+
|
|
119
|
+
type IStyleX = {
|
|
120
|
+
(...styles: $ReadOnlyArray<StyleXArray<?CompiledStyles | boolean>>): string,
|
|
121
|
+
props: (
|
|
122
|
+
this: ?mixed,
|
|
123
|
+
...styles: $ReadOnlyArray<
|
|
124
|
+
StyleXArray<
|
|
125
|
+
?CompiledStyles | boolean | $ReadOnly<[CompiledStyles, InlineStyles]>,
|
|
126
|
+
>,
|
|
127
|
+
>
|
|
128
|
+
) => $ReadOnly<{
|
|
129
|
+
className?: string,
|
|
130
|
+
style?: $ReadOnly<{ [string]: string | number }>,
|
|
131
|
+
}>,
|
|
132
|
+
create: Stylex$Create,
|
|
133
|
+
defineVars: StyleX$DefineVars,
|
|
134
|
+
createTheme: StyleX$CreateTheme,
|
|
135
|
+
include: Stylex$Include,
|
|
136
|
+
types: typeof types,
|
|
137
|
+
firstThatWorks: <T: string | number>(
|
|
138
|
+
...v: $ReadOnlyArray<T>
|
|
139
|
+
) => $ReadOnlyArray<T>,
|
|
140
|
+
keyframes: (keyframes: Keyframes) => string,
|
|
141
|
+
__customProperties?: { [string]: mixed },
|
|
142
|
+
...
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
declare export const stylex: IStyleX;
|
|
147
|
+
declare export default IStyleX;
|
package/package.json
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stylexjs/stylex",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "A
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "A library for defining styles for optimized user interfaces.",
|
|
5
5
|
"main": "lib/stylex.js",
|
|
6
6
|
"types": "lib/stylex.d.ts",
|
|
7
|
-
"repository": "https://www.github.com/
|
|
8
|
-
"author": "Naman Goel <nmn@fb.com>",
|
|
7
|
+
"repository": "https://www.github.com/facebook/stylex",
|
|
9
8
|
"license": "MIT",
|
|
10
9
|
"scripts": {
|
|
10
|
+
"prebuild": "gen-types -i src/ -o lib/",
|
|
11
11
|
"build": "babel src/ --out-dir lib/ --copy-files",
|
|
12
|
-
"build-haste": "
|
|
12
|
+
"build-haste": "rewrite-imports -i src/ -o lib/",
|
|
13
13
|
"test": "jest"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
+
"css-mediaquery": "^0.1.2",
|
|
16
17
|
"invariant": "^2.2.4",
|
|
17
|
-
"
|
|
18
|
-
"
|
|
18
|
+
"styleq": "0.1.3",
|
|
19
|
+
"utility-types": "^3.10.0"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@stylexjs/scripts": "0.4.0"
|
|
19
23
|
},
|
|
20
24
|
"jest": {},
|
|
21
25
|
"files": [
|