@a11yfred/neighbor 0.1.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/lib/helpers.js ADDED
@@ -0,0 +1,37 @@
1
+ /**
2
+ * neighbor/lib/helpers.js
3
+ * Shared constants and pure data — no AST dependency.
4
+ */
5
+
6
+ export const INTERACTIVE_ELEMENTS = new Set([
7
+ 'a', 'button', 'input', 'select', 'textarea', 'details', 'summary',
8
+ ])
9
+
10
+ export const INTERACTIVE_ROLES = new Set([
11
+ 'button', 'link', 'checkbox', 'radio', 'textbox', 'combobox', 'listbox',
12
+ 'menuitem', 'menuitemcheckbox', 'menuitemradio', 'option', 'tab', 'switch',
13
+ 'slider', 'spinbutton', 'searchbox', 'gridcell', 'treeitem',
14
+ ])
15
+
16
+ // Truly generic containers — not landmarks, not interactive, not sectioning
17
+ export const GENERIC_CONTAINERS = new Set(['div', 'span', 'p'])
18
+
19
+ // Void/leaf elements that cannot have children (aria-owns on these is wrong)
20
+ export const VOID_ELEMENTS = new Set([
21
+ 'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link',
22
+ 'meta', 'param', 'source', 'track', 'wbr',
23
+ ])
24
+
25
+ export const HEADING_ELEMENTS = new Set(['h1', 'h2', 'h3', 'h4', 'h5', 'h6'])
26
+
27
+ export const NAV_MENU_ROLES = new Set([
28
+ 'menu', 'menubar', 'menuitem', 'menuitemcheckbox', 'menuitemradio',
29
+ ])
30
+
31
+ export const ROLES_REQUIRING_NAME = new Set([
32
+ 'region', 'dialog', 'alertdialog', 'application', 'marquee', 'searchbox',
33
+ ])
34
+
35
+ export const FORM_ELEMENTS = new Set(['input', 'select', 'textarea'])
36
+
37
+ export const CAROUSEL_CLASS_PATTERN = /carousel|slider|slideshow|rotator/i