css-variants 1.1.3 → 2.0.1

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.
Files changed (64) hide show
  1. package/README.md +113 -153
  2. package/dist/cjs/cv.d.ts +48 -2
  3. package/dist/cjs/cv.js +56 -42
  4. package/dist/cjs/cv.js.map +1 -1
  5. package/dist/cjs/cx.d.ts +4 -2
  6. package/dist/cjs/cx.js +49 -34
  7. package/dist/cjs/cx.js.map +1 -1
  8. package/dist/cjs/index.d.ts +3 -2
  9. package/dist/cjs/index.js +3 -1
  10. package/dist/cjs/index.js.map +1 -1
  11. package/dist/cjs/scv.d.ts +56 -0
  12. package/dist/cjs/scv.js +98 -0
  13. package/dist/cjs/scv.js.map +1 -0
  14. package/dist/cjs/ssv.d.ts +51 -0
  15. package/dist/cjs/ssv.js +85 -0
  16. package/dist/cjs/ssv.js.map +1 -0
  17. package/dist/cjs/sv.d.ts +44 -0
  18. package/dist/cjs/sv.js +73 -0
  19. package/dist/cjs/sv.js.map +1 -0
  20. package/dist/cjs/utils/compact.d.ts +1 -0
  21. package/dist/cjs/utils/compact.js +13 -0
  22. package/dist/cjs/utils/compact.js.map +1 -0
  23. package/dist/cjs/utils/types.d.ts +14 -0
  24. package/dist/cjs/{types.js.map → utils/types.js.map} +1 -1
  25. package/dist/esm/cv.d.ts +48 -2
  26. package/dist/esm/cv.js +56 -42
  27. package/dist/esm/cv.js.map +1 -1
  28. package/dist/esm/cx.d.ts +4 -2
  29. package/dist/esm/cx.js +47 -31
  30. package/dist/esm/cx.js.map +1 -1
  31. package/dist/esm/index.d.ts +3 -2
  32. package/dist/esm/index.js +3 -1
  33. package/dist/esm/index.js.map +1 -1
  34. package/dist/esm/scv.d.ts +56 -0
  35. package/dist/esm/scv.js +94 -0
  36. package/dist/esm/scv.js.map +1 -0
  37. package/dist/esm/ssv.d.ts +51 -0
  38. package/dist/esm/ssv.js +81 -0
  39. package/dist/esm/ssv.js.map +1 -0
  40. package/dist/esm/sv.d.ts +44 -0
  41. package/dist/esm/sv.js +69 -0
  42. package/dist/esm/sv.js.map +1 -0
  43. package/dist/esm/utils/compact.d.ts +1 -0
  44. package/dist/esm/utils/compact.js +10 -0
  45. package/dist/esm/utils/compact.js.map +1 -0
  46. package/dist/esm/utils/types.d.ts +14 -0
  47. package/dist/esm/{types.js.map → utils/types.js.map} +1 -1
  48. package/package.json +13 -10
  49. package/dist/cjs/csv.d.ts +0 -3
  50. package/dist/cjs/csv.js +0 -83
  51. package/dist/cjs/csv.js.map +0 -1
  52. package/dist/cjs/types.d.ts +0 -46
  53. package/dist/cjs/utils.d.ts +0 -6
  54. package/dist/cjs/utils.js +0 -42
  55. package/dist/cjs/utils.js.map +0 -1
  56. package/dist/esm/csv.d.ts +0 -3
  57. package/dist/esm/csv.js +0 -79
  58. package/dist/esm/csv.js.map +0 -1
  59. package/dist/esm/types.d.ts +0 -46
  60. package/dist/esm/utils.d.ts +0 -6
  61. package/dist/esm/utils.js +0 -35
  62. package/dist/esm/utils.js.map +0 -1
  63. /package/dist/cjs/{types.js → utils/types.js} +0 -0
  64. /package/dist/esm/{types.js → utils/types.js} +0 -0
package/README.md CHANGED
@@ -44,7 +44,7 @@ Thank you to the authors and contributors of these projects for their innovative
44
44
  * [Overriding styles](#overriding-styles)
45
45
  * [Overriding styles on a single component](#overriding-styles-on-a-single-component)
46
46
  * [Overriding styles on a component with slots](#overriding-styles-on-a-component-with-slots)
47
- * [Handling Style Conflicts](#handling-style-conflicts)
47
+ * [Custom function to resolve class names](#custom-function-to-resolve-class-names)
48
48
  * [TypeScript](#typeScript)
49
49
  * [Contribute](#contribute)
50
50
  * [License](#license)
@@ -75,31 +75,39 @@ const button = cv({
75
75
  color: {
76
76
  primary: 'bg-blue-500 hover:bg-blue-700',
77
77
  secondary: 'bg-purple-500 hover:bg-purple-700',
78
+ success: 'hover:bg-green-700',
79
+ },
80
+ },
81
+ })
82
+
83
+ button({ color: 'secondary' })
84
+ // => 'font-bold rounded-sm bg-purple-500 hover:bg-purple-700'
85
+ ```
86
+
87
+ ```ts
88
+ import { sv } from 'css-variants'
89
+
90
+ const button = sv({
91
+ base: {
92
+ fontWeight: 700,
93
+ },
94
+ variants: {
95
+ color: {
96
+ primary: {
97
+ color: 'blue',
98
+ },
99
+ secondary: {
100
+ color: 'red',
101
+ },
78
102
  success: {
79
- className: 'hover:bg-green-700',
80
- style: { color: 'green' }, // You can also use inline style
103
+ color: 'green',
81
104
  },
82
105
  },
83
106
  },
84
107
  })
85
108
 
86
109
  button({ color: 'secondary' })
87
- /**
88
- * Result:
89
- * {
90
- * className: 'font-bold rounded-sm bg-purple-500 hover:bg-purple-700',
91
- * style: {},
92
- * }
93
- */
94
-
95
- button({ color: 'success' })
96
- /**
97
- * Result:
98
- * {
99
- * className: 'font-bold rounded-sm hover:bg-green-700',
100
- * style: { color: 'green' },
101
- * }
102
- */
110
+ // => { fontWeight: 700, color: 'red' }
103
111
  ```
104
112
 
105
113
  ### Multiple variants
@@ -110,10 +118,7 @@ You can add multiple variants to a single component.
110
118
  import { cv } from 'css-variants'
111
119
 
112
120
  const button = cv({
113
- base: {
114
- className: 'font-bold',
115
- style: { borderRadius: 16 },
116
- },
121
+ base: 'font-bold',
117
122
  variants: {
118
123
  color: {
119
124
  primary: 'bg-blue-500 hover:bg-blue-700',
@@ -129,13 +134,7 @@ const button = cv({
129
134
  })
130
135
 
131
136
  button({ color: 'success', size: 'lg' })
132
- /**
133
- * Result:
134
- * {
135
- * className: 'font-bold bg-green-500 hover:bg-green-700 text-lg p-6',
136
- * style: { borderRadius: 16 },
137
- * }
138
- */
137
+ // => 'font-bold bg-green-500 hover:bg-green-700 text-lg p-6'
139
138
  ```
140
139
 
141
140
  ### Boolean variants
@@ -146,9 +145,6 @@ You can also add boolean variants to a component. This is useful when you want t
146
145
  import { cv } from 'css-variants'
147
146
 
148
147
  const button = cv({
149
- base: {
150
- style: { fontWeight: 'bold' },
151
- },
152
148
  variants: {
153
149
  color: {
154
150
  primary: 'bg-blue-500 hover:bg-blue-700',
@@ -162,13 +158,7 @@ const button = cv({
162
158
  })
163
159
 
164
160
  button({ disabled: true })
165
- /**
166
- * Result:
167
- * {
168
- * className: 'opacity-50 pointer-events-none',
169
- * style: { fontWeight: 'bold' },
170
- * }
171
- */
161
+ // => 'opacity-50 pointer-events-none'
172
162
  ```
173
163
 
174
164
  ### Compound variants
@@ -179,17 +169,11 @@ Sometimes you might want to add a variant that depends on another variant. This
179
169
  import { cv } from 'css-variants'
180
170
 
181
171
  const button = cv({
182
- base: {
183
- style: { fontWeight: 'bold' },
184
- },
185
172
  variants: {
186
173
  size: {
187
174
  sm: 'text-sm p-2',
188
175
  md: 'text-md p-4',
189
- lg: {
190
- className: 'text-lg',
191
- style: { padding: 6 },
192
- },
176
+ lg: 'text-lg',
193
177
  },
194
178
  disabled: {
195
179
  true: 'opacity-50 pointer-events-none',
@@ -200,19 +184,12 @@ const button = cv({
200
184
  size: 'lg', // You can also use the values as an array
201
185
  disabled: true,
202
186
  className: 'uppercase',
203
- style: { padding: 5 },
204
187
  }
205
188
  ],
206
189
  })
207
190
 
208
191
  button({ size: 'lg', disabled: true })
209
- /**
210
- * Result:
211
- * {
212
- * className: 'text-lg p-6 opacity-50 pointer-events-none uppercase',
213
- * style: { fontWeight: 'bold', padding: 5 },
214
- * }
215
- */
192
+ // => 'text-lg p-6 opacity-50 pointer-events-none uppercase'
216
193
  ```
217
194
 
218
195
  ### Default variants
@@ -237,13 +214,7 @@ const button = cv({
237
214
  })
238
215
 
239
216
  button()
240
- /**
241
- * Result:
242
- * {
243
- * className: 'font-bold rounded-sm bg-blue-500 hover:bg-blue-700',
244
- * style: {},
245
- * }
246
- */
217
+ // => 'font-bold rounded-sm bg-blue-500 hover:bg-blue-700'
247
218
  ```
248
219
 
249
220
  ## Slots
@@ -255,16 +226,13 @@ Slots allows you to separate a component into multiple parts.
255
226
  You can add `slots` by using the slots key. There's no limit to how many slots you can add.
256
227
 
257
228
  ```ts
258
- import { csv } from 'css-variants'
229
+ import { scv } from 'css-variants'
259
230
 
260
- const notification = cv({
231
+ const notification = scv({
261
232
  slots: ['root', 'title'],
262
233
  base: {
263
234
  root: 'root',
264
- title: {
265
- className: 'title',
266
- style: { fontSize: 16 },
267
- },
235
+ title: 'title',
268
236
  },
269
237
  })
270
238
 
@@ -272,17 +240,35 @@ notification()
272
240
  /**
273
241
  * Result:
274
242
  * {
275
- * root: {
276
- * className: 'root',
277
- * style: {},
278
- * },
279
- * title: {
280
- * className: 'title',
281
- * style: { fontSize: 16 },
282
- * },
243
+ * root: 'root',
244
+ * title: 'title',
283
245
  * }
284
246
  */
247
+ ```
248
+
249
+ ```ts
250
+ import { ssv } from 'css-variants'
285
251
 
252
+ const notification = ssv({
253
+ slots: ['root', 'title'],
254
+ base: {
255
+ root: {
256
+ fontWeight: 'bold',
257
+ },
258
+ title: {
259
+ fontSize: '20px',
260
+ }
261
+ },
262
+ })
263
+
264
+ notification()
265
+ /**
266
+ * Result:
267
+ * {
268
+ * root: { fontWeight: 'bold' },
269
+ * title: { fontSize: '20px' },
270
+ * }
271
+ */
286
272
  ```
287
273
 
288
274
  ### Slots with variants
@@ -297,10 +283,7 @@ const notification = cv({
297
283
  base: {
298
284
  root: 'root',
299
285
  title: 'title',
300
- content: {
301
- className: 'content',
302
- style: { fontSize: 16 },
303
- },
286
+ content: 'content',
304
287
  },
305
288
  variants: {
306
289
  color: {
@@ -321,18 +304,9 @@ notification({ color: 'primary' })
321
304
  /**
322
305
  * Result:
323
306
  * {
324
- * root: {
325
- * className: 'root root-primary',
326
- * style: {},
327
- * },
328
- * title: {
329
- * className: 'title title-primary',
330
- * style: {},
331
- * },
332
- * content: {
333
- * className: 'content content-primary',
334
- * style: { fontSize: 16 },
335
- * },
307
+ * root: 'root root-primary',
308
+ * title: 'title title-primary',
309
+ * content: 'content content-primary',
336
310
  * }
337
311
  */
338
312
 
@@ -340,18 +314,9 @@ notification({ color: 'secondary' })
340
314
  /**
341
315
  * Result:
342
316
  * {
343
- * root: {
344
- * className: 'root',
345
- * style: {},
346
- * },
347
- * title: {
348
- * className: 'title title-secondary',
349
- * style: {},
350
- * },
351
- * content: {
352
- * className: 'content content-secondary',
353
- * style: { fontSize: 16 },
354
- * },
317
+ * root: 'root',
318
+ * title: 'title title-secondary',
319
+ * content: 'content content-secondary',
355
320
  * }
356
321
  */
357
322
  ```
@@ -380,18 +345,34 @@ const button = cv({
380
345
  button({
381
346
  color: 'secondary',
382
347
  className: 'border-purple-600',
383
- style: {
384
- color: 'purple',
348
+ })
349
+ // => 'bg-purple-500 hover:bg-purple-700 border-purple-600'
350
+ ```
351
+
352
+ ```ts
353
+ import { sv } from 'css-variants'
354
+
355
+ const button = cv({
356
+ base: {
357
+ fontWeight: 700,
385
358
  },
359
+ variants: {
360
+ color: {
361
+ primary: {
362
+ color: 'blue',
363
+ },
364
+ secondary: {
365
+ color: 'purple',
366
+ },
367
+ }
368
+ }
386
369
  })
387
370
 
388
- /**
389
- * Result:
390
- * {
391
- * className: 'bg-purple-500 hover:bg-purple-700 border-purple-600',
392
- * style: { color: 'purple' },
393
- * }
394
- */
371
+ button({
372
+ color: 'secondary',
373
+ style: { color: 'red' },
374
+ })
375
+ // => { fontWeight: 700, color: 'red' }
395
376
  ```
396
377
 
397
378
  ### Overriding styles on a component with slots
@@ -405,10 +386,7 @@ const notification = cv({
405
386
  slots: ['root', 'title'],
406
387
  base: {
407
388
  root: 'root',
408
- title: {
409
- className: 'title',
410
- style: { fontSize: 16 },
411
- },
389
+ title: 'title',
412
390
  },
413
391
  })
414
392
 
@@ -416,53 +394,38 @@ notification({
416
394
  classNames: {
417
395
  root: 'root-custom-class',
418
396
  },
419
- styles: {
420
- title: {
421
- fontSize: 20,
422
- }
423
- },
424
397
  })
425
398
  /**
426
399
  * Result:
427
400
  * {
428
- * root: {
429
- * className: 'root-custom-class',
430
- * style: {},
431
- * },
432
- * title: {
433
- * className: 'title',
434
- * style: { fontSize: 20 },
435
- * },
401
+ * root: 'root root-custom-class',
402
+ * title: 'title',
436
403
  * }
437
404
  */
438
405
 
439
406
  ```
440
407
 
441
- ## Handling Style Conflicts
442
-
443
- Although `css-variants` is designed to help you avoid styling conflicts, there's still a small margin of error when combining multiple classes or variants. To further minimize these conflicts and ensure consistent styling, you can integrate `tailwind-merge` into your project.
408
+ ## Custom function to resolve class names
444
409
 
445
- `tailwind-merge` is a utility that intelligently combines Tailwind CSS classes, resolving conflicts by giving precedence to the latter class when two classes target the same style property. By incorporating `tailwind-merge` with `css-variants`, you can create more robust components that automatically handle class conflicts.
410
+ Default is the internal 'cx' function. The resolver function should accept multiple class name arguments and return a single concatenated string.
446
411
 
447
- The following example demonstrates how to extend functions from `css-variants` to use `tailwind-merge`. This integration ensures that your components will have consistent styling, even when multiple classes or variants are applied.
412
+ You can use this to integrate with class name utilities like clsx, classnames, or your own custom class name resolution logic.
448
413
 
449
414
  ```ts
450
- import { twMerge } from 'tailwind-merge'
451
- import { cx as baseCx, cv as baseCv } from 'css-variants'
415
+ import { clsx } from 'clsx'
416
+ import { cv as _cv, scv as _scv } from 'css-variants'
452
417
 
453
- export const cx: typeof baseCx = (...args) => twMerge(baseCx(...args))
454
-
455
- export const cv: typeof baseCv = (config) => {
456
- return baseCv({
418
+ export const cv: typeof _cv = (config) => {
419
+ return _cv({
457
420
  ...config,
458
- onDone: ({ className, style }) => {
459
- const css = {
460
- style,
461
- className: twMerge(className),
462
- }
421
+ classNameResolver: clsx,
422
+ })
423
+ }
463
424
 
464
- return config.onDone ? config.onDone(css) : css
465
- },
425
+ export const scv: typeof _scv = (config) => {
426
+ return _scv({
427
+ ...config,
428
+ classNameResolver: clsx,
466
429
  })
467
430
  }
468
431
  ```
@@ -471,11 +434,8 @@ export const cv: typeof baseCv = (config) => {
471
434
 
472
435
  ### Extracting Variant Types
473
436
 
474
- You can use the `VariantProps` utility to extract variants from a component.
475
-
476
437
  ```tsx
477
- import { VariantProps } from 'css-variants'
478
- import { cv } from 'class-variance-authority'
438
+ import { cv } from 'css-variants'
479
439
 
480
440
  export const button = cv({
481
441
  variants: {
@@ -486,7 +446,7 @@ export const button = cv({
486
446
  },
487
447
  })
488
448
 
489
- export type ButtonProps = VariantProps<typeof button>
449
+ export type ButtonProps = Parameters<typeof button>[0]
490
450
  ```
491
451
 
492
452
  ## Contribute
package/dist/cjs/cv.d.ts CHANGED
@@ -1,3 +1,49 @@
1
- import { VariantCreatorFn } from './types';
2
- export declare const cv: VariantCreatorFn;
1
+ import { ObjectKeyPicker, ObjectKeyArrayPicker } from './utils/types';
2
+ import { cx, ClassValue } from './cx';
3
+ export type ClassVariantRecord = Record<string, Record<string, ClassValue>>;
4
+ export interface ClassVariantDefinition<T extends ClassVariantRecord | undefined> {
5
+ base?: ClassValue;
6
+ variants?: T;
7
+ compoundVariants?: (ObjectKeyArrayPicker<T> & {
8
+ className: ClassValue;
9
+ })[];
10
+ defaultVariants?: ObjectKeyPicker<T>;
11
+ classNameResolver?: typeof cx;
12
+ }
13
+ export type ClassVariantFn<T extends ClassVariantRecord | undefined> = (props?: ObjectKeyPicker<T> & {
14
+ className?: ClassValue;
15
+ }) => string;
16
+ export type ClassVariantCreatorFn = <T extends ClassVariantRecord | undefined>(config: ClassVariantDefinition<T>) => ClassVariantFn<T>;
17
+ /**
18
+ * Creates a class variant function that combines base classes, variants, compound variants, and default variants.
19
+ *
20
+ * @template T - Type of the variant record
21
+ * @param config - Configuration object for creating class variants
22
+ * @returns A function that accepts variant props and returns a combined class string
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * const button = cv({
27
+ * base: 'px-4 py-2 rounded',
28
+ * variants: {
29
+ * color: {
30
+ * primary: 'bg-blue-500 text-white',
31
+ * secondary: 'bg-gray-500 text-white'
32
+ * },
33
+ * size: {
34
+ * sm: 'text-sm',
35
+ * lg: 'text-lg'
36
+ * }
37
+ * },
38
+ * defaultVariants: {
39
+ * color: 'primary',
40
+ * size: 'sm'
41
+ * }
42
+ * });
43
+ *
44
+ * button(); // => 'px-4 py-2 rounded bg-blue-500 text-white text-sm'
45
+ * button({ color: 'secondary' }); // => 'px-4 py-2 rounded bg-gray-500 text-white text-sm'
46
+ * ```
47
+ */
48
+ export declare const cv: ClassVariantCreatorFn;
3
49
  export default cv;
package/dist/cjs/cv.js CHANGED
@@ -1,56 +1,70 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.cv = void 0;
4
- const utils_1 = require("./utils");
5
- const push = (data, value) => {
6
- if (typeof value === 'string') {
7
- data.className && (data.className += ' ');
8
- data.className += value.trim();
9
- }
10
- else {
11
- if (value?.className) {
12
- data.className && (data.className += ' ');
13
- data.className += value.className.trim();
14
- }
15
- if (value?.style) {
16
- data.style = { ...data.style, ...value.style };
17
- }
18
- }
19
- };
4
+ const compact_1 = require("./utils/compact");
5
+ const cx_1 = require("./cx");
6
+ /**
7
+ * Creates a class variant function that combines base classes, variants, compound variants, and default variants.
8
+ *
9
+ * @template T - Type of the variant record
10
+ * @param config - Configuration object for creating class variants
11
+ * @returns A function that accepts variant props and returns a combined class string
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const button = cv({
16
+ * base: 'px-4 py-2 rounded',
17
+ * variants: {
18
+ * color: {
19
+ * primary: 'bg-blue-500 text-white',
20
+ * secondary: 'bg-gray-500 text-white'
21
+ * },
22
+ * size: {
23
+ * sm: 'text-sm',
24
+ * lg: 'text-lg'
25
+ * }
26
+ * },
27
+ * defaultVariants: {
28
+ * color: 'primary',
29
+ * size: 'sm'
30
+ * }
31
+ * });
32
+ *
33
+ * button(); // => 'px-4 py-2 rounded bg-blue-500 text-white text-sm'
34
+ * button({ color: 'secondary' }); // => 'px-4 py-2 rounded bg-gray-500 text-white text-sm'
35
+ * ```
36
+ */
20
37
  const cv = (config) => {
21
- const { base, variants, compoundVariants, defaultVariants, onDone } = config;
38
+ const { base, variants, compoundVariants, defaultVariants, classNameResolver = cx_1.cx } = config;
22
39
  return (props) => {
23
- const { className: propClassName, style: propStyle, ...rest } = props ?? {};
24
- const variantProps = { ...defaultVariants, ...(0, utils_1.compact)(rest) };
25
- const css = { className: '', style: {} };
26
- let tmp;
27
- if (base) {
28
- push(css, base);
29
- }
30
- if (variants) {
31
- for (const [key, variant] of (0, utils_1.entries)(variants)) {
32
- if ((tmp = variant[variantProps[key]])) {
33
- push(css, tmp);
34
- }
40
+ const { className, ...rest } = props ?? {};
41
+ if (!variants)
42
+ return classNameResolver(base, className);
43
+ const mergedProps = { ...defaultVariants, ...(0, compact_1.compact)(rest) };
44
+ const classValues = [];
45
+ for (const key in mergedProps) {
46
+ const classValue = variants[key][mergedProps[key]];
47
+ if (classValue) {
48
+ classValues.push(classValue);
35
49
  }
36
50
  }
37
51
  if (compoundVariants) {
38
- for (const { className: cvClassName, style: cvStyle, ...compoundVariant } of compoundVariants) {
39
- if ((0, utils_1.match)(compoundVariant, variantProps)) {
40
- push(css, { className: cvClassName, style: cvStyle });
52
+ for (const { className: classValue, ...compoundVariant } of compoundVariants) {
53
+ let matches = true;
54
+ for (const key in compoundVariant) {
55
+ const value = compoundVariant[key];
56
+ const propValue = mergedProps[key];
57
+ if (Array.isArray(value) ? !value.includes(propValue) : value !== propValue) {
58
+ matches = false;
59
+ break;
60
+ }
61
+ }
62
+ if (matches) {
63
+ classValues.push(classValue);
41
64
  }
42
65
  }
43
66
  }
44
- if (propClassName) {
45
- css.className && (css.className += ' ');
46
- css.className += propClassName;
47
- }
48
- if (propStyle) {
49
- css.style = { ...css.style, ...propStyle };
50
- }
51
- if (onDone)
52
- return onDone(css);
53
- return css;
67
+ return classNameResolver(base, classValues, className);
54
68
  };
55
69
  };
56
70
  exports.cv = cv;
@@ -1 +1 @@
1
- {"version":3,"file":"cv.js","sourceRoot":"","sources":["../../src/cv.ts"],"names":[],"mappings":";;;AAAA,mCAAiD;AAGjD,MAAM,IAAI,GAAG,CAAC,IAAkB,EAAE,KAAqC,EAAE,EAAE;IACzE,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CA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C;gBACH,CAAC;gBACD,IAAI,OAAO,EAAE,CAAC;oBACZ,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;gBAC9B,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,iBAAiB,CAAC,IAAI,EAAE,WAAW,EAAE,SAAS,CAAC,CAAA;IACxD,CAAC,CAAA;AACH,CAAC,CAAA;AArCY,QAAA,EAAE,MAqCd;AAED,kBAAe,UAAE,CAAA"}
package/dist/cjs/cx.d.ts CHANGED
@@ -1,3 +1,5 @@
1
- type Arg = string | number | null | undefined | Record<string, boolean>;
2
- export declare const cx: (...args: (Arg | Arg[])[]) => string;
1
+ export type ClassDictionary = Record<string, boolean | string | number>;
2
+ export type ClassValue = ClassValue[] | string | number | bigint | ClassDictionary | null | boolean | undefined;
3
+ export type ClassArray = ClassValue[];
4
+ export declare function cx(...args: ClassValue[]): string;
3
5
  export default cx;