a11y-typed-aria 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.
Files changed (69) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +148 -0
  3. package/dist/attributes/global.d.ts +36 -0
  4. package/dist/attributes/global.d.ts.map +1 -0
  5. package/dist/attributes/global.js +6 -0
  6. package/dist/attributes/index.d.ts +14 -0
  7. package/dist/attributes/index.d.ts.map +1 -0
  8. package/dist/attributes/index.js +4 -0
  9. package/dist/attributes/property.d.ts +107 -0
  10. package/dist/attributes/property.d.ts.map +1 -0
  11. package/dist/attributes/property.js +6 -0
  12. package/dist/attributes/state.d.ts +27 -0
  13. package/dist/attributes/state.d.ts.map +1 -0
  14. package/dist/attributes/state.js +6 -0
  15. package/dist/core/aria-props.d.ts +36 -0
  16. package/dist/core/aria-props.d.ts.map +1 -0
  17. package/dist/core/aria-props.js +5 -0
  18. package/dist/core/aria-role.d.ts +47 -0
  19. package/dist/core/aria-role.d.ts.map +1 -0
  20. package/dist/core/aria-role.js +5 -0
  21. package/dist/core/forbid-props.d.ts +17 -0
  22. package/dist/core/forbid-props.d.ts.map +1 -0
  23. package/dist/core/forbid-props.js +5 -0
  24. package/dist/core/required-props.d.ts +23 -0
  25. package/dist/core/required-props.d.ts.map +1 -0
  26. package/dist/core/required-props.js +5 -0
  27. package/dist/index.d.ts +39 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +25 -0
  30. package/dist/roles/alert.d.ts +14 -0
  31. package/dist/roles/alert.d.ts.map +1 -0
  32. package/dist/roles/alert.js +6 -0
  33. package/dist/roles/button.d.ts +27 -0
  34. package/dist/roles/button.d.ts.map +1 -0
  35. package/dist/roles/button.js +6 -0
  36. package/dist/roles/checkbox.d.ts +28 -0
  37. package/dist/roles/checkbox.d.ts.map +1 -0
  38. package/dist/roles/checkbox.js +6 -0
  39. package/dist/roles/dialog.d.ts +29 -0
  40. package/dist/roles/dialog.d.ts.map +1 -0
  41. package/dist/roles/dialog.js +6 -0
  42. package/dist/roles/index.d.ts +17 -0
  43. package/dist/roles/index.d.ts.map +1 -0
  44. package/dist/roles/index.js +8 -0
  45. package/dist/roles/link.d.ts +21 -0
  46. package/dist/roles/link.d.ts.map +1 -0
  47. package/dist/roles/link.js +6 -0
  48. package/dist/roles/menu.d.ts +21 -0
  49. package/dist/roles/menu.d.ts.map +1 -0
  50. package/dist/roles/menu.js +6 -0
  51. package/dist/roles/menuitem.d.ts +29 -0
  52. package/dist/roles/menuitem.d.ts.map +1 -0
  53. package/dist/roles/menuitem.js +6 -0
  54. package/dist/roles/tab.d.ts +30 -0
  55. package/dist/roles/tab.d.ts.map +1 -0
  56. package/dist/roles/tab.js +6 -0
  57. package/dist/roles/textbox.d.ts +31 -0
  58. package/dist/roles/textbox.d.ts.map +1 -0
  59. package/dist/roles/textbox.js +6 -0
  60. package/dist/utils/merge.d.ts +20 -0
  61. package/dist/utils/merge.d.ts.map +1 -0
  62. package/dist/utils/merge.js +4 -0
  63. package/dist/utils/types.d.ts +38 -0
  64. package/dist/utils/types.d.ts.map +1 -0
  65. package/dist/utils/types.js +4 -0
  66. package/dist/version.d.ts +5 -0
  67. package/dist/version.d.ts.map +1 -0
  68. package/dist/version.js +4 -0
  69. package/package.json +67 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Gayathri Devi N
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,148 @@
1
+ # a11y-typed-aria
2
+
3
+ > Type-safe ARIA attributes with compile-time validation for better web accessibility. 🎯
4
+
5
+ [![npm version](https://img.shields.io/npm/v/a11y-typed-aria.svg)](https://www.npmjs.com/package/a11y-typed-aria)
6
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.3+-blue.svg)](https://www.typescriptlang.org/)
7
+ [![Zero Runtime](https://img.shields.io/badge/Runtime-Zero-green.svg)](https://www.npmjs.com/package/a11y-typed-aria)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
9
+
10
+ Catch ARIA mistakes at **compile-time**, not in production. `a11y-typed-aria` provides a strict, spec-aligned type system for ARIA roles and attributes.
11
+
12
+ ---
13
+
14
+ ## ✨ Features
15
+
16
+ - 🔒 **Strongly Typed**: Compile-time validation of ARIA roles and permitted attributes.
17
+ - 🚫 **Forbidden Props**: Prevents invalid attributes (e.g., `aria-checked` on `button`) via explicit `never` types.
18
+ - ⚡ **Zero Runtime**: Compiled to exactly nothing. Pure TypeScript types with no runtime overhead.
19
+ - 📖 **Spec-Aligned**: Closely follows [WAI-ARIA 1.2 specification](https://www.w3.org/TR/wai-aria-1.2/).
20
+ - 🎯 **DX-First**: Excellent IDE autocomplete and descriptive error messages.
21
+ - 🪶 **Dependency-Free**: Extremely lightweight, types-only package.
22
+
23
+ ---
24
+
25
+ ## 📦 Installation
26
+
27
+ ```bash
28
+ npm install a11y-typed-aria
29
+ ```
30
+
31
+ ---
32
+
33
+ ## 🚀 Quick Start
34
+
35
+ ```typescript
36
+ import type { Aria } from "a11y-typed-aria";
37
+
38
+ // ✅ Success: Correct attributes for button
39
+ const button: Aria<"button"> = {
40
+ role: "button",
41
+ "aria-pressed": true,
42
+ "aria-label": "Toggle menu"
43
+ };
44
+
45
+ // ❌ Error: aria-checked is not allowed on a button
46
+ const invalid: Aria<"button"> = {
47
+ role: "button",
48
+ "aria-checked": true // Type error!
49
+ };
50
+
51
+ // ✅ Success: Checkbox requires aria-checked
52
+ const checkbox: Aria<"checkbox"> = {
53
+ role: "checkbox",
54
+ "aria-checked": true,
55
+ "aria-label": "Accept terms"
56
+ };
57
+ ```
58
+
59
+ ---
60
+
61
+ ## 🏛️ Core Principles
62
+
63
+ | Feature | Raw Strings / `Record<string, any>` | `a11y-typed-aria` |
64
+ | :--- | :--- | :--- |
65
+ | **Validation** | Manual testing / Linting | **Compile-time enforcement** |
66
+ | **Autocomplete** | None | **Role-specific attributes** |
67
+ | **Breaking Changes** | Silent failures | **Immediate type errors** |
68
+ | **Spec Accuracy** | Human-prone errors | **Spec-aligned types** |
69
+
70
+ ---
71
+
72
+ ## 📚 Supported Roles
73
+
74
+ The package currently supports a wide range of common ARIA roles:
75
+
76
+ - **Widgets**: `button`, `checkbox`, `textbox`, `tab`, `link`, `menu`, `menuitem`
77
+ - **Live Regions**: `alert`
78
+ - **Windows**: `dialog`
79
+ - ...and more coming soon!
80
+
81
+ ---
82
+
83
+ ## 🛠️ Advanced Usage
84
+
85
+ ### React Integration
86
+
87
+ Using our types with React components is seamless:
88
+
89
+ ```tsx
90
+ import type { Aria } from "a11y-typed-aria";
91
+
92
+ interface ButtonProps extends Aria<"button"> {
93
+ children: React.ReactNode;
94
+ onClick: () => void;
95
+ }
96
+
97
+ const IconButton = ({ role, children, onClick, ...ariaProps }: ButtonProps) => (
98
+ <button role={role} onClick={onClick} {...ariaProps}>
99
+ {children}
100
+ </button>
101
+ );
102
+ ```
103
+
104
+ ### React Hook Pattern
105
+
106
+ Manage ARIA state with a reusable hook:
107
+
108
+ ```tsx
109
+ import { useAria } from "a11y-typed-aria/examples/react-hook";
110
+
111
+ function Accordion({ title, content }) {
112
+ const { ariaProps, toggleExpanded } = useAria("button", {
113
+ "aria-expanded": false,
114
+ });
115
+
116
+ return (
117
+ <>
118
+ <button {...ariaProps} onClick={toggleExpanded}>{title}</button>
119
+ <div hidden={!ariaProps["aria-expanded"]}>{content}</div>
120
+ </>
121
+ );
122
+ }
123
+ ```
124
+
125
+ ---
126
+
127
+ ## 🏗️ Architecture
128
+
129
+ - `src/core`: The brains of the type system.
130
+ - `src/roles`: Individual role definitions.
131
+ - `src/attributes`: Categorized ARIA attribute sets.
132
+ - `tests/`: Extensive type-level testing using `tsd`.
133
+
134
+ ---
135
+
136
+ ## 🤝 Contributing
137
+
138
+ Contributions are welcome! Please see our [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines on adding new roles.
139
+
140
+ ---
141
+
142
+ ## 📄 License
143
+
144
+ MIT © Gayathri Devi N
145
+
146
+ ---
147
+
148
+ **Built with ❤️ for a more accessible web.**
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Global ARIA attributes
3
+ * Available on all elements with ARIA roles
4
+ * @see https://www.w3.org/TR/wai-aria-1.2/#global_states
5
+ */
6
+ export type AriaLabel = string;
7
+ export type AriaLabelledBy = string;
8
+ export type AriaDescribedBy = string;
9
+ export type AriaDetails = string;
10
+ export type AriaHidden = boolean | "false" | "true";
11
+ export type AriaKeyShortcuts = string;
12
+ export type AriaRoleDescription = string;
13
+ /**
14
+ * Live region attributes
15
+ */
16
+ export type AriaLive = "off" | "polite" | "assertive";
17
+ export type AriaRelevant = "additions" | "removals" | "text" | "all" | string;
18
+ export type AriaAtomic = boolean | "false" | "true";
19
+ export type AriaBusy = boolean | "false" | "true";
20
+ /**
21
+ * Global ARIA attributes interface
22
+ */
23
+ export interface GlobalAriaAttributes {
24
+ "aria-label"?: AriaLabel;
25
+ "aria-labelledby"?: AriaLabelledBy;
26
+ "aria-describedby"?: AriaDescribedBy;
27
+ "aria-details"?: AriaDetails;
28
+ "aria-hidden"?: AriaHidden;
29
+ "aria-keyshortcuts"?: AriaKeyShortcuts;
30
+ "aria-roledescription"?: AriaRoleDescription;
31
+ "aria-live"?: AriaLive;
32
+ "aria-relevant"?: AriaRelevant;
33
+ "aria-atomic"?: AriaAtomic;
34
+ "aria-busy"?: AriaBusy;
35
+ }
36
+ //# sourceMappingURL=global.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global.d.ts","sourceRoot":"","sources":["../../src/attributes/global.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAC/B,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC;AACpC,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC;AACrC,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AACjC,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;AACpD,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC;AACtC,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAEzC;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,QAAQ,GAAG,WAAW,CAAC;AACtD,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,UAAU,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,CAAC;AAC9E,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;AACpD,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,iBAAiB,CAAC,EAAE,cAAc,CAAC;IACnC,kBAAkB,CAAC,EAAE,eAAe,CAAC;IACrC,cAAc,CAAC,EAAE,WAAW,CAAC;IAC7B,aAAa,CAAC,EAAE,UAAU,CAAC;IAC3B,mBAAmB,CAAC,EAAE,gBAAgB,CAAC;IACvC,sBAAsB,CAAC,EAAE,mBAAmB,CAAC;IAC7C,WAAW,CAAC,EAAE,QAAQ,CAAC;IACvB,eAAe,CAAC,EAAE,YAAY,CAAC;IAC/B,aAAa,CAAC,EAAE,UAAU,CAAC;IAC3B,WAAW,CAAC,EAAE,QAAQ,CAAC;CAC1B"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Global ARIA attributes
3
+ * Available on all elements with ARIA roles
4
+ * @see https://www.w3.org/TR/wai-aria-1.2/#global_states
5
+ */
6
+ export {};
@@ -0,0 +1,14 @@
1
+ /**
2
+ * ARIA attributes organized by category
3
+ */
4
+ export type { GlobalAriaAttributes } from "./global";
5
+ export type { StateAriaAttributes } from "./state";
6
+ export type { PropertyAriaAttributes } from "./property";
7
+ /**
8
+ * All ARIA attributes combined
9
+ */
10
+ import type { GlobalAriaAttributes } from "./global";
11
+ import type { StateAriaAttributes } from "./state";
12
+ import type { PropertyAriaAttributes } from "./property";
13
+ export type AllAriaAttributes = GlobalAriaAttributes & StateAriaAttributes & PropertyAriaAttributes;
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/attributes/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,YAAY,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AACrD,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACnD,YAAY,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEzD;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEzD,MAAM,MAAM,iBAAiB,GAAG,oBAAoB,GAAG,mBAAmB,GAAG,sBAAsB,CAAC"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * ARIA attributes organized by category
3
+ */
4
+ export {};
@@ -0,0 +1,107 @@
1
+ /**
2
+ * ARIA property attributes
3
+ * Represent static properties and relationships
4
+ * @see https://www.w3.org/TR/wai-aria-1.2/#state_prop_def
5
+ */
6
+ export type AriaAutocomplete = "none" | "inline" | "list" | "both";
7
+ export type AriaHasPopup = boolean | "false" | "true" | "menu" | "listbox" | "tree" | "grid" | "dialog";
8
+ /**
9
+ * ARIA numeric attributes with documentation on expected values
10
+ */
11
+ /**
12
+ * Defines the hierarchical level of an element within a structure.
13
+ * Values: integers 1 or greater.
14
+ */
15
+ export type AriaLevel = number;
16
+ /**
17
+ * Indicates whether the element is to be rendered as a multi-line input or a single-line input.
18
+ */
19
+ export type AriaMultiline = boolean | "false" | "true";
20
+ /**
21
+ * Indicates that the user may select more than one item from the current selectable descendants.
22
+ */
23
+ export type AriaMultiselectable = boolean | "false" | "true";
24
+ /**
25
+ * Indicates whether the element's orientation is horizontal, vertical, or unknown/ambiguous.
26
+ */
27
+ export type AriaOrientation = "horizontal" | "vertical";
28
+ /**
29
+ * Defines a short hint (a word or short phrase) intended to aid the user with data entry when the control has no value.
30
+ */
31
+ export type AriaPlaceholder = string;
32
+ /**
33
+ * Indicates that the element is not editable, but is otherwise operable.
34
+ */
35
+ export type AriaReadonly = boolean | "false" | "true";
36
+ /**
37
+ * Indicates that user input is required on the element before a form may be submitted.
38
+ */
39
+ export type AriaRequired = boolean | "false" | "true";
40
+ /**
41
+ * Indicates if items in a table or grid are sorted in ascending or descending order.
42
+ */
43
+ export type AriaSort = "none" | "ascending" | "descending" | "other";
44
+ /**
45
+ * Defines the maximum allowed value for a range widget.
46
+ */
47
+ export type AriaValueMax = number;
48
+ /**
49
+ * Defines the minimum allowed value for a range widget.
50
+ */
51
+ export type AriaValueMin = number;
52
+ /**
53
+ * Defines the current value for a range widget.
54
+ */
55
+ export type AriaValueNow = number;
56
+ /**
57
+ * Defines the human readable text alternative of aria-valuenow for a range widget.
58
+ */
59
+ export type AriaValueText = string;
60
+ /**
61
+ * Defines an element's number or position in the current set of listitems or treeitems.
62
+ * Values: integers 1 or greater, and less than or equal to aria-setsize.
63
+ */
64
+ export type AriaPosInSet = number;
65
+ /**
66
+ * Defines the total number of items in the current set of listitems or treeitems.
67
+ * Values: integers -1 (for unknown), 0, or greater.
68
+ */
69
+ export type AriaSetSize = number;
70
+ /**
71
+ * Relationship attributes
72
+ */
73
+ export type AriaActiveDescendant = string;
74
+ export type AriaControls = string;
75
+ export type AriaDescribedBy = string;
76
+ export type AriaDetails = string;
77
+ export type AriaErrorMessage = string;
78
+ export type AriaFlowTo = string;
79
+ export type AriaLabelledBy = string;
80
+ export type AriaOwns = string;
81
+ /**
82
+ * ARIA property attributes interface
83
+ */
84
+ export interface PropertyAriaAttributes {
85
+ "aria-autocomplete"?: AriaAutocomplete;
86
+ "aria-haspopup"?: AriaHasPopup;
87
+ "aria-level"?: AriaLevel;
88
+ "aria-multiline"?: AriaMultiline;
89
+ "aria-multiselectable"?: AriaMultiselectable;
90
+ "aria-orientation"?: AriaOrientation;
91
+ "aria-placeholder"?: AriaPlaceholder;
92
+ "aria-readonly"?: AriaReadonly;
93
+ "aria-required"?: AriaRequired;
94
+ "aria-sort"?: AriaSort;
95
+ "aria-valuemax"?: AriaValueMax;
96
+ "aria-valuemin"?: AriaValueMin;
97
+ "aria-valuenow"?: AriaValueNow;
98
+ "aria-valuetext"?: AriaValueText;
99
+ "aria-activedescendant"?: AriaActiveDescendant;
100
+ "aria-controls"?: AriaControls;
101
+ "aria-errormessage"?: AriaErrorMessage;
102
+ "aria-flowto"?: AriaFlowTo;
103
+ "aria-owns"?: AriaOwns;
104
+ "aria-posinset"?: AriaPosInSet;
105
+ "aria-setsize"?: AriaSetSize;
106
+ }
107
+ //# sourceMappingURL=property.d.ts.map
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6 @@
1
+ /**
2
+ * ARIA property attributes
3
+ * Represent static properties and relationships
4
+ * @see https://www.w3.org/TR/wai-aria-1.2/#state_prop_def
5
+ */
6
+ export {};
@@ -0,0 +1,27 @@
1
+ /**
2
+ * ARIA state attributes
3
+ * Represent dynamic state that can change during user interaction
4
+ * @see https://www.w3.org/TR/wai-aria-1.2/#state_prop_def
5
+ */
6
+ export type AriaChecked = boolean | "false" | "true" | "mixed";
7
+ export type AriaDisabled = boolean | "false" | "true";
8
+ export type AriaExpanded = boolean | "false" | "true";
9
+ export type AriaGrabbed = boolean | "false" | "true";
10
+ export type AriaHidden = boolean | "false" | "true";
11
+ export type AriaInvalid = boolean | "false" | "true" | "grammar" | "spelling";
12
+ export type AriaPressed = boolean | "false" | "true" | "mixed";
13
+ export type AriaSelected = boolean | "false" | "true";
14
+ /**
15
+ * ARIA state attributes interface
16
+ */
17
+ export interface StateAriaAttributes {
18
+ "aria-checked"?: AriaChecked;
19
+ "aria-disabled"?: AriaDisabled;
20
+ "aria-expanded"?: AriaExpanded;
21
+ "aria-grabbed"?: AriaGrabbed;
22
+ "aria-hidden"?: AriaHidden;
23
+ "aria-invalid"?: AriaInvalid;
24
+ "aria-pressed"?: AriaPressed;
25
+ "aria-selected"?: AriaSelected;
26
+ }
27
+ //# sourceMappingURL=state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/attributes/state.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;AAC/D,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;AACtD,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;AACtD,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;AACrD,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;AACpD,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,CAAC;AAC9E,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;AAC/D,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAChC,cAAc,CAAC,EAAE,WAAW,CAAC;IAC7B,eAAe,CAAC,EAAE,YAAY,CAAC;IAC/B,eAAe,CAAC,EAAE,YAAY,CAAC;IAC/B,cAAc,CAAC,EAAE,WAAW,CAAC;IAC7B,aAAa,CAAC,EAAE,UAAU,CAAC;IAC3B,cAAc,CAAC,EAAE,WAAW,CAAC;IAC7B,cAAc,CAAC,EAAE,WAAW,CAAC;IAC7B,eAAe,CAAC,EAAE,YAAY,CAAC;CAClC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * ARIA state attributes
3
+ * Represent dynamic state that can change during user interaction
4
+ * @see https://www.w3.org/TR/wai-aria-1.2/#state_prop_def
5
+ */
6
+ export {};
@@ -0,0 +1,36 @@
1
+ /**
2
+ * ARIA role to props mapping
3
+ * Maps each ARIA role to its allowed attributes
4
+ */
5
+ import type { ButtonAriaProps } from "../roles/button";
6
+ import type { CheckboxAriaProps } from "../roles/checkbox";
7
+ import type { TextboxAriaProps } from "../roles/textbox";
8
+ import type { TabAriaProps } from "../roles/tab";
9
+ import type { LinkAriaProps } from "../roles/link";
10
+ import type { AlertAriaProps } from "../roles/alert";
11
+ import type { DialogAriaProps } from "../roles/dialog";
12
+ import type { MenuAriaProps } from "../roles/menu";
13
+ import type { MenuitemAriaProps } from "../roles/menuitem";
14
+ /**
15
+ * Union of all supported ARIA roles
16
+ */
17
+ export type AriaRole = "button" | "checkbox" | "textbox" | "tab" | "link" | "alert" | "dialog" | "menu" | "menuitem";
18
+ /**
19
+ * Map role names to their prop types
20
+ */
21
+ export interface AriaRolePropsMap {
22
+ button: ButtonAriaProps;
23
+ checkbox: CheckboxAriaProps;
24
+ textbox: TextboxAriaProps;
25
+ tab: TabAriaProps;
26
+ link: LinkAriaProps;
27
+ alert: AlertAriaProps;
28
+ dialog: DialogAriaProps;
29
+ menu: MenuAriaProps;
30
+ menuitem: MenuitemAriaProps;
31
+ }
32
+ /**
33
+ * Get the props type for a specific role
34
+ */
35
+ export type AriaPropsForRole<R extends AriaRole> = AriaRolePropsMap[R];
36
+ //# sourceMappingURL=aria-props.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aria-props.d.ts","sourceRoot":"","sources":["../../src/core/aria-props.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE3D;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;AAErH;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,MAAM,EAAE,eAAe,CAAC;IACxB,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,OAAO,EAAE,gBAAgB,CAAC;IAC1B,GAAG,EAAE,YAAY,CAAC;IAClB,IAAI,EAAE,aAAa,CAAC;IACpB,KAAK,EAAE,cAAc,CAAC;IACtB,MAAM,EAAE,eAAe,CAAC;IACxB,IAAI,EAAE,aAAa,CAAC;IACpB,QAAQ,EAAE,iBAAiB,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,QAAQ,IAAI,gBAAgB,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * ARIA role to props mapping
3
+ * Maps each ARIA role to its allowed attributes
4
+ */
5
+ export {};
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Main Aria<T> generic type
3
+ * The core type that provides compile-time ARIA validation
4
+ */
5
+ import type { AriaRole, AriaPropsForRole } from "./aria-props";
6
+ import type { Prettify } from "../utils/types";
7
+ import type { ForbiddenPropsForRole, WithForbiddenProps } from "./forbid-props";
8
+ import type { AllAriaAttributes } from "../attributes";
9
+ /**
10
+ * Aria<T> - Type-safe ARIA props for a specific role
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * // Valid button
15
+ * const button: Aria<"button"> = {
16
+ * role: "button",
17
+ * "aria-pressed": true
18
+ * };
19
+ *
20
+ * // Invalid - aria-checked not allowed on button
21
+ * const invalid: Aria<"button"> = {
22
+ * role: "button",
23
+ * "aria-checked": true // ❌ Type error
24
+ * };
25
+ *
26
+ * // Valid checkbox with required aria-checked
27
+ * const checkbox: Aria<"checkbox"> = {
28
+ * role: "checkbox",
29
+ * "aria-checked": true
30
+ * };
31
+ *
32
+ * // Invalid - missing required aria-checked
33
+ * const invalid2: Aria<"checkbox"> = {
34
+ * role: "checkbox" // ❌ Type error
35
+ * };
36
+ * ```
37
+ */
38
+ export type Aria<R extends AriaRole> = Prettify<WithForbiddenProps<AriaPropsForRole<R>, ForbiddenPropsForRole<Extract<keyof AriaPropsForRole<R>, keyof AllAriaAttributes>>>>;
39
+ /**
40
+ * Helper to extract the role from an Aria type
41
+ */
42
+ export type ExtractRole<T extends Aria<any>> = T["role"];
43
+ /**
44
+ * Check if a role is valid
45
+ */
46
+ export type IsValidRole<R> = R extends AriaRole ? true : false;
47
+ //# sourceMappingURL=aria-role.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aria-role.d.ts","sourceRoot":"","sources":["../../src/core/aria-role.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,MAAM,IAAI,CAAC,CAAC,SAAS,QAAQ,IAAI,QAAQ,CAC3C,kBAAkB,CACd,gBAAgB,CAAC,CAAC,CAAC,EACnB,qBAAqB,CAAC,OAAO,CAAC,MAAM,gBAAgB,CAAC,CAAC,CAAC,EAAE,MAAM,iBAAiB,CAAC,CAAC,CACrF,CACJ,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,QAAQ,GAAG,IAAI,GAAG,KAAK,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Main Aria<T> generic type
3
+ * The core type that provides compile-time ARIA validation
4
+ */
5
+ export {};
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Forbidden props enforcement
3
+ * Prevents invalid ARIA attributes from being used on specific roles
4
+ */
5
+ import type { Forbid } from "../utils/types";
6
+ import type { AllAriaAttributes } from "../attributes";
7
+ /**
8
+ * Get forbidden props for a role
9
+ * These are all ARIA attributes NOT allowed on this role
10
+ */
11
+ export type ForbiddenPropsForRole<AllowedKeys extends keyof AllAriaAttributes> = Exclude<keyof AllAriaAttributes, AllowedKeys>;
12
+ /**
13
+ * Enforce forbidden props on a type
14
+ * Makes forbidden props have type 'never'
15
+ */
16
+ export type WithForbiddenProps<T, ForbiddenKeys extends keyof any> = Forbid<T, ForbiddenKeys>;
17
+ //# sourceMappingURL=forbid-props.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forbid-props.d.ts","sourceRoot":"","sources":["../../src/core/forbid-props.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD;;;GAGG;AACH,MAAM,MAAM,qBAAqB,CAAC,WAAW,SAAS,MAAM,iBAAiB,IAAI,OAAO,CACpF,MAAM,iBAAiB,EACvB,WAAW,CACd,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,kBAAkB,CAAC,CAAC,EAAE,aAAa,SAAS,MAAM,GAAG,IAAI,MAAM,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Forbidden props enforcement
3
+ * Prevents invalid ARIA attributes from being used on specific roles
4
+ */
5
+ export {};
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Required props enforcement
3
+ * Ensures required ARIA attributes are present at compile-time
4
+ */
5
+ import type { RequireKeys } from "../utils/types";
6
+ /**
7
+ * Map of roles to their required attributes
8
+ */
9
+ export interface RequiredPropsMap {
10
+ button: never;
11
+ checkbox: "aria-checked";
12
+ textbox: never;
13
+ tab: never;
14
+ }
15
+ /**
16
+ * Get required props for a role
17
+ */
18
+ export type RequiredPropsForRole<R extends keyof RequiredPropsMap> = RequiredPropsMap[R];
19
+ /**
20
+ * Enforce required props on a type
21
+ */
22
+ export type WithRequiredProps<T, K extends keyof T> = K extends never ? T : RequireKeys<T, K>;
23
+ //# sourceMappingURL=required-props.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"required-props.d.ts","sourceRoot":"","sources":["../../src/core/required-props.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,MAAM,EAAE,KAAK,CAAC;IACd,QAAQ,EAAE,cAAc,CAAC;IACzB,OAAO,EAAE,KAAK,CAAC;IACf,GAAG,EAAE,KAAK,CAAC;CACd;AAED;;GAEG;AACH,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,MAAM,gBAAgB,IAAI,gBAAgB,CAAC,CAAC,CAAC,CAAC;AAEzF;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,CAAC,SAAS,KAAK,GAC/D,CAAC,GACD,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Required props enforcement
3
+ * Ensures required ARIA attributes are present at compile-time
4
+ */
5
+ export {};
@@ -0,0 +1,39 @@
1
+ /**
2
+ * a11y-typed-aria
3
+ * TypeScript-first ARIA types with compile-time validation
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * import type { Aria } from "a11y-typed-aria";
8
+ *
9
+ * // Type-safe button
10
+ * const button: Aria<"button"> = {
11
+ * role: "button",
12
+ * "aria-pressed": true,
13
+ * "aria-label": "Toggle"
14
+ * };
15
+ *
16
+ * // Type-safe checkbox with required aria-checked
17
+ * const checkbox: Aria<"checkbox"> = {
18
+ * role: "checkbox",
19
+ * "aria-checked": true,
20
+ * "aria-label": "Accept terms"
21
+ * };
22
+ * ```
23
+ */
24
+ export type { Aria, ExtractRole, IsValidRole } from "./core/aria-role";
25
+ export type { AriaRole, AriaPropsForRole } from "./core/aria-props";
26
+ export type { ButtonAriaProps } from "./roles/button";
27
+ export type { CheckboxAriaProps } from "./roles/checkbox";
28
+ export type { TextboxAriaProps } from "./roles/textbox";
29
+ export type { TabAriaProps } from "./roles/tab";
30
+ export type { LinkAriaProps } from "./roles/link";
31
+ export type { AlertAriaProps } from "./roles/alert";
32
+ export type { DialogAriaProps } from "./roles/dialog";
33
+ export type { MenuAriaProps } from "./roles/menu";
34
+ export type { MenuitemAriaProps } from "./roles/menuitem";
35
+ export type { GlobalAriaAttributes, StateAriaAttributes, PropertyAriaAttributes, AllAriaAttributes, } from "./attributes";
36
+ export type { Prettify, RequireKeys, Forbid } from "./utils/types";
37
+ export type { MergeProps } from "./utils/merge";
38
+ export { VERSION } from "./version";
39
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,YAAY,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACvE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAGpE,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAG1D,YAAY,EACR,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,iBAAiB,GACpB,MAAM,cAAc,CAAC;AAGtB,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACnE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGhD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,25 @@
1
+ /**
2
+ * a11y-typed-aria
3
+ * TypeScript-first ARIA types with compile-time validation
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * import type { Aria } from "a11y-typed-aria";
8
+ *
9
+ * // Type-safe button
10
+ * const button: Aria<"button"> = {
11
+ * role: "button",
12
+ * "aria-pressed": true,
13
+ * "aria-label": "Toggle"
14
+ * };
15
+ *
16
+ * // Type-safe checkbox with required aria-checked
17
+ * const checkbox: Aria<"checkbox"> = {
18
+ * role: "checkbox",
19
+ * "aria-checked": true,
20
+ * "aria-label": "Accept terms"
21
+ * };
22
+ * ```
23
+ */
24
+ // Version
25
+ export { VERSION } from "./version";