praxis-kit 4.0.3 → 4.1.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.
@@ -3,17 +3,44 @@ import { RequireAtLeastOne, Simplify } from 'type-fest';
3
3
 
4
4
  type StringMap<T = unknown> = Record<string, T>;
5
5
  type AnyRecord = StringMap<unknown>;
6
+ type EmptyRecord = Record<never, never>;
6
7
 
7
8
  type IntrinsicTag = keyof HTMLElementTagNameMap;
8
9
 
9
10
  type Booleanish = boolean | 'true' | 'false';
10
11
  type ClassName = string | string[];
11
- type EmptyRecord = Record<never, never>;
12
12
  type NonEmptyArray<T> = [T, ...T[]];
13
13
  type Numberish = number | `${number}`;
14
14
  type Primitive = string | number | boolean;
15
15
  type TagMap = Partial<Record<IntrinsicTag | (string & {}), ClassName>>;
16
16
 
17
+ type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;
18
+
19
+ type VariantValue = string | string[];
20
+
21
+ type VariantStates<K extends string = string> = Record<K, VariantValue>;
22
+
23
+ type VariantMap<V extends string = string, K extends string = string> = Record<V, VariantStates<K>>;
24
+
25
+ type VariantKey<V extends VariantMap, K extends keyof V> = StringToBoolean<keyof V[K] & string>;
26
+
27
+ /**
28
+ * A partial selection of variant states authored at factory definition time.
29
+ *
30
+ * Uses `keyof V[K]` directly (not `VariantKey`) so TypeScript can eagerly
31
+ * resolve the union at constraint-check time without deferred conditional types.
32
+ */
33
+ type VariantSelection$1<V extends VariantMap> = {
34
+ [K in keyof V]?: keyof V[K];
35
+ };
36
+
37
+ type NormalizedVariantValue<K extends string> = string extends K ? Primitive : K extends 'true' | 'false' ? Booleanish : K extends `${number}` ? Numberish : K;
38
+ type DefaultVariants<V extends VariantMap> = {
39
+ [K in keyof V]?: NormalizedVariantValue<keyof V[K] & string>;
40
+ };
41
+
42
+ type RecipeTarget<TVariants extends VariantMap = VariantMap> = VariantSelection$1<TVariants>;
43
+
17
44
  type RequireAtLeastOneIfNotEmpty<T> = keyof T extends never ? EmptyRecord : RequireAtLeastOne<T>;
18
45
  type CompoundVariantConditionValue<V extends VariantMap, K extends keyof V> = VariantKey<V, K> | NonEmptyArray<VariantKey<V, K>>;
19
46
  type CompoundVariantConditions<V extends VariantMap> = Simplify<{
@@ -37,26 +64,6 @@ interface CVAVariants<V extends VariantMap> {
37
64
  variants?: V;
38
65
  }
39
66
 
40
- type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;
41
- type VariantValue = string | string[];
42
- type VariantStates<K extends string = string> = Record<K, VariantValue>;
43
- type VariantMap<V extends string = string, K extends string = string> = Record<V, VariantStates<K>>;
44
- type VariantKey<V extends VariantMap, K extends keyof V> = StringToBoolean<keyof V[K] & string>;
45
- /**
46
- * A partial selection of variant states authored at factory definition time.
47
- *
48
- * Uses `keyof V[K]` directly (not `VariantKey`) so TypeScript can eagerly
49
- * resolve the union at constraint-check time without deferred conditional types.
50
- */
51
- type VariantSelection$1<V extends VariantMap> = {
52
- [K in keyof V]?: keyof V[K];
53
- };
54
- type NormalizedVariantValue<K extends string> = string extends K ? Primitive : K extends 'true' | 'false' ? Booleanish : K extends `${number}` ? Numberish : K;
55
- type DefaultVariants<V extends VariantMap> = {
56
- [K in keyof V]?: NormalizedVariantValue<keyof V[K] & string>;
57
- };
58
- type RecipeTarget<TVariants extends VariantMap = VariantMap> = VariantSelection$1<TVariants>;
59
-
60
67
  interface BaseClassOptions {
61
68
  baseClassName?: ClassName;
62
69
  }
@@ -146,7 +153,7 @@ type ClassifiedToken = Simplify<LayoutToken | ConditionalToken | GapToken | Util
146
153
  type VariantSelection = Record<string, string>;
147
154
  type CompoundVariant = {
148
155
  class?: unknown;
149
- } & Record<string, unknown>;
156
+ } & AnyRecord;
150
157
 
151
158
  /**
152
159
  * Layout-aware class pipeline for Tailwind CSS utility class strings.
@@ -82,6 +82,16 @@ declare enum DiagnosticCode {
82
82
  InternalError = "INTERNAL9000"
83
83
  }
84
84
 
85
+ declare enum Severity$1 {
86
+ Debug = 0,
87
+ Info = 1,
88
+ Warning = 2,
89
+ Error = 3,
90
+ Fatal = 4
91
+ }
92
+
93
+ type Context = AnyRecord;
94
+ type Metadata = AnyRecord;
85
95
  interface SourcePosition {
86
96
  line: number;
87
97
  col: number;
@@ -91,23 +101,11 @@ interface SourceLocation {
91
101
  start: SourcePosition;
92
102
  end?: SourcePosition;
93
103
  }
94
-
95
- declare enum Severity$1 {
96
- Debug = 0,
97
- Info = 1,
98
- Warning = 2,
99
- Error = 3,
100
- Fatal = 4
101
- }
102
-
103
104
  interface DiagnosticSuggestion {
104
105
  title: string;
105
106
  description?: string;
106
107
  fix?: string;
107
108
  }
108
-
109
- type Context = AnyRecord;
110
- type Metadata = AnyRecord;
111
109
  interface Diagnostic$1 {
112
110
  code: DiagnosticCode;
113
111
  severity: Severity$1;
@@ -5,6 +5,7 @@ import { AllowedComponentProps } from 'vue';
5
5
 
6
6
  type StringMap<T = unknown> = Record<string, T>;
7
7
  type AnyRecord = StringMap<unknown>;
8
+ type EmptyRecord = Record<never, never>;
8
9
 
9
10
  type IntrinsicTag = keyof HTMLElementTagNameMap;
10
11
 
@@ -15,7 +16,6 @@ type KnownAriaRole = (typeof KNOWN_ARIA_ROLES)[number];
15
16
 
16
17
  type Booleanish = boolean | 'true' | 'false';
17
18
  type ClassName = string | string[];
18
- type EmptyRecord = Record<never, never>;
19
19
  type NonEmptyArray<T> = [T, ...T[]];
20
20
  type Numberish = number | `${number}`;
21
21
  type Primitive = string | number | boolean;
@@ -52,34 +52,16 @@ type ValidResult = {
52
52
  valid: true;
53
53
  };
54
54
 
55
- type RequireAtLeastOneIfNotEmpty<T> = keyof T extends never ? EmptyRecord : RequireAtLeastOne<T>;
56
- type CompoundVariantConditionValue<V extends VariantMap, K extends keyof V> = VariantKey<V, K> | NonEmptyArray<VariantKey<V, K>>;
57
- type CompoundVariantConditions<V extends VariantMap> = Simplify<{
58
- [K in keyof V]: CompoundVariantConditionValue<V, K>;
59
- }>;
60
- type CompoundVariantRequiredConditions<V extends VariantMap> = RequireAtLeastOneIfNotEmpty<CompoundVariantConditions<V>>;
61
- type CompoundVariantBase<V extends VariantMap> = keyof V extends never ? EmptyRecord : CompoundVariantRequiredConditions<V>;
62
- type CompoundVariant<V extends VariantMap> = CompoundVariantBase<V> & {
63
- class: VariantValue;
64
- };
65
-
66
- interface CVACompounds<V extends VariantMap> {
67
- compoundVariants?: readonly CompoundVariant<V>[];
68
- }
69
-
70
- interface CVADefaults<V extends VariantMap> {
71
- defaultVariants?: DefaultVariants<V>;
72
- }
73
-
74
- interface CVAVariants<V extends VariantMap> {
75
- variants?: V;
76
- }
77
-
78
55
  type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;
56
+
79
57
  type VariantValue = string | string[];
58
+
80
59
  type VariantStates<K extends string = string> = Record<K, VariantValue>;
60
+
81
61
  type VariantMap<V extends string = string, K extends string = string> = Record<V, VariantStates<K>>;
62
+
82
63
  type VariantKey<V extends VariantMap, K extends keyof V> = StringToBoolean<keyof V[K] & string>;
64
+
83
65
  /**
84
66
  * A partial selection of variant states authored at factory definition time.
85
67
  *
@@ -89,14 +71,17 @@ type VariantKey<V extends VariantMap, K extends keyof V> = StringToBoolean<keyof
89
71
  type VariantSelection<V extends VariantMap> = {
90
72
  [K in keyof V]?: keyof V[K];
91
73
  };
74
+
92
75
  /** The full optional prop surface exposed to callers for a given variant map. */
93
76
  type VariantProps<V extends VariantMap> = {
94
77
  [K in keyof V]?: VariantKey<V, K>;
95
78
  };
79
+
96
80
  type NormalizedVariantValue<K extends string> = string extends K ? Primitive : K extends 'true' | 'false' ? Booleanish : K extends `${number}` ? Numberish : K;
97
81
  type DefaultVariants<V extends VariantMap> = {
98
82
  [K in keyof V]?: NormalizedVariantValue<keyof V[K] & string>;
99
83
  };
84
+
100
85
  /**
101
86
  * A static, immutable map of named presets to partial variant selections.
102
87
  *
@@ -104,7 +89,9 @@ type DefaultVariants<V extends VariantMap> = {
104
89
  * avoiding the need to repeat variant combinations at each call site.
105
90
  */
106
91
  type RecipeMap<V extends VariantMap = VariantMap> = Readonly<Record<string, VariantSelection<V>>>;
92
+
107
93
  type RecipeTarget<TVariants extends VariantMap = VariantMap> = VariantSelection<TVariants>;
94
+
108
95
  interface PolymorphicGenerics<TDefault extends ElementType = ElementType, Props extends AnyRecord = AnyRecord, Variants extends Readonly<VariantMap> = Readonly<VariantMap>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TAllowed extends ElementType = ElementType> {
109
96
  default: TDefault;
110
97
  props: Props;
@@ -117,6 +104,29 @@ type RecipeOf<T extends PolymorphicGenerics> = T['preset'];
117
104
  type DefaultOf<T extends PolymorphicGenerics> = T['default'];
118
105
  type PropsOf<T extends PolymorphicGenerics> = T['props'];
119
106
 
107
+ type RequireAtLeastOneIfNotEmpty<T> = keyof T extends never ? EmptyRecord : RequireAtLeastOne<T>;
108
+ type CompoundVariantConditionValue<V extends VariantMap, K extends keyof V> = VariantKey<V, K> | NonEmptyArray<VariantKey<V, K>>;
109
+ type CompoundVariantConditions<V extends VariantMap> = Simplify<{
110
+ [K in keyof V]: CompoundVariantConditionValue<V, K>;
111
+ }>;
112
+ type CompoundVariantRequiredConditions<V extends VariantMap> = RequireAtLeastOneIfNotEmpty<CompoundVariantConditions<V>>;
113
+ type CompoundVariantBase<V extends VariantMap> = keyof V extends never ? EmptyRecord : CompoundVariantRequiredConditions<V>;
114
+ type CompoundVariant<V extends VariantMap> = CompoundVariantBase<V> & {
115
+ class: VariantValue;
116
+ };
117
+
118
+ interface CVACompounds<V extends VariantMap> {
119
+ compoundVariants?: readonly CompoundVariant<V>[];
120
+ }
121
+
122
+ interface CVADefaults<V extends VariantMap> {
123
+ defaultVariants?: DefaultVariants<V>;
124
+ }
125
+
126
+ interface CVAVariants<V extends VariantMap> {
127
+ variants?: V;
128
+ }
129
+
120
130
  interface BaseClassOptions {
121
131
  baseClassName?: ClassName;
122
132
  }
@@ -148,7 +158,11 @@ type ClassPlugin<TProps extends AnyRecord = EmptyRecord> = Readonly<{
148
158
  }>;
149
159
 
150
160
  type ClassPluginFactory<TProps extends AnyRecord = EmptyRecord> = <V extends VariantMap>(options: ClassPipelineOptions<V>, diagnostics: Diagnostics) => ClassPlugin<TProps>;
151
- type ExtractPluginProps<TPlugin extends ClassPluginFactory<AnyRecord> | undefined> = TPlugin extends ClassPluginFactory<infer T> ? string extends keyof T ? EmptyRecord : T : EmptyRecord;
161
+ /** `ClassPluginFactory` with its plugin-owned-props generic erased the common form used
162
+ * wherever a factory's concrete plugin-props shape isn't tracked (factory generics,
163
+ * capability wiring). */
164
+ type AnyClassPluginFactory = ClassPluginFactory<AnyRecord> | undefined;
165
+ type ExtractPluginProps<TPlugin extends AnyClassPluginFactory> = TPlugin extends ClassPluginFactory<infer T> ? string extends keyof T ? EmptyRecord : T : EmptyRecord;
152
166
 
153
167
  type AriaContext = {
154
168
  readonly tag: IntrinsicTag;
@@ -208,7 +222,7 @@ type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
208
222
  readonly allowedAs?: readonly TAllowed[];
209
223
  };
210
224
 
211
- type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>, TPlugin extends ClassPluginFactory<AnyRecord> | undefined = ClassPluginFactory<AnyRecord> | undefined> = {
225
+ type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>, TPlugin extends AnyClassPluginFactory = AnyClassPluginFactory> = {
212
226
  readonly base?: ClassName;
213
227
  readonly variants?: V;
214
228
  readonly defaults?: Partial<DefaultVariants<V>>;
@@ -222,8 +236,8 @@ type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPre
222
236
  type NormalizeFn<Props extends AnyRecord = AnyRecord> = {
223
237
  normalize(props: Readonly<Props & IntrinsicProps>): Props & IntrinsicProps;
224
238
  }['normalize'];
225
- type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap, RecipeMap<VariantMap>, ClassPluginFactory<AnyRecord> | undefined>;
226
- type FactoryOptions<TDefault extends ElementType = ElementType, Props extends AnyRecord = EmptyRecord, V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>, TPlugin extends ClassPluginFactory<AnyRecord> | undefined = ClassPluginFactory<AnyRecord> | undefined, TAllowed extends ElementType = ElementType> = {
239
+ type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap, RecipeMap<VariantMap>, AnyClassPluginFactory>;
240
+ type FactoryOptions<TDefault extends ElementType = ElementType, Props extends AnyRecord = EmptyRecord, V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>, TPlugin extends AnyClassPluginFactory = AnyClassPluginFactory, TAllowed extends ElementType = ElementType> = {
227
241
  readonly tag?: TDefault;
228
242
  readonly name?: string;
229
243
  readonly defaults?: Partial<NoInfer<Props>>;
@@ -245,9 +259,9 @@ declare const Slottable: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNod
245
259
  [key: string]: any;
246
260
  }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
247
261
 
248
- type UnknownProps = Record<string, unknown>;
262
+ type UnknownProps = AnyRecord;
249
263
 
250
- type VueFactoryOptions<TDefault extends ElementType, Props extends UnknownProps, Variants extends Readonly<VariantMap>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TPlugin extends ClassPluginFactory<AnyRecord> | undefined = ClassPluginFactory<AnyRecord> | undefined> = FactoryOptions<TDefault, Props, Variants, TPreset, TPlugin> & {
264
+ type VueFactoryOptions<TDefault extends ElementType, Props extends UnknownProps, Variants extends Readonly<VariantMap>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TPlugin extends AnyClassPluginFactory = AnyClassPluginFactory> = FactoryOptions<TDefault, Props, Variants, TPreset, TPlugin> & {
251
265
  /**
252
266
  * Return true for any prop key that should be consumed but not forwarded to
253
267
  * the DOM. Variant keys are always stripped automatically.
@@ -293,6 +307,6 @@ type PolymorphicComponent<G extends PolymorphicGenerics> = {
293
307
  displayName?: string;
294
308
  };
295
309
 
296
- declare function createContractComponent<TDefault extends ElementType, Props extends UnknownProps = EmptyRecord, Variants extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TPlugin extends ClassPluginFactory<AnyRecord> | undefined = ClassPluginFactory<AnyRecord> | undefined>(options: VueFactoryOptions<TDefault, Props, Variants, TPreset, TPlugin>): PolymorphicComponent<PolymorphicGenerics<TDefault, Props & ExtractPluginProps<TPlugin>, Variants, TPreset>>;
310
+ declare function createContractComponent<TDefault extends ElementType, Props extends UnknownProps = EmptyRecord, Variants extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TPlugin extends AnyClassPluginFactory = AnyClassPluginFactory>(options: VueFactoryOptions<TDefault, Props, Variants, TPreset, TPlugin>): PolymorphicComponent<PolymorphicGenerics<TDefault, Props & ExtractPluginProps<TPlugin>, Variants, TPreset>>;
297
311
 
298
312
  export { type AnyFactoryOptions, type ElementType, type EmptyRecord, type PolymorphicComponent, type PolymorphicGenerics, type PolymorphicProps, type PolymorphicWithAsChild, Slottable, type SlottableProps, type VueFactoryOptions, createContractComponent, defineContractComponent };