responsive-class-variants 1.3.1 → 1.3.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.
@@ -0,0 +1,38 @@
1
+ import type { CompoundVariantWithSlots, DefaultBreakpoints, ResponsiveClassesConfig, ResponsiveClassesConfigSlots, ResponsiveValue, SlotConfig, VariantConfig, VariantProps } from "./types.js";
2
+ /**
3
+ * Maps a ResponsiveValue to a new ResponsiveValue using the provided mapper function. Singular values are passed through as is.
4
+ *
5
+ * @template V The type of the original value
6
+ * @template T The type of the mapped value
7
+ * @template B The type of breakpoints
8
+ * @param {ResponsiveValue<V, B>} value - The original ResponsiveValue to be mapped
9
+ * @param {function(V): T} mapper - A function that maps a ResponsiveValue to a new ResponsiveValue
10
+ * @returns {ResponsiveValue<T, B>} A new ResponsiveValue with the mapped values
11
+ *
12
+ *
13
+ * @example
14
+ * const sizes = {
15
+ * initial: 'md',
16
+ * sm: 'lg',
17
+ * }
18
+ *
19
+ * const output = mapResponsiveValue(sizes, size => {
20
+ * switch (size) {
21
+ * case 'initial':
22
+ * return 'sm';
23
+ * case 'sm':
24
+ * return 'md';
25
+ * }
26
+ * });
27
+ *
28
+ * // console.log(output)
29
+ * {
30
+ * initial: 'sm',
31
+ * sm: 'md',
32
+ * }
33
+ */
34
+ export declare const mapResponsiveValue: <V, T, B extends string = DefaultBreakpoints>(value: ResponsiveValue<V, B>, mapper: (value: V) => T) => ResponsiveValue<T, B>;
35
+ export declare const isSlotsConfig: <T extends VariantConfig, B extends string>(config: ResponsiveClassesConfig<T, B>) => config is ResponsiveClassesConfigSlots<T, Record<string, SlotConfig>, B>;
36
+ export declare const processVariantProps: <T extends VariantConfig, B extends string>(props: Omit<VariantProps<T, B>, "className" | "class">, variants: T | undefined, slotName?: string) => (string | (string | undefined)[] | undefined)[];
37
+ export declare const matchesCompoundVariant: <T extends VariantConfig, B extends string>(compound: Omit<CompoundVariantWithSlots<T, string, B>, "className" | "class">, props: Omit<VariantProps<T, B>, "className" | "class">) => boolean;
38
+ export declare const createSlotFunction: <T extends VariantConfig, B extends string>(slotConfig: SlotConfig, variants: T | undefined, compoundVariants: CompoundVariantWithSlots<T, string, B>[] | undefined, onComplete: ((classes: string) => string) | undefined, slotName: string) => ({ className, class: classFromProps, ...props }?: VariantProps<T, B>) => string;
@@ -0,0 +1,139 @@
1
+ import { clsx } from "clsx";
2
+ const isSingularValue = (value) => !isBreakpointsMap(value);
3
+ const isBreakpointsMap = (value) => typeof value === "object" && value != null && !Array.isArray(value);
4
+ /**
5
+ * Maps a ResponsiveValue to a new ResponsiveValue using the provided mapper function. Singular values are passed through as is.
6
+ *
7
+ * @template V The type of the original value
8
+ * @template T The type of the mapped value
9
+ * @template B The type of breakpoints
10
+ * @param {ResponsiveValue<V, B>} value - The original ResponsiveValue to be mapped
11
+ * @param {function(V): T} mapper - A function that maps a ResponsiveValue to a new ResponsiveValue
12
+ * @returns {ResponsiveValue<T, B>} A new ResponsiveValue with the mapped values
13
+ *
14
+ *
15
+ * @example
16
+ * const sizes = {
17
+ * initial: 'md',
18
+ * sm: 'lg',
19
+ * }
20
+ *
21
+ * const output = mapResponsiveValue(sizes, size => {
22
+ * switch (size) {
23
+ * case 'initial':
24
+ * return 'sm';
25
+ * case 'sm':
26
+ * return 'md';
27
+ * }
28
+ * });
29
+ *
30
+ * // console.log(output)
31
+ * {
32
+ * initial: 'sm',
33
+ * sm: 'md',
34
+ * }
35
+ */
36
+ export const mapResponsiveValue = (value, mapper) => {
37
+ if (isSingularValue(value)) {
38
+ return mapper(value);
39
+ }
40
+ const result = {};
41
+ for (const key of Object.keys(value)) {
42
+ result[key] = mapper(value[key]);
43
+ }
44
+ return result;
45
+ };
46
+ // Helper functions for slots
47
+ export const isSlotsConfig = (config) => {
48
+ return "slots" in config;
49
+ };
50
+ const normalizeClassValue = (value) => {
51
+ if (Array.isArray(value)) {
52
+ return value.join(" ");
53
+ }
54
+ if (typeof value === "string") {
55
+ return value;
56
+ }
57
+ return undefined;
58
+ };
59
+ const prefixClasses = (classes, prefix) => classes.replace(/(\S+)/g, `${prefix}:$1`);
60
+ // Helper function to get variant value for a specific slot or base
61
+ const getVariantValue = (variants, key, value, slotName) => {
62
+ const variantValue = variants?.[key]?.[value];
63
+ // Early return if no variant value found
64
+ if (variantValue == null)
65
+ return undefined;
66
+ // Handle string or array values directly
67
+ if (typeof variantValue === "string" || Array.isArray(variantValue)) {
68
+ return normalizeClassValue(variantValue);
69
+ }
70
+ // Handle slot-specific values (object with slot keys)
71
+ if (slotName && slotName in variantValue) {
72
+ return normalizeClassValue(variantValue[slotName]);
73
+ }
74
+ return undefined;
75
+ };
76
+ // Helper function to process responsive values
77
+ const processResponsiveValue = (variants, key, value, slotName) => {
78
+ return Object.entries(value).map(([breakpoint, breakpointValue]) => {
79
+ const variantValue = getVariantValue(variants, key, breakpointValue, slotName);
80
+ if (!variantValue)
81
+ return undefined;
82
+ // If the breakpoint is initial, return without prefix
83
+ if (breakpoint === "initial") {
84
+ return variantValue;
85
+ }
86
+ // Otherwise, return with breakpoint prefix
87
+ return prefixClasses(variantValue, breakpoint);
88
+ });
89
+ };
90
+ // Helper function to process variant props into classes
91
+ export const processVariantProps = (props, variants, slotName) => {
92
+ return Object.entries(props).map(([key, propValue]) => {
93
+ const value = typeof propValue === "boolean" ? String(propValue) : propValue;
94
+ // Handle undefined values
95
+ if (!value)
96
+ return undefined;
97
+ // Handle singular values
98
+ if (typeof value === "string") {
99
+ return getVariantValue(variants, key, value, slotName);
100
+ }
101
+ // Handle responsive values
102
+ return processResponsiveValue(variants, key, value, slotName);
103
+ });
104
+ };
105
+ // Helper function to match compound variants
106
+ export const matchesCompoundVariant = (compound, props) => {
107
+ return Object.entries(compound).every(([key, value]) => {
108
+ const propValue = props[key];
109
+ // Direct comparison first, then try string conversion for boolean handling
110
+ return propValue === value || propValue === String(value);
111
+ });
112
+ };
113
+ // Helper function to extract class value from compound variant class prop
114
+ const getCompoundVariantSlotClass = (classValue, slotName) => {
115
+ if (!classValue)
116
+ return undefined;
117
+ if (typeof classValue === "object" && classValue[slotName]) {
118
+ return normalizeClassValue(classValue[slotName]);
119
+ }
120
+ if (typeof classValue === "string") {
121
+ return classValue;
122
+ }
123
+ return undefined;
124
+ };
125
+ export const createSlotFunction = (slotConfig, variants, compoundVariants, onComplete, slotName) => ({ className, class: classFromProps, ...props } = {}) => {
126
+ const responsiveClasses = processVariantProps(props, variants, slotName);
127
+ const compoundClasses = compoundVariants?.map(({ class: classFromCompound, className: classNameFromCompound, ...compound }) => {
128
+ if (matchesCompoundVariant(compound, props)) {
129
+ return [
130
+ getCompoundVariantSlotClass(classFromCompound, slotName),
131
+ getCompoundVariantSlotClass(classNameFromCompound, slotName),
132
+ ];
133
+ }
134
+ return undefined;
135
+ });
136
+ const classes = clsx(slotConfig, responsiveClasses, compoundClasses, className, classFromProps);
137
+ return onComplete ? onComplete(classes) : classes;
138
+ };
139
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"/","sources":["helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAe5B,MAAM,eAAe,GAAG,CACvB,KAA4B,EACf,EAAE,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;AAE1C,MAAM,gBAAgB,GAAG,CACxB,KAA4B,EACI,EAAE,CAClC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CACjC,KAA4B,EAC5B,MAAuB,EACC,EAAE;IAC1B,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;IAED,MAAM,MAAM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H,MAAM,iBAAiB,GAAG,mBAAmB,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAEzE,MAAM,eAAe,GAAG,gBAAgB,EAAE,GAAG,CAC5C,CAAC,EACA,KAAK,EAAE,iBAAiB,EACxB,SAAS,EAAE,qBAAqB,EAChC,GAAG,QAAQ,EACX,EAAE,EAAE;QACJ,IAAI,sBAAsB,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC;YAC7C,OAAO;gBACN,2BAA2B,CAAC,iBAAiB,EAAE,QAAQ,CAAC;gBACxD,2BAA2B,CAAC,qBAAqB,EAAE,QAAQ,CAAC;aAC5D,CAAC;QACH,CAAC;QACD,OAAO,SAAS,CAAC;IAClB,CAAC,CACD,CAAC;IAEF,MAAM,OAAO,GAAG,IAAI,CACnB,UAAU,EACV,iBAAiB,EACjB,eAAe,EACf,SAAS,EACT,cAAc,CACd,CAAC;IACF,OAAO,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AACnD,CAAC,CAAC","sourcesContent":["import { clsx } from \"clsx\";\nimport type {\n\tBreakpointsMap,\n\tCompoundVariantClassValue,\n\tCompoundVariantWithSlots,\n\tDefaultBreakpoints,\n\tResponsiveClassesConfig,\n\tResponsiveClassesConfigSlots,\n\tResponsiveValue,\n\tSlotConfig,\n\tVariantConfig,\n\tVariantProps,\n\tVariantPropValue,\n} from \"./types\";\n\nconst isSingularValue = <A, B extends string>(\n\tvalue: ResponsiveValue<A, B>,\n): value is A => !isBreakpointsMap(value);\n\nconst isBreakpointsMap = <A, B extends string>(\n\tvalue: ResponsiveValue<A, B>,\n): value is BreakpointsMap<A, B> =>\n\ttypeof value === \"object\" && value != null && !Array.isArray(value);\n\n/**\n * Maps a ResponsiveValue to a new ResponsiveValue using the provided mapper function. Singular values are passed through as is.\n *\n * @template V The type of the original value\n * @template T The type of the mapped value\n * @template B The type of breakpoints\n * @param {ResponsiveValue<V, B>} value - The original ResponsiveValue to be mapped\n * @param {function(V): T} mapper - A function that maps a ResponsiveValue to a new ResponsiveValue\n * @returns {ResponsiveValue<T, B>} A new ResponsiveValue with the mapped values\n *\n *\n * @example\n * const sizes = {\n * initial: 'md',\n * sm: 'lg',\n * }\n *\n * const output = mapResponsiveValue(sizes, size => {\n *\tswitch (size) {\n *\t\tcase 'initial':\n *\t\treturn 'sm';\n *\t\tcase 'sm':\n *\t\t\treturn 'md';\n *\t\t}\n *\t});\n *\n * // console.log(output)\n * {\n *\tinitial: 'sm',\n *\tsm: 'md',\n * }\n */\nexport const mapResponsiveValue = <V, T, B extends string = DefaultBreakpoints>(\n\tvalue: ResponsiveValue<V, B>,\n\tmapper: (value: V) => T,\n): ResponsiveValue<T, B> => {\n\tif (isSingularValue(value)) {\n\t\treturn mapper(value);\n\t}\n\n\tconst result: Record<string, T> = {};\n\tfor (const key of Object.keys(value)) {\n\t\tresult[key] = mapper(value[key as keyof typeof value] as V);\n\t}\n\treturn result as BreakpointsMap<T, B>;\n};\n\n// Helper functions for slots\nexport const isSlotsConfig = <T extends VariantConfig, B extends string>(\n\tconfig: ResponsiveClassesConfig<T, B>,\n): config is ResponsiveClassesConfigSlots<T, Record<string, SlotConfig>, B> => {\n\treturn \"slots\" in config;\n};\n\nconst normalizeClassValue = (\n\tvalue: string | ReadonlyArray<string> | undefined,\n) => {\n\tif (Array.isArray(value)) {\n\t\treturn value.join(\" \");\n\t}\n\tif (typeof value === \"string\") {\n\t\treturn value;\n\t}\n\treturn undefined;\n};\n\nconst prefixClasses = (classes: string, prefix: string) =>\n\tclasses.replace(/(\\S+)/g, `${prefix}:$1`);\n\n// Helper function to get variant value for a specific slot or base\nconst getVariantValue = <T extends VariantConfig>(\n\tvariants: T | undefined,\n\tkey: keyof T,\n\tvalue: string,\n\tslotName?: string,\n): string | undefined => {\n\tconst variantValue = variants?.[key]?.[value];\n\n\t// Early return if no variant value found\n\tif (variantValue == null) return undefined;\n\n\t// Handle string or array values directly\n\tif (typeof variantValue === \"string\" || Array.isArray(variantValue)) {\n\t\treturn normalizeClassValue(variantValue);\n\t}\n\n\t// Handle slot-specific values (object with slot keys)\n\tif (slotName && slotName in variantValue) {\n\t\treturn normalizeClassValue(\n\t\t\t(variantValue as Record<string, string | ReadonlyArray<string>>)[\n\t\t\t\tslotName\n\t\t\t],\n\t\t);\n\t}\n\n\treturn undefined;\n};\n\n// Helper function to process responsive values\nconst processResponsiveValue = <T extends VariantConfig, B extends string>(\n\tvariants: T | undefined,\n\tkey: keyof T,\n\tvalue: Partial<BreakpointsMap<T, B>>,\n\tslotName?: string,\n) => {\n\treturn Object.entries(value).map(([breakpoint, breakpointValue]) => {\n\t\tconst variantValue = getVariantValue(\n\t\t\tvariants,\n\t\t\tkey,\n\t\t\tbreakpointValue as string,\n\t\t\tslotName,\n\t\t);\n\n\t\tif (!variantValue) return undefined;\n\n\t\t// If the breakpoint is initial, return without prefix\n\t\tif (breakpoint === \"initial\") {\n\t\t\treturn variantValue;\n\t\t}\n\n\t\t// Otherwise, return with breakpoint prefix\n\t\treturn prefixClasses(variantValue, breakpoint);\n\t});\n};\n\n// Helper function to process variant props into classes\nexport const processVariantProps = <T extends VariantConfig, B extends string>(\n\tprops: Omit<VariantProps<T, B>, \"className\" | \"class\">,\n\tvariants: T | undefined,\n\tslotName?: string,\n) => {\n\treturn Object.entries(props).map(\n\t\t([key, propValue]: [keyof T, VariantPropValue<T[keyof T], B>]) => {\n\t\t\tconst value =\n\t\t\t\ttypeof propValue === \"boolean\" ? String(propValue) : propValue;\n\n\t\t\t// Handle undefined values\n\t\t\tif (!value) return undefined;\n\n\t\t\t// Handle singular values\n\t\t\tif (typeof value === \"string\") {\n\t\t\t\treturn getVariantValue(variants, key, value, slotName);\n\t\t\t}\n\n\t\t\t// Handle responsive values\n\t\t\treturn processResponsiveValue(\n\t\t\t\tvariants,\n\t\t\t\tkey,\n\t\t\t\tvalue as Partial<BreakpointsMap<T, B>>,\n\t\t\t\tslotName,\n\t\t\t);\n\t\t},\n\t);\n};\n\n// Helper function to match compound variants\nexport const matchesCompoundVariant = <\n\tT extends VariantConfig,\n\tB extends string,\n>(\n\tcompound: Omit<CompoundVariantWithSlots<T, string, B>, \"className\" | \"class\">,\n\tprops: Omit<VariantProps<T, B>, \"className\" | \"class\">,\n) => {\n\treturn Object.entries(compound).every(([key, value]) => {\n\t\tconst propValue = props[key as keyof typeof props];\n\t\t// Direct comparison first, then try string conversion for boolean handling\n\t\treturn propValue === value || propValue === String(value);\n\t});\n};\n\n// Helper function to extract class value from compound variant class prop\nconst getCompoundVariantSlotClass = <S extends string>(\n\tclassValue: CompoundVariantClassValue<S> | undefined,\n\tslotName: string,\n): string | undefined => {\n\tif (!classValue) return undefined;\n\n\tif (typeof classValue === \"object\" && classValue[slotName as S]) {\n\t\treturn normalizeClassValue(classValue[slotName as S]);\n\t}\n\n\tif (typeof classValue === \"string\") {\n\t\treturn classValue;\n\t}\n\n\treturn undefined;\n};\n\nexport const createSlotFunction =\n\t<T extends VariantConfig, B extends string>(\n\t\tslotConfig: SlotConfig,\n\t\tvariants: T | undefined,\n\t\tcompoundVariants: CompoundVariantWithSlots<T, string, B>[] | undefined,\n\t\tonComplete: ((classes: string) => string) | undefined,\n\t\tslotName: string,\n\t) =>\n\t(\n\t\t{\n\t\t\tclassName,\n\t\t\tclass: classFromProps,\n\t\t\t...props\n\t\t}: VariantProps<T, B> = {} as VariantProps<T, B>,\n\t) => {\n\t\tconst responsiveClasses = processVariantProps(props, variants, slotName);\n\n\t\tconst compoundClasses = compoundVariants?.map(\n\t\t\t({\n\t\t\t\tclass: classFromCompound,\n\t\t\t\tclassName: classNameFromCompound,\n\t\t\t\t...compound\n\t\t\t}) => {\n\t\t\t\tif (matchesCompoundVariant(compound, props)) {\n\t\t\t\t\treturn [\n\t\t\t\t\t\tgetCompoundVariantSlotClass(classFromCompound, slotName),\n\t\t\t\t\t\tgetCompoundVariantSlotClass(classNameFromCompound, slotName),\n\t\t\t\t\t];\n\t\t\t\t}\n\t\t\t\treturn undefined;\n\t\t\t},\n\t\t);\n\n\t\tconst classes = clsx(\n\t\t\tslotConfig,\n\t\t\tresponsiveClasses,\n\t\t\tcompoundClasses,\n\t\t\tclassName,\n\t\t\tclassFromProps,\n\t\t);\n\t\treturn onComplete ? onComplete(classes) : classes;\n\t};\n"]}
package/dist/index.d.ts CHANGED
@@ -1,117 +1,3 @@
1
- export type DefaultBreakpoints = "sm" | "md" | "lg" | "xl";
2
- export type Breakpoints = DefaultBreakpoints;
3
- export type BreakpointsMap<V, B extends string = DefaultBreakpoints> = {
4
- initial: V;
5
- } & Partial<{
6
- [breakpoint in B]: V;
7
- }>;
8
- export type ResponsiveValue<T, B extends string = DefaultBreakpoints> = T | BreakpointsMap<T, B>;
9
- /**
10
- * Maps a ResponsiveValue to a new ResponsiveValue using the provided mapper function. Singular values are passed through as is.
11
- *
12
- * @template V The type of the original value
13
- * @template T The type of the mapped value
14
- * @template B The type of breakpoints
15
- * @param {ResponsiveValue<V, B>} value - The original ResponsiveValue to be mapped
16
- * @param {function(V): T} mapper - A function that maps a ResponsiveValue to a new ResponsiveValue
17
- * @returns {ResponsiveValue<T, B>} A new ResponsiveValue with the mapped values
18
- *
19
- *
20
- * @example
21
- * const sizes = {
22
- * initial: 'md',
23
- * sm: 'lg',
24
- * }
25
- *
26
- * const output = mapResponsiveValue(sizes, size => {
27
- * switch (size) {
28
- * case 'initial':
29
- * return 'sm';
30
- * case 'sm':
31
- * return 'md';
32
- * }
33
- * });
34
- *
35
- * // console.log(output)
36
- * {
37
- * initial: 'sm',
38
- * sm: 'md',
39
- * }
40
- */
41
- export declare const mapResponsiveValue: <V, T, B extends string = DefaultBreakpoints>(value: ResponsiveValue<V, B>, mapper: (value: V) => T) => ResponsiveValue<T, B>;
42
- /**
43
- * Start of rcv and types
44
- */
45
- type ClassValue = string | ReadonlyArray<string>;
46
- type ValueType = ClassValue | Record<string, ClassValue>;
47
- type VariantValue = Record<string, ValueType>;
48
- type VariantConfig = Record<string, VariantValue>;
49
- type StringBoolean = "true" | "false";
50
- type BooleanVariant = Partial<Record<StringBoolean, ClassValue | Record<string, ClassValue>>>;
51
- type VariantPropValue<T, B extends string> = T extends BooleanVariant ? ResponsiveValue<boolean, B> | undefined : T extends Record<string, unknown> ? ResponsiveValue<keyof T, B> : never;
52
- type VariantPropsBase<T extends VariantConfig, B extends string> = {
53
- [K in keyof T]?: VariantPropValue<T[K], B>;
54
- };
55
- type VariantProps<T extends VariantConfig, B extends string> = VariantPropsBase<T, B> & {
56
- className?: string;
57
- class?: string;
58
- };
59
- type SlotConfig = ClassValue;
60
- type CompoundVariantClassValue<S extends string> = string | Partial<Record<S, ClassValue>>;
61
- type CompoundVariantWithSlots<T extends VariantConfig, S extends string, B extends string> = Partial<Omit<VariantProps<T, B>, "class" | "className">> & {
62
- class?: CompoundVariantClassValue<S>;
63
- className?: CompoundVariantClassValue<S>;
64
- };
65
- export declare function rcv<T extends VariantConfig = Record<never, VariantValue>, S extends Record<string, SlotConfig> = Record<string, SlotConfig>, B extends string = DefaultBreakpoints>(config: {
66
- slots: S;
67
- variants?: T;
68
- compoundVariants?: CompoundVariantWithSlots<T, keyof S & string, B>[];
69
- onComplete?: (classes: string) => string;
70
- }): () => {
71
- [K in keyof S]: (props?: VariantProps<T, B>) => string;
72
- };
73
- export declare function rcv<T extends VariantConfig = Record<never, VariantValue>, B extends string = DefaultBreakpoints>(config: {
74
- base: string;
75
- variants?: T;
76
- compoundVariants?: Partial<VariantProps<T, B>>[];
77
- onComplete?: (classes: string) => string;
78
- }): (props?: VariantProps<T, B>) => string;
79
- /**
80
- * Creates a custom rcv function with custom breakpoints and an optional onComplete callback
81
- *
82
- * @template B - The custom breakpoints type
83
- * @param breakpoints - Optional array of custom breakpoint names
84
- * @param onComplete - Optional callback function that receives the generated classes and returns the final classes
85
- * @returns A function that creates rcv with custom breakpoints
86
- *
87
- * @example
88
- * const customRcv = createRcv(['mobile', 'tablet', 'desktop']);
89
- *
90
- * const getButtonVariants = customRcv({
91
- * base: "px-4 py-2 rounded",
92
- * variants: {
93
- * intent: {
94
- * primary: "bg-blue-500 text-white",
95
- * secondary: "bg-gray-200 text-gray-800"
96
- * }
97
- * }
98
- * });
99
- *
100
- * // Usage with custom breakpoints:
101
- * getButtonVariants({ intent: { initial: "primary", mobile: "secondary", desktop: "primary" } })
102
- */
103
- export declare const createRcv: <B extends string>(_breakpoints?: readonly B[], onComplete?: (classes: string) => string) => {
104
- <T extends VariantConfig = Record<never, VariantValue>, S extends Record<string, SlotConfig> = Record<string, ClassValue>>(config: {
105
- slots: S;
106
- variants?: T;
107
- compoundVariants?: CompoundVariantWithSlots<T, keyof S & string, B>[];
108
- onComplete?: (classes: string) => string;
109
- }): () => { [K in keyof S]: (props?: VariantProps<T, B>) => string; };
110
- <T extends VariantConfig = Record<never, VariantValue>>(config: {
111
- base: string;
112
- variants?: T;
113
- compoundVariants?: Partial<VariantProps<T, B>>[];
114
- onComplete?: (classes: string) => string;
115
- }): (props?: VariantProps<T, B>) => string;
116
- };
117
- export {};
1
+ export { mapResponsiveValue } from "./helpers.js";
2
+ export { createRcv, rcv } from "./rcv.js";
3
+ export type { Breakpoints, BreakpointsMap, DefaultBreakpoints, ResponsiveValue, } from "./types.js";
package/dist/index.js CHANGED
@@ -1,208 +1,3 @@
1
- import { clsx } from "clsx";
2
- const isSingularValue = (value) => !isBreakpointsMap(value);
3
- const isBreakpointsMap = (value) => typeof value === "object" && value != null && !Array.isArray(value);
4
- /**
5
- * Maps a ResponsiveValue to a new ResponsiveValue using the provided mapper function. Singular values are passed through as is.
6
- *
7
- * @template V The type of the original value
8
- * @template T The type of the mapped value
9
- * @template B The type of breakpoints
10
- * @param {ResponsiveValue<V, B>} value - The original ResponsiveValue to be mapped
11
- * @param {function(V): T} mapper - A function that maps a ResponsiveValue to a new ResponsiveValue
12
- * @returns {ResponsiveValue<T, B>} A new ResponsiveValue with the mapped values
13
- *
14
- *
15
- * @example
16
- * const sizes = {
17
- * initial: 'md',
18
- * sm: 'lg',
19
- * }
20
- *
21
- * const output = mapResponsiveValue(sizes, size => {
22
- * switch (size) {
23
- * case 'initial':
24
- * return 'sm';
25
- * case 'sm':
26
- * return 'md';
27
- * }
28
- * });
29
- *
30
- * // console.log(output)
31
- * {
32
- * initial: 'sm',
33
- * sm: 'md',
34
- * }
35
- */
36
- export const mapResponsiveValue = (value, mapper) => {
37
- if (isSingularValue(value)) {
38
- return mapper(value);
39
- }
40
- const result = {};
41
- for (const key of Object.keys(value)) {
42
- result[key] = mapper(value[key]);
43
- }
44
- return result;
45
- };
46
- // Helper functions for slots
47
- const isSlotsConfig = (config) => {
48
- return "slots" in config;
49
- };
50
- const normalizeClassValue = (value) => {
51
- if (Array.isArray(value)) {
52
- return value.join(" ");
53
- }
54
- if (typeof value === "string") {
55
- return value;
56
- }
57
- return undefined;
58
- };
59
- const prefixClasses = (classes, prefix) => classes.replace(/(\S+)/g, `${prefix}:$1`);
60
- // Helper function to get variant value for a specific slot or base
61
- const getVariantValue = (variants, key, value, slotName) => {
62
- const variantValue = variants?.[key]?.[value];
63
- // Early return if no variant value found
64
- if (variantValue == null)
65
- return undefined;
66
- // Handle string or array values directly
67
- if (typeof variantValue === "string" || Array.isArray(variantValue)) {
68
- return normalizeClassValue(variantValue);
69
- }
70
- // Handle slot-specific values (object with slot keys)
71
- if (slotName && slotName in variantValue) {
72
- return normalizeClassValue(variantValue[slotName]);
73
- }
74
- return undefined;
75
- };
76
- // Helper function to process responsive values
77
- const processResponsiveValue = (variants, key, value, slotName) => {
78
- return Object.entries(value).map(([breakpoint, breakpointValue]) => {
79
- const variantValue = getVariantValue(variants, key, breakpointValue, slotName);
80
- if (!variantValue)
81
- return undefined;
82
- // If the breakpoint is initial, return without prefix
83
- if (breakpoint === "initial") {
84
- return variantValue;
85
- }
86
- // Otherwise, return with breakpoint prefix
87
- return prefixClasses(variantValue, breakpoint);
88
- });
89
- };
90
- // Helper function to process variant props into classes
91
- const processVariantProps = (props, variants, slotName) => {
92
- return Object.entries(props).map(([key, propValue]) => {
93
- const value = typeof propValue === "boolean" ? String(propValue) : propValue;
94
- // Handle undefined values
95
- if (!value)
96
- return undefined;
97
- // Handle singular values
98
- if (typeof value === "string") {
99
- return getVariantValue(variants, key, value, slotName);
100
- }
101
- // Handle responsive values
102
- return processResponsiveValue(variants, key, value, slotName);
103
- });
104
- };
105
- // Helper function to match compound variants
106
- const matchesCompoundVariant = (compound, props) => {
107
- return Object.entries(compound).every(([key, value]) => {
108
- const propValue = props[key];
109
- // Direct comparison first, then try string conversion for boolean handling
110
- return propValue === value || propValue === String(value);
111
- });
112
- };
113
- // Helper function to extract class value from compound variant class prop
114
- const getCompoundVariantSlotClass = (classValue, slotName) => {
115
- if (!classValue)
116
- return undefined;
117
- if (typeof classValue === "object" && classValue[slotName]) {
118
- return normalizeClassValue(classValue[slotName]);
119
- }
120
- if (typeof classValue === "string") {
121
- return classValue;
122
- }
123
- return undefined;
124
- };
125
- const createSlotFunction = (slotConfig, variants, compoundVariants, onComplete, slotName) => ({ className, class: classFromProps, ...props } = {}) => {
126
- const responsiveClasses = processVariantProps(props, variants, slotName);
127
- const compoundClasses = compoundVariants?.map(({ class: classFromCompound, className: classNameFromCompound, ...compound }) => {
128
- if (matchesCompoundVariant(compound, props)) {
129
- return [
130
- getCompoundVariantSlotClass(classFromCompound, slotName),
131
- getCompoundVariantSlotClass(classNameFromCompound, slotName),
132
- ];
133
- }
134
- return undefined;
135
- });
136
- const classes = clsx(slotConfig, responsiveClasses, compoundClasses, className, classFromProps);
137
- return onComplete ? onComplete(classes) : classes;
138
- };
139
- export function rcv(config) {
140
- // Check if config is a slots config
141
- if (isSlotsConfig(config)) {
142
- const { slots, variants, compoundVariants, onComplete } = config;
143
- return () => {
144
- const slotFunctions = {};
145
- // Create slot functions for each slot - ensure all slots are always present
146
- for (const [slotName, slotConfig] of Object.entries(slots)) {
147
- const slotFunction = createSlotFunction(slotConfig, variants, compoundVariants, onComplete, slotName);
148
- slotFunctions[slotName] = slotFunction;
149
- }
150
- return slotFunctions;
151
- };
152
- }
153
- // If config is not a slots config, create a base function
154
- const { base, variants, compoundVariants, onComplete } = config;
155
- return ({ className, class: classFromProps, ...props } = {}) => {
156
- const responsiveClasses = processVariantProps(props, variants);
157
- const compoundClasses = compoundVariants?.map(({ className: compoundClassName, ...compound }) => {
158
- if (matchesCompoundVariant(compound, props)) {
159
- return compoundClassName;
160
- }
161
- return undefined;
162
- });
163
- const classes = clsx(base, responsiveClasses, compoundClasses, className, classFromProps);
164
- return onComplete ? onComplete(classes) : classes;
165
- };
166
- }
167
- /**
168
- * Creates a custom rcv function with custom breakpoints and an optional onComplete callback
169
- *
170
- * @template B - The custom breakpoints type
171
- * @param breakpoints - Optional array of custom breakpoint names
172
- * @param onComplete - Optional callback function that receives the generated classes and returns the final classes
173
- * @returns A function that creates rcv with custom breakpoints
174
- *
175
- * @example
176
- * const customRcv = createRcv(['mobile', 'tablet', 'desktop']);
177
- *
178
- * const getButtonVariants = customRcv({
179
- * base: "px-4 py-2 rounded",
180
- * variants: {
181
- * intent: {
182
- * primary: "bg-blue-500 text-white",
183
- * secondary: "bg-gray-200 text-gray-800"
184
- * }
185
- * }
186
- * });
187
- *
188
- * // Usage with custom breakpoints:
189
- * getButtonVariants({ intent: { initial: "primary", mobile: "secondary", desktop: "primary" } })
190
- */
191
- export const createRcv = (_breakpoints, onComplete) => {
192
- function customRcv(config) {
193
- if (isSlotsConfig(config)) {
194
- return rcv({
195
- ...config,
196
- onComplete: onComplete || config.onComplete,
197
- });
198
- }
199
- else {
200
- return rcv({
201
- ...config,
202
- onComplete: onComplete || config.onComplete,
203
- });
204
- }
205
- }
206
- return customRcv;
207
- };
1
+ export { mapResponsiveValue } from "./helpers.js";
2
+ export { createRcv, rcv } from "./rcv.js";
208
3
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["index.ts"],"names":[],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AO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IACnD,CAAC,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,MAAM,CAAC,MAAM,SAAS,GAAG,CACxB,YAA2B,EAC3B,UAAwC,EACvC,EAAE;IAsBH,SAAS,SAAS,CAIjB,MAOI;QAEJ,IAAI,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;YAC3B,OAAO,GAAG,CAAU;gBACnB,GAAG,MAAM;gBACT,UAAU,EAAE,UAAU,IAAI,MAAM,CAAC,UAAU;aAM3C,CAAC,CAAC;QACJ,CAAC;aAAM,CAAC;YACP,OAAO,GAAG,CAAO;gBAChB,GAAG,MAAM;gBACT,UAAU,EAAE,UAAU,IAAI,MAAM,CAAC,UAAU;aAC3C,CAAC,CAAC;QACJ,CAAC;IACF,CAAC;IAED,OAAO,SAAS,CAAC;AAClB,CAAC,CAAC","sourcesContent":["import { clsx } from \"clsx\";\n\nexport type DefaultBreakpoints = \"sm\" | \"md\" | \"lg\" | \"xl\";\nexport type Breakpoints = DefaultBreakpoints;\n\nexport type BreakpointsMap<V, B extends string = DefaultBreakpoints> = {\n\tinitial: V;\n} & Partial<{\n\t[breakpoint in B]: V;\n}>;\n\nexport type ResponsiveValue<T, B extends string = DefaultBreakpoints> =\n\t| T\n\t| BreakpointsMap<T, B>;\n\nconst isSingularValue = <A, B extends string>(\n\tvalue: ResponsiveValue<A, B>,\n): value is A => !isBreakpointsMap(value);\n\nconst isBreakpointsMap = <A, B extends string>(\n\tvalue: ResponsiveValue<A, B>,\n): value is BreakpointsMap<A, B> =>\n\ttypeof value === \"object\" && value != null && !Array.isArray(value);\n\n/**\n * Maps a ResponsiveValue to a new ResponsiveValue using the provided mapper function. Singular values are passed through as is.\n *\n * @template V The type of the original value\n * @template T The type of the mapped value\n * @template B The type of breakpoints\n * @param {ResponsiveValue<V, B>} value - The original ResponsiveValue to be mapped\n * @param {function(V): T} mapper - A function that maps a ResponsiveValue to a new ResponsiveValue\n * @returns {ResponsiveValue<T, B>} A new ResponsiveValue with the mapped values\n *\n *\n * @example\n * const sizes = {\n * initial: 'md',\n * sm: 'lg',\n * }\n *\n * const output = mapResponsiveValue(sizes, size => {\n *\tswitch (size) {\n *\t\tcase 'initial':\n *\t\treturn 'sm';\n *\t\tcase 'sm':\n *\t\t\treturn 'md';\n *\t\t}\n *\t});\n *\n * // console.log(output)\n * {\n *\tinitial: 'sm',\n *\tsm: 'md',\n * }\n */\nexport const mapResponsiveValue = <V, T, B extends string = DefaultBreakpoints>(\n\tvalue: ResponsiveValue<V, B>,\n\tmapper: (value: V) => T,\n): ResponsiveValue<T, B> => {\n\tif (isSingularValue(value)) {\n\t\treturn mapper(value);\n\t}\n\n\tconst result: Record<string, T> = {};\n\tfor (const key of Object.keys(value)) {\n\t\tresult[key] = mapper(value[key as keyof typeof value] as V);\n\t}\n\treturn result as BreakpointsMap<T, B>;\n};\n\n/**\n * Start of rcv and types\n */\n\ntype ClassValue = string | ReadonlyArray<string>;\n\ntype ValueType = ClassValue | Record<string, ClassValue>;\n\ntype VariantValue = Record<string, ValueType>;\ntype VariantConfig = Record<string, VariantValue>;\n\ntype StringBoolean = \"true\" | \"false\";\ntype BooleanVariant = Partial<\n\tRecord<StringBoolean, ClassValue | Record<string, ClassValue>>\n>;\n\ntype VariantPropValue<T, B extends string> = T extends BooleanVariant\n\t? ResponsiveValue<boolean, B> | undefined\n\t: T extends Record<string, unknown>\n\t\t? ResponsiveValue<keyof T, B>\n\t\t: never;\n\ntype VariantPropsBase<T extends VariantConfig, B extends string> = {\n\t[K in keyof T]?: VariantPropValue<T[K], B>;\n};\n\ntype VariantProps<T extends VariantConfig, B extends string> = VariantPropsBase<\n\tT,\n\tB\n> & {\n\tclassName?: string;\n\tclass?: string;\n};\n\n// Slot configuration types\ntype SlotConfig = ClassValue;\n\ntype SlotsConfig<S extends Record<string, SlotConfig>> = S;\n\ntype CompoundVariantClassValue<S extends string> =\n\t| string\n\t| Partial<Record<S, ClassValue>>;\n\ntype CompoundVariantWithSlots<\n\tT extends VariantConfig,\n\tS extends string,\n\tB extends string,\n> = Partial<Omit<VariantProps<T, B>, \"class\" | \"className\">> & {\n\tclass?: CompoundVariantClassValue<S>;\n\tclassName?: CompoundVariantClassValue<S>;\n};\n\ntype ResponsiveClassesConfigBase<T extends VariantConfig, B extends string> = {\n\tbase: string;\n\tvariants?: T;\n\tcompoundVariants?: Partial<VariantProps<T, B>>[];\n\tonComplete?: (classes: string) => string;\n};\n\ntype ResponsiveClassesConfigSlots<\n\tT extends VariantConfig,\n\tS extends Record<string, SlotConfig>,\n\tB extends string,\n> = {\n\tslots: SlotsConfig<S>;\n\tvariants?: T;\n\tcompoundVariants?: CompoundVariantWithSlots<T, keyof S & string, B>[];\n\tonComplete?: (classes: string) => string;\n};\n\ntype ResponsiveClassesConfig<T extends VariantConfig, B extends string> =\n\t| ResponsiveClassesConfigBase<T, B>\n\t| ResponsiveClassesConfigSlots<T, Record<string, SlotConfig>, B>;\n\n// Helper functions for slots\nconst isSlotsConfig = <T extends VariantConfig, B extends string>(\n\tconfig: ResponsiveClassesConfig<T, B>,\n): config is ResponsiveClassesConfigSlots<T, Record<string, SlotConfig>, B> => {\n\treturn \"slots\" in config;\n};\n\nconst normalizeClassValue = (value: ClassValue | undefined) => {\n\tif (Array.isArray(value)) {\n\t\treturn value.join(\" \");\n\t}\n\tif (typeof value === \"string\") {\n\t\treturn value;\n\t}\n\treturn undefined;\n};\n\nconst prefixClasses = (classes: string, prefix: string) =>\n\tclasses.replace(/(\\S+)/g, `${prefix}:$1`);\n\n// Helper function to get variant value for a specific slot or base\nconst getVariantValue = <T extends VariantConfig>(\n\tvariants: T | undefined,\n\tkey: keyof T,\n\tvalue: string,\n\tslotName?: string,\n): string | undefined => {\n\tconst variantValue = variants?.[key]?.[value];\n\n\t// Early return if no variant value found\n\tif (variantValue == null) return undefined;\n\n\t// Handle string or array values directly\n\tif (typeof variantValue === \"string\" || Array.isArray(variantValue)) {\n\t\treturn normalizeClassValue(variantValue);\n\t}\n\n\t// Handle slot-specific values (object with slot keys)\n\tif (slotName && slotName in variantValue) {\n\t\treturn normalizeClassValue(\n\t\t\t(variantValue as Record<string, ClassValue>)[slotName],\n\t\t);\n\t}\n\n\treturn undefined;\n};\n\n// Helper function to process responsive values\nconst processResponsiveValue = <T extends VariantConfig, B extends string>(\n\tvariants: T | undefined,\n\tkey: keyof T,\n\tvalue: Partial<BreakpointsMap<T, B>>,\n\tslotName?: string,\n) => {\n\treturn Object.entries(value).map(([breakpoint, breakpointValue]) => {\n\t\tconst variantValue = getVariantValue(\n\t\t\tvariants,\n\t\t\tkey,\n\t\t\tbreakpointValue as string,\n\t\t\tslotName,\n\t\t);\n\n\t\tif (!variantValue) return undefined;\n\n\t\t// If the breakpoint is initial, return without prefix\n\t\tif (breakpoint === \"initial\") {\n\t\t\treturn variantValue;\n\t\t}\n\n\t\t// Otherwise, return with breakpoint prefix\n\t\treturn prefixClasses(variantValue, breakpoint);\n\t});\n};\n\n// Helper function to process variant props into classes\nconst processVariantProps = <T extends VariantConfig, B extends string>(\n\tprops: Omit<VariantProps<T, B>, \"className\" | \"class\">,\n\tvariants: T | undefined,\n\tslotName?: string,\n) => {\n\treturn Object.entries(props).map(\n\t\t([key, propValue]: [keyof T, VariantPropValue<T[keyof T], B>]) => {\n\t\t\tconst value =\n\t\t\t\ttypeof propValue === \"boolean\" ? String(propValue) : propValue;\n\n\t\t\t// Handle undefined values\n\t\t\tif (!value) return undefined;\n\n\t\t\t// Handle singular values\n\t\t\tif (typeof value === \"string\") {\n\t\t\t\treturn getVariantValue(variants, key, value, slotName);\n\t\t\t}\n\n\t\t\t// Handle responsive values\n\t\t\treturn processResponsiveValue(\n\t\t\t\tvariants,\n\t\t\t\tkey,\n\t\t\t\tvalue as Partial<BreakpointsMap<T, B>>,\n\t\t\t\tslotName,\n\t\t\t);\n\t\t},\n\t);\n};\n\n// Helper function to match compound variants\nconst matchesCompoundVariant = <T extends VariantConfig, B extends string>(\n\tcompound: Omit<CompoundVariantWithSlots<T, string, B>, \"className\" | \"class\">,\n\tprops: Omit<VariantProps<T, B>, \"className\" | \"class\">,\n) => {\n\treturn Object.entries(compound).every(([key, value]) => {\n\t\tconst propValue = props[key as keyof typeof props];\n\t\t// Direct comparison first, then try string conversion for boolean handling\n\t\treturn propValue === value || propValue === String(value);\n\t});\n};\n\n// Helper function to extract class value from compound variant class prop\nconst getCompoundVariantSlotClass = <S extends string>(\n\tclassValue: CompoundVariantClassValue<S> | undefined,\n\tslotName: string,\n): string | undefined => {\n\tif (!classValue) return undefined;\n\n\tif (typeof classValue === \"object\" && classValue[slotName as S]) {\n\t\treturn normalizeClassValue(classValue[slotName as S]);\n\t}\n\n\tif (typeof classValue === \"string\") {\n\t\treturn classValue;\n\t}\n\n\treturn undefined;\n};\n\nconst createSlotFunction =\n\t<T extends VariantConfig, B extends string>(\n\t\tslotConfig: SlotConfig,\n\t\tvariants: T | undefined,\n\t\tcompoundVariants: CompoundVariantWithSlots<T, string, B>[] | undefined,\n\t\tonComplete: ((classes: string) => string) | undefined,\n\t\tslotName: string,\n\t) =>\n\t(\n\t\t{\n\t\t\tclassName,\n\t\t\tclass: classFromProps,\n\t\t\t...props\n\t\t}: VariantProps<T, B> = {} as VariantProps<T, B>,\n\t) => {\n\t\tconst responsiveClasses = processVariantProps(props, variants, slotName);\n\n\t\tconst compoundClasses = compoundVariants?.map(\n\t\t\t({\n\t\t\t\tclass: classFromCompound,\n\t\t\t\tclassName: classNameFromCompound,\n\t\t\t\t...compound\n\t\t\t}) => {\n\t\t\t\tif (matchesCompoundVariant(compound, props)) {\n\t\t\t\t\treturn [\n\t\t\t\t\t\tgetCompoundVariantSlotClass(classFromCompound, slotName),\n\t\t\t\t\t\tgetCompoundVariantSlotClass(classNameFromCompound, slotName),\n\t\t\t\t\t];\n\t\t\t\t}\n\t\t\t\treturn undefined;\n\t\t\t},\n\t\t);\n\n\t\tconst classes = clsx(\n\t\t\tslotConfig,\n\t\t\tresponsiveClasses,\n\t\t\tcompoundClasses,\n\t\t\tclassName,\n\t\t\tclassFromProps,\n\t\t);\n\t\treturn onComplete ? onComplete(classes) : classes;\n\t};\n\n// Function overloads for rcv\nexport function rcv<\n\tT extends VariantConfig = Record<never, VariantValue>,\n\tS extends Record<string, SlotConfig> = Record<string, SlotConfig>,\n\tB extends string = DefaultBreakpoints,\n>(config: {\n\tslots: S;\n\tvariants?: T;\n\tcompoundVariants?: CompoundVariantWithSlots<T, keyof S & string, B>[];\n\tonComplete?: (classes: string) => string;\n}): () => {\n\t[K in keyof S]: (props?: VariantProps<T, B>) => string;\n};\n\nexport function rcv<\n\tT extends VariantConfig = Record<never, VariantValue>,\n\tB extends string = DefaultBreakpoints,\n>(config: {\n\tbase: string;\n\tvariants?: T;\n\tcompoundVariants?: Partial<VariantProps<T, B>>[];\n\tonComplete?: (classes: string) => string;\n}): (props?: VariantProps<T, B>) => string;\n\nexport function rcv<\n\tT extends VariantConfig = Record<never, VariantValue>,\n\tS extends Record<string, SlotConfig> = Record<string, SlotConfig>,\n\tB extends string = DefaultBreakpoints,\n>(\n\tconfig:\n\t\t| ResponsiveClassesConfig<T, B>\n\t\t| {\n\t\t\t\tslots: S;\n\t\t\t\tvariants?: T;\n\t\t\t\tcompoundVariants?: CompoundVariantWithSlots<T, keyof S & string, B>[];\n\t\t\t\tonComplete?: (classes: string) => string;\n\t\t },\n) {\n\t// Check if config is a slots config\n\tif (isSlotsConfig(config)) {\n\t\tconst { slots, variants, compoundVariants, onComplete } = config;\n\t\treturn () => {\n\t\t\tconst slotFunctions = {} as {\n\t\t\t\t[K in keyof S]: (props?: VariantProps<T, B>) => string;\n\t\t\t};\n\n\t\t\t// Create slot functions for each slot - ensure all slots are always present\n\t\t\tfor (const [slotName, slotConfig] of Object.entries(slots)) {\n\t\t\t\tconst slotFunction = createSlotFunction<T, B>(\n\t\t\t\t\tslotConfig,\n\t\t\t\t\tvariants,\n\t\t\t\t\tcompoundVariants,\n\t\t\t\t\tonComplete,\n\t\t\t\t\tslotName,\n\t\t\t\t);\n\n\t\t\t\tslotFunctions[slotName as keyof S] = slotFunction;\n\t\t\t}\n\n\t\t\treturn slotFunctions;\n\t\t};\n\t}\n\n\t// If config is not a slots config, create a base function\n\tconst { base, variants, compoundVariants, onComplete } = config;\n\treturn (\n\t\t{\n\t\t\tclassName,\n\t\t\tclass: classFromProps,\n\t\t\t...props\n\t\t}: VariantProps<T, B> = {} as VariantProps<T, B>,\n\t) => {\n\t\tconst responsiveClasses = processVariantProps(props, variants);\n\n\t\tconst compoundClasses = compoundVariants?.map(\n\t\t\t({ className: compoundClassName, ...compound }) => {\n\t\t\t\tif (\n\t\t\t\t\tmatchesCompoundVariant(\n\t\t\t\t\t\tcompound as Omit<\n\t\t\t\t\t\t\tCompoundVariantWithSlots<T, string, B>,\n\t\t\t\t\t\t\t\"className\" | \"class\"\n\t\t\t\t\t\t>,\n\t\t\t\t\t\tprops,\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn compoundClassName;\n\t\t\t\t}\n\t\t\t\treturn undefined;\n\t\t\t},\n\t\t);\n\n\t\tconst classes = clsx(\n\t\t\tbase,\n\t\t\tresponsiveClasses,\n\t\t\tcompoundClasses,\n\t\t\tclassName,\n\t\t\tclassFromProps,\n\t\t);\n\t\treturn onComplete ? onComplete(classes) : classes;\n\t};\n}\n\n/**\n * Creates a custom rcv function with custom breakpoints and an optional onComplete callback\n *\n * @template B - The custom breakpoints type\n * @param breakpoints - Optional array of custom breakpoint names\n * @param onComplete - Optional callback function that receives the generated classes and returns the final classes\n * @returns A function that creates rcv with custom breakpoints\n *\n * @example\n * const customRcv = createRcv(['mobile', 'tablet', 'desktop']);\n *\n * const getButtonVariants = customRcv({\n * base: \"px-4 py-2 rounded\",\n * variants: {\n * intent: {\n * primary: \"bg-blue-500 text-white\",\n * secondary: \"bg-gray-200 text-gray-800\"\n * }\n * }\n * });\n *\n * // Usage with custom breakpoints:\n * getButtonVariants({ intent: { initial: \"primary\", mobile: \"secondary\", desktop: \"primary\" } })\n */\n\nexport const createRcv = <B extends string>(\n\t_breakpoints?: readonly B[],\n\tonComplete?: (classes: string) => string,\n) => {\n\tfunction customRcv<\n\t\tT extends VariantConfig = Record<never, VariantValue>,\n\t\tS extends Record<string, SlotConfig> = Record<string, SlotConfig>,\n\t>(config: {\n\t\tslots: S;\n\t\tvariants?: T;\n\t\tcompoundVariants?: CompoundVariantWithSlots<T, keyof S & string, B>[];\n\t\tonComplete?: (classes: string) => string;\n\t}): () => {\n\t\t[K in keyof S]: (props?: VariantProps<T, B>) => string;\n\t};\n\n\tfunction customRcv<\n\t\tT extends VariantConfig = Record<never, VariantValue>,\n\t>(config: {\n\t\tbase: string;\n\t\tvariants?: T;\n\t\tcompoundVariants?: Partial<VariantProps<T, B>>[];\n\t\tonComplete?: (classes: string) => string;\n\t}): (props?: VariantProps<T, B>) => string;\n\n\tfunction customRcv<\n\t\tT extends VariantConfig = Record<never, VariantValue>,\n\t\tS extends Record<string, SlotConfig> = Record<string, SlotConfig>,\n\t>(\n\t\tconfig:\n\t\t\t| ResponsiveClassesConfig<T, B>\n\t\t\t| {\n\t\t\t\t\tslots: S;\n\t\t\t\t\tvariants?: T;\n\t\t\t\t\tcompoundVariants?: CompoundVariantWithSlots<T, keyof S & string, B>[];\n\t\t\t\t\tonComplete?: (classes: string) => string;\n\t\t\t },\n\t) {\n\t\tif (isSlotsConfig(config)) {\n\t\t\treturn rcv<T, S, B>({\n\t\t\t\t...config,\n\t\t\t\tonComplete: onComplete || config.onComplete,\n\t\t\t} as {\n\t\t\t\tslots: S;\n\t\t\t\tvariants?: T;\n\t\t\t\tcompoundVariants?: CompoundVariantWithSlots<T, keyof S & string, B>[];\n\t\t\t\tonComplete?: (classes: string) => string;\n\t\t\t});\n\t\t} else {\n\t\t\treturn rcv<T, B>({\n\t\t\t\t...config,\n\t\t\t\tonComplete: onComplete || config.onComplete,\n\t\t\t});\n\t\t}\n\t}\n\n\treturn customRcv;\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC","sourcesContent":["export { mapResponsiveValue } from \"./helpers\";\nexport { createRcv, rcv } from \"./rcv\";\nexport type {\n\tBreakpoints,\n\tBreakpointsMap,\n\tDefaultBreakpoints,\n\tResponsiveValue,\n} from \"./types\";\n"]}
package/dist/rcv.d.ts ADDED
@@ -0,0 +1,53 @@
1
+ import type { CompoundVariantWithSlots, DefaultBreakpoints, SlotConfig, VariantConfig, VariantProps, VariantValue } from "./types.js";
2
+ export declare function rcv<T extends VariantConfig = Record<never, VariantValue>, S extends Record<string, SlotConfig> = Record<string, SlotConfig>, B extends string = DefaultBreakpoints>(config: {
3
+ slots: S;
4
+ variants?: T;
5
+ compoundVariants?: CompoundVariantWithSlots<T, keyof S & string, B>[];
6
+ onComplete?: (classes: string) => string;
7
+ }): () => {
8
+ [K in keyof S]: (props?: VariantProps<T, B>) => string;
9
+ };
10
+ export declare function rcv<T extends VariantConfig = Record<never, VariantValue>, B extends string = DefaultBreakpoints>(config: {
11
+ base: string;
12
+ variants?: T;
13
+ compoundVariants?: Partial<VariantProps<T, B>>[];
14
+ onComplete?: (classes: string) => string;
15
+ }): (props?: VariantProps<T, B>) => string;
16
+ /**
17
+ * Creates a custom rcv function with custom breakpoints and an optional onComplete callback
18
+ *
19
+ * @template B - The custom breakpoints type
20
+ * @param breakpoints - Optional array of custom breakpoint names
21
+ * @param onComplete - Optional callback function that receives the generated classes and returns the final classes
22
+ * @returns A function that creates rcv with custom breakpoints
23
+ *
24
+ * @example
25
+ * const customRcv = createRcv(['mobile', 'tablet', 'desktop']);
26
+ *
27
+ * const getButtonVariants = customRcv({
28
+ * base: "px-4 py-2 rounded",
29
+ * variants: {
30
+ * intent: {
31
+ * primary: "bg-blue-500 text-white",
32
+ * secondary: "bg-gray-200 text-gray-800"
33
+ * }
34
+ * }
35
+ * });
36
+ *
37
+ * // Usage with custom breakpoints:
38
+ * getButtonVariants({ intent: { initial: "primary", mobile: "secondary", desktop: "primary" } })
39
+ */
40
+ export declare const createRcv: <B extends string>(_breakpoints?: readonly B[], onComplete?: (classes: string) => string) => {
41
+ <T extends VariantConfig = Record<never, VariantValue>, S extends Record<string, SlotConfig> = Record<string, import("./types.js").ClassValue>>(config: {
42
+ slots: S;
43
+ variants?: T;
44
+ compoundVariants?: CompoundVariantWithSlots<T, keyof S & string, B>[];
45
+ onComplete?: (classes: string) => string;
46
+ }): () => { [K in keyof S]: (props?: VariantProps<T, B>) => string; };
47
+ <T extends VariantConfig = Record<never, VariantValue>>(config: {
48
+ base: string;
49
+ variants?: T;
50
+ compoundVariants?: Partial<VariantProps<T, B>>[];
51
+ onComplete?: (classes: string) => string;
52
+ }): (props?: VariantProps<T, B>) => string;
53
+ };
package/dist/rcv.js ADDED
@@ -0,0 +1,72 @@
1
+ import { clsx } from "clsx";
2
+ import { createSlotFunction, isSlotsConfig, matchesCompoundVariant, processVariantProps, } from "./helpers.js";
3
+ export function rcv(config) {
4
+ // Check if config is a slots config
5
+ if (isSlotsConfig(config)) {
6
+ const { slots, variants, compoundVariants, onComplete } = config;
7
+ return () => {
8
+ const slotFunctions = {};
9
+ // Create slot functions for each slot - ensure all slots are always present
10
+ for (const [slotName, slotConfig] of Object.entries(slots)) {
11
+ const slotFunction = createSlotFunction(slotConfig, variants, compoundVariants, onComplete, slotName);
12
+ slotFunctions[slotName] = slotFunction;
13
+ }
14
+ return slotFunctions;
15
+ };
16
+ }
17
+ // If config is not a slots config, create a base function
18
+ const { base, variants, compoundVariants, onComplete } = config;
19
+ return ({ className, class: classFromProps, ...props } = {}) => {
20
+ const responsiveClasses = processVariantProps(props, variants);
21
+ const compoundClasses = compoundVariants?.map(({ className: compoundClassName, ...compound }) => {
22
+ if (matchesCompoundVariant(compound, props)) {
23
+ return compoundClassName;
24
+ }
25
+ return undefined;
26
+ });
27
+ const classes = clsx(base, responsiveClasses, compoundClasses, className, classFromProps);
28
+ return onComplete ? onComplete(classes) : classes;
29
+ };
30
+ }
31
+ /**
32
+ * Creates a custom rcv function with custom breakpoints and an optional onComplete callback
33
+ *
34
+ * @template B - The custom breakpoints type
35
+ * @param breakpoints - Optional array of custom breakpoint names
36
+ * @param onComplete - Optional callback function that receives the generated classes and returns the final classes
37
+ * @returns A function that creates rcv with custom breakpoints
38
+ *
39
+ * @example
40
+ * const customRcv = createRcv(['mobile', 'tablet', 'desktop']);
41
+ *
42
+ * const getButtonVariants = customRcv({
43
+ * base: "px-4 py-2 rounded",
44
+ * variants: {
45
+ * intent: {
46
+ * primary: "bg-blue-500 text-white",
47
+ * secondary: "bg-gray-200 text-gray-800"
48
+ * }
49
+ * }
50
+ * });
51
+ *
52
+ * // Usage with custom breakpoints:
53
+ * getButtonVariants({ intent: { initial: "primary", mobile: "secondary", desktop: "primary" } })
54
+ */
55
+ export const createRcv = (_breakpoints, onComplete) => {
56
+ function customRcv(config) {
57
+ if (isSlotsConfig(config)) {
58
+ return rcv({
59
+ ...config,
60
+ onComplete: onComplete || config.onComplete,
61
+ });
62
+ }
63
+ else {
64
+ return rcv({
65
+ ...config,
66
+ onComplete: onComplete || config.onComplete,
67
+ });
68
+ }
69
+ }
70
+ return customRcv;
71
+ };
72
+ //# sourceMappingURL=rcv.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rcv.js","sourceRoot":"/","sources":["rcv.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EACN,kBAAkB,EAClB,aAAa,EACb,sBAAsB,EACtB,mBAAmB,GACnB,MAAM,WAAW,CAAC;AAmCnB,MAAM,UAAU,GAAG,CAKlB,MAOI;IAEJ,oCAAoC;IACpC,IAAI,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3B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C;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,MAAM,CAAC,MAAM,SAAS,GAAG,CACxB,YAA2B,EAC3B,UAAwC,EACvC,EAAE;IAsBH,SAAS,SAAS,CAIjB,MAOI;QAEJ,IAAI,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;YAC3B,OAAO,GAAG,CAAU;gBACnB,GAAG,MAAM;gBACT,UAAU,EAAE,UAAU,IAAI,MAAM,CAAC,UAAU;aAM3C,CAAC,CAAC;QACJ,CAAC;aAAM,CAAC;YACP,OAAO,GAAG,CAAO;gBAChB,GAAG,MAAM;gBACT,UAAU,EAAE,UAAU,IAAI,MAAM,CAAC,UAAU;aAC3C,CAAC,CAAC;QACJ,CAAC;IACF,CAAC;IAED,OAAO,SAAS,CAAC;AAClB,CAAC,CAAC","sourcesContent":["import { clsx } from \"clsx\";\nimport {\n\tcreateSlotFunction,\n\tisSlotsConfig,\n\tmatchesCompoundVariant,\n\tprocessVariantProps,\n} from \"./helpers\";\nimport type {\n\tCompoundVariantWithSlots,\n\tDefaultBreakpoints,\n\tResponsiveClassesConfig,\n\tSlotConfig,\n\tVariantConfig,\n\tVariantProps,\n\tVariantValue,\n} from \"./types\";\n\n// Function overloads for rcv\nexport function rcv<\n\tT extends VariantConfig = Record<never, VariantValue>,\n\tS extends Record<string, SlotConfig> = Record<string, SlotConfig>,\n\tB extends string = DefaultBreakpoints,\n>(config: {\n\tslots: S;\n\tvariants?: T;\n\tcompoundVariants?: CompoundVariantWithSlots<T, keyof S & string, B>[];\n\tonComplete?: (classes: string) => string;\n}): () => {\n\t[K in keyof S]: (props?: VariantProps<T, B>) => string;\n};\n\nexport function rcv<\n\tT extends VariantConfig = Record<never, VariantValue>,\n\tB extends string = DefaultBreakpoints,\n>(config: {\n\tbase: string;\n\tvariants?: T;\n\tcompoundVariants?: Partial<VariantProps<T, B>>[];\n\tonComplete?: (classes: string) => string;\n}): (props?: VariantProps<T, B>) => string;\n\nexport function rcv<\n\tT extends VariantConfig = Record<never, VariantValue>,\n\tS extends Record<string, SlotConfig> = Record<string, SlotConfig>,\n\tB extends string = DefaultBreakpoints,\n>(\n\tconfig:\n\t\t| ResponsiveClassesConfig<T, B>\n\t\t| {\n\t\t\t\tslots: S;\n\t\t\t\tvariants?: T;\n\t\t\t\tcompoundVariants?: CompoundVariantWithSlots<T, keyof S & string, B>[];\n\t\t\t\tonComplete?: (classes: string) => string;\n\t\t },\n) {\n\t// Check if config is a slots config\n\tif (isSlotsConfig(config)) {\n\t\tconst { slots, variants, compoundVariants, onComplete } = config;\n\t\treturn () => {\n\t\t\tconst slotFunctions = {} as {\n\t\t\t\t[K in keyof S]: (props?: VariantProps<T, B>) => string;\n\t\t\t};\n\n\t\t\t// Create slot functions for each slot - ensure all slots are always present\n\t\t\tfor (const [slotName, slotConfig] of Object.entries(slots)) {\n\t\t\t\tconst slotFunction = createSlotFunction<T, B>(\n\t\t\t\t\tslotConfig,\n\t\t\t\t\tvariants,\n\t\t\t\t\tcompoundVariants,\n\t\t\t\t\tonComplete,\n\t\t\t\t\tslotName,\n\t\t\t\t);\n\n\t\t\t\tslotFunctions[slotName as keyof S] = slotFunction;\n\t\t\t}\n\n\t\t\treturn slotFunctions;\n\t\t};\n\t}\n\n\t// If config is not a slots config, create a base function\n\tconst { base, variants, compoundVariants, onComplete } = config;\n\treturn (\n\t\t{\n\t\t\tclassName,\n\t\t\tclass: classFromProps,\n\t\t\t...props\n\t\t}: VariantProps<T, B> = {} as VariantProps<T, B>,\n\t) => {\n\t\tconst responsiveClasses = processVariantProps(props, variants);\n\n\t\tconst compoundClasses = compoundVariants?.map(\n\t\t\t({ className: compoundClassName, ...compound }) => {\n\t\t\t\tif (\n\t\t\t\t\tmatchesCompoundVariant(\n\t\t\t\t\t\tcompound as Omit<\n\t\t\t\t\t\t\tCompoundVariantWithSlots<T, string, B>,\n\t\t\t\t\t\t\t\"className\" | \"class\"\n\t\t\t\t\t\t>,\n\t\t\t\t\t\tprops,\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn compoundClassName;\n\t\t\t\t}\n\t\t\t\treturn undefined;\n\t\t\t},\n\t\t);\n\n\t\tconst classes = clsx(\n\t\t\tbase,\n\t\t\tresponsiveClasses,\n\t\t\tcompoundClasses,\n\t\t\tclassName,\n\t\t\tclassFromProps,\n\t\t);\n\t\treturn onComplete ? onComplete(classes) : classes;\n\t};\n}\n\n/**\n * Creates a custom rcv function with custom breakpoints and an optional onComplete callback\n *\n * @template B - The custom breakpoints type\n * @param breakpoints - Optional array of custom breakpoint names\n * @param onComplete - Optional callback function that receives the generated classes and returns the final classes\n * @returns A function that creates rcv with custom breakpoints\n *\n * @example\n * const customRcv = createRcv(['mobile', 'tablet', 'desktop']);\n *\n * const getButtonVariants = customRcv({\n * base: \"px-4 py-2 rounded\",\n * variants: {\n * intent: {\n * primary: \"bg-blue-500 text-white\",\n * secondary: \"bg-gray-200 text-gray-800\"\n * }\n * }\n * });\n *\n * // Usage with custom breakpoints:\n * getButtonVariants({ intent: { initial: \"primary\", mobile: \"secondary\", desktop: \"primary\" } })\n */\n\nexport const createRcv = <B extends string>(\n\t_breakpoints?: readonly B[],\n\tonComplete?: (classes: string) => string,\n) => {\n\tfunction customRcv<\n\t\tT extends VariantConfig = Record<never, VariantValue>,\n\t\tS extends Record<string, SlotConfig> = Record<string, SlotConfig>,\n\t>(config: {\n\t\tslots: S;\n\t\tvariants?: T;\n\t\tcompoundVariants?: CompoundVariantWithSlots<T, keyof S & string, B>[];\n\t\tonComplete?: (classes: string) => string;\n\t}): () => {\n\t\t[K in keyof S]: (props?: VariantProps<T, B>) => string;\n\t};\n\n\tfunction customRcv<\n\t\tT extends VariantConfig = Record<never, VariantValue>,\n\t>(config: {\n\t\tbase: string;\n\t\tvariants?: T;\n\t\tcompoundVariants?: Partial<VariantProps<T, B>>[];\n\t\tonComplete?: (classes: string) => string;\n\t}): (props?: VariantProps<T, B>) => string;\n\n\tfunction customRcv<\n\t\tT extends VariantConfig = Record<never, VariantValue>,\n\t\tS extends Record<string, SlotConfig> = Record<string, SlotConfig>,\n\t>(\n\t\tconfig:\n\t\t\t| ResponsiveClassesConfig<T, B>\n\t\t\t| {\n\t\t\t\t\tslots: S;\n\t\t\t\t\tvariants?: T;\n\t\t\t\t\tcompoundVariants?: CompoundVariantWithSlots<T, keyof S & string, B>[];\n\t\t\t\t\tonComplete?: (classes: string) => string;\n\t\t\t },\n\t) {\n\t\tif (isSlotsConfig(config)) {\n\t\t\treturn rcv<T, S, B>({\n\t\t\t\t...config,\n\t\t\t\tonComplete: onComplete || config.onComplete,\n\t\t\t} as {\n\t\t\t\tslots: S;\n\t\t\t\tvariants?: T;\n\t\t\t\tcompoundVariants?: CompoundVariantWithSlots<T, keyof S & string, B>[];\n\t\t\t\tonComplete?: (classes: string) => string;\n\t\t\t});\n\t\t} else {\n\t\t\treturn rcv<T, B>({\n\t\t\t\t...config,\n\t\t\t\tonComplete: onComplete || config.onComplete,\n\t\t\t});\n\t\t}\n\t}\n\n\treturn customRcv;\n};\n"]}
@@ -0,0 +1,43 @@
1
+ export type DefaultBreakpoints = "sm" | "md" | "lg" | "xl";
2
+ export type Breakpoints = DefaultBreakpoints;
3
+ export type BreakpointsMap<V, B extends string = DefaultBreakpoints> = {
4
+ initial: V;
5
+ } & Partial<{
6
+ [breakpoint in B]: V;
7
+ }>;
8
+ export type ResponsiveValue<T, B extends string = DefaultBreakpoints> = T | BreakpointsMap<T, B>;
9
+ type ClassValue = string | ReadonlyArray<string>;
10
+ type ValueType = ClassValue | Record<string, ClassValue>;
11
+ type VariantValue = Record<string, ValueType>;
12
+ type VariantConfig = Record<string, VariantValue>;
13
+ type StringBoolean = "true" | "false";
14
+ type BooleanVariant = Partial<Record<StringBoolean, ClassValue | Record<string, ClassValue>>>;
15
+ type VariantPropValue<T, B extends string> = T extends BooleanVariant ? ResponsiveValue<boolean, B> | undefined : T extends Record<string, unknown> ? ResponsiveValue<keyof T, B> : never;
16
+ type VariantPropsBase<T extends VariantConfig, B extends string> = {
17
+ [K in keyof T]?: VariantPropValue<T[K], B>;
18
+ };
19
+ type VariantProps<T extends VariantConfig, B extends string> = VariantPropsBase<T, B> & {
20
+ className?: string;
21
+ class?: string;
22
+ };
23
+ type SlotConfig = ClassValue;
24
+ type SlotsConfig<S extends Record<string, SlotConfig>> = S;
25
+ type CompoundVariantClassValue<S extends string> = string | Partial<Record<S, ClassValue>>;
26
+ type CompoundVariantWithSlots<T extends VariantConfig, S extends string, B extends string> = Partial<Omit<VariantProps<T, B>, "class" | "className">> & {
27
+ class?: CompoundVariantClassValue<S>;
28
+ className?: CompoundVariantClassValue<S>;
29
+ };
30
+ type ResponsiveClassesConfigBase<T extends VariantConfig, B extends string> = {
31
+ base: string;
32
+ variants?: T;
33
+ compoundVariants?: Partial<VariantProps<T, B>>[];
34
+ onComplete?: (classes: string) => string;
35
+ };
36
+ type ResponsiveClassesConfigSlots<T extends VariantConfig, S extends Record<string, SlotConfig>, B extends string> = {
37
+ slots: SlotsConfig<S>;
38
+ variants?: T;
39
+ compoundVariants?: CompoundVariantWithSlots<T, keyof S & string, B>[];
40
+ onComplete?: (classes: string) => string;
41
+ };
42
+ type ResponsiveClassesConfig<T extends VariantConfig, B extends string> = ResponsiveClassesConfigBase<T, B> | ResponsiveClassesConfigSlots<T, Record<string, SlotConfig>, B>;
43
+ export type { ClassValue, CompoundVariantClassValue, CompoundVariantWithSlots, ResponsiveClassesConfig, ResponsiveClassesConfigSlots, SlotConfig, SlotsConfig, VariantConfig, VariantProps, VariantPropValue, VariantValue, };
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"/","sources":["types.ts"],"names":[],"mappings":"","sourcesContent":["export type DefaultBreakpoints = \"sm\" | \"md\" | \"lg\" | \"xl\";\nexport type Breakpoints = DefaultBreakpoints;\n\nexport type BreakpointsMap<V, B extends string = DefaultBreakpoints> = {\n\tinitial: V;\n} & Partial<{\n\t[breakpoint in B]: V;\n}>;\n\nexport type ResponsiveValue<T, B extends string = DefaultBreakpoints> =\n\t| T\n\t| BreakpointsMap<T, B>;\n\ntype ClassValue = string | ReadonlyArray<string>;\n\ntype ValueType = ClassValue | Record<string, ClassValue>;\n\ntype VariantValue = Record<string, ValueType>;\ntype VariantConfig = Record<string, VariantValue>;\n\ntype StringBoolean = \"true\" | \"false\";\ntype BooleanVariant = Partial<\n\tRecord<StringBoolean, ClassValue | Record<string, ClassValue>>\n>;\n\ntype VariantPropValue<T, B extends string> = T extends BooleanVariant\n\t? ResponsiveValue<boolean, B> | undefined\n\t: T extends Record<string, unknown>\n\t\t? ResponsiveValue<keyof T, B>\n\t\t: never;\n\ntype VariantPropsBase<T extends VariantConfig, B extends string> = {\n\t[K in keyof T]?: VariantPropValue<T[K], B>;\n};\n\ntype VariantProps<T extends VariantConfig, B extends string> = VariantPropsBase<\n\tT,\n\tB\n> & {\n\tclassName?: string;\n\tclass?: string;\n};\n\n// Slot configuration types\ntype SlotConfig = ClassValue;\n\ntype SlotsConfig<S extends Record<string, SlotConfig>> = S;\n\ntype CompoundVariantClassValue<S extends string> =\n\t| string\n\t| Partial<Record<S, ClassValue>>;\n\ntype CompoundVariantWithSlots<\n\tT extends VariantConfig,\n\tS extends string,\n\tB extends string,\n> = Partial<Omit<VariantProps<T, B>, \"class\" | \"className\">> & {\n\tclass?: CompoundVariantClassValue<S>;\n\tclassName?: CompoundVariantClassValue<S>;\n};\n\ntype ResponsiveClassesConfigBase<T extends VariantConfig, B extends string> = {\n\tbase: string;\n\tvariants?: T;\n\tcompoundVariants?: Partial<VariantProps<T, B>>[];\n\tonComplete?: (classes: string) => string;\n};\n\ntype ResponsiveClassesConfigSlots<\n\tT extends VariantConfig,\n\tS extends Record<string, SlotConfig>,\n\tB extends string,\n> = {\n\tslots: SlotsConfig<S>;\n\tvariants?: T;\n\tcompoundVariants?: CompoundVariantWithSlots<T, keyof S & string, B>[];\n\tonComplete?: (classes: string) => string;\n};\n\ntype ResponsiveClassesConfig<T extends VariantConfig, B extends string> =\n\t| ResponsiveClassesConfigBase<T, B>\n\t| ResponsiveClassesConfigSlots<T, Record<string, SlotConfig>, B>;\n\nexport type {\n\tClassValue,\n\tCompoundVariantClassValue,\n\tCompoundVariantWithSlots,\n\tResponsiveClassesConfig,\n\tResponsiveClassesConfigSlots,\n\tSlotConfig,\n\tSlotsConfig,\n\tVariantConfig,\n\tVariantProps,\n\tVariantPropValue,\n\tVariantValue,\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "responsive-class-variants",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "rcv helps you create responsive class variants",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -20,7 +20,7 @@
20
20
  "tailwindcss"
21
21
  ],
22
22
  "scripts": {
23
- "build": "tsc",
23
+ "build": "tsc && tsc-alias -f",
24
24
  "test": "vitest",
25
25
  "test:ci": "vitest run",
26
26
  "lint": "biome check .",
@@ -28,14 +28,15 @@
28
28
  },
29
29
  "author": "Benedikt Sperl",
30
30
  "license": "ISC",
31
- "packageManager": "pnpm@9.14.2+sha512.6e2baf77d06b9362294152c851c4f278ede37ab1eba3a55fda317a4a17b209f4dbb973fb250a77abc463a341fcb1f17f17cfa24091c4eb319cda0d9b84278387",
31
+ "packageManager": "pnpm@10.30.1",
32
32
  "dependencies": {
33
33
  "clsx": "^2.0.0"
34
34
  },
35
35
  "devDependencies": {
36
- "@biomejs/biome": "2.0.6",
37
- "lefthook": "^1.11.14",
38
- "typescript": "^5.8.3",
39
- "vitest": "^3.2.4"
36
+ "@biomejs/biome": "2.4.4",
37
+ "lefthook": "^2.1.1",
38
+ "tsc-alias": "^1.8.16",
39
+ "typescript": "^5.9.3",
40
+ "vitest": "^4.0.18"
40
41
  }
41
42
  }