@hulla/style 0.2.0 → 0.2.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.
|
@@ -50,7 +50,7 @@ type VariantGroupAPI<V extends readonly VariantAPI<any>[]> = {
|
|
|
50
50
|
type StyleFunctions = {
|
|
51
51
|
cn: <const CN extends ClassName[]>(...classes: CN) => string;
|
|
52
52
|
};
|
|
53
|
-
type VariantProps<V
|
|
53
|
+
type VariantProps<V> = V extends VariantGroupAPI<infer G> ? GroupProps<G> : V extends VariantAPI<infer VD> ? APIPropsMapper<VariantAPI<VD>> : {};
|
|
54
54
|
|
|
55
55
|
declare function variantGroupBuilder<const V extends readonly VariantAPI<any>[]>(...variants: V): VariantGroupAPI<V>;
|
|
56
56
|
|
|
@@ -62,15 +62,15 @@ declare function style(config?: StyleConfig): {
|
|
|
62
62
|
name: N;
|
|
63
63
|
classes: V;
|
|
64
64
|
default: D;
|
|
65
|
-
base?: B
|
|
65
|
+
base?: B;
|
|
66
66
|
}): VariantAPI<Variant<N, V, D, B>>;
|
|
67
|
-
<
|
|
68
|
-
name:
|
|
69
|
-
classes:
|
|
70
|
-
base?:
|
|
67
|
+
<N extends string, V extends ClassesDefinition, B extends string = "">(variantDefinition: {
|
|
68
|
+
name: N;
|
|
69
|
+
classes: V;
|
|
70
|
+
base?: B;
|
|
71
71
|
} & {
|
|
72
72
|
default?: undefined;
|
|
73
|
-
}): VariantAPI<Variant<
|
|
73
|
+
}): VariantAPI<Variant<N, V, NO_DEFAULT, B>>;
|
|
74
74
|
};
|
|
75
75
|
};
|
|
76
76
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hulla/style",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Styling made easy 🎨",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Samuel Hulla",
|
|
@@ -19,14 +19,16 @@
|
|
|
19
19
|
"files": [
|
|
20
20
|
"dist"
|
|
21
21
|
],
|
|
22
|
+
"type": "module",
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"main": "./dist/cjs/index.cjs",
|
|
25
|
+
"module": "./dist/es/index.mjs",
|
|
22
26
|
"exports": {
|
|
23
|
-
"
|
|
24
|
-
"types": "./dist/
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"import": "./dist/es/index.mjs",
|
|
30
|
+
"require": "./dist/cjs/index.cjs",
|
|
25
31
|
"default": "./dist/es/index.mjs"
|
|
26
|
-
},
|
|
27
|
-
"require": {
|
|
28
|
-
"types": "./dist/cjs/index.d.ts",
|
|
29
|
-
"default": "./dist/cjs/index.js"
|
|
30
32
|
}
|
|
31
33
|
},
|
|
32
34
|
"devDependencies": {
|
package/dist/es/index.d.mts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
type ClassNameNonRecursive = string | string[] | null | undefined | false | true | boolean | 0 | 0n | typeof NaN;
|
|
2
|
-
type ClassesDefinition = Record<string, ClassNameNonRecursive | Record<string, any> | any[]>;
|
|
3
|
-
type Simplify<T> = {
|
|
4
|
-
[K in keyof T]: T[K];
|
|
5
|
-
} & {};
|
|
6
|
-
type KeysWithDefault<V extends readonly VariantAPI<any>[]> = {
|
|
7
|
-
[P in V[number]["params"] as P["name"]]: P["default"] extends undefined ? P["name"] : never;
|
|
8
|
-
}[V[number]["params"]["name"]];
|
|
9
|
-
type KeysWithoutDefault<V extends readonly VariantAPI<any>[]> = {
|
|
10
|
-
[P in V[number]["params"] as P["name"]]: P["default"] extends undefined ? never : P["name"];
|
|
11
|
-
}[V[number]["params"]["name"]];
|
|
12
|
-
type GroupProps<V extends readonly VariantAPI<any>[]> = Simplify<{
|
|
13
|
-
[P in KeysWithDefault<V>]: keyof Extract<V[number]["params"], {
|
|
14
|
-
name: P;
|
|
15
|
-
}>["classes"];
|
|
16
|
-
} & {
|
|
17
|
-
[P in KeysWithoutDefault<V>]?: keyof Extract<V[number]["params"], {
|
|
18
|
-
name: P;
|
|
19
|
-
}>["classes"];
|
|
20
|
-
}>;
|
|
21
|
-
type APIPropsMapper<V extends VariantAPI<any>> = V extends VariantAPI<Variant<infer N, infer VN, infer D, any>> ? D extends NO_DEFAULT ? {
|
|
22
|
-
[K in N]: keyof VN;
|
|
23
|
-
} : {
|
|
24
|
-
[K in N]?: keyof VN;
|
|
25
|
-
} : {};
|
|
26
|
-
|
|
27
|
-
type ClassName = ClassNameNonRecursive | Record<string, ClassNameNonRecursive>;
|
|
28
|
-
type Serializer = (input: ClassName) => string;
|
|
29
|
-
type Composer = (...strings: string[]) => string;
|
|
30
|
-
declare const NO_DEFAULT: unique symbol;
|
|
31
|
-
type NO_DEFAULT = typeof NO_DEFAULT;
|
|
32
|
-
type Variant<N extends string, V extends ClassesDefinition, D extends keyof V | NO_DEFAULT = NO_DEFAULT, B extends string = ""> = {
|
|
33
|
-
name: N;
|
|
34
|
-
classes: V;
|
|
35
|
-
base?: B;
|
|
36
|
-
default?: D extends NO_DEFAULT ? never : D;
|
|
37
|
-
};
|
|
38
|
-
type StyleConfig = {
|
|
39
|
-
serializer?: Serializer;
|
|
40
|
-
composer?: Composer;
|
|
41
|
-
};
|
|
42
|
-
type VariantAPI<V extends Variant<any, any, any, any>> = {
|
|
43
|
-
params: V;
|
|
44
|
-
css: V extends Variant<any, any, NO_DEFAULT, any> ? (prop: keyof V["classes"]) => string : (prop?: keyof V["classes"]) => string;
|
|
45
|
-
};
|
|
46
|
-
type VariantGroupAPI<V extends readonly VariantAPI<any>[]> = {
|
|
47
|
-
params: Record<V[number]["params"]["name"], VariantAPI<any>>;
|
|
48
|
-
css: (props: GroupProps<V>) => string;
|
|
49
|
-
};
|
|
50
|
-
type StyleFunctions = {
|
|
51
|
-
cn: <const CN extends ClassName[]>(...classes: CN) => string;
|
|
52
|
-
};
|
|
53
|
-
type VariantProps<V extends VariantAPI<any> | VariantGroupAPI<any>> = V extends VariantGroupAPI<infer G> ? GroupProps<G> : V extends VariantAPI<infer V> ? APIPropsMapper<VariantAPI<V>> : {};
|
|
54
|
-
|
|
55
|
-
declare function variantGroupBuilder<const V extends readonly VariantAPI<any>[]>(...variants: V): VariantGroupAPI<V>;
|
|
56
|
-
|
|
57
|
-
declare function style(config?: StyleConfig): {
|
|
58
|
-
cn: <const CN extends ClassName[]>(...classes: CN) => string;
|
|
59
|
-
variantGroup: typeof variantGroupBuilder;
|
|
60
|
-
variant: {
|
|
61
|
-
<N extends string, V extends ClassesDefinition, D extends keyof V & string, B extends string = "">(variantDefinition: {
|
|
62
|
-
name: N;
|
|
63
|
-
classes: V;
|
|
64
|
-
default: D;
|
|
65
|
-
base?: B | undefined;
|
|
66
|
-
}): VariantAPI<Variant<N, V, D, B>>;
|
|
67
|
-
<N_1 extends string, V_1 extends ClassesDefinition, B_1 extends string = "">(variantDefinition: {
|
|
68
|
-
name: N_1;
|
|
69
|
-
classes: V_1;
|
|
70
|
-
base?: B_1 | undefined;
|
|
71
|
-
} & {
|
|
72
|
-
default?: undefined;
|
|
73
|
-
}): VariantAPI<Variant<N_1, V_1, typeof NO_DEFAULT, B_1>>;
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
declare function defaultSerializer(input: ClassName): string;
|
|
78
|
-
|
|
79
|
-
declare function defaultComposer(...strings: string[]): string;
|
|
80
|
-
|
|
81
|
-
export { type ClassName, type Composer, NO_DEFAULT, type Serializer, type StyleConfig, type StyleFunctions, type Variant, type VariantAPI, type VariantGroupAPI, type VariantProps, defaultComposer, defaultSerializer, style };
|
|
File without changes
|