@plumeria/core 19.1.3 → 19.1.4

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/css.d.ts CHANGED
@@ -15,8 +15,9 @@
15
15
  declare module '@plumeria/core' {
16
16
  import type {
17
17
  AtomicClassNameFor,
18
+ AtomicClassStyleFor,
18
19
  AtomicStyle,
19
- AtomicDynamicStyle,
20
+ AtomicClassStyle,
20
21
  Style,
21
22
  StyleProps,
22
23
  StaticStyles,
@@ -36,8 +37,9 @@ declare module '@plumeria/core' {
36
37
 
37
38
  export type {
38
39
  AtomicClassNameFor,
40
+ AtomicClassStyleFor,
39
41
  AtomicStyle,
40
- AtomicDynamicStyle,
42
+ AtomicClassStyle,
41
43
  Style,
42
44
  StyleProps,
43
45
  StaticStyles,
package/lib/types.d.ts CHANGED
@@ -48,6 +48,7 @@ type CSSProperties =
48
48
  type CreateStyleValue = CSSProperties | ((...args: any[]) => CSSProperties);
49
49
 
50
50
  declare const ClassNameTag: unique symbol;
51
+ declare const ClassStyleTag: unique symbol;
51
52
 
52
53
  type AtomicClassNameFor<P extends string, V> = string & {
53
54
  readonly _ident: typeof ClassNameTag;
@@ -55,45 +56,59 @@ type AtomicClassNameFor<P extends string, V> = string & {
55
56
  readonly _value: V;
56
57
  };
57
58
 
58
- declare const StyleTag: unique symbol;
59
+ type AtomicClassStyleFor<P extends string, V> = AtomicClassNameFor<P, V> & {
60
+ readonly _classStyle: typeof ClassStyleTag;
61
+ };
59
62
 
60
63
  type AtomicStyle<T> = Readonly<{
61
- [key in keyof T]: T[key] extends Record<string, unknown>
62
- ? key extends NestedKey
63
- ? AtomicStyle<T[key]>
64
- : AtomicClassNameFor<key & string, T[key]>
65
- : key extends string
66
- ? AtomicClassNameFor<key, T[key]>
67
- : never;
68
- }> & {
69
- readonly [StyleTag]: true;
70
- };
64
+ [key in keyof T]: key extends string
65
+ ? T[key] extends AtomicClassNameFor<string, infer V>
66
+ ? AtomicClassNameFor<key, V>
67
+ : T[key] extends Record<string, unknown>
68
+ ? key extends NestedKey
69
+ ? AtomicStyle<T[key]>
70
+ : AtomicClassNameFor<key, T[key]>
71
+ : AtomicClassNameFor<key, T[key]>
72
+ : T[key];
73
+ }>;
74
+
75
+ type ClassStyled<T> = Readonly<{
76
+ readonly [key in keyof T]: T[key] extends AtomicClassNameFor<infer P, infer V>
77
+ ? AtomicClassStyleFor<P, V>
78
+ : ClassStyled<T[key]>;
79
+ }>;
71
80
 
72
- declare const DynamicTag: unique symbol;
81
+ type AtomicClassStyle<T> = ClassStyled<AtomicStyle<T>>;
73
82
 
74
- type AtomicDynamicStyle<T> = AtomicStyle<T> & {
75
- readonly [DynamicTag]: true;
76
- };
83
+ type StyleMap<T> = [T] extends [unknown]
84
+ ? Readonly<{
85
+ readonly [key in keyof T]: T[key] extends Record<string, unknown>
86
+ ? key extends NestedKey
87
+ ? StyleMap<T[key]>
88
+ : AtomicClassNameFor<key & string, T[key]>
89
+ : key extends string
90
+ ? AtomicClassNameFor<key, T[key]>
91
+ : never;
92
+ }>
93
+ : never;
77
94
 
78
95
  type CreateReturnType<T> = Readonly<{
79
96
  [K in keyof T]: T[K] extends (...args: infer A) => infer R
80
- ? (...args: A) => AtomicDynamicStyle<R>
81
- : AtomicStyle<T[K]>;
97
+ ? (...args: A) => ClassStyled<StyleMap<R>>
98
+ : StyleMap<T[K]>;
82
99
  }>;
83
- type FlatNamespace<K extends StyleKey> = {
100
+ type FlatNamespace<K extends StyleKey, M = unknown> = {
84
101
  readonly [P in StyleKey]?: P extends K
85
- ? AtomicClassNameFor<P & string, unknown>
102
+ ? AtomicClassNameFor<P & string, unknown> & M
86
103
  : never;
87
104
  };
88
105
 
89
- interface NestedNamespace<K extends StyleKey> {
90
- readonly [P: NestedKey]: AllowedNamespace<K> | undefined;
106
+ interface NestedNamespace<K extends StyleKey, M> {
107
+ readonly [P: NestedKey]: AllowedNamespace<K, M> | undefined;
91
108
  }
92
109
 
93
- type AllowedNamespace<K extends StyleKey> = FlatNamespace<K> &
94
- NestedNamespace<K> & {
95
- readonly [StyleTag]: true;
96
- };
110
+ type AllowedNamespace<K extends StyleKey, M = unknown> = FlatNamespace<K, M> &
111
+ NestedNamespace<K, M>;
97
112
 
98
113
  type StyleList<T> = T | false | null | undefined | StyleList<T>[];
99
114
 
@@ -104,9 +119,10 @@ type StyleProps<K extends StyleKey> = StyleList<AllowedNamespace<K>>;
104
119
 
105
120
  type WithoutProperties<K extends StyleKey> = StyleProps<Exclude<StyleKey, K>>;
106
121
 
107
- type StaticNamespace<K extends StyleKey> = AllowedNamespace<K> & {
108
- readonly [DynamicTag]?: never;
109
- };
122
+ type StaticNamespace<K extends StyleKey> = AllowedNamespace<
123
+ K,
124
+ { readonly _classStyle?: never }
125
+ >;
110
126
 
111
127
  type StaticStyles<K extends StyleKey = StyleKey> = StyleList<
112
128
  StaticNamespace<K>
@@ -147,8 +163,9 @@ type Marker = Readonly<Record<ColonString, CSSVariableProperty>>;
147
163
 
148
164
  export type {
149
165
  AtomicClassNameFor,
166
+ AtomicClassStyleFor,
150
167
  AtomicStyle,
151
- AtomicDynamicStyle,
168
+ AtomicClassStyle,
152
169
  Style,
153
170
  StyleProps,
154
171
  StaticStyles,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/core",
3
- "version": "19.1.3",
3
+ "version": "19.1.4",
4
4
  "description": "Zero-cost abstraction layer for styling React components.",
5
5
  "author": "Refirst 11",
6
6
  "license": "MIT",