ember-aria-voyager 0.0.4 → 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 (43) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +58 -13
  3. package/declarations/index.d.ts +10 -3
  4. package/declarations/index.d.ts.map +1 -1
  5. package/declarations/modifiers/-emitter.d.ts +28 -0
  6. package/declarations/modifiers/-emitter.d.ts.map +1 -0
  7. package/declarations/modifiers/aria-listbox.d.ts +25 -0
  8. package/declarations/modifiers/aria-listbox.d.ts.map +1 -0
  9. package/declarations/modifiers/{menu.d.ts → aria-menu.d.ts} +4 -2
  10. package/declarations/modifiers/aria-menu.d.ts.map +1 -0
  11. package/declarations/modifiers/aria-tablist.d.ts +28 -0
  12. package/declarations/modifiers/aria-tablist.d.ts.map +1 -0
  13. package/declarations/template-registry.d.ts +6 -4
  14. package/declarations/template-registry.d.ts.map +1 -1
  15. package/declarations/test-support/-private/-get-element.d.ts.map +1 -1
  16. package/declarations/test-support/-private/-get-elements.d.ts.map +1 -1
  17. package/declarations/test-support/index.d.ts +1 -0
  18. package/declarations/test-support/index.d.ts.map +1 -1
  19. package/declarations/test-support/tablist.d.ts +11 -0
  20. package/declarations/test-support/tablist.d.ts.map +1 -0
  21. package/dist/-emitter-CQPiyyOK.js +47 -0
  22. package/dist/-emitter-CQPiyyOK.js.map +1 -0
  23. package/dist/_app_/modifiers/aria-listbox.js +1 -0
  24. package/dist/_app_/modifiers/aria-menu.js +1 -0
  25. package/dist/_app_/modifiers/aria-tablist.js +1 -0
  26. package/dist/index.js +3 -2
  27. package/dist/index.js.map +1 -1
  28. package/dist/modifiers/{listbox.js → aria-listbox.js} +10 -43
  29. package/dist/modifiers/aria-listbox.js.map +1 -0
  30. package/dist/modifiers/{menu.js → aria-menu.js} +9 -1
  31. package/dist/modifiers/aria-menu.js.map +1 -0
  32. package/dist/modifiers/aria-tablist.js +65 -0
  33. package/dist/modifiers/aria-tablist.js.map +1 -0
  34. package/dist/test-support/index.js +162 -13
  35. package/dist/test-support/index.js.map +1 -1
  36. package/package.json +27 -25
  37. package/declarations/modifiers/listbox.d.ts +0 -44
  38. package/declarations/modifiers/listbox.d.ts.map +0 -1
  39. package/declarations/modifiers/menu.d.ts.map +0 -1
  40. package/dist/_app_/modifiers/listbox.js +0 -1
  41. package/dist/_app_/modifiers/menu.js +0 -1
  42. package/dist/modifiers/listbox.js.map +0 -1
  43. package/dist/modifiers/menu.js.map +0 -1
package/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2024 Thomas Gossmann
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -26,16 +26,16 @@ pnpm add ember-aria-voyager
26
26
 
27
27
  ## Usage
28
28
 
29
- ### `{{listbox}}`
29
+ ### `{{ariaListbox}}`
30
30
 
31
31
  Basic example:
32
32
 
33
33
  ```glimmer-ts
34
- import { listbox } from 'ember-aria-voyager';
34
+ import { ariaListbox } from 'ember-aria-voyager';
35
35
  const options = ['apple', 'banana', 'pineapple'];
36
36
 
37
37
  <template>
38
- <ul role="listbox" {{listbox items=options}}>
38
+ <ul role="listbox" {{ariaListbox items=options}}>
39
39
  {{#each options as |option|}}
40
40
  <li role="option">{{option}}</li>
41
41
  {{/each}}
@@ -43,7 +43,7 @@ const options = ['apple', 'banana', 'pineapple'];
43
43
  </template>
44
44
  ```
45
45
 
46
- Here are the options, you can pass to `{{listbox}}`
46
+ Here are the options, you can pass to `{{ariaListbox}}`
47
47
 
48
48
  ```ts
49
49
  type ListboxSignature<T = HTMLElement> = {
@@ -67,7 +67,7 @@ When passing `items` the `select()` and `selection` can work off of your passed
67
67
  Full example:
68
68
 
69
69
  ```glimmer-ts
70
- import { listbox } from 'ember-aria-voyager';
70
+ import { ariaListbox } from 'ember-aria-voyager';
71
71
  const options = ['apple', 'banana', 'pineapple'];
72
72
  const context = new class {
73
73
  @tracked selection = [options[0]];
@@ -81,7 +81,7 @@ const context = new class {
81
81
  const selection = ['banana'];
82
82
 
83
83
  <template>
84
- <ul role="listbox" {{listbox
84
+ <ul role="listbox" {{ariaListbox
85
85
  items=options
86
86
  multi=true
87
87
  disabled=context.disabled
@@ -95,19 +95,19 @@ const selection = ['banana'];
95
95
  </template>
96
96
  ```
97
97
 
98
- ### `{{menu}}`
98
+ ### `{{ariaMenu}}`
99
99
 
100
100
  Basic example:
101
101
 
102
102
  ```glimmer-ts
103
- import { menu } from 'ember-aria-voyager';
103
+ import { ariaMenu } from 'ember-aria-voyager';
104
104
 
105
105
  <template>
106
- <div role="menu" {{menu}}>
106
+ <div role="menu" {{ariaMenu}}>
107
107
  <button role="menuitem">Version Info</button>
108
108
  <a role="menuitem" href="https://github.com/hokulea/aria-voyager" target="_blank">Github</a>
109
109
  <button role="menuitem" popovertarget="authormenu">Author</button>
110
- <div role="menu" id="authormenu" popover {{menu}}>
110
+ <div role="menu" id="authormenu" popover {{ariaMenu}}>
111
111
  <a role="menuitem" href="https://gos.si" target="_blank">Homepage</a>
112
112
  <a role="menuitem" href="https://github.com" target="_blank">Github</a>
113
113
  </div>
@@ -115,7 +115,7 @@ import { menu } from 'ember-aria-voyager';
115
115
  </template>
116
116
  ```
117
117
 
118
- Here are the options, you can pass to `{{menu}}`
118
+ Here are the options, you can pass to `{{ariaMenu}}`
119
119
 
120
120
  ```ts
121
121
  interface MenuSignature<T> {
@@ -127,7 +127,7 @@ interface MenuSignature<T> {
127
127
  Here is a full example:
128
128
 
129
129
  ```glimmer-ts
130
- import { menu } from 'ember-aria-voyager';
130
+ import { ariaMenu } from 'ember-aria-voyager';
131
131
  const items = [
132
132
  {
133
133
  label: 'Version Info',
@@ -140,7 +140,7 @@ const items = [
140
140
  ];
141
141
 
142
142
  <template>
143
- <div role="menu" {{menu items=items}}>
143
+ <div role="menu" {{ariaMenu items=items}}>
144
144
  {{#each items as |item|}}
145
145
  {{#if item.action}}
146
146
  <button type="button" role="menuitem" {{on "click" item.action}}>{{item.label}}</button>
@@ -153,3 +153,48 @@ const items = [
153
153
  </div>
154
154
  </template>
155
155
  ```
156
+
157
+ ### `{{ariaTablist}}`
158
+
159
+ Basic example:
160
+
161
+ ```glimmer-ts
162
+ import { ariaTablist } from 'ember-aria-voyager';
163
+ const tabs = ['apple', 'banana', 'pineapple'];
164
+
165
+ <template>
166
+ <div>
167
+ <ul role="tablist" {{ariaTablist items=tabs}}>
168
+ {{#each tabs as |tab id|}}
169
+ <li role="tab" id="tab-{{id}}" aria-controls="panel-{{id}}">{{tab}}</li>
170
+ {{/each}}
171
+ </ul>
172
+
173
+ {{#each tabs as |tab id|}}
174
+ <div role="tabpanel" id="panel-{{id}}" aria-labelledby="tab-{{id}}">
175
+ Contents Panel {{tab}}
176
+ </div>
177
+ {{/each}}
178
+ <div>
179
+ </template>
180
+ ```
181
+
182
+ Here are the options, you can pass to `{{ariaTablist}}`
183
+
184
+ ```ts
185
+ import type { EmitStrategy, Orientation, TablistBehavior } from 'aria-voyager';
186
+
187
+ interface TablistSignature<T> {
188
+ Element: HTMLElement;
189
+ Args: {
190
+ Positional: [];
191
+ Named: {
192
+ disabled?: boolean;
193
+ orientation?: Orientation;
194
+ behavior?: TablistBehavior;
195
+ } & EmitterSignature<T>;
196
+ };
197
+ }
198
+ ```
199
+
200
+ When passing `items` the `select()` and `selection` can work off of your passed items, anyway will fall back to the HTMLElement
@@ -1,4 +1,11 @@
1
- import { default as listbox } from './modifiers/listbox';
2
- import { default as menu } from './modifiers/menu';
3
- export { listbox, menu };
1
+ import { default as ariaListbox } from './modifiers/aria-listbox';
2
+ import { default as ariaMenu } from './modifiers/aria-menu';
3
+ import { default as ariaTablist } from './modifiers/aria-tablist';
4
+ export { ariaListbox, ariaMenu, ariaTablist,
5
+ /** @deprecated use `ariaListbox` */
6
+ ariaListbox as listbox,
7
+ /** @deprecated use `ariaMenu` */
8
+ ariaMenu as menu,
9
+ /** @deprecated use `ariaTablist` */
10
+ ariaTablist as tablist };
4
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,EACL,WAAW,EACX,QAAQ,EACR,WAAW;AACX,oCAAoC;AACpC,WAAW,IAAI,OAAO;AACtB,iCAAiC;AACjC,QAAQ,IAAI,IAAI;AAChB,oCAAoC;AACpC,WAAW,IAAI,OAAO,EACvB,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { type Control, IndexEmitStrategy, ItemEmitStrategy } from 'aria-voyager';
2
+ export declare function asArray(val?: unknown): any[];
3
+ export type WithItems<T> = {
4
+ items: T[];
5
+ selection?: T | T[];
6
+ activateItem?: (item: T) => void;
7
+ } & ({
8
+ multi: true;
9
+ select?: (selection: T[]) => void;
10
+ } | {
11
+ multi?: false;
12
+ select?: (selection: T) => void;
13
+ });
14
+ export type OptionalItems = {
15
+ items?: HTMLElement[];
16
+ selection?: HTMLElement | HTMLElement[];
17
+ activateItem?: (item: HTMLElement) => void;
18
+ } & ({
19
+ multi: true;
20
+ select?: (selection: HTMLElement[]) => void;
21
+ } | {
22
+ multi?: false;
23
+ select?: (selection: HTMLElement) => void;
24
+ });
25
+ export type EmitterSignature<T> = WithItems<T> | OptionalItems;
26
+ export declare function createItemEmitter<T>(control: Control, options: EmitterSignature<T>): ItemEmitStrategy;
27
+ export declare function createIndexEmitter<T>(control: Control, options: EmitterSignature<T>): IndexEmitStrategy;
28
+ //# sourceMappingURL=-emitter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"-emitter.d.ts","sourceRoot":"","sources":["../../src/modifiers/-emitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEjF,wBAAgB,OAAO,CAAC,GAAG,CAAC,EAAE,OAAO,SAOpC;AAED,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI;IACzB,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,SAAS,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;IACpB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;CAClC,GAAG,CACA;IACE,KAAK,EAAE,IAAI,CAAC;IACZ,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;CACnC,GACD;IACE,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,KAAK,IAAI,CAAC;CACjC,CACJ,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,CAAC,EAAE,WAAW,EAAE,CAAC;IACtB,SAAS,CAAC,EAAE,WAAW,GAAG,WAAW,EAAE,CAAC;IACxC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;CAC5C,GAAG,CACA;IACE,KAAK,EAAE,IAAI,CAAC;IACZ,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,WAAW,EAAE,KAAK,IAAI,CAAC;CAC7C,GACD;IACE,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,WAAW,KAAK,IAAI,CAAC;CAC3C,CACJ,CAAC;AAEF,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC;AAE/D,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,oBAYlF;AAED,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,qBA8BnF"}
@@ -0,0 +1,25 @@
1
+ import Modifier from 'ember-modifier';
2
+ import { type EmitterSignature } from './-emitter';
3
+ import type Owner from '@ember/owner';
4
+ import type { ArgsFor, NamedArgs, PositionalArgs } from 'ember-modifier';
5
+ interface ListboxSignature<T> {
6
+ Args: {
7
+ Positional: [];
8
+ Named: {
9
+ disabled?: boolean;
10
+ } & EmitterSignature<T>;
11
+ };
12
+ }
13
+ export default class ListboxModifier<T> extends Modifier<ListboxSignature<T>> {
14
+ private listbox?;
15
+ private updater;
16
+ private emitter;
17
+ private prevItems?;
18
+ private prevSelection?;
19
+ private prevMulti?;
20
+ private prevDisabled?;
21
+ constructor(owner: Owner, args: ArgsFor<ListboxSignature<T>>);
22
+ modify(element: Element, _: PositionalArgs<ListboxSignature<T>>, options: NamedArgs<ListboxSignature<T>>): void;
23
+ }
24
+ export {};
25
+ //# sourceMappingURL=aria-listbox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aria-listbox.d.ts","sourceRoot":"","sources":["../../src/modifiers/aria-listbox.ts"],"names":[],"mappings":"AAGA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAGtC,OAAO,EAIL,KAAK,gBAAgB,EAEtB,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEzE,UAAU,gBAAgB,CAAC,CAAC;IAC1B,IAAI,EAAE;QACJ,UAAU,EAAE,EAAE,CAAC;QACf,KAAK,EAAE;YAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;SAAE,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;KACrD,CAAC;CACH;AAED,MAAM,CAAC,OAAO,OAAO,eAAe,CAAC,CAAC,CAAE,SAAQ,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAC3E,OAAO,CAAC,OAAO,CAAC,CAAU;IAC1B,QAAgB,OAAO,CAAyB;IAChD,QAAgB,OAAO,CAAe;IAEtC,OAAO,CAAC,SAAS,CAAC,CAAM;IACxB,OAAO,CAAC,aAAa,CAAC,CAAU;IAChC,OAAO,CAAC,SAAS,CAAC,CAAU;IAC5B,OAAO,CAAC,YAAY,CAAC,CAAU;gBAEnB,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAS5D,MAAM,CACJ,OAAO,EAAE,OAAO,EAChB,CAAC,EAAE,cAAc,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,EACtC,OAAO,EAAE,SAAS,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;CAwD1C"}
@@ -1,5 +1,6 @@
1
1
  import Modifier from 'ember-modifier';
2
- import type { NamedArgs, PositionalArgs } from 'ember-modifier';
2
+ import type Owner from '@ember/owner';
3
+ import type { ArgsFor, NamedArgs, PositionalArgs } from 'ember-modifier';
3
4
  export interface MenuSignature<T> {
4
5
  Element: HTMLElement;
5
6
  Args: {
@@ -16,6 +17,7 @@ export default class MenuModifier<T> extends Modifier<MenuSignature<T>> {
16
17
  private emitter;
17
18
  private prevItems?;
18
19
  private prevDisabled?;
20
+ constructor(owner: Owner, args: ArgsFor<MenuSignature<T>>);
19
21
  modify(element: Element, _: PositionalArgs<MenuSignature<T>>, options: NamedArgs<MenuSignature<T>>): void;
20
22
  }
21
- //# sourceMappingURL=menu.d.ts.map
23
+ //# sourceMappingURL=aria-menu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aria-menu.d.ts","sourceRoot":"","sources":["../../src/modifiers/aria-menu.ts"],"names":[],"mappings":"AAGA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAGtC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEzE,MAAM,WAAW,aAAa,CAAC,CAAC;IAC9B,OAAO,EAAE,WAAW,CAAC;IACrB,IAAI,EAAE;QACJ,UAAU,EAAE,EAAE,CAAC;QACf,KAAK,EAAE;YACL,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;YACZ,QAAQ,CAAC,EAAE,OAAO,CAAC;SACpB,CAAC;KACH,CAAC;CACH;AAED,MAAM,CAAC,OAAO,OAAO,YAAY,CAAC,CAAC,CAAE,SAAQ,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IACrE,OAAO,CAAC,IAAI,CAAC,CAAO;IACpB,QAAgB,OAAO,CAAyB;IAChD,QAAgB,OAAO,CAAe;IAEtC,OAAO,CAAC,SAAS,CAAC,CAAM;IACxB,OAAO,CAAC,YAAY,CAAC,CAAU;gBAEnB,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IASzD,MAAM,CACJ,OAAO,EAAE,OAAO,EAChB,CAAC,EAAE,cAAc,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EACnC,OAAO,EAAE,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;CAiCvC"}
@@ -0,0 +1,28 @@
1
+ import Modifier from 'ember-modifier';
2
+ import { type EmitterSignature } from './-emitter';
3
+ import type Owner from '@ember/owner';
4
+ import type { Orientation, TablistBehavior } from 'aria-voyager';
5
+ import type { ArgsFor, NamedArgs, PositionalArgs } from 'ember-modifier';
6
+ export interface TablistSignature<T> {
7
+ Element: HTMLElement;
8
+ Args: {
9
+ Positional: [];
10
+ Named: {
11
+ disabled?: boolean;
12
+ orientation?: Orientation;
13
+ behavior?: TablistBehavior;
14
+ } & EmitterSignature<T>;
15
+ };
16
+ }
17
+ export default class TablistModifier<T> extends Modifier<TablistSignature<T>> {
18
+ private tablist?;
19
+ private updater;
20
+ private emitter;
21
+ private prevItems?;
22
+ private prevSelection?;
23
+ private prevDisabled?;
24
+ private prevOrientation?;
25
+ constructor(owner: Owner, args: ArgsFor<TablistSignature<T>>);
26
+ modify(element: Element, _: PositionalArgs<TablistSignature<T>>, options: NamedArgs<TablistSignature<T>>): void;
27
+ }
28
+ //# sourceMappingURL=aria-tablist.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aria-tablist.d.ts","sourceRoot":"","sources":["../../src/modifiers/aria-tablist.ts"],"names":[],"mappings":"AAGA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAGtC,OAAO,EAIL,KAAK,gBAAgB,EAEtB,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,EAAgB,WAAW,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/E,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEzE,MAAM,WAAW,gBAAgB,CAAC,CAAC;IACjC,OAAO,EAAE,WAAW,CAAC;IACrB,IAAI,EAAE;QACJ,UAAU,EAAE,EAAE,CAAC;QACf,KAAK,EAAE;YACL,QAAQ,CAAC,EAAE,OAAO,CAAC;YACnB,WAAW,CAAC,EAAE,WAAW,CAAC;YAC1B,QAAQ,CAAC,EAAE,eAAe,CAAC;SAC5B,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;KACzB,CAAC;CACH;AAED,MAAM,CAAC,OAAO,OAAO,eAAe,CAAC,CAAC,CAAE,SAAQ,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAC3E,OAAO,CAAC,OAAO,CAAC,CAAU;IAC1B,QAAgB,OAAO,CAAyB;IAChD,QAAgB,OAAO,CAAe;IAEtC,OAAO,CAAC,SAAS,CAAC,CAAM;IACxB,OAAO,CAAC,aAAa,CAAC,CAAU;IAChC,OAAO,CAAC,YAAY,CAAC,CAAU;IAC/B,OAAO,CAAC,eAAe,CAAC,CAAc;gBAE1B,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAS5D,MAAM,CACJ,OAAO,EAAE,OAAO,EAChB,CAAC,EAAE,cAAc,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,EACtC,OAAO,EAAE,SAAS,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;CA2D1C"}
@@ -1,7 +1,9 @@
1
- import type listbox from './modifiers/listbox';
2
- import type menu from './modifiers/menu';
1
+ import type listbox from './modifiers/aria-listbox';
2
+ import type menu from './modifiers/aria-menu';
3
+ import type tablist from './modifiers/aria-tablist';
3
4
  export default interface AriaVoyagerRegistry {
4
- listbox: typeof listbox;
5
- menu: typeof menu;
5
+ 'aria-listbox': typeof listbox;
6
+ 'aria-menu': typeof menu;
7
+ 'aria-tablist': typeof tablist;
6
8
  }
7
9
  //# sourceMappingURL=template-registry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"template-registry.d.ts","sourceRoot":"","sources":["../src/template-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,qBAAqB,CAAC;AAC/C,OAAO,KAAK,IAAI,MAAM,kBAAkB,CAAC;AAEzC,MAAM,CAAC,OAAO,WAAW,mBAAmB;IAC1C,OAAO,EAAE,OAAO,OAAO,CAAC;IACxB,IAAI,EAAE,OAAO,IAAI,CAAC;CACnB"}
1
+ {"version":3,"file":"template-registry.d.ts","sourceRoot":"","sources":["../src/template-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,0BAA0B,CAAC;AACpD,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAC;AAC9C,OAAO,KAAK,OAAO,MAAM,0BAA0B,CAAC;AAEpD,MAAM,CAAC,OAAO,WAAW,mBAAmB;IAE1C,cAAc,EAAE,OAAO,OAAO,CAAC;IAE/B,WAAW,EAAE,OAAO,IAAI,CAAC;IAEzB,cAAc,EAAE,OAAO,OAAO,CAAC;CAChC"}
@@ -1 +1 @@
1
- {"version":3,"file":"-get-element.d.ts","sourceRoot":"","sources":["../../../src/test-support/-private/-get-element.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,qBAAqB,EAG3B,MAAM,yBAAyB,CAAC;AAIjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,iBAAS,UAAU,CAAC,CAAC,SAAS,MAAM,CAAC,qBAAqB,GAAG,oBAAoB,CAAC,EAChF,MAAM,EAAE,CAAC,GACR,CAAC,qBAAqB,CAAC,CAAC,CAAC,GAAG,oBA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,CAAC,GACR,oBAAoB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;AAClC,iBAAS,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,qBAAqB,GAAG,OAAO,GAAG,IAAI,CAAC;AAC5E,iBAAS,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC;AAC9C,iBAAS,UAAU,CAAC,MAAM,EAAE,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAC;AACzD,iBAAS,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,IAAI,CAAC;AA6B/D,eAAe,UAAU,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"-get-elements.d.ts","sourceRoot":"","sources":["../../../src/test-support/-private/-get-elements.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,qBAAqB,EAG3B,MAAM,yBAAyB,CAAC;AAEjC,iBAAS,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;AAC1D,iBAAS,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,qBAAqB,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;AA0BhF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"-get-elements.d.ts","sourceRoot":"","sources":["../../../src/test-support/-private/-get-elements.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,qBAAqB,EAG3B,MAAM,yBAAyB,CAAC;AAEjC,iBAAS,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;AAC1D,iBAAS,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,qBAAqB,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;AA2BhF,eAAe,WAAW,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export * from './listbox';
2
2
  export * from './menu';
3
+ export * from './tablist';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test-support/index.ts"],"names":[],"mappings":"AAEA,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test-support/index.ts"],"names":[],"mappings":"AAEA,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC"}
@@ -0,0 +1,11 @@
1
+ type Selectors = {
2
+ tablist: string;
3
+ item: string;
4
+ };
5
+ export declare function testTablistKeyboardNavigation(assert: Assert, selectors?: Partial<Selectors>): Promise<void>;
6
+ export declare function testTablistKeyboardAutomaticSelection(assert: Assert, selectors?: Partial<Selectors>): Promise<void>;
7
+ export declare function testTablistKeyboardManualSelection(assert: Assert, selectors?: Partial<Selectors>): Promise<void>;
8
+ export declare function testTablistPointerNavigation(assert: Assert, selectors?: Partial<Selectors>): Promise<void>;
9
+ export declare function testTablistPointerSelection(assert: Assert, selectors?: Partial<Selectors>): Promise<void>;
10
+ export {};
11
+ //# sourceMappingURL=tablist.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tablist.d.ts","sourceRoot":"","sources":["../../src/test-support/tablist.ts"],"names":[],"mappings":"AAIA,KAAK,SAAS,GAAG;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAgCF,wBAAsB,6BAA6B,CACjD,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,OAAO,CAAC,SAAS,CAAqB,GAChD,OAAO,CAAC,IAAI,CAAC,CA6Bf;AAED,wBAAsB,qCAAqC,CACzD,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,OAAO,CAAC,SAAS,CAAqB,GAChD,OAAO,CAAC,IAAI,CAAC,CAqBf;AAED,wBAAsB,kCAAkC,CACtD,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,OAAO,CAAC,SAAS,CAAqB,GAChD,OAAO,CAAC,IAAI,CAAC,CAmCf;AAMD,wBAAsB,4BAA4B,CAChD,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,OAAO,CAAC,SAAS,CAAqB,GAChD,OAAO,CAAC,IAAI,CAAC,CAef;AAED,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,OAAO,CAAC,SAAS,CAAqB,GAChD,OAAO,CAAC,IAAI,CAAC,CAmBf"}
@@ -0,0 +1,47 @@
1
+ import { ItemEmitStrategy, IndexEmitStrategy } from 'aria-voyager';
2
+
3
+ function asArray(val) {
4
+ if (val === undefined) {
5
+ return [];
6
+ }
7
+
8
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
9
+ return Array.isArray(val) ? val : [val];
10
+ }
11
+ function createItemEmitter(control, options) {
12
+ return new ItemEmitStrategy(control, {
13
+ select: selection => {
14
+ options.select?.(options.multi ? selection : selection[0]);
15
+ },
16
+ activateItem: item => {
17
+ options.activateItem?.(item);
18
+ }
19
+ });
20
+ }
21
+ function createIndexEmitter(control, options) {
22
+ const findByIndex = index => {
23
+ return options.items[index] ?? undefined;
24
+ };
25
+ return new IndexEmitStrategy(control, {
26
+ select: selection => {
27
+ if (options.multi) {
28
+ const items = selection.map(index => findByIndex(index)).filter(i => i !== undefined);
29
+ options.select?.(items);
30
+ } else {
31
+ const item = findByIndex(selection[0]);
32
+ if (item) {
33
+ options.select?.(item);
34
+ }
35
+ }
36
+ },
37
+ activateItem: index => {
38
+ const item = findByIndex(index);
39
+ if (item) {
40
+ options.activateItem?.(item);
41
+ }
42
+ }
43
+ });
44
+ }
45
+
46
+ export { createItemEmitter as a, asArray as b, createIndexEmitter as c };
47
+ //# sourceMappingURL=-emitter-CQPiyyOK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"-emitter-CQPiyyOK.js","sources":["../src/modifiers/-emitter.ts"],"sourcesContent":["import { type Control, IndexEmitStrategy, ItemEmitStrategy } from 'aria-voyager';\n\nexport function asArray(val?: unknown) {\n if (val === undefined) {\n return [];\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return Array.isArray(val) ? val : [val];\n}\n\nexport type WithItems<T> = {\n items: T[];\n selection?: T | T[];\n activateItem?: (item: T) => void;\n} & (\n | {\n multi: true;\n select?: (selection: T[]) => void;\n }\n | {\n multi?: false;\n select?: (selection: T) => void;\n }\n);\n\nexport type OptionalItems = {\n items?: HTMLElement[];\n selection?: HTMLElement | HTMLElement[];\n activateItem?: (item: HTMLElement) => void;\n} & (\n | {\n multi: true;\n select?: (selection: HTMLElement[]) => void;\n }\n | {\n multi?: false;\n select?: (selection: HTMLElement) => void;\n }\n);\n\nexport type EmitterSignature<T> = WithItems<T> | OptionalItems;\n\nexport function createItemEmitter<T>(control: Control, options: EmitterSignature<T>) {\n return new ItemEmitStrategy(control, {\n select: (selection: HTMLElement[]) => {\n (options.select as ((selection: HTMLElement | HTMLElement[]) => void) | undefined)?.(\n options.multi ? selection : (selection[0] as HTMLElement)\n );\n },\n\n activateItem: (item: HTMLElement) => {\n (options.activateItem as ((item: HTMLElement) => void) | undefined)?.(item);\n }\n });\n}\n\nexport function createIndexEmitter<T>(control: Control, options: EmitterSignature<T>) {\n const findByIndex = (index: number) => {\n return (options as WithItems<T>).items[index] ?? undefined;\n };\n\n return new IndexEmitStrategy(control, {\n select: (selection: number[]) => {\n if (options.multi) {\n const items = selection\n .map((index) => findByIndex(index))\n .filter((i) => i !== undefined) as T[];\n\n (options.select as ((selection: T[]) => void) | undefined)?.(items);\n } else {\n const item = findByIndex(selection[0] as number);\n\n if (item) {\n (options.select as ((selection: T) => void) | undefined)?.(item);\n }\n }\n },\n\n activateItem: (index: number) => {\n const item = findByIndex(index);\n\n if (item) {\n (options.activateItem as ((item: T) => void) | undefined)?.(item);\n }\n }\n });\n}\n"],"names":["asArray","val","undefined","Array","isArray","createItemEmitter","control","options","ItemEmitStrategy","select","selection","multi","activateItem","item","createIndexEmitter","findByIndex","index","items","IndexEmitStrategy","map","filter","i"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AO,CAACE,MAAM,GAA4CI,IAAI,CAAC;AAClE;AACF;KACD;IAEDD,YAAY,EAAGI,KAAa,IAAK;AAC/B,MAAA,MAAMH,IAAI,GAAGE,WAAW,CAACC,KAAK,CAAC;AAE/B,MAAA,IAAIH,IAAI,EAAE;AACPN,QAAAA,OAAO,CAACK,YAAY,GAAuCC,IAAI,CAAC;AACnE;AACF;AACF,GAAC,CAAC;AACJ;;;;"}
@@ -0,0 +1 @@
1
+ export { default } from "ember-aria-voyager/modifiers/aria-listbox";
@@ -0,0 +1 @@
1
+ export { default } from "ember-aria-voyager/modifiers/aria-menu";
@@ -0,0 +1 @@
1
+ export { default } from "ember-aria-voyager/modifiers/aria-tablist";
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
- export { default as listbox } from './modifiers/listbox.js';
2
- export { default as menu } from './modifiers/menu.js';
1
+ export { default as ariaListbox, default as listbox } from './modifiers/aria-listbox.js';
2
+ export { default as ariaMenu, default as menu } from './modifiers/aria-menu.js';
3
+ export { default as ariaTablist, default as tablist } from './modifiers/aria-tablist.js';
3
4
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -1,50 +1,17 @@
1
+ import { registerDestructor } from '@ember/destroyable';
1
2
  import { ReactiveUpdateStrategy, Listbox, IndexEmitStrategy, ItemEmitStrategy } from 'aria-voyager';
2
3
  import Modifier from 'ember-modifier';
3
4
  import isEqual from 'lodash.isequal';
5
+ import { c as createIndexEmitter, a as createItemEmitter, b as asArray } from '../-emitter-CQPiyyOK.js';
4
6
 
5
- function asArray(val) {
6
- if (val === undefined) {
7
- return [];
8
- }
9
-
10
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
11
- return Array.isArray(val) ? val : [val];
12
- }
13
- function createItemEmitter(listbox, options) {
14
- return new ItemEmitStrategy(listbox, {
15
- select: selection => {
16
- options.select?.(options.multi ? selection : selection[0]);
17
- },
18
- activateItem: item => {
19
- options.activateItem?.(item);
20
- }
21
- });
22
- }
23
- function createIndexEmitter(listbox, options) {
24
- const findByIndex = index => {
25
- return options.items[index] ?? undefined;
26
- };
27
- return new IndexEmitStrategy(listbox, {
28
- select: selection => {
29
- if (options.multi) {
30
- const items = selection.map(index => findByIndex(index)).filter(i => i !== undefined);
31
- options.select?.(items);
32
- } else {
33
- const item = findByIndex(selection[0]);
34
- if (item) {
35
- options.select?.(item);
36
- }
37
- }
38
- },
39
- activateItem: index => {
40
- const item = findByIndex(index);
41
- if (item) {
42
- options.activateItem?.(item);
43
- }
44
- }
45
- });
46
- }
47
7
  class ListboxModifier extends Modifier {
8
+ constructor(owner, args) {
9
+ super(owner, args);
10
+ registerDestructor(this, () => {
11
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
12
+ this.listbox?.dispose();
13
+ });
14
+ }
48
15
  modify(element, _, options) {
49
16
  if (!this.listbox) {
50
17
  this.updater = new ReactiveUpdateStrategy();
@@ -91,4 +58,4 @@ class ListboxModifier extends Modifier {
91
58
  }
92
59
 
93
60
  export { ListboxModifier as default };
94
- //# sourceMappingURL=listbox.js.map
61
+ //# sourceMappingURL=aria-listbox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aria-listbox.js","sources":["../../src/modifiers/aria-listbox.ts"],"sourcesContent":["import { registerDestructor } from '@ember/destroyable';\n\nimport { IndexEmitStrategy, ItemEmitStrategy, Listbox, ReactiveUpdateStrategy } from 'aria-voyager';\nimport Modifier from 'ember-modifier';\nimport isEqual from 'lodash.isequal';\n\nimport {\n asArray,\n createIndexEmitter,\n createItemEmitter,\n type EmitterSignature,\n type WithItems\n} from './-emitter';\n\nimport type Owner from '@ember/owner';\nimport type { EmitStrategy } from 'aria-voyager';\nimport type { ArgsFor, NamedArgs, PositionalArgs } from 'ember-modifier';\n\ninterface ListboxSignature<T> {\n Args: {\n Positional: [];\n Named: { disabled?: boolean } & EmitterSignature<T>;\n };\n}\n\nexport default class ListboxModifier<T> extends Modifier<ListboxSignature<T>> {\n private listbox?: Listbox;\n declare private updater: ReactiveUpdateStrategy;\n declare private emitter: EmitStrategy;\n\n private prevItems?: T[];\n private prevSelection?: T | T[];\n private prevMulti?: boolean;\n private prevDisabled?: boolean;\n\n constructor(owner: Owner, args: ArgsFor<ListboxSignature<T>>) {\n super(owner, args);\n\n registerDestructor(this, () => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n this.listbox?.dispose();\n });\n }\n\n modify(\n element: Element,\n _: PositionalArgs<ListboxSignature<T>>,\n options: NamedArgs<ListboxSignature<T>>\n ) {\n if (!this.listbox) {\n this.updater = new ReactiveUpdateStrategy();\n\n this.listbox = new Listbox(element as HTMLElement, {\n updater: this.updater\n });\n }\n\n if (options.items && !(this.emitter instanceof IndexEmitStrategy)) {\n this.emitter = createIndexEmitter<T>(this.listbox, options);\n } else if (!options.items && !(this.emitter instanceof ItemEmitStrategy)) {\n this.emitter = createItemEmitter<T>(this.listbox, options);\n }\n\n if (options.items && !isEqual(this.prevItems, (options as WithItems<T>).items)) {\n this.updater.updateItems();\n this.prevItems = [...(options as WithItems<T>).items];\n }\n\n if (options.selection && !isEqual(asArray(this.prevSelection), asArray(options.selection))) {\n this.updater.updateSelection();\n this.prevSelection = asArray(options.selection);\n }\n\n let optionsChanged = false;\n\n if (this.prevMulti !== options.multi) {\n if (options.multi) {\n element.setAttribute('aria-multiselectable', 'true');\n } else {\n element.removeAttribute('aria-multiselectable');\n }\n\n optionsChanged = true;\n\n this.prevMulti = options.multi;\n }\n\n if (this.prevDisabled !== options.disabled) {\n if (options.disabled) {\n element.setAttribute('aria-disabled', 'true');\n } else {\n element.removeAttribute('aria-disabled');\n }\n\n optionsChanged = true;\n\n this.prevDisabled = options.disabled;\n }\n\n if (optionsChanged) {\n this.updater.updateOptions();\n }\n }\n}\n"],"names":["ListboxModifier","Modifier","constructor","owner","args","registerDestructor","listbox","dispose","modify","element","_","options","updater","ReactiveUpdateStrategy","Listbox","items","emitter","IndexEmitStrategy","createIndexEmitter","ItemEmitStrategy","createItemEmitter","isEqual","prevItems","updateItems","selection","asArray","prevSelection","updateSelection","optionsChanged","prevMulti","multi","setAttribute","removeAttribute","prevDisabled","disabled","updateOptions"],"mappings":";;;;;;AAyBe,MAAMA,eAAe,SAAYC,QAAQ,CAAsB;AAU5EC,EAAAA,WAAWA,CAACC,KAAY,EAAEC,IAAkC,EAAE;AAC5D,IAAA,KAAK,CAACD,KAAK,EAAEC,IAAI,CAAC;IAElBC,kBAAkB,CAAC,IAAI,EAAE,MAAM;AAC7B;AACA,MAAA,IAAI,CAACC,OAAO,EAAEC,OAAO,EAAE;AACzB,KAAC,CAAC;AACJ;AAEAC,EAAAA,MAAMA,CACJC,OAAgB,EAChBC,CAAsC,EACtCC,OAAuC,EACvC;AACA,IAAA,IAAI,CAAC,IAAI,CAACL,OAAO,EAAE;AACjB,MAAA,IAAI,CAACM,OAAO,GAAG,IAAIC,sBAAsB,EAAE;AAE3C,MAAA,IAAI,CAACP,OAAO,GAAG,IAAIQ,OAAO,CAACL,OAAO,EAAiB;QACjDG,OAAO,EAAE,IAAI,CAACA;AAChB,OAAC,CAAC;AACJ;IAEA,IAAID,OAAO,CAACI,KAAK,IAAI,EAAE,IAAI,CAACC,OAAO,YAAYC,iBAAiB,CAAC,EAAE;MACjE,IAAI,CAACD,OAAO,GAAGE,kBAAkB,CAAI,IAAI,CAACZ,OAAO,EAAEK,OAAO,CAAC;AAC7D,KAAC,MAAM,IAAI,CAACA,OAAO,CAACI,KAAK,IAAI,EAAE,IAAI,CAACC,OAAO,YAAYG,gBAAgB,CAAC,EAAE;MACxE,IAAI,CAACH,OAAO,GAAGI,iBAAiB,CAAI,IAAI,CAACd,OAAO,EAAEK,OAAO,CAAC;AAC5D;AAEA,IAAA,IAAIA,OAAO,CAACI,KAAK,IAAI,CAACM,OAAO,CAAC,IAAI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IAAI,CAAChB,OAAO,CAACuB,aAAa,EAAE;AAC9B;AACF;AACF;;;;"}
@@ -1,8 +1,16 @@
1
+ import { registerDestructor } from '@ember/destroyable';
1
2
  import { ReactiveUpdateStrategy, Menu } from 'aria-voyager';
2
3
  import Modifier from 'ember-modifier';
3
4
  import isEqual from 'lodash.isequal';
4
5
 
5
6
  class MenuModifier extends Modifier {
7
+ constructor(owner, args) {
8
+ super(owner, args);
9
+ registerDestructor(this, () => {
10
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
11
+ this.menu?.dispose();
12
+ });
13
+ }
6
14
  modify(element, _, options) {
7
15
  if (!this.menu) {
8
16
  this.updater = new ReactiveUpdateStrategy();
@@ -31,4 +39,4 @@ class MenuModifier extends Modifier {
31
39
  }
32
40
 
33
41
  export { MenuModifier as default };
34
- //# sourceMappingURL=menu.js.map
42
+ //# sourceMappingURL=aria-menu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aria-menu.js","sources":["../../src/modifiers/aria-menu.ts"],"sourcesContent":["import { registerDestructor } from '@ember/destroyable';\n\nimport { Menu, ReactiveUpdateStrategy } from 'aria-voyager';\nimport Modifier from 'ember-modifier';\nimport isEqual from 'lodash.isequal';\n\nimport type Owner from '@ember/owner';\nimport type { EmitStrategy } from 'aria-voyager';\nimport type { ArgsFor, NamedArgs, PositionalArgs } from 'ember-modifier';\n\nexport interface MenuSignature<T> {\n Element: HTMLElement;\n Args: {\n Positional: [];\n Named: {\n items?: T[];\n disabled?: boolean;\n };\n };\n}\n\nexport default class MenuModifier<T> extends Modifier<MenuSignature<T>> {\n private menu?: Menu;\n declare private updater: ReactiveUpdateStrategy;\n declare private emitter: EmitStrategy;\n\n private prevItems?: T[];\n private prevDisabled?: boolean;\n\n constructor(owner: Owner, args: ArgsFor<MenuSignature<T>>) {\n super(owner, args);\n\n registerDestructor(this, () => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n this.menu?.dispose();\n });\n }\n\n modify(\n element: Element,\n _: PositionalArgs<MenuSignature<T>>,\n options: NamedArgs<MenuSignature<T>>\n ) {\n if (!this.menu) {\n this.updater = new ReactiveUpdateStrategy();\n\n this.menu = new Menu(element as HTMLElement, {\n updater: this.updater\n });\n }\n\n if (options.items && !isEqual(this.prevItems, options.items)) {\n this.updater.updateItems();\n this.prevItems = [...options.items];\n }\n\n let optionsChanged = false;\n\n if (this.prevDisabled !== options.disabled) {\n if (options.disabled) {\n element.setAttribute('aria-disabled', 'true');\n } else {\n element.removeAttribute('aria-disabled');\n }\n\n optionsChanged = true;\n\n this.prevDisabled = options.disabled;\n }\n\n if (optionsChanged) {\n this.updater.updateOptions();\n }\n }\n}\n"],"names":["MenuModifier","Modifier","constructor","owner","args","registerDestructor","menu","dispose","modify","element","_","options","updater","ReactiveUpdateStrategy","Menu","items","isEqual","prevItems","updateItems","optionsChanged","prevDisabled","disabled","setAttribute","removeAttribute","updateOptions"],"mappings":";;;;;AAqBe,MAAMA,YAAY,SAAYC,QAAQ,CAAmB;AAQtEC,EAAAA,WAAWA,CAACC,KAAY,EAAEC,IAA+B,EAAE;AACzD,IAAA,KAAK,CAACD,KAAK,EAAEC,IAAI,CAAC;IAElBC,kBAAkB,CAAC,IAAI,EAAE,MAAM;AAC7B;AACA,MAAA,IAAI,CAACC,IAAI,EAAEC,OAAO,EAAE;AACtB,KAAC,CAAC;AACJ;AAEAC,EAAAA,MAAMA,CACJC,OAAgB,EAChBC,CAAmC,EACnCC,OAAoC,EACpC;AACA,IAAA,IAAI,CAAC,IAAI,CAACL,IAAI,EAAE;AACd,MAAA,IAAI,CAACM,OAAO,GAAG,IAAIC,sBAAsB,EAAE;AAE3C,MAAA,IAAI,CAACP,IAAI,GAAG,IAAIQ,IAAI,CAACL,OAAO,EAAiB;QAC3CG,OAAO,EAAE,IAAI,CAACA;AAChB,OAAC,CAAC;AACJ;AAEA,IAAA,IAAID,OAAO,CAACI,KAAK,IAAI,CAACC,OAAO,CAAC,IAAI,CAACC,SAAS,EAAEN,OAAO,CAACI,KAAK,CAAC,EAAE;AAC5D,MAAA,IAAI,CAACH,OAAO,CAACM,WAAW,EAAE;MAC1B,IAAI,CAACD,SAAS,GAAG,CAAC,GAAGN,OAAO,CAACI,KAAK,CAAC;AACrC;IAEA,IAAII,cAAc,GAAG,KAAK;AAE1B,IAAA,IAAI,IAAI,CAACC,YAAY,KAAKT,OAAO,CAACU,QAAQ,EAAE;MAC1C,IAAIV,OAAO,CAACU,QAAQ,EAAE;AACpBZ,QAAAA,OAAO,CAACa,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC;AAC/C,OAAC,MAAM;AACLb,QAAAA,OAAO,CAACc,eAAe,CAAC,eAAe,CAAC;AAC1C;AAEAJ,MAAAA,cAAc,GAAG,IAAI;AAErB,MAAA,IAAI,CAACC,YAAY,GAAGT,OAAO,CAACU,QAAQ;AACtC;AAEA,IAAA,IAAIF,cAAc,EAAE;AAClB,MAAA,IAAI,CAACP,OAAO,CAACY,aAAa,EAAE;AAC9B;AACF;AACF;;;;"}
@@ -0,0 +1,65 @@
1
+ import { registerDestructor } from '@ember/destroyable';
2
+ import { ReactiveUpdateStrategy, Tablist, IndexEmitStrategy, ItemEmitStrategy } from 'aria-voyager';
3
+ import Modifier from 'ember-modifier';
4
+ import isEqual from 'lodash.isequal';
5
+ import { c as createIndexEmitter, a as createItemEmitter, b as asArray } from '../-emitter-CQPiyyOK.js';
6
+
7
+ class TablistModifier extends Modifier {
8
+ constructor(owner, args) {
9
+ super(owner, args);
10
+ registerDestructor(this, () => {
11
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
12
+ this.tablist?.dispose();
13
+ });
14
+ }
15
+ modify(element, _, options) {
16
+ if (!this.tablist) {
17
+ this.updater = new ReactiveUpdateStrategy();
18
+ this.tablist = new Tablist(element, {
19
+ updater: this.updater,
20
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
21
+ behavior: options.behavior
22
+ });
23
+ }
24
+ if (options.items && !(this.emitter instanceof IndexEmitStrategy)) {
25
+ this.emitter = createIndexEmitter(this.tablist, options);
26
+ } else if (!options.items && !(this.emitter instanceof ItemEmitStrategy)) {
27
+ this.emitter = createItemEmitter(this.tablist, options);
28
+ }
29
+ if (options.items && !isEqual(this.prevItems, options.items)) {
30
+ this.updater.updateItems();
31
+ this.prevItems = [...options.items];
32
+ }
33
+ if (options.selection && !isEqual(asArray(this.prevSelection), asArray(options.selection))) {
34
+ this.updater.updateSelection();
35
+ this.prevSelection = asArray(options.selection);
36
+ }
37
+ let optionsChanged = false;
38
+ if (this.prevOrientation !== options.orientation) {
39
+ if (options.orientation) {
40
+ element.setAttribute('aria-orientation', options.orientation);
41
+ } else {
42
+ element.removeAttribute('aria-orientation');
43
+ }
44
+ optionsChanged = true;
45
+
46
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
47
+ this.prevOrientation = options.orientation;
48
+ }
49
+ if (this.prevDisabled !== options.disabled) {
50
+ if (options.disabled) {
51
+ element.setAttribute('aria-disabled', 'true');
52
+ } else {
53
+ element.removeAttribute('aria-disabled');
54
+ }
55
+ optionsChanged = true;
56
+ this.prevDisabled = options.disabled;
57
+ }
58
+ if (optionsChanged) {
59
+ this.updater.updateOptions();
60
+ }
61
+ }
62
+ }
63
+
64
+ export { TablistModifier as default };
65
+ //# sourceMappingURL=aria-tablist.js.map