praxis-kit 2.0.0 → 2.0.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.
@@ -1,4 +1,4 @@
1
- import { ReadonlyDeep } from 'type-fest';
1
+ import { RequireAtLeastOne, Simplify, ReadonlyDeep } from 'type-fest';
2
2
 
3
3
  type AnyRecord = Record<string, unknown>;
4
4
 
@@ -11,10 +11,24 @@ type KnownAriaRole = (typeof KNOWN_ARIA_ROLES)[number];
11
11
 
12
12
  type AriaRole = KnownAriaRole | (string & {});
13
13
 
14
+ type Booleanish = boolean | 'true' | 'false';
15
+
16
+ type ClassName = string | string[];
17
+
18
+ type EmptyRecord = Record<never, never>;
19
+
14
20
  type IntrinsicProps = AnyRecord & {
15
21
  role?: AriaRole;
16
22
  };
17
23
 
24
+ type NonEmptyArray<T> = [T, ...T[]];
25
+
26
+ type Numberish = number | `${number}`;
27
+
28
+ type Primitive = string | number | boolean;
29
+
30
+ type TagMap = Partial<Record<IntrinsicTag | (string & {}), ClassName>>;
31
+
18
32
  type StrictMode = boolean | 'warn' | 'async-warn' | 'throw';
19
33
 
20
34
  type CardinalityInput = {
@@ -43,6 +57,96 @@ type ValidResult = {
43
57
  valid: true;
44
58
  };
45
59
 
60
+ type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;
61
+
62
+ type VariantValue$1 = string | string[];
63
+
64
+ type VariantStates<K extends string = string> = Record<K, VariantValue$1>;
65
+
66
+ type VariantMap<V extends string = string, K extends string = string> = Record<V, VariantStates<K>>;
67
+
68
+ type VariantKey<V extends VariantMap, K extends keyof V> = StringToBoolean<keyof V[K] & string>;
69
+
70
+ type RequireAtLeastOneIfNotEmpty<T> = keyof T extends never ? EmptyRecord : RequireAtLeastOne<T>;
71
+ type CompoundVariantConditionValue<V extends VariantMap, K extends keyof V> = VariantKey<V, K> | NonEmptyArray<VariantKey<V, K>>;
72
+ type CompoundVariantConditions<V extends VariantMap> = Simplify<{
73
+ [K in keyof V]: CompoundVariantConditionValue<V, K>;
74
+ }>;
75
+ type CompoundVariantRequiredConditions<V extends VariantMap> = RequireAtLeastOneIfNotEmpty<CompoundVariantConditions<V>>;
76
+ type CompoundVariantBase<V extends VariantMap> = keyof V extends never ? EmptyRecord : CompoundVariantRequiredConditions<V>;
77
+ type CompoundVariant<V extends VariantMap> = CompoundVariantBase<V> & {
78
+ class: VariantValue$1;
79
+ };
80
+
81
+ interface CVACompounds<V extends VariantMap> {
82
+ compoundVariants?: readonly CompoundVariant<V>[];
83
+ }
84
+
85
+ type VariantValue<K extends string> = string extends K ? Primitive : K extends 'true' | 'false' ? Booleanish : K extends `${number}` ? Numberish : K;
86
+ type DefaultVariants<V extends VariantMap> = {
87
+ [K in keyof V]?: VariantValue<keyof V[K] & string>;
88
+ };
89
+
90
+ interface CVADefaults<V extends VariantMap> {
91
+ defaultVariants?: DefaultVariants<V>;
92
+ }
93
+
94
+ interface CVAVariants<V extends VariantMap> {
95
+ variants?: V;
96
+ }
97
+
98
+ /**
99
+ * A partial selection of variant states authored at factory definition time.
100
+ *
101
+ * Uses `keyof V[K]` directly (not `VariantKey`) so TypeScript can eagerly
102
+ * resolve the union at constraint-check time without deferred conditional types.
103
+ */
104
+ type VariantSelection<V extends VariantMap> = {
105
+ [K in keyof V]?: keyof V[K];
106
+ };
107
+
108
+ /**
109
+ * A static, immutable map of named presets to partial variant selections.
110
+ *
111
+ * Presets are named bundles of variant props that callers activate by key,
112
+ * avoiding the need to repeat variant combinations at each call site.
113
+ */
114
+ type PresetMap<V extends VariantMap = VariantMap> = Readonly<Record<string, VariantSelection<V>>>;
115
+
116
+ type PresetTarget<TVariants extends VariantMap = VariantMap> = VariantSelection<TVariants>;
117
+
118
+ interface BaseClassOptions {
119
+ baseClassName?: ClassName;
120
+ }
121
+
122
+ type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName, variantKey?: string) => string;
123
+
124
+ interface PresetOptions<TVariants extends VariantMap = VariantMap> {
125
+ presetMap?: Record<string, PresetTarget<TVariants>>;
126
+ }
127
+
128
+ interface TagMapOptions {
129
+ tagMap?: TagMap;
130
+ }
131
+
132
+ type CompositionOptions<TVariants extends VariantMap = VariantMap> = Simplify<TagMapOptions & PresetOptions<TVariants>>;
133
+
134
+ type CVASystemOptions<TVariants extends VariantMap = VariantMap> = Simplify<CVAVariants<TVariants> & CVADefaults<TVariants> & CVACompounds<TVariants>>;
135
+
136
+ type StyleOptions<TVariants extends VariantMap = VariantMap> = Simplify<BaseClassOptions & CVASystemOptions<TVariants>>;
137
+
138
+ type ClassPipelineOptions<TVariants extends VariantMap = VariantMap> = Simplify<StyleOptions<TVariants> & CompositionOptions<TVariants>>;
139
+
140
+ type OwnedPropKeys = ReadonlySet<string>;
141
+
142
+ type ClassPlugin<TProps extends AnyRecord = EmptyRecord> = Readonly<{
143
+ pipeline: ClassPipelineFn;
144
+ ownedKeys?: OwnedPropKeys;
145
+ readonly _pluginProps?: TProps;
146
+ }>;
147
+
148
+ type ClassPluginFactory<TProps extends AnyRecord = EmptyRecord> = <V extends VariantMap>(options: ClassPipelineOptions<V>, strict: StrictMode) => ClassPlugin<TProps>;
149
+
46
150
  type AriaContext = {
47
151
  readonly tag: IntrinsicTag;
48
152
  readonly implicitRole: AriaRole | undefined;
@@ -100,6 +204,30 @@ type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
100
204
  readonly allowedAs?: readonly TAllowed[];
101
205
  };
102
206
 
207
+ type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends PresetMap<V> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord> = {
208
+ readonly base?: ClassName;
209
+ readonly variants?: V;
210
+ readonly defaults?: Partial<DefaultVariants<V>>;
211
+ readonly compounds?: readonly CompoundVariant<V>[];
212
+ readonly presets?: TPreset;
213
+ readonly tags?: Readonly<TagMap>;
214
+ readonly plugin?: ClassPluginFactory<TPluginProps>;
215
+ readonly precomputedClasses?: Readonly<Record<string, string>>;
216
+ };
217
+
218
+ type NormalizeFn<Props extends AnyRecord = AnyRecord> = {
219
+ normalize(props: Readonly<Props & IntrinsicProps>): Props & IntrinsicProps;
220
+ }['normalize'];
221
+ type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap, PresetMap<VariantMap>, AnyRecord>;
222
+ type FactoryOptions<TDefault extends ElementType = ElementType, Props extends AnyRecord = EmptyRecord, V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends PresetMap<V> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord, TAllowed extends ElementType = ElementType> = {
223
+ readonly tag?: TDefault;
224
+ readonly name?: string;
225
+ readonly defaults?: Partial<NoInfer<Props>>;
226
+ readonly normalize?: NormalizeFn<NoInfer<Props>>;
227
+ readonly styling?: StylingOptions<V, TPreset, TPluginProps>;
228
+ readonly enforcement?: EnforcementOptions<TAllowed>;
229
+ };
230
+
103
231
  declare const activeProps: PropNormalizer;
104
232
 
105
233
  declare const disabledProps: PropNormalizer;
@@ -127,4 +255,4 @@ declare const selectedContract: EnforcementOptions;
127
255
 
128
256
  declare function mergeContracts(...contracts: readonly EnforcementOptions[]): EnforcementOptions;
129
257
 
130
- export { type PropNormalizer, activeContract, activeProps, disabledContract, disabledProps, expandedContract, expandedProps, invalidContract, invalidProps, loadingContract, loadingProps, mergeContracts, pressedContract, pressedProps, readonlyContract, readonlyProps, selectedContract, selectedProps };
258
+ export { type AnyFactoryOptions, type PropNormalizer, activeContract, activeProps, disabledContract, disabledProps, expandedContract, expandedProps, invalidContract, invalidProps, loadingContract, loadingProps, mergeContracts, pressedContract, pressedProps, readonlyContract, readonlyProps, selectedContract, selectedProps };
@@ -12,6 +12,8 @@ type KnownAriaRole = (typeof KNOWN_ARIA_ROLES)[number];
12
12
 
13
13
  type AriaRole = KnownAriaRole | (string & {});
14
14
 
15
+ type Booleanish = boolean | 'true' | 'false';
16
+
15
17
  type ClassName = string | string[];
16
18
 
17
19
  type EmptyRecord = Record<never, never>;
@@ -22,6 +24,10 @@ type IntrinsicProps = AnyRecord & {
22
24
 
23
25
  type NonEmptyArray<T> = [T, ...T[]];
24
26
 
27
+ type Numberish = number | `${number}`;
28
+
29
+ type Primitive = string | number | boolean;
30
+
25
31
  type TagMap = Partial<Record<IntrinsicTag | (string & {}), ClassName>>;
26
32
 
27
33
  type StrictMode = boolean | 'warn' | 'async-warn' | 'throw';
@@ -54,9 +60,9 @@ type ValidResult = {
54
60
 
55
61
  type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;
56
62
 
57
- type VariantValue = string | string[];
63
+ type VariantValue$1 = string | string[];
58
64
 
59
- type VariantStates<K extends string = string> = Record<K, VariantValue>;
65
+ type VariantStates<K extends string = string> = Record<K, VariantValue$1>;
60
66
 
61
67
  type VariantMap<V extends string = string, K extends string = string> = Record<V, VariantStates<K>>;
62
68
 
@@ -70,19 +76,16 @@ type CompoundVariantConditions<V extends VariantMap> = Simplify<{
70
76
  type CompoundVariantRequiredConditions<V extends VariantMap> = RequireAtLeastOneIfNotEmpty<CompoundVariantConditions<V>>;
71
77
  type CompoundVariantBase<V extends VariantMap> = keyof V extends never ? EmptyRecord : CompoundVariantRequiredConditions<V>;
72
78
  type CompoundVariant<V extends VariantMap> = CompoundVariantBase<V> & {
73
- class: VariantValue;
79
+ class: VariantValue$1;
74
80
  };
75
81
 
76
82
  interface CVACompounds<V extends VariantMap> {
77
83
  compoundVariants?: readonly CompoundVariant<V>[];
78
84
  }
79
85
 
80
- /** The full optional prop surface exposed to callers for a given variant map. */
81
- type VariantProps<V extends VariantMap> = {
82
- [K in keyof V]?: VariantKey<V, K>;
83
- };
86
+ type VariantValue<K extends string> = string extends K ? Primitive : K extends 'true' | 'false' ? Booleanish : K extends `${number}` ? Numberish : K;
84
87
  type DefaultVariants<V extends VariantMap> = {
85
- [K in keyof V]?: VariantKey<V, K>;
88
+ [K in keyof V]?: VariantValue<keyof V[K] & string>;
86
89
  };
87
90
 
88
91
  interface CVADefaults<V extends VariantMap> {
@@ -205,7 +208,7 @@ type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
205
208
  type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends PresetMap<V> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord> = {
206
209
  readonly base?: ClassName;
207
210
  readonly variants?: V;
208
- readonly defaults?: Partial<VariantProps<V>>;
211
+ readonly defaults?: Partial<DefaultVariants<V>>;
209
212
  readonly compounds?: readonly CompoundVariant<V>[];
210
213
  readonly presets?: TPreset;
211
214
  readonly tags?: Readonly<TagMap>;
@@ -12,6 +12,8 @@ type KnownAriaRole = (typeof KNOWN_ARIA_ROLES)[number];
12
12
 
13
13
  type AriaRole = KnownAriaRole | (string & {});
14
14
 
15
+ type Booleanish = boolean | 'true' | 'false';
16
+
15
17
  type ClassName = string | string[];
16
18
 
17
19
  type EmptyRecord = Record<never, never>;
@@ -22,6 +24,10 @@ type IntrinsicProps = AnyRecord & {
22
24
 
23
25
  type NonEmptyArray<T> = [T, ...T[]];
24
26
 
27
+ type Numberish = number | `${number}`;
28
+
29
+ type Primitive = string | number | boolean;
30
+
25
31
  type TagMap = Partial<Record<IntrinsicTag | (string & {}), ClassName>>;
26
32
 
27
33
  type StrictMode = boolean | 'warn' | 'async-warn' | 'throw';
@@ -54,9 +60,9 @@ type ValidResult = {
54
60
 
55
61
  type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;
56
62
 
57
- type VariantValue = string | string[];
63
+ type VariantValue$1 = string | string[];
58
64
 
59
- type VariantStates<K extends string = string> = Record<K, VariantValue>;
65
+ type VariantStates<K extends string = string> = Record<K, VariantValue$1>;
60
66
 
61
67
  type VariantMap<V extends string = string, K extends string = string> = Record<V, VariantStates<K>>;
62
68
 
@@ -70,7 +76,7 @@ type CompoundVariantConditions<V extends VariantMap> = Simplify<{
70
76
  type CompoundVariantRequiredConditions<V extends VariantMap> = RequireAtLeastOneIfNotEmpty<CompoundVariantConditions<V>>;
71
77
  type CompoundVariantBase<V extends VariantMap> = keyof V extends never ? EmptyRecord : CompoundVariantRequiredConditions<V>;
72
78
  type CompoundVariant<V extends VariantMap> = CompoundVariantBase<V> & {
73
- class: VariantValue;
79
+ class: VariantValue$1;
74
80
  };
75
81
 
76
82
  interface CVACompounds<V extends VariantMap> {
@@ -81,8 +87,9 @@ interface CVACompounds<V extends VariantMap> {
81
87
  type VariantProps<V extends VariantMap> = {
82
88
  [K in keyof V]?: VariantKey<V, K>;
83
89
  };
90
+ type VariantValue<K extends string> = string extends K ? Primitive : K extends 'true' | 'false' ? Booleanish : K extends `${number}` ? Numberish : K;
84
91
  type DefaultVariants<V extends VariantMap> = {
85
- [K in keyof V]?: VariantKey<V, K>;
92
+ [K in keyof V]?: VariantValue<keyof V[K] & string>;
86
93
  };
87
94
 
88
95
  interface CVADefaults<V extends VariantMap> {
@@ -216,7 +223,7 @@ type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
216
223
  type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends PresetMap<V> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord> = {
217
224
  readonly base?: ClassName;
218
225
  readonly variants?: V;
219
- readonly defaults?: Partial<VariantProps<V>>;
226
+ readonly defaults?: Partial<DefaultVariants<V>>;
220
227
  readonly compounds?: readonly CompoundVariant<V>[];
221
228
  readonly presets?: TPreset;
222
229
  readonly tags?: Readonly<TagMap>;
@@ -12,6 +12,8 @@ type KnownAriaRole = (typeof KNOWN_ARIA_ROLES)[number];
12
12
 
13
13
  type AriaRole = KnownAriaRole | (string & {});
14
14
 
15
+ type Booleanish = boolean | 'true' | 'false';
16
+
15
17
  type ClassName = string | string[];
16
18
 
17
19
  type EmptyRecord = Record<never, never>;
@@ -22,6 +24,10 @@ type IntrinsicProps = AnyRecord & {
22
24
 
23
25
  type NonEmptyArray<T> = [T, ...T[]];
24
26
 
27
+ type Numberish = number | `${number}`;
28
+
29
+ type Primitive = string | number | boolean;
30
+
25
31
  type TagMap = Partial<Record<IntrinsicTag | (string & {}), ClassName>>;
26
32
 
27
33
  type StrictMode = boolean | 'warn' | 'async-warn' | 'throw';
@@ -54,9 +60,9 @@ type ValidResult = {
54
60
 
55
61
  type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;
56
62
 
57
- type VariantValue = string | string[];
63
+ type VariantValue$1 = string | string[];
58
64
 
59
- type VariantStates<K extends string = string> = Record<K, VariantValue>;
65
+ type VariantStates<K extends string = string> = Record<K, VariantValue$1>;
60
66
 
61
67
  type VariantMap<V extends string = string, K extends string = string> = Record<V, VariantStates<K>>;
62
68
 
@@ -70,7 +76,7 @@ type CompoundVariantConditions<V extends VariantMap> = Simplify<{
70
76
  type CompoundVariantRequiredConditions<V extends VariantMap> = RequireAtLeastOneIfNotEmpty<CompoundVariantConditions<V>>;
71
77
  type CompoundVariantBase<V extends VariantMap> = keyof V extends never ? EmptyRecord : CompoundVariantRequiredConditions<V>;
72
78
  type CompoundVariant<V extends VariantMap> = CompoundVariantBase<V> & {
73
- class: VariantValue;
79
+ class: VariantValue$1;
74
80
  };
75
81
 
76
82
  interface CVACompounds<V extends VariantMap> {
@@ -81,8 +87,9 @@ interface CVACompounds<V extends VariantMap> {
81
87
  type VariantProps<V extends VariantMap> = {
82
88
  [K in keyof V]?: VariantKey<V, K>;
83
89
  };
90
+ type VariantValue<K extends string> = string extends K ? Primitive : K extends 'true' | 'false' ? Booleanish : K extends `${number}` ? Numberish : K;
84
91
  type DefaultVariants<V extends VariantMap> = {
85
- [K in keyof V]?: VariantKey<V, K>;
92
+ [K in keyof V]?: VariantValue<keyof V[K] & string>;
86
93
  };
87
94
 
88
95
  interface CVADefaults<V extends VariantMap> {
@@ -215,7 +222,7 @@ type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
215
222
  type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends PresetMap<V> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord> = {
216
223
  readonly base?: ClassName;
217
224
  readonly variants?: V;
218
- readonly defaults?: Partial<VariantProps<V>>;
225
+ readonly defaults?: Partial<DefaultVariants<V>>;
219
226
  readonly compounds?: readonly CompoundVariant<V>[];
220
227
  readonly presets?: TPreset;
221
228
  readonly tags?: Readonly<TagMap>;
@@ -1,5 +1,5 @@
1
- import { E as ElementType, U as UnknownProps, V as VariantMap, P as PresetMap, a as EmptyRecord, A as AnyRecord, R as ReactFactoryOptions, b as PolymorphicComponent, c as PolymorphicGenerics, F as FactoryOptions } from '../merge-refs-DxjWMq3U.js';
2
- export { d as AnyFactoryOptions, e as ElementRef, f as PolymorphicProps, g as PolymorphicWithAsChild, h as PolymorphicWithRender, i as RenderCallbackProps, S as Slottable, j as SlottableProps, m as mergeRefs } from '../merge-refs-DxjWMq3U.js';
1
+ import { E as ElementType, U as UnknownProps, V as VariantMap, P as PresetMap, a as EmptyRecord, A as AnyRecord, R as ReactFactoryOptions, b as PolymorphicComponent, c as PolymorphicGenerics, F as FactoryOptions } from '../merge-refs-tA18zYP6.js';
2
+ export { d as AnyFactoryOptions, e as ElementRef, f as PolymorphicProps, g as PolymorphicWithAsChild, h as PolymorphicWithRender, i as RenderCallbackProps, S as Slottable, j as SlottableProps, m as mergeRefs } from '../merge-refs-tA18zYP6.js';
3
3
  import { Ref, ReactElement } from 'react';
4
4
  import 'type-fest';
5
5
 
@@ -1,5 +1,5 @@
1
- import { E as ElementType, U as UnknownProps, V as VariantMap, P as PresetMap, a as EmptyRecord, A as AnyRecord, R as ReactFactoryOptions, b as PolymorphicComponent, c as PolymorphicGenerics } from '../merge-refs-DxjWMq3U.js';
2
- export { d as AnyFactoryOptions, e as ElementRef, F as FactoryOptions, f as PolymorphicProps, g as PolymorphicWithAsChild, h as PolymorphicWithRender, i as RenderCallbackProps, S as Slottable, j as SlottableProps, m as mergeRefs } from '../merge-refs-DxjWMq3U.js';
1
+ import { E as ElementType, U as UnknownProps, V as VariantMap, P as PresetMap, a as EmptyRecord, A as AnyRecord, R as ReactFactoryOptions, b as PolymorphicComponent, c as PolymorphicGenerics } from '../merge-refs-tA18zYP6.js';
2
+ export { d as AnyFactoryOptions, e as ElementRef, F as FactoryOptions, f as PolymorphicProps, g as PolymorphicWithAsChild, h as PolymorphicWithRender, i as RenderCallbackProps, S as Slottable, j as SlottableProps, m as mergeRefs } from '../merge-refs-tA18zYP6.js';
3
3
  import * as react from 'react';
4
4
  import 'type-fest';
5
5
 
@@ -12,6 +12,8 @@ type KnownAriaRole = (typeof KNOWN_ARIA_ROLES)[number];
12
12
 
13
13
  type AriaRole = KnownAriaRole | (string & {});
14
14
 
15
+ type Booleanish = boolean | 'true' | 'false';
16
+
15
17
  type ClassName = string | string[];
16
18
 
17
19
  type EmptyRecord = Record<never, never>;
@@ -22,6 +24,10 @@ type IntrinsicProps = AnyRecord & {
22
24
 
23
25
  type NonEmptyArray<T> = [T, ...T[]];
24
26
 
27
+ type Numberish = number | `${number}`;
28
+
29
+ type Primitive = string | number | boolean;
30
+
25
31
  type TagMap = Partial<Record<IntrinsicTag | (string & {}), ClassName>>;
26
32
 
27
33
  type StrictMode = boolean | 'warn' | 'async-warn' | 'throw';
@@ -54,9 +60,9 @@ type ValidResult = {
54
60
 
55
61
  type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;
56
62
 
57
- type VariantValue = string | string[];
63
+ type VariantValue$1 = string | string[];
58
64
 
59
- type VariantStates<K extends string = string> = Record<K, VariantValue>;
65
+ type VariantStates<K extends string = string> = Record<K, VariantValue$1>;
60
66
 
61
67
  type VariantMap<V extends string = string, K extends string = string> = Record<V, VariantStates<K>>;
62
68
 
@@ -70,7 +76,7 @@ type CompoundVariantConditions<V extends VariantMap> = Simplify<{
70
76
  type CompoundVariantRequiredConditions<V extends VariantMap> = RequireAtLeastOneIfNotEmpty<CompoundVariantConditions<V>>;
71
77
  type CompoundVariantBase<V extends VariantMap> = keyof V extends never ? EmptyRecord : CompoundVariantRequiredConditions<V>;
72
78
  type CompoundVariant<V extends VariantMap> = CompoundVariantBase<V> & {
73
- class: VariantValue;
79
+ class: VariantValue$1;
74
80
  };
75
81
 
76
82
  interface CVACompounds<V extends VariantMap> {
@@ -81,8 +87,9 @@ interface CVACompounds<V extends VariantMap> {
81
87
  type VariantProps<V extends VariantMap> = {
82
88
  [K in keyof V]?: VariantKey<V, K>;
83
89
  };
90
+ type VariantValue<K extends string> = string extends K ? Primitive : K extends 'true' | 'false' ? Booleanish : K extends `${number}` ? Numberish : K;
84
91
  type DefaultVariants<V extends VariantMap> = {
85
- [K in keyof V]?: VariantKey<V, K>;
92
+ [K in keyof V]?: VariantValue<keyof V[K] & string>;
86
93
  };
87
94
 
88
95
  interface CVADefaults<V extends VariantMap> {
@@ -215,7 +222,7 @@ type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
215
222
  type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends PresetMap<V> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord> = {
216
223
  readonly base?: ClassName;
217
224
  readonly variants?: V;
218
- readonly defaults?: Partial<VariantProps<V>>;
225
+ readonly defaults?: Partial<DefaultVariants<V>>;
219
226
  readonly compounds?: readonly CompoundVariant<V>[];
220
227
  readonly presets?: TPreset;
221
228
  readonly tags?: Readonly<TagMap>;
@@ -11,6 +11,8 @@ type KnownAriaRole = (typeof KNOWN_ARIA_ROLES)[number];
11
11
 
12
12
  type AriaRole = KnownAriaRole | (string & {});
13
13
 
14
+ type Booleanish = boolean | 'true' | 'false';
15
+
14
16
  type ClassName = string | string[];
15
17
 
16
18
  type EmptyRecord = Record<never, never>;
@@ -21,6 +23,10 @@ type IntrinsicProps = AnyRecord & {
21
23
 
22
24
  type NonEmptyArray<T> = [T, ...T[]];
23
25
 
26
+ type Numberish = number | `${number}`;
27
+
28
+ type Primitive = string | number | boolean;
29
+
24
30
  type TagMap = Partial<Record<IntrinsicTag | (string & {}), ClassName>>;
25
31
 
26
32
  type StrictMode = boolean | 'warn' | 'async-warn' | 'throw';
@@ -59,9 +65,9 @@ type ValidResult = {
59
65
 
60
66
  type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;
61
67
 
62
- type VariantValue = string | string[];
68
+ type VariantValue$1 = string | string[];
63
69
 
64
- type VariantStates<K extends string = string> = Record<K, VariantValue>;
70
+ type VariantStates<K extends string = string> = Record<K, VariantValue$1>;
65
71
 
66
72
  type VariantMap<V extends string = string, K extends string = string> = Record<V, VariantStates<K>>;
67
73
 
@@ -75,19 +81,16 @@ type CompoundVariantConditions<V extends VariantMap> = Simplify<{
75
81
  type CompoundVariantRequiredConditions<V extends VariantMap> = RequireAtLeastOneIfNotEmpty<CompoundVariantConditions<V>>;
76
82
  type CompoundVariantBase<V extends VariantMap> = keyof V extends never ? EmptyRecord : CompoundVariantRequiredConditions<V>;
77
83
  type CompoundVariant<V extends VariantMap> = CompoundVariantBase<V> & {
78
- class: VariantValue;
84
+ class: VariantValue$1;
79
85
  };
80
86
 
81
87
  interface CVACompounds<V extends VariantMap> {
82
88
  compoundVariants?: readonly CompoundVariant<V>[];
83
89
  }
84
90
 
85
- /** The full optional prop surface exposed to callers for a given variant map. */
86
- type VariantProps<V extends VariantMap> = {
87
- [K in keyof V]?: VariantKey<V, K>;
88
- };
91
+ type VariantValue<K extends string> = string extends K ? Primitive : K extends 'true' | 'false' ? Booleanish : K extends `${number}` ? Numberish : K;
89
92
  type DefaultVariants<V extends VariantMap> = {
90
- [K in keyof V]?: VariantKey<V, K>;
93
+ [K in keyof V]?: VariantValue<keyof V[K] & string>;
91
94
  };
92
95
 
93
96
  interface CVADefaults<V extends VariantMap> {
@@ -218,7 +221,7 @@ type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
218
221
  type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends PresetMap<V> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord> = {
219
222
  readonly base?: ClassName;
220
223
  readonly variants?: V;
221
- readonly defaults?: Partial<VariantProps<V>>;
224
+ readonly defaults?: Partial<DefaultVariants<V>>;
222
225
  readonly compounds?: readonly CompoundVariant<V>[];
223
226
  readonly presets?: TPreset;
224
227
  readonly tags?: Readonly<TagMap>;
@@ -246,7 +249,7 @@ type ResolvedFactoryOptions<TDefault extends ElementType = ElementType, Props ex
246
249
  readonly tagMap?: Readonly<TagMap>;
247
250
  readonly presetMap?: TPreset;
248
251
  readonly variants?: V;
249
- readonly defaultVariants?: Partial<VariantProps<V>>;
252
+ readonly defaultVariants?: Partial<DefaultVariants<V>>;
250
253
  readonly compoundVariants?: readonly CompoundVariant<V>[];
251
254
  readonly displayName?: string;
252
255
  readonly strict: StrictMode;
@@ -13,6 +13,8 @@ type KnownAriaRole = (typeof KNOWN_ARIA_ROLES)[number];
13
13
 
14
14
  type AriaRole = KnownAriaRole | (string & {});
15
15
 
16
+ type Booleanish = boolean | 'true' | 'false';
17
+
16
18
  type ClassName = string | string[];
17
19
 
18
20
  type EmptyRecord = Record<never, never>;
@@ -23,6 +25,10 @@ type IntrinsicProps = AnyRecord & {
23
25
 
24
26
  type NonEmptyArray<T> = [T, ...T[]];
25
27
 
28
+ type Numberish = number | `${number}`;
29
+
30
+ type Primitive = string | number | boolean;
31
+
26
32
  type TagMap = Partial<Record<IntrinsicTag | (string & {}), ClassName>>;
27
33
 
28
34
  type StrictMode = boolean | 'warn' | 'async-warn' | 'throw';
@@ -55,9 +61,9 @@ type ValidResult = {
55
61
 
56
62
  type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;
57
63
 
58
- type VariantValue = string | string[];
64
+ type VariantValue$1 = string | string[];
59
65
 
60
- type VariantStates<K extends string = string> = Record<K, VariantValue>;
66
+ type VariantStates<K extends string = string> = Record<K, VariantValue$1>;
61
67
 
62
68
  type VariantMap<V extends string = string, K extends string = string> = Record<V, VariantStates<K>>;
63
69
 
@@ -71,7 +77,7 @@ type CompoundVariantConditions<V extends VariantMap> = Simplify<{
71
77
  type CompoundVariantRequiredConditions<V extends VariantMap> = RequireAtLeastOneIfNotEmpty<CompoundVariantConditions<V>>;
72
78
  type CompoundVariantBase<V extends VariantMap> = keyof V extends never ? EmptyRecord : CompoundVariantRequiredConditions<V>;
73
79
  type CompoundVariant<V extends VariantMap> = CompoundVariantBase<V> & {
74
- class: VariantValue;
80
+ class: VariantValue$1;
75
81
  };
76
82
 
77
83
  interface CVACompounds<V extends VariantMap> {
@@ -82,8 +88,9 @@ interface CVACompounds<V extends VariantMap> {
82
88
  type VariantProps<V extends VariantMap> = {
83
89
  [K in keyof V]?: VariantKey<V, K>;
84
90
  };
91
+ type VariantValue<K extends string> = string extends K ? Primitive : K extends 'true' | 'false' ? Booleanish : K extends `${number}` ? Numberish : K;
85
92
  type DefaultVariants<V extends VariantMap> = {
86
- [K in keyof V]?: VariantKey<V, K>;
93
+ [K in keyof V]?: VariantValue<keyof V[K] & string>;
87
94
  };
88
95
 
89
96
  interface CVADefaults<V extends VariantMap> {
@@ -216,7 +223,7 @@ type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
216
223
  type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends PresetMap<V> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord> = {
217
224
  readonly base?: ClassName;
218
225
  readonly variants?: V;
219
- readonly defaults?: Partial<VariantProps<V>>;
226
+ readonly defaults?: Partial<DefaultVariants<V>>;
220
227
  readonly compounds?: readonly CompoundVariant<V>[];
221
228
  readonly presets?: TPreset;
222
229
  readonly tags?: Readonly<TagMap>;
@@ -11,6 +11,8 @@ type KnownAriaRole = (typeof KNOWN_ARIA_ROLES)[number];
11
11
 
12
12
  type AriaRole = KnownAriaRole | (string & {});
13
13
 
14
+ type Booleanish = boolean | 'true' | 'false';
15
+
14
16
  type ClassName = string | string[];
15
17
 
16
18
  type EmptyRecord = Record<never, never>;
@@ -21,6 +23,10 @@ type IntrinsicProps = AnyRecord & {
21
23
 
22
24
  type NonEmptyArray<T> = [T, ...T[]];
23
25
 
26
+ type Numberish = number | `${number}`;
27
+
28
+ type Primitive = string | number | boolean;
29
+
24
30
  type TagMap = Partial<Record<IntrinsicTag | (string & {}), ClassName>>;
25
31
 
26
32
  type StrictMode = boolean | 'warn' | 'async-warn' | 'throw';
@@ -53,9 +59,9 @@ type ValidResult = {
53
59
 
54
60
  type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;
55
61
 
56
- type VariantValue = string | string[];
62
+ type VariantValue$1 = string | string[];
57
63
 
58
- type VariantStates<K extends string = string> = Record<K, VariantValue>;
64
+ type VariantStates<K extends string = string> = Record<K, VariantValue$1>;
59
65
 
60
66
  type VariantMap<V extends string = string, K extends string = string> = Record<V, VariantStates<K>>;
61
67
 
@@ -69,19 +75,16 @@ type CompoundVariantConditions<V extends VariantMap> = Simplify<{
69
75
  type CompoundVariantRequiredConditions<V extends VariantMap> = RequireAtLeastOneIfNotEmpty<CompoundVariantConditions<V>>;
70
76
  type CompoundVariantBase<V extends VariantMap> = keyof V extends never ? EmptyRecord : CompoundVariantRequiredConditions<V>;
71
77
  type CompoundVariant<V extends VariantMap> = CompoundVariantBase<V> & {
72
- class: VariantValue;
78
+ class: VariantValue$1;
73
79
  };
74
80
 
75
81
  interface CVACompounds<V extends VariantMap> {
76
82
  compoundVariants?: readonly CompoundVariant<V>[];
77
83
  }
78
84
 
79
- /** The full optional prop surface exposed to callers for a given variant map. */
80
- type VariantProps<V extends VariantMap> = {
81
- [K in keyof V]?: VariantKey<V, K>;
82
- };
85
+ type VariantValue<K extends string> = string extends K ? Primitive : K extends 'true' | 'false' ? Booleanish : K extends `${number}` ? Numberish : K;
83
86
  type DefaultVariants<V extends VariantMap> = {
84
- [K in keyof V]?: VariantKey<V, K>;
87
+ [K in keyof V]?: VariantValue<keyof V[K] & string>;
85
88
  };
86
89
 
87
90
  interface CVADefaults<V extends VariantMap> {
@@ -204,7 +207,7 @@ type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
204
207
  type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends PresetMap<V> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord> = {
205
208
  readonly base?: ClassName;
206
209
  readonly variants?: V;
207
- readonly defaults?: Partial<VariantProps<V>>;
210
+ readonly defaults?: Partial<DefaultVariants<V>>;
208
211
  readonly compounds?: readonly CompoundVariant<V>[];
209
212
  readonly presets?: TPreset;
210
213
  readonly tags?: Readonly<TagMap>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "praxis-kit",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./react": {