@stylexjs/stylex 0.1.0-beta.6 → 0.2.0-beta.8

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/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 StyleXNamespaceSet>(
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
- ? StyleXClassNameFor<P, S[K][P]>
46
+ ? ClassNameFor<P, S[K][P]>
47
47
  : {
48
- readonly [F in keyof S[K][P]]: StyleXClassNameFor<
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 StyleXNamespaceSet>(
65
- animationConfig: S
66
- ) => string;
59
+ type Stylex$Keyframes = <S extends NamespaceSet>(animationConfig: S) => string;
67
60
 
68
- type stylex = {
61
+ type NestedArray<T> = T | Array<T | NestedArray<T>>;
62
+
63
+ declare let stylex: {
69
64
  (
70
65
  ...styles: ReadonlyArray<
71
- StyleXArray<(CompiledNamespace | null | undefined) | boolean>
66
+ NestedArray<(CompiledNamespace | null | undefined) | boolean>
72
67
  >
73
68
  ): string;
74
69
  create: Stylex$Create;
package/lib/stylex.js CHANGED
@@ -55,27 +55,13 @@ function stylex() {
55
55
  for (const prop in styleObj) {
56
56
  const value = styleObj[prop];
57
57
  // Style declarations, e.g., opacity: 's3fkgpd'
58
- if (typeof value === 'string') {
58
+ if (typeof value === 'string' || value === null) {
59
59
  // Skip adding to the chunks if property has already been seen
60
60
  if (!definedProperties.includes(prop)) {
61
61
  definedProperties.push(prop);
62
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;
63
+ if (typeof value === 'string') {
64
+ classNameChunk += classNameChunk ? ' ' + value : value;
79
65
  }
80
66
  }
81
67
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stylexjs/stylex",
3
- "version": "0.1.0-beta.6",
3
+ "version": "0.2.0-beta.8",
4
4
  "description": "A minimal runtime styling library for web.",
5
5
  "main": "lib/stylex.js",
6
6
  "types": "lib/stylex.d.ts",