@compa11y/core 0.1.2 → 0.1.5
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/announcer/index.cjs +1 -49
- package/dist/announcer/index.js +1 -4
- package/dist/aria/index.cjs +1 -24
- package/dist/aria/index.js +1 -3
- package/dist/chunk-7BL2ABLF.cjs +1 -0
- package/dist/chunk-AQ6HEUSD.cjs +1 -0
- package/dist/chunk-C3VZQUKG.js +1 -0
- package/dist/chunk-EM45V5TK.cjs +1 -0
- package/dist/chunk-KQUAJKTG.cjs +1 -0
- package/dist/chunk-QGEFH2VG.js +1 -0
- package/dist/chunk-RE4QIUWR.js +1 -0
- package/dist/chunk-TGXWODB3.js +1 -0
- package/dist/chunk-Y2RTDE4A.cjs +1 -0
- package/dist/chunk-ZAQMM5TA.js +1 -0
- package/dist/focus/index.cjs +1 -53
- package/dist/focus/index.d.cts +63 -1
- package/dist/focus/index.d.ts +63 -1
- package/dist/focus/index.js +1 -4
- package/dist/index.cjs +2 -567
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -337
- package/dist/keyboard/index.cjs +1 -28
- package/dist/keyboard/index.js +1 -3
- package/package.json +1 -1
- package/dist/announcer/index.cjs.map +0 -1
- package/dist/announcer/index.js.map +0 -1
- package/dist/aria/index.cjs.map +0 -1
- package/dist/aria/index.js.map +0 -1
- package/dist/chunk-24U5HHMC.js +0 -309
- package/dist/chunk-24U5HHMC.js.map +0 -1
- package/dist/chunk-2CQOLVQH.js +0 -147
- package/dist/chunk-2CQOLVQH.js.map +0 -1
- package/dist/chunk-2PUYKF2E.js +0 -631
- package/dist/chunk-2PUYKF2E.js.map +0 -1
- package/dist/chunk-2WF5Y6D7.js +0 -175
- package/dist/chunk-2WF5Y6D7.js.map +0 -1
- package/dist/chunk-CQXMBRLD.cjs +0 -657
- package/dist/chunk-CQXMBRLD.cjs.map +0 -1
- package/dist/chunk-HQOFVJFO.cjs +0 -181
- package/dist/chunk-HQOFVJFO.cjs.map +0 -1
- package/dist/chunk-NBGFFCIJ.cjs +0 -314
- package/dist/chunk-NBGFFCIJ.cjs.map +0 -1
- package/dist/chunk-V6TZIZZ4.cjs +0 -158
- package/dist/chunk-V6TZIZZ4.cjs.map +0 -1
- package/dist/chunk-XEGB27QF.cjs +0 -78
- package/dist/chunk-XEGB27QF.cjs.map +0 -1
- package/dist/chunk-Z7K2G6FX.js +0 -66
- package/dist/chunk-Z7K2G6FX.js.map +0 -1
- package/dist/focus/index.cjs.map +0 -1
- package/dist/focus/index.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/keyboard/index.cjs.map +0 -1
- package/dist/keyboard/index.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,338 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export { KeyboardPatterns, createKeyboardManager, createTypeAhead, getKeyCombo, normalizeKey } from './chunk-2WF5Y6D7.js';
|
|
3
|
-
export { announce, announceAssertive, announceError, announcePolite, announceProgress, announceStatus, clearAnnouncements, createAnnouncer, initAnnouncer, queueAnnouncement } from './chunk-2CQOLVQH.js';
|
|
4
|
-
export { createMediaQueryListener, getScreenReaderHints, isAndroid, isBrowser, isIOS, isMac, isTouchDevice, isWindows, prefersDarkMode, prefersHighContrast, prefersReducedMotion } from './chunk-Z7K2G6FX.js';
|
|
5
|
-
import { hasAccessibleName } from './chunk-24U5HHMC.js';
|
|
6
|
-
export { aria, buildAriaProps, hasAccessibleName, mergeAriaIds } from './chunk-24U5HHMC.js';
|
|
1
|
+
export{a as FOCUSABLE_SELECTORS,b as TABBABLE_SELECTORS,j as containsFocus,A as createFocusReturn,x as createFocusScope,o as createFocusTrap,y as createRovingTabindex,z as findFocusNeighbor,w as focusWithVisibleRing,p as getActiveFocusTrap,h as getFirstFocusable,f as getFocusableElements,u as getLastFocusSource,i as getLastFocusable,k as getNextFocusable,l as getPreviousFocusable,g as getTabbableElements,q as hasFocusTrap,t as hasVisibleFocus,r as initFocusVisible,s as isFocusVisible,d as isFocusable,e as isTabbable,c as isVisible,m as isWithinContainer,n as resolveElement,v as setFocusVisible}from'./chunk-QGEFH2VG.js';export{d as KeyboardPatterns,c as createKeyboardManager,e as createTypeAhead,b as getKeyCombo,a as normalizeKey}from'./chunk-RE4QIUWR.js';export{b as announce,d as announceAssertive,i as announceError,c as announcePolite,j as announceProgress,h as announceStatus,e as clearAnnouncements,g as createAnnouncer,a as initAnnouncer,f as queueAnnouncement}from'./chunk-ZAQMM5TA.js';export{k as createMediaQueryListener,j as getScreenReaderHints,d as isAndroid,a as isBrowser,c as isIOS,b as isMac,f as isTouchDevice,e as isWindows,i as prefersDarkMode,h as prefersHighContrast,g as prefersReducedMotion}from'./chunk-C3VZQUKG.js';import {d as d$1}from'./chunk-TGXWODB3.js';export{a as aria,b as buildAriaProps,d as hasAccessibleName,c as mergeAriaIds}from'./chunk-TGXWODB3.js';var g=0,d="compa11y";function u(e){let n=++g;return e?`${d}-${e}-${n}`:`${d}-${n}`}function $e(e,n){let r=u(n),t={};for(let o of e)t[o]=`${r}-${o}`;return t}function we(){g=0;}function Ae(e){let n=u(e);return {id:n,generate:r=>`${n}-${r}`,generateMultiple:r=>{let t={};for(let o of r)t[o]=`${n}-${o}`;return t}}}var a=null,l=new Set;function p(){return typeof process<"u"&&process.env?.NODE_ENV!=="production"}function b(e){a=e;}function f(e){return `${e.component}:${e.message}`}function i(e){if(!p())return;let n=f(e);if(l.has(n))return;if(l.add(n),a){a(e);return}let r=`[compa11y/${e.component}]`,t=m(e.type),o=e.suggestion?`${e.message}
|
|
7
2
|
|
|
8
|
-
|
|
9
|
-
var idCounter = 0;
|
|
10
|
-
var PREFIX = "compa11y";
|
|
11
|
-
function generateId(prefix) {
|
|
12
|
-
const id = ++idCounter;
|
|
13
|
-
return prefix ? `${PREFIX}-${prefix}-${id}` : `${PREFIX}-${id}`;
|
|
14
|
-
}
|
|
15
|
-
function generateIds(parts, prefix) {
|
|
16
|
-
const baseId = generateId(prefix);
|
|
17
|
-
const ids = {};
|
|
18
|
-
for (const part of parts) {
|
|
19
|
-
ids[part] = `${baseId}-${part}`;
|
|
20
|
-
}
|
|
21
|
-
return ids;
|
|
22
|
-
}
|
|
23
|
-
function resetIdCounter() {
|
|
24
|
-
idCounter = 0;
|
|
25
|
-
}
|
|
26
|
-
function createIdScope(componentName) {
|
|
27
|
-
const scopeId = generateId(componentName);
|
|
28
|
-
return {
|
|
29
|
-
id: scopeId,
|
|
30
|
-
generate: (suffix) => `${scopeId}-${suffix}`,
|
|
31
|
-
generateMultiple: (parts) => {
|
|
32
|
-
const ids = {};
|
|
33
|
-
for (const part of parts) {
|
|
34
|
-
ids[part] = `${scopeId}-${part}`;
|
|
35
|
-
}
|
|
36
|
-
return ids;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// src/dev/warnings.ts
|
|
42
|
-
var warningHandler = null;
|
|
43
|
-
var issuedWarnings = /* @__PURE__ */ new Set();
|
|
44
|
-
function isDev() {
|
|
45
|
-
return typeof process !== "undefined" && process.env?.NODE_ENV !== "production";
|
|
46
|
-
}
|
|
47
|
-
function setWarningHandler(handler) {
|
|
48
|
-
warningHandler = handler;
|
|
49
|
-
}
|
|
50
|
-
function createWarningKey(warning) {
|
|
51
|
-
return `${warning.component}:${warning.message}`;
|
|
52
|
-
}
|
|
53
|
-
function warn(warning) {
|
|
54
|
-
if (!isDev()) return;
|
|
55
|
-
const key = createWarningKey(warning);
|
|
56
|
-
if (issuedWarnings.has(key)) return;
|
|
57
|
-
issuedWarnings.add(key);
|
|
58
|
-
if (warningHandler) {
|
|
59
|
-
warningHandler(warning);
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
const prefix = `[compa11y/${warning.component}]`;
|
|
63
|
-
const style = getConsoleStyle(warning.type);
|
|
64
|
-
const message = warning.suggestion ? `${warning.message}
|
|
65
|
-
|
|
66
|
-
\u{1F4A1} Suggestion: ${warning.suggestion}` : warning.message;
|
|
67
|
-
switch (warning.type) {
|
|
68
|
-
case "error":
|
|
69
|
-
console.error(`%c${prefix}%c ${message}`, style, "");
|
|
70
|
-
break;
|
|
71
|
-
case "warning":
|
|
72
|
-
console.warn(`%c${prefix}%c ${message}`, style, "");
|
|
73
|
-
break;
|
|
74
|
-
case "info":
|
|
75
|
-
console.info(`%c${prefix}%c ${message}`, style, "");
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
if (warning.element) {
|
|
79
|
-
console.log("Element:", warning.element);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
function getConsoleStyle(type) {
|
|
83
|
-
switch (type) {
|
|
84
|
-
case "error":
|
|
85
|
-
return "background: #ff5555; color: white; padding: 2px 4px; border-radius: 2px; font-weight: bold;";
|
|
86
|
-
case "warning":
|
|
87
|
-
return "background: #ffaa00; color: black; padding: 2px 4px; border-radius: 2px; font-weight: bold;";
|
|
88
|
-
case "info":
|
|
89
|
-
return "background: #5555ff; color: white; padding: 2px 4px; border-radius: 2px; font-weight: bold;";
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
function clearWarnings() {
|
|
93
|
-
issuedWarnings.clear();
|
|
94
|
-
}
|
|
95
|
-
var checks = {
|
|
96
|
-
/**
|
|
97
|
-
* Check for missing accessible label
|
|
98
|
-
*/
|
|
99
|
-
accessibleLabel(element, component, propName = "aria-label") {
|
|
100
|
-
if (!element) return;
|
|
101
|
-
if (!hasAccessibleName(element)) {
|
|
102
|
-
warn({
|
|
103
|
-
type: "error",
|
|
104
|
-
component,
|
|
105
|
-
message: `Missing accessible label. Screen reader users will not be able to understand this element.`,
|
|
106
|
-
suggestion: `Add ${propName}, aria-labelledby, or visible text content.`,
|
|
107
|
-
element
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
/**
|
|
112
|
-
* Check for missing required prop
|
|
113
|
-
*/
|
|
114
|
-
requiredProp(value, propName, component) {
|
|
115
|
-
if (value === void 0 || value === null || value === "") {
|
|
116
|
-
warn({
|
|
117
|
-
type: "error",
|
|
118
|
-
component,
|
|
119
|
-
message: `Missing required prop "${propName}".`,
|
|
120
|
-
suggestion: `Provide a value for the "${propName}" prop.`
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
/**
|
|
125
|
-
* Check for invalid ARIA role
|
|
126
|
-
*/
|
|
127
|
-
validRole(role, component, element) {
|
|
128
|
-
if (!role) return;
|
|
129
|
-
const validRoles = /* @__PURE__ */ new Set([
|
|
130
|
-
"alert",
|
|
131
|
-
"alertdialog",
|
|
132
|
-
"application",
|
|
133
|
-
"article",
|
|
134
|
-
"banner",
|
|
135
|
-
"button",
|
|
136
|
-
"cell",
|
|
137
|
-
"columnheader",
|
|
138
|
-
"combobox",
|
|
139
|
-
"complementary",
|
|
140
|
-
"contentinfo",
|
|
141
|
-
"definition",
|
|
142
|
-
"dialog",
|
|
143
|
-
"directory",
|
|
144
|
-
"document",
|
|
145
|
-
"feed",
|
|
146
|
-
"figure",
|
|
147
|
-
"form",
|
|
148
|
-
"grid",
|
|
149
|
-
"gridcell",
|
|
150
|
-
"group",
|
|
151
|
-
"heading",
|
|
152
|
-
"img",
|
|
153
|
-
"link",
|
|
154
|
-
"list",
|
|
155
|
-
"listbox",
|
|
156
|
-
"listitem",
|
|
157
|
-
"log",
|
|
158
|
-
"main",
|
|
159
|
-
"marquee",
|
|
160
|
-
"math",
|
|
161
|
-
"menu",
|
|
162
|
-
"menubar",
|
|
163
|
-
"menuitem",
|
|
164
|
-
"navigation",
|
|
165
|
-
"none",
|
|
166
|
-
"note",
|
|
167
|
-
"option",
|
|
168
|
-
"presentation",
|
|
169
|
-
"progressbar",
|
|
170
|
-
"region",
|
|
171
|
-
"row",
|
|
172
|
-
"rowgroup",
|
|
173
|
-
"rowheader",
|
|
174
|
-
"scrollbar",
|
|
175
|
-
"search",
|
|
176
|
-
"searchbox",
|
|
177
|
-
"separator",
|
|
178
|
-
"slider",
|
|
179
|
-
"spinbutton",
|
|
180
|
-
"status",
|
|
181
|
-
"switch",
|
|
182
|
-
"tab",
|
|
183
|
-
"table",
|
|
184
|
-
"tablist",
|
|
185
|
-
"tabpanel",
|
|
186
|
-
"term",
|
|
187
|
-
"textbox",
|
|
188
|
-
"timer",
|
|
189
|
-
"toolbar",
|
|
190
|
-
"tooltip",
|
|
191
|
-
"tree",
|
|
192
|
-
"treegrid",
|
|
193
|
-
"treeitem"
|
|
194
|
-
]);
|
|
195
|
-
if (!validRoles.has(role)) {
|
|
196
|
-
warn({
|
|
197
|
-
type: "warning",
|
|
198
|
-
component,
|
|
199
|
-
message: `Invalid ARIA role "${role}".`,
|
|
200
|
-
suggestion: "Use a valid ARIA role from the WAI-ARIA specification.",
|
|
201
|
-
element
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
},
|
|
205
|
-
/**
|
|
206
|
-
* Check for interactive element without keyboard support
|
|
207
|
-
*/
|
|
208
|
-
keyboardAccessible(element, component, handlers) {
|
|
209
|
-
if (!element) return;
|
|
210
|
-
if (handlers.onClick && !handlers.onKeyDown) {
|
|
211
|
-
const tagName = element.tagName.toLowerCase();
|
|
212
|
-
const role = element.getAttribute("role");
|
|
213
|
-
if (["button", "a", "input", "select", "textarea"].includes(tagName)) {
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
const interactiveRoles = ["button", "link", "menuitem", "option", "tab"];
|
|
217
|
-
if (role && interactiveRoles.includes(role)) {
|
|
218
|
-
warn({
|
|
219
|
-
type: "warning",
|
|
220
|
-
component,
|
|
221
|
-
message: `Element has onClick but no onKeyDown handler.`,
|
|
222
|
-
suggestion: "Add keyboard event handling for Enter and Space keys.",
|
|
223
|
-
element
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
},
|
|
228
|
-
/**
|
|
229
|
-
* Check tabIndex usage
|
|
230
|
-
*/
|
|
231
|
-
tabIndex(tabIndex, component, element) {
|
|
232
|
-
if (tabIndex === void 0) return;
|
|
233
|
-
if (tabIndex > 0) {
|
|
234
|
-
warn({
|
|
235
|
-
type: "warning",
|
|
236
|
-
component,
|
|
237
|
-
message: `Positive tabIndex (${tabIndex}) disrupts natural tab order.`,
|
|
238
|
-
suggestion: "Use tabIndex={0} or tabIndex={-1} instead. Rely on DOM order for tab sequence.",
|
|
239
|
-
element
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
},
|
|
243
|
-
/**
|
|
244
|
-
* Check for autofocus in dialogs
|
|
245
|
-
*/
|
|
246
|
-
dialogAutoFocus(hasAutoFocus, component) {
|
|
247
|
-
if (!hasAutoFocus) {
|
|
248
|
-
warn({
|
|
249
|
-
type: "info",
|
|
250
|
-
component,
|
|
251
|
-
message: "No initial focus element specified for dialog.",
|
|
252
|
-
suggestion: "Consider setting initialFocus to guide keyboard users."
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
},
|
|
256
|
-
/**
|
|
257
|
-
* Check for missing form labels
|
|
258
|
-
*/
|
|
259
|
-
formLabel(inputElement, labelId, component) {
|
|
260
|
-
if (!inputElement) return;
|
|
261
|
-
const hasLabel = labelId || inputElement.getAttribute("aria-label") || inputElement.getAttribute("aria-labelledby") || inputElement.labels?.length;
|
|
262
|
-
if (!hasLabel) {
|
|
263
|
-
warn({
|
|
264
|
-
type: "error",
|
|
265
|
-
component,
|
|
266
|
-
message: "Form input is missing an accessible label.",
|
|
267
|
-
suggestion: "Add a <label>, aria-label, or aria-labelledby.",
|
|
268
|
-
element: inputElement
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
},
|
|
272
|
-
/**
|
|
273
|
-
* Check for missing alt text on images
|
|
274
|
-
*/
|
|
275
|
-
imageAlt(element, component) {
|
|
276
|
-
if (!element || element.tagName !== "IMG") return;
|
|
277
|
-
const alt = element.getAttribute("alt");
|
|
278
|
-
const role = element.getAttribute("role");
|
|
279
|
-
if (alt === null && role !== "presentation" && role !== "none") {
|
|
280
|
-
warn({
|
|
281
|
-
type: "error",
|
|
282
|
-
component,
|
|
283
|
-
message: "Image is missing alt attribute.",
|
|
284
|
-
suggestion: 'Add alt="" for decorative images or descriptive alt text for meaningful images.',
|
|
285
|
-
element
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
};
|
|
290
|
-
function createComponentWarnings(componentName) {
|
|
291
|
-
return {
|
|
292
|
-
error: (message, suggestion, element) => warn({
|
|
293
|
-
type: "error",
|
|
294
|
-
component: componentName,
|
|
295
|
-
message,
|
|
296
|
-
suggestion,
|
|
297
|
-
element
|
|
298
|
-
}),
|
|
299
|
-
warning: (message, suggestion, element) => warn({
|
|
300
|
-
type: "warning",
|
|
301
|
-
component: componentName,
|
|
302
|
-
message,
|
|
303
|
-
suggestion,
|
|
304
|
-
element
|
|
305
|
-
}),
|
|
306
|
-
info: (message, suggestion, element) => warn({
|
|
307
|
-
type: "info",
|
|
308
|
-
component: componentName,
|
|
309
|
-
message,
|
|
310
|
-
suggestion,
|
|
311
|
-
element
|
|
312
|
-
}),
|
|
313
|
-
checks: {
|
|
314
|
-
accessibleLabel: (element, propName) => checks.accessibleLabel(element, componentName, propName),
|
|
315
|
-
requiredProp: (value, propName) => checks.requiredProp(value, propName, componentName),
|
|
316
|
-
keyboardAccessible: (element, handlers) => checks.keyboardAccessible(element, componentName, handlers),
|
|
317
|
-
tabIndex: (tabIndex, element) => checks.tabIndex(tabIndex, componentName, element)
|
|
318
|
-
}
|
|
319
|
-
};
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
// src/index.ts
|
|
323
|
-
function initCompa11y() {
|
|
324
|
-
const cleanups = [];
|
|
325
|
-
import('./focus/index.js').then(({ initFocusVisible: initFocusVisible2 }) => {
|
|
326
|
-
cleanups.push(initFocusVisible2());
|
|
327
|
-
});
|
|
328
|
-
import('./announcer/index.js').then(({ initAnnouncer: initAnnouncer2 }) => {
|
|
329
|
-
cleanups.push(initAnnouncer2());
|
|
330
|
-
});
|
|
331
|
-
return () => {
|
|
332
|
-
cleanups.forEach((cleanup) => cleanup());
|
|
333
|
-
};
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
export { checks, clearWarnings, createComponentWarnings, createIdScope, generateId, generateIds, initCompa11y, resetIdCounter, setWarningHandler, warn };
|
|
337
|
-
//# sourceMappingURL=index.js.map
|
|
338
|
-
//# sourceMappingURL=index.js.map
|
|
3
|
+
\u{1F4A1} Suggestion: ${e.suggestion}`:e.message;switch(e.type){case "error":console.error(`%c${r}%c ${o}`,t,"");break;case "warning":console.warn(`%c${r}%c ${o}`,t,"");break;case "info":console.info(`%c${r}%c ${o}`,t,"");break}e.element&&console.log("Element:",e.element);}function m(e){switch(e){case "error":return "background: #ff5555; color: white; padding: 2px 4px; border-radius: 2px; font-weight: bold;";case "warning":return "background: #ffaa00; color: black; padding: 2px 4px; border-radius: 2px; font-weight: bold;";case "info":return "background: #5555ff; color: white; padding: 2px 4px; border-radius: 2px; font-weight: bold;"}}function x(){l.clear();}var s={accessibleLabel(e,n,r="aria-label"){e&&(d$1(e)||i({type:"error",component:n,message:"Missing accessible label. Screen reader users will not be able to understand this element.",suggestion:`Add ${r}, aria-labelledby, or visible text content.`,element:e}));},requiredProp(e,n,r){(e==null||e==="")&&i({type:"error",component:r,message:`Missing required prop "${n}".`,suggestion:`Provide a value for the "${n}" prop.`});},validRole(e,n,r){if(!e)return;new Set(["alert","alertdialog","application","article","banner","button","cell","columnheader","combobox","complementary","contentinfo","definition","dialog","directory","document","feed","figure","form","grid","gridcell","group","heading","img","link","list","listbox","listitem","log","main","marquee","math","menu","menubar","menuitem","navigation","none","note","option","presentation","progressbar","region","row","rowgroup","rowheader","scrollbar","search","searchbox","separator","slider","spinbutton","status","switch","tab","table","tablist","tabpanel","term","textbox","timer","toolbar","tooltip","tree","treegrid","treeitem"]).has(e)||i({type:"warning",component:n,message:`Invalid ARIA role "${e}".`,suggestion:"Use a valid ARIA role from the WAI-ARIA specification.",element:r});},keyboardAccessible(e,n,r){if(e&&r.onClick&&!r.onKeyDown){let t=e.tagName.toLowerCase(),o=e.getAttribute("role");if(["button","a","input","select","textarea"].includes(t))return;o&&["button","link","menuitem","option","tab"].includes(o)&&i({type:"warning",component:n,message:"Element has onClick but no onKeyDown handler.",suggestion:"Add keyboard event handling for Enter and Space keys.",element:e});}},tabIndex(e,n,r){e!==void 0&&e>0&&i({type:"warning",component:n,message:`Positive tabIndex (${e}) disrupts natural tab order.`,suggestion:"Use tabIndex={0} or tabIndex={-1} instead. Rely on DOM order for tab sequence.",element:r});},dialogAutoFocus(e,n){e||i({type:"info",component:n,message:"No initial focus element specified for dialog.",suggestion:"Consider setting initialFocus to guide keyboard users."});},formLabel(e,n,r){if(!e)return;n||e.getAttribute("aria-label")||e.getAttribute("aria-labelledby")||e.labels?.length||i({type:"error",component:r,message:"Form input is missing an accessible label.",suggestion:"Add a <label>, aria-label, or aria-labelledby.",element:e});},imageAlt(e,n){if(!e||e.tagName!=="IMG")return;let r=e.getAttribute("alt"),t=e.getAttribute("role");r===null&&t!=="presentation"&&t!=="none"&&i({type:"error",component:n,message:"Image is missing alt attribute.",suggestion:'Add alt="" for decorative images or descriptive alt text for meaningful images.',element:e});}};function y(e){return {error:(n,r,t)=>i({type:"error",component:e,message:n,suggestion:r,element:t}),warning:(n,r,t)=>i({type:"warning",component:e,message:n,suggestion:r,element:t}),info:(n,r,t)=>i({type:"info",component:e,message:n,suggestion:r,element:t}),checks:{accessibleLabel:(n,r)=>s.accessibleLabel(n,e,r),requiredProp:(n,r)=>s.requiredProp(n,r,e),keyboardAccessible:(n,r)=>s.keyboardAccessible(n,e,r),tabIndex:(n,r)=>s.tabIndex(n,e,r)}}}function We(){let e=[];return import('./focus/index.js').then(({initFocusVisible:n})=>{e.push(n());}),import('./announcer/index.js').then(({initAnnouncer:n})=>{e.push(n());}),()=>{e.forEach(n=>n());}}export{s as checks,x as clearWarnings,y as createComponentWarnings,Ae as createIdScope,u as generateId,$e as generateIds,We as initCompa11y,we as resetIdCounter,b as setWarningHandler,i as warn};
|
package/dist/keyboard/index.cjs
CHANGED
|
@@ -1,28 +1 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkHQOFVJFO_cjs = require('../chunk-HQOFVJFO.cjs');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "KeyboardPatterns", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function () { return chunkHQOFVJFO_cjs.KeyboardPatterns; }
|
|
10
|
-
});
|
|
11
|
-
Object.defineProperty(exports, "createKeyboardManager", {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: function () { return chunkHQOFVJFO_cjs.createKeyboardManager; }
|
|
14
|
-
});
|
|
15
|
-
Object.defineProperty(exports, "createTypeAhead", {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
get: function () { return chunkHQOFVJFO_cjs.createTypeAhead; }
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports, "getKeyCombo", {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
get: function () { return chunkHQOFVJFO_cjs.getKeyCombo; }
|
|
22
|
-
});
|
|
23
|
-
Object.defineProperty(exports, "normalizeKey", {
|
|
24
|
-
enumerable: true,
|
|
25
|
-
get: function () { return chunkHQOFVJFO_cjs.normalizeKey; }
|
|
26
|
-
});
|
|
27
|
-
//# sourceMappingURL=index.cjs.map
|
|
28
|
-
//# sourceMappingURL=index.cjs.map
|
|
1
|
+
'use strict';var chunkEM45V5TK_cjs=require('../chunk-EM45V5TK.cjs');Object.defineProperty(exports,"KeyboardPatterns",{enumerable:true,get:function(){return chunkEM45V5TK_cjs.d}});Object.defineProperty(exports,"createKeyboardManager",{enumerable:true,get:function(){return chunkEM45V5TK_cjs.c}});Object.defineProperty(exports,"createTypeAhead",{enumerable:true,get:function(){return chunkEM45V5TK_cjs.e}});Object.defineProperty(exports,"getKeyCombo",{enumerable:true,get:function(){return chunkEM45V5TK_cjs.b}});Object.defineProperty(exports,"normalizeKey",{enumerable:true,get:function(){return chunkEM45V5TK_cjs.a}});
|
package/dist/keyboard/index.js
CHANGED
|
@@ -1,3 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
3
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export{d as KeyboardPatterns,c as createKeyboardManager,e as createTypeAhead,b as getKeyCombo,a as normalizeKey}from'../chunk-RE4QIUWR.js';
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
package/dist/aria/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
package/dist/aria/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|