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.
- package/dist/_shared/diagnostics.d.ts +14 -17
- package/dist/{chunk-DRGZ4ZI2.js → chunk-R2RKHZNX.js} +968 -634
- package/dist/contract/index.d.ts +39 -27
- package/dist/lit/index.d.ts +42 -30
- package/dist/lit/index.js +653 -413
- package/dist/preact/index.d.ts +45 -31
- package/dist/preact/index.js +1009 -685
- package/dist/react/index.d.ts +24 -11
- package/dist/react/index.js +21 -143
- package/dist/react/legacy.d.ts +3 -3
- package/dist/react/legacy.js +28 -147
- package/dist/{merge-refs-B0YcfdtP.d.ts → react-options-XrRof248.d.ts} +156 -100
- package/dist/solid/index.d.ts +45 -31
- package/dist/solid/index.js +521 -296
- package/dist/svelte/index.d.ts +55 -34
- package/dist/svelte/index.js +504 -296
- package/dist/tailwind/index.d.ts +29 -22
- package/dist/vite-plugin/index.d.ts +10 -12
- package/dist/vue/index.d.ts +45 -31
- package/dist/vue/index.js +898 -693
- package/dist/web/index.d.ts +43 -31
- package/dist/web/index.js +652 -406
- package/package.json +3 -3
package/dist/svelte/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { Diagnostics, DiagnosticInput } from '../_shared/diagnostics.js';
|
|
|
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
|
|
|
@@ -13,7 +14,6 @@ type KnownAriaRole = (typeof KNOWN_ARIA_ROLES)[number];
|
|
|
13
14
|
|
|
14
15
|
type Booleanish = boolean | 'true' | 'false';
|
|
15
16
|
type ClassName = string | string[];
|
|
16
|
-
type EmptyRecord = Record<never, never>;
|
|
17
17
|
type NonEmptyArray<T> = [T, ...T[]];
|
|
18
18
|
type Numberish = number | `${number}`;
|
|
19
19
|
type Primitive = string | number | boolean;
|
|
@@ -29,6 +29,13 @@ type MinMax = {
|
|
|
29
29
|
};
|
|
30
30
|
type CardinalityInput = Partial<MinMax>;
|
|
31
31
|
|
|
32
|
+
/** Structural counterpart to `@praxis-kit/contract`'s `ChildrenEvaluator` class — `lib/primitive`
|
|
33
|
+
* may not depend on `lib/contract` (see `primitive-no-upper-layers` in .dependency-cruiser.cjs),
|
|
34
|
+
* so this describes only the shape consumers actually call. Mirrors `AriaEngine`'s pattern. */
|
|
35
|
+
type ChildrenEvaluator$1 = {
|
|
36
|
+
evaluate: (children: unknown[]) => void;
|
|
37
|
+
};
|
|
38
|
+
|
|
32
39
|
type ChildRuleMatch<T, U extends T = T> = (child: T) => child is U;
|
|
33
40
|
|
|
34
41
|
type ChildRulePosition = 'first' | 'last' | 'any';
|
|
@@ -56,34 +63,16 @@ type ValidResult = {
|
|
|
56
63
|
valid: true;
|
|
57
64
|
};
|
|
58
65
|
|
|
59
|
-
type RequireAtLeastOneIfNotEmpty<T> = keyof T extends never ? EmptyRecord : RequireAtLeastOne<T>;
|
|
60
|
-
type CompoundVariantConditionValue<V extends VariantMap, K extends keyof V> = VariantKey<V, K> | NonEmptyArray<VariantKey<V, K>>;
|
|
61
|
-
type CompoundVariantConditions<V extends VariantMap> = Simplify<{
|
|
62
|
-
[K in keyof V]: CompoundVariantConditionValue<V, K>;
|
|
63
|
-
}>;
|
|
64
|
-
type CompoundVariantRequiredConditions<V extends VariantMap> = RequireAtLeastOneIfNotEmpty<CompoundVariantConditions<V>>;
|
|
65
|
-
type CompoundVariantBase<V extends VariantMap> = keyof V extends never ? EmptyRecord : CompoundVariantRequiredConditions<V>;
|
|
66
|
-
type CompoundVariant<V extends VariantMap> = CompoundVariantBase<V> & {
|
|
67
|
-
class: VariantValue;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
interface CVACompounds<V extends VariantMap> {
|
|
71
|
-
compoundVariants?: readonly CompoundVariant<V>[];
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
interface CVADefaults<V extends VariantMap> {
|
|
75
|
-
defaultVariants?: DefaultVariants<V>;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
interface CVAVariants<V extends VariantMap> {
|
|
79
|
-
variants?: V;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
66
|
type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;
|
|
67
|
+
|
|
83
68
|
type VariantValue = string | string[];
|
|
69
|
+
|
|
84
70
|
type VariantStates<K extends string = string> = Record<K, VariantValue>;
|
|
71
|
+
|
|
85
72
|
type VariantMap<V extends string = string, K extends string = string> = Record<V, VariantStates<K>>;
|
|
73
|
+
|
|
86
74
|
type VariantKey<V extends VariantMap, K extends keyof V> = StringToBoolean<keyof V[K] & string>;
|
|
75
|
+
|
|
87
76
|
/**
|
|
88
77
|
* A partial selection of variant states authored at factory definition time.
|
|
89
78
|
*
|
|
@@ -93,10 +82,12 @@ type VariantKey<V extends VariantMap, K extends keyof V> = StringToBoolean<keyof
|
|
|
93
82
|
type VariantSelection<V extends VariantMap> = {
|
|
94
83
|
[K in keyof V]?: keyof V[K];
|
|
95
84
|
};
|
|
85
|
+
|
|
96
86
|
type NormalizedVariantValue<K extends string> = string extends K ? Primitive : K extends 'true' | 'false' ? Booleanish : K extends `${number}` ? Numberish : K;
|
|
97
87
|
type DefaultVariants<V extends VariantMap> = {
|
|
98
88
|
[K in keyof V]?: NormalizedVariantValue<keyof V[K] & string>;
|
|
99
89
|
};
|
|
90
|
+
|
|
100
91
|
/**
|
|
101
92
|
* A static, immutable map of named presets to partial variant selections.
|
|
102
93
|
*
|
|
@@ -104,7 +95,9 @@ type DefaultVariants<V extends VariantMap> = {
|
|
|
104
95
|
* avoiding the need to repeat variant combinations at each call site.
|
|
105
96
|
*/
|
|
106
97
|
type RecipeMap<V extends VariantMap = VariantMap> = Readonly<Record<string, VariantSelection<V>>>;
|
|
98
|
+
|
|
107
99
|
type RecipeTarget<TVariants extends VariantMap = VariantMap> = VariantSelection<TVariants>;
|
|
100
|
+
|
|
108
101
|
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
102
|
default: TDefault;
|
|
110
103
|
props: Props;
|
|
@@ -113,6 +106,29 @@ interface PolymorphicGenerics<TDefault extends ElementType = ElementType, Props
|
|
|
113
106
|
allowed: TAllowed;
|
|
114
107
|
}
|
|
115
108
|
|
|
109
|
+
type RequireAtLeastOneIfNotEmpty<T> = keyof T extends never ? EmptyRecord : RequireAtLeastOne<T>;
|
|
110
|
+
type CompoundVariantConditionValue<V extends VariantMap, K extends keyof V> = VariantKey<V, K> | NonEmptyArray<VariantKey<V, K>>;
|
|
111
|
+
type CompoundVariantConditions<V extends VariantMap> = Simplify<{
|
|
112
|
+
[K in keyof V]: CompoundVariantConditionValue<V, K>;
|
|
113
|
+
}>;
|
|
114
|
+
type CompoundVariantRequiredConditions<V extends VariantMap> = RequireAtLeastOneIfNotEmpty<CompoundVariantConditions<V>>;
|
|
115
|
+
type CompoundVariantBase<V extends VariantMap> = keyof V extends never ? EmptyRecord : CompoundVariantRequiredConditions<V>;
|
|
116
|
+
type CompoundVariant<V extends VariantMap> = CompoundVariantBase<V> & {
|
|
117
|
+
class: VariantValue;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
interface CVACompounds<V extends VariantMap> {
|
|
121
|
+
compoundVariants?: readonly CompoundVariant<V>[];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
interface CVADefaults<V extends VariantMap> {
|
|
125
|
+
defaultVariants?: DefaultVariants<V>;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
interface CVAVariants<V extends VariantMap> {
|
|
129
|
+
variants?: V;
|
|
130
|
+
}
|
|
131
|
+
|
|
116
132
|
interface BaseClassOptions {
|
|
117
133
|
baseClassName?: ClassName;
|
|
118
134
|
}
|
|
@@ -144,8 +160,12 @@ type ClassPlugin<TProps extends AnyRecord = EmptyRecord> = Readonly<{
|
|
|
144
160
|
}>;
|
|
145
161
|
|
|
146
162
|
type ClassPluginFactory<TProps extends AnyRecord = EmptyRecord> = <V extends VariantMap>(options: ClassPipelineOptions<V>, diagnostics: Diagnostics) => ClassPlugin<TProps>;
|
|
147
|
-
|
|
148
|
-
|
|
163
|
+
/** `ClassPluginFactory` with its plugin-owned-props generic erased — the common form used
|
|
164
|
+
* wherever a factory's concrete plugin-props shape isn't tracked (factory generics,
|
|
165
|
+
* capability wiring). */
|
|
166
|
+
type AnyClassPluginFactory = ClassPluginFactory<AnyRecord> | undefined;
|
|
167
|
+
type ExtractPluginProps<TPlugin extends AnyClassPluginFactory> = TPlugin extends ClassPluginFactory<infer T> ? string extends keyof T ? EmptyRecord : T : EmptyRecord;
|
|
168
|
+
type PluginInstance<TPlugin extends AnyClassPluginFactory> = TPlugin extends ClassPluginFactory<infer TProps> ? ClassPlugin<TProps> : undefined;
|
|
149
169
|
|
|
150
170
|
type AriaContext = {
|
|
151
171
|
readonly tag: IntrinsicTag;
|
|
@@ -205,7 +225,7 @@ type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
|
|
|
205
225
|
readonly allowedAs?: readonly TAllowed[];
|
|
206
226
|
};
|
|
207
227
|
|
|
208
|
-
type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>, TPlugin extends
|
|
228
|
+
type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>, TPlugin extends AnyClassPluginFactory = AnyClassPluginFactory> = {
|
|
209
229
|
readonly base?: ClassName;
|
|
210
230
|
readonly variants?: V;
|
|
211
231
|
readonly defaults?: Partial<DefaultVariants<V>>;
|
|
@@ -219,8 +239,8 @@ type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPre
|
|
|
219
239
|
type NormalizeFn<Props extends AnyRecord = AnyRecord> = {
|
|
220
240
|
normalize(props: Readonly<Props & IntrinsicProps>): Props & IntrinsicProps;
|
|
221
241
|
}['normalize'];
|
|
222
|
-
type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap, RecipeMap<VariantMap>,
|
|
223
|
-
type FactoryOptions<TDefault extends ElementType = ElementType, Props extends AnyRecord = EmptyRecord, V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>, TPlugin extends
|
|
242
|
+
type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap, RecipeMap<VariantMap>, AnyClassPluginFactory>;
|
|
243
|
+
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> = {
|
|
224
244
|
readonly tag?: TDefault;
|
|
225
245
|
readonly name?: string;
|
|
226
246
|
readonly defaults?: Partial<NoInfer<Props>>;
|
|
@@ -243,6 +263,7 @@ type ResolvedFactoryOptions<TDefault extends ElementType = ElementType, Props ex
|
|
|
243
263
|
readonly variantKeys: ReadonlySet<string>;
|
|
244
264
|
readonly normalizeFn?: NormalizeFn<Props>;
|
|
245
265
|
readonly htmlPropNormalizersFn?: (tag: unknown) => readonly PropNormalizer[] | undefined;
|
|
266
|
+
readonly htmlChildrenEvaluatorFn?: (tag: unknown) => ChildrenEvaluator$1 | undefined;
|
|
246
267
|
readonly childRules?: readonly ChildRuleInput[];
|
|
247
268
|
readonly ariaRules?: readonly AriaRule[];
|
|
248
269
|
readonly allowedAs?: readonly ElementType[];
|
|
@@ -287,7 +308,7 @@ declare class ChildrenEvaluator extends InvariantBase {
|
|
|
287
308
|
evaluate(children: unknown[]): void;
|
|
288
309
|
}
|
|
289
310
|
|
|
290
|
-
declare function
|
|
311
|
+
declare function createPolymorphic2<TDefault extends ElementType, Props extends AnyRecord, Variants extends Readonly<VariantMap>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TPlugin extends AnyClassPluginFactory = AnyClassPluginFactory>(options?: FactoryOptions<TDefault, Props, Variants, TPreset, TPlugin>): PolymorphicRuntime<TDefault, Props, Variants, Extract<keyof TPreset, string>, TPreset, PluginInstance<TPlugin>>;
|
|
291
312
|
|
|
292
313
|
declare class SlotValidator extends InvariantBase {
|
|
293
314
|
#private;
|
|
@@ -309,9 +330,9 @@ type BuiltChildrenEvaluator<TOptions extends WithChildRules> = TOptions extends
|
|
|
309
330
|
|
|
310
331
|
declare function defineContractComponent<O extends FactoryOptions>(options: O): <R>(factory: (options: O) => R) => R;
|
|
311
332
|
|
|
312
|
-
type UnknownProps =
|
|
333
|
+
type UnknownProps = AnyRecord;
|
|
313
334
|
|
|
314
|
-
type SvelteFactoryOptions<TDefault extends ElementType, Props extends UnknownProps, Variants extends Readonly<VariantMap>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TPlugin extends
|
|
335
|
+
type SvelteFactoryOptions<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> & {
|
|
315
336
|
/**
|
|
316
337
|
* Return true for any prop key that should be consumed but not forwarded to the DOM.
|
|
317
338
|
* Receives `runtime.options.variantKeys` as a convenience if needed.
|
|
@@ -319,7 +340,7 @@ type SvelteFactoryOptions<TDefault extends ElementType, Props extends UnknownPro
|
|
|
319
340
|
filterProps?: (key: string, variantKeys: ReadonlySet<string>) => boolean;
|
|
320
341
|
};
|
|
321
342
|
|
|
322
|
-
type TypedRuntime<G extends PolymorphicGenerics> = ReturnType<typeof
|
|
343
|
+
type TypedRuntime<G extends PolymorphicGenerics> = ReturnType<typeof createPolymorphic2<DefaultOf<G>, PropsOf<G>, VariantsOf<G>, RecipeOf<G>>>;
|
|
323
344
|
|
|
324
345
|
type BuiltRuntime<G extends PolymorphicGenerics = PolymorphicGenerics, TOptions extends WithChildRules = WithChildRules> = BuiltChildrenEvaluator<TOptions> & {
|
|
325
346
|
runtime: TypedRuntime<G>;
|
|
@@ -327,6 +348,6 @@ type BuiltRuntime<G extends PolymorphicGenerics = PolymorphicGenerics, TOptions
|
|
|
327
348
|
slotValidator: SlotValidator;
|
|
328
349
|
};
|
|
329
350
|
|
|
330
|
-
declare function createContractComponent<TDefault extends ElementType, Props extends UnknownProps = EmptyRecord, Variants extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TPlugin extends
|
|
351
|
+
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, TOptions extends WithChildRules = SvelteFactoryOptions<TDefault, Props & ExtractPluginProps<TPlugin>, Variants, TPreset>>(options: SvelteFactoryOptions<TDefault, Props, Variants, TPreset, TPlugin> & TOptions): BuiltRuntime<PolymorphicGenerics<TDefault, Props & ExtractPluginProps<TPlugin>, Variants, TPreset>, TOptions>;
|
|
331
352
|
|
|
332
353
|
export { type AnyFactoryOptions, type BuiltRuntime, type ElementType, type EmptyRecord, type FilterPredicate, type PolymorphicGenerics, type SvelteFactoryOptions, type UnknownProps, type WithChildRules, createContractComponent, defineContractComponent };
|