@cocreate/aria 1.5.0 → 1.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/CONTRIBUTING.md CHANGED
@@ -13,7 +13,7 @@ Fork the [project on Github](https://github.com/CoCreate-app/CoCreate-aria) and
13
13
  ```
14
14
  git clone https://github.com/contributor/CoCreate-aria.git
15
15
  cd CoCreate-aria
16
- git remote add upstream https://github.com/CoCreate-app/CoCreate-aria.git
16
+ git remote add upstream https://gitlab.com/cocreatejs/CoCreate-aria.git
17
17
  ```
18
18
 
19
19
  ## Create a Topic Branch
package/README.md CHANGED
@@ -83,3 +83,118 @@ We appreciate your continued support, thank you!
83
83
  # License
84
84
 
85
85
  [The MIT License (MIT)](https://github.com/CoCreate-app/CoCreate-aria/blob/master/LICENSE)
86
+
87
+ ## Toggle buttons and selection groups
88
+
89
+ Use `aria-pressed` on a button for an independent toggle. Related toggles can
90
+ sit inside `role="group"`; grouping does not make them mutually exclusive.
91
+
92
+ ```html
93
+ <div role="group" aria-label="Text formatting">
94
+ <button type="button" aria-pressed="false">Bold</button>
95
+ <button type="button" aria-pressed="false">Italic</button>
96
+ </div>
97
+ ```
98
+
99
+ For one selected option, use custom radios inside a labelled `radiogroup`.
100
+ These controls do not need `aria-controls` or a panel to display.
101
+
102
+ ```html
103
+ <div role="radiogroup" aria-label="API category">
104
+ <button type="button" role="radio" aria-checked="true">All</button>
105
+ <button type="button" role="radio" aria-checked="false">Storage</button>
106
+ <button type="button" role="radio" aria-checked="false">Cloud</button>
107
+ </div>
108
+ ```
109
+
110
+ Activating a radio selects it and deselects its siblings. Arrow keys move and
111
+ select, Home/End jump to the first/last available item, and Space/Enter activate.
112
+ Inside a toolbar, arrow keys move focus without selecting. Nested radio groups
113
+ are independent. Disabled and hidden items are skipped during group navigation.
114
+
115
+ Custom `role="checkbox"` and `role="switch"` controls toggle `aria-checked`.
116
+ Native checkbox and radio inputs retain native behavior. Toggle and custom
117
+ checked controls synchronize their `active` class with the state attribute;
118
+ external attribute changes and dynamically inserted controls are supported.
119
+ An initial `mixed` state is preserved until activation, which selects `true`.
120
+
121
+ Controls handled by this module block activation when disabled or when
122
+ `aria-disabled="true"`. Existing tab panel behavior continues to use
123
+ `aria-selected` with its `tablist` and `aria-controls` targets.
124
+
125
+ CoCreate links selection controls that reference the same `aria-controls` target.
126
+ Clicking a custom radio clears linked pressed/checked controls; activating a
127
+ linked toggle clears the radios while preserving other toggles. Mark a radio
128
+ with `aria-default="true"` (or an empty `aria-default`) to select it when the
129
+ last toggle is cleared. Without a default, all controls may remain unselected.
130
+ `aria-default="false"` disables fallback; disabled radios are not eligible.
131
+ If multiple eligible defaults are declared, no fallback is selected.
132
+ `aria-checked` describes current selection independently of this default.
133
+ `aria-default` is a CoCreate extension, not a standard ARIA attribute.
134
+ This is CoCreate behavior, not native ARIA grouping. Tabs and disclosure
135
+ controls remain separate, and the target's visibility is unchanged.
136
+
137
+ Use `aria-default="next"` for a moving default. Its initial radio is the
138
+ starting fallback. Selecting another radio sharing the controlled target
139
+ removes the marker from the previous radio and places it on the selected one.
140
+ "Next" means the next radio selected by the user, including keyboard activation,
141
+ not the next radio in DOM order. Pressed buttons and checked toggles never
142
+ receive or move this marker. Clearing the last toggle returns to the radio
143
+ currently carrying it. A fixed `aria-default="true"` does not move.
144
+ Declare one default per linked set; use either a fixed or a moving default.
145
+ The marker lives in DOM attributes and is not automatically persisted across
146
+ reloads. Direct changes to `aria-checked` do not transfer it.
147
+
148
+ ```html
149
+ <div role="group" aria-label="Results mode">
150
+ <div role="radiogroup" aria-label="Preset">
151
+ <button role="radio" aria-checked="true" aria-controls="results" aria-default="next">All</button>
152
+ <button role="radio" aria-checked="false" aria-controls="results">Recommended</button>
153
+ </div>
154
+ <button aria-pressed="false" aria-controls="results">Storage</button>
155
+ <button aria-pressed="false" aria-controls="results">Cloud</button>
156
+ </div>
157
+ <div id="results"></div>
158
+ ```
159
+
160
+ Native `input[type="radio"]` and `input[type="checkbox"]` with `aria-controls`
161
+ also participate in linked selection and fixed/moving defaults. They use their
162
+ native `checked` property and keyboard behavior, without redundant `aria-checked`
163
+ or `aria-pressed` attributes. When coordination changes another native input,
164
+ CoCreate dispatches `input` and `change` after the linked values are updated;
165
+ unselected radios do not dispatch these notifications.
166
+
167
+ ## Multiselectable grids
168
+
169
+ An element with `role="grid" aria-multiselectable="true"` scopes selection to
170
+ its descendant rows. Mark selectable rows with `role="row"` and
171
+ `aria-selected="false"`; include a `gridcell` in each row. Native `table`, `tr`,
172
+ and `td` elements provide the corresponding row and cell structure. The module
173
+ sets one row in the grid's tab sequence and leaves selection on the row's
174
+ `aria-selected` attribute so other actions can query it directly.
175
+
176
+ ```html
177
+ <div role="grid" aria-label="Files" aria-multiselectable="true">
178
+ <div role="row" aria-selected="false">
179
+ <div role="gridcell">Document A</div>
180
+ </div>
181
+ <div role="row" aria-selected="false">
182
+ <div role="gridcell">Document B</div>
183
+ </div>
184
+ </div>
185
+ ```
186
+
187
+ Click selects one row; Control/Command-click toggles one row; Shift-click
188
+ selects a range; and Control/Command-Shift-click adds a range. Arrow keys and
189
+ Home/End move focus without changing selection. Space toggles the focused row,
190
+ Shift with an arrow extends selection, Control/Command-A selects the loaded
191
+ rows, and Escape clears them. These interactions do not activate links or other
192
+ controls inside a row. Selection actions are scoped to the nearest grid.
193
+
194
+ A grid row can instead contain a native checkbox. Its own `checked` state is
195
+ the selection state; the row does not need `aria-selected`. Checkbox clicks
196
+ toggle independently, including Control/Command-click. Shift-click applies
197
+ the clicked checkbox's new state to the range since the last checkbox click.
198
+ Checkboxes with the same `name` form a range within one grid. CoCreate Aria
199
+ does not synchronize checkbox `checked` with row `aria-selected`; an app can
200
+ bind them explicitly when it needs both.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/aria",
3
- "version": "1.5.0",
3
+ "version": "1.8.0",
4
4
  "description": "Orchestrate dynamic UI behavior and ARIA state with event-driven action chains, configured via HTML5 attributes or the JavaScript API.",
5
5
  "keywords": [
6
6
  "aria",
@@ -25,7 +25,7 @@
25
25
  },
26
26
  "repository": {
27
27
  "type": "git",
28
- "url": "git+https://github.com/CoCreate-app/CoCreate-aria.git"
28
+ "url": "git+https://gitlab.com/cocreatejs/CoCreate-aria.git"
29
29
  },
30
30
  "author": "CoCreate LLC",
31
31
  "license": "MIT",
@@ -39,10 +39,11 @@
39
39
  },
40
40
  "main": "./src/index.js",
41
41
  "dependencies": {
42
- "@cocreate/observer": "^1.21.0"
42
+ "@cocreate/observer": "^1.23.0",
43
+ "@cocreate/state": "^1.29.0"
43
44
  },
44
45
  "devDependencies": {
45
- "@cocreate/webpack": "^1.7.0"
46
+ "@cocreate/webpack": "^1.9.0"
46
47
  },
47
48
  "allowScripts": {
48
49
  "@cocreate/observer@1.19.0": true,