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/tailwind/index.js
CHANGED
|
@@ -184,118 +184,6 @@ var iterate = Object.freeze({
|
|
|
184
184
|
values
|
|
185
185
|
});
|
|
186
186
|
|
|
187
|
-
// ../../lib/diagnostics/src/category.ts
|
|
188
|
-
var DiagnosticCategory = /* @__PURE__ */ ((DiagnosticCategory2) => {
|
|
189
|
-
DiagnosticCategory2[DiagnosticCategory2["Contract"] = 0] = "Contract";
|
|
190
|
-
DiagnosticCategory2[DiagnosticCategory2["HTML"] = 1] = "HTML";
|
|
191
|
-
DiagnosticCategory2[DiagnosticCategory2["ARIA"] = 2] = "ARIA";
|
|
192
|
-
DiagnosticCategory2[DiagnosticCategory2["Composition"] = 3] = "Composition";
|
|
193
|
-
DiagnosticCategory2[DiagnosticCategory2["Rendering"] = 4] = "Rendering";
|
|
194
|
-
DiagnosticCategory2[DiagnosticCategory2["Accessibility"] = 5] = "Accessibility";
|
|
195
|
-
DiagnosticCategory2[DiagnosticCategory2["Performance"] = 6] = "Performance";
|
|
196
|
-
DiagnosticCategory2[DiagnosticCategory2["Internal"] = 7] = "Internal";
|
|
197
|
-
DiagnosticCategory2[DiagnosticCategory2["Deprecation"] = 8] = "Deprecation";
|
|
198
|
-
DiagnosticCategory2[DiagnosticCategory2["Lint"] = 9] = "Lint";
|
|
199
|
-
return DiagnosticCategory2;
|
|
200
|
-
})(DiagnosticCategory || {});
|
|
201
|
-
|
|
202
|
-
// ../../lib/diagnostics/src/error.ts
|
|
203
|
-
var PraxisError = class extends Error {
|
|
204
|
-
diagnostic;
|
|
205
|
-
constructor(diagnostic) {
|
|
206
|
-
super(diagnostic.message);
|
|
207
|
-
this.name = "PraxisError";
|
|
208
|
-
this.diagnostic = diagnostic;
|
|
209
|
-
}
|
|
210
|
-
};
|
|
211
|
-
|
|
212
|
-
// ../../lib/diagnostics/src/severity.ts
|
|
213
|
-
var Severity = /* @__PURE__ */ ((Severity2) => {
|
|
214
|
-
Severity2[Severity2["Debug"] = 0] = "Debug";
|
|
215
|
-
Severity2[Severity2["Info"] = 1] = "Info";
|
|
216
|
-
Severity2[Severity2["Warning"] = 2] = "Warning";
|
|
217
|
-
Severity2[Severity2["Error"] = 3] = "Error";
|
|
218
|
-
Severity2[Severity2["Fatal"] = 4] = "Fatal";
|
|
219
|
-
return Severity2;
|
|
220
|
-
})(Severity || {});
|
|
221
|
-
|
|
222
|
-
// ../../lib/diagnostics/src/policy.ts
|
|
223
|
-
var DefaultPolicy = class {
|
|
224
|
-
reportThreshold;
|
|
225
|
-
throwThreshold;
|
|
226
|
-
constructor({
|
|
227
|
-
reportThreshold = 1 /* Info */,
|
|
228
|
-
throwThreshold = 4 /* Fatal */
|
|
229
|
-
} = {}) {
|
|
230
|
-
this.reportThreshold = reportThreshold;
|
|
231
|
-
this.throwThreshold = throwThreshold;
|
|
232
|
-
}
|
|
233
|
-
resolve(diagnostic) {
|
|
234
|
-
if (diagnostic.severity >= this.throwThreshold) return 2 /* Throw */;
|
|
235
|
-
if (diagnostic.severity >= this.reportThreshold) return 1 /* Report */;
|
|
236
|
-
return 0 /* Ignore */;
|
|
237
|
-
}
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
// ../../lib/diagnostics/src/diagnostics.ts
|
|
241
|
-
var Diagnostics = class {
|
|
242
|
-
reporter;
|
|
243
|
-
policy;
|
|
244
|
-
// Pre-computed at construction time: true if Warning-level diagnostics are not ignored.
|
|
245
|
-
active;
|
|
246
|
-
constructor(reporter, policy = new DefaultPolicy()) {
|
|
247
|
-
this.reporter = reporter;
|
|
248
|
-
this.policy = policy;
|
|
249
|
-
this.active = policy.resolve({ severity: 2 /* Warning */ }) !== 0 /* Ignore */;
|
|
250
|
-
}
|
|
251
|
-
report(diagnostic) {
|
|
252
|
-
const enforcement = this.policy.resolve(diagnostic);
|
|
253
|
-
if (enforcement === 0 /* Ignore */) return diagnostic;
|
|
254
|
-
if (enforcement === 2 /* Throw */) throw new PraxisError(diagnostic);
|
|
255
|
-
this.reporter.report(diagnostic);
|
|
256
|
-
return diagnostic;
|
|
257
|
-
}
|
|
258
|
-
warn(input) {
|
|
259
|
-
return this.report({ ...input, severity: 2 /* Warning */ });
|
|
260
|
-
}
|
|
261
|
-
error(input) {
|
|
262
|
-
return this.report({ ...input, severity: 3 /* Error */ });
|
|
263
|
-
}
|
|
264
|
-
info(input) {
|
|
265
|
-
return this.report({ ...input, severity: 1 /* Info */ });
|
|
266
|
-
}
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
// ../../lib/diagnostics/src/formatter.ts
|
|
270
|
-
function formatDiagnostic(diagnostic) {
|
|
271
|
-
const level = Severity[diagnostic.severity];
|
|
272
|
-
const category = DiagnosticCategory[diagnostic.category];
|
|
273
|
-
const prefix = category !== void 0 ? `[${category}] ` : "";
|
|
274
|
-
return `${level} ${diagnostic.code}: ${prefix}${diagnostic.message}`;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
// ../../lib/diagnostics/src/console-reporter.ts
|
|
278
|
-
var ConsoleReporter = class {
|
|
279
|
-
report(diagnostic) {
|
|
280
|
-
const message = formatDiagnostic(diagnostic);
|
|
281
|
-
switch (diagnostic.severity) {
|
|
282
|
-
case 0 /* Debug */:
|
|
283
|
-
console.debug(message);
|
|
284
|
-
break;
|
|
285
|
-
case 1 /* Info */:
|
|
286
|
-
console.info(message);
|
|
287
|
-
break;
|
|
288
|
-
case 2 /* Warning */:
|
|
289
|
-
console.warn(message);
|
|
290
|
-
break;
|
|
291
|
-
case 3 /* Error */:
|
|
292
|
-
case 4 /* Fatal */:
|
|
293
|
-
console.error(message);
|
|
294
|
-
break;
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
};
|
|
298
|
-
|
|
299
187
|
// ../../node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.mjs
|
|
300
188
|
import { clsx as clsx2 } from "clsx";
|
|
301
189
|
var falsyToString = (value) => typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
|
|
@@ -649,26 +537,30 @@ var LayoutState = class {
|
|
|
649
537
|
}
|
|
650
538
|
};
|
|
651
539
|
|
|
540
|
+
// ../../lib/tailwind/src/create-tailwind-pipeline.ts
|
|
541
|
+
import { ConsoleReporter, Diagnostics, DefaultPolicy, Severity } from "../_shared/diagnostics.js";
|
|
542
|
+
|
|
652
543
|
// ../../lib/tailwind/src/diagnostics.ts
|
|
544
|
+
import { DiagnosticCategory, DiagnosticCode } from "../_shared/diagnostics.js";
|
|
653
545
|
var TailwindDiagnostics = {
|
|
654
546
|
multipleDisplayProps(active) {
|
|
655
547
|
return {
|
|
656
|
-
code:
|
|
657
|
-
category:
|
|
548
|
+
code: DiagnosticCode.TailwindMultipleDisplayProps,
|
|
549
|
+
category: DiagnosticCategory.Contract,
|
|
658
550
|
message: `[createTailwindPipeline] Multiple display props set (${active.join(", ")}); "${active[0]}" takes precedence.`
|
|
659
551
|
};
|
|
660
552
|
},
|
|
661
553
|
reservedLayoutLiteral(reserved) {
|
|
662
554
|
return {
|
|
663
|
-
code:
|
|
664
|
-
category:
|
|
555
|
+
code: DiagnosticCode.TailwindReservedLayoutLiteral,
|
|
556
|
+
category: DiagnosticCategory.Contract,
|
|
665
557
|
message: `[createTailwindPipeline] Reserved display class(es) ${reserved.map((r) => `"${r}"`).join(", ")} found in resolved classes. The display mode is controlled by the display props (flex, inline-flex, grid, block, hidden, etc.), not by class strings.`
|
|
666
558
|
};
|
|
667
559
|
},
|
|
668
560
|
deadVariantClass(dim, value, mode, classStr) {
|
|
669
561
|
return {
|
|
670
|
-
code:
|
|
671
|
-
category:
|
|
562
|
+
code: DiagnosticCode.TailwindDeadVariantClass,
|
|
563
|
+
category: DiagnosticCategory.Contract,
|
|
672
564
|
message: `[createTailwindPipeline] Variant "${dim}=${value}" contributes only classes stripped under layout mode "${mode}" ("${classStr}") \u2014 it produces nothing in this mode.`
|
|
673
565
|
};
|
|
674
566
|
}
|
|
@@ -678,7 +570,7 @@ var TailwindDiagnostics = {
|
|
|
678
570
|
var DEV = process.env.NODE_ENV !== "production";
|
|
679
571
|
var devDiagnostics = new Diagnostics(
|
|
680
572
|
new ConsoleReporter(),
|
|
681
|
-
new DefaultPolicy({ reportThreshold:
|
|
573
|
+
new DefaultPolicy({ reportThreshold: Severity.Warning, throwThreshold: Severity.Fatal })
|
|
682
574
|
);
|
|
683
575
|
var classifier = new ClassClassifier();
|
|
684
576
|
var evaluator = new DependencyEvaluator(defaultDependencyRules);
|
|
@@ -1,8 +1,144 @@
|
|
|
1
1
|
import { Plugin } from 'vite';
|
|
2
|
-
import {
|
|
3
|
-
import { DiagnosticInput } from '@praxis-kit/diagnostics';
|
|
2
|
+
import { Except, Simplify } from 'type-fest';
|
|
4
3
|
import ts from 'typescript';
|
|
5
4
|
|
|
5
|
+
type StringMap<T = unknown> = Record<string, T>;
|
|
6
|
+
type AnyRecord = StringMap<unknown>;
|
|
7
|
+
|
|
8
|
+
declare enum DiagnosticCategory {
|
|
9
|
+
Contract = 0,
|
|
10
|
+
HTML = 1,
|
|
11
|
+
ARIA = 2,
|
|
12
|
+
Composition = 3,
|
|
13
|
+
Rendering = 4,
|
|
14
|
+
Accessibility = 5,
|
|
15
|
+
Performance = 6,
|
|
16
|
+
Internal = 7,
|
|
17
|
+
Deprecation = 8,
|
|
18
|
+
Lint = 9
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
declare enum DiagnosticCode {
|
|
22
|
+
MissingRequiredChild = "COMP1001",
|
|
23
|
+
InvalidParent = "COMP1002",
|
|
24
|
+
InvalidChild = "COMP1003",
|
|
25
|
+
UnexpectedChild = "COMP1004",
|
|
26
|
+
AmbiguousChild = "COMP1005",
|
|
27
|
+
CardinalityMin = "COMP1006",
|
|
28
|
+
CardinalityMax = "COMP1007",
|
|
29
|
+
PositionViolation = "COMP1008",
|
|
30
|
+
AllowedAsViolation = "COMP1009",
|
|
31
|
+
SlotExclusive = "SLOT1001",
|
|
32
|
+
SlotSingleChild = "SLOT1002",
|
|
33
|
+
SlotDiscardedChildren = "SLOT1003",
|
|
34
|
+
SlotRenderFn = "SLOT1004",
|
|
35
|
+
MissingAriaRelationship = "ARIA2001",
|
|
36
|
+
AriaViolation = "ARIA2002",
|
|
37
|
+
AriaAttributeInvalid = "ARIA2003",
|
|
38
|
+
AriaMissingLiveRegion = "ARIA2004",
|
|
39
|
+
AriaMissingAtomic = "ARIA2005",
|
|
40
|
+
AriaRelevantInvalidToken = "ARIA2006",
|
|
41
|
+
AriaRelevantSuperseded = "ARIA2007",
|
|
42
|
+
AriaInvalidRole = "ARIA2008",
|
|
43
|
+
AriaMissingAccessibleName = "ARIA2009",
|
|
44
|
+
AriaAttributeOnPresentational = "ARIA2010",
|
|
45
|
+
AriaHiddenOnFocusable = "ARIA2011",
|
|
46
|
+
AriaRequiredProperty = "ARIA2012",
|
|
47
|
+
AriaInvalidAttributeValue = "ARIA2013",
|
|
48
|
+
AriaRedundantLevelAttribute = "ARIA2014",
|
|
49
|
+
InvalidHeadingHierarchy = "HTML3001",
|
|
50
|
+
HtmlEmptyRole = "HTML3002",
|
|
51
|
+
HtmlImplicitRoleRedundant = "HTML3003",
|
|
52
|
+
HtmlImplicitRoleOverride = "HTML3004",
|
|
53
|
+
HtmlStandaloneRegionOverride = "HTML3005",
|
|
54
|
+
HtmlLandmarkRoleOverride = "HTML3006",
|
|
55
|
+
HtmlInvalidChild = "HTML3007",
|
|
56
|
+
InvalidRenderingTarget = "RENDER4001",
|
|
57
|
+
LintDeadCompoundKey = "LINT5001",
|
|
58
|
+
LintDeadCompoundValue = "LINT5002",
|
|
59
|
+
LintDeadCompoundNonLiteral = "LINT5003",
|
|
60
|
+
LintMissingStrict = "LINT5004",
|
|
61
|
+
LintInvalidDefaultKey = "LINT5005",
|
|
62
|
+
LintInvalidDefaultValue = "LINT5006",
|
|
63
|
+
LintInvalidDefaultNonLiteral = "LINT5007",
|
|
64
|
+
LintNegativeMin = "LINT5008",
|
|
65
|
+
LintNegativeMax = "LINT5009",
|
|
66
|
+
LintMaxLessThanMin = "LINT5010",
|
|
67
|
+
LintZeroMax = "LINT5011",
|
|
68
|
+
LintMultipleFirst = "LINT5012",
|
|
69
|
+
LintMultipleLast = "LINT5013",
|
|
70
|
+
LintMinSumExceedsCapacity = "LINT5014",
|
|
71
|
+
LintCardinalityViolation = "LINT5015",
|
|
72
|
+
LintAriaTagOverride = "LINT5016",
|
|
73
|
+
ContractUnknownVariantDim = "COMP1010",
|
|
74
|
+
ContractUnknownVariantValue = "COMP1011",
|
|
75
|
+
ContractUnknownRecipeKey = "COMP1012",
|
|
76
|
+
ContractInvalidVariantValue = "COMP1013",
|
|
77
|
+
TailwindMultipleDisplayProps = "CSS6001",
|
|
78
|
+
TailwindReservedLayoutLiteral = "CSS6002",
|
|
79
|
+
TailwindDeadVariantClass = "CSS6003",
|
|
80
|
+
PluginInvalidShape = "PLUGIN7001",
|
|
81
|
+
PluginPipelineReturnType = "PLUGIN7002",
|
|
82
|
+
InternalError = "INTERNAL9000"
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
interface SourcePosition {
|
|
86
|
+
line: number;
|
|
87
|
+
col: number;
|
|
88
|
+
}
|
|
89
|
+
interface SourceLocation {
|
|
90
|
+
file: string;
|
|
91
|
+
start: SourcePosition;
|
|
92
|
+
end?: SourcePosition;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
declare enum Severity$1 {
|
|
96
|
+
Debug = 0,
|
|
97
|
+
Info = 1,
|
|
98
|
+
Warning = 2,
|
|
99
|
+
Error = 3,
|
|
100
|
+
Fatal = 4
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
interface DiagnosticSuggestion {
|
|
104
|
+
title: string;
|
|
105
|
+
description?: string;
|
|
106
|
+
fix?: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
type Context = AnyRecord;
|
|
110
|
+
type Metadata = AnyRecord;
|
|
111
|
+
interface Diagnostic$1 {
|
|
112
|
+
code: DiagnosticCode;
|
|
113
|
+
severity: Severity$1;
|
|
114
|
+
category: DiagnosticCategory;
|
|
115
|
+
message: string;
|
|
116
|
+
rationale?: string;
|
|
117
|
+
component?: string;
|
|
118
|
+
contract?: string;
|
|
119
|
+
location?: SourceLocation;
|
|
120
|
+
suggestions?: DiagnosticSuggestion[];
|
|
121
|
+
context?: Context;
|
|
122
|
+
metadata?: Metadata;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
type DiagnosticInput = Except<Diagnostic$1, 'severity'>;
|
|
126
|
+
|
|
127
|
+
type MinMax = {
|
|
128
|
+
min: number;
|
|
129
|
+
max: number;
|
|
130
|
+
};
|
|
131
|
+
/** Unboundedness is encoded in the type, not a sentinel value, enabling exhaustive switches. */
|
|
132
|
+
type Cardinality = Simplify<{
|
|
133
|
+
kind: 'bounded';
|
|
134
|
+
} & MinMax> | {
|
|
135
|
+
kind: 'unbounded';
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
type ChildRulePosition = 'first' | 'last' | 'any';
|
|
139
|
+
|
|
140
|
+
type Severity = 'error' | 'warning' | (string & {});
|
|
141
|
+
|
|
6
142
|
/**
|
|
7
143
|
* One enforcement.children rule whose cardinality is statically extractable
|
|
8
144
|
* from the factory call AST. The `Cardinality` discriminated union matches the
|
package/dist/vue/index.d.ts
CHANGED
|
@@ -1,9 +1,238 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { RequireAtLeastOne, Simplify, ReadonlyDeep } from 'type-fest';
|
|
2
|
+
import { Diagnostics, DiagnosticInput } from '../_shared/diagnostics.js';
|
|
3
3
|
import * as vue from 'vue';
|
|
4
4
|
import { AllowedComponentProps } from 'vue';
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
|
|
6
|
+
type StringMap<T = unknown> = Record<string, T>;
|
|
7
|
+
type AnyRecord = StringMap<unknown>;
|
|
8
|
+
|
|
9
|
+
type IntrinsicTag = keyof HTMLElementTagNameMap;
|
|
10
|
+
|
|
11
|
+
type ElementType = IntrinsicTag | (string & {});
|
|
12
|
+
|
|
13
|
+
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"];
|
|
14
|
+
type KnownAriaRole = (typeof KNOWN_ARIA_ROLES)[number];
|
|
15
|
+
|
|
16
|
+
type Booleanish = boolean | 'true' | 'false';
|
|
17
|
+
type ClassName = string | string[];
|
|
18
|
+
type EmptyRecord = Record<never, never>;
|
|
19
|
+
type NonEmptyArray<T> = [T, ...T[]];
|
|
20
|
+
type Numberish = number | `${number}`;
|
|
21
|
+
type Primitive = string | number | boolean;
|
|
22
|
+
type AriaRole = KnownAriaRole | (string & {});
|
|
23
|
+
type IntrinsicProps = AnyRecord & {
|
|
24
|
+
role?: AriaRole;
|
|
25
|
+
};
|
|
26
|
+
type TagMap = Partial<Record<IntrinsicTag | (string & {}), ClassName>>;
|
|
27
|
+
|
|
28
|
+
type MinMax = {
|
|
29
|
+
min: number;
|
|
30
|
+
max: number;
|
|
31
|
+
};
|
|
32
|
+
type CardinalityInput = Partial<MinMax>;
|
|
33
|
+
|
|
34
|
+
type ChildRuleMatch<T, U extends T = T> = (child: T) => child is U;
|
|
35
|
+
|
|
36
|
+
type ChildRulePosition = 'first' | 'last' | 'any';
|
|
37
|
+
|
|
38
|
+
type ChildRuleInput<T = unknown, U extends T = T> = {
|
|
39
|
+
name: string;
|
|
40
|
+
match: ChildRuleMatch<T, U>;
|
|
41
|
+
cardinality?: CardinalityInput;
|
|
42
|
+
position?: ChildRulePosition;
|
|
43
|
+
/**
|
|
44
|
+
* Optional component-type reference for O(1) dispatch index.
|
|
45
|
+
* When provided for every rule, the matcher reads child.type instead of
|
|
46
|
+
* calling every match function on every child (O(n×m) → O(n+m)).
|
|
47
|
+
*/
|
|
48
|
+
type?: unknown;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
type ValidResult = {
|
|
52
|
+
valid: true;
|
|
53
|
+
};
|
|
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
|
+
type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;
|
|
79
|
+
type VariantValue = string | string[];
|
|
80
|
+
type VariantStates<K extends string = string> = Record<K, VariantValue>;
|
|
81
|
+
type VariantMap<V extends string = string, K extends string = string> = Record<V, VariantStates<K>>;
|
|
82
|
+
type VariantKey<V extends VariantMap, K extends keyof V> = StringToBoolean<keyof V[K] & string>;
|
|
83
|
+
/**
|
|
84
|
+
* A partial selection of variant states authored at factory definition time.
|
|
85
|
+
*
|
|
86
|
+
* Uses `keyof V[K]` directly (not `VariantKey`) so TypeScript can eagerly
|
|
87
|
+
* resolve the union at constraint-check time without deferred conditional types.
|
|
88
|
+
*/
|
|
89
|
+
type VariantSelection<V extends VariantMap> = {
|
|
90
|
+
[K in keyof V]?: keyof V[K];
|
|
91
|
+
};
|
|
92
|
+
/** The full optional prop surface exposed to callers for a given variant map. */
|
|
93
|
+
type VariantProps<V extends VariantMap> = {
|
|
94
|
+
[K in keyof V]?: VariantKey<V, K>;
|
|
95
|
+
};
|
|
96
|
+
type NormalizedVariantValue<K extends string> = string extends K ? Primitive : K extends 'true' | 'false' ? Booleanish : K extends `${number}` ? Numberish : K;
|
|
97
|
+
type DefaultVariants<V extends VariantMap> = {
|
|
98
|
+
[K in keyof V]?: NormalizedVariantValue<keyof V[K] & string>;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* A static, immutable map of named presets to partial variant selections.
|
|
102
|
+
*
|
|
103
|
+
* Presets are named bundles of variant props that callers activate by key,
|
|
104
|
+
* avoiding the need to repeat variant combinations at each call site.
|
|
105
|
+
*/
|
|
106
|
+
type RecipeMap<V extends VariantMap = VariantMap> = Readonly<Record<string, VariantSelection<V>>>;
|
|
107
|
+
type RecipeTarget<TVariants extends VariantMap = VariantMap> = VariantSelection<TVariants>;
|
|
108
|
+
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
|
+
default: TDefault;
|
|
110
|
+
props: Props;
|
|
111
|
+
variants: Variants;
|
|
112
|
+
preset: TPreset;
|
|
113
|
+
allowed: TAllowed;
|
|
114
|
+
}
|
|
115
|
+
type VariantsOf<T extends PolymorphicGenerics> = T['variants'];
|
|
116
|
+
type RecipeOf<T extends PolymorphicGenerics> = T['preset'];
|
|
117
|
+
type DefaultOf<T extends PolymorphicGenerics> = T['default'];
|
|
118
|
+
type PropsOf<T extends PolymorphicGenerics> = T['props'];
|
|
119
|
+
|
|
120
|
+
interface BaseClassOptions {
|
|
121
|
+
baseClassName?: ClassName;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName, recipe?: string) => string;
|
|
125
|
+
|
|
126
|
+
interface RecipeOptions<TVariants extends VariantMap = VariantMap> {
|
|
127
|
+
recipeMap?: Record<string, RecipeTarget<TVariants>>;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
interface TagMapOptions {
|
|
131
|
+
tagMap?: TagMap;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
type CompositionOptions<TVariants extends VariantMap = VariantMap> = Simplify<TagMapOptions & RecipeOptions<TVariants>>;
|
|
135
|
+
|
|
136
|
+
type CVASystemOptions<TVariants extends VariantMap = VariantMap> = Simplify<CVAVariants<TVariants> & CVADefaults<TVariants> & CVACompounds<TVariants>>;
|
|
137
|
+
|
|
138
|
+
type StyleOptions<TVariants extends VariantMap = VariantMap> = Simplify<BaseClassOptions & CVASystemOptions<TVariants>>;
|
|
139
|
+
|
|
140
|
+
type ClassPipelineOptions<TVariants extends VariantMap = VariantMap> = Simplify<StyleOptions<TVariants> & CompositionOptions<TVariants>>;
|
|
141
|
+
|
|
142
|
+
type OwnedPropKeys = ReadonlySet<string>;
|
|
143
|
+
|
|
144
|
+
type ClassPlugin<TProps extends AnyRecord = EmptyRecord> = Readonly<{
|
|
145
|
+
pipeline: ClassPipelineFn;
|
|
146
|
+
ownedKeys?: OwnedPropKeys;
|
|
147
|
+
readonly _pluginProps?: TProps;
|
|
148
|
+
}>;
|
|
149
|
+
|
|
150
|
+
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;
|
|
152
|
+
|
|
153
|
+
type AriaContext = {
|
|
154
|
+
readonly tag: IntrinsicTag;
|
|
155
|
+
readonly implicitRole: AriaRole | undefined;
|
|
156
|
+
readonly effectiveRole: string | undefined;
|
|
157
|
+
readonly props: ReadonlyDeep<IntrinsicProps>;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
type RemoveAttributeFixKind = `removeAttribute:${string}`;
|
|
161
|
+
type InjectLiveFixKind = `injectLive:${string}`;
|
|
162
|
+
type FixKind = 'removeRole' | 'setRole' | 'normalizeRelevantAll' | RemoveAttributeFixKind | InjectLiveFixKind;
|
|
163
|
+
|
|
164
|
+
type AriaFixResult = {
|
|
165
|
+
applied: false;
|
|
166
|
+
next: ReadonlyDeep<IntrinsicProps>;
|
|
167
|
+
} | {
|
|
168
|
+
applied: true;
|
|
169
|
+
next: ReadonlyDeep<IntrinsicProps>;
|
|
170
|
+
previous: ReadonlyDeep<IntrinsicProps>;
|
|
171
|
+
};
|
|
172
|
+
type AriaFix = {
|
|
173
|
+
readonly kind: FixKind;
|
|
174
|
+
readonly priority?: number;
|
|
175
|
+
readonly source?: string;
|
|
176
|
+
readonly apply: (context: AriaContext) => AriaFixResult;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
type Severity = 'error' | 'warning' | (string & {});
|
|
180
|
+
|
|
181
|
+
type AriaInvalidBase<M extends string = string> = {
|
|
182
|
+
valid: false;
|
|
183
|
+
severity: Severity;
|
|
184
|
+
message?: M;
|
|
185
|
+
attribute?: string;
|
|
186
|
+
diagnostic?: DiagnosticInput;
|
|
187
|
+
};
|
|
188
|
+
type AriaInvalidWithFix<M extends string = string> = AriaInvalidBase<M> & {
|
|
189
|
+
fixable: true;
|
|
190
|
+
fix: AriaFix;
|
|
191
|
+
};
|
|
192
|
+
type AriaInvalidWithoutFix<M extends string = string> = AriaInvalidBase<M> & {
|
|
193
|
+
fixable: false;
|
|
194
|
+
};
|
|
195
|
+
type AriaInvalidResult<M extends string = string> = AriaInvalidWithFix<M> | AriaInvalidWithoutFix<M>;
|
|
196
|
+
type AriaResult = ValidResult | AriaInvalidResult;
|
|
197
|
+
|
|
198
|
+
type AriaRule<C extends AriaContext = AriaContext> = (context: C) => readonly AriaResult[];
|
|
199
|
+
|
|
200
|
+
type PropNormalizer = (props: Readonly<AnyRecord & IntrinsicProps>) => Partial<AnyRecord & IntrinsicProps>;
|
|
201
|
+
|
|
202
|
+
type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
|
|
203
|
+
readonly diagnostics?: Diagnostics;
|
|
204
|
+
readonly aria?: readonly AriaRule[];
|
|
205
|
+
readonly children?: readonly ChildRuleInput[];
|
|
206
|
+
readonly props?: readonly PropNormalizer[];
|
|
207
|
+
/** Restricts the `as` prop to this set of tags. Violations route through diagnostics. */
|
|
208
|
+
readonly allowedAs?: readonly TAllowed[];
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>, TPlugin extends ClassPluginFactory<AnyRecord> | undefined = ClassPluginFactory<AnyRecord> | undefined> = {
|
|
212
|
+
readonly base?: ClassName;
|
|
213
|
+
readonly variants?: V;
|
|
214
|
+
readonly defaults?: Partial<DefaultVariants<V>>;
|
|
215
|
+
readonly compounds?: readonly CompoundVariant<V>[];
|
|
216
|
+
readonly presets?: TPreset;
|
|
217
|
+
readonly tags?: Readonly<TagMap>;
|
|
218
|
+
readonly plugin?: TPlugin;
|
|
219
|
+
readonly precomputedClasses?: Readonly<Record<string, string>>;
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
type NormalizeFn<Props extends AnyRecord = AnyRecord> = {
|
|
223
|
+
normalize(props: Readonly<Props & IntrinsicProps>): Props & IntrinsicProps;
|
|
224
|
+
}['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> = {
|
|
227
|
+
readonly tag?: TDefault;
|
|
228
|
+
readonly name?: string;
|
|
229
|
+
readonly defaults?: Partial<NoInfer<Props>>;
|
|
230
|
+
readonly normalize?: NormalizeFn<NoInfer<Props>>;
|
|
231
|
+
readonly styling?: StylingOptions<V, TPreset, TPlugin>;
|
|
232
|
+
readonly enforcement?: EnforcementOptions<TAllowed>;
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
declare function defineContractComponent<O extends FactoryOptions>(options: O): <R>(factory: (options: O) => R) => R;
|
|
7
236
|
|
|
8
237
|
type SlottableProps = {
|
|
9
238
|
children?: unknown;
|
|
@@ -66,4 +295,4 @@ type PolymorphicComponent<G extends PolymorphicGenerics> = {
|
|
|
66
295
|
|
|
67
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>>;
|
|
68
297
|
|
|
69
|
-
export { type PolymorphicComponent, type PolymorphicProps, type PolymorphicWithAsChild, Slottable, type SlottableProps, type VueFactoryOptions, createContractComponent };
|
|
298
|
+
export { type AnyFactoryOptions, type ElementType, type EmptyRecord, type PolymorphicComponent, type PolymorphicGenerics, type PolymorphicProps, type PolymorphicWithAsChild, Slottable, type SlottableProps, type VueFactoryOptions, createContractComponent, defineContractComponent };
|