@stylexjs/stylex 0.2.0-beta.21 → 0.2.0-beta.23
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 +80 -43
- package/lib/StyleXCSSTypes.js +1 -1
- package/lib/StyleXSheet.js +18 -19
- package/lib/StyleXTypes.d.ts +26 -51
- package/lib/StyleXTypes.js +1 -1
- package/lib/StyleXTypes.js.flow +16 -16
- package/lib/native/CSSCustomPropertyValue.js +1 -1
- package/lib/native/CSSLengthUnitValue.js +7 -7
- package/lib/native/CSSMediaQuery.js +4 -4
- package/lib/native/SpreadOptions.d.ts +3 -2
- package/lib/native/SpreadOptions.js.flow +3 -2
- package/lib/native/__tests__/__snapshots__/stylex-test.js.snap +16 -0
- package/lib/native/__tests__/parseTimeValue-test.js +3 -3
- package/lib/native/__tests__/stylex-css-var-test.js +60 -60
- package/lib/native/__tests__/stylex-test.js +310 -293
- package/lib/native/fixContentBox.js +7 -7
- package/lib/native/flattenStyle.js +1 -1
- package/lib/native/parseShadow.js +4 -4
- package/lib/native/parseTimeValue.js +4 -4
- package/lib/native/stylex.d.ts +17 -7
- package/lib/native/stylex.js +124 -89
- package/lib/native/stylex.js.flow +21 -7
- package/lib/stylex.d.ts +45 -32
- package/lib/stylex.js +87 -61
- package/lib/stylex.js.flow +42 -33
- package/package.json +2 -2
package/lib/stylex.d.ts
CHANGED
|
@@ -10,33 +10,45 @@
|
|
|
10
10
|
import type {
|
|
11
11
|
Keyframes,
|
|
12
12
|
Stylex$Create,
|
|
13
|
-
StyleX$
|
|
14
|
-
StyleX$
|
|
13
|
+
StyleX$DefineVars,
|
|
14
|
+
StyleX$CreateTheme,
|
|
15
15
|
StyleXArray,
|
|
16
|
-
MapNamespace,
|
|
17
16
|
CompiledStyles,
|
|
17
|
+
InlineStyles,
|
|
18
|
+
StyleXClassNameFor,
|
|
18
19
|
} from './StyleXTypes';
|
|
19
20
|
export type { Theme, Variant } from './StyleXTypes';
|
|
20
21
|
import injectStyle from './stylex-inject';
|
|
21
|
-
export declare function
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
export declare function props(
|
|
23
|
+
this: null | undefined | unknown,
|
|
24
|
+
...styles: ReadonlyArray<
|
|
25
|
+
StyleXArray<
|
|
26
|
+
| (null | undefined | CompiledStyles)
|
|
27
|
+
| boolean
|
|
28
|
+
| Readonly<[CompiledStyles, InlineStyles]>
|
|
29
|
+
>
|
|
30
|
+
>
|
|
28
31
|
): Readonly<{
|
|
29
|
-
className
|
|
30
|
-
style
|
|
32
|
+
className?: string;
|
|
33
|
+
style?: Readonly<{ [$$Key$$: string]: string | number }>;
|
|
31
34
|
}>;
|
|
32
35
|
type Stylex$Include = <
|
|
33
|
-
TStyles extends {
|
|
36
|
+
TStyles extends {
|
|
37
|
+
readonly [$$Key$$: string]: StyleXClassNameFor<string, unknown>;
|
|
38
|
+
},
|
|
34
39
|
>(
|
|
35
|
-
|
|
36
|
-
) =>
|
|
40
|
+
styles: TStyles,
|
|
41
|
+
) => {
|
|
42
|
+
readonly [Key in keyof TStyles]: TStyles[Key] extends StyleXClassNameFor<
|
|
43
|
+
unknown,
|
|
44
|
+
infer V
|
|
45
|
+
>
|
|
46
|
+
? V
|
|
47
|
+
: string;
|
|
48
|
+
};
|
|
37
49
|
export declare const create: Stylex$Create;
|
|
38
|
-
export declare const
|
|
39
|
-
export declare const
|
|
50
|
+
export declare const defineVars: StyleX$DefineVars;
|
|
51
|
+
export declare const createTheme: StyleX$CreateTheme;
|
|
40
52
|
export declare const include: Stylex$Include;
|
|
41
53
|
type ValueWithDefault<T> =
|
|
42
54
|
| T
|
|
@@ -90,32 +102,33 @@ export declare const types: {
|
|
|
90
102
|
_v: ValueWithDefault<T>,
|
|
91
103
|
) => ICSSType<T>;
|
|
92
104
|
};
|
|
93
|
-
export declare const keyframes: (
|
|
105
|
+
export declare const keyframes: (keyframes: Keyframes) => string;
|
|
94
106
|
export declare const firstThatWorks: <T extends string | number>(
|
|
95
|
-
...
|
|
107
|
+
...styles: ReadonlyArray<T>
|
|
96
108
|
) => ReadonlyArray<T>;
|
|
97
109
|
export declare const inject: typeof injectStyle;
|
|
98
|
-
export declare const UNSUPPORTED_PROPERTY: <T>(_props: T) => T;
|
|
99
110
|
type IStyleX = {
|
|
100
111
|
(
|
|
101
112
|
...styles: ReadonlyArray<
|
|
102
113
|
StyleXArray<(null | undefined | CompiledStyles) | boolean>
|
|
103
114
|
>
|
|
104
115
|
): string;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
116
|
+
props: (
|
|
117
|
+
this: null | undefined | unknown,
|
|
118
|
+
...styles: ReadonlyArray<
|
|
119
|
+
StyleXArray<
|
|
120
|
+
| (null | undefined | CompiledStyles)
|
|
121
|
+
| boolean
|
|
122
|
+
| Readonly<[CompiledStyles, InlineStyles]>
|
|
123
|
+
>
|
|
124
|
+
>
|
|
112
125
|
) => Readonly<{
|
|
113
|
-
className
|
|
114
|
-
style
|
|
126
|
+
className?: string;
|
|
127
|
+
style?: Readonly<{ [$$Key$$: string]: string | number }>;
|
|
115
128
|
}>;
|
|
116
129
|
create: Stylex$Create;
|
|
117
|
-
|
|
118
|
-
|
|
130
|
+
defineVars: StyleX$DefineVars;
|
|
131
|
+
createTheme: StyleX$CreateTheme;
|
|
119
132
|
include: Stylex$Include;
|
|
120
133
|
types: typeof types;
|
|
121
134
|
firstThatWorks: <T extends string | number>(
|
|
@@ -127,7 +140,7 @@ type IStyleX = {
|
|
|
127
140
|
rtlRule: null | undefined | string,
|
|
128
141
|
) => void;
|
|
129
142
|
keyframes: (keyframes: Keyframes) => string;
|
|
130
|
-
|
|
143
|
+
__customProperties?: { [$$Key$$: string]: unknown };
|
|
131
144
|
};
|
|
132
145
|
export declare const stylex: IStyleX;
|
|
133
146
|
declare const $$EXPORT_DEFAULT_DECLARATION$$: IStyleX;
|
package/lib/stylex.js
CHANGED
|
@@ -1,116 +1,142 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
8
|
-
exports.
|
|
6
|
+
exports.__monkey_patch__ = __monkey_patch__;
|
|
7
|
+
exports.keyframes = exports.inject = exports.include = exports.firstThatWorks = exports.defineVars = exports.default = exports.createTheme = exports.create = void 0;
|
|
8
|
+
exports.props = props;
|
|
9
|
+
exports.types = exports.stylex = void 0;
|
|
9
10
|
var _stylexInject = _interopRequireDefault(require("./stylex-inject"));
|
|
10
11
|
var _styleq = require("styleq");
|
|
11
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
function
|
|
13
|
+
function props() {
|
|
14
|
+
const options = this;
|
|
15
|
+
for (var _len = arguments.length, styles = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
16
|
+
styles[_key] = arguments[_key];
|
|
17
|
+
}
|
|
18
|
+
if (__implementations.props) {
|
|
19
|
+
return __implementations.props.call(options, styles);
|
|
20
|
+
}
|
|
13
21
|
const [className, style] = (0, _styleq.styleq)(styles);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
function stylexCreateVars(_styles) {
|
|
23
|
-
throw new Error("stylex.createVars should never be called. It should be compiled away.");
|
|
22
|
+
const result = {};
|
|
23
|
+
if (className != null && className !== '') {
|
|
24
|
+
result.className = className;
|
|
25
|
+
}
|
|
26
|
+
if (style != null && Object.keys(style).length > 0) {
|
|
27
|
+
result.style = style;
|
|
28
|
+
}
|
|
29
|
+
return result;
|
|
24
30
|
}
|
|
25
|
-
function
|
|
26
|
-
|
|
31
|
+
function stylexCreate(styles) {
|
|
32
|
+
if (__implementations.create != null) {
|
|
33
|
+
const create = __implementations.create;
|
|
34
|
+
return create(styles);
|
|
35
|
+
}
|
|
36
|
+
throw new Error('stylex.create should never be called. It should be compiled away.');
|
|
27
37
|
}
|
|
28
|
-
function
|
|
29
|
-
|
|
38
|
+
function stylexDefineVars(styles) {
|
|
39
|
+
if (__implementations.defineVars) {
|
|
40
|
+
return __implementations.defineVars(styles);
|
|
41
|
+
}
|
|
42
|
+
throw new Error('stylex.defineVars should never be called. It should be compiled away.');
|
|
30
43
|
}
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
const stylexCreateTheme = (baseTokens, overrides) => {
|
|
45
|
+
if (__implementations.createTheme) {
|
|
46
|
+
return __implementations.createTheme(baseTokens, overrides);
|
|
47
|
+
}
|
|
48
|
+
throw new Error('stylex.createTheme should never be called. It should be compiled away.');
|
|
49
|
+
};
|
|
50
|
+
const stylexInclude = styles => {
|
|
51
|
+
if (__implementations.include) {
|
|
52
|
+
return __implementations.include(styles);
|
|
53
|
+
}
|
|
54
|
+
throw new Error('stylex.extends should never be called. It should be compiled away.');
|
|
55
|
+
};
|
|
56
|
+
const create = exports.create = stylexCreate;
|
|
57
|
+
const defineVars = exports.defineVars = stylexDefineVars;
|
|
58
|
+
const createTheme = exports.createTheme = stylexCreateTheme;
|
|
59
|
+
const include = exports.include = stylexInclude;
|
|
60
|
+
const types = exports.types = {
|
|
40
61
|
angle: _v => {
|
|
41
|
-
throw new Error(errorForType(
|
|
62
|
+
throw new Error(errorForType('angle'));
|
|
42
63
|
},
|
|
43
64
|
color: _v => {
|
|
44
|
-
throw new Error(errorForType(
|
|
65
|
+
throw new Error(errorForType('color'));
|
|
45
66
|
},
|
|
46
67
|
url: _v => {
|
|
47
|
-
throw new Error(errorForType(
|
|
68
|
+
throw new Error(errorForType('url'));
|
|
48
69
|
},
|
|
49
70
|
image: _v => {
|
|
50
|
-
throw new Error(errorForType(
|
|
71
|
+
throw new Error(errorForType('image'));
|
|
51
72
|
},
|
|
52
73
|
integer: _v => {
|
|
53
|
-
throw new Error(errorForType(
|
|
74
|
+
throw new Error(errorForType('integer'));
|
|
54
75
|
},
|
|
55
76
|
lengthPercentage: _v => {
|
|
56
|
-
throw new Error(errorForType(
|
|
77
|
+
throw new Error(errorForType('lengthPercentage'));
|
|
57
78
|
},
|
|
58
79
|
length: _v => {
|
|
59
|
-
throw new Error(errorForType(
|
|
80
|
+
throw new Error(errorForType('length'));
|
|
60
81
|
},
|
|
61
82
|
percentage: _v => {
|
|
62
|
-
throw new Error(errorForType(
|
|
83
|
+
throw new Error(errorForType('percentage'));
|
|
63
84
|
},
|
|
64
85
|
number: _v => {
|
|
65
|
-
throw new Error(errorForType(
|
|
86
|
+
throw new Error(errorForType('number'));
|
|
66
87
|
},
|
|
67
88
|
resolution: _v => {
|
|
68
|
-
throw new Error(errorForType(
|
|
89
|
+
throw new Error(errorForType('resolution'));
|
|
69
90
|
},
|
|
70
91
|
time: _v => {
|
|
71
|
-
throw new Error(errorForType(
|
|
92
|
+
throw new Error(errorForType('time'));
|
|
72
93
|
},
|
|
73
94
|
transformFunction: _v => {
|
|
74
|
-
throw new Error(errorForType(
|
|
95
|
+
throw new Error(errorForType('transformFunction'));
|
|
75
96
|
},
|
|
76
97
|
transformList: _v => {
|
|
77
|
-
throw new Error(errorForType(
|
|
98
|
+
throw new Error(errorForType('transformList'));
|
|
78
99
|
}
|
|
79
100
|
};
|
|
80
|
-
exports.types = types;
|
|
81
101
|
const errorForType = type => `stylex.types.${type} should be compiled away by @stylexjs/babel-plugin`;
|
|
82
|
-
const keyframes =
|
|
83
|
-
|
|
102
|
+
const keyframes = keyframes => {
|
|
103
|
+
if (__implementations.keyframes) {
|
|
104
|
+
return __implementations.keyframes(keyframes);
|
|
105
|
+
}
|
|
106
|
+
throw new Error('stylex.keyframes should never be called');
|
|
84
107
|
};
|
|
85
108
|
exports.keyframes = keyframes;
|
|
86
109
|
const firstThatWorks = function () {
|
|
87
|
-
|
|
110
|
+
if (__implementations.firstThatWorks) {
|
|
111
|
+
return __implementations.firstThatWorks(...arguments);
|
|
112
|
+
}
|
|
113
|
+
throw new Error('stylex.firstThatWorks should never be called.');
|
|
88
114
|
};
|
|
89
115
|
exports.firstThatWorks = firstThatWorks;
|
|
90
|
-
const inject = _stylexInject.default;
|
|
91
|
-
exports.inject = inject;
|
|
92
|
-
const UNSUPPORTED_PROPERTY = _props => {
|
|
93
|
-
throw new Error("stylex.UNSUPPORTED_PROPERTY should never be called. It should be compiled away.");
|
|
94
|
-
};
|
|
95
|
-
exports.UNSUPPORTED_PROPERTY = UNSUPPORTED_PROPERTY;
|
|
116
|
+
const inject = exports.inject = _stylexInject.default;
|
|
96
117
|
function _stylex() {
|
|
97
|
-
for (var
|
|
98
|
-
styles[
|
|
118
|
+
for (var _len2 = arguments.length, styles = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
119
|
+
styles[_key2] = arguments[_key2];
|
|
99
120
|
}
|
|
100
121
|
const [className] = (0, _styleq.styleq)(styles);
|
|
101
122
|
return className;
|
|
102
123
|
}
|
|
103
|
-
_stylex.
|
|
124
|
+
_stylex.props = props;
|
|
104
125
|
_stylex.create = create;
|
|
105
|
-
_stylex.
|
|
106
|
-
_stylex.
|
|
126
|
+
_stylex.defineVars = defineVars;
|
|
127
|
+
_stylex.createTheme = createTheme;
|
|
107
128
|
_stylex.include = include;
|
|
108
129
|
_stylex.keyframes = keyframes;
|
|
109
130
|
_stylex.firstThatWorks = firstThatWorks;
|
|
110
131
|
_stylex.inject = inject;
|
|
111
|
-
_stylex.UNSUPPORTED_PROPERTY = UNSUPPORTED_PROPERTY;
|
|
112
132
|
_stylex.types = types;
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
133
|
+
const __implementations = {};
|
|
134
|
+
function __monkey_patch__(key, implementation) {
|
|
135
|
+
if (key === 'types') {
|
|
136
|
+
Object.assign(types, implementation);
|
|
137
|
+
} else {
|
|
138
|
+
__implementations[key] = implementation;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
const stylex = exports.stylex = _stylex;
|
|
142
|
+
var _default = exports.default = _stylex;
|
package/lib/stylex.js.flow
CHANGED
|
@@ -10,37 +10,47 @@
|
|
|
10
10
|
import type {
|
|
11
11
|
Keyframes,
|
|
12
12
|
Stylex$Create,
|
|
13
|
-
StyleX$
|
|
14
|
-
StyleX$
|
|
13
|
+
StyleX$DefineVars,
|
|
14
|
+
StyleX$CreateTheme,
|
|
15
15
|
StyleXArray,
|
|
16
|
-
MapNamespace,
|
|
17
16
|
CompiledStyles,
|
|
17
|
+
InlineStyles,
|
|
18
|
+
StyleXClassNameFor,
|
|
18
19
|
} from './StyleXTypes';
|
|
19
20
|
|
|
20
21
|
export type { Theme, Variant } from './StyleXTypes';
|
|
21
22
|
|
|
22
23
|
import injectStyle from './stylex-inject';
|
|
23
|
-
declare export function
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
declare export function props(
|
|
25
|
+
this: ?mixed,
|
|
26
|
+
...styles: $ReadOnlyArray<
|
|
27
|
+
StyleXArray<
|
|
28
|
+
?CompiledStyles | boolean | $ReadOnly<[CompiledStyles, InlineStyles]>,
|
|
29
|
+
>,
|
|
30
|
+
>
|
|
30
31
|
): $ReadOnly<{
|
|
31
|
-
className
|
|
32
|
-
style
|
|
32
|
+
className?: string,
|
|
33
|
+
style?: $ReadOnly<{ [string]: string | number }>,
|
|
33
34
|
}>;
|
|
34
35
|
|
|
35
|
-
type Stylex$Include = <
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
type Stylex$Include = <
|
|
37
|
+
TStyles: { +[string]: StyleXClassNameFor<string, mixed> },
|
|
38
|
+
>(
|
|
39
|
+
styles: TStyles,
|
|
40
|
+
) => {
|
|
41
|
+
+[Key in keyof TStyles]: TStyles[Key] extends StyleXClassNameFor<
|
|
42
|
+
mixed,
|
|
43
|
+
infer V,
|
|
44
|
+
>
|
|
45
|
+
? V
|
|
46
|
+
: string,
|
|
47
|
+
};
|
|
38
48
|
|
|
39
49
|
declare export const create: Stylex$Create;
|
|
40
50
|
|
|
41
|
-
declare export const
|
|
51
|
+
declare export const defineVars: StyleX$DefineVars;
|
|
42
52
|
|
|
43
|
-
declare export const
|
|
53
|
+
declare export const createTheme: StyleX$CreateTheme;
|
|
44
54
|
|
|
45
55
|
declare export const include: Stylex$Include;
|
|
46
56
|
|
|
@@ -94,32 +104,30 @@ declare export const types: {
|
|
|
94
104
|
) => ICSSType<T>,
|
|
95
105
|
transformList: <T: number | string>(_v: ValueWithDefault<T>) => ICSSType<T>,
|
|
96
106
|
};
|
|
97
|
-
declare export const keyframes: (
|
|
107
|
+
declare export const keyframes: (keyframes: Keyframes) => string;
|
|
98
108
|
|
|
99
109
|
declare export const firstThatWorks: <T: string | number>(
|
|
100
|
-
...
|
|
110
|
+
...styles: $ReadOnlyArray<T>
|
|
101
111
|
) => $ReadOnlyArray<T>;
|
|
102
112
|
|
|
103
113
|
declare export const inject: typeof injectStyle;
|
|
104
114
|
|
|
105
|
-
declare export const UNSUPPORTED_PROPERTY: <T>(_props: T) => T;
|
|
106
|
-
|
|
107
115
|
type IStyleX = {
|
|
108
116
|
(...styles: $ReadOnlyArray<StyleXArray<?CompiledStyles | boolean>>): string,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
117
|
+
props: (
|
|
118
|
+
this: ?mixed,
|
|
119
|
+
...styles: $ReadOnlyArray<
|
|
120
|
+
StyleXArray<
|
|
121
|
+
?CompiledStyles | boolean | $ReadOnly<[CompiledStyles, InlineStyles]>,
|
|
122
|
+
>,
|
|
123
|
+
>
|
|
116
124
|
) => $ReadOnly<{
|
|
117
|
-
className
|
|
118
|
-
style
|
|
125
|
+
className?: string,
|
|
126
|
+
style?: $ReadOnly<{ [string]: string | number }>,
|
|
119
127
|
}>,
|
|
120
128
|
create: Stylex$Create,
|
|
121
|
-
|
|
122
|
-
|
|
129
|
+
defineVars: StyleX$DefineVars,
|
|
130
|
+
createTheme: StyleX$CreateTheme,
|
|
123
131
|
include: Stylex$Include,
|
|
124
132
|
types: typeof types,
|
|
125
133
|
firstThatWorks: <T: string | number>(
|
|
@@ -127,9 +135,10 @@ type IStyleX = {
|
|
|
127
135
|
) => $ReadOnlyArray<T>,
|
|
128
136
|
inject: (ltrRule: string, priority: number, rtlRule: ?string) => void,
|
|
129
137
|
keyframes: (keyframes: Keyframes) => string,
|
|
130
|
-
|
|
138
|
+
__customProperties?: { [string]: mixed },
|
|
131
139
|
...
|
|
132
140
|
};
|
|
133
141
|
|
|
142
|
+
|
|
134
143
|
declare export const stylex: IStyleX;
|
|
135
144
|
declare export default IStyleX;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stylexjs/stylex",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.23",
|
|
4
4
|
"description": "A library for defining styles for optimized user interfaces.",
|
|
5
5
|
"main": "lib/stylex.js",
|
|
6
6
|
"react-native": "lib/native/stylex.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"utility-types": "^3.10.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@stylexjs/scripts": "0.2.0-beta.
|
|
23
|
+
"@stylexjs/scripts": "0.2.0-beta.23"
|
|
24
24
|
},
|
|
25
25
|
"jest": {},
|
|
26
26
|
"files": [
|