praxis-kit 3.1.1 → 4.0.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/README.md +141 -126
- package/dist/chunk-TJRHF6MS.js +2777 -0
- package/dist/codemod/index.js +20 -20
- package/dist/contract/index.d.ts +164 -37
- package/dist/contract/index.js +158 -1190
- package/dist/eslint/index.js +403 -178
- package/dist/lit/index.d.ts +164 -37
- package/dist/lit/index.js +1384 -747
- package/dist/{merge-refs-BKyE8h8M.d.ts → merge-refs-CEpa0zK1.d.ts} +208 -49
- package/dist/preact/index.d.ts +177 -52
- package/dist/preact/index.js +1686 -1025
- package/dist/react/index.d.ts +19 -11
- package/dist/react/index.js +115 -116
- package/dist/react/legacy.d.ts +3 -11
- package/dist/react/legacy.js +116 -136
- package/dist/solid/index.d.ts +171 -46
- package/dist/solid/index.js +1476 -706
- package/dist/svelte/index.d.ts +177 -50
- package/dist/svelte/index.js +1407 -725
- package/dist/tailwind/index.d.ts +231 -5
- package/dist/tailwind/index.js +366 -90
- package/dist/ts-plugin/index.cjs +5 -5
- package/dist/vite-plugin/index.d.ts +228 -121
- package/dist/vite-plugin/index.js +568 -347
- package/dist/vue/index.d.ts +181 -56
- package/dist/vue/index.js +1701 -926
- package/dist/web/index.d.ts +167 -40
- package/dist/web/index.js +1369 -732
- package/package.json +5 -4
- package/dist/chunk-6RJN5B6L.js +0 -2221
package/dist/web/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { RequireAtLeastOne, Simplify, ReadonlyDeep } from 'type-fest';
|
|
1
|
+
import { Except, RequireAtLeastOne, Simplify, ReadonlyDeep } from 'type-fest';
|
|
2
2
|
|
|
3
|
-
type
|
|
3
|
+
type StringMap<T = unknown> = Record<string, T>;
|
|
4
|
+
type AnyRecord = StringMap<unknown>;
|
|
4
5
|
|
|
5
6
|
type IntrinsicTag = keyof HTMLElementTagNameMap;
|
|
6
7
|
|
|
@@ -9,32 +10,165 @@ type ElementType = IntrinsicTag | (string & {});
|
|
|
9
10
|
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"];
|
|
10
11
|
type KnownAriaRole = (typeof KNOWN_ARIA_ROLES)[number];
|
|
11
12
|
|
|
12
|
-
type AriaRole = KnownAriaRole | (string & {});
|
|
13
|
-
|
|
14
13
|
type Booleanish = boolean | 'true' | 'false';
|
|
15
|
-
|
|
16
14
|
type ClassName = string | string[];
|
|
17
|
-
|
|
18
15
|
type EmptyRecord = Record<never, never>;
|
|
19
|
-
|
|
16
|
+
type NonEmptyArray<T> = [T, ...T[]];
|
|
17
|
+
type Numberish = number | `${number}`;
|
|
18
|
+
type Primitive = string | number | boolean;
|
|
19
|
+
type AriaRole = KnownAriaRole | (string & {});
|
|
20
20
|
type IntrinsicProps = AnyRecord & {
|
|
21
21
|
role?: AriaRole;
|
|
22
22
|
};
|
|
23
|
+
type TagMap = Partial<Record<IntrinsicTag | (string & {}), ClassName>>;
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
declare enum DiagnosticCategory {
|
|
26
|
+
Contract = 0,
|
|
27
|
+
HTML = 1,
|
|
28
|
+
ARIA = 2,
|
|
29
|
+
Composition = 3,
|
|
30
|
+
Rendering = 4,
|
|
31
|
+
Accessibility = 5,
|
|
32
|
+
Performance = 6,
|
|
33
|
+
Internal = 7,
|
|
34
|
+
Deprecation = 8,
|
|
35
|
+
Lint = 9
|
|
36
|
+
}
|
|
25
37
|
|
|
26
|
-
|
|
38
|
+
declare enum DiagnosticCode {
|
|
39
|
+
MissingRequiredChild = "COMP1001",
|
|
40
|
+
InvalidParent = "COMP1002",
|
|
41
|
+
InvalidChild = "COMP1003",
|
|
42
|
+
UnexpectedChild = "COMP1004",
|
|
43
|
+
AmbiguousChild = "COMP1005",
|
|
44
|
+
CardinalityMin = "COMP1006",
|
|
45
|
+
CardinalityMax = "COMP1007",
|
|
46
|
+
PositionViolation = "COMP1008",
|
|
47
|
+
AllowedAsViolation = "COMP1009",
|
|
48
|
+
SlotExclusive = "SLOT1001",
|
|
49
|
+
SlotSingleChild = "SLOT1002",
|
|
50
|
+
SlotDiscardedChildren = "SLOT1003",
|
|
51
|
+
SlotRenderFn = "SLOT1004",
|
|
52
|
+
MissingAriaRelationship = "ARIA2001",
|
|
53
|
+
AriaViolation = "ARIA2002",
|
|
54
|
+
AriaAttributeInvalid = "ARIA2003",
|
|
55
|
+
AriaMissingLiveRegion = "ARIA2004",
|
|
56
|
+
AriaMissingAtomic = "ARIA2005",
|
|
57
|
+
AriaRelevantInvalidToken = "ARIA2006",
|
|
58
|
+
AriaRelevantSuperseded = "ARIA2007",
|
|
59
|
+
AriaInvalidRole = "ARIA2008",
|
|
60
|
+
AriaMissingAccessibleName = "ARIA2009",
|
|
61
|
+
AriaAttributeOnPresentational = "ARIA2010",
|
|
62
|
+
AriaHiddenOnFocusable = "ARIA2011",
|
|
63
|
+
AriaRequiredProperty = "ARIA2012",
|
|
64
|
+
AriaInvalidAttributeValue = "ARIA2013",
|
|
65
|
+
AriaRedundantLevelAttribute = "ARIA2014",
|
|
66
|
+
InvalidHeadingHierarchy = "HTML3001",
|
|
67
|
+
HtmlEmptyRole = "HTML3002",
|
|
68
|
+
HtmlImplicitRoleRedundant = "HTML3003",
|
|
69
|
+
HtmlImplicitRoleOverride = "HTML3004",
|
|
70
|
+
HtmlStandaloneRegionOverride = "HTML3005",
|
|
71
|
+
HtmlLandmarkRoleOverride = "HTML3006",
|
|
72
|
+
HtmlInvalidChild = "HTML3007",
|
|
73
|
+
InvalidRenderingTarget = "RENDER4001",
|
|
74
|
+
LintDeadCompoundKey = "LINT5001",
|
|
75
|
+
LintDeadCompoundValue = "LINT5002",
|
|
76
|
+
LintDeadCompoundNonLiteral = "LINT5003",
|
|
77
|
+
LintMissingStrict = "LINT5004",
|
|
78
|
+
LintInvalidDefaultKey = "LINT5005",
|
|
79
|
+
LintInvalidDefaultValue = "LINT5006",
|
|
80
|
+
LintInvalidDefaultNonLiteral = "LINT5007",
|
|
81
|
+
LintNegativeMin = "LINT5008",
|
|
82
|
+
LintNegativeMax = "LINT5009",
|
|
83
|
+
LintMaxLessThanMin = "LINT5010",
|
|
84
|
+
LintZeroMax = "LINT5011",
|
|
85
|
+
LintMultipleFirst = "LINT5012",
|
|
86
|
+
LintMultipleLast = "LINT5013",
|
|
87
|
+
LintMinSumExceedsCapacity = "LINT5014",
|
|
88
|
+
LintCardinalityViolation = "LINT5015",
|
|
89
|
+
LintAriaTagOverride = "LINT5016",
|
|
90
|
+
ContractUnknownVariantDim = "COMP1010",
|
|
91
|
+
ContractUnknownVariantValue = "COMP1011",
|
|
92
|
+
ContractUnknownRecipeKey = "COMP1012",
|
|
93
|
+
ContractInvalidVariantValue = "COMP1013",
|
|
94
|
+
TailwindMultipleDisplayProps = "CSS6001",
|
|
95
|
+
TailwindReservedLayoutLiteral = "CSS6002",
|
|
96
|
+
TailwindDeadVariantClass = "CSS6003",
|
|
97
|
+
PluginInvalidShape = "PLUGIN7001",
|
|
98
|
+
PluginPipelineReturnType = "PLUGIN7002",
|
|
99
|
+
InternalError = "INTERNAL9000"
|
|
100
|
+
}
|
|
27
101
|
|
|
28
|
-
|
|
102
|
+
interface SourcePosition {
|
|
103
|
+
line: number;
|
|
104
|
+
col: number;
|
|
105
|
+
}
|
|
106
|
+
interface SourceLocation {
|
|
107
|
+
file: string;
|
|
108
|
+
start: SourcePosition;
|
|
109
|
+
end?: SourcePosition;
|
|
110
|
+
}
|
|
29
111
|
|
|
30
|
-
|
|
112
|
+
declare enum Severity$1 {
|
|
113
|
+
Debug = 0,
|
|
114
|
+
Info = 1,
|
|
115
|
+
Warning = 2,
|
|
116
|
+
Error = 3,
|
|
117
|
+
Fatal = 4
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
interface DiagnosticSuggestion {
|
|
121
|
+
title: string;
|
|
122
|
+
description?: string;
|
|
123
|
+
fix?: string;
|
|
124
|
+
}
|
|
31
125
|
|
|
32
|
-
type
|
|
126
|
+
type Context = AnyRecord;
|
|
127
|
+
type Metadata = AnyRecord;
|
|
128
|
+
interface Diagnostic {
|
|
129
|
+
code: DiagnosticCode;
|
|
130
|
+
severity: Severity$1;
|
|
131
|
+
category: DiagnosticCategory;
|
|
132
|
+
message: string;
|
|
133
|
+
rationale?: string;
|
|
134
|
+
component?: string;
|
|
135
|
+
contract?: string;
|
|
136
|
+
location?: SourceLocation;
|
|
137
|
+
suggestions?: DiagnosticSuggestion[];
|
|
138
|
+
context?: Context;
|
|
139
|
+
metadata?: Metadata;
|
|
140
|
+
}
|
|
33
141
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
142
|
+
declare enum Enforcement {
|
|
143
|
+
Ignore = 0,
|
|
144
|
+
Report = 1,
|
|
145
|
+
Throw = 2
|
|
146
|
+
}
|
|
147
|
+
interface DiagnosticPolicy {
|
|
148
|
+
resolve(diagnostic: Diagnostic): Enforcement;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
interface DiagnosticReporter {
|
|
152
|
+
report(diagnostic: Diagnostic): void;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
type DiagnosticInput = Except<Diagnostic, 'severity'>;
|
|
156
|
+
declare class Diagnostics {
|
|
157
|
+
private readonly reporter;
|
|
158
|
+
private readonly policy;
|
|
159
|
+
readonly active: boolean;
|
|
160
|
+
constructor(reporter: DiagnosticReporter, policy?: DiagnosticPolicy);
|
|
161
|
+
report(diagnostic: Diagnostic): Diagnostic;
|
|
162
|
+
warn(input: DiagnosticInput): Diagnostic;
|
|
163
|
+
error(input: DiagnosticInput): Diagnostic;
|
|
164
|
+
info(input: DiagnosticInput): Diagnostic;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
type MinMax = {
|
|
168
|
+
min: number;
|
|
169
|
+
max: number;
|
|
37
170
|
};
|
|
171
|
+
type CardinalityInput = Partial<MinMax>;
|
|
38
172
|
|
|
39
173
|
type ChildRuleMatch<T, U extends T = T> = (child: T) => child is U;
|
|
40
174
|
|
|
@@ -57,16 +191,6 @@ type ValidResult = {
|
|
|
57
191
|
valid: true;
|
|
58
192
|
};
|
|
59
193
|
|
|
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
194
|
type RequireAtLeastOneIfNotEmpty<T> = keyof T extends never ? EmptyRecord : RequireAtLeastOne<T>;
|
|
71
195
|
type CompoundVariantConditionValue<V extends VariantMap, K extends keyof V> = VariantKey<V, K> | NonEmptyArray<VariantKey<V, K>>;
|
|
72
196
|
type CompoundVariantConditions<V extends VariantMap> = Simplify<{
|
|
@@ -75,18 +199,13 @@ type CompoundVariantConditions<V extends VariantMap> = Simplify<{
|
|
|
75
199
|
type CompoundVariantRequiredConditions<V extends VariantMap> = RequireAtLeastOneIfNotEmpty<CompoundVariantConditions<V>>;
|
|
76
200
|
type CompoundVariantBase<V extends VariantMap> = keyof V extends never ? EmptyRecord : CompoundVariantRequiredConditions<V>;
|
|
77
201
|
type CompoundVariant<V extends VariantMap> = CompoundVariantBase<V> & {
|
|
78
|
-
class: VariantValue
|
|
202
|
+
class: VariantValue;
|
|
79
203
|
};
|
|
80
204
|
|
|
81
205
|
interface CVACompounds<V extends VariantMap> {
|
|
82
206
|
compoundVariants?: readonly CompoundVariant<V>[];
|
|
83
207
|
}
|
|
84
208
|
|
|
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
209
|
interface CVADefaults<V extends VariantMap> {
|
|
91
210
|
defaultVariants?: DefaultVariants<V>;
|
|
92
211
|
}
|
|
@@ -95,6 +214,11 @@ interface CVAVariants<V extends VariantMap> {
|
|
|
95
214
|
variants?: V;
|
|
96
215
|
}
|
|
97
216
|
|
|
217
|
+
type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;
|
|
218
|
+
type VariantValue = string | string[];
|
|
219
|
+
type VariantStates<K extends string = string> = Record<K, VariantValue>;
|
|
220
|
+
type VariantMap<V extends string = string, K extends string = string> = Record<V, VariantStates<K>>;
|
|
221
|
+
type VariantKey<V extends VariantMap, K extends keyof V> = StringToBoolean<keyof V[K] & string>;
|
|
98
222
|
/**
|
|
99
223
|
* A partial selection of variant states authored at factory definition time.
|
|
100
224
|
*
|
|
@@ -104,7 +228,10 @@ interface CVAVariants<V extends VariantMap> {
|
|
|
104
228
|
type VariantSelection<V extends VariantMap> = {
|
|
105
229
|
[K in keyof V]?: keyof V[K];
|
|
106
230
|
};
|
|
107
|
-
|
|
231
|
+
type NormalizedVariantValue<K extends string> = string extends K ? Primitive : K extends 'true' | 'false' ? Booleanish : K extends `${number}` ? Numberish : K;
|
|
232
|
+
type DefaultVariants<V extends VariantMap> = {
|
|
233
|
+
[K in keyof V]?: NormalizedVariantValue<keyof V[K] & string>;
|
|
234
|
+
};
|
|
108
235
|
/**
|
|
109
236
|
* A static, immutable map of named presets to partial variant selections.
|
|
110
237
|
*
|
|
@@ -112,7 +239,6 @@ type VariantSelection<V extends VariantMap> = {
|
|
|
112
239
|
* avoiding the need to repeat variant combinations at each call site.
|
|
113
240
|
*/
|
|
114
241
|
type RecipeMap<V extends VariantMap = VariantMap> = Readonly<Record<string, VariantSelection<V>>>;
|
|
115
|
-
|
|
116
242
|
type RecipeTarget<TVariants extends VariantMap = VariantMap> = VariantSelection<TVariants>;
|
|
117
243
|
|
|
118
244
|
interface BaseClassOptions {
|
|
@@ -145,7 +271,7 @@ type ClassPlugin<TProps extends AnyRecord = EmptyRecord> = Readonly<{
|
|
|
145
271
|
readonly _pluginProps?: TProps;
|
|
146
272
|
}>;
|
|
147
273
|
|
|
148
|
-
type ClassPluginFactory<TProps extends AnyRecord = EmptyRecord> = <V extends VariantMap>(options: ClassPipelineOptions<V>,
|
|
274
|
+
type ClassPluginFactory<TProps extends AnyRecord = EmptyRecord> = <V extends VariantMap>(options: ClassPipelineOptions<V>, diagnostics: Diagnostics) => ClassPlugin<TProps>;
|
|
149
275
|
type ExtractPluginProps<TPlugin extends ClassPluginFactory<AnyRecord> | undefined> = TPlugin extends ClassPluginFactory<infer T> ? string extends keyof T ? EmptyRecord : T : EmptyRecord;
|
|
150
276
|
|
|
151
277
|
type AriaContext = {
|
|
@@ -179,8 +305,9 @@ type Severity = 'error' | 'warning' | (string & {});
|
|
|
179
305
|
type AriaInvalidBase<M extends string = string> = {
|
|
180
306
|
valid: false;
|
|
181
307
|
severity: Severity;
|
|
182
|
-
message
|
|
308
|
+
message?: M;
|
|
183
309
|
attribute?: string;
|
|
310
|
+
diagnostic?: DiagnosticInput;
|
|
184
311
|
};
|
|
185
312
|
type AriaInvalidWithFix<M extends string = string> = AriaInvalidBase<M> & {
|
|
186
313
|
fixable: true;
|
|
@@ -197,11 +324,11 @@ type AriaRule<C extends AriaContext = AriaContext> = (context: C) => readonly Ar
|
|
|
197
324
|
type PropNormalizer = (props: Readonly<AnyRecord & IntrinsicProps>) => Partial<AnyRecord & IntrinsicProps>;
|
|
198
325
|
|
|
199
326
|
type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
|
|
200
|
-
readonly
|
|
327
|
+
readonly diagnostics?: Diagnostics;
|
|
201
328
|
readonly aria?: readonly AriaRule[];
|
|
202
329
|
readonly children?: readonly ChildRuleInput[];
|
|
203
330
|
readonly props?: readonly PropNormalizer[];
|
|
204
|
-
/** Restricts the `as` prop to this set of tags. Violations route through
|
|
331
|
+
/** Restricts the `as` prop to this set of tags. Violations route through diagnostics. */
|
|
205
332
|
readonly allowedAs?: readonly TAllowed[];
|
|
206
333
|
};
|
|
207
334
|
|
|
@@ -260,8 +387,8 @@ type WebContractComponent<TVariants extends Readonly<VariantMap> = Readonly<Empt
|
|
|
260
387
|
} & {
|
|
261
388
|
[K in Extract<keyof TVariants, string>]?: string | null;
|
|
262
389
|
} & TPluginProps;
|
|
263
|
-
/** The resolved
|
|
264
|
-
readonly
|
|
390
|
+
/** The resolved diagnostics for this component — usable by subclasses for custom enforcement. */
|
|
391
|
+
readonly diagnostics: Diagnostics;
|
|
265
392
|
};
|
|
266
393
|
|
|
267
394
|
/**
|
|
@@ -278,7 +405,7 @@ type WebContractComponent<TVariants extends Readonly<VariantMap> = Readonly<Empt
|
|
|
278
405
|
* variants: { intent: { primary: 'btn--primary', ghost: 'btn--ghost' } },
|
|
279
406
|
* defaults: { intent: 'primary' },
|
|
280
407
|
* },
|
|
281
|
-
* enforcement: {
|
|
408
|
+
* enforcement: { diagnostics: warnDiagnostics },
|
|
282
409
|
* })
|
|
283
410
|
*
|
|
284
411
|
* customElements.define('praxis-button', Button)
|