@stylexjs/stylex 0.1.0-beta.6 → 0.2.0-beta.10
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 +245 -0
- package/lib/StyleXSheet.js +4 -3
- package/lib/stylex.d.ts +17 -14
- package/lib/stylex.js +40 -92
- package/package.json +3 -5
package/README.md
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
# @stylexjs/stylex
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
To start playing with StyleX without having to set up any build settings you can install just two packages:
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install --save @stylexjs/stylex
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### Compiler
|
|
12
|
+
|
|
13
|
+
StyleX is designed to extract styles to a static CSS style sheet during an app's build process. StyleX provides a Babel plugin along with plugin integrations for Webpack, Rollup and NextJS.
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm install --save-dev @stylexjs/babel-plugin
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
For more information on working with the compiler, please see the documentation for [`@stylexjs/babel-plugin`](https://www.npmjs.com/package/@stylexjs/babel-plugin).
|
|
20
|
+
|
|
21
|
+
### Runtime compiler
|
|
22
|
+
|
|
23
|
+
The runtime compiler should only be used for development and testing purposes.
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
npm install --save-dev @stylexjs/dev-runtime
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Import `@stylexjs/dev-runtime` in your JS entry-point to set everything up.
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import inject from '@stylexjs/dev-runtime';
|
|
33
|
+
|
|
34
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
35
|
+
inject({
|
|
36
|
+
// configuration options
|
|
37
|
+
classNamePrefix: 'x-',
|
|
38
|
+
dev: true,
|
|
39
|
+
test: false,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
For more information on working with the compiler, please see the documentation for [`@stylexjs/dev-runtime`](https://www.npmjs.com/package/@stylexjs/dev-runtime).
|
|
45
|
+
|
|
46
|
+
## API
|
|
47
|
+
|
|
48
|
+
### stylex.create()
|
|
49
|
+
|
|
50
|
+
Styles are defined as a map of CSS rules using `stylex.create()`. In the example below, there are 2 different CSS rules. The names "root" and "highlighted" are arbitrary names given to the rules.
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
import stylex from '@stylexjs/stylex';
|
|
54
|
+
|
|
55
|
+
const styles = stylex.create({
|
|
56
|
+
root: {
|
|
57
|
+
width: '100%',
|
|
58
|
+
color: 'rgb(60,60,60)',
|
|
59
|
+
},
|
|
60
|
+
highlighted: {
|
|
61
|
+
color: 'yellow',
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Pseudo-classes and Media Queries can be nested within style definitions:
|
|
67
|
+
|
|
68
|
+
```tsx
|
|
69
|
+
import stylex from '@stylexjs/stylex';
|
|
70
|
+
|
|
71
|
+
const styles = stylex.create({
|
|
72
|
+
root: {
|
|
73
|
+
width: '100%',
|
|
74
|
+
color: 'rgb(60,60,60)',
|
|
75
|
+
'@media (min-width: 800px)': {
|
|
76
|
+
maxWidth: '800px',
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
highlighted: {
|
|
80
|
+
color: 'yellow',
|
|
81
|
+
':hover': {
|
|
82
|
+
opacity: '0.9',
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
The compiler will extract the rules to CSS and replace the rules in the source code with a "compiled style" object.
|
|
89
|
+
|
|
90
|
+
### stylex.apply()
|
|
91
|
+
|
|
92
|
+
Applying style rules to specific elements is done using `stylex.apply()`. Each argument to this function must be a reference to a compiled style object, or an array of compiled style objects. The function merges styles from left to right.
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
<div {...stylex.apply(styles.root, styles.highlighted)} />
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
The `stylex.apply` function returns React DOM style props as required to render an HTML element. StyleX styles can still be passed to other components via props, but only the components rendering HTML elements will use `stylex.apply()`. For example:
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
const styles = stylex.create({
|
|
102
|
+
internalRoot: {
|
|
103
|
+
padding: 10
|
|
104
|
+
},
|
|
105
|
+
exportedRoot: {
|
|
106
|
+
position: 'relative'
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
function InternalComponent(props) {
|
|
111
|
+
return <div {...props} {...stylex.apply([ styles.internalRoot, props.style ])} />
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function ExportedComponent(props) {
|
|
115
|
+
return <InternalComponent style={[ styles.exportedRoot, props.style ]} />
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Styles can be conditionally included using standard JavaScript.
|
|
120
|
+
|
|
121
|
+
```tsx
|
|
122
|
+
<div {...stylex.apply(styles.root, isHighlighted && styles.highlighted)} />
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
And the local merging of styles can be used to control the relative priority of rules. For example, to allow a component's local styles to take priority over style property values passed in via props.
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
<div {...stylex.apply(props.style, styles.root)} />
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
You can even mix compiled styles with inline styles
|
|
132
|
+
|
|
133
|
+
```tsx
|
|
134
|
+
<div {...stylex.apply(styles.root, { opacity })} />
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### stylex.firstThatWorks()
|
|
138
|
+
|
|
139
|
+
Defining fallback styles is done with `stylex.firstThatWorks()`. This is useful for engines that may not support a specific style property.
|
|
140
|
+
|
|
141
|
+
```tsx
|
|
142
|
+
import stylex from '@stylexjs/stylex';
|
|
143
|
+
|
|
144
|
+
const styles = stylex.create({
|
|
145
|
+
header: {
|
|
146
|
+
position: stylex.firstThatWorks('sticky', '-webkit-sticky', 'fixed'),
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
This is equivalent to defining CSS as follows:
|
|
152
|
+
|
|
153
|
+
```css
|
|
154
|
+
.header {
|
|
155
|
+
position: fixed;
|
|
156
|
+
position: -webkit-sticky;
|
|
157
|
+
position: sticky;
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Types
|
|
162
|
+
|
|
163
|
+
StyleX comes with full support for Static Types.
|
|
164
|
+
|
|
165
|
+
### `XStyle<>`
|
|
166
|
+
|
|
167
|
+
The most common type you might need to use is `XStyle<>`. This lets you accept an object of arbitrary StyleX styles.
|
|
168
|
+
|
|
169
|
+
```tsx
|
|
170
|
+
type Props = {
|
|
171
|
+
...
|
|
172
|
+
style?: XStyle<>,
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
function MyComponent({style, ...}: Props) {
|
|
176
|
+
return (
|
|
177
|
+
<div {...stylex.apply(localStyles.foo, localStyles.bar, style)} />
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### `XStyleWithout<>`
|
|
183
|
+
|
|
184
|
+
To disallow specific style properties, use the `XStyleWithout<>` type.
|
|
185
|
+
|
|
186
|
+
```tsx
|
|
187
|
+
type Props = {
|
|
188
|
+
// ...
|
|
189
|
+
style?: XStyleWithout<{
|
|
190
|
+
postion: unknown,
|
|
191
|
+
display: unknown
|
|
192
|
+
}>
|
|
193
|
+
};
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### `XStyleValue<>`
|
|
197
|
+
|
|
198
|
+
To accept specific style properties only, use the `XStyle<{...}>` and `XStyleValue` types. For example, to allow only color-related style props:
|
|
199
|
+
|
|
200
|
+
```tsx
|
|
201
|
+
type Props = {
|
|
202
|
+
// ...
|
|
203
|
+
style?: XStyle<{
|
|
204
|
+
color?: StyleXValue,
|
|
205
|
+
backgroundColor?: StyleXValue,
|
|
206
|
+
borderColor?: StyleXValue,
|
|
207
|
+
borderTopColor?: StyleXValue,
|
|
208
|
+
borderEndColor?: StyleXValue,
|
|
209
|
+
borderBottomColor?: StyleXValue,
|
|
210
|
+
borderStartColor?: StyleXValue,
|
|
211
|
+
}>,
|
|
212
|
+
};
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### `XStyleValueFor<>`
|
|
216
|
+
|
|
217
|
+
To limit the possible values for style properties, use the `XStyleValueFor<>` type. Pass in a type argument with a union of literal types that provide the set of possible values that the style property can have. For example, if a component should accept `marginTop` but only accept one of `0`, `4`, or `8` pixels as values.
|
|
218
|
+
|
|
219
|
+
```tsx
|
|
220
|
+
type Props = {
|
|
221
|
+
...
|
|
222
|
+
style?: XStyle<{
|
|
223
|
+
marginTop: XStyleValueFor<0 | 4 | 8>
|
|
224
|
+
}>,
|
|
225
|
+
};
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
## How StyleX works
|
|
229
|
+
|
|
230
|
+
StyleX produces atomic styles, which means that each CSS rule contains only a single declaration and uses a unique class name. For example:
|
|
231
|
+
|
|
232
|
+
```tsx
|
|
233
|
+
import stylex from '@stylexjs/stylex';
|
|
234
|
+
|
|
235
|
+
const styles = stylex.create({
|
|
236
|
+
root: {
|
|
237
|
+
width: '100%',
|
|
238
|
+
color: 'red',
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
From this code, StyleX will generate 2 classes. One for the `width: '100%'` declaration, and one for the `color: 'red'` declaration. If you use the declaration `width: '100%'` anywhere else in your application, it will *reuse the same CSS class* rather than creating a new one.
|
|
244
|
+
|
|
245
|
+
One of the benefits of this approach is that the generated CSS file grows *logarithmically* as you add new styled components to your app. As more style declarations are added to components, they are more likely to already be in use elsehwere in the app. As a result of this CSS optimization, the generated CSS style sheet for an app is usually small enough to be contained in a single file and used across routes, avoiding style recalculation and layout thrashing as users navigate through your app.
|
package/lib/StyleXSheet.js
CHANGED
|
@@ -15,7 +15,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
15
15
|
exports.styleSheet = exports.StyleXSheet = void 0;
|
|
16
16
|
var _invariant = _interopRequireDefault(require("invariant"));
|
|
17
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
-
|
|
18
|
+
// import rtlDetect from 'rtl-detect';
|
|
19
|
+
|
|
19
20
|
const LIGHT_MODE_CLASS_NAME = '__fb-light-mode';
|
|
20
21
|
const DARK_MODE_CLASS_NAME = '__fb-dark-mode';
|
|
21
22
|
/**
|
|
@@ -62,6 +63,8 @@ const VARIABLE_MATCH = /var\(--(.*?)\)/g;
|
|
|
62
63
|
* CSS rules.
|
|
63
64
|
*/
|
|
64
65
|
class StyleXSheet {
|
|
66
|
+
static LIGHT_MODE_CLASS_NAME = LIGHT_MODE_CLASS_NAME;
|
|
67
|
+
static DARK_MODE_CLASS_NAME = DARK_MODE_CLASS_NAME;
|
|
65
68
|
constructor(opts) {
|
|
66
69
|
this.tag = null;
|
|
67
70
|
this.injected = false;
|
|
@@ -265,8 +268,6 @@ class StyleXSheet {
|
|
|
265
268
|
* Adds an ancestor selector in a media-query-aware way.
|
|
266
269
|
*/
|
|
267
270
|
exports.StyleXSheet = StyleXSheet;
|
|
268
|
-
_defineProperty(StyleXSheet, "LIGHT_MODE_CLASS_NAME", LIGHT_MODE_CLASS_NAME);
|
|
269
|
-
_defineProperty(StyleXSheet, "DARK_MODE_CLASS_NAME", DARK_MODE_CLASS_NAME);
|
|
270
271
|
function addAncestorSelector(selector, ancestorSelector) {
|
|
271
272
|
if (!selector.startsWith('@')) {
|
|
272
273
|
return `${ancestorSelector} ${selector}`;
|
package/lib/stylex.d.ts
CHANGED
|
@@ -38,17 +38,14 @@ export type CompiledNamespaceSet = {
|
|
|
38
38
|
readonly [K in string]: CompiledNamespace;
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
type Stylex$Create = <S extends
|
|
41
|
+
type Stylex$Create = <S extends NamespaceSet>(
|
|
42
42
|
styles: S
|
|
43
43
|
) => $ReadOnly<{
|
|
44
44
|
readonly [K in keyof S]: {
|
|
45
45
|
readonly [P in keyof S[K]]: S[K][P] extends string | number
|
|
46
|
-
?
|
|
46
|
+
? ClassNameFor<P, S[K][P]>
|
|
47
47
|
: {
|
|
48
|
-
readonly [F in keyof S[K][P]]:
|
|
49
|
-
`${P}+${F}`,
|
|
50
|
-
S[K][P][F]
|
|
51
|
-
>;
|
|
48
|
+
readonly [F in keyof S[K][P]]: ClassNameFor<`${P}+${F}`, S[K][P][F]>;
|
|
52
49
|
};
|
|
53
50
|
};
|
|
54
51
|
}>;
|
|
@@ -56,19 +53,17 @@ type Stylex$Create = <S extends StyleXNamespaceSet>(
|
|
|
56
53
|
type StylexInclude = <S extends CompiledNamespace>(
|
|
57
54
|
compiledNamespace: S
|
|
58
55
|
) => {
|
|
59
|
-
readonly [K in keyof S]: S[K] extends ClassNameFor<K, infer V>
|
|
60
|
-
? V
|
|
61
|
-
: Uncompiled<S[K]>;
|
|
56
|
+
readonly [K in keyof S]: S[K] extends ClassNameFor<K, infer V> ? V : S[K];
|
|
62
57
|
};
|
|
63
58
|
|
|
64
|
-
type Stylex$Keyframes = <S extends
|
|
65
|
-
animationConfig: S
|
|
66
|
-
) => string;
|
|
59
|
+
type Stylex$Keyframes = <S extends NamespaceSet>(animationConfig: S) => string;
|
|
67
60
|
|
|
68
|
-
type
|
|
61
|
+
type NestedArray<T> = T | Array<T | NestedArray<T>>;
|
|
62
|
+
|
|
63
|
+
declare let stylex: {
|
|
69
64
|
(
|
|
70
65
|
...styles: ReadonlyArray<
|
|
71
|
-
|
|
66
|
+
NestedArray<(CompiledNamespace | null | undefined) | boolean>
|
|
72
67
|
>
|
|
73
68
|
): string;
|
|
74
69
|
create: Stylex$Create;
|
|
@@ -79,6 +74,14 @@ type stylex = {
|
|
|
79
74
|
rtlRule: string | null | undefined
|
|
80
75
|
) => void;
|
|
81
76
|
keyframes: Stylex$Keyframes;
|
|
77
|
+
spread: (
|
|
78
|
+
...styles: ReadonlyArray<
|
|
79
|
+
NestedArray<(Object | CompiledNamespace | null | undefined) | boolean>
|
|
80
|
+
>
|
|
81
|
+
) => {
|
|
82
|
+
className: string;
|
|
83
|
+
style: { [key: string]: string | number };
|
|
84
|
+
};
|
|
82
85
|
};
|
|
83
86
|
|
|
84
87
|
export default stylex;
|
package/lib/stylex.js
CHANGED
|
@@ -12,95 +12,21 @@
|
|
|
12
12
|
Object.defineProperty(exports, "__esModule", {
|
|
13
13
|
value: true
|
|
14
14
|
});
|
|
15
|
-
exports.default = void 0;
|
|
15
|
+
exports.keyframes = exports.inject = exports.include = exports.firstThatWorks = exports.default = exports.create = exports.UNSUPPORTED_PROPERTY = void 0;
|
|
16
|
+
exports.spread = spread;
|
|
17
|
+
exports.stylex = void 0;
|
|
16
18
|
var _stylexInject = _interopRequireDefault(require("./stylex-inject"));
|
|
19
|
+
var _styleq = require("styleq");
|
|
17
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
-
|
|
19
|
-
const cache = enableCache ? new WeakMap() : null;
|
|
20
|
-
function stylex() {
|
|
21
|
-
// Keep a set of property commits to the className
|
|
22
|
-
const definedProperties = [];
|
|
23
|
-
let className = '';
|
|
24
|
-
let nextCache = cache;
|
|
21
|
+
function spread() {
|
|
25
22
|
for (var _len = arguments.length, styles = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
26
23
|
styles[_key] = arguments[_key];
|
|
27
24
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
styles.push(possibleStyle[i]);
|
|
34
|
-
}
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Process an individual style object
|
|
39
|
-
const styleObj = possibleStyle;
|
|
40
|
-
if (styleObj != null && typeof styleObj === 'object') {
|
|
41
|
-
// Build up the class names defined by this object
|
|
42
|
-
let classNameChunk = '';
|
|
43
|
-
if (nextCache != null && nextCache.has(styleObj)) {
|
|
44
|
-
// Cache: read
|
|
45
|
-
const cacheEntry = nextCache.get(styleObj);
|
|
46
|
-
if (cacheEntry != null) {
|
|
47
|
-
classNameChunk = cacheEntry.classNameChunk;
|
|
48
|
-
definedProperties.push(...cacheEntry.definedPropertiesChunk);
|
|
49
|
-
nextCache = cacheEntry.next;
|
|
50
|
-
}
|
|
51
|
-
} else {
|
|
52
|
-
// Record the properties this object defines (and that haven't already
|
|
53
|
-
// been defined by later objects.)
|
|
54
|
-
const definedPropertiesChunk = [];
|
|
55
|
-
for (const prop in styleObj) {
|
|
56
|
-
const value = styleObj[prop];
|
|
57
|
-
// Style declarations, e.g., opacity: 's3fkgpd'
|
|
58
|
-
if (typeof value === 'string') {
|
|
59
|
-
// Skip adding to the chunks if property has already been seen
|
|
60
|
-
if (!definedProperties.includes(prop)) {
|
|
61
|
-
definedProperties.push(prop);
|
|
62
|
-
definedPropertiesChunk.push(prop);
|
|
63
|
-
classNameChunk += classNameChunk ? ' ' + value : value;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
// Style conditions, e.g., ':hover', '@media', etc.
|
|
67
|
-
// TODO: remove if #98 is fixed
|
|
68
|
-
else if (typeof value === 'object') {
|
|
69
|
-
const condition = prop;
|
|
70
|
-
const nestedStyleObject = value;
|
|
71
|
-
for (const conditionalProp in nestedStyleObject) {
|
|
72
|
-
const conditionalValue = nestedStyleObject[conditionalProp];
|
|
73
|
-
const conditionalProperty = condition + conditionalProp;
|
|
74
|
-
// Skip if conditional property has already been seen
|
|
75
|
-
if (!definedProperties.includes(conditionalProperty)) {
|
|
76
|
-
definedProperties.push(conditionalProperty);
|
|
77
|
-
definedPropertiesChunk.push(conditionalProperty);
|
|
78
|
-
classNameChunk += classNameChunk ? ' ' + conditionalValue : conditionalValue;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
// Cache: write
|
|
84
|
-
if (nextCache != null) {
|
|
85
|
-
const emptyCache = new WeakMap();
|
|
86
|
-
nextCache.set(styleObj, {
|
|
87
|
-
classNameChunk,
|
|
88
|
-
definedPropertiesChunk,
|
|
89
|
-
next: emptyCache
|
|
90
|
-
});
|
|
91
|
-
nextCache = emptyCache;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// Order of classes in chunks matches property-iteration order of style
|
|
96
|
-
// object. Order of chunks matches passed order of styles from first to
|
|
97
|
-
// last (which we iterate over in reverse).
|
|
98
|
-
if (classNameChunk) {
|
|
99
|
-
className = className ? classNameChunk + ' ' + className : classNameChunk;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return className;
|
|
25
|
+
const [className, style] = (0, _styleq.styleq)(styles);
|
|
26
|
+
return {
|
|
27
|
+
className,
|
|
28
|
+
style
|
|
29
|
+
};
|
|
104
30
|
}
|
|
105
31
|
function stylexCreate(_styles) {
|
|
106
32
|
throw new Error('stylex.create should never be called. It should be compiled away.');
|
|
@@ -108,17 +34,39 @@ function stylexCreate(_styles) {
|
|
|
108
34
|
function stylexIncludes(_styles) {
|
|
109
35
|
throw new Error('stylex.extends should never be called. It should be compiled away.');
|
|
110
36
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
37
|
+
const create = stylexCreate;
|
|
38
|
+
exports.create = create;
|
|
39
|
+
const include = stylexIncludes;
|
|
40
|
+
exports.include = include;
|
|
41
|
+
const keyframes = _keyframes => {
|
|
114
42
|
throw new Error('stylex.keyframes should never be called');
|
|
115
43
|
};
|
|
116
|
-
|
|
44
|
+
exports.keyframes = keyframes;
|
|
45
|
+
const firstThatWorks = function () {
|
|
117
46
|
throw new Error('stylex.firstThatWorks should never be called.');
|
|
118
47
|
};
|
|
119
|
-
|
|
120
|
-
|
|
48
|
+
exports.firstThatWorks = firstThatWorks;
|
|
49
|
+
const inject = _stylexInject.default;
|
|
50
|
+
exports.inject = inject;
|
|
51
|
+
const UNSUPPORTED_PROPERTY = _props => {
|
|
121
52
|
throw new Error('stylex.UNSUPPORTED_PROPERTY should never be called. It should be compiled away.');
|
|
122
53
|
};
|
|
123
|
-
|
|
124
|
-
|
|
54
|
+
exports.UNSUPPORTED_PROPERTY = UNSUPPORTED_PROPERTY;
|
|
55
|
+
function _stylex() {
|
|
56
|
+
for (var _len2 = arguments.length, styles = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
57
|
+
styles[_key2] = arguments[_key2];
|
|
58
|
+
}
|
|
59
|
+
const [className] = (0, _styleq.styleq)(styles);
|
|
60
|
+
return className;
|
|
61
|
+
}
|
|
62
|
+
_stylex.spread = spread;
|
|
63
|
+
_stylex.create = create;
|
|
64
|
+
_stylex.include = include;
|
|
65
|
+
_stylex.keyframes = keyframes;
|
|
66
|
+
_stylex.firstThatWorks = firstThatWorks;
|
|
67
|
+
_stylex.inject = inject;
|
|
68
|
+
_stylex.UNSUPPORTED_PROPERTY = UNSUPPORTED_PROPERTY;
|
|
69
|
+
var _default = _stylex;
|
|
70
|
+
exports.default = _default;
|
|
71
|
+
const stylex = _stylex;
|
|
72
|
+
exports.stylex = stylex;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stylexjs/stylex",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0-beta.10",
|
|
4
4
|
"description": "A minimal runtime styling library for web.",
|
|
5
5
|
"main": "lib/stylex.js",
|
|
6
6
|
"types": "lib/stylex.d.ts",
|
|
@@ -14,10 +14,8 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"invariant": "^2.2.4",
|
|
17
|
-
"utility-types": "^3.10.0"
|
|
18
|
-
|
|
19
|
-
"devDependencies": {
|
|
20
|
-
"benchmark": "^2.1.4"
|
|
17
|
+
"utility-types": "^3.10.0",
|
|
18
|
+
"styleq": "0.1.3"
|
|
21
19
|
},
|
|
22
20
|
"jest": {},
|
|
23
21
|
"files": [
|