praxis-kit 7.4.0 → 7.8.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/dist/_shared/diagnostics.d.ts +3 -0
- package/dist/_shared/diagnostics.js +3 -0
- package/dist/{chunk-EIKPSL26.js → chunk-QYP7KLRE.js} +316 -154
- package/dist/contract/index.d.ts +27 -4
- package/dist/eslint/index.js +227 -187
- package/dist/html/index.d.ts +6 -1
- package/dist/html/index.js +234 -68
- package/dist/lit/index.d.ts +27 -4
- package/dist/lit/index.js +305 -141
- package/dist/preact/index.d.ts +114 -6
- package/dist/preact/index.js +321 -153
- package/dist/react/index.d.ts +3 -2
- package/dist/react/index.js +7 -2
- package/dist/react/legacy.d.ts +8 -5
- package/dist/react/legacy.js +13 -9
- package/dist/{react-options-BnjZpdVh.d.ts → react-options-DU3EdFOv.d.ts} +126 -7
- package/dist/solid/index.d.ts +127 -8
- package/dist/solid/index.js +320 -153
- package/dist/svelte/Polymorphic.svelte +8 -0
- package/dist/svelte/index.d.ts +224 -13
- package/dist/svelte/index.js +319 -152
- package/dist/tailwind/index.d.ts +1 -1
- package/dist/vite-plugin/index.d.ts +6 -3
- package/dist/vue/index.d.ts +94 -6
- package/dist/vue/index.js +320 -153
- package/dist/web/index.d.ts +27 -4
- package/dist/web/index.js +305 -141
- package/package.json +9 -9
package/dist/contract/index.d.ts
CHANGED
|
@@ -25,6 +25,19 @@ type SubComponentMap = Readonly<AnyRecord>;
|
|
|
25
25
|
type IntrinsicTag = keyof HTMLElementTagNameMap;
|
|
26
26
|
|
|
27
27
|
type ElementType = IntrinsicTag | (string & {});
|
|
28
|
+
/**
|
|
29
|
+
* Resolves a component's default tag to its real DOM interface — `HTMLDialogElement` for
|
|
30
|
+
* `'dialog'`, `HTMLDetailsElement` for `'details'`, and so on — falling back to `HTMLElement`
|
|
31
|
+
* for custom-element tags or anything not in `HTMLElementTagNameMap`. Used to type
|
|
32
|
+
* `FactoryOptions.onElement`'s `element` param so component authors get direct, correctly-typed
|
|
33
|
+
* access to tag-specific native members (`dialogEl.showModal()`) without an unsafe cast.
|
|
34
|
+
*
|
|
35
|
+
* The fallback is `HTMLElement`, not the more generic `Element` — every tag reachable through
|
|
36
|
+
* `IntrinsicTag` extends it, and so does every custom element per spec, so members `HTMLElement`
|
|
37
|
+
* itself declares (`showPopover()`/`hidePopover()`/`togglePopover()`, the `popover` attribute)
|
|
38
|
+
* stay directly accessible even for tags with no dedicated entry in `HTMLElementTagNameMap`.
|
|
39
|
+
*/
|
|
40
|
+
type ElementForTag<TDefault extends ElementType> = TDefault extends keyof HTMLElementTagNameMap ? HTMLElementTagNameMap[TDefault] : HTMLElement;
|
|
28
41
|
|
|
29
42
|
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"];
|
|
30
43
|
type KnownAriaRole = (typeof KNOWN_ARIA_ROLES)[number];
|
|
@@ -124,7 +137,7 @@ type DefaultVariants<V extends VariantMap> = {
|
|
|
124
137
|
* Presets are named bundles of variant props that callers activate by key,
|
|
125
138
|
* avoiding the need to repeat variant combinations at each call site.
|
|
126
139
|
*/
|
|
127
|
-
type RecipeMap<V extends VariantMap = VariantMap> = Readonly<
|
|
140
|
+
type RecipeMap<V extends VariantMap = VariantMap> = Readonly<StringMap<VariantSelection<V>>>;
|
|
128
141
|
|
|
129
142
|
type RecipeTarget<TVariants extends VariantMap = VariantMap> = VariantSelection<TVariants>;
|
|
130
143
|
|
|
@@ -158,7 +171,7 @@ interface BaseClassOptions {
|
|
|
158
171
|
type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName, recipe?: string) => string | undefined;
|
|
159
172
|
|
|
160
173
|
interface RecipeOptions<TVariants extends VariantMap = VariantMap> {
|
|
161
|
-
recipeMap?:
|
|
174
|
+
recipeMap?: StringMap<RecipeTarget<TVariants>>;
|
|
162
175
|
}
|
|
163
176
|
|
|
164
177
|
interface TagMapOptions {
|
|
@@ -327,7 +340,7 @@ type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPre
|
|
|
327
340
|
* combination, skipping runtime class computation entirely when a match is found. Normally
|
|
328
341
|
* generated by a build-time class-extraction plugin rather than hand-authored.
|
|
329
342
|
*/
|
|
330
|
-
readonly precomputedClasses?: Readonly<
|
|
343
|
+
readonly precomputedClasses?: Readonly<StringMap<string>>;
|
|
331
344
|
};
|
|
332
345
|
|
|
333
346
|
type NormalizeFn<Props extends AnyRecord = AnyRecord> = {
|
|
@@ -373,13 +386,23 @@ type FactoryOptions<TDefault extends ElementType = ElementType, Props extends An
|
|
|
373
386
|
* no prop-based equivalent), not for anything expressible as a plain
|
|
374
387
|
* prop.
|
|
375
388
|
*
|
|
389
|
+
* `element` is typed to the real DOM interface of every tag the rendered
|
|
390
|
+
* element could actually be — `TDefault` plus whatever `enforcement.allowed`
|
|
391
|
+
* permits via `as` (`HTMLDialogElement` for `tag: 'dialog'`,
|
|
392
|
+
* `HTMLDetailsElement` for `tag: 'details'`, and so on) — no cast needed to
|
|
393
|
+
* reach tag-specific members. A component that leaves `allowed`
|
|
394
|
+
* unconstrained (any tag reachable via `as`) falls back to `HTMLElement`,
|
|
395
|
+
* which still covers members every element shares (`showPopover()` and
|
|
396
|
+
* friends); restrict `enforcement.allowed` to the tags `onElement`
|
|
397
|
+
* actually knows how to handle to get real narrowing.
|
|
398
|
+
*
|
|
376
399
|
* `getProps` returns the instance's *current* resolved props at call
|
|
377
400
|
* time — read it from inside a listener registered once at mount, rather
|
|
378
401
|
* than re-subscribing on every prop change.
|
|
379
402
|
*
|
|
380
403
|
* Return a cleanup function to run when the instance unmounts.
|
|
381
404
|
*/
|
|
382
|
-
readonly onElement?: (element:
|
|
405
|
+
readonly onElement?: (element: ElementForTag<TDefault | TAllowed>, getProps: () => Readonly<Props>) => void | (() => void);
|
|
383
406
|
};
|
|
384
407
|
|
|
385
408
|
/** Shared input shape for `invalidWithFix`/`invalidWithoutFix`. */
|
package/dist/eslint/index.js
CHANGED
|
@@ -28,9 +28,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
mod
|
|
29
29
|
));
|
|
30
30
|
|
|
31
|
-
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.
|
|
31
|
+
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.66.0_eslint@10.7.0_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/deepMerge.js
|
|
32
32
|
var require_deepMerge = __commonJS({
|
|
33
|
-
"../../node_modules/.pnpm/@typescript-eslint+utils@8.
|
|
33
|
+
"../../node_modules/.pnpm/@typescript-eslint+utils@8.66.0_eslint@10.7.0_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/deepMerge.js"(exports) {
|
|
34
34
|
"use strict";
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.isObjectNotArray = isObjectNotArray;
|
|
@@ -63,9 +63,9 @@ var require_deepMerge = __commonJS({
|
|
|
63
63
|
}
|
|
64
64
|
});
|
|
65
65
|
|
|
66
|
-
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.
|
|
66
|
+
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.66.0_eslint@10.7.0_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/applyDefault.js
|
|
67
67
|
var require_applyDefault = __commonJS({
|
|
68
|
-
"../../node_modules/.pnpm/@typescript-eslint+utils@8.
|
|
68
|
+
"../../node_modules/.pnpm/@typescript-eslint+utils@8.66.0_eslint@10.7.0_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/applyDefault.js"(exports) {
|
|
69
69
|
"use strict";
|
|
70
70
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
71
71
|
exports.applyDefault = applyDefault;
|
|
@@ -90,9 +90,9 @@ var require_applyDefault = __commonJS({
|
|
|
90
90
|
}
|
|
91
91
|
});
|
|
92
92
|
|
|
93
|
-
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.
|
|
93
|
+
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.66.0_eslint@10.7.0_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/parserSeemsToBeTSESLint.js
|
|
94
94
|
var require_parserSeemsToBeTSESLint = __commonJS({
|
|
95
|
-
"../../node_modules/.pnpm/@typescript-eslint+utils@8.
|
|
95
|
+
"../../node_modules/.pnpm/@typescript-eslint+utils@8.66.0_eslint@10.7.0_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/parserSeemsToBeTSESLint.js"(exports) {
|
|
96
96
|
"use strict";
|
|
97
97
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
98
98
|
exports.parserSeemsToBeTSESLint = parserSeemsToBeTSESLint;
|
|
@@ -102,9 +102,9 @@ var require_parserSeemsToBeTSESLint = __commonJS({
|
|
|
102
102
|
}
|
|
103
103
|
});
|
|
104
104
|
|
|
105
|
-
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.
|
|
105
|
+
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.66.0_eslint@10.7.0_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/getParserServices.js
|
|
106
106
|
var require_getParserServices = __commonJS({
|
|
107
|
-
"../../node_modules/.pnpm/@typescript-eslint+utils@8.
|
|
107
|
+
"../../node_modules/.pnpm/@typescript-eslint+utils@8.66.0_eslint@10.7.0_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/getParserServices.js"(exports) {
|
|
108
108
|
"use strict";
|
|
109
109
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
110
110
|
exports.getParserServices = getParserServices;
|
|
@@ -135,17 +135,17 @@ var require_getParserServices = __commonJS({
|
|
|
135
135
|
}
|
|
136
136
|
});
|
|
137
137
|
|
|
138
|
-
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.
|
|
138
|
+
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.66.0_eslint@10.7.0_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/InferTypesFromRule.js
|
|
139
139
|
var require_InferTypesFromRule = __commonJS({
|
|
140
|
-
"../../node_modules/.pnpm/@typescript-eslint+utils@8.
|
|
140
|
+
"../../node_modules/.pnpm/@typescript-eslint+utils@8.66.0_eslint@10.7.0_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/InferTypesFromRule.js"(exports) {
|
|
141
141
|
"use strict";
|
|
142
142
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
143
143
|
}
|
|
144
144
|
});
|
|
145
145
|
|
|
146
|
-
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.
|
|
146
|
+
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.66.0_eslint@10.7.0_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/nullThrows.js
|
|
147
147
|
var require_nullThrows = __commonJS({
|
|
148
|
-
"../../node_modules/.pnpm/@typescript-eslint+utils@8.
|
|
148
|
+
"../../node_modules/.pnpm/@typescript-eslint+utils@8.66.0_eslint@10.7.0_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/nullThrows.js"(exports) {
|
|
149
149
|
"use strict";
|
|
150
150
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
151
151
|
exports.NullThrowsReasons = void 0;
|
|
@@ -163,9 +163,9 @@ var require_nullThrows = __commonJS({
|
|
|
163
163
|
}
|
|
164
164
|
});
|
|
165
165
|
|
|
166
|
-
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.
|
|
166
|
+
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.66.0_eslint@10.7.0_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/RuleCreator.js
|
|
167
167
|
var require_RuleCreator = __commonJS({
|
|
168
|
-
"../../node_modules/.pnpm/@typescript-eslint+utils@8.
|
|
168
|
+
"../../node_modules/.pnpm/@typescript-eslint+utils@8.66.0_eslint@10.7.0_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/RuleCreator.js"(exports) {
|
|
169
169
|
"use strict";
|
|
170
170
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
171
171
|
exports.RuleCreator = RuleCreator8;
|
|
@@ -211,9 +211,9 @@ var require_RuleCreator = __commonJS({
|
|
|
211
211
|
}
|
|
212
212
|
});
|
|
213
213
|
|
|
214
|
-
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.
|
|
214
|
+
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.66.0_eslint@10.7.0_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/index.js
|
|
215
215
|
var require_eslint_utils = __commonJS({
|
|
216
|
-
"../../node_modules/.pnpm/@typescript-eslint+utils@8.
|
|
216
|
+
"../../node_modules/.pnpm/@typescript-eslint+utils@8.66.0_eslint@10.7.0_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/index.js"(exports) {
|
|
217
217
|
"use strict";
|
|
218
218
|
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
219
219
|
if (k2 === void 0) k2 = k;
|
|
@@ -245,6 +245,10 @@ var require_eslint_utils = __commonJS({
|
|
|
245
245
|
var import_eslint_utils = __toESM(require_eslint_utils(), 1);
|
|
246
246
|
|
|
247
247
|
// ../../lib/primitive/src/utils/type-guards.ts
|
|
248
|
+
function isObject(value, excludeArrays = false) {
|
|
249
|
+
if (value === null || typeof value !== "object") return false;
|
|
250
|
+
return excludeArrays ? !Array.isArray(value) : true;
|
|
251
|
+
}
|
|
248
252
|
function isString(value) {
|
|
249
253
|
return typeof value === "string";
|
|
250
254
|
}
|
|
@@ -420,6 +424,9 @@ var iterate = Object.freeze({
|
|
|
420
424
|
});
|
|
421
425
|
|
|
422
426
|
// ../../plugins/eslint/src/utils/ast.ts
|
|
427
|
+
function hasStringValue(node) {
|
|
428
|
+
return isObject(node, true) && isString(node.value);
|
|
429
|
+
}
|
|
423
430
|
function asObjectExpression(node) {
|
|
424
431
|
return node?.type === "ObjectExpression" ? node : void 0;
|
|
425
432
|
}
|
|
@@ -442,23 +449,20 @@ function asNumericLiteral(node) {
|
|
|
442
449
|
return void 0;
|
|
443
450
|
}
|
|
444
451
|
function asStringLiteral(node) {
|
|
445
|
-
if (node?.type === "Literal" &&
|
|
452
|
+
if (node?.type === "Literal" && hasStringValue(node)) return node.value;
|
|
446
453
|
return void 0;
|
|
447
454
|
}
|
|
448
455
|
function getPropertyKey(prop) {
|
|
449
456
|
const { key } = prop;
|
|
450
457
|
if (prop.computed) return void 0;
|
|
451
458
|
if (key.type === "Identifier") return key.name;
|
|
452
|
-
if (key.type === "Literal" &&
|
|
459
|
+
if (key.type === "Literal" && hasStringValue(key)) return key.value;
|
|
453
460
|
return void 0;
|
|
454
461
|
}
|
|
455
462
|
function getObjectProperty(obj, key) {
|
|
456
463
|
return obj.properties.find((prop) => {
|
|
457
|
-
if (prop.type !== "Property" || prop.kind !== "init"
|
|
458
|
-
|
|
459
|
-
}
|
|
460
|
-
const { key: propKey } = prop;
|
|
461
|
-
return propKey.type === "Identifier" && propKey.name === key || propKey.type === "Literal" && propKey.value === key;
|
|
464
|
+
if (prop.type !== "Property" || prop.kind !== "init") return false;
|
|
465
|
+
return getPropertyKey(prop) === key;
|
|
462
466
|
});
|
|
463
467
|
}
|
|
464
468
|
function getFirstObjectArg(node) {
|
|
@@ -763,182 +767,218 @@ var noInvalidDefault = createRule3({
|
|
|
763
767
|
// ../../plugins/eslint/src/rules/no-invalid-html-nesting.ts
|
|
764
768
|
var import_eslint_utils4 = __toESM(require_eslint_utils(), 1);
|
|
765
769
|
|
|
770
|
+
// ../../plugins/eslint/src/utils/content-model-builders.ts
|
|
771
|
+
function categories(...values2) {
|
|
772
|
+
return new Set(values2);
|
|
773
|
+
}
|
|
774
|
+
function tags(...values2) {
|
|
775
|
+
return new Set(values2);
|
|
776
|
+
}
|
|
777
|
+
function category(...allowed) {
|
|
778
|
+
return { model: { kind: "category", allowed: categories(...allowed) } };
|
|
779
|
+
}
|
|
780
|
+
function specific(...allowed) {
|
|
781
|
+
return { model: { kind: "specific", allowed: tags(...allowed) } };
|
|
782
|
+
}
|
|
783
|
+
function phrasing() {
|
|
784
|
+
return category("phrasing");
|
|
785
|
+
}
|
|
786
|
+
function phrasingOrHeading() {
|
|
787
|
+
return category("phrasing", "heading");
|
|
788
|
+
}
|
|
789
|
+
function categoriesFor(categoryList, tagNames) {
|
|
790
|
+
return Object.fromEntries(tagNames.map((tagName) => [tagName, categories(...categoryList)]));
|
|
791
|
+
}
|
|
792
|
+
function defineContentModels(definitions) {
|
|
793
|
+
return definitions;
|
|
794
|
+
}
|
|
795
|
+
|
|
766
796
|
// ../../plugins/eslint/src/utils/html-nesting.ts
|
|
797
|
+
var FLOW_PHRASING_TAGS = [
|
|
798
|
+
"abbr",
|
|
799
|
+
"b",
|
|
800
|
+
"bdi",
|
|
801
|
+
"bdo",
|
|
802
|
+
"br",
|
|
803
|
+
"cite",
|
|
804
|
+
"code",
|
|
805
|
+
"data",
|
|
806
|
+
"dfn",
|
|
807
|
+
"em",
|
|
808
|
+
"i",
|
|
809
|
+
"kbd",
|
|
810
|
+
"mark",
|
|
811
|
+
"output",
|
|
812
|
+
"q",
|
|
813
|
+
"ruby",
|
|
814
|
+
"s",
|
|
815
|
+
"samp",
|
|
816
|
+
"small",
|
|
817
|
+
"span",
|
|
818
|
+
"strong",
|
|
819
|
+
"sub",
|
|
820
|
+
"sup",
|
|
821
|
+
"time",
|
|
822
|
+
"u",
|
|
823
|
+
"var",
|
|
824
|
+
"wbr"
|
|
825
|
+
];
|
|
826
|
+
var FLOW_PHRASING_EMBEDDED_TAGS = [
|
|
827
|
+
"audio",
|
|
828
|
+
"canvas",
|
|
829
|
+
"img",
|
|
830
|
+
"math",
|
|
831
|
+
"object",
|
|
832
|
+
"picture",
|
|
833
|
+
"svg",
|
|
834
|
+
"video"
|
|
835
|
+
];
|
|
836
|
+
var FLOW_PHRASING_INTERACTIVE_TAGS = ["button", "input", "label", "select", "textarea"];
|
|
837
|
+
var FLOW_PHRASING_EMBEDDED_INTERACTIVE_TAGS = ["embed", "iframe"];
|
|
838
|
+
var FLOW_PHRASING_METADATA_TAGS = ["meta", "noscript", "script", "template", "link"];
|
|
839
|
+
var FLOW_ONLY_TAGS = [
|
|
840
|
+
"address",
|
|
841
|
+
"blockquote",
|
|
842
|
+
"dialog",
|
|
843
|
+
"div",
|
|
844
|
+
"dl",
|
|
845
|
+
"fieldset",
|
|
846
|
+
"figure",
|
|
847
|
+
"footer",
|
|
848
|
+
"form",
|
|
849
|
+
"header",
|
|
850
|
+
"hr",
|
|
851
|
+
"li",
|
|
852
|
+
"main",
|
|
853
|
+
"menu",
|
|
854
|
+
"ol",
|
|
855
|
+
"p",
|
|
856
|
+
"pre",
|
|
857
|
+
"summary",
|
|
858
|
+
"table",
|
|
859
|
+
"ul"
|
|
860
|
+
];
|
|
861
|
+
var FLOW_SECTIONING_TAGS = ["article", "aside", "nav", "section"];
|
|
862
|
+
var FLOW_INTERACTIVE_TAGS = ["details"];
|
|
863
|
+
var FLOW_METADATA_TAGS = ["style"];
|
|
864
|
+
var FLOW_HEADING_TAGS = ["h1", "h2", "h3", "h4", "h5", "h6", "hgroup"];
|
|
865
|
+
var METADATA_ONLY_TAGS = ["base", "title"];
|
|
767
866
|
var TAG_CATEGORIES = {
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
embed: /* @__PURE__ */ new Set(["flow", "phrasing", "embedded", "interactive"]),
|
|
783
|
-
i: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
784
|
-
iframe: /* @__PURE__ */ new Set(["flow", "phrasing", "embedded", "interactive"]),
|
|
785
|
-
img: /* @__PURE__ */ new Set(["flow", "phrasing", "embedded"]),
|
|
786
|
-
input: /* @__PURE__ */ new Set(["flow", "phrasing", "interactive"]),
|
|
787
|
-
kbd: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
788
|
-
label: /* @__PURE__ */ new Set(["flow", "phrasing", "interactive"]),
|
|
789
|
-
mark: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
790
|
-
math: /* @__PURE__ */ new Set(["flow", "phrasing", "embedded"]),
|
|
791
|
-
meta: /* @__PURE__ */ new Set(["metadata", "flow", "phrasing"]),
|
|
792
|
-
noscript: /* @__PURE__ */ new Set(["metadata", "flow", "phrasing"]),
|
|
793
|
-
object: /* @__PURE__ */ new Set(["flow", "phrasing", "embedded"]),
|
|
794
|
-
output: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
795
|
-
picture: /* @__PURE__ */ new Set(["flow", "phrasing", "embedded"]),
|
|
796
|
-
q: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
797
|
-
ruby: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
798
|
-
s: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
799
|
-
samp: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
800
|
-
script: /* @__PURE__ */ new Set(["metadata", "flow", "phrasing"]),
|
|
801
|
-
select: /* @__PURE__ */ new Set(["flow", "phrasing", "interactive"]),
|
|
802
|
-
small: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
803
|
-
span: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
804
|
-
strong: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
805
|
-
sub: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
806
|
-
sup: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
807
|
-
svg: /* @__PURE__ */ new Set(["flow", "phrasing", "embedded"]),
|
|
808
|
-
template: /* @__PURE__ */ new Set(["metadata", "flow", "phrasing"]),
|
|
809
|
-
textarea: /* @__PURE__ */ new Set(["flow", "phrasing", "interactive"]),
|
|
810
|
-
time: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
811
|
-
u: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
812
|
-
var: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
813
|
-
video: /* @__PURE__ */ new Set(["flow", "phrasing", "embedded"]),
|
|
814
|
-
wbr: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
815
|
-
// Flow only (block-level)
|
|
816
|
-
address: /* @__PURE__ */ new Set(["flow"]),
|
|
817
|
-
article: /* @__PURE__ */ new Set(["flow", "sectioning"]),
|
|
818
|
-
aside: /* @__PURE__ */ new Set(["flow", "sectioning"]),
|
|
819
|
-
blockquote: /* @__PURE__ */ new Set(["flow"]),
|
|
820
|
-
details: /* @__PURE__ */ new Set(["flow", "interactive"]),
|
|
821
|
-
dialog: /* @__PURE__ */ new Set(["flow"]),
|
|
822
|
-
div: /* @__PURE__ */ new Set(["flow"]),
|
|
823
|
-
dl: /* @__PURE__ */ new Set(["flow"]),
|
|
824
|
-
fieldset: /* @__PURE__ */ new Set(["flow"]),
|
|
825
|
-
figure: /* @__PURE__ */ new Set(["flow"]),
|
|
826
|
-
footer: /* @__PURE__ */ new Set(["flow"]),
|
|
827
|
-
form: /* @__PURE__ */ new Set(["flow"]),
|
|
828
|
-
header: /* @__PURE__ */ new Set(["flow"]),
|
|
829
|
-
hr: /* @__PURE__ */ new Set(["flow"]),
|
|
830
|
-
li: /* @__PURE__ */ new Set(["flow"]),
|
|
831
|
-
link: /* @__PURE__ */ new Set(["metadata", "flow", "phrasing"]),
|
|
832
|
-
main: /* @__PURE__ */ new Set(["flow"]),
|
|
833
|
-
menu: /* @__PURE__ */ new Set(["flow"]),
|
|
834
|
-
nav: /* @__PURE__ */ new Set(["flow", "sectioning"]),
|
|
835
|
-
ol: /* @__PURE__ */ new Set(["flow"]),
|
|
836
|
-
p: /* @__PURE__ */ new Set(["flow"]),
|
|
837
|
-
pre: /* @__PURE__ */ new Set(["flow"]),
|
|
838
|
-
section: /* @__PURE__ */ new Set(["flow", "sectioning"]),
|
|
839
|
-
style: /* @__PURE__ */ new Set(["metadata", "flow"]),
|
|
840
|
-
summary: /* @__PURE__ */ new Set(["flow"]),
|
|
841
|
-
table: /* @__PURE__ */ new Set(["flow"]),
|
|
842
|
-
ul: /* @__PURE__ */ new Set(["flow"]),
|
|
843
|
-
// Heading
|
|
844
|
-
h1: /* @__PURE__ */ new Set(["flow", "heading"]),
|
|
845
|
-
h2: /* @__PURE__ */ new Set(["flow", "heading"]),
|
|
846
|
-
h3: /* @__PURE__ */ new Set(["flow", "heading"]),
|
|
847
|
-
h4: /* @__PURE__ */ new Set(["flow", "heading"]),
|
|
848
|
-
h5: /* @__PURE__ */ new Set(["flow", "heading"]),
|
|
849
|
-
h6: /* @__PURE__ */ new Set(["flow", "heading"]),
|
|
850
|
-
hgroup: /* @__PURE__ */ new Set(["flow", "heading"]),
|
|
851
|
-
// Metadata only
|
|
852
|
-
base: /* @__PURE__ */ new Set(["metadata"]),
|
|
853
|
-
title: /* @__PURE__ */ new Set(["metadata"])
|
|
867
|
+
...categoriesFor(["flow", "phrasing"], FLOW_PHRASING_TAGS),
|
|
868
|
+
...categoriesFor(["flow", "phrasing", "embedded"], FLOW_PHRASING_EMBEDDED_TAGS),
|
|
869
|
+
...categoriesFor(["flow", "phrasing", "interactive"], FLOW_PHRASING_INTERACTIVE_TAGS),
|
|
870
|
+
...categoriesFor(
|
|
871
|
+
["flow", "phrasing", "embedded", "interactive"],
|
|
872
|
+
FLOW_PHRASING_EMBEDDED_INTERACTIVE_TAGS
|
|
873
|
+
),
|
|
874
|
+
...categoriesFor(["metadata", "flow", "phrasing"], FLOW_PHRASING_METADATA_TAGS),
|
|
875
|
+
...categoriesFor(["flow"], FLOW_ONLY_TAGS),
|
|
876
|
+
...categoriesFor(["flow", "sectioning"], FLOW_SECTIONING_TAGS),
|
|
877
|
+
...categoriesFor(["flow", "interactive"], FLOW_INTERACTIVE_TAGS),
|
|
878
|
+
...categoriesFor(["flow", "metadata"], FLOW_METADATA_TAGS),
|
|
879
|
+
...categoriesFor(["flow", "heading"], FLOW_HEADING_TAGS),
|
|
880
|
+
...categoriesFor(["metadata"], METADATA_ONLY_TAGS)
|
|
854
881
|
};
|
|
855
|
-
var HTML_CONTENT_MODELS = {
|
|
882
|
+
var HTML_CONTENT_MODELS = defineContentModels({
|
|
856
883
|
// Specific-tag constraints (structural elements whose content is enumerated, not categorical)
|
|
857
|
-
colgroup:
|
|
858
|
-
dl:
|
|
859
|
-
menu:
|
|
860
|
-
ol:
|
|
861
|
-
optgroup:
|
|
862
|
-
picture:
|
|
863
|
-
select:
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
"caption",
|
|
871
|
-
"colgroup",
|
|
872
|
-
"thead",
|
|
873
|
-
"tbody",
|
|
874
|
-
"tfoot",
|
|
875
|
-
"tr",
|
|
876
|
-
"script",
|
|
877
|
-
"template"
|
|
878
|
-
])
|
|
879
|
-
},
|
|
880
|
-
tbody: { kind: "specific", allowed: /* @__PURE__ */ new Set(["tr", "script", "template"]) },
|
|
881
|
-
tfoot: { kind: "specific", allowed: /* @__PURE__ */ new Set(["tr", "script", "template"]) },
|
|
882
|
-
thead: { kind: "specific", allowed: /* @__PURE__ */ new Set(["tr", "script", "template"]) },
|
|
883
|
-
tr: { kind: "specific", allowed: /* @__PURE__ */ new Set(["td", "th", "script", "template"]) },
|
|
884
|
-
ul: { kind: "specific", allowed: /* @__PURE__ */ new Set(["li", "script", "template"]) },
|
|
884
|
+
colgroup: specific("col", "template"),
|
|
885
|
+
dl: specific("dt", "dd", "div", "script", "template"),
|
|
886
|
+
menu: specific("li", "script", "template"),
|
|
887
|
+
ol: specific("li", "script", "template"),
|
|
888
|
+
optgroup: specific("option", "script", "template"),
|
|
889
|
+
picture: specific("source", "img", "script", "template"),
|
|
890
|
+
select: specific("option", "optgroup", "hr", "script", "template"),
|
|
891
|
+
table: specific("caption", "colgroup", "thead", "tbody", "tfoot", "tr", "script", "template"),
|
|
892
|
+
tbody: specific("tr", "script", "template"),
|
|
893
|
+
tfoot: specific("tr", "script", "template"),
|
|
894
|
+
thead: specific("tr", "script", "template"),
|
|
895
|
+
tr: specific("td", "th", "script", "template"),
|
|
896
|
+
ul: specific("li", "script", "template"),
|
|
885
897
|
// Phrasing-content parents (any element whose content model is phrasing content)
|
|
886
|
-
abbr:
|
|
887
|
-
b:
|
|
888
|
-
bdi:
|
|
889
|
-
bdo:
|
|
890
|
-
cite:
|
|
891
|
-
code:
|
|
892
|
-
data:
|
|
893
|
-
dfn:
|
|
894
|
-
dt:
|
|
895
|
-
em:
|
|
896
|
-
h1:
|
|
897
|
-
h2:
|
|
898
|
-
h3:
|
|
899
|
-
h4:
|
|
900
|
-
h5:
|
|
901
|
-
h6:
|
|
902
|
-
i:
|
|
903
|
-
kbd:
|
|
904
|
-
label:
|
|
905
|
-
mark:
|
|
906
|
-
output:
|
|
907
|
-
p:
|
|
908
|
-
q:
|
|
909
|
-
ruby:
|
|
910
|
-
s:
|
|
911
|
-
samp:
|
|
912
|
-
small:
|
|
913
|
-
span:
|
|
914
|
-
strong:
|
|
915
|
-
sub:
|
|
916
|
-
sup:
|
|
917
|
-
time:
|
|
918
|
-
u:
|
|
919
|
-
var:
|
|
898
|
+
abbr: phrasing(),
|
|
899
|
+
b: phrasing(),
|
|
900
|
+
bdi: phrasing(),
|
|
901
|
+
bdo: phrasing(),
|
|
902
|
+
cite: phrasing(),
|
|
903
|
+
code: phrasing(),
|
|
904
|
+
data: phrasing(),
|
|
905
|
+
dfn: phrasing(),
|
|
906
|
+
dt: phrasing(),
|
|
907
|
+
em: phrasing(),
|
|
908
|
+
h1: phrasing(),
|
|
909
|
+
h2: phrasing(),
|
|
910
|
+
h3: phrasing(),
|
|
911
|
+
h4: phrasing(),
|
|
912
|
+
h5: phrasing(),
|
|
913
|
+
h6: phrasing(),
|
|
914
|
+
i: phrasing(),
|
|
915
|
+
kbd: phrasing(),
|
|
916
|
+
label: phrasing(),
|
|
917
|
+
mark: phrasing(),
|
|
918
|
+
output: phrasing(),
|
|
919
|
+
p: phrasing(),
|
|
920
|
+
q: phrasing(),
|
|
921
|
+
ruby: phrasing(),
|
|
922
|
+
s: phrasing(),
|
|
923
|
+
samp: phrasing(),
|
|
924
|
+
small: phrasing(),
|
|
925
|
+
span: phrasing(),
|
|
926
|
+
strong: phrasing(),
|
|
927
|
+
sub: phrasing(),
|
|
928
|
+
sup: phrasing(),
|
|
929
|
+
time: phrasing(),
|
|
930
|
+
u: phrasing(),
|
|
931
|
+
var: phrasing(),
|
|
920
932
|
// Phrasing or heading (spec allows either as first child)
|
|
921
|
-
legend:
|
|
922
|
-
summary:
|
|
923
|
-
};
|
|
933
|
+
legend: phrasingOrHeading(),
|
|
934
|
+
summary: phrasingOrHeading()
|
|
935
|
+
});
|
|
936
|
+
function getTagCategorySet(tagCategories, tagName) {
|
|
937
|
+
return tagCategories[tagName];
|
|
938
|
+
}
|
|
939
|
+
function getContentModelDefinition(contentModels, tagName) {
|
|
940
|
+
return contentModels[tagName];
|
|
941
|
+
}
|
|
924
942
|
|
|
925
943
|
// ../../plugins/eslint/src/rules/no-invalid-html-nesting.ts
|
|
926
944
|
var createRule4 = (0, import_eslint_utils4.RuleCreator)((name) => `https://praxis-kit.dev/eslint-rules/${name}`);
|
|
945
|
+
function describeAllowed(definition) {
|
|
946
|
+
const { model } = definition;
|
|
947
|
+
switch (model.kind) {
|
|
948
|
+
case "specific":
|
|
949
|
+
return [...model.allowed].join(", ");
|
|
950
|
+
case "category":
|
|
951
|
+
return [...model.allowed].map((c) => `${c} content`).join(", ");
|
|
952
|
+
// `transparent`/`nothing`/`structured` aren't evaluated yet (see `isAllowed` below) — no
|
|
953
|
+
// entry in HTML_CONTENT_MODELS currently uses them, so this stays unreachable in practice.
|
|
954
|
+
case "transparent":
|
|
955
|
+
case "nothing":
|
|
956
|
+
case "structured":
|
|
957
|
+
return "";
|
|
958
|
+
}
|
|
959
|
+
}
|
|
927
960
|
var ALLOWED_TEXT = Object.fromEntries(
|
|
928
|
-
Object.entries(HTML_CONTENT_MODELS).map(([tag,
|
|
929
|
-
tag,
|
|
930
|
-
model.kind === "specific" ? [...model.allowed].join(", ") : [...model.allowed].map((c) => `${c} content`).join(", ")
|
|
931
|
-
])
|
|
961
|
+
Object.entries(HTML_CONTENT_MODELS).filter((entry) => entry[1] !== void 0).map(([tag, definition]) => [tag, describeAllowed(definition)])
|
|
932
962
|
);
|
|
933
963
|
function getIntrinsicTag(name) {
|
|
934
964
|
if (name.type !== "JSXIdentifier") return void 0;
|
|
935
965
|
return /^[a-z]/.test(name.name) ? name.name : void 0;
|
|
936
966
|
}
|
|
937
|
-
function isAllowed(childTag,
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
967
|
+
function isAllowed(childTag, definition) {
|
|
968
|
+
const { model } = definition;
|
|
969
|
+
switch (model.kind) {
|
|
970
|
+
case "specific":
|
|
971
|
+
return model.allowed.has(childTag);
|
|
972
|
+
case "category": {
|
|
973
|
+
const cats = getTagCategorySet(TAG_CATEGORIES, childTag);
|
|
974
|
+
if (!cats) return true;
|
|
975
|
+
return [...model.allowed].some((c) => cats.has(c));
|
|
976
|
+
}
|
|
977
|
+
case "transparent":
|
|
978
|
+
case "nothing":
|
|
979
|
+
case "structured":
|
|
980
|
+
return true;
|
|
981
|
+
}
|
|
942
982
|
}
|
|
943
983
|
var noInvalidHtmlNesting = createRule4({
|
|
944
984
|
name: "no-invalid-html-nesting",
|
|
@@ -958,13 +998,13 @@ var noInvalidHtmlNesting = createRule4({
|
|
|
958
998
|
JSXElement(node) {
|
|
959
999
|
const parentTag = getIntrinsicTag(node.openingElement.name);
|
|
960
1000
|
if (!parentTag) return;
|
|
961
|
-
const
|
|
962
|
-
if (!
|
|
1001
|
+
const definition = getContentModelDefinition(HTML_CONTENT_MODELS, parentTag);
|
|
1002
|
+
if (!definition) return;
|
|
963
1003
|
iterate.forEach(node.children, (child) => {
|
|
964
1004
|
if (child.type !== "JSXElement") return;
|
|
965
1005
|
const childTag = getIntrinsicTag(child.openingElement.name);
|
|
966
1006
|
if (childTag === void 0) return;
|
|
967
|
-
if (isAllowed(childTag,
|
|
1007
|
+
if (isAllowed(childTag, definition)) return;
|
|
968
1008
|
context.report({
|
|
969
1009
|
node: child,
|
|
970
1010
|
messageId: "invalidChild",
|
package/dist/html/index.d.ts
CHANGED
|
@@ -84,6 +84,11 @@ declare const HTML_ARIA_RULES: readonly AriaRule[];
|
|
|
84
84
|
|
|
85
85
|
declare const roleNotPermittedRule: AriaRule;
|
|
86
86
|
|
|
87
|
+
declare const dangerousHrefRule: AriaRule;
|
|
88
|
+
declare const roleButtonWithHrefRule: AriaRule;
|
|
89
|
+
declare const ariaDisabledInertRule: AriaRule;
|
|
90
|
+
declare const ANCHOR_RULES: readonly AriaRule[];
|
|
91
|
+
|
|
87
92
|
declare const supportedInputTypeRule: AriaRule;
|
|
88
93
|
declare const checkedRequiresCheckableTypeRule: AriaRule;
|
|
89
94
|
declare const multipleRequiresSupportedTypeRule: AriaRule;
|
|
@@ -104,4 +109,4 @@ declare const passwordAutocompleteRule: AriaRule;
|
|
|
104
109
|
declare const requiredReadOnlyConflictRule: AriaRule;
|
|
105
110
|
declare const INPUT_RULES: readonly AriaRule[];
|
|
106
111
|
|
|
107
|
-
export { HTML_ARIA_RULES, INPUT_RULES, acceptRequiresFileTypeRule, altRequiresImageTypeRule, captureRequiresFileTypeRule, checkedRequiresCheckableTypeRule, heightRequiresImageTypeRule, inputAccessibleNameRule, landmarkAccessibleNameRule, landmarkRoleRule, maxLengthRequiresTextTypeRule, maxRequiresNumericTypeRule, minLengthRequiresTextTypeRule, minRequiresNumericTypeRule, multipleRequiresSupportedTypeRule, passwordAutocompleteRule, patternRequiresTextTypeRule, requireAccessibleName, requiredReadOnlyConflictRule, roleNotPermittedRule, sizeRequiresTextTypeRule, stepRequiresNumericTypeRule, supportedInputTypeRule, widthRequiresImageTypeRule };
|
|
112
|
+
export { ANCHOR_RULES, HTML_ARIA_RULES, INPUT_RULES, acceptRequiresFileTypeRule, altRequiresImageTypeRule, ariaDisabledInertRule, captureRequiresFileTypeRule, checkedRequiresCheckableTypeRule, dangerousHrefRule, heightRequiresImageTypeRule, inputAccessibleNameRule, landmarkAccessibleNameRule, landmarkRoleRule, maxLengthRequiresTextTypeRule, maxRequiresNumericTypeRule, minLengthRequiresTextTypeRule, minRequiresNumericTypeRule, multipleRequiresSupportedTypeRule, passwordAutocompleteRule, patternRequiresTextTypeRule, requireAccessibleName, requiredReadOnlyConflictRule, roleButtonWithHrefRule, roleNotPermittedRule, sizeRequiresTextTypeRule, stepRequiresNumericTypeRule, supportedInputTypeRule, widthRequiresImageTypeRule };
|