@stylexjs/stylex 0.2.0-beta.13 → 0.2.0-beta.14

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.
@@ -172,3 +172,31 @@ export type Stylex$Create = <S extends {}>(
172
172
  * | ^^^^^^^^^^^^^^^^^^^^^^^^^ Unsupported feature: Translating "$ObjMap" is currently not supported.
173
173
  **/
174
174
  any>;
175
+ export declare type StyleXVarsTheme<
176
+ Vars extends { readonly [$$Key$$: string]: string }
177
+ > = Vars;
178
+ export type Stylex$CreateVars = <
179
+ Vars extends { readonly [$$Key$$: string]: string }
180
+ >(
181
+ styles: Vars,
182
+ config?: { themeName: string }
183
+ ) => StyleXVarsTheme<
184
+ Readonly</**
185
+ * > 129 | ) => StyleXVarsTheme<$ReadOnly<$ObjMapConst<Vars, string>>>;
186
+ * | ^^^^^^^^^^^^^^^^^^^^^^^^^^ Unsupported feature: Translating "$ObjMapConst" is currently not supported.
187
+ **/
188
+ any>
189
+ >;
190
+ export type Stylex$OverrideVars = <
191
+ Vars extends { readonly [$$Key$$: string]: string }
192
+ >(
193
+ styles: Vars & { __themeName__: string },
194
+ stylesOverride: Vars,
195
+ config?: { themeName: string }
196
+ ) => StyleXVarsTheme<
197
+ Readonly</**
198
+ * > 135 | ) => StyleXVarsTheme<$ReadOnly<$ObjMapConst<Vars, string>>>;
199
+ * | ^^^^^^^^^^^^^^^^^^^^^^^^^^ Unsupported feature: Translating "$ObjMapConst" is currently not supported.
200
+ **/
201
+ any>
202
+ >;
@@ -119,3 +119,17 @@ export type MapNamespaces = <CSS: { ... }>(CSS) => MapNamespace<CSS>;
119
119
  export type Stylex$Create = <S: { ... }>(
120
120
  styles: S
121
121
  ) => $ReadOnly<$ObjMap<S, MapNamespaces>>;
122
+
123
+ // This is the type for the variables object
124
+ declare export opaque type StyleXVarsTheme<+Vars: { +[string]: string }>: Vars;
125
+
126
+ export type Stylex$CreateVars = <+Vars: { +[string]: string }>(
127
+ styles: Vars,
128
+ config?: { themeName: string }
129
+ ) => StyleXVarsTheme<$ReadOnly<$ObjMapConst<Vars, string>>>;
130
+
131
+ export type Stylex$OverrideVars = <+Vars: { +[string]: string }>(
132
+ styles: Vars & { __themeName__: string },
133
+ stylesOverride: Vars,
134
+ config?: { themeName: string }
135
+ ) => StyleXVarsTheme<$ReadOnly<$ObjMapConst<Vars, string>>>;
package/lib/stylex.d.ts CHANGED
@@ -10,6 +10,8 @@
10
10
  import type {
11
11
  Keyframes,
12
12
  Stylex$Create,
13
+ Stylex$CreateVars,
14
+ Stylex$OverrideVars,
13
15
  StyleXArray,
14
16
  MapNamespace,
15
17
  } from './StyleXTypes';
@@ -21,16 +23,21 @@ export declare function spread(
21
23
  styles: StyleXArray<
22
24
  | (null | undefined | DedupeStyles)
23
25
  | boolean
24
- | { [$$Key$$: string]: string | number }
26
+ | Readonly<{ $$css?: void; [$$Key$$: string]: string | number }>
25
27
  >,
26
28
  _options?: {}
27
- ): { className: string; style: { [$$Key$$: string]: string | number } };
29
+ ): Readonly<{
30
+ className: string;
31
+ style: Readonly<{ $$css?: void; [$$Key$$: string]: string | number }>;
32
+ }>;
28
33
  type Stylex$Include = <
29
34
  TStyles extends { readonly [$$Key$$: string]: string | number }
30
35
  >(
31
36
  _styles: MapNamespace<TStyles>
32
37
  ) => TStyles;
33
38
  export declare var create: Stylex$Create;
39
+ export declare var unstable_createVars: Stylex$CreateVars;
40
+ export declare var unstable_overrideVars: Stylex$OverrideVars;
34
41
  export declare var include: Stylex$Include;
35
42
  export declare var keyframes: (_keyframes: Keyframes) => string;
36
43
  export declare var firstThatWorks: <T extends string | number>(
@@ -45,12 +52,19 @@ type IStyleX = {
45
52
  >
46
53
  ): string;
47
54
  spread: (
48
- styles: ReadonlyArray<
49
- StyleXArray<(null | undefined | DedupeStyles) | boolean>
55
+ styles: StyleXArray<
56
+ | (null | undefined | DedupeStyles)
57
+ | boolean
58
+ | Readonly<{ $$css?: void; [$$Key$$: string]: string | number }>
50
59
  >,
51
- options?: {}
52
- ) => { className: string; style: { [$$Key$$: string]: string | number } };
60
+ _options?: {}
61
+ ) => Readonly<{
62
+ className: string;
63
+ style: Readonly<{ $$css?: void; [$$Key$$: string]: string | number }>;
64
+ }>;
53
65
  create: Stylex$Create;
66
+ unstable_createVars: Stylex$CreateVars;
67
+ unstable_overrideVars: Stylex$OverrideVars;
54
68
  include: Stylex$Include;
55
69
  firstThatWorks: <T extends string | number>(
56
70
  ...v: ReadonlyArray<T>
package/lib/stylex.js CHANGED
@@ -14,7 +14,7 @@ Object.defineProperty(exports, "__esModule", {
14
14
  });
15
15
  exports.keyframes = exports.inject = exports.include = exports.firstThatWorks = exports.default = exports.create = exports.UNSUPPORTED_PROPERTY = void 0;
16
16
  exports.spread = spread;
17
- exports.stylex = void 0;
17
+ exports.unstable_overrideVars = exports.unstable_createVars = exports.stylex = void 0;
18
18
  var _stylexInject = _interopRequireDefault(require("./stylex-inject"));
19
19
  var _styleq = require("styleq");
20
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -28,11 +28,21 @@ function spread(styles, _options) {
28
28
  function stylexCreate(_styles) {
29
29
  throw new Error('stylex.create should never be called. It should be compiled away.');
30
30
  }
31
+ function stylexCreateVars(_styles) {
32
+ throw new Error('stylex.createVars should never be called. It should be compiled away.');
33
+ }
34
+ function stylexOverrideVars(_styles) {
35
+ throw new Error('stylex.overrideVars should never be called. It should be compiled away.');
36
+ }
31
37
  function stylexIncludes(_styles) {
32
38
  throw new Error('stylex.extends should never be called. It should be compiled away.');
33
39
  }
34
40
  const create = stylexCreate;
35
41
  exports.create = create;
42
+ const unstable_createVars = stylexCreateVars;
43
+ exports.unstable_createVars = unstable_createVars;
44
+ const unstable_overrideVars = stylexOverrideVars;
45
+ exports.unstable_overrideVars = unstable_overrideVars;
36
46
  const include = stylexIncludes;
37
47
  exports.include = include;
38
48
  const keyframes = _keyframes => {
@@ -58,6 +68,8 @@ function _stylex() {
58
68
  }
59
69
  _stylex.spread = spread;
60
70
  _stylex.create = create;
71
+ _stylex.unstable_createVars = unstable_createVars;
72
+ _stylex.unstable_overrideVars = unstable_overrideVars;
61
73
  _stylex.include = include;
62
74
  _stylex.keyframes = keyframes;
63
75
  _stylex.firstThatWorks = firstThatWorks;
@@ -10,6 +10,8 @@
10
10
  import type {
11
11
  Keyframes,
12
12
  Stylex$Create,
13
+ Stylex$CreateVars,
14
+ Stylex$OverrideVars,
13
15
  StyleXArray,
14
16
  MapNamespace,
15
17
  } from './StyleXTypes';
@@ -21,9 +23,16 @@ type DedupeStyles = $ReadOnly<{
21
23
  }>;
22
24
 
23
25
  declare export function spread(
24
- styles: StyleXArray<?DedupeStyles | boolean | { [string]: string | number }>,
26
+ styles: StyleXArray<
27
+ | ?DedupeStyles
28
+ | boolean
29
+ | $ReadOnly<{ $$css?: void, [string]: string | number }>
30
+ >,
25
31
  _options?: { ... }
26
- ): { className: string, style: { [string]: string | number } };
32
+ ): $ReadOnly<{
33
+ className: string,
34
+ style: $ReadOnly<{ $$css?: void, [string]: string | number }>,
35
+ }>;
27
36
 
28
37
  type Stylex$Include = <TStyles: { +[string]: string | number }>(
29
38
  _styles: MapNamespace<TStyles>
@@ -31,6 +40,10 @@ type Stylex$Include = <TStyles: { +[string]: string | number }>(
31
40
 
32
41
  declare export var create: Stylex$Create;
33
42
 
43
+ declare export var unstable_createVars: Stylex$CreateVars;
44
+
45
+ declare export var unstable_overrideVars: Stylex$OverrideVars;
46
+
34
47
  declare export var include: Stylex$Include;
35
48
 
36
49
  declare export var keyframes: (_keyframes: Keyframes) => string;
@@ -46,13 +59,19 @@ declare export var UNSUPPORTED_PROPERTY: <T>(_props: T) => T;
46
59
  type IStyleX = {
47
60
  (...styles: $ReadOnlyArray<StyleXArray<?DedupeStyles | boolean>>): string,
48
61
  spread: (
49
- styles: $ReadOnlyArray<StyleXArray<?DedupeStyles | boolean>>,
50
- options?: { ... }
51
- ) => {
62
+ styles: StyleXArray<
63
+ | ?DedupeStyles
64
+ | boolean
65
+ | $ReadOnly<{ $$css?: void, [string]: string | number }>
66
+ >,
67
+ _options?: { ... }
68
+ ) => $ReadOnly<{
52
69
  className: string,
53
- style: { [string]: string | number },
54
- },
70
+ style: $ReadOnly<{ $$css?: void, [string]: string | number }>,
71
+ }>,
55
72
  create: Stylex$Create,
73
+ unstable_createVars: Stylex$CreateVars,
74
+ unstable_overrideVars: Stylex$OverrideVars,
56
75
  include: Stylex$Include,
57
76
  firstThatWorks: <T: string | number>(
58
77
  ...v: $ReadOnlyArray<T>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stylexjs/stylex",
3
- "version": "0.2.0-beta.13",
3
+ "version": "0.2.0-beta.14",
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.13"
23
+ "@stylexjs/scripts": "0.2.0-beta.14"
24
24
  },
25
25
  "jest": {},
26
26
  "files": [