@spectrum-web-components/action-group 0.35.1-rc.43 → 0.36.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.
@@ -0,0 +1,433 @@
1
+ {
2
+ "schemaVersion": "1.0.0",
3
+ "readme": "",
4
+ "modules": [
5
+ {
6
+ "kind": "javascript-module",
7
+ "path": "sp-action-group.js",
8
+ "declarations": [],
9
+ "exports": [
10
+ {
11
+ "kind": "custom-element-definition",
12
+ "name": "sp-action-group",
13
+ "declaration": {
14
+ "name": "ActionGroup",
15
+ "module": "/src/ActionGroup.js"
16
+ }
17
+ }
18
+ ]
19
+ },
20
+ {
21
+ "kind": "javascript-module",
22
+ "path": "src/ActionGroup.js",
23
+ "declarations": [
24
+ {
25
+ "kind": "class",
26
+ "description": "",
27
+ "name": "ActionGroup",
28
+ "slots": [
29
+ {
30
+ "description": "the sp-action-button elements that make up the group",
31
+ "name": ""
32
+ }
33
+ ],
34
+ "members": [
35
+ {
36
+ "kind": "field",
37
+ "name": "buttons",
38
+ "privacy": "public",
39
+ "type": {
40
+ "text": "ActionButton[]"
41
+ }
42
+ },
43
+ {
44
+ "kind": "field",
45
+ "name": "_buttons",
46
+ "type": {
47
+ "text": "ActionButton[]"
48
+ },
49
+ "privacy": "public",
50
+ "default": "[]"
51
+ },
52
+ {
53
+ "kind": "field",
54
+ "name": "_buttonSelector",
55
+ "type": {
56
+ "text": "string"
57
+ },
58
+ "privacy": "protected",
59
+ "default": "'sp-action-button'"
60
+ },
61
+ {
62
+ "kind": "field",
63
+ "name": "rovingTabindexController",
64
+ "default": "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 )"
65
+ },
66
+ {
67
+ "kind": "field",
68
+ "name": "compact",
69
+ "type": {
70
+ "text": "boolean"
71
+ },
72
+ "privacy": "public",
73
+ "default": "false",
74
+ "attribute": "compact",
75
+ "reflects": true
76
+ },
77
+ {
78
+ "kind": "field",
79
+ "name": "emphasized",
80
+ "type": {
81
+ "text": "boolean"
82
+ },
83
+ "privacy": "public",
84
+ "default": "false",
85
+ "attribute": "emphasized",
86
+ "reflects": true
87
+ },
88
+ {
89
+ "kind": "field",
90
+ "name": "justified",
91
+ "type": {
92
+ "text": "boolean"
93
+ },
94
+ "privacy": "public",
95
+ "default": "false",
96
+ "attribute": "justified",
97
+ "reflects": true
98
+ },
99
+ {
100
+ "kind": "field",
101
+ "name": "label",
102
+ "type": {
103
+ "text": "string"
104
+ },
105
+ "privacy": "public",
106
+ "default": "''",
107
+ "attribute": "label"
108
+ },
109
+ {
110
+ "kind": "field",
111
+ "name": "quiet",
112
+ "type": {
113
+ "text": "boolean"
114
+ },
115
+ "privacy": "public",
116
+ "default": "false",
117
+ "attribute": "quiet",
118
+ "reflects": true
119
+ },
120
+ {
121
+ "kind": "field",
122
+ "name": "selects",
123
+ "type": {
124
+ "text": "undefined | 'single' | 'multiple'"
125
+ },
126
+ "privacy": "public",
127
+ "attribute": "selects"
128
+ },
129
+ {
130
+ "kind": "field",
131
+ "name": "static",
132
+ "type": {
133
+ "text": "'white' | 'black' | undefined"
134
+ },
135
+ "privacy": "public",
136
+ "attribute": "static",
137
+ "reflects": true
138
+ },
139
+ {
140
+ "kind": "field",
141
+ "name": "vertical",
142
+ "type": {
143
+ "text": "boolean"
144
+ },
145
+ "privacy": "public",
146
+ "default": "false",
147
+ "attribute": "vertical",
148
+ "reflects": true
149
+ },
150
+ {
151
+ "kind": "field",
152
+ "name": "_selected",
153
+ "type": {
154
+ "text": "string[]"
155
+ },
156
+ "privacy": "private",
157
+ "default": "[]"
158
+ },
159
+ {
160
+ "kind": "field",
161
+ "name": "selected",
162
+ "type": {
163
+ "text": "string[]"
164
+ },
165
+ "attribute": "selected"
166
+ },
167
+ {
168
+ "kind": "field",
169
+ "name": "slotElement",
170
+ "type": {
171
+ "text": "HTMLSlotElement"
172
+ }
173
+ },
174
+ {
175
+ "kind": "method",
176
+ "name": "dispatchChange",
177
+ "privacy": "private",
178
+ "return": {
179
+ "type": {
180
+ "text": "void"
181
+ }
182
+ },
183
+ "parameters": [
184
+ {
185
+ "name": "old",
186
+ "type": {
187
+ "text": "string[]"
188
+ }
189
+ }
190
+ ]
191
+ },
192
+ {
193
+ "kind": "method",
194
+ "name": "setSelected",
195
+ "privacy": "private",
196
+ "return": {
197
+ "type": {
198
+ "text": "void"
199
+ }
200
+ },
201
+ "parameters": [
202
+ {
203
+ "name": "selected",
204
+ "type": {
205
+ "text": "string[]"
206
+ }
207
+ },
208
+ {
209
+ "name": "announce",
210
+ "optional": true,
211
+ "type": {
212
+ "text": "boolean"
213
+ }
214
+ }
215
+ ]
216
+ },
217
+ {
218
+ "kind": "method",
219
+ "name": "focus",
220
+ "privacy": "public",
221
+ "return": {
222
+ "type": {
223
+ "text": "void"
224
+ }
225
+ },
226
+ "parameters": [
227
+ {
228
+ "name": "options",
229
+ "optional": true,
230
+ "type": {
231
+ "text": "FocusOptions"
232
+ }
233
+ }
234
+ ]
235
+ },
236
+ {
237
+ "kind": "method",
238
+ "name": "deselectSelectedButtons",
239
+ "privacy": "private",
240
+ "return": {
241
+ "type": {
242
+ "text": "void"
243
+ }
244
+ }
245
+ },
246
+ {
247
+ "kind": "method",
248
+ "name": "handleClick",
249
+ "privacy": "private",
250
+ "return": {
251
+ "type": {
252
+ "text": "void"
253
+ }
254
+ },
255
+ "parameters": [
256
+ {
257
+ "name": "event",
258
+ "type": {
259
+ "text": "Event"
260
+ }
261
+ }
262
+ ]
263
+ },
264
+ {
265
+ "kind": "method",
266
+ "name": "applySelects",
267
+ "privacy": "private",
268
+ "return": {
269
+ "type": {
270
+ "text": "Promise<void>"
271
+ }
272
+ }
273
+ },
274
+ {
275
+ "kind": "method",
276
+ "name": "manageSelects",
277
+ "privacy": "private",
278
+ "return": {
279
+ "type": {
280
+ "text": "Promise<void>"
281
+ }
282
+ },
283
+ "parameters": [
284
+ {
285
+ "name": "applied",
286
+ "optional": true,
287
+ "type": {
288
+ "text": "boolean"
289
+ }
290
+ }
291
+ ]
292
+ },
293
+ {
294
+ "kind": "method",
295
+ "name": "manageChildren",
296
+ "privacy": "private",
297
+ "return": {
298
+ "type": {
299
+ "text": "void"
300
+ }
301
+ },
302
+ "parameters": [
303
+ {
304
+ "name": "changes",
305
+ "optional": true,
306
+ "type": {
307
+ "text": "PropertyValues"
308
+ }
309
+ }
310
+ ]
311
+ },
312
+ {
313
+ "kind": "field",
314
+ "name": "hasManaged",
315
+ "type": {
316
+ "text": "boolean"
317
+ },
318
+ "privacy": "private",
319
+ "default": "false"
320
+ },
321
+ {
322
+ "kind": "field",
323
+ "name": "manageButtons",
324
+ "privacy": "private"
325
+ }
326
+ ],
327
+ "events": [
328
+ {
329
+ "name": "change",
330
+ "type": {
331
+ "text": "Event"
332
+ },
333
+ "description": "Announces that selection state has been changed by user"
334
+ }
335
+ ],
336
+ "attributes": [
337
+ {
338
+ "name": "compact",
339
+ "type": {
340
+ "text": "boolean"
341
+ },
342
+ "default": "false",
343
+ "fieldName": "compact"
344
+ },
345
+ {
346
+ "name": "emphasized",
347
+ "type": {
348
+ "text": "boolean"
349
+ },
350
+ "default": "false",
351
+ "fieldName": "emphasized"
352
+ },
353
+ {
354
+ "name": "justified",
355
+ "type": {
356
+ "text": "boolean"
357
+ },
358
+ "default": "false",
359
+ "fieldName": "justified"
360
+ },
361
+ {
362
+ "name": "label",
363
+ "type": {
364
+ "text": "string"
365
+ },
366
+ "default": "''",
367
+ "fieldName": "label"
368
+ },
369
+ {
370
+ "name": "quiet",
371
+ "type": {
372
+ "text": "boolean"
373
+ },
374
+ "default": "false",
375
+ "fieldName": "quiet"
376
+ },
377
+ {
378
+ "name": "selects",
379
+ "type": {
380
+ "text": "undefined | 'single' | 'multiple'"
381
+ },
382
+ "fieldName": "selects"
383
+ },
384
+ {
385
+ "name": "static",
386
+ "type": {
387
+ "text": "'white' | 'black' | undefined"
388
+ },
389
+ "fieldName": "static"
390
+ },
391
+ {
392
+ "name": "vertical",
393
+ "type": {
394
+ "text": "boolean"
395
+ },
396
+ "default": "false",
397
+ "fieldName": "vertical"
398
+ },
399
+ {
400
+ "name": "selected",
401
+ "type": {
402
+ "text": "string[]"
403
+ },
404
+ "fieldName": "selected"
405
+ }
406
+ ],
407
+ "mixins": [
408
+ {
409
+ "name": "SizedMixin",
410
+ "package": "@spectrum-web-components/base"
411
+ }
412
+ ],
413
+ "superclass": {
414
+ "name": "SpectrumElement",
415
+ "package": "@spectrum-web-components/base"
416
+ },
417
+ "tagName": "sp-action-group",
418
+ "customElement": true
419
+ }
420
+ ],
421
+ "exports": [
422
+ {
423
+ "kind": "js",
424
+ "name": "ActionGroup",
425
+ "declaration": {
426
+ "name": "ActionGroup",
427
+ "module": "src/ActionGroup.js"
428
+ }
429
+ }
430
+ ]
431
+ }
432
+ ]
433
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-web-components/action-group",
3
- "version": "0.35.1-rc.43+432051b80",
3
+ "version": "0.36.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -58,13 +58,13 @@
58
58
  ],
59
59
  "dependencies": {
60
60
  "@lit-labs/observers": "^2.0.0",
61
- "@spectrum-web-components/action-button": "^0.35.1-rc.43+432051b80",
62
- "@spectrum-web-components/base": "^0.35.1-rc.43+432051b80",
63
- "@spectrum-web-components/icons-workflow": "^0.35.1-rc.43+432051b80",
64
- "@spectrum-web-components/reactive-controllers": "^0.35.1-rc.43+432051b80"
61
+ "@spectrum-web-components/action-button": "^0.36.0",
62
+ "@spectrum-web-components/base": "^0.36.0",
63
+ "@spectrum-web-components/icons-workflow": "^0.36.0",
64
+ "@spectrum-web-components/reactive-controllers": "^0.36.0"
65
65
  },
66
66
  "devDependencies": {
67
- "@spectrum-css/actiongroup": "^3.0.57"
67
+ "@spectrum-css/actiongroup": "^3.0.61"
68
68
  },
69
69
  "types": "./src/index.d.ts",
70
70
  "customElements": "custom-elements.json",
@@ -72,5 +72,5 @@
72
72
  "./sp-*.js",
73
73
  "./**/*.dev.js"
74
74
  ],
75
- "gitHead": "432051b8085e7c86032333fa296bfa5334d47d84"
75
+ "gitHead": "a532ff8a410abeefb54d9638a2316ae82570566e"
76
76
  }
@@ -13,7 +13,7 @@ declare const ActionGroup_base: typeof SpectrumElement & {
13
13
  */
14
14
  export declare class ActionGroup extends ActionGroup_base {
15
15
  static get styles(): CSSResultArray;
16
- set buttons(tabs: ActionButton[]);
16
+ set buttons(buttons: ActionButton[]);
17
17
  get buttons(): ActionButton[];
18
18
  _buttons: ActionButton[];
19
19
  protected _buttonSelector: string;
@@ -30,6 +30,7 @@ export declare class ActionGroup extends ActionGroup_base {
30
30
  private _selected;
31
31
  set selected(selected: string[]);
32
32
  get selected(): string[];
33
+ slotElement: HTMLSlotElement;
33
34
  private dispatchChange;
34
35
  private setSelected;
35
36
  focus(options?: FocusOptions): void;
@@ -41,6 +42,7 @@ export declare class ActionGroup extends ActionGroup_base {
41
42
  protected firstUpdated(changes: PropertyValues): void;
42
43
  protected updated(changes: PropertyValues): void;
43
44
  private manageChildren;
45
+ private hasManaged;
44
46
  private manageButtons;
45
47
  }
46
48
  export {};
@@ -15,7 +15,10 @@ import {
15
15
  SizedMixin,
16
16
  SpectrumElement
17
17
  } from "@spectrum-web-components/base";
18
- import { property } from "@spectrum-web-components/base/src/decorators.js";
18
+ import {
19
+ property,
20
+ query
21
+ } from "@spectrum-web-components/base/src/decorators.js";
19
22
  import { RovingTabindexController } from "@spectrum-web-components/reactive-controllers/src/RovingTabindex.js";
20
23
  import { MutationController } from "@lit-labs/observers/mutation-controller.js";
21
24
  import styles from "./action-group.css.js";
@@ -51,11 +54,11 @@ export class ActionGroup extends SizedMixin(SpectrumElement, {
51
54
  this.quiet = false;
52
55
  this.vertical = false;
53
56
  this._selected = EMPTY_SELECTION;
57
+ this.hasManaged = false;
54
58
  this.manageButtons = () => {
55
- const slot = this.shadowRoot.querySelector("slot");
56
- if (!slot)
57
- return;
58
- const assignedElements = slot.assignedElements({ flatten: true });
59
+ const assignedElements = this.slotElement.assignedElements({
60
+ flatten: true
61
+ });
59
62
  const buttons = assignedElements.reduce((acc, el) => {
60
63
  if (el.matches(this._buttonSelector)) {
61
64
  acc.push(el);
@@ -68,15 +71,18 @@ export class ActionGroup extends SizedMixin(SpectrumElement, {
68
71
  return acc;
69
72
  }, []);
70
73
  this.buttons = buttons;
71
- const currentlySelectedButtons = [];
72
- this.buttons.forEach((button) => {
73
- if (button.selected) {
74
- currentlySelectedButtons.push(button.value);
75
- }
76
- });
77
- this.setSelected(this.selected.concat(currentlySelectedButtons));
74
+ if (this.selects || !this.hasManaged) {
75
+ const currentlySelectedButtons = [];
76
+ this.buttons.forEach((button) => {
77
+ if (button.selected) {
78
+ currentlySelectedButtons.push(button.value);
79
+ }
80
+ });
81
+ this.setSelected(this.selected.concat(currentlySelectedButtons));
82
+ }
78
83
  this.manageChildren();
79
84
  this.manageSelects();
85
+ this.hasManaged = true;
80
86
  };
81
87
  new MutationController(this, {
82
88
  config: {
@@ -85,16 +91,17 @@ export class ActionGroup extends SizedMixin(SpectrumElement, {
85
91
  },
86
92
  callback: () => {
87
93
  this.manageButtons();
88
- }
94
+ },
95
+ skipInitial: true
89
96
  });
90
97
  }
91
98
  static get styles() {
92
99
  return [styles];
93
100
  }
94
- set buttons(tabs) {
95
- if (tabs === this.buttons)
101
+ set buttons(buttons) {
102
+ if (buttons === this.buttons)
96
103
  return;
97
- this._buttons = tabs;
104
+ this._buttons = buttons;
98
105
  this.rovingTabindexController.clearElementCache();
99
106
  }
100
107
  get buttons() {
@@ -147,7 +154,10 @@ export class ActionGroup extends SizedMixin(SpectrumElement, {
147
154
  el.selected = false;
148
155
  el.tabIndex = -1;
149
156
  el.setAttribute(
150
- !this.selects ? "aria-pressed" : "aria-checked",
157
+ this.selects ? "aria-checked" : (
158
+ /* c8 ignore */
159
+ "aria-pressed"
160
+ ),
151
161
  "false"
152
162
  );
153
163
  });
@@ -164,6 +174,7 @@ export class ActionGroup extends SizedMixin(SpectrumElement, {
164
174
  target.tabIndex = 0;
165
175
  target.setAttribute("aria-checked", "true");
166
176
  this.setSelected([target.value], true);
177
+ target.focus();
167
178
  break;
168
179
  }
169
180
  case "multiple": {
@@ -315,7 +326,9 @@ export class ActionGroup extends SizedMixin(SpectrumElement, {
315
326
  if (this.static || (changes == null ? void 0 : changes.get("static"))) {
316
327
  button.static = this.static;
317
328
  }
318
- button.selected = this.selected.includes(button.value);
329
+ if (this.selects || !this.hasManaged) {
330
+ button.selected = this.selected.includes(button.value);
331
+ }
319
332
  if (this.size) {
320
333
  button.size = this.size;
321
334
  }
@@ -349,4 +362,7 @@ __decorateClass([
349
362
  __decorateClass([
350
363
  property({ type: Array })
351
364
  ], ActionGroup.prototype, "selected", 1);
365
+ __decorateClass([
366
+ query("slot")
367
+ ], ActionGroup.prototype, "slotElement", 2);
352
368
  //# sourceMappingURL=ActionGroup.dev.js.map