@spectrum-web-components/action-group 0.10.0 → 0.10.1

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.
@@ -4,7 +4,7 @@
4
4
  "modules": [
5
5
  {
6
6
  "kind": "javascript-module",
7
- "path": "sp-action-group.ts",
7
+ "path": "sp-action-group.js",
8
8
  "declarations": [],
9
9
  "exports": [
10
10
  {
@@ -19,7 +19,7 @@
19
19
  },
20
20
  {
21
21
  "kind": "javascript-module",
22
- "path": "src/ActionGroup.ts",
22
+ "path": "src/ActionGroup.js",
23
23
  "declarations": [
24
24
  {
25
25
  "kind": "class",
@@ -376,7 +376,7 @@
376
376
  "name": "ActionGroup",
377
377
  "declaration": {
378
378
  "name": "ActionGroup",
379
- "module": "src/ActionGroup.ts"
379
+ "module": "src/ActionGroup.js"
380
380
  }
381
381
  }
382
382
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-web-components/action-group",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -20,11 +20,24 @@
20
20
  "module": "./src/index.js",
21
21
  "type": "module",
22
22
  "exports": {
23
- ".": "./src/index.js",
24
- "./src/*": "./src/*",
23
+ ".": {
24
+ "development": "./src/index.dev.js",
25
+ "default": "./src/index.js"
26
+ },
25
27
  "./package.json": "./package.json",
26
- "./sp-action-group": "./sp-action-group.js",
27
- "./sp-action-group.js": "./sp-action-group.js"
28
+ "./src/ActionGroup.js": {
29
+ "development": "./src/ActionGroup.dev.js",
30
+ "default": "./src/ActionGroup.js"
31
+ },
32
+ "./src/action-group.css.js": "./src/action-group.css.js",
33
+ "./src/index.js": {
34
+ "development": "./src/index.dev.js",
35
+ "default": "./src/index.js"
36
+ },
37
+ "./sp-action-group.js": {
38
+ "development": "./sp-action-group.dev.js",
39
+ "default": "./sp-action-group.js"
40
+ }
28
41
  },
29
42
  "scripts": {
30
43
  "test": "karma start --coverage"
@@ -45,9 +58,9 @@
45
58
  ],
46
59
  "dependencies": {
47
60
  "@lit-labs/observers": "^1.0.1",
48
- "@spectrum-web-components/action-button": "^0.9.0",
49
- "@spectrum-web-components/base": "^0.5.8",
50
- "@spectrum-web-components/reactive-controllers": "^0.2.4",
61
+ "@spectrum-web-components/action-button": "^0.9.1",
62
+ "@spectrum-web-components/base": "^0.6.0",
63
+ "@spectrum-web-components/reactive-controllers": "^0.2.5",
51
64
  "tslib": "^2.0.0"
52
65
  },
53
66
  "devDependencies": {
@@ -58,5 +71,5 @@
58
71
  "sideEffects": [
59
72
  "./sp-*.js"
60
73
  ],
61
- "gitHead": "3be62133721efba844cd7032566a2c49ed6d9875"
74
+ "gitHead": "50cac779bbb0d6735c2061f1eceb86b9daf9b22b"
62
75
  }
@@ -0,0 +1,3 @@
1
+ import { ActionGroup } from "./src/ActionGroup.dev.js";
2
+ customElements.define("sp-action-group", ActionGroup);
3
+ //# sourceMappingURL=sp-action-group.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["sp-action-group.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { ActionGroup } from './src/ActionGroup.dev.js'\n\ncustomElements.define('sp-action-group', ActionGroup);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-action-group': ActionGroup;\n }\n}\n"],
5
+ "mappings": "AAYA;AAEA,eAAe,OAAO,mBAAmB,WAAW;",
6
+ "names": []
7
+ }
@@ -1,14 +1,3 @@
1
- /*
2
- Copyright 2020 Adobe. All rights reserved.
3
- This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License. You may obtain a copy
5
- of the License at http://www.apache.org/licenses/LICENSE-2.0
6
-
7
- Unless required by applicable law or agreed to in writing, software distributed under
8
- the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- OF ANY KIND, either express or implied. See the License for the specific language
10
- governing permissions and limitations under the License.
11
- */
12
- import { ActionGroup } from './src/ActionGroup.js';
13
- customElements.define('sp-action-group', ActionGroup);
14
- //# sourceMappingURL=sp-action-group.js.map
1
+ import { ActionGroup } from "./src/ActionGroup.js";
2
+ customElements.define("sp-action-group", ActionGroup);
3
+ //# sourceMappingURL=sp-action-group.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"sp-action-group.js","sourceRoot":"","sources":["sp-action-group.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,cAAc,CAAC,MAAM,CAAC,iBAAiB,EAAE,WAAW,CAAC,CAAC","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { ActionGroup } from './src/ActionGroup.js';\n\ncustomElements.define('sp-action-group', ActionGroup);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-action-group': ActionGroup;\n }\n}\n"]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["sp-action-group.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { ActionGroup } from './src/ActionGroup.js';\n\ncustomElements.define('sp-action-group', ActionGroup);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-action-group': ActionGroup;\n }\n}\n"],
5
+ "mappings": "AAYA;AAEA,eAAe,OAAO,mBAAmB,WAAW;",
6
+ "names": []
7
+ }
@@ -0,0 +1,309 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __decorateClass = (decorators, target, key, kind) => {
4
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
+ if (decorator = decorators[i])
7
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
+ if (kind && result)
9
+ __defProp(target, key, result);
10
+ return result;
11
+ };
12
+ import {
13
+ html,
14
+ SpectrumElement
15
+ } from "@spectrum-web-components/base";
16
+ import { property } from "@spectrum-web-components/base/src/decorators.js";
17
+ import { RovingTabindexController } from "@spectrum-web-components/reactive-controllers/src/RovingTabindex.js";
18
+ import { MutationController } from "@lit-labs/observers/mutation_controller.js";
19
+ import styles from "./action-group.css.js";
20
+ const EMPTY_SELECTION = [];
21
+ export class ActionGroup extends SpectrumElement {
22
+ constructor() {
23
+ super();
24
+ this._buttons = [];
25
+ this._buttonSelector = "sp-action-button";
26
+ this.rovingTabindexController = new RovingTabindexController(this, {
27
+ focusInIndex: (elements) => {
28
+ let firstEnabledIndex = -1;
29
+ const firstSelectedIndex = elements.findIndex((el, index) => {
30
+ if (!elements[firstEnabledIndex] && !el.disabled) {
31
+ firstEnabledIndex = index;
32
+ }
33
+ return el.selected && !el.disabled;
34
+ });
35
+ return elements[firstSelectedIndex] ? firstSelectedIndex : firstEnabledIndex;
36
+ },
37
+ elements: () => this.buttons,
38
+ isFocusableElement: (el) => !el.disabled
39
+ });
40
+ this.compact = false;
41
+ this.emphasized = false;
42
+ this.justified = false;
43
+ this.label = "";
44
+ this.quiet = false;
45
+ this.vertical = false;
46
+ this._selected = EMPTY_SELECTION;
47
+ this.manageButtons = () => {
48
+ const slot = this.shadowRoot.querySelector("slot");
49
+ if (!slot)
50
+ return;
51
+ const assignedElements = slot.assignedElements({ flatten: true });
52
+ const buttons = assignedElements.reduce((acc, el) => {
53
+ if (el.matches(this._buttonSelector)) {
54
+ acc.push(el);
55
+ } else {
56
+ const buttonDescendents = Array.from(el.querySelectorAll(`:scope > ${this._buttonSelector}`));
57
+ acc.push(...buttonDescendents);
58
+ }
59
+ return acc;
60
+ }, []);
61
+ this.buttons = buttons;
62
+ const currentlySelectedButtons = [];
63
+ this.buttons.forEach((button) => {
64
+ if (button.selected) {
65
+ currentlySelectedButtons.push(button.value);
66
+ }
67
+ });
68
+ this.setSelected(this.selected.concat(currentlySelectedButtons));
69
+ this.manageChildren();
70
+ this.manageSelects();
71
+ };
72
+ new MutationController(this, {
73
+ config: {
74
+ childList: true,
75
+ subtree: true
76
+ },
77
+ callback: () => {
78
+ this.manageButtons();
79
+ }
80
+ });
81
+ }
82
+ static get styles() {
83
+ return [styles];
84
+ }
85
+ set buttons(tabs) {
86
+ if (tabs === this.buttons)
87
+ return;
88
+ this._buttons = tabs;
89
+ this.rovingTabindexController.clearElementCache();
90
+ }
91
+ get buttons() {
92
+ return this._buttons;
93
+ }
94
+ set selected(selected) {
95
+ this.requestUpdate("selected", this._selected);
96
+ this._selected = selected;
97
+ this.updateComplete.then(() => {
98
+ this.applySelects();
99
+ this.manageChildren();
100
+ });
101
+ }
102
+ get selected() {
103
+ return this._selected;
104
+ }
105
+ dispatchChange(old) {
106
+ const applyDefault = this.dispatchEvent(new Event("change", {
107
+ bubbles: true,
108
+ composed: true,
109
+ cancelable: true
110
+ }));
111
+ if (!applyDefault) {
112
+ this.setSelected(old);
113
+ this.buttons.map((button) => {
114
+ button.selected = this.selected.includes(button.value);
115
+ });
116
+ }
117
+ }
118
+ setSelected(selected, announce) {
119
+ if (selected === this.selected)
120
+ return;
121
+ const old = this.selected;
122
+ this.requestUpdate("selected", old);
123
+ this._selected = selected;
124
+ if (!announce)
125
+ return;
126
+ this.dispatchChange(old);
127
+ }
128
+ focus(options) {
129
+ this.rovingTabindexController.focus(options);
130
+ }
131
+ deselectSelectedButtons() {
132
+ const selected = [
133
+ ...this.querySelectorAll("[selected]")
134
+ ];
135
+ selected.forEach((el) => {
136
+ el.selected = false;
137
+ el.tabIndex = -1;
138
+ el.setAttribute("aria-checked", "false");
139
+ });
140
+ }
141
+ handleClick(event) {
142
+ const target = event.target;
143
+ if (typeof target.value === "undefined") {
144
+ return;
145
+ }
146
+ switch (this.selects) {
147
+ case "single": {
148
+ this.deselectSelectedButtons();
149
+ target.selected = true;
150
+ target.tabIndex = 0;
151
+ target.setAttribute("aria-checked", "true");
152
+ this.setSelected([target.value], true);
153
+ target.focus();
154
+ break;
155
+ }
156
+ case "multiple": {
157
+ const selected = [...this.selected];
158
+ target.selected = !target.selected;
159
+ target.setAttribute("aria-checked", target.selected ? "true" : "false");
160
+ if (target.selected) {
161
+ selected.push(target.value);
162
+ } else {
163
+ selected.splice(this.selected.indexOf(target.value), 1);
164
+ }
165
+ this.setSelected(selected, true);
166
+ this.buttons.forEach((button) => {
167
+ button.tabIndex = -1;
168
+ });
169
+ target.tabIndex = 0;
170
+ break;
171
+ }
172
+ default:
173
+ break;
174
+ }
175
+ }
176
+ async applySelects() {
177
+ await this.manageSelects(true);
178
+ }
179
+ async manageSelects(applied) {
180
+ if (!this.buttons.length) {
181
+ return;
182
+ }
183
+ const options = this.buttons;
184
+ switch (this.selects) {
185
+ case "single": {
186
+ this.setAttribute("role", "radiogroup");
187
+ const selections = [];
188
+ const updates = options.map(async (option) => {
189
+ await option.updateComplete;
190
+ option.setAttribute("role", "radio");
191
+ option.setAttribute("aria-checked", option.selected ? "true" : "false");
192
+ if (option.selected) {
193
+ selections.push(option);
194
+ }
195
+ });
196
+ if (applied)
197
+ break;
198
+ await Promise.all(updates);
199
+ const selected = selections.map((button) => {
200
+ return button.value;
201
+ });
202
+ this.setSelected(selected || EMPTY_SELECTION);
203
+ break;
204
+ }
205
+ case "multiple": {
206
+ this.setAttribute("role", "group");
207
+ const selection = [];
208
+ const selections = [];
209
+ const updates = options.map(async (option) => {
210
+ await option.updateComplete;
211
+ option.setAttribute("role", "checkbox");
212
+ option.setAttribute("aria-checked", option.selected ? "true" : "false");
213
+ if (option.selected) {
214
+ selection.push(option.value);
215
+ selections.push(option);
216
+ }
217
+ });
218
+ if (applied)
219
+ break;
220
+ await Promise.all(updates);
221
+ const selected = !!selection.length ? selection : EMPTY_SELECTION;
222
+ this.setSelected(selected);
223
+ break;
224
+ }
225
+ default:
226
+ if (this.selected.length) {
227
+ const selections = [];
228
+ const updates = options.map(async (option) => {
229
+ await option.updateComplete;
230
+ option.setAttribute("aria-checked", option.selected ? "true" : "false");
231
+ option.setAttribute("role", "button");
232
+ if (option.selected) {
233
+ selections.push(option);
234
+ }
235
+ });
236
+ if (applied)
237
+ break;
238
+ await Promise.all(updates);
239
+ this.setSelected(selections.map((button) => {
240
+ return button.value;
241
+ }));
242
+ } else {
243
+ this.buttons.forEach((option) => {
244
+ option.setAttribute("role", "button");
245
+ });
246
+ this.removeAttribute("role");
247
+ break;
248
+ }
249
+ }
250
+ }
251
+ render() {
252
+ return html`
253
+ <slot role="presentation" @slotchange=${this.manageButtons}></slot>
254
+ `;
255
+ }
256
+ firstUpdated(changes) {
257
+ super.firstUpdated(changes);
258
+ this.addEventListener("click", this.handleClick);
259
+ }
260
+ updated(changes) {
261
+ super.updated(changes);
262
+ if (changes.has("selects")) {
263
+ this.manageSelects();
264
+ this.manageChildren();
265
+ }
266
+ if (changes.has("quiet") && this.quiet || changes.has("emphasized") && this.emphasized) {
267
+ this.manageChildren();
268
+ }
269
+ if (changes.has("label") && (this.label || typeof changes.get("label") !== "undefined")) {
270
+ if (this.label.length) {
271
+ this.setAttribute("aria-label", this.label);
272
+ } else {
273
+ this.removeAttribute("aria-label");
274
+ }
275
+ }
276
+ }
277
+ manageChildren() {
278
+ this.buttons.forEach((button) => {
279
+ button.quiet = this.quiet;
280
+ button.emphasized = this.emphasized;
281
+ button.selected = this.selected.includes(button.value);
282
+ });
283
+ }
284
+ }
285
+ __decorateClass([
286
+ property({ type: Boolean, reflect: true })
287
+ ], ActionGroup.prototype, "compact", 2);
288
+ __decorateClass([
289
+ property({ type: Boolean, reflect: true })
290
+ ], ActionGroup.prototype, "emphasized", 2);
291
+ __decorateClass([
292
+ property({ type: Boolean, reflect: true })
293
+ ], ActionGroup.prototype, "justified", 2);
294
+ __decorateClass([
295
+ property({ type: String })
296
+ ], ActionGroup.prototype, "label", 2);
297
+ __decorateClass([
298
+ property({ type: Boolean, reflect: true })
299
+ ], ActionGroup.prototype, "quiet", 2);
300
+ __decorateClass([
301
+ property({ type: String })
302
+ ], ActionGroup.prototype, "selects", 2);
303
+ __decorateClass([
304
+ property({ type: Boolean, reflect: true })
305
+ ], ActionGroup.prototype, "vertical", 2);
306
+ __decorateClass([
307
+ property({ type: Array })
308
+ ], ActionGroup.prototype, "selected", 1);
309
+ //# sourceMappingURL=ActionGroup.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["ActionGroup.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n html,\n PropertyValues,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport type { ActionButton } from '@spectrum-web-components/action-button';\nimport { RovingTabindexController } from '@spectrum-web-components/reactive-controllers/src/RovingTabindex.js';\nimport { MutationController } from '@lit-labs/observers/mutation_controller.js';\n\nimport styles from './action-group.css.js';\n\nconst EMPTY_SELECTION: string[] = [];\n\n/**\n * @element sp-action-group\n * @slot - the sp-action-button elements that make up the group\n *\n * @fires change - Announces that selection state has been changed by user\n */\nexport class ActionGroup extends SpectrumElement {\n public static override get styles(): CSSResultArray {\n return [styles];\n }\n\n public set buttons(tabs: ActionButton[]) {\n if (tabs === this.buttons) return;\n this._buttons = tabs;\n this.rovingTabindexController.clearElementCache();\n }\n\n public get buttons(): ActionButton[] {\n return this._buttons;\n }\n\n public _buttons: ActionButton[] = [];\n\n protected _buttonSelector = 'sp-action-button';\n\n constructor() {\n super();\n\n new MutationController(this, {\n config: {\n childList: true,\n subtree: true,\n },\n callback: () => {\n this.manageButtons();\n },\n });\n }\n\n rovingTabindexController = new RovingTabindexController<ActionButton>(\n this,\n {\n focusInIndex: (elements: ActionButton[]) => {\n let firstEnabledIndex = -1;\n const firstSelectedIndex = elements.findIndex((el, index) => {\n if (!elements[firstEnabledIndex] && !el.disabled) {\n firstEnabledIndex = index;\n }\n return el.selected && !el.disabled;\n });\n return elements[firstSelectedIndex]\n ? firstSelectedIndex\n : firstEnabledIndex;\n },\n elements: () => this.buttons,\n isFocusableElement: (el: ActionButton) => !el.disabled,\n }\n );\n\n @property({ type: Boolean, reflect: true })\n public compact = false;\n\n @property({ type: Boolean, reflect: true })\n public emphasized = false;\n\n @property({ type: Boolean, reflect: true })\n public justified = false;\n\n @property({ type: String })\n public label = '';\n\n @property({ type: Boolean, reflect: true })\n public quiet = false;\n\n @property({ type: String })\n public selects: undefined | 'single' | 'multiple';\n\n @property({ type: Boolean, reflect: true })\n public vertical = false;\n\n private _selected: string[] = EMPTY_SELECTION;\n\n set selected(selected: string[]) {\n this.requestUpdate('selected', this._selected);\n this._selected = selected;\n this.updateComplete.then(() => {\n this.applySelects();\n this.manageChildren();\n });\n }\n\n @property({ type: Array })\n get selected(): string[] {\n return this._selected;\n }\n\n private dispatchChange(old: string[]): void {\n const applyDefault = this.dispatchEvent(\n new Event('change', {\n bubbles: true,\n composed: true,\n cancelable: true,\n })\n );\n\n if (!applyDefault) {\n this.setSelected(old);\n this.buttons.map((button) => {\n button.selected = this.selected.includes(button.value);\n });\n }\n }\n\n private setSelected(selected: string[], announce?: boolean): void {\n if (selected === this.selected) return;\n\n const old = this.selected;\n this.requestUpdate('selected', old);\n this._selected = selected;\n if (!announce) return;\n this.dispatchChange(old);\n }\n\n public override focus(options?: FocusOptions): void {\n this.rovingTabindexController.focus(options);\n }\n\n private deselectSelectedButtons(): void {\n const selected = [\n ...this.querySelectorAll('[selected]'),\n ] as ActionButton[];\n selected.forEach((el) => {\n el.selected = false;\n el.tabIndex = -1;\n el.setAttribute('aria-checked', 'false');\n });\n }\n\n private handleClick(event: Event): void {\n const target = event.target as ActionButton;\n if (typeof target.value === 'undefined') {\n return;\n }\n switch (this.selects) {\n case 'single': {\n this.deselectSelectedButtons();\n target.selected = true;\n target.tabIndex = 0;\n target.setAttribute('aria-checked', 'true');\n this.setSelected([target.value], true);\n target.focus();\n break;\n }\n case 'multiple': {\n const selected = [...this.selected];\n target.selected = !target.selected;\n target.setAttribute(\n 'aria-checked',\n target.selected ? 'true' : 'false'\n );\n if (target.selected) {\n selected.push(target.value);\n } else {\n selected.splice(this.selected.indexOf(target.value), 1);\n }\n this.setSelected(selected, true);\n\n this.buttons.forEach((button) => {\n button.tabIndex = -1;\n });\n\n target.tabIndex = 0;\n\n break;\n }\n default:\n break;\n }\n }\n\n private async applySelects(): Promise<void> {\n await this.manageSelects(true);\n }\n\n private async manageSelects(applied?: boolean): Promise<void> {\n if (!this.buttons.length) {\n return;\n }\n\n const options = this.buttons;\n switch (this.selects) {\n case 'single': {\n this.setAttribute('role', 'radiogroup');\n const selections: ActionButton[] = [];\n const updates = options.map(async (option) => {\n await option.updateComplete;\n option.setAttribute('role', 'radio');\n option.setAttribute(\n 'aria-checked',\n option.selected ? 'true' : 'false'\n );\n if (option.selected) {\n selections.push(option);\n }\n });\n if (applied) break;\n await Promise.all(updates);\n\n const selected = selections.map((button) => {\n return button.value;\n });\n\n this.setSelected(selected || EMPTY_SELECTION);\n break;\n }\n case 'multiple': {\n this.setAttribute('role', 'group');\n const selection: string[] = [];\n const selections: ActionButton[] = [];\n const updates = options.map(async (option) => {\n await option.updateComplete;\n option.setAttribute('role', 'checkbox');\n option.setAttribute(\n 'aria-checked',\n option.selected ? 'true' : 'false'\n );\n if (option.selected) {\n selection.push(option.value);\n selections.push(option);\n }\n });\n if (applied) break;\n await Promise.all(updates);\n const selected = !!selection.length\n ? selection\n : EMPTY_SELECTION;\n this.setSelected(selected);\n break;\n }\n default:\n // if user defines .selected\n if (this.selected.length) {\n const selections: ActionButton[] = [];\n const updates = options.map(async (option) => {\n await option.updateComplete;\n option.setAttribute(\n 'aria-checked',\n option.selected ? 'true' : 'false'\n );\n option.setAttribute('role', 'button');\n if (option.selected) {\n selections.push(option);\n }\n });\n if (applied) break;\n await Promise.all(updates);\n\n this.setSelected(\n selections.map((button) => {\n return button.value;\n })\n );\n } else {\n this.buttons.forEach((option) => {\n option.setAttribute('role', 'button');\n });\n this.removeAttribute('role');\n break;\n }\n }\n }\n\n protected override render(): TemplateResult {\n return html`\n <slot role=\"presentation\" @slotchange=${this.manageButtons}></slot>\n `;\n }\n\n protected override firstUpdated(changes: PropertyValues): void {\n super.firstUpdated(changes);\n this.addEventListener('click', this.handleClick);\n }\n\n protected override updated(changes: PropertyValues): void {\n super.updated(changes);\n if (changes.has('selects')) {\n this.manageSelects();\n this.manageChildren();\n }\n if (\n (changes.has('quiet') && this.quiet) ||\n (changes.has('emphasized') && this.emphasized)\n ) {\n this.manageChildren();\n }\n // Update `aria-label` when `label` available or not first `updated`\n if (\n changes.has('label') &&\n (this.label || typeof changes.get('label') !== 'undefined')\n ) {\n if (this.label.length) {\n this.setAttribute('aria-label', this.label);\n } else {\n this.removeAttribute('aria-label');\n }\n }\n }\n\n private manageChildren(): void {\n this.buttons.forEach((button) => {\n button.quiet = this.quiet;\n button.emphasized = this.emphasized;\n button.selected = this.selected.includes(button.value);\n });\n }\n\n private manageButtons = (): void => {\n const slot = this.shadowRoot.querySelector('slot');\n if (!slot) return;\n const assignedElements = slot.assignedElements({ flatten: true });\n const buttons = assignedElements.reduce((acc: unknown[], el) => {\n if (el.matches(this._buttonSelector)) {\n acc.push(el);\n } else {\n const buttonDescendents = Array.from(\n el.querySelectorAll(`:scope > ${this._buttonSelector}`)\n );\n acc.push(...buttonDescendents);\n }\n return acc;\n }, []);\n this.buttons = buttons as ActionButton[];\n // <selected> element merges selected so following paradigm here\n const currentlySelectedButtons: string[] = [];\n this.buttons.forEach((button: ActionButton) => {\n if (button.selected) {\n currentlySelectedButtons.push(button.value);\n }\n });\n this.setSelected(this.selected.concat(currentlySelectedButtons));\n this.manageChildren();\n this.manageSelects();\n };\n}\n"],
5
+ "mappings": ";;;;;;;;;;;AAYA;AAAA;AAAA;AAAA;AAOA;AAEA;AACA;AAEA;AAEA,MAAM,kBAA4B,CAAC;AAQ5B,aAAM,oBAAoB,gBAAgB;AAAA,EAmB7C,cAAc;AACV,UAAM;AALH,oBAA2B,CAAC;AAEzB,2BAAkB;AAgB5B,oCAA2B,IAAI,yBAC3B,MACA;AAAA,MACI,cAAc,CAAC,aAA6B;AACxC,YAAI,oBAAoB;AACxB,cAAM,qBAAqB,SAAS,UAAU,CAAC,IAAI,UAAU;AACzD,cAAI,CAAC,SAAS,sBAAsB,CAAC,GAAG,UAAU;AAC9C,gCAAoB;AAAA,UACxB;AACA,iBAAO,GAAG,YA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