@stylexjs/shared 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -21,7 +21,7 @@ function styleXDefineVars(variables, options) {
21
21
  const themeNameHash = classNamePrefix + (0, _hash.default)(themeName);
22
22
  const typedVariables = {};
23
23
  const variablesMap = (0, _objectUtils.objMap)(variables, (value, key) => {
24
- const nameHash = classNamePrefix + (0, _hash.default)(`${themeName}.${key}`);
24
+ const nameHash = key.startsWith('--') ? key.slice(2) : classNamePrefix + (0, _hash.default)(`${themeName}.${key}`);
25
25
  if ((0, _types.isCSSType)(value)) {
26
26
  const v = value;
27
27
  typedVariables[nameHash] = {
@@ -49,19 +49,21 @@ export interface CSSType<_T extends string | number = string | number> {
49
49
  export declare const isCSSType: (
50
50
  value: unknown,
51
51
  ) => value is CSSType<string | number>;
52
- type AnguleValue = string;
53
- export declare class Angle<T extends AnguleValue>
52
+ type AngleValue = string;
53
+ export declare class Angle<T extends AngleValue>
54
54
  extends BaseCSSType
55
55
  implements CSSType<T>
56
56
  {
57
57
  readonly value: ValueWithDefault;
58
58
  readonly syntax: CSSSyntaxType;
59
59
  static readonly syntax: CSSSyntaxType;
60
- static create<T extends AnguleValue = AnguleValue>(
60
+ static create<T extends AngleValue = AngleValue>(
61
61
  value: ValueWithDefault,
62
62
  ): Angle<T>;
63
63
  }
64
- export declare const angle: any;
64
+ export declare const angle: <T extends AngleValue = AngleValue>(
65
+ value: ValueWithDefault,
66
+ ) => Angle<T>;
65
67
  type ColorValue = string;
66
68
  export declare class Color<T extends ColorValue>
67
69
  extends BaseCSSType
@@ -73,7 +75,9 @@ export declare class Color<T extends ColorValue>
73
75
  value: ValueWithDefault,
74
76
  ): Color<T>;
75
77
  }
76
- export declare const color: any;
78
+ export declare const color: <T extends ColorValue = ColorValue>(
79
+ value: ValueWithDefault,
80
+ ) => Color<T>;
77
81
  type URLValue = string;
78
82
  export declare class Url<T extends URLValue>
79
83
  extends BaseCSSType
@@ -83,7 +87,9 @@ export declare class Url<T extends URLValue>
83
87
  readonly syntax: CSSSyntaxType;
84
88
  static create<T extends URLValue = URLValue>(value: ValueWithDefault): Url<T>;
85
89
  }
86
- export declare const url: any;
90
+ export declare const url: <T extends URLValue = URLValue>(
91
+ value: ValueWithDefault,
92
+ ) => Url<T>;
87
93
  type ImageValue = string;
88
94
  export declare class Image<T extends ImageValue>
89
95
  extends Url<T>
@@ -96,7 +102,9 @@ export declare class Image<T extends ImageValue>
96
102
  value: ValueWithDefault,
97
103
  ): Image<T>;
98
104
  }
99
- export declare const image: any;
105
+ export declare const image: <T extends ImageValue = ImageValue>(
106
+ value: ValueWithDefault,
107
+ ) => Image<T>;
100
108
  type IntegerValue = number;
101
109
  export declare class Integer<T extends IntegerValue>
102
110
  extends BaseCSSType
@@ -106,7 +114,9 @@ export declare class Integer<T extends IntegerValue>
106
114
  readonly syntax: CSSSyntaxType;
107
115
  static create<T extends IntegerValue = IntegerValue>(value: T): Integer<T>;
108
116
  }
109
- export declare const integer: any;
117
+ export declare const integer: <T extends IntegerValue = IntegerValue>(
118
+ value: T,
119
+ ) => Integer<T>;
110
120
  type LengthPercentageValue = string;
111
121
  export declare class LengthPercentage<_T extends LengthPercentageValue>
112
122
  extends BaseCSSType
@@ -121,7 +131,11 @@ export declare class LengthPercentage<_T extends LengthPercentageValue>
121
131
  value: ValueWithDefault,
122
132
  ): LengthPercentage<string>;
123
133
  }
124
- export declare const lengthPercentage: any;
134
+ export declare const lengthPercentage: <
135
+ _T extends LengthPercentageValue | number,
136
+ >(
137
+ value: ValueWithDefault,
138
+ ) => LengthPercentage<string>;
125
139
  type LengthValue = number | string;
126
140
  export declare class Length<_T extends LengthValue>
127
141
  extends LengthPercentage<string>
@@ -133,7 +147,9 @@ export declare class Length<_T extends LengthValue>
133
147
  value: NestedWithNumbers,
134
148
  ): Length<T>;
135
149
  }
136
- export declare const length: any;
150
+ export declare const length: <T extends LengthValue = LengthValue>(
151
+ value: NestedWithNumbers,
152
+ ) => Length<T>;
137
153
  type PercentageValue = string | number;
138
154
  export declare class Percentage<_T extends PercentageValue>
139
155
  extends LengthPercentage<string>
@@ -145,7 +161,9 @@ export declare class Percentage<_T extends PercentageValue>
145
161
  value: NestedWithNumbers,
146
162
  ): Percentage<T>;
147
163
  }
148
- export declare const percentage: any;
164
+ export declare const percentage: <T extends PercentageValue = PercentageValue>(
165
+ value: NestedWithNumbers,
166
+ ) => Percentage<T>;
149
167
  type NumberValue = number;
150
168
  export declare class Num<T extends NumberValue>
151
169
  extends BaseCSSType
@@ -157,7 +175,9 @@ export declare class Num<T extends NumberValue>
157
175
  value: NestedWithNumbers,
158
176
  ): Num<T>;
159
177
  }
160
- export declare const number: any;
178
+ export declare const number: <T extends NumberValue = NumberValue>(
179
+ value: NestedWithNumbers,
180
+ ) => Num<T>;
161
181
  type ResolutionValue = string | 0;
162
182
  export declare class Resolution<T extends ResolutionValue>
163
183
  extends BaseCSSType
@@ -169,7 +189,9 @@ export declare class Resolution<T extends ResolutionValue>
169
189
  value: ValueWithDefault,
170
190
  ): Resolution<T>;
171
191
  }
172
- export declare const resolution: any;
192
+ export declare const resolution: <T extends ResolutionValue = ResolutionValue>(
193
+ value: ValueWithDefault,
194
+ ) => Resolution<T>;
173
195
  type TimeValue = string | 0;
174
196
  export declare class Time<T extends TimeValue>
175
197
  extends BaseCSSType
@@ -181,7 +203,9 @@ export declare class Time<T extends TimeValue>
181
203
  value: ValueWithDefault,
182
204
  ): Time<T>;
183
205
  }
184
- export declare const time: any;
206
+ export declare const time: <T extends TimeValue = TimeValue>(
207
+ value: ValueWithDefault,
208
+ ) => Time<T>;
185
209
  type TransformFunctionValue = string;
186
210
  export declare class TransformFunction<T extends TransformFunctionValue>
187
211
  extends BaseCSSType
@@ -193,7 +217,11 @@ export declare class TransformFunction<T extends TransformFunctionValue>
193
217
  value: ValueWithDefault,
194
218
  ): TransformFunction<T>;
195
219
  }
196
- export declare const transformFunction: any;
220
+ export declare const transformFunction: <
221
+ T extends TransformFunctionValue = TransformFunctionValue,
222
+ >(
223
+ value: ValueWithDefault,
224
+ ) => TransformFunction<T>;
197
225
  type TransformListValue = string;
198
226
  export declare class TransformList<T extends TransformListValue>
199
227
  extends BaseCSSType
@@ -205,4 +233,8 @@ export declare class TransformList<T extends TransformListValue>
205
233
  value: ValueWithDefault,
206
234
  ): TransformList<T>;
207
235
  }
208
- export declare const transformList: any;
236
+ export declare const transformList: <
237
+ T extends TransformListValue = TransformListValue,
238
+ >(
239
+ value: ValueWithDefault,
240
+ ) => TransformList<T>;
@@ -67,19 +67,20 @@ declare export const isCSSType: (
67
67
  value: mixed,
68
68
  ) => value is CSSType<string | number>;
69
69
 
70
- type AnguleValue = string;
71
- declare export class Angle<+T: AnguleValue>
70
+ type AngleValue = string;
71
+ declare export class Angle<+T: AngleValue>
72
72
  extends BaseCSSType
73
73
  implements CSSType<T>
74
74
  {
75
75
  +value: ValueWithDefault;
76
76
  +syntax: CSSSyntaxType;
77
77
  static +syntax: CSSSyntaxType;
78
- static create<T: AnguleValue = AnguleValue>(
79
- value: ValueWithDefault,
80
- ): Angle<T>;
78
+ static create<T: AngleValue = AngleValue>(value: ValueWithDefault): Angle<T>;
81
79
  }
82
- declare export const angle: $FlowFixMe;
80
+ declare export const angle: <T: AngleValue = AngleValue>(
81
+ value: ValueWithDefault,
82
+ // $FlowIgnore[method-unbinding]
83
+ ) => Angle<T>;
83
84
 
84
85
  type ColorValue = string;
85
86
  declare export class Color<+T: ColorValue>
@@ -90,7 +91,10 @@ declare export class Color<+T: ColorValue>
90
91
  +syntax: CSSSyntaxType;
91
92
  static create<T: ColorValue = ColorValue>(value: ValueWithDefault): Color<T>;
92
93
  }
93
- declare export const color: $FlowFixMe;
94
+ declare export const color: <T: ColorValue = ColorValue>(
95
+ value: ValueWithDefault,
96
+ // $FlowIgnore[method-unbinding]
97
+ ) => Color<T>;
94
98
 
95
99
  type URLValue = string;
96
100
 
@@ -102,7 +106,9 @@ declare export class Url<+T: URLValue>
102
106
  +syntax: CSSSyntaxType;
103
107
  static create<T: URLValue = URLValue>(value: ValueWithDefault): Url<T>;
104
108
  }
105
- declare export const url: $FlowFixMe;
109
+ declare export const url: <T: URLValue = URLValue>(
110
+ value: ValueWithDefault,
111
+ ) => Url<T>;
106
112
 
107
113
  type ImageValue = string;
108
114
 
@@ -115,7 +121,10 @@ declare export class Image<+T: ImageValue>
115
121
  constructor(value: ValueWithDefault): void;
116
122
  static create<T: ImageValue = ImageValue>(value: ValueWithDefault): Image<T>;
117
123
  }
118
- declare export const image: $FlowFixMe;
124
+ declare export const image: <T: ImageValue = ImageValue>(
125
+ value: ValueWithDefault,
126
+ // $FlowIgnore[method-unbinding]
127
+ ) => Image<T>;
119
128
 
120
129
  type IntegerValue = number;
121
130
 
@@ -127,7 +136,9 @@ declare export class Integer<+T: IntegerValue>
127
136
  +syntax: CSSSyntaxType;
128
137
  static create<T: IntegerValue = IntegerValue>(value: T): Integer<T>;
129
138
  }
130
- declare export const integer: $FlowFixMe;
139
+ declare export const integer: <T: IntegerValue = IntegerValue>(
140
+ value: T,
141
+ ) => Integer<T>;
131
142
 
132
143
  type LengthPercentageValue = string;
133
144
 
@@ -144,7 +155,10 @@ declare export class LengthPercentage<+_T: LengthPercentageValue>
144
155
  value: ValueWithDefault,
145
156
  ): LengthPercentage<string>;
146
157
  }
147
- declare export const lengthPercentage: $FlowFixMe;
158
+ declare export const lengthPercentage: <_T: LengthPercentageValue | number>(
159
+ value: ValueWithDefault,
160
+ // $FlowIgnore[method-unbinding]
161
+ ) => LengthPercentage<string>;
148
162
 
149
163
  type LengthValue = number | string;
150
164
 
@@ -158,7 +172,10 @@ declare export class Length<+_T: LengthValue>
158
172
  value: NestedWithNumbers,
159
173
  ): Length<T>;
160
174
  }
161
- declare export const length: $FlowFixMe;
175
+ declare export const length: <T: LengthValue = LengthValue>(
176
+ value: NestedWithNumbers,
177
+ // $FlowIgnore[method-unbinding]
178
+ ) => Length<T>;
162
179
 
163
180
  type PercentageValue = string | number;
164
181
 
@@ -172,7 +189,10 @@ declare export class Percentage<+_T: PercentageValue>
172
189
  value: NestedWithNumbers,
173
190
  ): Percentage<T>;
174
191
  }
175
- declare export const percentage: $FlowFixMe;
192
+ declare export const percentage: <T: PercentageValue = PercentageValue>(
193
+ value: NestedWithNumbers,
194
+ // $FlowIgnore[method-unbinding]
195
+ ) => Percentage<T>;
176
196
 
177
197
  type NumberValue = number;
178
198
 
@@ -184,7 +204,10 @@ declare export class Num<+T: NumberValue>
184
204
  +syntax: CSSSyntaxType;
185
205
  static create<T: NumberValue = NumberValue>(value: NestedWithNumbers): Num<T>;
186
206
  }
187
- declare export const number: $FlowFixMe;
207
+ declare export const number: <T: NumberValue = NumberValue>(
208
+ value: NestedWithNumbers,
209
+ // $FlowIgnore[method-unbinding]
210
+ ) => Num<T>;
188
211
 
189
212
  type ResolutionValue = string | 0;
190
213
 
@@ -198,7 +221,10 @@ declare export class Resolution<+T: ResolutionValue>
198
221
  value: ValueWithDefault,
199
222
  ): Resolution<T>;
200
223
  }
201
- declare export const resolution: $FlowFixMe;
224
+ declare export const resolution: <T: ResolutionValue = ResolutionValue>(
225
+ value: ValueWithDefault,
226
+ // $FlowIgnore[method-unbinding]
227
+ ) => Resolution<T>;
202
228
 
203
229
  type TimeValue = string | 0;
204
230
 
@@ -210,7 +236,10 @@ declare export class Time<+T: TimeValue>
210
236
  +syntax: CSSSyntaxType;
211
237
  static create<T: TimeValue = TimeValue>(value: ValueWithDefault): Time<T>;
212
238
  }
213
- declare export const time: $FlowFixMe;
239
+ declare export const time: <T: TimeValue = TimeValue>(
240
+ value: ValueWithDefault,
241
+ // $FlowIgnore[method-unbinding]
242
+ ) => Time<T>;
214
243
 
215
244
  type TransformFunctionValue = string;
216
245
 
@@ -224,7 +253,12 @@ declare export class TransformFunction<+T: TransformFunctionValue>
224
253
  value: ValueWithDefault,
225
254
  ): TransformFunction<T>;
226
255
  }
227
- declare export const transformFunction: $FlowFixMe;
256
+ declare export const transformFunction: <
257
+ T: TransformFunctionValue = TransformFunctionValue,
258
+ >(
259
+ value: ValueWithDefault,
260
+ // $FlowIgnore[method-unbinding]
261
+ ) => TransformFunction<T>;
228
262
 
229
263
  type TransformListValue = string;
230
264
 
@@ -238,4 +272,9 @@ declare export class TransformList<T: TransformListValue>
238
272
  value: ValueWithDefault,
239
273
  ): TransformList<T>;
240
274
  }
241
- declare export const transformList: $FlowFixMe;
275
+ declare export const transformList: <
276
+ T: TransformListValue = TransformListValue,
277
+ >(
278
+ value: ValueWithDefault,
279
+ // $FlowIgnore[method-unbinding]
280
+ ) => TransformList<T>;
@@ -9,11 +9,12 @@ var _leadingZero = _interopRequireDefault(require("./normalizers/leading-zero"))
9
9
  var _quotes = _interopRequireDefault(require("./normalizers/quotes"));
10
10
  var _timings = _interopRequireDefault(require("./normalizers/timings"));
11
11
  var _whitespace = _interopRequireDefault(require("./normalizers/whitespace"));
12
+ var _zeroDimensions = _interopRequireDefault(require("./normalizers/zero-dimensions"));
12
13
  var _detectUnclosedFns = _interopRequireDefault(require("./normalizers/detect-unclosed-fns"));
13
14
  var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
14
15
  var _convertCamelCaseValues = _interopRequireDefault(require("./normalizers/convert-camel-case-values"));
15
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
- const normalizers = [_detectUnclosedFns.default, _whitespace.default, _timings.default, _leadingZero.default, _quotes.default, _convertCamelCaseValues.default];
17
+ const normalizers = [_detectUnclosedFns.default, _whitespace.default, _timings.default, _zeroDimensions.default, _leadingZero.default, _quotes.default, _convertCamelCaseValues.default];
17
18
  function normalizeValue(value, key, _ref) {
18
19
  let {
19
20
  useRemForFontSize
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stylexjs/shared",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "main": "lib/index.js",
5
5
  "repository": "https://www.github.com/facebook/stylex",
6
6
  "license": "MIT",
@@ -13,7 +13,7 @@
13
13
  "postcss-value-parser": "^4.1.0"
14
14
  },
15
15
  "devDependencies": {
16
- "@stylexjs/scripts": "0.6.0"
16
+ "@stylexjs/scripts": "0.7.0"
17
17
  },
18
18
  "jest": {
19
19
  "snapshotFormat": {