praxis-kit 3.1.1 → 4.0.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 +141 -126
- package/dist/chunk-TJRHF6MS.js +2777 -0
- package/dist/codemod/index.js +20 -20
- package/dist/contract/index.d.ts +2 -258
- package/dist/contract/index.js +158 -1190
- package/dist/eslint/index.js +403 -178
- package/dist/lit/index.d.ts +5 -235
- package/dist/lit/index.js +1384 -747
- package/dist/merge-refs-DUuHyTRO.d.ts +144 -0
- package/dist/preact/index.d.ts +9 -254
- package/dist/preact/index.js +1686 -1025
- package/dist/react/index.d.ts +23 -11
- package/dist/react/index.js +115 -116
- package/dist/react/legacy.d.ts +7 -11
- package/dist/react/legacy.js +116 -136
- package/dist/solid/index.d.ts +5 -250
- package/dist/solid/index.js +1476 -706
- package/dist/svelte/index.d.ts +5 -325
- package/dist/svelte/index.js +1407 -725
- package/dist/tailwind/index.d.ts +5 -4
- package/dist/tailwind/index.js +366 -90
- package/dist/ts-plugin/index.cjs +5 -5
- package/dist/vite-plugin/index.d.ts +91 -120
- package/dist/vite-plugin/index.js +568 -347
- package/dist/vue/index.d.ts +12 -257
- package/dist/vue/index.js +1701 -926
- package/dist/web/index.d.ts +9 -238
- package/dist/web/index.js +1369 -732
- package/package.json +4 -3
- package/dist/chunk-6RJN5B6L.js +0 -2221
- package/dist/merge-refs-BKyE8h8M.d.ts +0 -381
package/dist/vue/index.d.ts
CHANGED
|
@@ -1,254 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ElementType, VariantMap, RecipeMap, EmptyRecord, ClassPluginFactory, AnyRecord, FactoryOptions, PolymorphicGenerics, DefaultOf, PropsOf, VariantProps, VariantsOf, ClassName, RecipeOf, ExtractPluginProps } from '@praxis-kit/core';
|
|
2
|
+
export { AnyFactoryOptions, ElementType, EmptyRecord, PolymorphicGenerics } from '@praxis-kit/core';
|
|
2
3
|
import * as vue from 'vue';
|
|
3
4
|
import { AllowedComponentProps } from 'vue';
|
|
5
|
+
import { Simplify } from 'type-fest';
|
|
6
|
+
export { defineContractComponent } from '@praxis-kit/adapter-utils';
|
|
4
7
|
|
|
5
|
-
type
|
|
6
|
-
|
|
7
|
-
type IntrinsicTag = keyof HTMLElementTagNameMap;
|
|
8
|
-
|
|
9
|
-
type ElementType = IntrinsicTag | (string & {});
|
|
10
|
-
|
|
11
|
-
declare const KNOWN_ARIA_ROLES: readonly ["alert", "alertdialog", "application", "article", "banner", "blockquote", "button", "caption", "cell", "checkbox", "code", "columnheader", "combobox", "complementary", "contentinfo", "definition", "deletion", "dialog", "document", "emphasis", "feed", "figure", "form", "generic", "grid", "gridcell", "group", "heading", "img", "insertion", "link", "list", "listbox", "listitem", "log", "main", "marquee", "math", "menu", "menubar", "menuitem", "menuitemcheckbox", "menuitemradio", "meter", "navigation", "none", "note", "option", "paragraph", "presentation", "progressbar", "radio", "radiogroup", "region", "row", "rowgroup", "rowheader", "scrollbar", "search", "searchbox", "separator", "slider", "spinbutton", "status", "strong", "subscript", "superscript", "switch", "tab", "table", "tablist", "tabpanel", "term", "textbox", "time", "timer", "toolbar", "tooltip", "tree", "treegrid", "treeitem"];
|
|
12
|
-
type KnownAriaRole = (typeof KNOWN_ARIA_ROLES)[number];
|
|
13
|
-
|
|
14
|
-
type AriaRole = KnownAriaRole | (string & {});
|
|
15
|
-
|
|
16
|
-
type Booleanish = boolean | 'true' | 'false';
|
|
17
|
-
|
|
18
|
-
type ClassName = string | string[];
|
|
19
|
-
|
|
20
|
-
type EmptyRecord = Record<never, never>;
|
|
21
|
-
|
|
22
|
-
type IntrinsicProps = AnyRecord & {
|
|
23
|
-
role?: AriaRole;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
type NonEmptyArray<T> = [T, ...T[]];
|
|
27
|
-
|
|
28
|
-
type Numberish = number | `${number}`;
|
|
29
|
-
|
|
30
|
-
type Primitive = string | number | boolean;
|
|
31
|
-
|
|
32
|
-
type TagMap = Partial<Record<IntrinsicTag | (string & {}), ClassName>>;
|
|
33
|
-
|
|
34
|
-
type StrictMode = boolean | 'warn' | 'async-warn' | 'throw';
|
|
35
|
-
|
|
36
|
-
type CardinalityInput = {
|
|
37
|
-
min?: number;
|
|
38
|
-
max?: number;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
type ChildRuleMatch<T, U extends T = T> = (child: T) => child is U;
|
|
42
|
-
|
|
43
|
-
type ChildRulePosition = 'first' | 'last' | 'any';
|
|
44
|
-
|
|
45
|
-
type ChildRuleInput<T = unknown, U extends T = T> = {
|
|
46
|
-
name: string;
|
|
47
|
-
match: ChildRuleMatch<T, U>;
|
|
48
|
-
cardinality?: CardinalityInput;
|
|
49
|
-
position?: ChildRulePosition;
|
|
50
|
-
/**
|
|
51
|
-
* Optional component-type reference for O(1) dispatch index.
|
|
52
|
-
* When provided for every rule, the matcher reads child.type instead of
|
|
53
|
-
* calling every match function on every child (O(n×m) → O(n+m)).
|
|
54
|
-
*/
|
|
55
|
-
type?: unknown;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
type ValidResult = {
|
|
59
|
-
valid: true;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;
|
|
63
|
-
|
|
64
|
-
type VariantValue$1 = string | string[];
|
|
65
|
-
|
|
66
|
-
type VariantStates<K extends string = string> = Record<K, VariantValue$1>;
|
|
67
|
-
|
|
68
|
-
type VariantMap<V extends string = string, K extends string = string> = Record<V, VariantStates<K>>;
|
|
69
|
-
|
|
70
|
-
type VariantKey<V extends VariantMap, K extends keyof V> = StringToBoolean<keyof V[K] & string>;
|
|
71
|
-
|
|
72
|
-
type RequireAtLeastOneIfNotEmpty<T> = keyof T extends never ? EmptyRecord : RequireAtLeastOne<T>;
|
|
73
|
-
type CompoundVariantConditionValue<V extends VariantMap, K extends keyof V> = VariantKey<V, K> | NonEmptyArray<VariantKey<V, K>>;
|
|
74
|
-
type CompoundVariantConditions<V extends VariantMap> = Simplify<{
|
|
75
|
-
[K in keyof V]: CompoundVariantConditionValue<V, K>;
|
|
76
|
-
}>;
|
|
77
|
-
type CompoundVariantRequiredConditions<V extends VariantMap> = RequireAtLeastOneIfNotEmpty<CompoundVariantConditions<V>>;
|
|
78
|
-
type CompoundVariantBase<V extends VariantMap> = keyof V extends never ? EmptyRecord : CompoundVariantRequiredConditions<V>;
|
|
79
|
-
type CompoundVariant<V extends VariantMap> = CompoundVariantBase<V> & {
|
|
80
|
-
class: VariantValue$1;
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
interface CVACompounds<V extends VariantMap> {
|
|
84
|
-
compoundVariants?: readonly CompoundVariant<V>[];
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/** The full optional prop surface exposed to callers for a given variant map. */
|
|
88
|
-
type VariantProps<V extends VariantMap> = {
|
|
89
|
-
[K in keyof V]?: VariantKey<V, K>;
|
|
90
|
-
};
|
|
91
|
-
type VariantValue<K extends string> = string extends K ? Primitive : K extends 'true' | 'false' ? Booleanish : K extends `${number}` ? Numberish : K;
|
|
92
|
-
type DefaultVariants<V extends VariantMap> = {
|
|
93
|
-
[K in keyof V]?: VariantValue<keyof V[K] & string>;
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
interface CVADefaults<V extends VariantMap> {
|
|
97
|
-
defaultVariants?: DefaultVariants<V>;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
interface CVAVariants<V extends VariantMap> {
|
|
101
|
-
variants?: V;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* A partial selection of variant states authored at factory definition time.
|
|
106
|
-
*
|
|
107
|
-
* Uses `keyof V[K]` directly (not `VariantKey`) so TypeScript can eagerly
|
|
108
|
-
* resolve the union at constraint-check time without deferred conditional types.
|
|
109
|
-
*/
|
|
110
|
-
type VariantSelection<V extends VariantMap> = {
|
|
111
|
-
[K in keyof V]?: keyof V[K];
|
|
8
|
+
type SlottableProps = {
|
|
9
|
+
children?: unknown;
|
|
112
10
|
};
|
|
113
|
-
|
|
114
11
|
/**
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
* Presets are named bundles of variant props that callers activate by key,
|
|
118
|
-
* avoiding the need to repeat variant combinations at each call site.
|
|
12
|
+
* Marker component for the Slottable sibling pattern. Wrap content that should
|
|
13
|
+
* be passed as the asChild slot's children when additional siblings are present.
|
|
119
14
|
*/
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
default: TDefault;
|
|
124
|
-
props: Props;
|
|
125
|
-
variants: Variants;
|
|
126
|
-
preset: TPreset;
|
|
127
|
-
allowed: TAllowed;
|
|
128
|
-
}
|
|
129
|
-
type VariantsOf<T extends PolymorphicGenerics> = T['variants'];
|
|
130
|
-
type RecipeOf<T extends PolymorphicGenerics> = T['preset'];
|
|
131
|
-
|
|
132
|
-
type RecipeTarget<TVariants extends VariantMap = VariantMap> = VariantSelection<TVariants>;
|
|
133
|
-
|
|
134
|
-
interface BaseClassOptions {
|
|
135
|
-
baseClassName?: ClassName;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName, recipe?: string) => string;
|
|
139
|
-
|
|
140
|
-
interface RecipeOptions<TVariants extends VariantMap = VariantMap> {
|
|
141
|
-
recipeMap?: Record<string, RecipeTarget<TVariants>>;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
interface TagMapOptions {
|
|
145
|
-
tagMap?: TagMap;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
type CompositionOptions<TVariants extends VariantMap = VariantMap> = Simplify<TagMapOptions & RecipeOptions<TVariants>>;
|
|
149
|
-
|
|
150
|
-
type CVASystemOptions<TVariants extends VariantMap = VariantMap> = Simplify<CVAVariants<TVariants> & CVADefaults<TVariants> & CVACompounds<TVariants>>;
|
|
151
|
-
|
|
152
|
-
type StyleOptions<TVariants extends VariantMap = VariantMap> = Simplify<BaseClassOptions & CVASystemOptions<TVariants>>;
|
|
153
|
-
|
|
154
|
-
type ClassPipelineOptions<TVariants extends VariantMap = VariantMap> = Simplify<StyleOptions<TVariants> & CompositionOptions<TVariants>>;
|
|
155
|
-
|
|
156
|
-
type OwnedPropKeys = ReadonlySet<string>;
|
|
157
|
-
|
|
158
|
-
type ClassPlugin<TProps extends AnyRecord = EmptyRecord> = Readonly<{
|
|
159
|
-
pipeline: ClassPipelineFn;
|
|
160
|
-
ownedKeys?: OwnedPropKeys;
|
|
161
|
-
readonly _pluginProps?: TProps;
|
|
162
|
-
}>;
|
|
163
|
-
|
|
164
|
-
type ClassPluginFactory<TProps extends AnyRecord = EmptyRecord> = <V extends VariantMap>(options: ClassPipelineOptions<V>, strict: StrictMode) => ClassPlugin<TProps>;
|
|
165
|
-
type ExtractPluginProps<TPlugin extends ClassPluginFactory<AnyRecord> | undefined> = TPlugin extends ClassPluginFactory<infer T> ? string extends keyof T ? EmptyRecord : T : EmptyRecord;
|
|
166
|
-
|
|
167
|
-
type AriaContext = {
|
|
168
|
-
readonly tag: IntrinsicTag;
|
|
169
|
-
readonly implicitRole: AriaRole | undefined;
|
|
170
|
-
readonly effectiveRole: string | undefined;
|
|
171
|
-
readonly props: ReadonlyDeep<IntrinsicProps>;
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
type RemoveAttributeFixKind = `removeAttribute:${string}`;
|
|
175
|
-
type InjectLiveFixKind = `injectLive:${string}`;
|
|
176
|
-
type FixKind = 'removeRole' | 'setRole' | 'normalizeRelevantAll' | RemoveAttributeFixKind | InjectLiveFixKind;
|
|
177
|
-
|
|
178
|
-
type AriaFixResult = {
|
|
179
|
-
applied: false;
|
|
180
|
-
next: ReadonlyDeep<IntrinsicProps>;
|
|
181
|
-
} | {
|
|
182
|
-
applied: true;
|
|
183
|
-
next: ReadonlyDeep<IntrinsicProps>;
|
|
184
|
-
previous: ReadonlyDeep<IntrinsicProps>;
|
|
185
|
-
};
|
|
186
|
-
type AriaFix = {
|
|
187
|
-
readonly kind: FixKind;
|
|
188
|
-
readonly priority?: number;
|
|
189
|
-
readonly source?: string;
|
|
190
|
-
readonly apply: (context: AriaContext) => AriaFixResult;
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
type Severity = 'error' | 'warning' | (string & {});
|
|
194
|
-
|
|
195
|
-
type AriaInvalidBase<M extends string = string> = {
|
|
196
|
-
valid: false;
|
|
197
|
-
severity: Severity;
|
|
198
|
-
message: M;
|
|
199
|
-
attribute?: string;
|
|
200
|
-
};
|
|
201
|
-
type AriaInvalidWithFix<M extends string = string> = AriaInvalidBase<M> & {
|
|
202
|
-
fixable: true;
|
|
203
|
-
fix: AriaFix;
|
|
204
|
-
};
|
|
205
|
-
type AriaInvalidWithoutFix<M extends string = string> = AriaInvalidBase<M> & {
|
|
206
|
-
fixable: false;
|
|
207
|
-
};
|
|
208
|
-
type AriaInvalidResult<M extends string = string> = AriaInvalidWithFix<M> | AriaInvalidWithoutFix<M>;
|
|
209
|
-
type AriaResult = ValidResult | AriaInvalidResult;
|
|
210
|
-
|
|
211
|
-
type AriaRule<C extends AriaContext = AriaContext> = (context: C) => readonly AriaResult[];
|
|
212
|
-
|
|
213
|
-
type PropNormalizer = (props: Readonly<AnyRecord & IntrinsicProps>) => Partial<AnyRecord & IntrinsicProps>;
|
|
214
|
-
|
|
215
|
-
type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
|
|
216
|
-
readonly strict?: StrictMode;
|
|
217
|
-
readonly aria?: readonly AriaRule[];
|
|
218
|
-
readonly children?: readonly ChildRuleInput[];
|
|
219
|
-
readonly props?: readonly PropNormalizer[];
|
|
220
|
-
/** Restricts the `as` prop to this set of tags. Violations route through strict mode. */
|
|
221
|
-
readonly allowedAs?: readonly TAllowed[];
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>, TPlugin extends ClassPluginFactory<AnyRecord> | undefined = ClassPluginFactory<AnyRecord> | undefined> = {
|
|
225
|
-
readonly base?: ClassName;
|
|
226
|
-
readonly variants?: V;
|
|
227
|
-
readonly defaults?: Partial<DefaultVariants<V>>;
|
|
228
|
-
readonly compounds?: readonly CompoundVariant<V>[];
|
|
229
|
-
readonly presets?: TPreset;
|
|
230
|
-
readonly tags?: Readonly<TagMap>;
|
|
231
|
-
readonly plugin?: TPlugin;
|
|
232
|
-
readonly precomputedClasses?: Readonly<Record<string, string>>;
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
type NormalizeFn<Props extends AnyRecord = AnyRecord> = {
|
|
236
|
-
normalize(props: Readonly<Props & IntrinsicProps>): Props & IntrinsicProps;
|
|
237
|
-
}['normalize'];
|
|
238
|
-
type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap, RecipeMap<VariantMap>, ClassPluginFactory<AnyRecord> | undefined>;
|
|
239
|
-
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> = {
|
|
240
|
-
readonly tag?: TDefault;
|
|
241
|
-
readonly name?: string;
|
|
242
|
-
readonly defaults?: Partial<NoInfer<Props>>;
|
|
243
|
-
readonly normalize?: NormalizeFn<NoInfer<Props>>;
|
|
244
|
-
readonly styling?: StylingOptions<V, TPreset, TPlugin>;
|
|
245
|
-
readonly enforcement?: EnforcementOptions<TAllowed>;
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
type DefaultOf<T extends PolymorphicGenerics> = T['default'];
|
|
249
|
-
type PropsOf<T extends PolymorphicGenerics> = T['props'];
|
|
250
|
-
|
|
251
|
-
declare function defineContractComponent<O extends FactoryOptions>(options: O): <R>(factory: (options: O) => R) => R;
|
|
15
|
+
declare const Slottable: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
252
18
|
|
|
253
19
|
type UnknownProps = Record<string, unknown>;
|
|
254
20
|
|
|
@@ -260,17 +26,6 @@ type VueFactoryOptions<TDefault extends ElementType, Props extends UnknownProps,
|
|
|
260
26
|
filterProps?: (key: string, variantKeys: ReadonlySet<string>) => boolean;
|
|
261
27
|
};
|
|
262
28
|
|
|
263
|
-
type SlottableProps = {
|
|
264
|
-
children?: unknown;
|
|
265
|
-
};
|
|
266
|
-
/**
|
|
267
|
-
* Marker component for the Slottable sibling pattern. Wrap content that should
|
|
268
|
-
* be passed as the asChild slot's children when additional siblings are present.
|
|
269
|
-
*/
|
|
270
|
-
declare const Slottable: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
271
|
-
[key: string]: any;
|
|
272
|
-
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
273
|
-
|
|
274
29
|
type ControlProps<G extends PolymorphicGenerics, TAs extends ElementType> = PropsOf<G> & VariantProps<VariantsOf<G>> & {
|
|
275
30
|
as?: TAs;
|
|
276
31
|
class?: ClassName;
|
|
@@ -311,4 +66,4 @@ type PolymorphicComponent<G extends PolymorphicGenerics> = {
|
|
|
311
66
|
|
|
312
67
|
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>>;
|
|
313
68
|
|
|
314
|
-
export { type
|
|
69
|
+
export { type PolymorphicComponent, type PolymorphicProps, type PolymorphicWithAsChild, Slottable, type SlottableProps, type VueFactoryOptions, createContractComponent };
|