praxis-kit 6.6.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_shared/diagnostics.d.ts +1 -0
- package/dist/_shared/diagnostics.js +1 -0
- package/dist/{chunk-OCG5VM4H.js → chunk-35CJAOJW.js} +267 -155
- package/dist/contract/index.d.ts +56 -3
- package/dist/contract/index.js +75 -0
- package/dist/eslint/index.js +16 -16
- package/dist/guards/index.d.ts +21 -1
- package/dist/guards/index.js +29 -1
- package/dist/html/index.d.ts +7 -4
- package/dist/html/index.js +48 -27
- package/dist/lit/index.d.ts +5 -2
- package/dist/lit/index.js +264 -155
- package/dist/preact/index.d.ts +5 -2
- package/dist/preact/index.js +267 -155
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +1 -1
- package/dist/react/legacy.d.ts +2 -2
- package/dist/react/legacy.js +1 -1
- package/dist/{react-options-BUBVohU6.d.ts → react-options-Cm99IE5J.d.ts} +5 -2
- package/dist/solid/index.d.ts +5 -2
- package/dist/solid/index.js +267 -155
- package/dist/svelte/Polymorphic.svelte +3 -1
- package/dist/svelte/index.d.ts +12 -9
- package/dist/svelte/index.js +263 -154
- package/dist/tailwind/index.js +31 -0
- package/dist/vite-plugin/index.d.ts +1 -0
- package/dist/vue/index.d.ts +5 -2
- package/dist/vue/index.js +264 -155
- package/dist/web/index.d.ts +5 -2
- package/dist/web/index.js +264 -155
- package/package.json +7 -7
package/dist/contract/index.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
// ../../lib/primitive/src/guards/foundational/is-defined.ts
|
|
2
|
+
function isDefined(value) {
|
|
3
|
+
return value !== void 0;
|
|
4
|
+
}
|
|
5
|
+
|
|
1
6
|
// ../../lib/primitive/src/utils/iterate.ts
|
|
2
7
|
function find(iterable, callback) {
|
|
3
8
|
for (const value of iterable) {
|
|
@@ -168,6 +173,72 @@ var iterate = Object.freeze({
|
|
|
168
173
|
values
|
|
169
174
|
});
|
|
170
175
|
|
|
176
|
+
// ../../lib/contract/src/aria/factories.ts
|
|
177
|
+
function invalidWithoutFix(input) {
|
|
178
|
+
return {
|
|
179
|
+
valid: false,
|
|
180
|
+
fixable: false,
|
|
181
|
+
severity: input.severity,
|
|
182
|
+
...isDefined(input.attribute) && { attribute: input.attribute },
|
|
183
|
+
...isDefined(input.message) && { message: input.message },
|
|
184
|
+
...isDefined(input.diagnostic) && { diagnostic: input.diagnostic }
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
function invalidWithFix(input) {
|
|
188
|
+
return {
|
|
189
|
+
valid: false,
|
|
190
|
+
fixable: true,
|
|
191
|
+
severity: input.severity,
|
|
192
|
+
...isDefined(input.attribute) && { attribute: input.attribute },
|
|
193
|
+
...isDefined(input.message) && { message: input.message },
|
|
194
|
+
...isDefined(input.diagnostic) && { diagnostic: input.diagnostic },
|
|
195
|
+
fix: input.fix
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
function removeProp(props, key) {
|
|
199
|
+
const next = { ...props };
|
|
200
|
+
delete next[key];
|
|
201
|
+
return next;
|
|
202
|
+
}
|
|
203
|
+
function removeAttributeFix(attribute) {
|
|
204
|
+
return Object.freeze({
|
|
205
|
+
kind: "removeAttribute",
|
|
206
|
+
attribute,
|
|
207
|
+
apply: ({ props }) => {
|
|
208
|
+
if (!(attribute in props)) return { applied: false, next: props };
|
|
209
|
+
return { applied: true, next: removeProp(props, attribute), previous: props };
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
function defineRuleMetadata(rule, metadata) {
|
|
214
|
+
const descriptors = {};
|
|
215
|
+
for (const key of Object.keys(metadata)) {
|
|
216
|
+
descriptors[key] = { value: metadata[key], enumerable: false };
|
|
217
|
+
}
|
|
218
|
+
Object.defineProperties(rule, descriptors);
|
|
219
|
+
return rule;
|
|
220
|
+
}
|
|
221
|
+
function createRemoveAttributeRule(attribute, options) {
|
|
222
|
+
const { when, severity = "warning", message, diagnostic, readsProps, tags } = options;
|
|
223
|
+
const fix = removeAttributeFix(attribute);
|
|
224
|
+
const rule = (context) => {
|
|
225
|
+
if (!when(context)) return [];
|
|
226
|
+
return [
|
|
227
|
+
invalidWithFix({
|
|
228
|
+
severity,
|
|
229
|
+
attribute,
|
|
230
|
+
...isDefined(message) && { message },
|
|
231
|
+
...isDefined(diagnostic) && { diagnostic: diagnostic(context) },
|
|
232
|
+
fix
|
|
233
|
+
})
|
|
234
|
+
];
|
|
235
|
+
};
|
|
236
|
+
return defineRuleMetadata(rule, {
|
|
237
|
+
...isDefined(readsProps) && { readsProps },
|
|
238
|
+
...isDefined(tags) && { tags }
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
|
|
171
242
|
// ../../lib/contract/src/props/get-active-props.ts
|
|
172
243
|
var activeProps = ({
|
|
173
244
|
active,
|
|
@@ -333,12 +404,15 @@ function mergeContracts(...contracts) {
|
|
|
333
404
|
export {
|
|
334
405
|
activeContract,
|
|
335
406
|
activeProps,
|
|
407
|
+
createRemoveAttributeRule,
|
|
336
408
|
disabledContract,
|
|
337
409
|
disabledProps,
|
|
338
410
|
expandedContract,
|
|
339
411
|
expandedProps,
|
|
340
412
|
invalidContract,
|
|
341
413
|
invalidProps,
|
|
414
|
+
invalidWithFix,
|
|
415
|
+
invalidWithoutFix,
|
|
342
416
|
loadingContract,
|
|
343
417
|
loadingProps,
|
|
344
418
|
mergeContracts,
|
|
@@ -346,6 +420,7 @@ export {
|
|
|
346
420
|
pressedProps,
|
|
347
421
|
readonlyContract,
|
|
348
422
|
readonlyProps,
|
|
423
|
+
removeAttributeFix,
|
|
349
424
|
selectedContract,
|
|
350
425
|
selectedProps
|
|
351
426
|
};
|
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.65.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.65.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.65.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.65.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.65.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.65.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.65.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.65.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.65.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.65.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.65.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.65.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.65.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.65.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.65.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.65.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;
|
package/dist/guards/index.d.ts
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
type StringMap<T = unknown> = Record<string, T>;
|
|
2
2
|
type AnyRecord = StringMap<unknown>;
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Well-known Symbol stamped onto every component created by praxis-kit factories.
|
|
6
|
+
* Stores the factory's defaultTag — the tag that renders when no `as` prop is given.
|
|
7
|
+
* HOC wrappers must propagate it: `Wrapped[COMPONENT_DEFAULT_TAG] = Original[COMPONENT_DEFAULT_TAG]`.
|
|
8
|
+
*/
|
|
9
|
+
declare const COMPONENT_DEFAULT_TAG: unique symbol;
|
|
10
|
+
/**
|
|
11
|
+
* Stamps `COMPONENT_DEFAULT_TAG` onto a component function/object, so `isTag()`
|
|
12
|
+
* (and every built-in/custom `enforcement.children` rule built on it) resolves it
|
|
13
|
+
* to `tag` — the same recognition a component created via `createContractComponent`
|
|
14
|
+
* gets automatically. A transparent wrapper around a praxis-kit component (added
|
|
15
|
+
* purely to narrow prop types, for example) is a *different* function object with
|
|
16
|
+
* no `COMPONENT_DEFAULT_TAG` of its own, so without this it silently stops being
|
|
17
|
+
* recognized as a valid child by every parent contract. Returns `component` for
|
|
18
|
+
* call-site chaining, e.g. `export const Wrapped = markComponentTag(WrapperFn, 'source')`.
|
|
19
|
+
*/
|
|
20
|
+
declare function markComponentTag<T extends object>(component: T, tag: string): T;
|
|
21
|
+
/** Reads `COMPONENT_DEFAULT_TAG` off a component function/object, if present. */
|
|
22
|
+
declare function getComponentDefaultTag(component: unknown): string | undefined;
|
|
23
|
+
|
|
4
24
|
/**
|
|
5
25
|
* Resolves the effective HTML tag for a vnode:
|
|
6
26
|
* - native element: returns its type string directly
|
|
@@ -42,4 +62,4 @@ declare function isObject(value: unknown, excludeArrays: true): value is AnyReco
|
|
|
42
62
|
declare function isObject(value: unknown, excludeArrays?: false): value is object;
|
|
43
63
|
declare function isString(value: unknown): value is string;
|
|
44
64
|
|
|
45
|
-
export { type FlowContentChild, type TagChild, getTag, isFlowContent, isObject, isString, isTag };
|
|
65
|
+
export { COMPONENT_DEFAULT_TAG, type FlowContentChild, type TagChild, getComponentDefaultTag, getTag, isFlowContent, isObject, isString, isTag, markComponentTag };
|
package/dist/guards/index.js
CHANGED
|
@@ -9,9 +9,34 @@ function isString(value) {
|
|
|
9
9
|
function isNumber(value) {
|
|
10
10
|
return typeof value === "number";
|
|
11
11
|
}
|
|
12
|
+
function isFunction(value) {
|
|
13
|
+
return typeof value === "function";
|
|
14
|
+
}
|
|
12
15
|
|
|
13
16
|
// ../../lib/primitive/src/guards/children/component-id.ts
|
|
14
17
|
var COMPONENT_DEFAULT_TAG = /* @__PURE__ */ Symbol.for("praxis.component-default-tag");
|
|
18
|
+
function isMarkable(value) {
|
|
19
|
+
return isFunction(value) || isObject(value);
|
|
20
|
+
}
|
|
21
|
+
function defineComponentMetadata(component, metadata) {
|
|
22
|
+
for (const key of Object.getOwnPropertySymbols(metadata)) {
|
|
23
|
+
Object.defineProperty(component, key, {
|
|
24
|
+
value: metadata[key],
|
|
25
|
+
writable: false,
|
|
26
|
+
configurable: true,
|
|
27
|
+
enumerable: false
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return component;
|
|
31
|
+
}
|
|
32
|
+
function markComponentTag(component, tag) {
|
|
33
|
+
return defineComponentMetadata(component, { [COMPONENT_DEFAULT_TAG]: tag });
|
|
34
|
+
}
|
|
35
|
+
function getComponentDefaultTag(component) {
|
|
36
|
+
if (!isMarkable(component)) return void 0;
|
|
37
|
+
const tag = component[COMPONENT_DEFAULT_TAG];
|
|
38
|
+
return typeof tag === "string" ? tag : void 0;
|
|
39
|
+
}
|
|
15
40
|
|
|
16
41
|
// ../../lib/primitive/src/guards/children/is-tag.ts
|
|
17
42
|
function getAsProp(child) {
|
|
@@ -54,9 +79,12 @@ function isFlowContent(...blockedTags) {
|
|
|
54
79
|
};
|
|
55
80
|
}
|
|
56
81
|
export {
|
|
82
|
+
COMPONENT_DEFAULT_TAG,
|
|
83
|
+
getComponentDefaultTag,
|
|
57
84
|
getTag,
|
|
58
85
|
isFlowContent,
|
|
59
86
|
isObject,
|
|
60
87
|
isString,
|
|
61
|
-
isTag
|
|
88
|
+
isTag,
|
|
89
|
+
markComponentTag
|
|
62
90
|
};
|
package/dist/html/index.d.ts
CHANGED
|
@@ -25,8 +25,8 @@ type AriaContext = {
|
|
|
25
25
|
readonly props: ReadonlyDeep<IntrinsicProps>;
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
type RemoveAttributeFixKind =
|
|
29
|
-
type InjectLiveFixKind =
|
|
28
|
+
type RemoveAttributeFixKind = 'removeAttribute';
|
|
29
|
+
type InjectLiveFixKind = 'injectLive';
|
|
30
30
|
type FixKind = 'removeRole' | 'setRole' | 'normalizeRelevantAll' | RemoveAttributeFixKind | InjectLiveFixKind;
|
|
31
31
|
|
|
32
32
|
type AriaFixResult = {
|
|
@@ -39,6 +39,9 @@ type AriaFixResult = {
|
|
|
39
39
|
};
|
|
40
40
|
type AriaFix = {
|
|
41
41
|
readonly kind: FixKind;
|
|
42
|
+
/** The attribute a `'removeAttribute'`/`'injectLive'` fix targets — always set for those
|
|
43
|
+
* kinds, absent for kinds with no single-attribute target (`'removeRole'`, etc.). */
|
|
44
|
+
readonly attribute?: string;
|
|
42
45
|
readonly priority?: number;
|
|
43
46
|
readonly source?: string;
|
|
44
47
|
readonly apply: (context: AriaContext) => AriaFixResult;
|
|
@@ -70,7 +73,7 @@ type AriaRule<C extends AriaContext = AriaContext> = ((context: C) => readonly A
|
|
|
70
73
|
|
|
71
74
|
declare const landmarkRoleRule: AriaRule;
|
|
72
75
|
declare function requireAccessibleName({ tag, props }: AriaContext): readonly AriaResult[];
|
|
73
|
-
declare const
|
|
76
|
+
declare const landmarkAccessibleNameRule: AriaRule;
|
|
74
77
|
declare const HTML_ARIA_RULES: readonly AriaRule[];
|
|
75
78
|
|
|
76
79
|
declare const roleNotPermittedRule: AriaRule;
|
|
@@ -95,4 +98,4 @@ declare const passwordAutocompleteRule: AriaRule;
|
|
|
95
98
|
declare const requiredReadOnlyConflictRule: AriaRule;
|
|
96
99
|
declare const INPUT_RULES: readonly AriaRule[];
|
|
97
100
|
|
|
98
|
-
export { HTML_ARIA_RULES, INPUT_RULES, acceptRequiresFileTypeRule, altRequiresImageTypeRule, captureRequiresFileTypeRule, checkedRequiresCheckableTypeRule, heightRequiresImageTypeRule, inputAccessibleNameRule,
|
|
101
|
+
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 };
|
package/dist/html/index.js
CHANGED
|
@@ -360,6 +360,33 @@ var InputAccessibilityDiagnostics = {
|
|
|
360
360
|
}
|
|
361
361
|
};
|
|
362
362
|
|
|
363
|
+
// ../../lib/contract/src/aria/factories.ts
|
|
364
|
+
function removeProp(props, key) {
|
|
365
|
+
const next = { ...props };
|
|
366
|
+
delete next[key];
|
|
367
|
+
return next;
|
|
368
|
+
}
|
|
369
|
+
function removeAttributeFix(attribute) {
|
|
370
|
+
return Object.freeze({
|
|
371
|
+
kind: "removeAttribute",
|
|
372
|
+
attribute,
|
|
373
|
+
apply: ({ props }) => {
|
|
374
|
+
if (!(attribute in props)) return { applied: false, next: props };
|
|
375
|
+
return { applied: true, next: removeProp(props, attribute), previous: props };
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
// ../core/src/html/contracts/categories.ts
|
|
381
|
+
var LANDMARK_TAGS = [
|
|
382
|
+
"article",
|
|
383
|
+
"aside",
|
|
384
|
+
"footer",
|
|
385
|
+
"header",
|
|
386
|
+
"main",
|
|
387
|
+
"nav"
|
|
388
|
+
];
|
|
389
|
+
|
|
363
390
|
// ../core/src/html/spec/vocabulary/input.ts
|
|
364
391
|
var TEXT_INPUT_TYPES = ["text", "search", "url", "tel", "email", "password"];
|
|
365
392
|
var NUMERIC_INPUT_TYPES = [
|
|
@@ -414,20 +441,6 @@ var INPUT_MUTUALLY_EXCLUSIVE_POLICIES = [
|
|
|
414
441
|
|
|
415
442
|
// ../core/src/html/spec/validators/attribute-type-validator.ts
|
|
416
443
|
var DEFAULT_INPUT_TYPE = "text";
|
|
417
|
-
function omit(props, key) {
|
|
418
|
-
const next = { ...props };
|
|
419
|
-
delete next[key];
|
|
420
|
-
return next;
|
|
421
|
-
}
|
|
422
|
-
function removeAttributeFix(attribute) {
|
|
423
|
-
return {
|
|
424
|
-
kind: `removeAttribute:${attribute}`,
|
|
425
|
-
apply: ({ props }) => {
|
|
426
|
-
if (!(attribute in props)) return { applied: false, next: props };
|
|
427
|
-
return { applied: true, next: omit(props, attribute), previous: props };
|
|
428
|
-
}
|
|
429
|
-
};
|
|
430
|
-
}
|
|
431
444
|
function createInputAttributeTypeRule({
|
|
432
445
|
attribute,
|
|
433
446
|
allowedTypes
|
|
@@ -739,7 +752,11 @@ var ALLOWED_ROLES = {
|
|
|
739
752
|
"treeitem"
|
|
740
753
|
],
|
|
741
754
|
dialog: ["alertdialog"],
|
|
742
|
-
fieldset: ["none", "presentation", "radiogroup"]
|
|
755
|
+
fieldset: ["none", "presentation", "radiogroup"],
|
|
756
|
+
// `<label>` has no implicit role and no documented alternates — its native labeling
|
|
757
|
+
// semantics (control association, accessible-name contribution) aren't reproducible via
|
|
758
|
+
// ARIA, so any explicit `role` should be avoided rather than substituted.
|
|
759
|
+
label: []
|
|
743
760
|
};
|
|
744
761
|
var ELEMENT_SPECS = {
|
|
745
762
|
input: inputElementSpec,
|
|
@@ -780,7 +797,10 @@ var roleNotPermittedRule = Object.assign(
|
|
|
780
797
|
);
|
|
781
798
|
|
|
782
799
|
// ../core/src/html/aria-rules.ts
|
|
783
|
-
|
|
800
|
+
function defineAriaRule(tags, rule) {
|
|
801
|
+
return Object.assign(rule, { tags });
|
|
802
|
+
}
|
|
803
|
+
var LANDMARK_TAG_SET = new Set(LANDMARK_TAGS);
|
|
784
804
|
var removeLandmarkRoleOverride = {
|
|
785
805
|
kind: "removeRole",
|
|
786
806
|
apply: ({ props }) => {
|
|
@@ -789,10 +809,11 @@ var removeLandmarkRoleOverride = {
|
|
|
789
809
|
return { applied: true, next: rest, previous: props };
|
|
790
810
|
}
|
|
791
811
|
};
|
|
792
|
-
var landmarkRoleRule =
|
|
812
|
+
var landmarkRoleRule = defineAriaRule(
|
|
813
|
+
LANDMARK_TAGS,
|
|
793
814
|
({ tag, props, implicitRole }) => {
|
|
794
815
|
if (!LANDMARK_TAG_SET.has(tag) || !implicitRole) return [];
|
|
795
|
-
const role = props
|
|
816
|
+
const { role } = props;
|
|
796
817
|
if (!role || role === implicitRole) return [];
|
|
797
818
|
const diagnostic = HtmlDiagnostics.landmarkRoleOverride(tag, implicitRole, role);
|
|
798
819
|
return [
|
|
@@ -804,8 +825,7 @@ var landmarkRoleRule = Object.assign(
|
|
|
804
825
|
diagnostic
|
|
805
826
|
}
|
|
806
827
|
];
|
|
807
|
-
}
|
|
808
|
-
{ tags: [...LANDMARK_TAG_SET] }
|
|
828
|
+
}
|
|
809
829
|
);
|
|
810
830
|
function requireAccessibleName({ tag, props }) {
|
|
811
831
|
if ("aria-label" in props || "aria-labelledby" in props) return [];
|
|
@@ -818,17 +838,18 @@ function requireAccessibleName({ tag, props }) {
|
|
|
818
838
|
}
|
|
819
839
|
];
|
|
820
840
|
}
|
|
821
|
-
var NAMED_LANDMARK_TAGS =
|
|
822
|
-
var
|
|
841
|
+
var NAMED_LANDMARK_TAGS = ["nav", "aside"];
|
|
842
|
+
var NAMED_LANDMARK_TAG_SET = new Set(NAMED_LANDMARK_TAGS);
|
|
843
|
+
var landmarkAccessibleNameRule = defineAriaRule(
|
|
844
|
+
NAMED_LANDMARK_TAGS,
|
|
823
845
|
(ctx) => {
|
|
824
|
-
if (!ctx.implicitRole || !
|
|
846
|
+
if (!ctx.implicitRole || !NAMED_LANDMARK_TAG_SET.has(ctx.tag)) return [];
|
|
825
847
|
return requireAccessibleName(ctx);
|
|
826
|
-
}
|
|
827
|
-
{ tags: [...NAMED_LANDMARK_TAGS] }
|
|
848
|
+
}
|
|
828
849
|
);
|
|
829
850
|
var HTML_ARIA_RULES = [
|
|
830
851
|
landmarkRoleRule,
|
|
831
|
-
|
|
852
|
+
landmarkAccessibleNameRule,
|
|
832
853
|
roleNotPermittedRule,
|
|
833
854
|
...INPUT_RULES
|
|
834
855
|
];
|
|
@@ -841,7 +862,7 @@ export {
|
|
|
841
862
|
checkedRequiresCheckableTypeRule,
|
|
842
863
|
heightRequiresImageTypeRule,
|
|
843
864
|
inputAccessibleNameRule,
|
|
844
|
-
|
|
865
|
+
landmarkAccessibleNameRule,
|
|
845
866
|
landmarkRoleRule,
|
|
846
867
|
maxLengthRequiresTextTypeRule,
|
|
847
868
|
maxRequiresNumericTypeRule,
|
package/dist/lit/index.d.ts
CHANGED
|
@@ -179,8 +179,8 @@ type AriaContext = {
|
|
|
179
179
|
readonly props: ReadonlyDeep<IntrinsicProps>;
|
|
180
180
|
};
|
|
181
181
|
|
|
182
|
-
type RemoveAttributeFixKind =
|
|
183
|
-
type InjectLiveFixKind =
|
|
182
|
+
type RemoveAttributeFixKind = 'removeAttribute';
|
|
183
|
+
type InjectLiveFixKind = 'injectLive';
|
|
184
184
|
type FixKind = 'removeRole' | 'setRole' | 'normalizeRelevantAll' | RemoveAttributeFixKind | InjectLiveFixKind;
|
|
185
185
|
|
|
186
186
|
type AriaFixResult = {
|
|
@@ -193,6 +193,9 @@ type AriaFixResult = {
|
|
|
193
193
|
};
|
|
194
194
|
type AriaFix = {
|
|
195
195
|
readonly kind: FixKind;
|
|
196
|
+
/** The attribute a `'removeAttribute'`/`'injectLive'` fix targets — always set for those
|
|
197
|
+
* kinds, absent for kinds with no single-attribute target (`'removeRole'`, etc.). */
|
|
198
|
+
readonly attribute?: string;
|
|
196
199
|
readonly priority?: number;
|
|
197
200
|
readonly source?: string;
|
|
198
201
|
readonly apply: (context: AriaContext) => AriaFixResult;
|