@stylexjs/stylex 0.11.1 → 0.13.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 +0 -27
- package/lib/{stylex-inject.d.ts → cjs/inject.d.ts} +1 -5
- package/lib/cjs/inject.js +210 -0
- package/lib/{stylex-inject.js.flow → cjs/inject.js.flow} +2 -3
- package/lib/cjs/stylesheet/createCSSStyleSheet.d.ts +13 -0
- package/lib/cjs/stylesheet/createCSSStyleSheet.js.flow +13 -0
- package/lib/cjs/stylesheet/createOrderedCSSStyleSheet.d.ts +31 -0
- package/lib/cjs/stylesheet/createOrderedCSSStyleSheet.js.flow +32 -0
- package/lib/cjs/stylesheet/createSheet.d.ts +12 -0
- package/lib/cjs/stylesheet/createSheet.js.flow +16 -0
- package/lib/cjs/stylesheet/utils.d.ts +18 -0
- package/lib/cjs/stylesheet/utils.js.flow +19 -0
- package/lib/{stylex.d.ts → cjs/stylex.d.ts} +8 -21
- package/lib/cjs/stylex.js +242 -0
- package/lib/{stylex.js.flow → cjs/stylex.js.flow} +10 -26
- package/lib/{StyleXCSSTypes.d.ts → cjs/types/StyleXCSSTypes.d.ts} +22 -0
- package/lib/{StyleXCSSTypes.js.flow → cjs/types/StyleXCSSTypes.js.flow} +25 -0
- package/lib/{StyleXTypes.d.ts → cjs/types/StyleXTypes.d.ts} +60 -5
- package/lib/{StyleXTypes.js.flow → cjs/types/StyleXTypes.js.flow} +56 -5
- package/lib/{VarTypes.d.ts → cjs/types/VarTypes.d.ts} +19 -18
- package/lib/{VarTypes.js.flow → cjs/types/VarTypes.js.flow} +17 -19
- package/lib/es/inject.d.ts +11 -0
- package/lib/es/inject.js.flow +13 -0
- package/lib/es/inject.mjs +208 -0
- package/lib/es/stylesheet/createCSSStyleSheet.d.ts +13 -0
- package/lib/es/stylesheet/createCSSStyleSheet.js.flow +13 -0
- package/lib/es/stylesheet/createOrderedCSSStyleSheet.d.ts +31 -0
- package/lib/es/stylesheet/createOrderedCSSStyleSheet.js.flow +32 -0
- package/lib/es/stylesheet/createSheet.d.ts +12 -0
- package/lib/es/stylesheet/createSheet.js.flow +16 -0
- package/lib/es/stylesheet/utils.d.ts +18 -0
- package/lib/es/stylesheet/utils.js.flow +19 -0
- package/lib/es/stylex.d.ts +135 -0
- package/lib/es/stylex.js.flow +134 -0
- package/lib/es/stylex.mjs +8 -20
- package/lib/es/types/StyleXCSSTypes.d.ts +1487 -0
- package/lib/es/types/StyleXCSSTypes.js.flow +1580 -0
- package/lib/es/types/StyleXOpaqueTypes.d.ts +11 -0
- package/lib/es/types/StyleXOpaqueTypes.js.flow +16 -0
- package/lib/es/types/StyleXTypes.d.ts +292 -0
- package/lib/es/types/StyleXTypes.js.flow +240 -0
- package/lib/es/types/StyleXUtils.d.ts +15 -0
- package/lib/es/types/StyleXUtils.js.flow +15 -0
- package/lib/es/types/VarTypes.d.ts +104 -0
- package/lib/es/types/VarTypes.js.flow +102 -0
- package/package.json +20 -28
- package/lib/StyleXCSSTypes.js +0 -1
- package/lib/StyleXOpaqueTypes.js +0 -1
- package/lib/StyleXSheet.d.ts +0 -49
- package/lib/StyleXSheet.js +0 -188
- package/lib/StyleXSheet.js.flow +0 -49
- package/lib/StyleXTypes.js +0 -1
- package/lib/VarTypes.js +0 -1
- package/lib/es/StyleXCSSTypes.mjs +0 -1
- package/lib/es/StyleXOpaqueTypes.mjs +0 -0
- package/lib/es/StyleXSheet.mjs +0 -247
- package/lib/es/StyleXTypes.mjs +0 -1
- package/lib/es/VarTypes.mjs +0 -0
- package/lib/es/stylex-inject.mjs +0 -5
- package/lib/es/util-types.mjs +0 -0
- package/lib/stylex-inject.js +0 -11
- package/lib/stylex.js +0 -125
- package/lib/util-types.js +0 -1
- /package/lib/{StyleXOpaqueTypes.d.ts → cjs/types/StyleXOpaqueTypes.d.ts} +0 -0
- /package/lib/{StyleXOpaqueTypes.js.flow → cjs/types/StyleXOpaqueTypes.js.flow} +0 -0
- /package/lib/{util-types.d.ts → cjs/types/StyleXUtils.d.ts} +0 -0
- /package/lib/{util-types.js.flow → cjs/types/StyleXUtils.js.flow} +0 -0
|
@@ -0,0 +1,135 @@
|
|
|
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 {
|
|
11
|
+
CompiledStyles,
|
|
12
|
+
InlineStyles,
|
|
13
|
+
Keyframes,
|
|
14
|
+
StaticStyles,
|
|
15
|
+
StaticStylesWithout,
|
|
16
|
+
StyleX$Create,
|
|
17
|
+
StyleX$CreateTheme,
|
|
18
|
+
StyleX$DefineVars,
|
|
19
|
+
StyleX$DefineConsts,
|
|
20
|
+
StyleXArray,
|
|
21
|
+
StyleXStyles,
|
|
22
|
+
StyleXStylesWithout,
|
|
23
|
+
Theme,
|
|
24
|
+
VarGroup,
|
|
25
|
+
PositionTry,
|
|
26
|
+
} from './types/StyleXTypes';
|
|
27
|
+
import type { ValueWithDefault } from './types/StyleXUtils';
|
|
28
|
+
import * as Types from './types/VarTypes';
|
|
29
|
+
export type {
|
|
30
|
+
StaticStyles,
|
|
31
|
+
StaticStylesWithout,
|
|
32
|
+
StyleXStyles,
|
|
33
|
+
StyleXStylesWithout,
|
|
34
|
+
Theme,
|
|
35
|
+
Types,
|
|
36
|
+
VarGroup,
|
|
37
|
+
};
|
|
38
|
+
export declare const create: StyleX$Create;
|
|
39
|
+
export declare const createTheme: StyleX$CreateTheme;
|
|
40
|
+
export declare const defineConsts: StyleX$DefineConsts;
|
|
41
|
+
export declare const defineVars: StyleX$DefineVars;
|
|
42
|
+
export declare const firstThatWorks: <T extends string | number>(
|
|
43
|
+
..._styles: ReadonlyArray<T>
|
|
44
|
+
) => ReadonlyArray<T>;
|
|
45
|
+
export declare const keyframes: (_keyframes: Keyframes) => string;
|
|
46
|
+
export declare const positionTry: (_positionTry: PositionTry) => string;
|
|
47
|
+
export declare function props(
|
|
48
|
+
this: null | undefined | unknown,
|
|
49
|
+
...styles: ReadonlyArray<
|
|
50
|
+
StyleXArray<
|
|
51
|
+
| (null | undefined | CompiledStyles)
|
|
52
|
+
| boolean
|
|
53
|
+
| Readonly<[CompiledStyles, InlineStyles]>
|
|
54
|
+
>
|
|
55
|
+
>
|
|
56
|
+
): Readonly<{
|
|
57
|
+
className?: string;
|
|
58
|
+
'data-style-src'?: string;
|
|
59
|
+
style?: Readonly<{ [$$Key$$: string]: string | number }>;
|
|
60
|
+
}>;
|
|
61
|
+
export declare const types: {
|
|
62
|
+
angle: <T extends string | 0 = string | 0>(
|
|
63
|
+
_v: ValueWithDefault<T>,
|
|
64
|
+
) => Types.Angle<T>;
|
|
65
|
+
color: <T extends string = string>(_v: ValueWithDefault<T>) => Types.Color<T>;
|
|
66
|
+
url: <T extends string = string>(_v: ValueWithDefault<T>) => Types.Url<T>;
|
|
67
|
+
image: <T extends string = string>(_v: ValueWithDefault<T>) => Types.Image<T>;
|
|
68
|
+
integer: <T extends number | string = number | string>(
|
|
69
|
+
_v: ValueWithDefault<T>,
|
|
70
|
+
) => Types.Integer<T>;
|
|
71
|
+
lengthPercentage: <T extends number | string = number | string>(
|
|
72
|
+
_v: ValueWithDefault<T>,
|
|
73
|
+
) => Types.LengthPercentage<T>;
|
|
74
|
+
length: <T extends number | string = number | string>(
|
|
75
|
+
_v: ValueWithDefault<T>,
|
|
76
|
+
) => Types.Length<T>;
|
|
77
|
+
percentage: <T extends number | string = number | string>(
|
|
78
|
+
_v: ValueWithDefault<T>,
|
|
79
|
+
) => Types.Percentage<T>;
|
|
80
|
+
number: <T extends number | string = number | string>(
|
|
81
|
+
_v: ValueWithDefault<T>,
|
|
82
|
+
) => Types.Num<T>;
|
|
83
|
+
resolution: <T extends string = string>(
|
|
84
|
+
_v: ValueWithDefault<T>,
|
|
85
|
+
) => Types.Resolution<T>;
|
|
86
|
+
time: <T extends string | 0 = string | 0>(
|
|
87
|
+
_v: ValueWithDefault<T>,
|
|
88
|
+
) => Types.Time<T>;
|
|
89
|
+
transformFunction: <T extends string = string>(
|
|
90
|
+
_v: ValueWithDefault<T>,
|
|
91
|
+
) => Types.TransformFunction<T>;
|
|
92
|
+
transformList: <T extends string = string>(
|
|
93
|
+
_v: ValueWithDefault<T>,
|
|
94
|
+
) => Types.TransformList<T>;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* DO NOT USE. Legacy export for Meta
|
|
98
|
+
*/
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* DO NOT USE. Legacy export for Meta
|
|
102
|
+
*/
|
|
103
|
+
|
|
104
|
+
type IStyleX = {
|
|
105
|
+
(
|
|
106
|
+
...styles: ReadonlyArray<
|
|
107
|
+
StyleXArray<(null | undefined | CompiledStyles) | boolean>
|
|
108
|
+
>
|
|
109
|
+
): string;
|
|
110
|
+
create: StyleX$Create;
|
|
111
|
+
createTheme: StyleX$CreateTheme;
|
|
112
|
+
defineVars: StyleX$DefineVars;
|
|
113
|
+
firstThatWorks: <T extends string | number>(
|
|
114
|
+
...v: ReadonlyArray<T>
|
|
115
|
+
) => ReadonlyArray<T>;
|
|
116
|
+
keyframes: (keyframes: Keyframes) => string;
|
|
117
|
+
positionTry: (positionTry: PositionTry) => string;
|
|
118
|
+
props: (
|
|
119
|
+
this: null | undefined | unknown,
|
|
120
|
+
...styles: ReadonlyArray<
|
|
121
|
+
StyleXArray<
|
|
122
|
+
| (null | undefined | CompiledStyles)
|
|
123
|
+
| boolean
|
|
124
|
+
| Readonly<[CompiledStyles, InlineStyles]>
|
|
125
|
+
>
|
|
126
|
+
>
|
|
127
|
+
) => Readonly<{
|
|
128
|
+
className?: string;
|
|
129
|
+
'data-style-src'?: string;
|
|
130
|
+
style?: Readonly<{ [$$Key$$: string]: string | number }>;
|
|
131
|
+
}>;
|
|
132
|
+
types: typeof types;
|
|
133
|
+
__customProperties?: { [$$Key$$: string]: unknown };
|
|
134
|
+
};
|
|
135
|
+
export declare const legacyMerge: IStyleX;
|
|
@@ -0,0 +1,134 @@
|
|
|
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
|
+
CompiledStyles,
|
|
12
|
+
InlineStyles,
|
|
13
|
+
Keyframes,
|
|
14
|
+
StaticStyles,
|
|
15
|
+
StaticStylesWithout,
|
|
16
|
+
StyleX$Create,
|
|
17
|
+
StyleX$CreateTheme,
|
|
18
|
+
StyleX$DefineVars,
|
|
19
|
+
StyleX$DefineConsts,
|
|
20
|
+
StyleXArray,
|
|
21
|
+
StyleXStyles,
|
|
22
|
+
StyleXStylesWithout,
|
|
23
|
+
Theme,
|
|
24
|
+
VarGroup,
|
|
25
|
+
PositionTry,
|
|
26
|
+
} from './types/StyleXTypes';
|
|
27
|
+
import type { ValueWithDefault } from './types/StyleXUtils';
|
|
28
|
+
import * as Types from './types/VarTypes';
|
|
29
|
+
|
|
30
|
+
export type {
|
|
31
|
+
StaticStyles,
|
|
32
|
+
StaticStylesWithout,
|
|
33
|
+
StyleXStyles,
|
|
34
|
+
StyleXStylesWithout,
|
|
35
|
+
Theme,
|
|
36
|
+
Types,
|
|
37
|
+
VarGroup,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
declare export const create: StyleX$Create;
|
|
41
|
+
|
|
42
|
+
declare export const createTheme: StyleX$CreateTheme;
|
|
43
|
+
|
|
44
|
+
declare export const defineConsts: StyleX$DefineConsts;
|
|
45
|
+
|
|
46
|
+
declare export const defineVars: StyleX$DefineVars;
|
|
47
|
+
|
|
48
|
+
declare export const firstThatWorks: <T: string | number>(
|
|
49
|
+
..._styles: $ReadOnlyArray<T>
|
|
50
|
+
) => $ReadOnlyArray<T>;
|
|
51
|
+
|
|
52
|
+
declare export const keyframes: (_keyframes: Keyframes) => string;
|
|
53
|
+
|
|
54
|
+
declare export const positionTry: (_positionTry: PositionTry) => string;
|
|
55
|
+
|
|
56
|
+
declare export function props(
|
|
57
|
+
this: ?mixed,
|
|
58
|
+
...styles: $ReadOnlyArray<
|
|
59
|
+
StyleXArray<
|
|
60
|
+
?CompiledStyles | boolean | $ReadOnly<[CompiledStyles, InlineStyles]>,
|
|
61
|
+
>,
|
|
62
|
+
>
|
|
63
|
+
): $ReadOnly<{
|
|
64
|
+
className?: string,
|
|
65
|
+
'data-style-src'?: string,
|
|
66
|
+
style?: $ReadOnly<{ [string]: string | number }>,
|
|
67
|
+
}>;
|
|
68
|
+
|
|
69
|
+
declare export const types: {
|
|
70
|
+
angle: <T: string | 0 = string | 0>(
|
|
71
|
+
_v: ValueWithDefault<T>,
|
|
72
|
+
) => Types.Angle<T>,
|
|
73
|
+
color: <T: string = string>(_v: ValueWithDefault<T>) => Types.Color<T>,
|
|
74
|
+
url: <T: string = string>(_v: ValueWithDefault<T>) => Types.Url<T>,
|
|
75
|
+
image: <T: string = string>(_v: ValueWithDefault<T>) => Types.Image<T>,
|
|
76
|
+
integer: <T: number | string = number | string>(
|
|
77
|
+
_v: ValueWithDefault<T>,
|
|
78
|
+
) => Types.Integer<T>,
|
|
79
|
+
lengthPercentage: <T: number | string = number | string>(
|
|
80
|
+
_v: ValueWithDefault<T>,
|
|
81
|
+
) => Types.LengthPercentage<T>,
|
|
82
|
+
length: <T: number | string = number | string>(
|
|
83
|
+
_v: ValueWithDefault<T>,
|
|
84
|
+
) => Types.Length<T>,
|
|
85
|
+
percentage: <T: number | string = number | string>(
|
|
86
|
+
_v: ValueWithDefault<T>,
|
|
87
|
+
) => Types.Percentage<T>,
|
|
88
|
+
number: <T: number | string = number | string>(
|
|
89
|
+
_v: ValueWithDefault<T>,
|
|
90
|
+
) => Types.Num<T>,
|
|
91
|
+
resolution: <T: string = string>(
|
|
92
|
+
_v: ValueWithDefault<T>,
|
|
93
|
+
) => Types.Resolution<T>,
|
|
94
|
+
time: <T: string | 0 = string | 0>(_v: ValueWithDefault<T>) => Types.Time<T>,
|
|
95
|
+
transformFunction: <T: string = string>(
|
|
96
|
+
_v: ValueWithDefault<T>,
|
|
97
|
+
) => Types.TransformFunction<T>,
|
|
98
|
+
transformList: <T: string = string>(
|
|
99
|
+
_v: ValueWithDefault<T>,
|
|
100
|
+
) => Types.TransformList<T>,
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* DO NOT USE. Legacy export for Meta
|
|
105
|
+
*/
|
|
106
|
+
|
|
107
|
+
type IStyleX = {
|
|
108
|
+
(...styles: $ReadOnlyArray<StyleXArray<?CompiledStyles | boolean>>): string,
|
|
109
|
+
create: StyleX$Create,
|
|
110
|
+
createTheme: StyleX$CreateTheme,
|
|
111
|
+
defineVars: StyleX$DefineVars,
|
|
112
|
+
firstThatWorks: <T: string | number>(
|
|
113
|
+
...v: $ReadOnlyArray<T>
|
|
114
|
+
) => $ReadOnlyArray<T>,
|
|
115
|
+
keyframes: (keyframes: Keyframes) => string,
|
|
116
|
+
positionTry: (positionTry: PositionTry) => string,
|
|
117
|
+
props: (
|
|
118
|
+
this: ?mixed,
|
|
119
|
+
...styles: $ReadOnlyArray<
|
|
120
|
+
StyleXArray<
|
|
121
|
+
?CompiledStyles | boolean | $ReadOnly<[CompiledStyles, InlineStyles]>,
|
|
122
|
+
>,
|
|
123
|
+
>
|
|
124
|
+
) => $ReadOnly<{
|
|
125
|
+
className?: string,
|
|
126
|
+
'data-style-src'?: string,
|
|
127
|
+
style?: $ReadOnly<{ [string]: string | number }>,
|
|
128
|
+
}>,
|
|
129
|
+
types: typeof types,
|
|
130
|
+
__customProperties?: { [string]: mixed },
|
|
131
|
+
...
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
declare export const legacyMerge: IStyleX;
|
package/lib/es/stylex.mjs
CHANGED
|
@@ -132,30 +132,15 @@ var styleqExports = /*@__PURE__*/ requireStyleq();
|
|
|
132
132
|
|
|
133
133
|
const errorForFn = name => new Error(`Unexpected 'stylex.${name}' call at runtime. Styles must be compiled by '@stylexjs/babel-plugin'.`);
|
|
134
134
|
const errorForType = key => errorForFn(`types.${key}`);
|
|
135
|
-
function attrs() {
|
|
136
|
-
const {
|
|
137
|
-
className,
|
|
138
|
-
'data-style-src': dataStyleSrc,
|
|
139
|
-
style
|
|
140
|
-
} = props(...arguments);
|
|
141
|
-
const result = {};
|
|
142
|
-
if (className != null && className !== '') {
|
|
143
|
-
result.class = className;
|
|
144
|
-
}
|
|
145
|
-
if (style != null && Object.keys(style).length > 0) {
|
|
146
|
-
result.style = Object.keys(style).map(key => `${key}:${style[key]};`).join('');
|
|
147
|
-
}
|
|
148
|
-
if (dataStyleSrc != null && dataStyleSrc !== '') {
|
|
149
|
-
result['data-style-src'] = dataStyleSrc;
|
|
150
|
-
}
|
|
151
|
-
return result;
|
|
152
|
-
}
|
|
153
135
|
const create = function stylexCreate(_styles) {
|
|
154
136
|
throw errorForFn('create');
|
|
155
137
|
};
|
|
156
138
|
const createTheme = (_baseTokens, _overrides) => {
|
|
157
139
|
throw errorForFn('createTheme');
|
|
158
140
|
};
|
|
141
|
+
const defineConsts = function stylexDefineConsts(_styles) {
|
|
142
|
+
throw errorForFn('defineConsts');
|
|
143
|
+
};
|
|
159
144
|
const defineVars = function stylexDefineVars(_styles) {
|
|
160
145
|
throw errorForFn('defineVars');
|
|
161
146
|
};
|
|
@@ -165,6 +150,9 @@ const firstThatWorks = function () {
|
|
|
165
150
|
const keyframes = _keyframes => {
|
|
166
151
|
throw errorForFn('keyframes');
|
|
167
152
|
};
|
|
153
|
+
const positionTry = _positionTry => {
|
|
154
|
+
throw errorForFn('positionTry');
|
|
155
|
+
};
|
|
168
156
|
function props() {
|
|
169
157
|
for (var _len = arguments.length, styles = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
170
158
|
styles[_key] = arguments[_key];
|
|
@@ -230,14 +218,14 @@ function _legacyMerge() {
|
|
|
230
218
|
const [className] = styleqExports.styleq(styles);
|
|
231
219
|
return className;
|
|
232
220
|
}
|
|
233
|
-
_legacyMerge.attrs = attrs;
|
|
234
221
|
_legacyMerge.create = create;
|
|
235
222
|
_legacyMerge.createTheme = createTheme;
|
|
236
223
|
_legacyMerge.defineVars = defineVars;
|
|
237
224
|
_legacyMerge.firstThatWorks = firstThatWorks;
|
|
238
225
|
_legacyMerge.keyframes = keyframes;
|
|
226
|
+
_legacyMerge.positionTry = positionTry;
|
|
239
227
|
_legacyMerge.props = props;
|
|
240
228
|
_legacyMerge.types = types;
|
|
241
229
|
const legacyMerge = _legacyMerge;
|
|
242
230
|
|
|
243
|
-
export {
|
|
231
|
+
export { create, createTheme, defineConsts, defineVars, firstThatWorks, keyframes, legacyMerge, positionTry, props, types };
|