@yaredfall/class-variants 0.1.2 → 0.5.0-rc
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/LICENSE +21 -0
- package/build/chunk-6DFTYFKO.js +2 -0
- package/build/chunk-6DFTYFKO.js.map +1 -0
- package/build/chunk-6Y37KLAC.js +2 -0
- package/build/chunk-6Y37KLAC.js.map +1 -0
- package/build/chunk-BSA7R4NK.js +2 -0
- package/build/chunk-BSA7R4NK.js.map +1 -0
- package/build/chunk-FIET564E.js +2 -0
- package/build/chunk-FIET564E.js.map +1 -0
- package/build/chunk-IMTFPGTY.js +2 -0
- package/build/chunk-IMTFPGTY.js.map +1 -0
- package/build/chunk-RNIIXHL2.js +2 -0
- package/build/chunk-RNIIXHL2.js.map +1 -0
- package/build/cn.cjs +2 -0
- package/build/cn.cjs.map +1 -0
- package/build/cn.d.cts +11 -0
- package/build/cn.d.ts +11 -0
- package/build/cn.js +2 -0
- package/build/cn.js.map +1 -0
- package/build/compose.cjs +2 -0
- package/build/compose.cjs.map +1 -0
- package/build/compose.d.cts +20 -0
- package/build/compose.d.ts +20 -0
- package/build/compose.js +2 -0
- package/build/compose.js.map +1 -0
- package/build/cv-BWSJNbxE.d.cts +84 -0
- package/build/cv-WFZM6Df-.d.ts +84 -0
- package/build/cv.cjs +2 -0
- package/build/cv.cjs.map +1 -0
- package/build/cv.d.cts +4 -0
- package/build/cv.d.ts +4 -0
- package/build/cv.js +2 -0
- package/build/cv.js.map +1 -0
- package/build/define.cjs +2 -0
- package/build/define.cjs.map +1 -0
- package/build/define.d.cts +15 -0
- package/build/define.d.ts +15 -0
- package/build/define.js +2 -0
- package/build/define.js.map +1 -0
- package/build/index.cjs +1 -1
- package/build/index.cjs.map +1 -1
- package/build/index.d.cts +11 -1
- package/build/index.d.ts +11 -1
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/build/tokens.cjs +2 -0
- package/build/tokens.cjs.map +1 -0
- package/build/tokens.d.cts +4 -0
- package/build/tokens.d.ts +4 -0
- package/build/tokens.js +2 -0
- package/build/tokens.js.map +1 -0
- package/build/utils.cjs +1 -1
- package/build/utils.cjs.map +1 -1
- package/build/utils.d.cts +2 -1
- package/build/utils.d.ts +2 -1
- package/build/utils.js +1 -1
- package/build/vue.cjs +1 -1
- package/build/vue.cjs.map +1 -1
- package/build/vue.d.cts +8 -5
- package/build/vue.d.ts +8 -5
- package/build/vue.js +1 -1
- package/build/vue.js.map +1 -1
- package/package.json +56 -57
- package/build/chunk-4SXOWWRN.js +0 -2
- package/build/chunk-4SXOWWRN.js.map +0 -1
- package/build/chunk-BV75ULQK.js +0 -2
- package/build/chunk-BV75ULQK.js.map +0 -1
- package/build/index-CFb2xboY.d.cts +0 -80
- package/build/index-CFb2xboY.d.ts +0 -80
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { ClassValue } from 'clsx';
|
|
2
|
-
import { Prettify, UnionToIntersection, DeepReadonly, DeepWritable, StrictExclude, MarkRequired, Opaque } from 'ts-essentials';
|
|
3
|
-
|
|
4
|
-
type KeysOf<O extends Record<string, unknown>> = (keyof O)[];
|
|
5
|
-
declare function getKeys<O extends Record<string, unknown>>(obj: O): KeysOf<O>;
|
|
6
|
-
type EntriesOf<O extends Record<string, unknown>> = {
|
|
7
|
-
[K in keyof O]: [K, O[K]];
|
|
8
|
-
};
|
|
9
|
-
declare function getEntries<O extends Record<string, unknown>>(obj: O): EntriesOf<O>[keyof EntriesOf<O>][];
|
|
10
|
-
type VariantOptions<V extends CVVariantsSchema> = {
|
|
11
|
-
[K in keyof V]: KeysOf<V[K]>;
|
|
12
|
-
};
|
|
13
|
-
declare function getVariantsOptions<V extends CVVariantsSchema>(variants: V): VariantOptions<V>;
|
|
14
|
-
type Entries = [PropertyKey, unknown][] | DeepReadonly<[PropertyKey, unknown][]>;
|
|
15
|
-
type UnionFromPairs<TArr extends Entries> = DeepWritable<TArr> extends (infer R)[] ? R extends [infer key, infer val] ? {
|
|
16
|
-
[prop in key & PropertyKey]: val;
|
|
17
|
-
} : never : never;
|
|
18
|
-
type MergeIntersectingObjects<O> = {
|
|
19
|
-
[K in keyof O]: O[K];
|
|
20
|
-
};
|
|
21
|
-
declare function objectFromEntries<E extends Entries>(entries: E): Prettify<MergeIntersectingObjects<UnionToIntersection<UnionFromPairs<E>>>>;
|
|
22
|
-
|
|
23
|
-
type VariantProps<CVR extends (args?: any) => string> = Prettify<Omit<NonNullable<StrictExclude<Parameters<CVR>[0], void>>, "class" | "className">>;
|
|
24
|
-
type ClassProp = {
|
|
25
|
-
class?: ClassValue;
|
|
26
|
-
className?: never;
|
|
27
|
-
} | {
|
|
28
|
-
class?: never;
|
|
29
|
-
className?: ClassValue;
|
|
30
|
-
};
|
|
31
|
-
type WithClassProp<T extends Record<string, any>> = T & ClassProp;
|
|
32
|
-
type BooleanStringToBoolean<T> = T extends "true" | "false" ? boolean : T;
|
|
33
|
-
type CVVariantsSchema = Record<string, Record<string, ClassValue>>;
|
|
34
|
-
type CVVariant<V extends CVVariantsSchema> = {
|
|
35
|
-
[K in keyof V]?: BooleanStringToBoolean<keyof V[K]>;
|
|
36
|
-
};
|
|
37
|
-
type CVCompoundVariant<V extends CVVariantsSchema> = WithClassProp<{
|
|
38
|
-
[K in keyof V]?: BooleanStringToBoolean<keyof V[K]> | BooleanStringToBoolean<keyof V[K]>[] | CVToken;
|
|
39
|
-
}>;
|
|
40
|
-
type CVCompoundVariantsSchema<V extends CVVariantsSchema> = CVCompoundVariant<V>[];
|
|
41
|
-
interface CVConfig<V extends CVVariantsSchema, R extends keyof V> {
|
|
42
|
-
base?: ClassValue;
|
|
43
|
-
variants?: V;
|
|
44
|
-
compoundVariants?: CVCompoundVariantsSchema<V> | ((arg: {
|
|
45
|
-
variants: V;
|
|
46
|
-
keys: KeysOf<V>;
|
|
47
|
-
options: VariantOptions<V>;
|
|
48
|
-
defaults: CVVariant<V>;
|
|
49
|
-
}) => CVCompoundVariantsSchema<V>);
|
|
50
|
-
defaultVariant?: CVVariant<V>;
|
|
51
|
-
requiredProps?: R[];
|
|
52
|
-
}
|
|
53
|
-
interface CVOptions {
|
|
54
|
-
merge?: (...args: ClassValue[]) => string;
|
|
55
|
-
}
|
|
56
|
-
type CVReturnProps<V extends CVVariantsSchema, R extends keyof V = never> = Prettify<WithClassProp<MarkRequired<CVVariant<V>, R>>> | ([R] extends [never] ? void : never);
|
|
57
|
-
interface CVReturn<V extends CVVariantsSchema, R extends keyof V = never> {
|
|
58
|
-
(props: CVReturnProps<V, R>): string;
|
|
59
|
-
keys: KeysOf<V>;
|
|
60
|
-
options: VariantOptions<V>;
|
|
61
|
-
defaults: CVVariant<V>;
|
|
62
|
-
}
|
|
63
|
-
interface CV {
|
|
64
|
-
<V extends CVVariantsSchema, R extends keyof V = never>(config: CVConfig<V, R>, cvOptions?: CVOptions): CVReturn<V, R>;
|
|
65
|
-
}
|
|
66
|
-
declare const cv: CV;
|
|
67
|
-
declare function defineCV(options: CVOptions): CV;
|
|
68
|
-
type OnlyWhenDefined = Opaque<{
|
|
69
|
-
__token: string;
|
|
70
|
-
}, "OnlyWhenDefined">;
|
|
71
|
-
type OnlyWhenUndefined = Opaque<{
|
|
72
|
-
__token: string;
|
|
73
|
-
}, "OnlyWhenUndefined">;
|
|
74
|
-
type CVToken = OnlyWhenDefined | OnlyWhenUndefined;
|
|
75
|
-
/** Apply compound variant only if prop **is** specified */
|
|
76
|
-
declare const onlyWhenDefined: OnlyWhenDefined;
|
|
77
|
-
/** Apply compound variant only if prop **is not** specified */
|
|
78
|
-
declare const onlyWhenUndefined: OnlyWhenUndefined;
|
|
79
|
-
|
|
80
|
-
export { type CVVariantsSchema as C, type EntriesOf as E, type KeysOf as K, type VariantOptions as V, type WithClassProp as W, type CVReturn as a, type CVConfig as b, type CVOptions as c, getEntries as d, getVariantsOptions as e, type VariantProps as f, getKeys as g, type CVVariant as h, type CVCompoundVariant as i, type CVCompoundVariantsSchema as j, type CV as k, cv as l, defineCV as m, onlyWhenDefined as n, objectFromEntries as o, onlyWhenUndefined as p };
|