nestable-tailwind-variants 0.2.1 → 0.3.0

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/README.md CHANGED
@@ -73,11 +73,11 @@ npm install nestable-tailwind-variants
73
73
 
74
74
  ### `$base` - Always-applied styles
75
75
 
76
- The `$base` property defines styles that are always included in the output:
76
+ The `$base` property defines styles that are always applied at that level. It can be used at the top level or nested inside variants and conditions:
77
77
 
78
78
  ```ts
79
79
  interface CardProps {
80
- variant: 'elevated' | 'flat';
80
+ variant?: 'elevated' | 'flat';
81
81
  }
82
82
 
83
83
  const card = ntv<CardProps>({
@@ -96,14 +96,129 @@ card({ variant: 'elevated' });
96
96
  // Note: shadow-md is replaced by shadow-xl via tailwind-merge
97
97
  ```
98
98
 
99
+ When nested inside a variant or condition, `$base` applies whenever that context is entered:
100
+
101
+ ```ts
102
+ interface ButtonProps {
103
+ variant?: 'primary' | 'secondary';
104
+ size?: 'sm' | 'lg';
105
+ }
106
+
107
+ const button = ntv<ButtonProps>({
108
+ $base: 'px-4 py-2',
109
+ variant: {
110
+ primary: {
111
+ $base: 'bg-blue-500 text-white', // Applied when variant='primary'
112
+ size: {
113
+ sm: 'text-sm',
114
+ lg: 'text-lg',
115
+ },
116
+ },
117
+ secondary: 'bg-gray-500',
118
+ },
119
+ });
120
+
121
+ button({ variant: 'primary' });
122
+ // => 'px-4 py-2 bg-blue-500 text-white'
123
+
124
+ button({ variant: 'primary', size: 'sm' });
125
+ // => 'px-4 py-2 bg-blue-500 text-white text-sm'
126
+ ```
127
+
128
+ ### `$default` - Fallback styles
129
+
130
+ Use `$default` for styles applied when no conditions match at that level. Within variants, `$default` can also contain nested conditions:
131
+
132
+ ```ts
133
+ interface ChipProps {
134
+ variant?: 'filled' | 'outlined';
135
+ isSelected?: boolean;
136
+ }
137
+
138
+ const chip = ntv<ChipProps>({
139
+ $base: 'inline-flex items-center rounded-full px-3 py-1',
140
+ variant: {
141
+ $default: {
142
+ $base: 'bg-gray-100', // Applied when variant is not specified
143
+ isSelected: 'bg-gray-200', // Applied when isSelected and no variant
144
+ },
145
+ filled: {
146
+ $default: 'bg-gray-200 text-gray-800', // Applied when isSelected is false
147
+ isSelected: 'bg-blue-500 text-white',
148
+ },
149
+ outlined: {
150
+ $default: 'border border-gray-300 text-gray-800',
151
+ isSelected: 'border-blue-500 text-blue-500',
152
+ },
153
+ },
154
+ });
155
+
156
+ chip();
157
+ // => 'inline-flex items-center rounded-full px-3 py-1 bg-gray-100'
158
+
159
+ chip({ isSelected: true });
160
+ // => 'inline-flex items-center rounded-full px-3 py-1 bg-gray-200'
161
+
162
+ chip({ variant: 'filled' });
163
+ // => 'inline-flex items-center rounded-full px-3 py-1 bg-gray-200 text-gray-800'
164
+
165
+ chip({ variant: 'filled', isSelected: true });
166
+ // => 'inline-flex items-center rounded-full px-3 py-1 bg-blue-500 text-white'
167
+ ```
168
+
169
+ > **Note:** Within variant conditions, `$default` is only available when the variant key is optional. Required variant keys always have a value provided, so there's no fallback case:
170
+ >
171
+ > ```ts
172
+ > // ❌ Error: variant is required, so $default is not allowed
173
+ > ntv<{ variant: 'a' | 'b' }>({
174
+ > variant: {
175
+ > a: 'a-class',
176
+ > b: 'b-class',
177
+ > $default: 'default-class', // TypeScript error
178
+ > },
179
+ > });
180
+ >
181
+ > // ✅ OK: variant is optional, so $default is allowed
182
+ > ntv<{ variant?: 'a' | 'b' }>({
183
+ > variant: {
184
+ > a: 'a-class',
185
+ > b: 'b-class',
186
+ > $default: 'default-class',
187
+ > },
188
+ > });
189
+ > ```
190
+
191
+ ### `$base` vs `$default`
192
+
193
+ - **`$base`**: Always applied, regardless of whether conditions match
194
+ - **`$default`**: Only applied when no conditions match
195
+
196
+ ```ts
197
+ interface ButtonProps {
198
+ isDisabled?: boolean;
199
+ }
200
+
201
+ const button = ntv<ButtonProps>({
202
+ $base: 'px-4 py-2', // Always applied
203
+ $default: 'bg-blue-500', // Only applied when isDisabled is false
204
+ isDisabled: 'bg-gray-300 cursor-not-allowed',
205
+ });
206
+
207
+ button();
208
+ // => 'px-4 py-2 bg-blue-500'
209
+
210
+ button({ isDisabled: true });
211
+ // => 'px-4 py-2 bg-gray-300 cursor-not-allowed'
212
+ ```
213
+
99
214
  ### Variants - String-based selection
100
215
 
101
216
  Define variants as objects mapping variant values to class names:
102
217
 
103
218
  ```ts
104
219
  interface BadgeProps {
105
- size: 'sm' | 'md' | 'lg';
106
- color: 'info' | 'success' | 'warning';
220
+ size?: 'sm' | 'md' | 'lg';
221
+ color?: 'info' | 'success' | 'warning';
107
222
  }
108
223
 
109
224
  const badge = ntv<BadgeProps>({
@@ -130,10 +245,10 @@ Keys matching `is[A-Z]*` or `allows[A-Z]*` are treated as boolean conditions:
130
245
 
131
246
  ```ts
132
247
  interface InputProps {
133
- isFocused: boolean;
134
- isDisabled: boolean;
135
- isInvalid: boolean;
136
- allowsClearing: boolean;
248
+ isFocused?: boolean;
249
+ isDisabled?: boolean;
250
+ isInvalid?: boolean;
251
+ allowsClearing?: boolean;
137
252
  }
138
253
 
139
254
  const input = ntv<InputProps>({
@@ -151,65 +266,6 @@ input({ isDisabled: true, isInvalid: true });
151
266
  // => 'border rounded px-3 py-2 bg-gray-100 text-gray-400 cursor-not-allowed border-red-500 text-red-600'
152
267
  ```
153
268
 
154
- ### `$default` - Fallback styles
155
-
156
- Use `$default` for styles applied when no conditions match:
157
-
158
- ```ts
159
- interface TextProps {
160
- variant: 'primary' | 'danger';
161
- }
162
-
163
- const text = ntv<TextProps>({
164
- $default: 'text-gray-500',
165
- variant: {
166
- primary: 'text-blue-600',
167
- danger: 'text-red-600',
168
- },
169
- });
170
-
171
- text();
172
- // => 'text-gray-500'
173
-
174
- text({ variant: 'primary' });
175
- // => 'text-blue-600'
176
- ```
177
-
178
- When `$default` is nested inside variants, they accumulate only when no conditions match at each level:
179
-
180
- ```ts
181
- interface Props {
182
- variant: 'primary';
183
- size: 'large';
184
- }
185
-
186
- const styles = ntv<Props>({
187
- $base: 'base',
188
- $default: 'root-default',
189
- variant: {
190
- $default: 'variant-default',
191
- primary: {
192
- size: {
193
- $default: 'size-default',
194
- large: 'size-large',
195
- },
196
- },
197
- },
198
- });
199
-
200
- styles();
201
- // => 'base root-default variant-default'
202
- // No conditions matched, so $defaults accumulate
203
-
204
- styles({ variant: 'primary' });
205
- // => 'base size-default'
206
- // variant matched, so only nested $default is applied
207
-
208
- styles({ variant: 'primary', size: 'large' });
209
- // => 'base size-large'
210
- // Both matched, so no $defaults are applied
211
- ```
212
-
213
269
  ## Nested Conditions
214
270
 
215
271
  The core feature of nestable-tailwind-variants is the ability to nest conditions inside variants.
@@ -218,8 +274,8 @@ The core feature of nestable-tailwind-variants is the ability to nest conditions
218
274
 
219
275
  ```ts
220
276
  interface ChipProps {
221
- variant: 'filled' | 'outlined';
222
- isSelected: boolean;
277
+ variant?: 'filled' | 'outlined';
278
+ isSelected?: boolean;
223
279
  }
224
280
 
225
281
  const chip = ntv<ChipProps>({
@@ -252,10 +308,10 @@ You can nest conditions to any depth:
252
308
 
253
309
  ```ts
254
310
  interface ButtonProps {
255
- variant: 'primary';
256
- isHovered: boolean;
257
- isPressed: boolean;
258
- isDisabled: boolean;
311
+ variant?: 'primary';
312
+ isHovered?: boolean;
313
+ isPressed?: boolean;
314
+ isDisabled?: boolean;
259
315
  }
260
316
 
261
317
  const button = ntv<ButtonProps>({
@@ -294,7 +350,7 @@ Merge multiple style functions into one. Later functions take precedence:
294
350
  import { ntv, mergeNtv } from 'nestable-tailwind-variants';
295
351
 
296
352
  interface BaseButtonProps {
297
- size: 'sm' | 'md';
353
+ size?: 'sm' | 'md';
298
354
  }
299
355
 
300
356
  const baseButton = ntv<BaseButtonProps>({
@@ -306,7 +362,7 @@ const baseButton = ntv<BaseButtonProps>({
306
362
  });
307
363
 
308
364
  interface ColoredButtonProps {
309
- variant: 'primary' | 'secondary';
365
+ variant?: 'primary' | 'secondary';
310
366
  }
311
367
 
312
368
  const coloredButton = ntv<ColoredButtonProps>({
@@ -328,7 +384,7 @@ Pass additional classes using `class` or `className`:
328
384
 
329
385
  ```ts
330
386
  interface BoxProps {
331
- variant: 'primary' | 'secondary';
387
+ variant?: 'primary' | 'secondary';
332
388
  }
333
389
 
334
390
  const box = ntv<BoxProps>({
@@ -435,8 +491,39 @@ const button = ntv<ButtonProps>({
435
491
  isDisabled: 'opacity-50',
436
492
  });
437
493
 
438
- button({ variant: 'primary', size: 'lg' }); // OK
494
+ // All props are required - props parameter is mandatory
495
+ button({ variant: 'primary', size: 'lg', isDisabled: false }); // ✅ OK
439
496
  button({ variant: 'tertiary' }); // ❌ Error: 'tertiary' is not assignable
497
+ button({ variant: 'primary' }); // ❌ Error: missing 'size' and 'isDisabled'
498
+ ```
499
+
500
+ Use optional properties (`?`) when you want to allow calling the style function without providing all props:
501
+
502
+ ```ts
503
+ interface ButtonProps {
504
+ variant?: 'primary' | 'secondary';
505
+ size?: 'sm' | 'md' | 'lg';
506
+ isDisabled?: boolean;
507
+ }
508
+
509
+ const button = ntv<ButtonProps>({
510
+ $base: 'rounded',
511
+ variant: {
512
+ primary: 'bg-blue-500',
513
+ secondary: 'bg-gray-200',
514
+ },
515
+ size: {
516
+ sm: 'text-sm',
517
+ md: 'text-base',
518
+ lg: 'text-lg',
519
+ },
520
+ isDisabled: 'opacity-50',
521
+ });
522
+
523
+ // All props are optional - props parameter can be omitted
524
+ button(); // ✅ OK
525
+ button({ variant: 'primary' }); // ✅ OK
526
+ button({ variant: 'primary', size: 'lg' }); // ✅ OK
440
527
  ```
441
528
 
442
529
  Omitting the type argument when the scheme has keys disables type checking. Provide explicit type arguments when possible for better type safety.
@@ -601,13 +688,13 @@ export default [
601
688
 
602
689
  ### Scheme Properties
603
690
 
604
- | Property | Description |
605
- | -------------- | ---------------------------------------------------- |
606
- | `$base` | Classes always applied (top-level only) |
607
- | `$default` | Fallback classes when no conditions match |
608
- | `is[A-Z]*` | Boolean condition (e.g., `isSelected`, `isDisabled`) |
609
- | `allows[A-Z]*` | Boolean condition (e.g., `allowsRemoving`) |
610
- | `[key]` | Variant object mapping values to classes |
691
+ | Property | Description |
692
+ | -------------- | ------------------------------------------------------------------------------------------- |
693
+ | `$base` | Classes always applied at that level (can be used at top-level or nested within conditions) |
694
+ | `$default` | Fallback classes when no conditions match at that level |
695
+ | `is[A-Z]*` | Boolean condition (e.g., `isSelected`, `isDisabled`) |
696
+ | `allows[A-Z]*` | Boolean condition (e.g., `allowsRemoving`) |
697
+ | `[key]` | Variant object mapping values to classes |
611
698
 
612
699
  ## License
613
700
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { createMergeNtv, mergeNtv, mergeNtvWithOptions } from './merge.js';
2
2
  export { createNtv, ntv } from './ntv.js';
3
- export type { ClassProp, ClassValue, MergeStyleFunctionProps, NtvOptions, NtvProps, NtvScheme, SchemeFor, StyleFunction, TwMergeConfig, } from './types.js';
3
+ export type { ClassProp, ClassValue, MergeStyleFunctionProps, NtvOptions, Props, PropValue, Scheme, StyleFunction, TwMergeConfig, } from './types.js';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC1C,YAAY,EACV,SAAS,EACT,UAAU,EACV,uBAAuB,EACvB,UAAU,EACV,QAAQ,EACR,SAAS,EACT,SAAS,EACT,aAAa,EACb,aAAa,GACd,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC1C,YAAY,EACV,SAAS,EACT,UAAU,EACV,uBAAuB,EACvB,UAAU,EACV,KAAK,EACL,SAAS,EACT,MAAM,EACN,aAAa,EACb,aAAa,GACd,MAAM,YAAY,CAAC"}
package/dist/merge.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { MergeStyleFunctionProps, NtvOptions, StyleFunction } from './types.js';
1
+ import type { AnyStyleFunction, MergeStyleFunctionProps, NtvOptions, StyleFunction } from './types.js';
2
2
  /**
3
3
  * Create a merged style function with custom options (curried version).
4
4
  *
@@ -11,7 +11,7 @@ import type { MergeStyleFunctionProps, NtvOptions, StyleFunction } from './types
11
11
  * styles({ variant: 'primary' });
12
12
  * ```
13
13
  */
14
- export declare function mergeNtvWithOptions<T extends readonly StyleFunction<any>[]>(...styleFns: T): (options?: NtvOptions) => StyleFunction<MergeStyleFunctionProps<T>>;
14
+ export declare function mergeNtvWithOptions<T extends readonly AnyStyleFunction[]>(...styleFns: T): (options?: NtvOptions) => StyleFunction<MergeStyleFunctionProps<T>>;
15
15
  /**
16
16
  * Merge multiple style functions into a single style function.
17
17
  * Later functions take precedence over earlier ones (via tailwind-merge).
@@ -21,11 +21,11 @@ export declare function mergeNtvWithOptions<T extends readonly StyleFunction<any
21
21
  *
22
22
  * @example
23
23
  * ```ts
24
- * const colorStyles = ntv<{ color: 'red' | 'blue' }>({
24
+ * const colorStyles = ntv<{ color?: 'red' | 'blue' }>({
25
25
  * color: { red: 'text-red', blue: 'text-blue' },
26
26
  * });
27
27
  *
28
- * const sizeStyles = ntv<{ size: 'sm' | 'lg' }>({
28
+ * const sizeStyles = ntv<{ size?: 'sm' | 'lg' }>({
29
29
  * size: { sm: 'text-sm', lg: 'text-lg' },
30
30
  * });
31
31
  *
@@ -33,7 +33,7 @@ export declare function mergeNtvWithOptions<T extends readonly StyleFunction<any
33
33
  * styles({ color: 'red', size: 'lg' }); // 'text-red text-lg'
34
34
  * ```
35
35
  */
36
- export declare function mergeNtv<T extends readonly StyleFunction<any>[]>(...styleFns: T): StyleFunction<MergeStyleFunctionProps<T>>;
36
+ export declare function mergeNtv<T extends readonly AnyStyleFunction[]>(...styleFns: T): StyleFunction<MergeStyleFunctionProps<T>>;
37
37
  /**
38
38
  * Create a pre-configured mergeNtv function with fixed options.
39
39
  *
@@ -55,5 +55,5 @@ export declare function mergeNtv<T extends readonly StyleFunction<any>[]>(...sty
55
55
  * const styles = myMergeNtv(baseStyles, overrideStyles);
56
56
  * ```
57
57
  */
58
- export declare function createMergeNtv(defaultOptions: NtvOptions): <T extends readonly StyleFunction<any>[]>(...styleFns: T) => StyleFunction<MergeStyleFunctionProps<[...T]>>;
58
+ export declare function createMergeNtv(defaultOptions: NtvOptions): <T extends readonly AnyStyleFunction[]>(...styleFns: T) => StyleFunction<MergeStyleFunctionProps<T>>;
59
59
  //# sourceMappingURL=merge.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../src/merge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAa,uBAAuB,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhG;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,SAAS,aAAa,CAAC,GAAG,CAAC,EAAE,EACzE,GAAG,QAAQ,EAAE,CAAC,GACb,CAAC,OAAO,CAAC,EAAE,UAAU,KAAK,aAAa,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,CAoBrE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,SAAS,aAAa,CAAC,GAAG,CAAC,EAAE,EAC9D,GAAG,QAAQ,EAAE,CAAC,GACb,aAAa,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,CAE3C;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,cAAc,CAAC,cAAc,EAAE,UAAU,IACpB,CAAC,SAAS,SAAS,aAAa,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,UAAU,CAAC,oDAG3F"}
1
+ {"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../src/merge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,gBAAgB,EAEhB,uBAAuB,EACvB,UAAU,EACV,aAAa,EACd,MAAM,YAAY,CAAC;AAGpB;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,SAAS,gBAAgB,EAAE,EACvE,GAAG,QAAQ,EAAE,CAAC,GACb,CAAC,OAAO,CAAC,EAAE,UAAU,KAAK,aAAa,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,CAoBrE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,SAAS,gBAAgB,EAAE,EAC5D,GAAG,QAAQ,EAAE,CAAC,GACb,aAAa,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,CAE3C;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,cAAc,CAC5B,cAAc,EAAE,UAAU,GACzB,CAAC,CAAC,SAAS,SAAS,gBAAgB,EAAE,EACvC,GAAG,QAAQ,EAAE,CAAC,KACX,aAAa,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,CAQ7C"}
package/dist/merge.js CHANGED
@@ -34,11 +34,11 @@ export function mergeNtvWithOptions(...styleFns) {
34
34
  *
35
35
  * @example
36
36
  * ```ts
37
- * const colorStyles = ntv<{ color: 'red' | 'blue' }>({
37
+ * const colorStyles = ntv<{ color?: 'red' | 'blue' }>({
38
38
  * color: { red: 'text-red', blue: 'text-blue' },
39
39
  * });
40
40
  *
41
- * const sizeStyles = ntv<{ size: 'sm' | 'lg' }>({
41
+ * const sizeStyles = ntv<{ size?: 'sm' | 'lg' }>({
42
42
  * size: { sm: 'text-sm', lg: 'text-lg' },
43
43
  * });
44
44
  *
package/dist/merge.js.map CHANGED
@@ -1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4 @@
1
- import type { NtvOptions, NtvProps, NtvScheme, SchemeFor, StyleFunction } from './types.js';
1
+ import type { NtvOptions, Scheme, StyleFunction } from './types.js';
2
2
  /**
3
3
  * Create a nestable tailwind variants style function.
4
4
  *
@@ -8,7 +8,7 @@ import type { NtvOptions, NtvProps, NtvScheme, SchemeFor, StyleFunction } from '
8
8
  *
9
9
  * @example
10
10
  * ```ts
11
- * type ButtonProps = { variant: 'primary' | 'secondary'; isDisabled: boolean };
11
+ * type ButtonProps = { variant?: 'primary' | 'secondary'; isDisabled?: boolean };
12
12
  *
13
13
  * const button = ntv<ButtonProps>({
14
14
  * $base: 'px-4 py-2 rounded',
@@ -23,8 +23,8 @@ import type { NtvOptions, NtvProps, NtvScheme, SchemeFor, StyleFunction } from '
23
23
  * button({ variant: 'primary', isDisabled: true }); // 'px-4 py-2 rounded bg-blue-500 text-white opacity-50 cursor-not-allowed'
24
24
  * ```
25
25
  */
26
- export declare function ntv<TProps extends NtvProps>(scheme: SchemeFor<TProps>, options?: NtvOptions): StyleFunction<TProps>;
27
- export declare function ntv(scheme: NtvScheme, options?: NtvOptions): StyleFunction<any>;
26
+ export declare function ntv<TProps extends {}>(scheme: Scheme<TProps>, options?: NtvOptions): StyleFunction<TProps>;
27
+ export declare function ntv(scheme: Scheme & Record<string, unknown>, options?: NtvOptions): StyleFunction<any>;
28
28
  /**
29
29
  * Create a pre-configured ntv function with fixed options.
30
30
  *
@@ -53,7 +53,7 @@ export declare function ntv(scheme: NtvScheme, options?: NtvOptions): StyleFunct
53
53
  * ```
54
54
  */
55
55
  export declare function createNtv(defaultOptions: NtvOptions): {
56
- <TProps extends NtvProps>(scheme: SchemeFor<TProps>): StyleFunction<TProps>;
57
- (scheme: NtvScheme): StyleFunction<any>;
56
+ <TProps extends {}>(scheme: Scheme<TProps>): StyleFunction<TProps>;
57
+ (scheme: Scheme & Record<string, unknown>): StyleFunction<any>;
58
58
  };
59
59
  //# sourceMappingURL=ntv.d.ts.map
package/dist/ntv.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ntv.d.ts","sourceRoot":"","sources":["../src/ntv.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,UAAU,EACV,QAAQ,EACR,SAAS,EACT,SAAS,EACT,aAAa,EACd,MAAM,YAAY,CAAC;AAiCpB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,GAAG,CAAC,MAAM,SAAS,QAAQ,EACzC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,EACzB,OAAO,CAAC,EAAE,UAAU,GACnB,aAAa,CAAC,MAAM,CAAC,CAAC;AACzB,wBAAgB,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;AAwBjF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,SAAS,CAAC,cAAc,EAAE,UAAU,GAAG;IACrD,CAAC,MAAM,SAAS,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IAC5E,CAAC,MAAM,EAAE,SAAS,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;CACzC,CAIA"}
1
+ {"version":3,"file":"ntv.d.ts","sourceRoot":"","sources":["../src/ntv.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAa,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAa/E;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,wBAAgB,GAAG,CAAC,MAAM,SAAS,EAAE,EACnC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,EACtB,OAAO,CAAC,EAAE,UAAU,GACnB,aAAa,CAAC,MAAM,CAAC,CAAC;AACzB,wBAAgB,GAAG,CACjB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACxC,OAAO,CAAC,EAAE,UAAU,GACnB,aAAa,CAAC,GAAG,CAAC,CAAC;AAuBtB;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,SAAS,CAAC,cAAc,EAAE,UAAU,GAAG;IAErD,CAAC,MAAM,SAAS,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IACnE,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;CAChE,CAIA"}
package/dist/ntv.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { twJoin, twMerge } from 'tailwind-merge';
2
2
  import { getCachedTwMerge } from './cache.js';
3
3
  import { resolveConditions } from './resolver.js';
4
- import { isPlainObject } from './utils.js';
5
4
  function validateScheme(scheme) {
6
5
  if ('class' in scheme) {
7
6
  throw new Error('The "class" property is not allowed in ntv scheme. Use "$base" instead.');
@@ -9,30 +8,17 @@ function validateScheme(scheme) {
9
8
  if ('className' in scheme) {
10
9
  throw new Error('The "className" property is not allowed in ntv scheme. Use "$base" instead.');
11
10
  }
12
- validateNoNestedSpecialKeys(scheme, false);
13
- }
14
- function validateNoNestedSpecialKeys(obj, isNested) {
15
- for (const [key, value] of Object.entries(obj)) {
16
- // Check if this is a top-level-only key in a nested context
17
- if (isNested && key === '$base') {
18
- throw new Error(`The "${key}" property is only allowed at the top level of ntv scheme. It cannot be nested inside variants or conditions.`);
19
- }
20
- // Recursively validate nested objects
21
- if (isPlainObject(value)) {
22
- validateNoNestedSpecialKeys(value, true);
23
- }
24
- }
25
11
  }
26
12
  export function ntv(scheme, { twMerge: usesTwMerge = true, twMergeConfig } = {}) {
27
13
  validateScheme(scheme);
28
- const { $base, ...conditions } = scheme;
29
14
  const mergeFn = usesTwMerge
30
15
  ? twMergeConfig
31
16
  ? getCachedTwMerge(twMergeConfig)
32
17
  : twMerge
33
18
  : twJoin;
34
19
  return function styleFn({ class: slotClass, className: slotClassName, ...props } = {}) {
35
- return mergeFn($base, ...resolveConditions(conditions, props), slotClass, slotClassName);
20
+ const resolvedClasses = resolveConditions(scheme, props);
21
+ return mergeFn(...resolvedClasses, slotClass, slotClassName);
36
22
  };
37
23
  }
38
24
  /**
package/dist/ntv.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ntv.js","sourceRoot":"","sources":["../src/ntv.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AASjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,SAAS,cAAc,CAAC,MAAiB;IACvC,IAAI,OAAO,IAAI,MAAM,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,yEAAyE,CAAC,CAAC;IAC7F,CAAC;IAED,IAAI,WAAW,IAAI,MAAM,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,6EAA6E,CAAC,CAAC;IACjG,CAAC;IAED,2BAA2B,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAC7C,CAAC;AAED,SAAS,2BAA2B,CAAC,GAA4B,EAAE,QAAiB;IAClF,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/C,4DAA4D;QAC5D,IAAI,QAAQ,IAAI,GAAG,KAAK,OAAO,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CACb,QAAQ,GAAG,+GAA+G,CAC3H,CAAC;QACJ,CAAC;QAED,sCAAsC;QACtC,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,2BAA2B,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAC3C,CAAC;IAC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,MAAM,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,6EAA6E,CAAC,CAAC;IACjG,CAAC;AACH,CAAC;AAmCD,MAAM,UAAU,GAAG,CACjB,MAAc,EACd,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI,EAAE,aAAa,KAAiB,EAAE;IAE/D,cAAc,CAAC,MAAM,CAAC,CAAC;IAEvB,MAAM,OAAO,GAAG,WAAW;QACzB,CAAC,CAAC,aAAa;YACb,CAAC,CAAC,gBAAgB,CAAC,aAAa,CAAC;YACjC,CAAC,CAAC,OAAO;QACX,CAAC,CAAC,MAAM,CAAC;IAEX,OAAO,SAAS,OAAO,CAAC,EACtB,KAAK,EAAE,SAAS,EAChB,SAAS,EAAE,aAAa,EACxB,GAAG,KAAK,KAC+B,EAAE;QACzC,MAAM,eAAe,GAAG,iBAAiB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QACzD,OAAO,OAAO,CAAC,GAAG,eAAe,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;IAC/D,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,SAAS,CAAC,cAA0B;IAKlD,OAAO,SAAS,aAAa,CAAC,MAAwC;QACpE,OAAO,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACrC,CAAC,CAAC;AACJ,CAAC"}
@@ -7,5 +7,5 @@ import type { ClassValue } from './types.js';
7
7
  * - If a variant matches, only the nested evaluation result is used
8
8
  * - When no conditions match, $defaults accumulate from each unmatched level
9
9
  */
10
- export declare function resolveConditions({ $default, ...conditions }: Record<string, unknown>, props: Record<string, unknown>): ClassValue[];
10
+ export declare function resolveConditions({ $base, $default, ...conditions }: Record<string, unknown>, props: Record<string, unknown>): ClassValue[];
11
11
  //# sourceMappingURL=resolver.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7C;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,UAAU,EAAE,CA8Cd"}
1
+ {"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAM7C;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3D,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,UAAU,EAAE,CA2Cd"}
package/dist/resolver.js CHANGED
@@ -1,4 +1,6 @@
1
- import { isPlainObject } from './utils.js';
1
+ function isPlainObject(value) {
2
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
3
+ }
2
4
  /**
3
5
  * Resolves conditions from scheme based on provided props to generate class values.
4
6
  *
@@ -7,16 +9,11 @@ import { isPlainObject } from './utils.js';
7
9
  * - If a variant matches, only the nested evaluation result is used
8
10
  * - When no conditions match, $defaults accumulate from each unmatched level
9
11
  */
10
- export function resolveConditions({ $default, ...conditions }, props) {
12
+ export function resolveConditions({ $base, $default, ...conditions }, props) {
11
13
  const classes = [];
12
14
  let hasMatchedCondition = false;
13
- function addClasses(value) {
14
- if (isPlainObject(value)) {
15
- classes.push(...resolveConditions(value, props));
16
- }
17
- else {
18
- classes.push(value);
19
- }
15
+ function toClassValues(value) {
16
+ return isPlainObject(value) ? resolveConditions(value, props) : [value];
20
17
  }
21
18
  for (const [key, value] of Object.entries(conditions)) {
22
19
  const propValue = props[key];
@@ -27,24 +24,23 @@ export function resolveConditions({ $default, ...conditions }, props) {
27
24
  if (/^is[A-Z]/.test(key) || /^allows[A-Z]/.test(key)) {
28
25
  if (propValue) {
29
26
  hasMatchedCondition = true;
30
- addClasses(value);
27
+ classes.push(...toClassValues(value));
31
28
  }
32
29
  continue;
33
30
  }
34
31
  // Variant conditions (nested objects)
35
32
  if (isPlainObject(value)) {
36
- if (typeof propValue === 'string' && propValue in value) {
33
+ const matched = typeof propValue === 'string' && propValue in value;
34
+ if (matched) {
37
35
  hasMatchedCondition = true;
38
- addClasses(value[propValue]);
39
- }
40
- else {
41
- classes.push(value['$default']);
42
36
  }
37
+ classes.push(...toClassValues(value[matched ? propValue : '$default']));
43
38
  }
44
39
  }
45
40
  if (!hasMatchedCondition) {
46
41
  classes.unshift($default);
47
42
  }
43
+ classes.unshift($base);
48
44
  return classes;
49
45
  }
50
46
  //# sourceMappingURL=resolver.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolver.js","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAC/B,EAAE,QAAQ,EAAE,GAAG,UAAU,EAA2B,EACpD,KAA8B;IAE9B,MAAM,OAAO,GAAiB,EAAE,CAAC;IACjC,IAAI,mBAAmB,GAAG,KAAK,CAAC;IAEhC,SAAS,UAAU,CAAC,KAAc;QAChC,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,CAAC,IAAI,CAAC,GAAG,iBAAiB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;QACnD,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CAAC,KAAmB,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IAED,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAA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CAAC;IAED,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACzB,OAAO,CAAC,OAAO,CAAC,QAAsB,CAAC,CAAC;IAC1C,CAAC;IAED,OAAO,CAAC,OAAO,CAAC,KAAmB,CAAC,CAAC;IAErC,OAAO,OAAO,CAAC;AACjB,CAAC"}
package/dist/types.d.ts CHANGED
@@ -1,9 +1,7 @@
1
1
  import type { ClassNameValue as ClassValue, extendTailwindMerge } from 'tailwind-merge';
2
2
  export type { ClassValue };
3
- /**
4
- * Union type for class prop - ensures only one of class or className is used.
5
- * This prevents ambiguity when passing class names to components.
6
- */
3
+ export type PropValue = boolean | string;
4
+ export type Props = Record<string, PropValue | undefined>;
7
5
  export type ClassProp = {
8
6
  class?: ClassValue;
9
7
  className?: never;
@@ -11,88 +9,55 @@ export type ClassProp = {
11
9
  class?: never;
12
10
  className?: ClassValue;
13
11
  };
14
- /**
15
- * Props type constraint for NTV style functions.
16
- * Props are either boolean flags or string variant selections.
17
- */
18
- export interface NtvProps {
19
- }
20
- /**
21
- * Merge all properties from a union type into a single object type.
22
- * Combines props from multiple style functions by creating unions of their values.
23
- */
24
- type MergeUnion<T> = {
25
- [K in T extends unknown ? keyof T : never]: T extends unknown ? K extends keyof T ? T[K] : never : never;
26
- };
27
- /**
28
- * Extract and merge props types from an array of style functions.
29
- * Used by mergeNtv to create a combined props type.
30
- */
31
- export type MergeStyleFunctionProps<T extends readonly StyleFunction<any>[]> = MergeUnion<{
32
- [K in keyof T]: T[K] extends StyleFunction<infer P> ? P : never;
33
- }[number]>;
34
- /**
35
- * Make all properties optional and allow undefined values.
36
- * Ensures proper handling of missing props in style functions.
37
- */
38
- type PartialWithUndefined<T> = {
39
- [K in keyof T]?: T[K] | undefined;
40
- };
41
- /**
42
- * Flatten intersection types for better IDE display.
43
- */
44
- type Simplify<T> = {
12
+ type Flatten<T> = {
45
13
  [K in keyof T]: T[K];
46
14
  };
47
- /**
48
- * Function signature for style generators.
49
- * Accepts optional props and returns a string of class names.
50
- */
51
- export type StyleFunction<TProps> = (props?: Simplify<PartialWithUndefined<TProps> & ClassProp>) => string;
52
- /**
53
- * Boolean scheme entry - class value or nested scheme with conditions.
54
- */
55
- type BooleanSchemeEntry<TProps extends NtvProps> = ClassValue | (SchemeFor<TProps> & {
15
+ type RequiredKeys<T> = {
16
+ [K in keyof T]-?: {} extends Pick<T, K> ? never : K;
17
+ }[keyof T];
18
+ type OptionalKeys<T> = Exclude<keyof T, RequiredKeys<T>>;
19
+ type NestedScheme<TProps extends Props = {}> = {
20
+ $base?: ClassValue;
21
+ $default?: ClassValue | NestedScheme<TProps>;
22
+ } & PropConditions<TProps>;
23
+ type VariantMapping<TVariant extends string, TProps extends Props, TAllowDefault extends boolean> = {
24
+ [V in TVariant]?: ClassValue | NestedScheme<TProps>;
25
+ } & (TAllowDefault extends true ? {
26
+ $default?: ClassValue | NestedScheme<TProps>;
27
+ } : {});
28
+ type PropConditions<TProps extends Props> = {
29
+ [K in keyof TProps & string]?: NonNullable<TProps[K]> extends boolean ? ClassValue | NestedScheme<TProps> : NonNullable<TProps[K]> extends string ? VariantMapping<NonNullable<TProps[K]>, TProps, undefined extends TProps[K] ? true : false> : never;
30
+ };
31
+ export type Scheme<TProps extends Props = {}> = {
32
+ $base?: ClassValue;
56
33
  $default?: ClassValue;
57
- });
58
- /**
59
- * Variant scheme entry - maps variant values to class values or nested schemes.
60
- */
61
- type VariantSchemeEntry<TVariant extends string, TProps extends NtvProps> = {
62
- [V in TVariant]?: ClassValue | (SchemeFor<TProps> & {
63
- $default?: ClassValue;
64
- });
34
+ } & PropConditions<TProps>;
35
+ type NormalizeProps<T> = Flatten<{
36
+ [K in RequiredKeys<T>]: T[K];
65
37
  } & {
66
- $default?: ClassValue;
38
+ [K in OptionalKeys<T>]?: T[K];
39
+ }>;
40
+ export type StyleFunction<TProps = Props> = (RequiredKeys<TProps> extends never ? (props?: Flatten<NormalizeProps<TProps> & ClassProp>) => string : (props: Flatten<NormalizeProps<TProps> & ClassProp>) => string) & {
41
+ readonly __ntvProps?: TProps;
67
42
  };
68
- /**
69
- * Scheme conditions based on the props type.
70
- * Maps each prop to its appropriate scheme entry type.
71
- */
72
- type SchemeConditions<TProps extends NtvProps> = {
73
- [K in keyof TProps & string]?: TProps[K] extends boolean ? BooleanSchemeEntry<TProps> : TProps[K] extends string ? VariantSchemeEntry<TProps[K], TProps> : never;
43
+ export type AnyStyleFunction = ((...args: any[]) => string) & {
44
+ readonly __ntvProps?: unknown;
74
45
  };
75
- /**
76
- * Main scheme type for NTV style definitions.
77
- * Validated against TProps to ensure type safety.
78
- */
79
- export type SchemeFor<TProps extends NtvProps> = {
80
- $base?: ClassValue;
81
- $default?: ClassValue;
82
- } & SchemeConditions<TProps>;
83
- /**
84
- * Runtime scheme interface for NTV style definitions.
85
- * Untyped version used for JavaScript or when types aren't available.
86
- */
87
- export interface NtvScheme {
88
- $base?: ClassValue;
89
- $default?: ClassValue;
90
- [key: string]: unknown;
91
- }
46
+ type KeysOfUnion<T> = T extends unknown ? keyof T : never;
47
+ type IsRequiredInAny<T, K extends PropertyKey> = T extends unknown ? K extends keyof T ? K extends RequiredKeys<T> ? true : never : never : never;
48
+ type ValueFromUnion<T, K extends PropertyKey> = T extends unknown ? K extends keyof T ? Exclude<T[K], undefined> : never : never;
49
+ type MergeProps<T> = Flatten<{
50
+ [K in KeysOfUnion<T> as true extends IsRequiredInAny<T, K> ? K : never]: ValueFromUnion<T, K>;
51
+ } & {
52
+ [K in KeysOfUnion<T> as true extends IsRequiredInAny<T, K> ? never : K]?: ValueFromUnion<T, K>;
53
+ }>;
54
+ type ExtractProps<T> = T extends {
55
+ readonly __ntvProps?: infer P;
56
+ } ? NonNullable<P> : never;
57
+ export type MergeStyleFunctionProps<T extends readonly AnyStyleFunction[]> = MergeProps<{
58
+ [K in keyof T]: ExtractProps<T[K]>;
59
+ }[number]>;
92
60
  export type TwMergeConfig = Parameters<typeof extendTailwindMerge>[0];
93
- /**
94
- * Configuration options for NTV function behavior.
95
- */
96
61
  export interface NtvOptions {
97
62
  /**
98
63
  * Whether to merge the class names with `tailwind-merge` library.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,IAAI,UAAU,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAExF,YAAY,EAAE,UAAU,EAAE,CAAC;AAE3B;;;GAGG;AACH,MAAM,MAAM,SAAS,GACjB;IAAE,KAAK,CAAC,EAAE,UAAU,CAAC;IAAC,SAAS,CAAC,EAAE,KAAK,CAAA;CAAE,GACzC;IAAE,KAAK,CAAC,EAAE,KAAK,CAAC;IAAC,SAAS,CAAC,EAAE,UAAU,CAAA;CAAE,CAAC;AAE9C;;;GAGG;AAEH,MAAM,WAAW,QAAQ;CAAG;AAE5B;;;GAGG;AACH,KAAK,UAAU,CAAC,CAAC,IAAI;KAClB,CAAC,IAAI,CAAC,SAAS,OAAO,GAAG,MAAM,CAAC,GAAG,KAAK,GAAG,CAAC,SAAS,OAAO,GACzD,CAAC,SAAS,MAAM,CAAC,GACf,CAAC,CAAC,CAAC,CAAC,GACJ,KAAK,GACP,KAAK;CACV,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,uBAAuB,CAAC,CAAC,SAAS,SAAS,aAAa,CAAC,GAAG,CAAC,EAAE,IAAI,UAAU,CACvF;KACG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK;CAChE,CAAC,MAAM,CAAC,CACV,CAAC;AAEF;;;GAGG;AACH,KAAK,oBAAoB,CAAC,CAAC,IAAI;KAC5B,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS;CAClC,CAAC;AAEF;;GAEG;AACH,KAAK,QAAQ,CAAC,CAAC,IAAI;KAAG,CAA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AK,UAAU,CAAC,CAAC,IAAI,OAAO,CAC1B;KACG,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,IAAI,IAAI,SAAS,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,GAAG,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC;CAC9F,GAAG;KACD,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,IAAI,IAAI,SAAS,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC;CAC/F,CACF,CAAC;AAEF,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS;IAAE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,CAAA;CAAE,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;AAE5F,MAAM,MAAM,uBAAuB,CAAC,CAAC,SAAS,SAAS,gBAAgB,EAAE,IAAI,UAAU,CACrF;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC,MAAM,CAAC,CAC/C,CAAC;AAMF,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC;AAEtE,MAAM,WAAW,UAAU;IACzB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nestable-tailwind-variants",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "Tailwind CSS variant library with nestable conditions for compound styling instead of flat compoundVariants.",
5
5
  "homepage": "https://github.com/yuheiy/nestable-tailwind-variants#readme",
6
6
  "bugs": {
package/dist/utils.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
2
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAE9E"}
package/dist/utils.js DELETED
@@ -1,4 +0,0 @@
1
- export function isPlainObject(value) {
2
- return typeof value === 'object' && value !== null && !Array.isArray(value);
3
- }
4
- //# sourceMappingURL=utils.js.map
package/dist/utils.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}