@plumeria/core 13.1.0 → 13.1.2
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 +5 -5
- package/lib/css.d.ts +7 -6
- package/lib/types.d.ts +18 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# @plumeria/core
|
|
2
2
|
|
|
3
|
-

|
|
4
|
+

|
|
5
5
|
|
|
6
|
-

|
|
7
|
+

|
|
8
|
+

|
|
9
9
|
|
|
10
10
|
**Plumeria** is a **zero-cost abstraction layer** for styling React components without JavaScript. Its axioms are grounded in category theory, making it self-evident, predictable, and composable by construction. It enforces strict syntax and linting to reduce the cognitive overhead for engineers.
|
|
11
11
|
|
package/lib/css.d.ts
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
* Bundler plugin required.
|
|
4
4
|
* ```ts
|
|
5
5
|
* type create = <const T extends Record<string, CreateStyleValue>>(rule: T)=> CreateReturnType<T>;
|
|
6
|
+
* type variants = <T extends Variants>(rule: T) => (props: { [K in keyof T]?: keyof T[K] }) => VariantStyles<T>;
|
|
6
7
|
* type createTheme = <const T extends CreateTheme>(themeSelector: string, rule: T) => CreateThemeReturnType<T>;
|
|
7
8
|
* type createStatic = <const T extends CreateStatic>(rule: T)=> T;
|
|
8
9
|
* type keyframes = <const T extends Keyframes>(rule: T) => string;
|
|
9
10
|
* type viewTransition = <const T extends ViewTransition>(rule: T) => string;
|
|
10
|
-
* type variants = <T extends Variants>(rule: T) => (props: { [K in keyof T]?: keyof T[K] }) => CSSProperties;
|
|
11
11
|
* type marker = (id: string, pseudo: string) => Marker;
|
|
12
12
|
* type extended = <I extends string, P extends string>(id: I, pseudo: P) => Extended<I, P>;
|
|
13
13
|
* type use = (...rules: (false | CSSProperties | null | undefined)[])=> string;
|
|
@@ -23,6 +23,7 @@ declare module '@plumeria/core' {
|
|
|
23
23
|
CreateThemeReturnType,
|
|
24
24
|
CreateStatic,
|
|
25
25
|
Variants,
|
|
26
|
+
VariantStyles,
|
|
26
27
|
Keyframes,
|
|
27
28
|
ViewTransition,
|
|
28
29
|
Marker,
|
|
@@ -44,6 +45,11 @@ declare module '@plumeria/core' {
|
|
|
44
45
|
rule: T,
|
|
45
46
|
) => CreateReturnType<T>;
|
|
46
47
|
|
|
48
|
+
export const variants: variants;
|
|
49
|
+
export type variants = <T extends Variants>(
|
|
50
|
+
rule: T,
|
|
51
|
+
) => (props: { [K in keyof T]?: keyof T[K] }) => VariantStyles<T>;
|
|
52
|
+
|
|
47
53
|
export const createTheme: createTheme;
|
|
48
54
|
export type createTheme = <const T extends CreateTheme>(
|
|
49
55
|
themeSelector: string,
|
|
@@ -61,11 +67,6 @@ declare module '@plumeria/core' {
|
|
|
61
67
|
rule: T,
|
|
62
68
|
) => string;
|
|
63
69
|
|
|
64
|
-
export const variants: variants;
|
|
65
|
-
export type variants = <T extends Variants>(
|
|
66
|
-
rule: T,
|
|
67
|
-
) => (props: { [K in keyof T]?: keyof T[K] }) => CSSProperties;
|
|
68
|
-
|
|
69
70
|
export const marker: marker;
|
|
70
71
|
export type marker = (id: string, pseudo: string) => Marker;
|
|
71
72
|
|
package/lib/types.d.ts
CHANGED
|
@@ -91,6 +91,23 @@ type ViewTransition = {
|
|
|
91
91
|
|
|
92
92
|
type Variants = Record<string, Record<string, CSSProperties>>;
|
|
93
93
|
|
|
94
|
+
type AllOptionsOf<T> = {
|
|
95
|
+
[G in keyof T]: T[G][keyof T[G]];
|
|
96
|
+
}[keyof T];
|
|
97
|
+
|
|
98
|
+
type KeysOfUnion<U> = U extends unknown ? keyof U : never;
|
|
99
|
+
type ValueForKeyInUnion<U, K> = U extends unknown
|
|
100
|
+
? K extends keyof U
|
|
101
|
+
? U[K]
|
|
102
|
+
: never
|
|
103
|
+
: never;
|
|
104
|
+
|
|
105
|
+
type MergeVariants<U> = Readonly<{
|
|
106
|
+
[K in KeysOfUnion<U>]?: ValueForKeyInUnion<U, K>;
|
|
107
|
+
}>;
|
|
108
|
+
|
|
109
|
+
type VariantStyles<T> = MergeVariants<AllOptionsOf<T>>;
|
|
110
|
+
|
|
94
111
|
type Marker = Record<string, CSSProperties>;
|
|
95
112
|
|
|
96
113
|
type StripColon<T extends string> = T extends `:${infer R}` ? StripColon<R> : T;
|
|
@@ -109,6 +126,7 @@ export type {
|
|
|
109
126
|
CreateThemeReturnType,
|
|
110
127
|
CreateStatic,
|
|
111
128
|
Variants,
|
|
129
|
+
VariantStyles,
|
|
112
130
|
Keyframes,
|
|
113
131
|
ViewTransition,
|
|
114
132
|
Marker,
|