praxis-kit 4.0.0 → 4.0.3
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 +212 -0
- package/dist/_shared/diagnostics.js +289 -0
- package/dist/{chunk-TJRHF6MS.js → chunk-DRGZ4ZI2.js} +79 -208
- package/dist/codemod/index.js +23 -15
- package/dist/contract/index.d.ts +246 -2
- package/dist/eslint/index.js +21 -17
- package/dist/lit/index.d.ts +221 -5
- package/dist/lit/index.js +74 -203
- package/dist/merge-refs-B0YcfdtP.d.ts +399 -0
- package/dist/preact/index.d.ts +234 -5
- package/dist/preact/index.js +79 -208
- package/dist/react/index.d.ts +4 -7
- package/dist/react/index.js +1 -1
- package/dist/react/legacy.d.ts +4 -7
- package/dist/react/legacy.js +1 -1
- package/dist/solid/index.d.ts +234 -5
- package/dist/solid/index.js +83 -212
- package/dist/svelte/index.d.ts +311 -5
- package/dist/svelte/index.js +83 -212
- package/dist/tailwind/index.d.ts +88 -4
- package/dist/tailwind/index.js +11 -119
- package/dist/vite-plugin/index.d.ts +138 -2
- package/dist/vue/index.d.ts +234 -5
- package/dist/vue/index.js +79 -208
- package/dist/web/index.d.ts +221 -6
- package/dist/web/index.js +74 -203
- package/package.json +3 -3
- package/dist/merge-refs-DUuHyTRO.d.ts +0 -144
package/dist/web/index.d.ts
CHANGED
|
@@ -1,8 +1,223 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { RequireAtLeastOne, Simplify, ReadonlyDeep } from 'type-fest';
|
|
2
|
+
import { Diagnostics, DiagnosticInput } from '../_shared/diagnostics.js';
|
|
3
|
+
|
|
4
|
+
type StringMap<T = unknown> = Record<string, T>;
|
|
5
|
+
type AnyRecord = StringMap<unknown>;
|
|
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 Booleanish = boolean | 'true' | 'false';
|
|
15
|
+
type ClassName = string | string[];
|
|
16
|
+
type EmptyRecord = Record<never, never>;
|
|
17
|
+
type NonEmptyArray<T> = [T, ...T[]];
|
|
18
|
+
type Numberish = number | `${number}`;
|
|
19
|
+
type Primitive = string | number | boolean;
|
|
20
|
+
type AriaRole = KnownAriaRole | (string & {});
|
|
21
|
+
type IntrinsicProps = AnyRecord & {
|
|
22
|
+
role?: AriaRole;
|
|
23
|
+
};
|
|
24
|
+
type TagMap = Partial<Record<IntrinsicTag | (string & {}), ClassName>>;
|
|
25
|
+
|
|
26
|
+
type MinMax = {
|
|
27
|
+
min: number;
|
|
28
|
+
max: number;
|
|
29
|
+
};
|
|
30
|
+
type CardinalityInput = Partial<MinMax>;
|
|
31
|
+
|
|
32
|
+
type ChildRuleMatch<T, U extends T = T> = (child: T) => child is U;
|
|
33
|
+
|
|
34
|
+
type ChildRulePosition = 'first' | 'last' | 'any';
|
|
35
|
+
|
|
36
|
+
type ChildRuleInput<T = unknown, U extends T = T> = {
|
|
37
|
+
name: string;
|
|
38
|
+
match: ChildRuleMatch<T, U>;
|
|
39
|
+
cardinality?: CardinalityInput;
|
|
40
|
+
position?: ChildRulePosition;
|
|
41
|
+
/**
|
|
42
|
+
* Optional component-type reference for O(1) dispatch index.
|
|
43
|
+
* When provided for every rule, the matcher reads child.type instead of
|
|
44
|
+
* calling every match function on every child (O(n×m) → O(n+m)).
|
|
45
|
+
*/
|
|
46
|
+
type?: unknown;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
type ValidResult = {
|
|
50
|
+
valid: true;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
type RequireAtLeastOneIfNotEmpty<T> = keyof T extends never ? EmptyRecord : RequireAtLeastOne<T>;
|
|
54
|
+
type CompoundVariantConditionValue<V extends VariantMap, K extends keyof V> = VariantKey<V, K> | NonEmptyArray<VariantKey<V, K>>;
|
|
55
|
+
type CompoundVariantConditions<V extends VariantMap> = Simplify<{
|
|
56
|
+
[K in keyof V]: CompoundVariantConditionValue<V, K>;
|
|
57
|
+
}>;
|
|
58
|
+
type CompoundVariantRequiredConditions<V extends VariantMap> = RequireAtLeastOneIfNotEmpty<CompoundVariantConditions<V>>;
|
|
59
|
+
type CompoundVariantBase<V extends VariantMap> = keyof V extends never ? EmptyRecord : CompoundVariantRequiredConditions<V>;
|
|
60
|
+
type CompoundVariant<V extends VariantMap> = CompoundVariantBase<V> & {
|
|
61
|
+
class: VariantValue;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
interface CVACompounds<V extends VariantMap> {
|
|
65
|
+
compoundVariants?: readonly CompoundVariant<V>[];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
interface CVADefaults<V extends VariantMap> {
|
|
69
|
+
defaultVariants?: DefaultVariants<V>;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
interface CVAVariants<V extends VariantMap> {
|
|
73
|
+
variants?: V;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;
|
|
77
|
+
type VariantValue = string | string[];
|
|
78
|
+
type VariantStates<K extends string = string> = Record<K, VariantValue>;
|
|
79
|
+
type VariantMap<V extends string = string, K extends string = string> = Record<V, VariantStates<K>>;
|
|
80
|
+
type VariantKey<V extends VariantMap, K extends keyof V> = StringToBoolean<keyof V[K] & string>;
|
|
81
|
+
/**
|
|
82
|
+
* A partial selection of variant states authored at factory definition time.
|
|
83
|
+
*
|
|
84
|
+
* Uses `keyof V[K]` directly (not `VariantKey`) so TypeScript can eagerly
|
|
85
|
+
* resolve the union at constraint-check time without deferred conditional types.
|
|
86
|
+
*/
|
|
87
|
+
type VariantSelection<V extends VariantMap> = {
|
|
88
|
+
[K in keyof V]?: keyof V[K];
|
|
89
|
+
};
|
|
90
|
+
type NormalizedVariantValue<K extends string> = string extends K ? Primitive : K extends 'true' | 'false' ? Booleanish : K extends `${number}` ? Numberish : K;
|
|
91
|
+
type DefaultVariants<V extends VariantMap> = {
|
|
92
|
+
[K in keyof V]?: NormalizedVariantValue<keyof V[K] & string>;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* A static, immutable map of named presets to partial variant selections.
|
|
96
|
+
*
|
|
97
|
+
* Presets are named bundles of variant props that callers activate by key,
|
|
98
|
+
* avoiding the need to repeat variant combinations at each call site.
|
|
99
|
+
*/
|
|
100
|
+
type RecipeMap<V extends VariantMap = VariantMap> = Readonly<Record<string, VariantSelection<V>>>;
|
|
101
|
+
type RecipeTarget<TVariants extends VariantMap = VariantMap> = VariantSelection<TVariants>;
|
|
102
|
+
|
|
103
|
+
interface BaseClassOptions {
|
|
104
|
+
baseClassName?: ClassName;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName, recipe?: string) => string;
|
|
108
|
+
|
|
109
|
+
interface RecipeOptions<TVariants extends VariantMap = VariantMap> {
|
|
110
|
+
recipeMap?: Record<string, RecipeTarget<TVariants>>;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
interface TagMapOptions {
|
|
114
|
+
tagMap?: TagMap;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
type CompositionOptions<TVariants extends VariantMap = VariantMap> = Simplify<TagMapOptions & RecipeOptions<TVariants>>;
|
|
118
|
+
|
|
119
|
+
type CVASystemOptions<TVariants extends VariantMap = VariantMap> = Simplify<CVAVariants<TVariants> & CVADefaults<TVariants> & CVACompounds<TVariants>>;
|
|
120
|
+
|
|
121
|
+
type StyleOptions<TVariants extends VariantMap = VariantMap> = Simplify<BaseClassOptions & CVASystemOptions<TVariants>>;
|
|
122
|
+
|
|
123
|
+
type ClassPipelineOptions<TVariants extends VariantMap = VariantMap> = Simplify<StyleOptions<TVariants> & CompositionOptions<TVariants>>;
|
|
124
|
+
|
|
125
|
+
type OwnedPropKeys = ReadonlySet<string>;
|
|
126
|
+
|
|
127
|
+
type ClassPlugin<TProps extends AnyRecord = EmptyRecord> = Readonly<{
|
|
128
|
+
pipeline: ClassPipelineFn;
|
|
129
|
+
ownedKeys?: OwnedPropKeys;
|
|
130
|
+
readonly _pluginProps?: TProps;
|
|
131
|
+
}>;
|
|
132
|
+
|
|
133
|
+
type ClassPluginFactory<TProps extends AnyRecord = EmptyRecord> = <V extends VariantMap>(options: ClassPipelineOptions<V>, diagnostics: Diagnostics) => ClassPlugin<TProps>;
|
|
134
|
+
type ExtractPluginProps<TPlugin extends ClassPluginFactory<AnyRecord> | undefined> = TPlugin extends ClassPluginFactory<infer T> ? string extends keyof T ? EmptyRecord : T : EmptyRecord;
|
|
135
|
+
|
|
136
|
+
type AriaContext = {
|
|
137
|
+
readonly tag: IntrinsicTag;
|
|
138
|
+
readonly implicitRole: AriaRole | undefined;
|
|
139
|
+
readonly effectiveRole: string | undefined;
|
|
140
|
+
readonly props: ReadonlyDeep<IntrinsicProps>;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
type RemoveAttributeFixKind = `removeAttribute:${string}`;
|
|
144
|
+
type InjectLiveFixKind = `injectLive:${string}`;
|
|
145
|
+
type FixKind = 'removeRole' | 'setRole' | 'normalizeRelevantAll' | RemoveAttributeFixKind | InjectLiveFixKind;
|
|
146
|
+
|
|
147
|
+
type AriaFixResult = {
|
|
148
|
+
applied: false;
|
|
149
|
+
next: ReadonlyDeep<IntrinsicProps>;
|
|
150
|
+
} | {
|
|
151
|
+
applied: true;
|
|
152
|
+
next: ReadonlyDeep<IntrinsicProps>;
|
|
153
|
+
previous: ReadonlyDeep<IntrinsicProps>;
|
|
154
|
+
};
|
|
155
|
+
type AriaFix = {
|
|
156
|
+
readonly kind: FixKind;
|
|
157
|
+
readonly priority?: number;
|
|
158
|
+
readonly source?: string;
|
|
159
|
+
readonly apply: (context: AriaContext) => AriaFixResult;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
type Severity = 'error' | 'warning' | (string & {});
|
|
163
|
+
|
|
164
|
+
type AriaInvalidBase<M extends string = string> = {
|
|
165
|
+
valid: false;
|
|
166
|
+
severity: Severity;
|
|
167
|
+
message?: M;
|
|
168
|
+
attribute?: string;
|
|
169
|
+
diagnostic?: DiagnosticInput;
|
|
170
|
+
};
|
|
171
|
+
type AriaInvalidWithFix<M extends string = string> = AriaInvalidBase<M> & {
|
|
172
|
+
fixable: true;
|
|
173
|
+
fix: AriaFix;
|
|
174
|
+
};
|
|
175
|
+
type AriaInvalidWithoutFix<M extends string = string> = AriaInvalidBase<M> & {
|
|
176
|
+
fixable: false;
|
|
177
|
+
};
|
|
178
|
+
type AriaInvalidResult<M extends string = string> = AriaInvalidWithFix<M> | AriaInvalidWithoutFix<M>;
|
|
179
|
+
type AriaResult = ValidResult | AriaInvalidResult;
|
|
180
|
+
|
|
181
|
+
type AriaRule<C extends AriaContext = AriaContext> = (context: C) => readonly AriaResult[];
|
|
182
|
+
|
|
183
|
+
type PropNormalizer = (props: Readonly<AnyRecord & IntrinsicProps>) => Partial<AnyRecord & IntrinsicProps>;
|
|
184
|
+
|
|
185
|
+
type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
|
|
186
|
+
readonly diagnostics?: Diagnostics;
|
|
187
|
+
readonly aria?: readonly AriaRule[];
|
|
188
|
+
readonly children?: readonly ChildRuleInput[];
|
|
189
|
+
readonly props?: readonly PropNormalizer[];
|
|
190
|
+
/** Restricts the `as` prop to this set of tags. Violations route through diagnostics. */
|
|
191
|
+
readonly allowedAs?: readonly TAllowed[];
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>, TPlugin extends ClassPluginFactory<AnyRecord> | undefined = ClassPluginFactory<AnyRecord> | undefined> = {
|
|
195
|
+
readonly base?: ClassName;
|
|
196
|
+
readonly variants?: V;
|
|
197
|
+
readonly defaults?: Partial<DefaultVariants<V>>;
|
|
198
|
+
readonly compounds?: readonly CompoundVariant<V>[];
|
|
199
|
+
readonly presets?: TPreset;
|
|
200
|
+
readonly tags?: Readonly<TagMap>;
|
|
201
|
+
readonly plugin?: TPlugin;
|
|
202
|
+
readonly precomputedClasses?: Readonly<Record<string, string>>;
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
type NormalizeFn<Props extends AnyRecord = AnyRecord> = {
|
|
206
|
+
normalize(props: Readonly<Props & IntrinsicProps>): Props & IntrinsicProps;
|
|
207
|
+
}['normalize'];
|
|
208
|
+
type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap, RecipeMap<VariantMap>, ClassPluginFactory<AnyRecord> | undefined>;
|
|
209
|
+
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> = {
|
|
210
|
+
readonly tag?: TDefault;
|
|
211
|
+
readonly name?: string;
|
|
212
|
+
readonly defaults?: Partial<NoInfer<Props>>;
|
|
213
|
+
readonly normalize?: NormalizeFn<NoInfer<Props>>;
|
|
214
|
+
readonly styling?: StylingOptions<V, TPreset, TPlugin>;
|
|
215
|
+
readonly enforcement?: EnforcementOptions<TAllowed>;
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
type FilterPredicate = (key: string, variantKeys: ReadonlySet<string>) => boolean;
|
|
219
|
+
|
|
220
|
+
declare function defineContractComponent<O extends FactoryOptions>(options: O): <R>(factory: (options: O) => R) => R;
|
|
6
221
|
|
|
7
222
|
/**
|
|
8
223
|
* Options accepted by createContractComponent in the web adapter.
|
|
@@ -75,4 +290,4 @@ declare function createContractComponent<TDefault extends ElementType, TProps ex
|
|
|
75
290
|
*/
|
|
76
291
|
declare function renderToString(component: WebContractComponent, props?: UnknownProps, innerHTML?: string): string;
|
|
77
292
|
|
|
78
|
-
export { type WebContractComponent, type WebFactoryOptions, createContractComponent, renderToString };
|
|
293
|
+
export { type AnyFactoryOptions, type WebContractComponent, type WebFactoryOptions, createContractComponent, defineContractComponent, renderToString };
|