clava 0.1.0 → 0.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/CHANGELOG.md +12 -0
- package/dist/index.d.ts +25 -12
- package/dist/index.js +42 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +79 -51
- package/src/test-react.ts +40 -0
- package/src/test-solid.ts +36 -0
- package/src/test.ts +234 -310
- package/src/types.ts +131 -46
- package/src/utils.ts +15 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# clava
|
|
2
2
|
|
|
3
|
+
## 0.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e7a2ebe: Removed `onlyVariants` property in favor of `variantKeys`.
|
|
8
|
+
|
|
9
|
+
## 0.1.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- c06f0ec: Fixed `context.setDefaultVariants()` not overriding `defaultVariants`.
|
|
14
|
+
|
|
3
15
|
## 0.1.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -28,29 +28,35 @@ type GetVariants<V$1> = (variants?: VariantValues<V$1>) => VariantValues<V$1>;
|
|
|
28
28
|
type KeySourceArray = readonly string[];
|
|
29
29
|
type KeySourceComponent = {
|
|
30
30
|
keys: readonly (string | number | symbol)[];
|
|
31
|
+
variantKeys: readonly (string | number | symbol)[];
|
|
31
32
|
getVariants: () => Record<string, unknown>;
|
|
32
33
|
};
|
|
33
34
|
type KeySource = KeySourceArray | KeySourceComponent;
|
|
35
|
+
type IsComponent<S> = S extends {
|
|
36
|
+
getVariants: () => unknown;
|
|
37
|
+
} ? true : false;
|
|
34
38
|
type SourceKeys<S> = S extends readonly (infer K)[] ? K : S extends {
|
|
35
39
|
keys: readonly (infer K)[];
|
|
36
40
|
} ? K : never;
|
|
41
|
+
type SourceVariantKeys<S> = S extends readonly (infer K)[] ? K : S extends {
|
|
42
|
+
variantKeys: readonly (infer K)[];
|
|
43
|
+
} ? K : never;
|
|
37
44
|
type SourceDefaults<S> = S extends {
|
|
38
45
|
getVariants: () => infer Defaults;
|
|
39
46
|
} ? Defaults : {};
|
|
40
|
-
type
|
|
41
|
-
type
|
|
42
|
-
type
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
keys: (keyof V$1)[];
|
|
46
|
-
}
|
|
47
|
+
type SourceResultWithStyling<T, S> = Pick<T, Extract<keyof T, SourceKeys<S>>> & Omit<SourceDefaults<S>, keyof T>;
|
|
48
|
+
type SourceResultWithoutStyling<T, S> = IsComponent<S> extends true ? Pick<T, Extract<keyof T, SourceVariantKeys<S>>> & Omit<SourceDefaults<S>, keyof T> : Pick<T, Extract<keyof T, SourceKeys<S>>>;
|
|
49
|
+
type HasComponent<Sources> = Sources extends readonly [] ? false : Sources extends readonly [infer First, ...infer Rest] ? IsComponent<First> extends true ? true : HasComponent<Rest> : false;
|
|
50
|
+
type SplitPropsFunction = <T, const S1 extends KeySource, const Sources extends readonly KeySource[]>(props: T, source1: S1, ...sources: Sources) => SplitPropsFunctionResult<T, S1, Sources>;
|
|
51
|
+
type SplitPropsFunctionResult<T, S1 extends KeySource, Sources extends readonly KeySource[]> = Sources extends readonly [] ? [SourceResultWithStyling<T, S1>, Omit<T, SourceKeys<S1>>] : Sources extends readonly [infer S2 extends KeySource] ? [SourceResultWithStyling<T, S1>, IsComponent<S1> extends true ? SourceResultWithoutStyling<T, S2> : SourceResultWithStyling<T, S2>, Omit<T, SourceKeys<S1> | SourceKeys<S2>>] : Sources extends readonly [infer S2 extends KeySource, infer S3 extends KeySource] ? [SourceResultWithStyling<T, S1>, IsComponent<S1> extends true ? SourceResultWithoutStyling<T, S2> : SourceResultWithStyling<T, S2>, HasComponent<[S1, S2]> extends true ? SourceResultWithoutStyling<T, S3> : SourceResultWithStyling<T, S3>, Omit<T, SourceKeys<S1> | SourceKeys<S2> | SourceKeys<S3>>] : Sources extends readonly [infer S2 extends KeySource, infer S3 extends KeySource, infer S4 extends KeySource] ? [SourceResultWithStyling<T, S1>, IsComponent<S1> extends true ? SourceResultWithoutStyling<T, S2> : SourceResultWithStyling<T, S2>, HasComponent<[S1, S2]> extends true ? SourceResultWithoutStyling<T, S3> : SourceResultWithStyling<T, S3>, HasComponent<[S1, S2, S3]> extends true ? SourceResultWithoutStyling<T, S4> : SourceResultWithStyling<T, S4>, Omit<T, SourceKeys<S1> | SourceKeys<S2> | SourceKeys<S3> | SourceKeys<S4>>] : Sources extends readonly [infer S2 extends KeySource, infer S3 extends KeySource, infer S4 extends KeySource, infer S5 extends KeySource] ? [SourceResultWithStyling<T, S1>, IsComponent<S1> extends true ? SourceResultWithoutStyling<T, S2> : SourceResultWithStyling<T, S2>, HasComponent<[S1, S2]> extends true ? SourceResultWithoutStyling<T, S3> : SourceResultWithStyling<T, S3>, HasComponent<[S1, S2, S3]> extends true ? SourceResultWithoutStyling<T, S4> : SourceResultWithStyling<T, S4>, HasComponent<[S1, S2, S3, S4]> extends true ? SourceResultWithoutStyling<T, S5> : SourceResultWithStyling<T, S5>, Omit<T, SourceKeys<S1> | SourceKeys<S2> | SourceKeys<S3> | SourceKeys<S4> | SourceKeys<S5>>] : Sources extends readonly [infer S2 extends KeySource, infer S3 extends KeySource, infer S4 extends KeySource, infer S5 extends KeySource, infer S6 extends KeySource] ? [SourceResultWithStyling<T, S1>, IsComponent<S1> extends true ? SourceResultWithoutStyling<T, S2> : SourceResultWithStyling<T, S2>, HasComponent<[S1, S2]> extends true ? SourceResultWithoutStyling<T, S3> : SourceResultWithStyling<T, S3>, HasComponent<[S1, S2, S3]> extends true ? SourceResultWithoutStyling<T, S4> : SourceResultWithStyling<T, S4>, HasComponent<[S1, S2, S3, S4]> extends true ? SourceResultWithoutStyling<T, S5> : SourceResultWithStyling<T, S5>, HasComponent<[S1, S2, S3, S4, S5]> extends true ? SourceResultWithoutStyling<T, S6> : SourceResultWithStyling<T, S6>, Omit<T, SourceKeys<S1> | SourceKeys<S2> | SourceKeys<S3> | SourceKeys<S4> | SourceKeys<S5> | SourceKeys<S6>>] : Sources extends readonly [infer S2 extends KeySource, infer S3 extends KeySource, infer S4 extends KeySource, infer S5 extends KeySource, infer S6 extends KeySource, infer S7 extends KeySource] ? [SourceResultWithStyling<T, S1>, IsComponent<S1> extends true ? SourceResultWithoutStyling<T, S2> : SourceResultWithStyling<T, S2>, HasComponent<[S1, S2]> extends true ? SourceResultWithoutStyling<T, S3> : SourceResultWithStyling<T, S3>, HasComponent<[S1, S2, S3]> extends true ? SourceResultWithoutStyling<T, S4> : SourceResultWithStyling<T, S4>, HasComponent<[S1, S2, S3, S4]> extends true ? SourceResultWithoutStyling<T, S5> : SourceResultWithStyling<T, S5>, HasComponent<[S1, S2, S3, S4, S5]> extends true ? SourceResultWithoutStyling<T, S6> : SourceResultWithStyling<T, S6>, HasComponent<[S1, S2, S3, S4, S5, S6]> extends true ? SourceResultWithoutStyling<T, S7> : SourceResultWithStyling<T, S7>, Omit<T, SourceKeys<S1> | SourceKeys<S2> | SourceKeys<S3> | SourceKeys<S4> | SourceKeys<S5> | SourceKeys<S6> | SourceKeys<S7>>] : Sources extends readonly [infer S2 extends KeySource, infer S3 extends KeySource, infer S4 extends KeySource, infer S5 extends KeySource, infer S6 extends KeySource, infer S7 extends KeySource, infer S8 extends KeySource] ? [SourceResultWithStyling<T, S1>, IsComponent<S1> extends true ? SourceResultWithoutStyling<T, S2> : SourceResultWithStyling<T, S2>, HasComponent<[S1, S2]> extends true ? SourceResultWithoutStyling<T, S3> : SourceResultWithStyling<T, S3>, HasComponent<[S1, S2, S3]> extends true ? SourceResultWithoutStyling<T, S4> : SourceResultWithStyling<T, S4>, HasComponent<[S1, S2, S3, S4]> extends true ? SourceResultWithoutStyling<T, S5> : SourceResultWithStyling<T, S5>, HasComponent<[S1, S2, S3, S4, S5]> extends true ? SourceResultWithoutStyling<T, S6> : SourceResultWithStyling<T, S6>, HasComponent<[S1, S2, S3, S4, S5, S6]> extends true ? SourceResultWithoutStyling<T, S7> : SourceResultWithStyling<T, S7>, HasComponent<[S1, S2, S3, S4, S5, S6, S7]> extends true ? SourceResultWithoutStyling<T, S8> : SourceResultWithStyling<T, S8>, Omit<T, SourceKeys<S1> | SourceKeys<S2> | SourceKeys<S3> | SourceKeys<S4> | SourceKeys<S5> | SourceKeys<S6> | SourceKeys<S7> | SourceKeys<S8>>] : unknown[];
|
|
47
52
|
interface ModalComponent<V$1, R extends ComponentResult> {
|
|
48
53
|
(props?: ComponentProps<V$1>): R;
|
|
49
54
|
class: (props?: ComponentProps<V$1>) => string;
|
|
50
55
|
style: (props?: ComponentProps<V$1>) => R["style"];
|
|
51
56
|
getVariants: GetVariants<V$1>;
|
|
52
57
|
keys: (keyof V$1 | keyof R)[];
|
|
53
|
-
|
|
58
|
+
variantKeys: (keyof V$1)[];
|
|
59
|
+
propKeys: (keyof V$1 | keyof R)[];
|
|
54
60
|
/** @internal Base class without variants */
|
|
55
61
|
_baseClass: string;
|
|
56
62
|
}
|
|
@@ -88,9 +94,11 @@ type Variants = Record<string, Variant>;
|
|
|
88
94
|
type ExtendedVariants<E$1 extends AnyComponent[]> = MergeExtendedVariants<E$1> & MergeExtendedComputedVariants<E$1>;
|
|
89
95
|
type ExtendableVariants<V$1 extends Variants, E$1 extends AnyComponent[]> = V$1 & { [K in keyof ExtendedVariants<E$1>]?: Partial<ExtendedVariants<E$1>[K]> | Variant };
|
|
90
96
|
//#endregion
|
|
91
|
-
//#region src/
|
|
97
|
+
//#region src/utils.d.ts
|
|
92
98
|
declare const MODES: readonly ["jsx", "html", "htmlObj"];
|
|
93
99
|
type Mode = (typeof MODES)[number];
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region src/index.d.ts
|
|
94
102
|
type VariantProps<T extends Pick<AnyComponent, "getVariants">> = ReturnType<T["getVariants"]>;
|
|
95
103
|
interface CVConfig<V$1 extends Variants = {}, CV$1 extends ComputedVariants = {}, E$1 extends AnyComponent[] = []> {
|
|
96
104
|
extend?: E$1;
|
|
@@ -108,6 +116,9 @@ interface CreateParams<M extends Mode> {
|
|
|
108
116
|
/**
|
|
109
117
|
* Splits props into multiple groups based on key sources.
|
|
110
118
|
* Each source gets its own result object containing all its matching keys.
|
|
119
|
+
* The first component source claims styling props (class/className/style).
|
|
120
|
+
* Subsequent components only receive variant props.
|
|
121
|
+
* Arrays receive their listed keys but don't claim styling props.
|
|
111
122
|
* The last element is always the "rest" containing keys not claimed by any source.
|
|
112
123
|
*
|
|
113
124
|
* @example
|
|
@@ -115,19 +126,21 @@ interface CreateParams<M extends Mode> {
|
|
|
115
126
|
* const [buttonProps, inputProps, rest] = splitProps(
|
|
116
127
|
* props,
|
|
117
128
|
* buttonComponent,
|
|
118
|
-
* inputComponent
|
|
129
|
+
* inputComponent,
|
|
119
130
|
* );
|
|
131
|
+
* // buttonProps has class/style + button variants
|
|
132
|
+
* // inputProps has only input variants (no class/style)
|
|
120
133
|
* ```
|
|
121
134
|
*/
|
|
122
135
|
declare const splitProps: SplitPropsFunction;
|
|
123
|
-
declare function create<M extends Mode>({
|
|
136
|
+
declare function create<M extends Mode = "jsx">({
|
|
124
137
|
defaultMode,
|
|
125
138
|
transformClass
|
|
126
139
|
}?: CreateParams<M>): {
|
|
127
140
|
cv: <V$1 extends Variants = {}, CV$1 extends ComputedVariants = {}, const E$1 extends AnyComponent[] = []>(config?: CVConfig<V$1, CV$1, E$1>) => Component<V$1, CV$1, E$1, StyleProps[M]>;
|
|
128
141
|
cx: (...classes: ClassValue$1[]) => string;
|
|
129
142
|
};
|
|
130
|
-
declare const cv: <V$1 extends Variants = {}, CV$1 extends ComputedVariants = {}, const E$1 extends AnyComponent[] = []>(config?: CVConfig<V$1, CV$1, E$1>) => Component<V$1, CV$1, E$1, JSXProps
|
|
143
|
+
declare const cv: <V$1 extends Variants = {}, CV$1 extends ComputedVariants = {}, const E$1 extends AnyComponent[] = []>(config?: CVConfig<V$1, CV$1, E$1>) => Component<V$1, CV$1, E$1, JSXProps>, cx: (...classes: ClassValue$1[]) => string;
|
|
131
144
|
//#endregion
|
|
132
145
|
export { CVConfig, type ClassValue, type StyleClassValue, type StyleValue, VariantProps, create, cv, cx, splitProps };
|
|
133
146
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -17,6 +17,15 @@ var clsx_default = clsx;
|
|
|
17
17
|
//#endregion
|
|
18
18
|
//#region src/utils.ts
|
|
19
19
|
/**
|
|
20
|
+
* Returns the appropriate class property name based on the mode.
|
|
21
|
+
* @example
|
|
22
|
+
* getClassPropertyName("jsx") // "className"
|
|
23
|
+
* getClassPropertyName("html") // "class"
|
|
24
|
+
*/
|
|
25
|
+
function getClassPropertyName(mode) {
|
|
26
|
+
return mode === "jsx" ? "className" : "class";
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
20
29
|
* Converts a hyphenated CSS property name to camelCase.
|
|
21
30
|
* @example
|
|
22
31
|
* hyphenToCamel("background-color") // "backgroundColor"
|
|
@@ -198,7 +207,7 @@ function processVariantValue(value) {
|
|
|
198
207
|
*/
|
|
199
208
|
function collectVariantKeys(config) {
|
|
200
209
|
const keys = /* @__PURE__ */ new Set();
|
|
201
|
-
if (config.extend) for (const ext of config.extend) for (const key of ext.
|
|
210
|
+
if (config.extend) for (const ext of config.extend) for (const key of ext.variantKeys) keys.add(key);
|
|
202
211
|
if (config.variants) for (const key of Object.keys(config.variants)) keys.add(key);
|
|
203
212
|
if (config.computedVariants) for (const key of Object.keys(config.computedVariants)) keys.add(key);
|
|
204
213
|
return Array.from(keys);
|
|
@@ -325,7 +334,7 @@ function processVariants(config, resolvedVariants) {
|
|
|
325
334
|
/**
|
|
326
335
|
* Processes the computed function if present.
|
|
327
336
|
*/
|
|
328
|
-
function processComputed(config, resolvedVariants) {
|
|
337
|
+
function processComputed(config, resolvedVariants, propsVariants) {
|
|
329
338
|
const classes = [];
|
|
330
339
|
let style = {};
|
|
331
340
|
let updatedVariants = { ...resolvedVariants };
|
|
@@ -339,7 +348,7 @@ function processComputed(config, resolvedVariants) {
|
|
|
339
348
|
};
|
|
340
349
|
},
|
|
341
350
|
setDefaultVariants: (newDefaults) => {
|
|
342
|
-
for (const [key, value] of Object.entries(newDefaults)) if (
|
|
351
|
+
for (const [key, value] of Object.entries(newDefaults)) if (propsVariants[key] === void 0) updatedVariants[key] = value;
|
|
343
352
|
}
|
|
344
353
|
};
|
|
345
354
|
const computedResult = config.computed(context);
|
|
@@ -359,40 +368,52 @@ function processComputed(config, resolvedVariants) {
|
|
|
359
368
|
};
|
|
360
369
|
}
|
|
361
370
|
/**
|
|
362
|
-
* Normalizes a key source (array or component) to an object with keys and
|
|
371
|
+
* Normalizes a key source (array or component) to an object with keys, variantKeys, defaults, and isComponent flag.
|
|
363
372
|
*/
|
|
364
373
|
function normalizeKeySource(source) {
|
|
365
374
|
if (Array.isArray(source)) return {
|
|
366
375
|
keys: source,
|
|
367
|
-
|
|
376
|
+
variantKeys: source,
|
|
377
|
+
defaults: {},
|
|
378
|
+
isComponent: false
|
|
368
379
|
};
|
|
369
|
-
if (source && (typeof source === "object" || typeof source === "function") && "keys" in source) return {
|
|
380
|
+
if (source && (typeof source === "object" || typeof source === "function") && "keys" in source && "variantKeys" in source) return {
|
|
370
381
|
keys: [...source.keys],
|
|
371
|
-
|
|
382
|
+
variantKeys: [...source.variantKeys],
|
|
383
|
+
defaults: "getVariants" in source ? source.getVariants() : {},
|
|
384
|
+
isComponent: true
|
|
372
385
|
};
|
|
373
386
|
return {
|
|
374
387
|
keys: [],
|
|
375
|
-
|
|
388
|
+
variantKeys: [],
|
|
389
|
+
defaults: {},
|
|
390
|
+
isComponent: false
|
|
376
391
|
};
|
|
377
392
|
}
|
|
378
393
|
/**
|
|
379
394
|
* Splits props into multiple groups based on key sources.
|
|
395
|
+
* Only the first component claims styling props (class/className/style).
|
|
396
|
+
* Subsequent components only receive variant props.
|
|
397
|
+
* Arrays always receive their listed keys but don't claim styling props.
|
|
380
398
|
*/
|
|
381
|
-
function splitPropsImpl(selfKeys, selfDefaults, props, sources) {
|
|
399
|
+
function splitPropsImpl(selfKeys, selfVariantKeys, selfDefaults, selfIsComponent, props, sources) {
|
|
382
400
|
const allUsedKeys = new Set(selfKeys);
|
|
383
401
|
const results = [];
|
|
402
|
+
let stylingClaimed = selfIsComponent;
|
|
384
403
|
const selfResult = {};
|
|
385
404
|
for (const [key, value] of Object.entries(selfDefaults)) if (selfKeys.includes(key)) selfResult[key] = value;
|
|
386
405
|
for (const key of selfKeys) if (key in props) selfResult[key] = props[key];
|
|
387
406
|
results.push(selfResult);
|
|
388
407
|
for (const source of sources) {
|
|
389
408
|
const sourceResult = {};
|
|
390
|
-
|
|
391
|
-
for (const key of source.
|
|
409
|
+
const effectiveKeys = source.isComponent && stylingClaimed ? source.variantKeys : source.keys;
|
|
410
|
+
for (const [key, value] of Object.entries(source.defaults)) if (effectiveKeys.includes(key)) sourceResult[key] = value;
|
|
411
|
+
for (const key of effectiveKeys) {
|
|
392
412
|
allUsedKeys.add(key);
|
|
393
413
|
if (key in props) sourceResult[key] = props[key];
|
|
394
414
|
}
|
|
395
415
|
results.push(sourceResult);
|
|
416
|
+
if (source.isComponent && !stylingClaimed) stylingClaimed = true;
|
|
396
417
|
}
|
|
397
418
|
const rest = {};
|
|
398
419
|
for (const [key, value] of Object.entries(props)) if (!allUsedKeys.has(key)) rest[key] = value;
|
|
@@ -402,6 +423,9 @@ function splitPropsImpl(selfKeys, selfDefaults, props, sources) {
|
|
|
402
423
|
/**
|
|
403
424
|
* Splits props into multiple groups based on key sources.
|
|
404
425
|
* Each source gets its own result object containing all its matching keys.
|
|
426
|
+
* The first component source claims styling props (class/className/style).
|
|
427
|
+
* Subsequent components only receive variant props.
|
|
428
|
+
* Arrays receive their listed keys but don't claim styling props.
|
|
405
429
|
* The last element is always the "rest" containing keys not claimed by any source.
|
|
406
430
|
*
|
|
407
431
|
* @example
|
|
@@ -409,20 +433,21 @@ function splitPropsImpl(selfKeys, selfDefaults, props, sources) {
|
|
|
409
433
|
* const [buttonProps, inputProps, rest] = splitProps(
|
|
410
434
|
* props,
|
|
411
435
|
* buttonComponent,
|
|
412
|
-
* inputComponent
|
|
436
|
+
* inputComponent,
|
|
413
437
|
* );
|
|
438
|
+
* // buttonProps has class/style + button variants
|
|
439
|
+
* // inputProps has only input variants (no class/style)
|
|
414
440
|
* ```
|
|
415
441
|
*/
|
|
416
442
|
const splitProps = ((props, source1, ...sources) => {
|
|
417
443
|
const normalizedSource1 = normalizeKeySource(source1);
|
|
418
444
|
const normalizedSources = sources.map(normalizeKeySource);
|
|
419
|
-
return splitPropsImpl(normalizedSource1.keys, normalizedSource1.defaults, props, normalizedSources);
|
|
445
|
+
return splitPropsImpl(normalizedSource1.keys, normalizedSource1.variantKeys, normalizedSource1.defaults, normalizedSource1.isComponent, props, normalizedSources);
|
|
420
446
|
});
|
|
421
447
|
function create({ defaultMode = "jsx", transformClass = (className) => className } = {}) {
|
|
422
448
|
const cx$1 = (...classes) => transformClass(clsx_default(...classes));
|
|
423
449
|
const cv$1 = (config = {}) => {
|
|
424
450
|
const variantKeys = collectVariantKeys(config);
|
|
425
|
-
const getClassPropertyName = (mode) => mode === "jsx" ? "className" : "class";
|
|
426
451
|
const getPropsKeys = (mode) => [
|
|
427
452
|
getClassPropertyName(mode),
|
|
428
453
|
"style",
|
|
@@ -434,7 +459,7 @@ function create({ defaultMode = "jsx", transformClass = (className) => className
|
|
|
434
459
|
const variantProps = {};
|
|
435
460
|
for (const key of variantKeys) if (key in props) variantProps[key] = props[key];
|
|
436
461
|
let resolvedVariants = resolveVariants(config, variantProps);
|
|
437
|
-
const computedResult = processComputed(config, resolvedVariants);
|
|
462
|
+
const computedResult = processComputed(config, resolvedVariants, variantProps);
|
|
438
463
|
resolvedVariants = computedResult.updatedVariants;
|
|
439
464
|
const computedVariantKeys = new Set(config.computedVariants ? Object.keys(config.computedVariants) : []);
|
|
440
465
|
const extendedResult = processExtended(config, resolvedVariants, computedVariantKeys);
|
|
@@ -501,12 +526,8 @@ function create({ defaultMode = "jsx", transformClass = (className) => className
|
|
|
501
526
|
return resolveVariants(config, variants);
|
|
502
527
|
};
|
|
503
528
|
component$1.keys = propsKeys;
|
|
504
|
-
component$1.
|
|
505
|
-
|
|
506
|
-
return resolveVariants(config, variants);
|
|
507
|
-
},
|
|
508
|
-
keys: variantKeys
|
|
509
|
-
};
|
|
529
|
+
component$1.variantKeys = variantKeys;
|
|
530
|
+
component$1.propKeys = propsKeys;
|
|
510
531
|
const extendedBaseClasses = [];
|
|
511
532
|
if (config.extend) for (const ext of config.extend) extendedBaseClasses.push(ext._baseClass);
|
|
512
533
|
component$1._baseClass = cx$1(...extendedBaseClasses, config.class);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["cx","clsx","cv","component"],"sources":["../../../node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs","../src/utils.ts","../src/index.ts"],"sourcesContent":["function r(e){var t,f,n=\"\";if(\"string\"==typeof e||\"number\"==typeof e)n+=e;else if(\"object\"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=\" \"),n+=f)}else for(f in e)e[f]&&(n&&(n+=\" \"),n+=f);return n}export function clsx(){for(var e,t,f=0,n=\"\",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=\" \"),n+=t);return n}export default clsx;","import type * as CSS from \"csstype\";\n\nimport type {\n StyleValue,\n JSXCSSProperties,\n HTMLCSSProperties,\n} from \"./types.ts\";\n\n/**\n * Converts a hyphenated CSS property name to camelCase.\n * @example\n * hyphenToCamel(\"background-color\") // \"backgroundColor\"\n * hyphenToCamel(\"--custom-var\") // \"--custom-var\" (CSS variables are preserved)\n */\nexport function hyphenToCamel(str: string) {\n // CSS custom properties (variables) should not be converted\n if (str.startsWith(\"--\")) {\n return str;\n }\n return str.replace(/-([a-z])/gi, (_, letter) => letter.toUpperCase());\n}\n\n/**\n * Converts a camelCase CSS property name to hyphenated form.\n * @example\n * camelToHyphen(\"backgroundColor\") // \"background-color\"\n * camelToHyphen(\"--customVar\") // \"--customVar\" (CSS variables are preserved)\n */\nexport function camelToHyphen(str: string) {\n // CSS custom properties (variables) should not be converted\n if (str.startsWith(\"--\")) {\n return str;\n }\n return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\n/**\n * Parses a length value, adding \"px\" if it's a number.\n * @example\n * parseLengthValue(16); // \"16px\"\n * parseLengthValue(\"2em\"); // \"2em\"\n */\nexport function parseLengthValue(value: string | number) {\n if (typeof value === \"string\") return value;\n return `${value}px`;\n}\n\n/**\n * Parses a CSS style string into a StyleValue object.\n * @example\n * htmlStyleToStyleValue(\"background-color: red; font-size: 16px;\");\n * // { backgroundColor: \"red\", fontSize: \"16px\" }\n */\nexport function htmlStyleToStyleValue(styleString: string) {\n if (!styleString) return {};\n\n const result: StyleValue = {};\n const declarations = styleString.split(\";\");\n\n for (const declaration of declarations) {\n const trimmed = declaration.trim();\n if (!trimmed) continue;\n\n const colonIndex = trimmed.indexOf(\":\");\n if (colonIndex === -1) continue;\n\n const property = trimmed.slice(0, colonIndex).trim();\n const value = trimmed.slice(colonIndex + 1).trim();\n if (!property) continue;\n if (!value) continue;\n\n const camelProperty = hyphenToCamel(property) as any;\n result[camelProperty] = value;\n }\n\n return result;\n}\n\n/**\n * Converts a hyphenated style object to a camelCase StyleValue object.\n * @example\n * htmlObjStyleToStyleValue({ \"background-color\": \"red\", \"font-size\": \"16px\" });\n * // { backgroundColor: \"red\", fontSize: \"16px\" }\n */\nexport function htmlObjStyleToStyleValue(style: HTMLCSSProperties) {\n const result: StyleValue = {};\n for (const [key, value] of Object.entries(style)) {\n if (value == null) continue;\n const property = hyphenToCamel(key) as any;\n result[property] = parseLengthValue(value);\n }\n return result;\n}\n\n/**\n * Converts a camelCase style object to a StyleValue object.\n * @example\n * jsxStyleToStyleValue({ backgroundColor: \"red\", fontSize: 16 });\n * // { backgroundColor: \"red\", fontSize: \"16px\" }\n */\nexport function jsxStyleToStyleValue(style: JSXCSSProperties) {\n const result: StyleValue = {};\n for (const [key, value] of Object.entries(style)) {\n if (value == null) continue;\n result[key as any] = parseLengthValue(value);\n }\n return result;\n}\n\n/**\n * Converts a StyleValue object to a CSS style string.\n * @example\n * styleValueToHTMLStyle({ backgroundColor: \"red\", fontSize: \"16px\" });\n * // \"background-color: red; font-size: 16px;\"\n */\nexport function styleValueToHTMLStyle(style: StyleValue): string {\n const parts: string[] = [];\n for (const [key, value] of Object.entries(style)) {\n if (value == null) continue;\n parts.push(`${camelToHyphen(key)}: ${value}`);\n }\n if (!parts.length) return \"\";\n return `${parts.join(\"; \")};`;\n}\n\n/**\n * Converts a StyleValue object to a hyphenated style object.\n * @example\n * styleValueToHTMLObjStyle({ backgroundColor: \"red\", fontSize: \"16px\" });\n * // { \"background-color\": \"red\", \"font-size\": \"16px\" }\n */\nexport function styleValueToHTMLObjStyle(style: StyleValue) {\n const result: CSS.PropertiesHyphen = {};\n for (const [key, value] of Object.entries(style)) {\n if (value == null) continue;\n const property = camelToHyphen(key) as keyof HTMLCSSProperties;\n result[property] = value;\n }\n return result;\n}\n\n/**\n * Converts a StyleValue object to a camelCase style object.\n * @example\n * styleValueToJSXStyle({ backgroundColor: \"red\", fontSize: \"16px\" });\n * // { backgroundColor: \"red\", fontSize: \"16px\" }\n */\nexport function styleValueToJSXStyle(style: StyleValue) {\n return style as JSXCSSProperties;\n}\n\n/**\n * Type guard to check if a style object has hyphenated keys.\n * @example\n * isHTMLObjStyle({ \"background-color\": \"red\" }); // true\n * isHTMLObjStyle({ backgroundColor: \"red\" }); // false\n */\nexport function isHTMLObjStyle(\n style: CSS.Properties<any> | CSS.PropertiesHyphen<any>,\n): style is CSS.PropertiesHyphen {\n return Object.keys(style).some(\n (key) => key.includes(\"-\") && !key.startsWith(\"--\"),\n );\n}\n","import clsx, { type ClassValue as ClsxClassValue } from \"clsx\";\n\nimport type {\n Variants,\n ComputedVariants,\n AnyComponent,\n Component,\n StyleProps,\n ClassValue,\n StyleValue,\n StyleClassValue,\n VariantValues,\n Computed,\n ExtendableVariants,\n MergeVariants,\n ModalComponent,\n ComponentResult,\n JSXProps,\n HTMLProps,\n HTMLObjProps,\n OnlyVariantsComponent,\n ComponentProps,\n SplitPropsFunction,\n} from \"./types.ts\";\n\nimport {\n htmlObjStyleToStyleValue,\n htmlStyleToStyleValue,\n isHTMLObjStyle,\n jsxStyleToStyleValue,\n styleValueToHTMLObjStyle,\n styleValueToHTMLStyle,\n styleValueToJSXStyle,\n} from \"./utils.ts\";\n\nconst MODES = [\"jsx\", \"html\", \"htmlObj\"] as const;\ntype Mode = (typeof MODES)[number];\n\nexport type { ClassValue, StyleValue, StyleClassValue };\n\nexport type VariantProps<T extends Pick<AnyComponent, \"getVariants\">> =\n ReturnType<T[\"getVariants\"]>;\n\nexport interface CVConfig<\n V extends Variants = {},\n CV extends ComputedVariants = {},\n E extends AnyComponent[] = [],\n> {\n extend?: E;\n class?: ClassValue;\n style?: StyleValue;\n variants?: ExtendableVariants<V, E>;\n computedVariants?: CV;\n defaultVariants?: VariantValues<MergeVariants<V, CV, E>>;\n computed?: Computed<MergeVariants<V, CV, E>>;\n}\n\ninterface CreateParams<M extends Mode> {\n defaultMode?: M;\n transformClass?: (className: string) => string;\n}\n\n/**\n * Checks if a value is a style-class object (has style properties, not just a\n * class value).\n */\nfunction isStyleClassValue(value: unknown): value is StyleClassValue {\n if (typeof value !== \"object\") return false;\n if (value == null) return false;\n if (Array.isArray(value)) return false;\n return true;\n}\n\n/**\n * Converts any style input (string, JSX object, or HTML object) to a\n * normalized StyleValue.\n */\nfunction normalizeStyle(style: unknown): StyleValue {\n if (typeof style === \"string\") {\n return htmlStyleToStyleValue(style);\n }\n if (typeof style === \"object\" && style != null) {\n if (isHTMLObjStyle(style as Record<string, unknown>)) {\n return htmlObjStyleToStyleValue(style as Record<string, string | number>);\n }\n return jsxStyleToStyleValue(style as Record<string, string | number>);\n }\n return {};\n}\n\n/**\n * Extracts class and style from a style-class value object.\n */\nfunction extractStyleClass(value: StyleClassValue): {\n class: ClassValue;\n style: StyleValue;\n} {\n const { class: cls, ...style } = value;\n return { class: cls, style };\n}\n\n/**\n * Processes a variant value to extract class and style.\n */\nfunction processVariantValue(value: unknown): {\n class: ClassValue;\n style: StyleValue;\n} {\n if (isStyleClassValue(value)) {\n return extractStyleClass(value);\n }\n return { class: value as ClassValue, style: {} };\n}\n\n/**\n * Gets all variant keys from a component's config, including extended\n * components.\n */\nfunction collectVariantKeys(\n config: CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n): string[] {\n const keys = new Set<string>();\n\n // Collect from extended components\n if (config.extend) {\n for (const ext of config.extend) {\n for (const key of ext.onlyVariants.keys) {\n keys.add(key as string);\n }\n }\n }\n\n // Collect from variants\n if (config.variants) {\n for (const key of Object.keys(config.variants)) {\n keys.add(key);\n }\n }\n\n // Collect from computedVariants\n if (config.computedVariants) {\n for (const key of Object.keys(config.computedVariants)) {\n keys.add(key);\n }\n }\n\n return Array.from(keys);\n}\n\n/**\n * Collects default variants from extended components and the current config.\n * Also handles implicit boolean defaults (when only `false` key exists).\n */\nfunction collectDefaultVariants(\n config: CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n): Record<string, unknown> {\n let defaults: Record<string, unknown> = {};\n\n // Collect from extended components\n if (config.extend) {\n for (const ext of config.extend) {\n const extDefaults = ext.getVariants();\n defaults = { ...defaults, ...extDefaults };\n }\n }\n\n // Handle implicit boolean defaults from variants\n // If a variant only has a `false` key and no `true` key, default to false\n if (config.variants) {\n for (const [variantName, variantDef] of Object.entries(config.variants)) {\n if (isStyleClassValue(variantDef)) {\n const keys = Object.keys(variantDef);\n const hasFalseOnly = keys.includes(\"false\") && !keys.includes(\"true\");\n if (hasFalseOnly && defaults[variantName] === undefined) {\n defaults[variantName] = false;\n }\n }\n }\n }\n\n // Override with current config's defaults\n if (config.defaultVariants) {\n defaults = { ...defaults, ...config.defaultVariants };\n }\n\n return defaults;\n}\n\n/**\n * Resolves variant values by merging defaults with provided props.\n */\nfunction resolveVariants(\n config: CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n props: Record<string, unknown> = {},\n): Record<string, unknown> {\n const defaults = collectDefaultVariants(config);\n return { ...defaults, ...props };\n}\n\n/**\n * Gets the value for a single variant based on the variant definition and the\n * selected value.\n */\nfunction getVariantResult(\n variantDef: unknown,\n selectedValue: unknown,\n): { class: ClassValue; style: StyleValue } {\n // Shorthand variant: `disabled: \"disabled-class\"` means { true: \"...\" }\n if (!isStyleClassValue(variantDef)) {\n if (selectedValue === true) {\n return processVariantValue(variantDef);\n }\n return { class: null, style: {} };\n }\n\n // Object variant: { sm: \"...\", lg: \"...\" }\n const key = String(selectedValue);\n const value = (variantDef as Record<string, unknown>)[key];\n if (value === undefined) return { class: null, style: {} };\n\n return processVariantValue(value);\n}\n\n/**\n * Processes extended components and returns base classes and variant classes separately.\n * Base classes should come before current component's base, variant classes come after.\n * When overrideVariantKeys is provided, those variant keys are excluded from the extended\n * component's result (used when current component's computedVariants overrides them).\n */\nfunction processExtended(\n config: CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n resolvedVariants: Record<string, unknown>,\n overrideVariantKeys: Set<string> = new Set(),\n): {\n baseClasses: ClassValue[];\n variantClasses: ClassValue[];\n style: StyleValue;\n} {\n const baseClasses: ClassValue[] = [];\n const variantClasses: ClassValue[] = [];\n let style: StyleValue = {};\n\n if (config.extend) {\n for (const ext of config.extend) {\n // Filter out variant keys that are being overridden by current component's computedVariants\n const filteredVariants = { ...resolvedVariants };\n for (const key of overrideVariantKeys) {\n delete filteredVariants[key];\n }\n\n // Get the result with filtered variants (excluding overridden keys)\n const extResult = ext({ ...filteredVariants });\n\n // Only merge style for non-overridden keys\n const extStyle = normalizeStyle(extResult.style);\n style = { ...style, ...extStyle };\n\n // Get base class from internal property (no variants)\n const baseClass = ext._baseClass;\n baseClasses.push(baseClass);\n\n // Get full class with variants\n const fullClass =\n \"className\" in extResult ? extResult.className : extResult.class;\n\n // Extract variant portion (full class minus base class)\n if (fullClass && baseClass) {\n const baseClassSet = new Set(baseClass.split(\" \").filter(Boolean));\n const variantPortion = fullClass\n .split(\" \")\n .filter((c: string) => c && !baseClassSet.has(c))\n .join(\" \");\n if (variantPortion) {\n variantClasses.push(variantPortion);\n }\n } else if (fullClass && !baseClass) {\n variantClasses.push(fullClass);\n }\n }\n }\n\n return { baseClasses, variantClasses, style };\n}\n\n/**\n * Processes all variants (not extended) and returns accumulated class and\n * style.\n */\nfunction processVariants(\n config: CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n resolvedVariants: Record<string, unknown>,\n): { classes: ClassValue[]; style: StyleValue } {\n const classes: ClassValue[] = [];\n let style: StyleValue = {};\n\n // Process current component's variants\n if (config.variants) {\n for (const [variantName, variantDef] of Object.entries(config.variants)) {\n const selectedValue = resolvedVariants[variantName];\n if (selectedValue === undefined) continue;\n\n const result = getVariantResult(variantDef, selectedValue);\n classes.push(result.class);\n style = { ...style, ...result.style };\n }\n }\n\n // Process computedVariants\n if (config.computedVariants) {\n for (const [variantName, computeFn] of Object.entries(\n config.computedVariants,\n )) {\n const selectedValue = resolvedVariants[variantName];\n if (selectedValue === undefined) continue;\n\n const computedResult = computeFn(selectedValue);\n const result = processVariantValue(computedResult);\n classes.push(result.class);\n style = { ...style, ...result.style };\n }\n }\n\n return { classes, style };\n}\n\n/**\n * Processes the computed function if present.\n */\nfunction processComputed(\n config: CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n resolvedVariants: Record<string, unknown>,\n): {\n classes: ClassValue[];\n style: StyleValue;\n updatedVariants: Record<string, unknown>;\n} {\n const classes: ClassValue[] = [];\n let style: StyleValue = {};\n let updatedVariants = { ...resolvedVariants };\n\n if (config.computed) {\n const context = {\n variants: resolvedVariants,\n setVariants: (newVariants: VariantValues<Record<string, unknown>>) => {\n updatedVariants = { ...updatedVariants, ...newVariants };\n },\n setDefaultVariants: (\n newDefaults: VariantValues<Record<string, unknown>>,\n ) => {\n // Only apply defaults for variants not already set\n for (const [key, value] of Object.entries(newDefaults)) {\n if (resolvedVariants[key] === undefined) {\n updatedVariants[key] = value;\n }\n }\n },\n };\n\n const computedResult = config.computed(context);\n if (computedResult != null) {\n const result = processVariantValue(computedResult);\n classes.push(result.class);\n style = { ...style, ...result.style };\n }\n }\n\n return { classes, style, updatedVariants };\n}\n\n/**\n * Normalizes a key source (array or component) to an object with keys and defaults.\n */\nfunction normalizeKeySource(source: unknown): {\n keys: string[];\n defaults: Record<string, unknown>;\n} {\n if (Array.isArray(source)) {\n return { keys: source as string[], defaults: {} };\n }\n // Components are functions with keys property, onlyVariants are objects with keys\n if (\n source &&\n (typeof source === \"object\" || typeof source === \"function\") &&\n \"keys\" in source\n ) {\n const keys = [...(source as { keys: string[] }).keys] as string[];\n const defaults =\n \"getVariants\" in source\n ? (\n source as { getVariants: () => Record<string, unknown> }\n ).getVariants()\n : {};\n return { keys, defaults };\n }\n return { keys: [], defaults: {} };\n}\n\n/**\n * Splits props into multiple groups based on key sources.\n */\nfunction splitPropsImpl(\n selfKeys: string[],\n selfDefaults: Record<string, unknown>,\n props: Record<string, unknown>,\n sources: Array<{ keys: string[]; defaults: Record<string, unknown> }>,\n): Record<string, unknown>[] {\n const allUsedKeys = new Set<string>(selfKeys);\n const results: Record<string, unknown>[] = [];\n\n // Self result with defaults\n const selfResult: Record<string, unknown> = {};\n // First apply defaults\n for (const [key, value] of Object.entries(selfDefaults)) {\n if (selfKeys.includes(key)) {\n selfResult[key] = value;\n }\n }\n // Then override with props\n for (const key of selfKeys) {\n if (key in props) {\n selfResult[key] = props[key];\n }\n }\n results.push(selfResult);\n\n // Process each source\n for (const source of sources) {\n const sourceResult: Record<string, unknown> = {};\n // First apply defaults\n for (const [key, value] of Object.entries(source.defaults)) {\n if (source.keys.includes(key)) {\n sourceResult[key] = value;\n }\n }\n // Then override with props\n for (const key of source.keys) {\n allUsedKeys.add(key);\n if (key in props) {\n sourceResult[key] = props[key];\n }\n }\n results.push(sourceResult);\n }\n\n // Rest - keys not used by anyone\n const rest: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(props)) {\n if (!allUsedKeys.has(key)) {\n rest[key] = value;\n }\n }\n results.push(rest);\n\n return results;\n}\n\n/**\n * Splits props into multiple groups based on key sources.\n * Each source gets its own result object containing all its matching keys.\n * The last element is always the \"rest\" containing keys not claimed by any source.\n *\n * @example\n * ```ts\n * const [buttonProps, inputProps, rest] = splitProps(\n * props,\n * buttonComponent,\n * inputComponent.onlyVariants,\n * );\n * ```\n */\nexport const splitProps: SplitPropsFunction = ((\n props: Record<string, unknown>,\n source1: unknown,\n ...sources: unknown[]\n) => {\n const normalizedSource1 = normalizeKeySource(source1);\n const normalizedSources = sources.map(normalizeKeySource);\n return splitPropsImpl(\n normalizedSource1.keys,\n normalizedSource1.defaults,\n props,\n normalizedSources,\n );\n}) as SplitPropsFunction;\n\nexport function create<M extends Mode>({\n defaultMode = \"jsx\" as M,\n transformClass = (className) => className,\n}: CreateParams<M> = {}) {\n const cx = (...classes: ClsxClassValue[]) => transformClass(clsx(...classes));\n\n const cv = <\n V extends Variants = {},\n CV extends ComputedVariants = {},\n const E extends AnyComponent[] = [],\n >(\n config: CVConfig<V, CV, E> = {},\n ): Component<V, CV, E, StyleProps[M]> => {\n type MergedVariants = MergeVariants<V, CV, E>;\n\n const variantKeys = collectVariantKeys(\n config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n );\n\n const getClassPropertyName = (mode: Mode) =>\n mode === \"jsx\" ? \"className\" : \"class\";\n\n const getPropsKeys = (mode: Mode) => [\n getClassPropertyName(mode),\n \"style\",\n ...variantKeys,\n ];\n\n const computeResult = (\n props: ComponentProps<MergedVariants> = {},\n ): { className: string; style: StyleValue } => {\n const allClasses: ClassValue[] = [];\n let allStyle: StyleValue = {};\n\n // Extract variant props from input\n const variantProps: Record<string, unknown> = {};\n for (const key of variantKeys) {\n if (key in props) {\n variantProps[key] = (props as Record<string, unknown>)[key];\n }\n }\n\n // Resolve variants with defaults\n let resolvedVariants = resolveVariants(\n config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n variantProps,\n );\n\n // Process computed first to potentially update variants\n const computedResult = processComputed(\n config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n resolvedVariants,\n );\n resolvedVariants = computedResult.updatedVariants;\n\n // Collect computedVariants keys that will override extended variants\n const computedVariantKeys = new Set<string>(\n config.computedVariants ? Object.keys(config.computedVariants) : [],\n );\n\n // Process extended components (separates base and variant classes)\n const extendedResult = processExtended(\n config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n resolvedVariants,\n computedVariantKeys,\n );\n\n // 1. Extended base classes first\n allClasses.push(...extendedResult.baseClasses);\n allStyle = { ...allStyle, ...extendedResult.style };\n\n // 2. Current component's base class\n allClasses.push(config.class);\n\n // 3. Add base style\n if (config.style) {\n allStyle = { ...allStyle, ...config.style };\n }\n\n // 4. Extended variant classes\n allClasses.push(...extendedResult.variantClasses);\n\n // 5. Current component's variants\n const variantsResult = processVariants(\n config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n resolvedVariants,\n );\n allClasses.push(...variantsResult.classes);\n allStyle = { ...allStyle, ...variantsResult.style };\n\n // Add computed results\n allClasses.push(...computedResult.classes);\n allStyle = { ...allStyle, ...computedResult.style };\n\n // Merge class from props\n if (\"class\" in props) {\n allClasses.push(props.class);\n }\n if (\"className\" in props) {\n allClasses.push(props.className);\n }\n\n // Merge style from props\n if (props.style != null) {\n allStyle = { ...allStyle, ...normalizeStyle(props.style) };\n }\n\n return {\n className: cx(...(allClasses as ClsxClassValue[])),\n style: allStyle,\n };\n };\n\n const createModalComponent = <R extends ComponentResult>(\n mode: Mode,\n ): ModalComponent<MergedVariants, R> => {\n const propsKeys = getPropsKeys(mode);\n\n const component = ((props: ComponentProps<MergedVariants> = {}) => {\n const { className, style } = computeResult(props);\n\n if (mode === \"jsx\") {\n return { className, style: styleValueToJSXStyle(style) } as R;\n }\n if (mode === \"html\") {\n return {\n class: className,\n style: styleValueToHTMLStyle(style),\n } as R;\n }\n // htmlObj\n return {\n class: className,\n style: styleValueToHTMLObjStyle(style),\n } as R;\n }) as ModalComponent<MergedVariants, R>;\n\n component.class = (props: ComponentProps<MergedVariants> = {}) => {\n return computeResult(props).className;\n };\n\n component.style = ((props: ComponentProps<MergedVariants> = {}) => {\n const { style } = computeResult(props);\n if (mode === \"jsx\") return styleValueToJSXStyle(style);\n if (mode === \"html\") return styleValueToHTMLStyle(style);\n return styleValueToHTMLObjStyle(style);\n }) as ModalComponent<MergedVariants, R>[\"style\"];\n\n component.getVariants = (\n variants?: VariantValues<MergedVariants>,\n ): VariantValues<MergedVariants> => {\n return resolveVariants(\n config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n variants as VariantValues<Record<string, unknown>>,\n ) as VariantValues<MergedVariants>;\n };\n\n component.keys = propsKeys as (keyof MergedVariants | keyof R)[];\n\n component.onlyVariants = {\n getVariants: (\n variants?: VariantValues<MergedVariants>,\n ): VariantValues<MergedVariants> => {\n return resolveVariants(\n config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n variants as VariantValues<Record<string, unknown>>,\n ) as VariantValues<MergedVariants>;\n },\n keys: variantKeys as (keyof MergedVariants)[],\n } as OnlyVariantsComponent<MergedVariants>;\n\n // Compute base class (without variants) - includes extended base classes\n const extendedBaseClasses: ClassValue[] = [];\n if (config.extend) {\n for (const ext of config.extend) {\n extendedBaseClasses.push(ext._baseClass);\n }\n }\n component._baseClass = cx(\n ...(extendedBaseClasses as ClsxClassValue[]),\n config.class as ClsxClassValue,\n );\n\n return component;\n };\n\n // Create the default modal component\n const defaultComponent = createModalComponent<StyleProps[M]>(defaultMode);\n\n // Create all modal variants\n const jsxComponent = createModalComponent<JSXProps>(\"jsx\");\n const htmlComponent = createModalComponent<HTMLProps>(\"html\");\n const htmlObjComponent = createModalComponent<HTMLObjProps>(\"htmlObj\");\n\n // Build the final component\n const component = defaultComponent as Component<V, CV, E, StyleProps[M]>;\n component.jsx = jsxComponent;\n component.html = htmlComponent;\n component.htmlObj = htmlObjComponent;\n\n return component;\n };\n\n return { cv, cx };\n}\n\nexport const { cv, cx } = create();\n"],"x_google_ignoreList":[0],"mappings":";AAAA,SAAS,EAAE,GAAE;CAAC,IAAI,GAAE,GAAE,IAAE;AAAG,KAAG,YAAU,OAAO,KAAG,YAAU,OAAO,EAAE,MAAG;UAAU,YAAU,OAAO,EAAE,KAAG,MAAM,QAAQ,EAAE,EAAC;EAAC,IAAI,IAAE,EAAE;AAAO,OAAI,IAAE,GAAE,IAAE,GAAE,IAAI,GAAE,OAAK,IAAE,EAAE,EAAE,GAAG,MAAI,MAAI,KAAG,MAAK,KAAG;OAAQ,MAAI,KAAK,EAAE,GAAE,OAAK,MAAI,KAAG,MAAK,KAAG;AAAG,QAAO;;AAAE,SAAgB,OAAM;AAAC,MAAI,IAAI,GAAE,GAAE,IAAE,GAAE,IAAE,IAAG,IAAE,UAAU,QAAO,IAAE,GAAE,IAAI,EAAC,IAAE,UAAU,QAAM,IAAE,EAAE,EAAE,MAAI,MAAI,KAAG,MAAK,KAAG;AAAG,QAAO;;AAAE,mBAAe;;;;;;;;;;ACc/X,SAAgB,cAAc,KAAa;AAEzC,KAAI,IAAI,WAAW,KAAK,CACtB,QAAO;AAET,QAAO,IAAI,QAAQ,eAAe,GAAG,WAAW,OAAO,aAAa,CAAC;;;;;;;;AASvE,SAAgB,cAAc,KAAa;AAEzC,KAAI,IAAI,WAAW,KAAK,CACtB,QAAO;AAET,QAAO,IAAI,QAAQ,WAAW,WAAW,IAAI,OAAO,aAAa,GAAG;;;;;;;;AAStE,SAAgB,iBAAiB,OAAwB;AACvD,KAAI,OAAO,UAAU,SAAU,QAAO;AACtC,QAAO,GAAG,MAAM;;;;;;;;AASlB,SAAgB,sBAAsB,aAAqB;AACzD,KA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;KACP,OAAO,sBAAsB,MAAM;KACpC;AAGH,WAAO;KACL,OAAO;KACP,OAAO,yBAAyB,MAAM;KACvC;;AAGH,eAAU,SAAS,QAAwC,EAAE,KAAK;AAChE,WAAO,cAAc,MAAM,CAAC;;AAG9B,eAAU,UAAU,QAAwC,EAAE,KAAK;IACjE,MAAM,EAAE,UAAU,cAAc,MAAM;AACtC,QAAI,SAAS,MAAO,QAAO,qBAAqB,MAAM;AACtD,QAAI,SAAS,OAAQ,QAAO,sBAAsB,MAAM;AACxD,WAAO,yBAAyB,MAAM;;AAGxC,eAAU,eACR,aACkC;AAClC,WAAO,gBACL,QACA,SACD;;AAGH,eAAU,OAAO;AAEjB,eAAU,eAAe;IACvB,cACE,aACkC;AAClC,YAAO,gBACL,QACA,SACD;;IAEH,MAAM;IACP;GAGD,MAAM,sBAAoC,EAAE;AAC5C,OAAI,OAAO,OACT,MAAK,MAAM,OAAO,OAAO,OACvB,qBAAoB,KAAK,IAAI,WAAW;AAG5C,eAAU,aAAaH,KACrB,GAAI,qBACJ,OAAO,MACR;AAED,UAAOG;;EAIT,MAAM,mBAAmB,qBAAoC,YAAY;EAGzE,MAAM,eAAe,qBAA+B,MAAM;EAC1D,MAAM,gBAAgB,qBAAgC,OAAO;EAC7D,MAAM,mBAAmB,qBAAmC,UAAU;EAGtE,MAAM,YAAY;AAClB,YAAU,MAAM;AAChB,YAAU,OAAO;AACjB,YAAU,UAAU;AAEpB,SAAO;;AAGT,QAAO;EAAE;EAAI;EAAI;;AAGnB,MAAa,EAAE,IAAI,OAAO,QAAQ"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["cx","clsx","cv","component"],"sources":["../../../node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs","../src/utils.ts","../src/index.ts"],"sourcesContent":["function r(e){var t,f,n=\"\";if(\"string\"==typeof e||\"number\"==typeof e)n+=e;else if(\"object\"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=\" \"),n+=f)}else for(f in e)e[f]&&(n&&(n+=\" \"),n+=f);return n}export function clsx(){for(var e,t,f=0,n=\"\",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=\" \"),n+=t);return n}export default clsx;","import type * as CSS from \"csstype\";\nimport type {\n HTMLCSSProperties,\n JSXCSSProperties,\n StyleValue,\n} from \"./types.ts\";\n\nexport const MODES = [\"jsx\", \"html\", \"htmlObj\"] as const;\nexport type Mode = (typeof MODES)[number];\n\n/**\n * Returns the appropriate class property name based on the mode.\n * @example\n * getClassPropertyName(\"jsx\") // \"className\"\n * getClassPropertyName(\"html\") // \"class\"\n */\nexport function getClassPropertyName(mode: Mode) {\n return mode === \"jsx\" ? \"className\" : \"class\";\n}\n\n/**\n * Converts a hyphenated CSS property name to camelCase.\n * @example\n * hyphenToCamel(\"background-color\") // \"backgroundColor\"\n * hyphenToCamel(\"--custom-var\") // \"--custom-var\" (CSS variables are preserved)\n */\nexport function hyphenToCamel(str: string) {\n // CSS custom properties (variables) should not be converted\n if (str.startsWith(\"--\")) {\n return str;\n }\n return str.replace(/-([a-z])/gi, (_, letter) => letter.toUpperCase());\n}\n\n/**\n * Converts a camelCase CSS property name to hyphenated form.\n * @example\n * camelToHyphen(\"backgroundColor\") // \"background-color\"\n * camelToHyphen(\"--customVar\") // \"--customVar\" (CSS variables are preserved)\n */\nexport function camelToHyphen(str: string) {\n // CSS custom properties (variables) should not be converted\n if (str.startsWith(\"--\")) {\n return str;\n }\n return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\n/**\n * Parses a length value, adding \"px\" if it's a number.\n * @example\n * parseLengthValue(16); // \"16px\"\n * parseLengthValue(\"2em\"); // \"2em\"\n */\nexport function parseLengthValue(value: string | number) {\n if (typeof value === \"string\") return value;\n return `${value}px`;\n}\n\n/**\n * Parses a CSS style string into a StyleValue object.\n * @example\n * htmlStyleToStyleValue(\"background-color: red; font-size: 16px;\");\n * // { backgroundColor: \"red\", fontSize: \"16px\" }\n */\nexport function htmlStyleToStyleValue(styleString: string) {\n if (!styleString) return {};\n\n const result: StyleValue = {};\n const declarations = styleString.split(\";\");\n\n for (const declaration of declarations) {\n const trimmed = declaration.trim();\n if (!trimmed) continue;\n\n const colonIndex = trimmed.indexOf(\":\");\n if (colonIndex === -1) continue;\n\n const property = trimmed.slice(0, colonIndex).trim();\n const value = trimmed.slice(colonIndex + 1).trim();\n if (!property) continue;\n if (!value) continue;\n\n const camelProperty = hyphenToCamel(property) as any;\n result[camelProperty] = value;\n }\n\n return result;\n}\n\n/**\n * Converts a hyphenated style object to a camelCase StyleValue object.\n * @example\n * htmlObjStyleToStyleValue({ \"background-color\": \"red\", \"font-size\": \"16px\" });\n * // { backgroundColor: \"red\", fontSize: \"16px\" }\n */\nexport function htmlObjStyleToStyleValue(style: HTMLCSSProperties) {\n const result: StyleValue = {};\n for (const [key, value] of Object.entries(style)) {\n if (value == null) continue;\n const property = hyphenToCamel(key) as any;\n result[property] = parseLengthValue(value);\n }\n return result;\n}\n\n/**\n * Converts a camelCase style object to a StyleValue object.\n * @example\n * jsxStyleToStyleValue({ backgroundColor: \"red\", fontSize: 16 });\n * // { backgroundColor: \"red\", fontSize: \"16px\" }\n */\nexport function jsxStyleToStyleValue(style: JSXCSSProperties) {\n const result: StyleValue = {};\n for (const [key, value] of Object.entries(style)) {\n if (value == null) continue;\n result[key as any] = parseLengthValue(value);\n }\n return result;\n}\n\n/**\n * Converts a StyleValue object to a CSS style string.\n * @example\n * styleValueToHTMLStyle({ backgroundColor: \"red\", fontSize: \"16px\" });\n * // \"background-color: red; font-size: 16px;\"\n */\nexport function styleValueToHTMLStyle(style: StyleValue): string {\n const parts: string[] = [];\n for (const [key, value] of Object.entries(style)) {\n if (value == null) continue;\n parts.push(`${camelToHyphen(key)}: ${value}`);\n }\n if (!parts.length) return \"\";\n return `${parts.join(\"; \")};`;\n}\n\n/**\n * Converts a StyleValue object to a hyphenated style object.\n * @example\n * styleValueToHTMLObjStyle({ backgroundColor: \"red\", fontSize: \"16px\" });\n * // { \"background-color\": \"red\", \"font-size\": \"16px\" }\n */\nexport function styleValueToHTMLObjStyle(style: StyleValue) {\n const result: CSS.PropertiesHyphen = {};\n for (const [key, value] of Object.entries(style)) {\n if (value == null) continue;\n const property = camelToHyphen(key) as keyof HTMLCSSProperties;\n result[property] = value;\n }\n return result;\n}\n\n/**\n * Converts a StyleValue object to a camelCase style object.\n * @example\n * styleValueToJSXStyle({ backgroundColor: \"red\", fontSize: \"16px\" });\n * // { backgroundColor: \"red\", fontSize: \"16px\" }\n */\nexport function styleValueToJSXStyle(style: StyleValue) {\n return style as JSXCSSProperties;\n}\n\n/**\n * Type guard to check if a style object has hyphenated keys.\n * @example\n * isHTMLObjStyle({ \"background-color\": \"red\" }); // true\n * isHTMLObjStyle({ backgroundColor: \"red\" }); // false\n */\nexport function isHTMLObjStyle(\n style: CSS.Properties<any> | CSS.PropertiesHyphen<any>,\n): style is CSS.PropertiesHyphen {\n return Object.keys(style).some(\n (key) => key.includes(\"-\") && !key.startsWith(\"--\"),\n );\n}\n","import clsx, { type ClassValue as ClsxClassValue } from \"clsx\";\nimport type {\n AnyComponent,\n ClassValue,\n Component,\n ComponentProps,\n ComponentResult,\n Computed,\n ComputedVariants,\n ExtendableVariants,\n HTMLObjProps,\n HTMLProps,\n JSXProps,\n MergeVariants,\n ModalComponent,\n SplitPropsFunction,\n StyleClassValue,\n StyleProps,\n StyleValue,\n VariantValues,\n Variants,\n} from \"./types.ts\";\nimport {\n type Mode,\n getClassPropertyName,\n htmlObjStyleToStyleValue,\n htmlStyleToStyleValue,\n isHTMLObjStyle,\n jsxStyleToStyleValue,\n styleValueToHTMLObjStyle,\n styleValueToHTMLStyle,\n styleValueToJSXStyle,\n} from \"./utils.ts\";\n\nexport type { ClassValue, StyleValue, StyleClassValue };\n\nexport type VariantProps<T extends Pick<AnyComponent, \"getVariants\">> =\n ReturnType<T[\"getVariants\"]>;\n\nexport interface CVConfig<\n V extends Variants = {},\n CV extends ComputedVariants = {},\n E extends AnyComponent[] = [],\n> {\n extend?: E;\n class?: ClassValue;\n style?: StyleValue;\n variants?: ExtendableVariants<V, E>;\n computedVariants?: CV;\n defaultVariants?: VariantValues<MergeVariants<V, CV, E>>;\n computed?: Computed<MergeVariants<V, CV, E>>;\n}\n\ninterface CreateParams<M extends Mode> {\n defaultMode?: M;\n transformClass?: (className: string) => string;\n}\n\n/**\n * Checks if a value is a style-class object (has style properties, not just a\n * class value).\n */\nfunction isStyleClassValue(value: unknown): value is StyleClassValue {\n if (typeof value !== \"object\") return false;\n if (value == null) return false;\n if (Array.isArray(value)) return false;\n return true;\n}\n\n/**\n * Converts any style input (string, JSX object, or HTML object) to a\n * normalized StyleValue.\n */\nfunction normalizeStyle(style: unknown): StyleValue {\n if (typeof style === \"string\") {\n return htmlStyleToStyleValue(style);\n }\n if (typeof style === \"object\" && style != null) {\n if (isHTMLObjStyle(style as Record<string, unknown>)) {\n return htmlObjStyleToStyleValue(style as Record<string, string | number>);\n }\n return jsxStyleToStyleValue(style as Record<string, string | number>);\n }\n return {};\n}\n\n/**\n * Extracts class and style from a style-class value object.\n */\nfunction extractStyleClass(value: StyleClassValue): {\n class: ClassValue;\n style: StyleValue;\n} {\n const { class: cls, ...style } = value;\n return { class: cls, style };\n}\n\n/**\n * Processes a variant value to extract class and style.\n */\nfunction processVariantValue(value: unknown): {\n class: ClassValue;\n style: StyleValue;\n} {\n if (isStyleClassValue(value)) {\n return extractStyleClass(value);\n }\n return { class: value as ClassValue, style: {} };\n}\n\n/**\n * Gets all variant keys from a component's config, including extended\n * components.\n */\nfunction collectVariantKeys(\n config: CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n): string[] {\n const keys = new Set<string>();\n\n // Collect from extended components\n if (config.extend) {\n for (const ext of config.extend) {\n for (const key of ext.variantKeys) {\n keys.add(key as string);\n }\n }\n }\n\n // Collect from variants\n if (config.variants) {\n for (const key of Object.keys(config.variants)) {\n keys.add(key);\n }\n }\n\n // Collect from computedVariants\n if (config.computedVariants) {\n for (const key of Object.keys(config.computedVariants)) {\n keys.add(key);\n }\n }\n\n return Array.from(keys);\n}\n\n/**\n * Collects default variants from extended components and the current config.\n * Also handles implicit boolean defaults (when only `false` key exists).\n */\nfunction collectDefaultVariants(\n config: CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n): Record<string, unknown> {\n let defaults: Record<string, unknown> = {};\n\n // Collect from extended components\n if (config.extend) {\n for (const ext of config.extend) {\n const extDefaults = ext.getVariants();\n defaults = { ...defaults, ...extDefaults };\n }\n }\n\n // Handle implicit boolean defaults from variants\n // If a variant only has a `false` key and no `true` key, default to false\n if (config.variants) {\n for (const [variantName, variantDef] of Object.entries(config.variants)) {\n if (isStyleClassValue(variantDef)) {\n const keys = Object.keys(variantDef);\n const hasFalseOnly = keys.includes(\"false\") && !keys.includes(\"true\");\n if (hasFalseOnly && defaults[variantName] === undefined) {\n defaults[variantName] = false;\n }\n }\n }\n }\n\n // Override with current config's defaults\n if (config.defaultVariants) {\n defaults = { ...defaults, ...config.defaultVariants };\n }\n\n return defaults;\n}\n\n/**\n * Resolves variant values by merging defaults with provided props.\n */\nfunction resolveVariants(\n config: CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n props: Record<string, unknown> = {},\n): Record<string, unknown> {\n const defaults = collectDefaultVariants(config);\n return { ...defaults, ...props };\n}\n\n/**\n * Gets the value for a single variant based on the variant definition and the\n * selected value.\n */\nfunction getVariantResult(\n variantDef: unknown,\n selectedValue: unknown,\n): { class: ClassValue; style: StyleValue } {\n // Shorthand variant: `disabled: \"disabled-class\"` means { true: \"...\" }\n if (!isStyleClassValue(variantDef)) {\n if (selectedValue === true) {\n return processVariantValue(variantDef);\n }\n return { class: null, style: {} };\n }\n\n // Object variant: { sm: \"...\", lg: \"...\" }\n const key = String(selectedValue);\n const value = (variantDef as Record<string, unknown>)[key];\n if (value === undefined) return { class: null, style: {} };\n\n return processVariantValue(value);\n}\n\n/**\n * Processes extended components and returns base classes and variant classes separately.\n * Base classes should come before current component's base, variant classes come after.\n * When overrideVariantKeys is provided, those variant keys are excluded from the extended\n * component's result (used when current component's computedVariants overrides them).\n */\nfunction processExtended(\n config: CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n resolvedVariants: Record<string, unknown>,\n overrideVariantKeys: Set<string> = new Set(),\n): {\n baseClasses: ClassValue[];\n variantClasses: ClassValue[];\n style: StyleValue;\n} {\n const baseClasses: ClassValue[] = [];\n const variantClasses: ClassValue[] = [];\n let style: StyleValue = {};\n\n if (config.extend) {\n for (const ext of config.extend) {\n // Filter out variant keys that are being overridden by current component's computedVariants\n const filteredVariants = { ...resolvedVariants };\n for (const key of overrideVariantKeys) {\n delete filteredVariants[key];\n }\n\n // Get the result with filtered variants (excluding overridden keys)\n const extResult = ext({ ...filteredVariants });\n\n // Only merge style for non-overridden keys\n const extStyle = normalizeStyle(extResult.style);\n style = { ...style, ...extStyle };\n\n // Get base class from internal property (no variants)\n const baseClass = ext._baseClass;\n baseClasses.push(baseClass);\n\n // Get full class with variants\n const fullClass =\n \"className\" in extResult ? extResult.className : extResult.class;\n\n // Extract variant portion (full class minus base class)\n if (fullClass && baseClass) {\n const baseClassSet = new Set(baseClass.split(\" \").filter(Boolean));\n const variantPortion = fullClass\n .split(\" \")\n .filter((c: string) => c && !baseClassSet.has(c))\n .join(\" \");\n if (variantPortion) {\n variantClasses.push(variantPortion);\n }\n } else if (fullClass && !baseClass) {\n variantClasses.push(fullClass);\n }\n }\n }\n\n return { baseClasses, variantClasses, style };\n}\n\n/**\n * Processes all variants (not extended) and returns accumulated class and\n * style.\n */\nfunction processVariants(\n config: CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n resolvedVariants: Record<string, unknown>,\n): { classes: ClassValue[]; style: StyleValue } {\n const classes: ClassValue[] = [];\n let style: StyleValue = {};\n\n // Process current component's variants\n if (config.variants) {\n for (const [variantName, variantDef] of Object.entries(config.variants)) {\n const selectedValue = resolvedVariants[variantName];\n if (selectedValue === undefined) continue;\n\n const result = getVariantResult(variantDef, selectedValue);\n classes.push(result.class);\n style = { ...style, ...result.style };\n }\n }\n\n // Process computedVariants\n if (config.computedVariants) {\n for (const [variantName, computeFn] of Object.entries(\n config.computedVariants,\n )) {\n const selectedValue = resolvedVariants[variantName];\n if (selectedValue === undefined) continue;\n\n const computedResult = computeFn(selectedValue);\n const result = processVariantValue(computedResult);\n classes.push(result.class);\n style = { ...style, ...result.style };\n }\n }\n\n return { classes, style };\n}\n\n/**\n * Processes the computed function if present.\n */\nfunction processComputed(\n config: CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n resolvedVariants: Record<string, unknown>,\n propsVariants: Record<string, unknown>,\n): {\n classes: ClassValue[];\n style: StyleValue;\n updatedVariants: Record<string, unknown>;\n} {\n const classes: ClassValue[] = [];\n let style: StyleValue = {};\n let updatedVariants = { ...resolvedVariants };\n\n if (config.computed) {\n const context = {\n variants: resolvedVariants,\n setVariants: (newVariants: VariantValues<Record<string, unknown>>) => {\n updatedVariants = { ...updatedVariants, ...newVariants };\n },\n setDefaultVariants: (\n newDefaults: VariantValues<Record<string, unknown>>,\n ) => {\n // Only apply defaults for variants not explicitly set in props\n for (const [key, value] of Object.entries(newDefaults)) {\n if (propsVariants[key] === undefined) {\n updatedVariants[key] = value;\n }\n }\n },\n };\n\n const computedResult = config.computed(context);\n if (computedResult != null) {\n const result = processVariantValue(computedResult);\n classes.push(result.class);\n style = { ...style, ...result.style };\n }\n }\n\n return { classes, style, updatedVariants };\n}\n\ninterface NormalizedSource {\n keys: string[];\n variantKeys: string[];\n defaults: Record<string, unknown>;\n isComponent: boolean;\n}\n\n/**\n * Normalizes a key source (array or component) to an object with keys, variantKeys, defaults, and isComponent flag.\n */\nfunction normalizeKeySource(source: unknown): NormalizedSource {\n if (Array.isArray(source)) {\n return {\n keys: source as string[],\n variantKeys: source as string[],\n defaults: {},\n isComponent: false,\n };\n }\n // Components are functions with keys and variantKeys properties\n if (\n source &&\n (typeof source === \"object\" || typeof source === \"function\") &&\n \"keys\" in source &&\n \"variantKeys\" in source\n ) {\n const keys = [...(source as { keys: string[] }).keys] as string[];\n const variantKeys = [\n ...(source as { variantKeys: string[] }).variantKeys,\n ] as string[];\n const defaults =\n \"getVariants\" in source\n ? (\n source as { getVariants: () => Record<string, unknown> }\n ).getVariants()\n : {};\n return { keys, variantKeys, defaults, isComponent: true };\n }\n return { keys: [], variantKeys: [], defaults: {}, isComponent: false };\n}\n\n/**\n * Splits props into multiple groups based on key sources.\n * Only the first component claims styling props (class/className/style).\n * Subsequent components only receive variant props.\n * Arrays always receive their listed keys but don't claim styling props.\n */\nfunction splitPropsImpl(\n selfKeys: string[],\n selfVariantKeys: string[],\n selfDefaults: Record<string, unknown>,\n selfIsComponent: boolean,\n props: Record<string, unknown>,\n sources: NormalizedSource[],\n): Record<string, unknown>[] {\n const allUsedKeys = new Set<string>(selfKeys);\n const results: Record<string, unknown>[] = [];\n\n // Track if styling has been claimed by a component\n let stylingClaimed = selfIsComponent;\n\n // Self result with defaults\n const selfResult: Record<string, unknown> = {};\n // First apply defaults\n for (const [key, value] of Object.entries(selfDefaults)) {\n if (selfKeys.includes(key)) {\n selfResult[key] = value;\n }\n }\n // Then override with props\n for (const key of selfKeys) {\n if (key in props) {\n selfResult[key] = props[key];\n }\n }\n results.push(selfResult);\n\n // Process each source\n for (const source of sources) {\n const sourceResult: Record<string, unknown> = {};\n\n // Determine which keys this source should use\n // Components use variantKeys if styling has already been claimed\n // Arrays always use their listed keys\n const effectiveKeys =\n source.isComponent && stylingClaimed ? source.variantKeys : source.keys;\n\n // First apply defaults (only for variant keys if component and styling claimed)\n for (const [key, value] of Object.entries(source.defaults)) {\n if (effectiveKeys.includes(key)) {\n sourceResult[key] = value;\n }\n }\n\n // Then override with props\n for (const key of effectiveKeys) {\n allUsedKeys.add(key);\n if (key in props) {\n sourceResult[key] = props[key];\n }\n }\n results.push(sourceResult);\n\n // If this is a component that hasn't claimed styling yet, mark styling as claimed\n if (source.isComponent && !stylingClaimed) {\n stylingClaimed = true;\n }\n }\n\n // Rest - keys not used by anyone\n const rest: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(props)) {\n if (!allUsedKeys.has(key)) {\n rest[key] = value;\n }\n }\n results.push(rest);\n\n return results;\n}\n\n/**\n * Splits props into multiple groups based on key sources.\n * Each source gets its own result object containing all its matching keys.\n * The first component source claims styling props (class/className/style).\n * Subsequent components only receive variant props.\n * Arrays receive their listed keys but don't claim styling props.\n * The last element is always the \"rest\" containing keys not claimed by any source.\n *\n * @example\n * ```ts\n * const [buttonProps, inputProps, rest] = splitProps(\n * props,\n * buttonComponent,\n * inputComponent,\n * );\n * // buttonProps has class/style + button variants\n * // inputProps has only input variants (no class/style)\n * ```\n */\nexport const splitProps: SplitPropsFunction = ((\n props: Record<string, unknown>,\n source1: unknown,\n ...sources: unknown[]\n) => {\n const normalizedSource1 = normalizeKeySource(source1);\n const normalizedSources = sources.map(normalizeKeySource);\n return splitPropsImpl(\n normalizedSource1.keys,\n normalizedSource1.variantKeys,\n normalizedSource1.defaults,\n normalizedSource1.isComponent,\n props,\n normalizedSources,\n );\n}) as SplitPropsFunction;\n\nexport function create<M extends Mode = \"jsx\">({\n defaultMode = \"jsx\" as M,\n transformClass = (className) => className,\n}: CreateParams<M> = {}) {\n const cx = (...classes: ClsxClassValue[]) => transformClass(clsx(...classes));\n\n const cv = <\n V extends Variants = {},\n CV extends ComputedVariants = {},\n const E extends AnyComponent[] = [],\n >(\n config: CVConfig<V, CV, E> = {},\n ): Component<V, CV, E, StyleProps[M]> => {\n type MergedVariants = MergeVariants<V, CV, E>;\n\n const variantKeys = collectVariantKeys(\n config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n );\n\n const getPropsKeys = (mode: Mode) => [\n getClassPropertyName(mode),\n \"style\",\n ...variantKeys,\n ];\n\n const computeResult = (\n props: ComponentProps<MergedVariants> = {},\n ): { className: string; style: StyleValue } => {\n const allClasses: ClassValue[] = [];\n let allStyle: StyleValue = {};\n\n // Extract variant props from input\n const variantProps: Record<string, unknown> = {};\n for (const key of variantKeys) {\n if (key in props) {\n variantProps[key] = (props as Record<string, unknown>)[key];\n }\n }\n\n // Resolve variants with defaults\n let resolvedVariants = resolveVariants(\n config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n variantProps,\n );\n\n // Process computed first to potentially update variants\n const computedResult = processComputed(\n config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n resolvedVariants,\n variantProps,\n );\n resolvedVariants = computedResult.updatedVariants;\n\n // Collect computedVariants keys that will override extended variants\n const computedVariantKeys = new Set<string>(\n config.computedVariants ? Object.keys(config.computedVariants) : [],\n );\n\n // Process extended components (separates base and variant classes)\n const extendedResult = processExtended(\n config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n resolvedVariants,\n computedVariantKeys,\n );\n\n // 1. Extended base classes first\n allClasses.push(...extendedResult.baseClasses);\n allStyle = { ...allStyle, ...extendedResult.style };\n\n // 2. Current component's base class\n allClasses.push(config.class);\n\n // 3. Add base style\n if (config.style) {\n allStyle = { ...allStyle, ...config.style };\n }\n\n // 4. Extended variant classes\n allClasses.push(...extendedResult.variantClasses);\n\n // 5. Current component's variants\n const variantsResult = processVariants(\n config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n resolvedVariants,\n );\n allClasses.push(...variantsResult.classes);\n allStyle = { ...allStyle, ...variantsResult.style };\n\n // Add computed results\n allClasses.push(...computedResult.classes);\n allStyle = { ...allStyle, ...computedResult.style };\n\n // Merge class from props\n if (\"class\" in props) {\n allClasses.push(props.class);\n }\n if (\"className\" in props) {\n allClasses.push(props.className);\n }\n\n // Merge style from props\n if (props.style != null) {\n allStyle = { ...allStyle, ...normalizeStyle(props.style) };\n }\n\n return {\n className: cx(...(allClasses as ClsxClassValue[])),\n style: allStyle,\n };\n };\n\n const createModalComponent = <R extends ComponentResult>(\n mode: Mode,\n ): ModalComponent<MergedVariants, R> => {\n const propsKeys = getPropsKeys(mode);\n\n const component = ((props: ComponentProps<MergedVariants> = {}) => {\n const { className, style } = computeResult(props);\n\n if (mode === \"jsx\") {\n return { className, style: styleValueToJSXStyle(style) } as R;\n }\n if (mode === \"html\") {\n return {\n class: className,\n style: styleValueToHTMLStyle(style),\n } as R;\n }\n // htmlObj\n return {\n class: className,\n style: styleValueToHTMLObjStyle(style),\n } as R;\n }) as ModalComponent<MergedVariants, R>;\n\n component.class = (props: ComponentProps<MergedVariants> = {}) => {\n return computeResult(props).className;\n };\n\n component.style = ((props: ComponentProps<MergedVariants> = {}) => {\n const { style } = computeResult(props);\n if (mode === \"jsx\") return styleValueToJSXStyle(style);\n if (mode === \"html\") return styleValueToHTMLStyle(style);\n return styleValueToHTMLObjStyle(style);\n }) as ModalComponent<MergedVariants, R>[\"style\"];\n\n component.getVariants = (\n variants?: VariantValues<MergedVariants>,\n ): VariantValues<MergedVariants> => {\n return resolveVariants(\n config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n variants as VariantValues<Record<string, unknown>>,\n ) as VariantValues<MergedVariants>;\n };\n\n component.keys = propsKeys as (keyof MergedVariants | keyof R)[];\n\n component.variantKeys = variantKeys as (keyof MergedVariants)[];\n\n component.propKeys = propsKeys as (keyof MergedVariants | keyof R)[];\n\n // Compute base class (without variants) - includes extended base classes\n const extendedBaseClasses: ClassValue[] = [];\n if (config.extend) {\n for (const ext of config.extend) {\n extendedBaseClasses.push(ext._baseClass);\n }\n }\n component._baseClass = cx(\n ...(extendedBaseClasses as ClsxClassValue[]),\n config.class as ClsxClassValue,\n );\n\n return component;\n };\n\n // Create the default modal component\n const defaultComponent = createModalComponent<StyleProps[M]>(defaultMode);\n\n // Create all modal variants\n const jsxComponent = createModalComponent<JSXProps>(\"jsx\");\n const htmlComponent = createModalComponent<HTMLProps>(\"html\");\n const htmlObjComponent = createModalComponent<HTMLObjProps>(\"htmlObj\");\n\n // Build the final component\n const component = defaultComponent as Component<V, CV, E, StyleProps[M]>;\n component.jsx = jsxComponent;\n component.html = htmlComponent;\n component.htmlObj = htmlObjComponent;\n\n return component;\n };\n\n return { cv, cx };\n}\n\nexport const { cv, cx } = create();\n"],"x_google_ignoreList":[0],"mappings":";AAAA,SAAS,EAAE,GAAE;CAAC,IAAI,GAAE,GAAE,IAAE;AAAG,KAAG,YAAU,OAAO,KAAG,YAAU,OAAO,EAAE,MAAG;UAAU,YAAU,OAAO,EAAE,KAAG,MAAM,QAAQ,EAAE,EAAC;EAAC,IAAI,IAAE,EAAE;AAAO,OAAI,IAAE,GAAE,IAAE,GAAE,IAAI,GAAE,OAAK,IAAE,EAAE,EAAE,GAAG,MAAI,MAAI,KAAG,MAAK,KAAG;OAAQ,MAAI,KAAK,EAAE,GAAE,OAAK,MAAI,KAAG,MAAK,KAAG;AAAG,QAAO;;AAAE,SAAgB,OAAM;AAAC,MAAI,IAAI,GAAE,GAAE,IAAE,GAAE,IAAE,IAAG,IAAE,UAAU,QAAO,IAAE,GAAE,IAAI,EAAC,IAAE,UAAU,QAAM,IAAE,EAAE,EAAE,MAAI,MAAI,KAAG,MAAK,KAAG;AAAG,QAAO;;AAAE,mBAAe;;;;;;;;;;ACgB/X,SAAgB,qBAAqB,MAAY;AAC/C,QAAO,SAAS,QAAQ,cAAc;;;;;;;;AASxC,SAAgB,cAAc,KAAa;AAEzC,KAAI,IAAI,WAAW,KAAK,CACtB,QAAO;AAET,QAAO,IAAI,QAAQ,eAAe,GAAG,WAAW,OAAO,aAAa,CAAC;;;;;;;;AASvE,SAAgB,cAAc,KAAa;AAEzC,KAAI,IAAI,WAAW,KAAK,CACtB,QAAO;AAET,QAAO,IAAI,QAAQ,WAAW,WAAW,IAAI,OAAO,aAAa,GAAG;;;;;;;;AAStE,SAAgB,iBAAiB,OAAwB;AACvD,KAAI,OAAO,UAAU,SAAU,QAAO;AACtC,QAAO,GAAG,MAAM;;;;;;;;AASlB,SAAgB,sBAAsB,aAAqB;AACzD,KAAI,CAAC,YAAa,QAAO,EAA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