@spectrum-web-components/action-group 0.0.0-20241209155954
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/README.md +478 -0
- package/package.json +76 -0
- package/sp-action-group.d.ts +6 -0
- package/sp-action-group.dev.js +5 -0
- package/sp-action-group.dev.js.map +7 -0
- package/sp-action-group.js +2 -0
- package/sp-action-group.js.map +7 -0
- package/src/ActionGroup.d.ts +49 -0
- package/src/ActionGroup.dev.js +377 -0
- package/src/ActionGroup.dev.js.map +7 -0
- package/src/ActionGroup.js +4 -0
- package/src/ActionGroup.js.map +7 -0
- package/src/action-group-overrides.css.d.ts +2 -0
- package/src/action-group-overrides.css.dev.js +7 -0
- package/src/action-group-overrides.css.dev.js.map +7 -0
- package/src/action-group-overrides.css.js +4 -0
- package/src/action-group-overrides.css.js.map +7 -0
- package/src/action-group.css.d.ts +2 -0
- package/src/action-group.css.dev.js +7 -0
- package/src/action-group.css.dev.js.map +7 -0
- package/src/action-group.css.js +4 -0
- package/src/action-group.css.js.map +7 -0
- package/src/index.d.ts +1 -0
- package/src/index.dev.js +3 -0
- package/src/index.dev.js.map +7 -0
- package/src/index.js +2 -0
- package/src/index.js.map +7 -0
- package/src/spectrum-action-group.css.d.ts +2 -0
- package/src/spectrum-action-group.css.dev.js +7 -0
- package/src/spectrum-action-group.css.dev.js.map +7 -0
- package/src/spectrum-action-group.css.js +4 -0
- package/src/spectrum-action-group.css.js.map +7 -0
- package/src/spectrum-config.js +186 -0
package/README.md
ADDED
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
## Description
|
|
2
|
+
|
|
3
|
+
`sp-action-group` delivers a set of action buttons in horizontal or vertical orientation while ensuring the appropriate spacing between those buttons. The `compact` attribute merges these buttons so that they are visually joined to clarify their relationship to each other and their distance from other buttons/groups.
|
|
4
|
+
|
|
5
|
+
### Usage
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@spectrum-web-components/action-group)
|
|
8
|
+
[](https://bundlephobia.com/result?p=@spectrum-web-components/action-group)
|
|
9
|
+
[](https://webcomponents.dev/edit/collection/fO75441E1Q5ZlI0e9pgq/ty5ezK85zgVE5vuZfMem/src/index.ts)
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
yarn add @spectrum-web-components/action-group
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Import the side effectful registration of `<sp-action-group>` via:
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
import '@spectrum-web-components/action-group/sp-action-group.js';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
When looking to leverage the `ActionGroup` base class as a type and/or for extension purposes, do so via:
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
import { ActionGroup } from '@spectrum-web-components/action-group';
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Sizes
|
|
28
|
+
|
|
29
|
+
<sp-tabs selected="m" auto label="Size Attribute Options">
|
|
30
|
+
<sp-tab value="xs">Extra Small</sp-tab>
|
|
31
|
+
<sp-tab-panel value="xs">
|
|
32
|
+
|
|
33
|
+
```html demo
|
|
34
|
+
<sp-action-group size="xs">
|
|
35
|
+
<sp-action-button>Extra Small 1</sp-action-button>
|
|
36
|
+
<sp-action-button>Extra Small 2</sp-action-button>
|
|
37
|
+
</sp-action-group>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
</sp-tab-panel>
|
|
41
|
+
<sp-tab value="s">Small</sp-tab>
|
|
42
|
+
<sp-tab-panel value="s">
|
|
43
|
+
|
|
44
|
+
```html demo
|
|
45
|
+
<sp-action-group size="s">
|
|
46
|
+
<sp-action-button>Small 1</sp-action-button>
|
|
47
|
+
<sp-action-button>Small 2</sp-action-button>
|
|
48
|
+
</sp-action-group>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
</sp-tab-panel>
|
|
52
|
+
<sp-tab value="m">Medium</sp-tab>
|
|
53
|
+
<sp-tab-panel value="m">
|
|
54
|
+
|
|
55
|
+
```html demo
|
|
56
|
+
<sp-action-group size="m">
|
|
57
|
+
<sp-action-button>Medium 1</sp-action-button>
|
|
58
|
+
<sp-action-button>Medium 2</sp-action-button>
|
|
59
|
+
</sp-action-group>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
</sp-tab-panel>
|
|
63
|
+
<sp-tab value="l">Large</sp-tab>
|
|
64
|
+
<sp-tab-panel value="l">
|
|
65
|
+
|
|
66
|
+
```html demo
|
|
67
|
+
<sp-action-group size="l">
|
|
68
|
+
<sp-action-button>Large 1</sp-action-button>
|
|
69
|
+
<sp-action-button>Large 2</sp-action-button>
|
|
70
|
+
</sp-action-group>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
</sp-tab-panel>
|
|
74
|
+
<sp-tab value="xl">Extra Large</sp-tab>
|
|
75
|
+
<sp-tab-panel value="xl">
|
|
76
|
+
|
|
77
|
+
```html demo
|
|
78
|
+
<sp-action-group size="xl">
|
|
79
|
+
<sp-action-button>Extra Large 1</sp-action-button>
|
|
80
|
+
<sp-action-button>Extra Large 2</sp-action-button>
|
|
81
|
+
</sp-action-group>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
</sp-tab-panel>
|
|
85
|
+
</sp-tabs>
|
|
86
|
+
|
|
87
|
+
## Selects
|
|
88
|
+
|
|
89
|
+
An `<sp-action-group selects="single|multiple">` will manage a `selected` property that consists on an array of the `<sp-action-button>` children that are currently selected. A `change` event is dispatched from the `<sp-action-group>` element when the value of `selected` is updated. This event can be canceled via `event.preventDefault()`, after which the value of `selected` will be returned to what it was previously.
|
|
90
|
+
|
|
91
|
+
When a selection can be made, it is a good idea to supply the group of options with accessible text that names the group of buttons. This can be done in a non-visual way via the `label` attribute of the `<sp-action-group>` element. You can also associate the `<sp-action-group>` to a second, visible DOM element via the `aria-labelledby` attribute or, when available, via the `for` attribute on the second element to make the association in the other direction.
|
|
92
|
+
|
|
93
|
+
### Single
|
|
94
|
+
|
|
95
|
+
An `<sp-action-group selects="single">` will manage its `<sp-action-button>` children as "radio buttons" allowing the user to select a _single_ one of the buttons presented. The `<sp-action-button>` children will only be able to turn their `selected` value on while maintaining a single selection after an initial selection is made.
|
|
96
|
+
|
|
97
|
+
```html
|
|
98
|
+
<sp-action-group
|
|
99
|
+
selects="single"
|
|
100
|
+
emphasized
|
|
101
|
+
label="Single Selection Demo Group"
|
|
102
|
+
>
|
|
103
|
+
<sp-action-button>
|
|
104
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
105
|
+
Button 1
|
|
106
|
+
</sp-action-button>
|
|
107
|
+
<sp-action-button selected>
|
|
108
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
109
|
+
Longer Button 2
|
|
110
|
+
</sp-action-button>
|
|
111
|
+
<sp-action-button>
|
|
112
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
113
|
+
Short 3
|
|
114
|
+
</sp-action-button>
|
|
115
|
+
</sp-action-group>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Multiple
|
|
119
|
+
|
|
120
|
+
An `<sp-action-group selects="multiple">` will manage its `<sp-action-button>` children as "checkboxes" allowing the user to select a _multiple_ of the buttons presented. The `<sp-action-button>` children will toggle their `selected` value on and off when clicked successively.
|
|
121
|
+
|
|
122
|
+
```html
|
|
123
|
+
<sp-action-group
|
|
124
|
+
selects="multiple"
|
|
125
|
+
emphasized
|
|
126
|
+
label="Multiple Selection Demo Group"
|
|
127
|
+
>
|
|
128
|
+
<sp-action-button selected>
|
|
129
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
130
|
+
Button 1
|
|
131
|
+
</sp-action-button>
|
|
132
|
+
<sp-action-button>
|
|
133
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
134
|
+
Longer Button 2
|
|
135
|
+
</sp-action-button>
|
|
136
|
+
<sp-action-button selected>
|
|
137
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
138
|
+
Short 3
|
|
139
|
+
</sp-action-button>
|
|
140
|
+
</sp-action-group>
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Selected
|
|
144
|
+
|
|
145
|
+
The `selected` property represents the selection state within a button group. This property can be managed either by the component or by the user. Passing in an array of button values will make `<sp-action-group>` a controllable component. Though `selected` would more commonly be set via Javascript expressions (i.e. `<sp-action-group .selected=${["first"]}>`), it is also possible to set `selected` as a JSON string.
|
|
146
|
+
|
|
147
|
+
```html
|
|
148
|
+
<sp-action-group selects="single" selected='["first"]'>
|
|
149
|
+
<sp-action-button value="first">First</sp-action-button>
|
|
150
|
+
<sp-action-button value="second">Second</sp-action-button>
|
|
151
|
+
</sp-action-group>
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
By default, an `<sp-action-group>` will select any button passed into `selected`. Afterwards, `.selects` controls how button values are added to the selection state. For example, if `.selects` is not specified when `selected` is set, any further interaction will result in no change to the selection.
|
|
155
|
+
|
|
156
|
+
```html
|
|
157
|
+
<sp-action-group selected='["first", "second"]'>
|
|
158
|
+
<sp-action-button value="first">First</sp-action-button>
|
|
159
|
+
<sp-action-button value="second">Second</sp-action-button>
|
|
160
|
+
<sp-action-button value="third">Third</sp-action-button>
|
|
161
|
+
</sp-action-group>
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Similarly, if `selected` contains more than one button value, but `selects = "single"`, then those initial buttons will be highlighted, but further interaction will result in radio-button functionality.
|
|
165
|
+
|
|
166
|
+
```html
|
|
167
|
+
<sp-action-group selects="single" selected='["first", "second"]'>
|
|
168
|
+
<sp-action-button value="first">First</sp-action-button>
|
|
169
|
+
<sp-action-button value="second">Second</sp-action-button>
|
|
170
|
+
<sp-action-button value="third">Third</sp-action-button>
|
|
171
|
+
</sp-action-group>
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Horizontal
|
|
175
|
+
|
|
176
|
+
By default, an `<sp-action-group>` will organize its child buttons horizontally and the delivery of those buttons can be modified with the `compact`, `emphasized`, or `quiet` attributes.
|
|
177
|
+
|
|
178
|
+
```html
|
|
179
|
+
<sp-action-group>
|
|
180
|
+
<sp-action-button>
|
|
181
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
182
|
+
Button 1
|
|
183
|
+
</sp-action-button>
|
|
184
|
+
<sp-action-button>
|
|
185
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
186
|
+
Longer Button 2
|
|
187
|
+
</sp-action-button>
|
|
188
|
+
<sp-action-button>
|
|
189
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
190
|
+
Short 3
|
|
191
|
+
</sp-action-button>
|
|
192
|
+
</sp-action-group>
|
|
193
|
+
<br />
|
|
194
|
+
<sp-action-group compact>
|
|
195
|
+
<sp-action-button>
|
|
196
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
197
|
+
Button 1
|
|
198
|
+
</sp-action-button>
|
|
199
|
+
<sp-action-button>
|
|
200
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
201
|
+
Longer Button 2
|
|
202
|
+
</sp-action-button>
|
|
203
|
+
<sp-action-button>
|
|
204
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
205
|
+
Short 3
|
|
206
|
+
</sp-action-button>
|
|
207
|
+
</sp-action-group>
|
|
208
|
+
<br />
|
|
209
|
+
<sp-action-group quiet>
|
|
210
|
+
<sp-action-button label="Zoom in">
|
|
211
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
212
|
+
</sp-action-button>
|
|
213
|
+
<sp-action-button label="Zoom in">
|
|
214
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
215
|
+
</sp-action-button>
|
|
216
|
+
<sp-action-button label="Zoom in">
|
|
217
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
218
|
+
</sp-action-button>
|
|
219
|
+
</sp-action-group>
|
|
220
|
+
<br />
|
|
221
|
+
<sp-action-group compact emphasized>
|
|
222
|
+
<sp-action-button label="Zoom in">
|
|
223
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
224
|
+
</sp-action-button>
|
|
225
|
+
<sp-action-button label="Zoom in">
|
|
226
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
227
|
+
</sp-action-button>
|
|
228
|
+
<sp-action-button label="Zoom in">
|
|
229
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
230
|
+
</sp-action-button>
|
|
231
|
+
</sp-action-group>
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## Vertical
|
|
235
|
+
|
|
236
|
+
The use of the `vertical` attribute instructs the `<sp-action-group>` element to organize its child buttons vertically, while accepting the same `compact`, `emphasized`, and `quiet` attributes as modifiers.
|
|
237
|
+
|
|
238
|
+
```html
|
|
239
|
+
<div style="display: flex; justify-content: space-around;">
|
|
240
|
+
<sp-action-group vertical>
|
|
241
|
+
<sp-action-button>
|
|
242
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
243
|
+
Button 1
|
|
244
|
+
</sp-action-button>
|
|
245
|
+
<sp-action-button>
|
|
246
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
247
|
+
Longer Button 2
|
|
248
|
+
</sp-action-button>
|
|
249
|
+
<sp-action-button>
|
|
250
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
251
|
+
Short 3
|
|
252
|
+
</sp-action-button>
|
|
253
|
+
</sp-action-group>
|
|
254
|
+
<sp-action-group vertical compact>
|
|
255
|
+
<sp-action-button>
|
|
256
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
257
|
+
Button 1
|
|
258
|
+
</sp-action-button>
|
|
259
|
+
<sp-action-button>
|
|
260
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
261
|
+
Longer Button 2
|
|
262
|
+
</sp-action-button>
|
|
263
|
+
<sp-action-button>
|
|
264
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
265
|
+
Short 3
|
|
266
|
+
</sp-action-button>
|
|
267
|
+
</sp-action-group>
|
|
268
|
+
<sp-action-group vertical quiet>
|
|
269
|
+
<sp-action-button label="Zoom in">
|
|
270
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
271
|
+
</sp-action-button>
|
|
272
|
+
<sp-action-button label="Zoom in">
|
|
273
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
274
|
+
</sp-action-button>
|
|
275
|
+
<sp-action-button label="Zoom in">
|
|
276
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
277
|
+
</sp-action-button>
|
|
278
|
+
</sp-action-group>
|
|
279
|
+
<sp-action-group compact vertical>
|
|
280
|
+
<sp-action-button label="Zoom in">
|
|
281
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
282
|
+
</sp-action-button>
|
|
283
|
+
<sp-action-button label="Zoom in">
|
|
284
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
285
|
+
</sp-action-button>
|
|
286
|
+
<sp-action-button label="Zoom in">
|
|
287
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
288
|
+
</sp-action-button>
|
|
289
|
+
</sp-action-group>
|
|
290
|
+
</div>
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
## Justified
|
|
294
|
+
|
|
295
|
+
The `justified` attribute will cause the `<sp-action-group>` element to fill the available horizontal space and evenly distribute that space across its child button elements.
|
|
296
|
+
|
|
297
|
+
```html
|
|
298
|
+
<sp-action-group justified>
|
|
299
|
+
<sp-action-button>
|
|
300
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
301
|
+
Button 1
|
|
302
|
+
</sp-action-button>
|
|
303
|
+
<sp-action-button>
|
|
304
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
305
|
+
Longer Button 2
|
|
306
|
+
</sp-action-button>
|
|
307
|
+
<sp-action-button>
|
|
308
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
309
|
+
Short 3
|
|
310
|
+
</sp-action-button>
|
|
311
|
+
</sp-action-group>
|
|
312
|
+
<br />
|
|
313
|
+
<sp-action-group justified compact>
|
|
314
|
+
<sp-action-button>
|
|
315
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
316
|
+
Button 1
|
|
317
|
+
</sp-action-button>
|
|
318
|
+
<sp-action-button>
|
|
319
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
320
|
+
Longer Button 2
|
|
321
|
+
</sp-action-button>
|
|
322
|
+
<sp-action-button>
|
|
323
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
324
|
+
Short 3
|
|
325
|
+
</sp-action-button>
|
|
326
|
+
</sp-action-group>
|
|
327
|
+
<br />
|
|
328
|
+
<sp-action-group justified quiet>
|
|
329
|
+
<sp-action-button label="Zoom in">
|
|
330
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
331
|
+
</sp-action-button>
|
|
332
|
+
<sp-action-button label="Zoom in">
|
|
333
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
334
|
+
</sp-action-button>
|
|
335
|
+
<sp-action-button label="Zoom in">
|
|
336
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
337
|
+
</sp-action-button>
|
|
338
|
+
</sp-action-group>
|
|
339
|
+
<br />
|
|
340
|
+
<sp-action-group compact justified>
|
|
341
|
+
<sp-action-button label="Zoom in">
|
|
342
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
343
|
+
</sp-action-button>
|
|
344
|
+
<sp-action-button label="Zoom in">
|
|
345
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
346
|
+
</sp-action-button>
|
|
347
|
+
<sp-action-button label="Zoom in">
|
|
348
|
+
<sp-icon-magnify slot="icon"></sp-icon-magnify>
|
|
349
|
+
</sp-action-button>
|
|
350
|
+
</sp-action-group>
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
## Accessibility
|
|
354
|
+
|
|
355
|
+
The accessibility `role` for an `<sp-action-group>` element depends on the manner in which items are selected. By default, `<sp-action-group selects="single">` will have `role="radiogroup"`, because it manages its children as a "radio group", while `<sp-action-group>` or `<sp-action-group selects="multiple">` will have `role="toolbar"`, which makes sense for a group of buttons or checkboxes between which one can navigate using the arrow keys.
|
|
356
|
+
|
|
357
|
+
When more than one `<sp-action-group>` elements are combined together with in a toolbar, the `role` attribute for `<sp-action-group>` or `<sp-action-group selects="multiple">` should be overwritten using `role="group"` or `role="presentation"`, so that toolbars are not nested, as demonstrated in the following example of a hypothetical toolbar for formatting text within a rich text editor:
|
|
358
|
+
|
|
359
|
+
<script type="module">
|
|
360
|
+
import '@spectrum-web-components/divider/sp-divider.js';
|
|
361
|
+
import '@spectrum-web-components/icons-workflow/icons/sp-icon-text-bold.js';
|
|
362
|
+
import '@spectrum-web-components/icons-workflow/icons/sp-icon-text-italic.js';
|
|
363
|
+
import '@spectrum-web-components/icons-workflow/icons/sp-icon-text-underline.js';
|
|
364
|
+
import '@spectrum-web-components/icons-workflow/icons/sp-icon-text-align-left.js';
|
|
365
|
+
import '@spectrum-web-components/icons-workflow/icons/sp-icon-text-align-center.js';
|
|
366
|
+
import '@spectrum-web-components/icons-workflow/icons/sp-icon-text-align-justify.js';
|
|
367
|
+
import '@spectrum-web-components/icons-workflow/icons/sp-icon-text-align-right.js';
|
|
368
|
+
import '@spectrum-web-components/icons-workflow/icons/sp-icon-text-bulleted.js';
|
|
369
|
+
import '@spectrum-web-components/icons-workflow/icons/sp-icon-text-numbered.js';
|
|
370
|
+
import '@spectrum-web-components/icons-workflow/icons/sp-icon-copy.js';
|
|
371
|
+
import '@spectrum-web-components/icons-workflow/icons/sp-icon-paste.js';
|
|
372
|
+
import '@spectrum-web-components/icons-workflow/icons/sp-icon-cut.js';
|
|
373
|
+
</script>
|
|
374
|
+
|
|
375
|
+
```html
|
|
376
|
+
<div
|
|
377
|
+
aria-label="Text Formatting"
|
|
378
|
+
role="toolbar"
|
|
379
|
+
style="height: 32px; display: flex; gap: 6px"
|
|
380
|
+
>
|
|
381
|
+
<sp-action-group
|
|
382
|
+
aria-label="Text Style"
|
|
383
|
+
selects="multiple"
|
|
384
|
+
role="group"
|
|
385
|
+
compact
|
|
386
|
+
emphasized
|
|
387
|
+
>
|
|
388
|
+
<sp-action-button label="Bold" value="bold">
|
|
389
|
+
<sp-icon-text-bold slot="icon"></sp-icon-text-bold>
|
|
390
|
+
</sp-action-button>
|
|
391
|
+
<sp-action-button label="Italic" value="italic">
|
|
392
|
+
<sp-icon-text-italic slot="icon"></sp-icon-text-italic>
|
|
393
|
+
</sp-action-button>
|
|
394
|
+
<sp-action-button label="Underline" value="underline">
|
|
395
|
+
<sp-icon-text-underline slot="icon"></sp-icon-text-underline>
|
|
396
|
+
</sp-action-button>
|
|
397
|
+
</sp-action-group>
|
|
398
|
+
<sp-divider
|
|
399
|
+
size="s"
|
|
400
|
+
style="align-self: stretch; height: auto;"
|
|
401
|
+
vertical
|
|
402
|
+
></sp-divider>
|
|
403
|
+
<sp-action-group
|
|
404
|
+
aria-label="Text Align"
|
|
405
|
+
selects="single"
|
|
406
|
+
compact
|
|
407
|
+
emphasized
|
|
408
|
+
>
|
|
409
|
+
<sp-action-button label="Left" value="left" selected>
|
|
410
|
+
<sp-icon-text-align-left slot="icon"></sp-icon-text-align-left>
|
|
411
|
+
</sp-action-button>
|
|
412
|
+
<sp-action-button label="Center" value="center">
|
|
413
|
+
<sp-icon-text-align-center slot="icon"></sp-icon-text-align-center>
|
|
414
|
+
</sp-action-button>
|
|
415
|
+
<sp-action-button label="Right" value="right">
|
|
416
|
+
<sp-icon-text-align-right slot="icon"></sp-icon-text-align-right>
|
|
417
|
+
</sp-action-button>
|
|
418
|
+
<sp-action-button label="Justify" value="justify">
|
|
419
|
+
<sp-icon-text-align-justify
|
|
420
|
+
slot="icon"
|
|
421
|
+
></sp-icon-text-align-justify>
|
|
422
|
+
</sp-action-button>
|
|
423
|
+
</sp-action-group>
|
|
424
|
+
<sp-divider
|
|
425
|
+
size="s"
|
|
426
|
+
style="align-self: stretch; height: auto;"
|
|
427
|
+
vertical
|
|
428
|
+
></sp-divider>
|
|
429
|
+
<sp-action-group
|
|
430
|
+
aria-label="List Style"
|
|
431
|
+
selects="multiple"
|
|
432
|
+
role="group"
|
|
433
|
+
compact
|
|
434
|
+
emphasized
|
|
435
|
+
>
|
|
436
|
+
<sp-action-button
|
|
437
|
+
label="Bulleted"
|
|
438
|
+
value="bulleted"
|
|
439
|
+
onclick="
|
|
440
|
+
/* makes mutually exclusive checkbox */
|
|
441
|
+
this.selected &&
|
|
442
|
+
requestAnimationFrame(() => this.parentElement.selected = []);
|
|
443
|
+
this.parentElement.selected = [];
|
|
444
|
+
"
|
|
445
|
+
>
|
|
446
|
+
<sp-icon-text-bulleted slot="icon"></sp-icon-text-bulleted>
|
|
447
|
+
</sp-action-button>
|
|
448
|
+
<sp-action-button
|
|
449
|
+
label="Numbering"
|
|
450
|
+
value="numbering"
|
|
451
|
+
onclick="
|
|
452
|
+
/* makes mutually exclusive checkbox */
|
|
453
|
+
this.selected &&
|
|
454
|
+
requestAnimationFrame(() => this.parentElement.selected = []);
|
|
455
|
+
this.parentElement.selected = [];
|
|
456
|
+
"
|
|
457
|
+
>
|
|
458
|
+
<sp-icon-text-numbered slot="icon"></sp-icon-text-numbered>
|
|
459
|
+
</sp-action-button>
|
|
460
|
+
</sp-action-group>
|
|
461
|
+
<sp-divider
|
|
462
|
+
size="s"
|
|
463
|
+
style="align-self: stretch; height: auto;"
|
|
464
|
+
vertical
|
|
465
|
+
></sp-divider>
|
|
466
|
+
<sp-action-group role="presentation" compact>
|
|
467
|
+
<sp-action-button disabled label="Copy" value="copy">
|
|
468
|
+
<sp-icon-copy slot="icon"></sp-icon-copy>
|
|
469
|
+
</sp-action-button>
|
|
470
|
+
<sp-action-button disabled label="Paste" value="paste">
|
|
471
|
+
<sp-icon-paste slot="icon"></sp-icon-paste>
|
|
472
|
+
</sp-action-button>
|
|
473
|
+
<sp-action-button disabled label="Cut" value="cut">
|
|
474
|
+
<sp-icon-cut slot="icon"></sp-icon-cut>
|
|
475
|
+
</sp-action-button>
|
|
476
|
+
</sp-action-group>
|
|
477
|
+
</div>
|
|
478
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@spectrum-web-components/action-group",
|
|
3
|
+
"version": "0.0.0-20241209155954",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"description": "",
|
|
8
|
+
"license": "Apache-2.0",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/adobe/spectrum-web-components.git",
|
|
12
|
+
"directory": "packages/action-group"
|
|
13
|
+
},
|
|
14
|
+
"author": "",
|
|
15
|
+
"homepage": "https://opensource.adobe.com/spectrum-web-components/components/action-group",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/adobe/spectrum-web-components/issues"
|
|
18
|
+
},
|
|
19
|
+
"main": "./src/index.js",
|
|
20
|
+
"module": "./src/index.js",
|
|
21
|
+
"type": "module",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"development": "./src/index.dev.js",
|
|
25
|
+
"default": "./src/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./package.json": "./package.json",
|
|
28
|
+
"./src/ActionGroup.js": {
|
|
29
|
+
"development": "./src/ActionGroup.dev.js",
|
|
30
|
+
"default": "./src/ActionGroup.js"
|
|
31
|
+
},
|
|
32
|
+
"./src/action-group-overrides.css.js": "./src/action-group-overrides.css.js",
|
|
33
|
+
"./src/action-group.css.js": "./src/action-group.css.js",
|
|
34
|
+
"./src/index.js": {
|
|
35
|
+
"development": "./src/index.dev.js",
|
|
36
|
+
"default": "./src/index.js"
|
|
37
|
+
},
|
|
38
|
+
"./sp-action-group.js": {
|
|
39
|
+
"development": "./sp-action-group.dev.js",
|
|
40
|
+
"default": "./sp-action-group.js"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"test": "karma start --coverage"
|
|
45
|
+
},
|
|
46
|
+
"files": [
|
|
47
|
+
"**/*.d.ts",
|
|
48
|
+
"**/*.js",
|
|
49
|
+
"**/*.js.map",
|
|
50
|
+
"custom-elements.json",
|
|
51
|
+
"!stories/",
|
|
52
|
+
"!test/"
|
|
53
|
+
],
|
|
54
|
+
"keywords": [
|
|
55
|
+
"spectrum css",
|
|
56
|
+
"web components",
|
|
57
|
+
"lit-element",
|
|
58
|
+
"lit-html"
|
|
59
|
+
],
|
|
60
|
+
"dependencies": {
|
|
61
|
+
"@lit-labs/observers": "^2.0.2",
|
|
62
|
+
"@spectrum-web-components/action-button": "0.0.0-20241209155954",
|
|
63
|
+
"@spectrum-web-components/base": "0.0.0-20241209155954",
|
|
64
|
+
"@spectrum-web-components/icons-workflow": "0.0.0-20241209155954",
|
|
65
|
+
"@spectrum-web-components/reactive-controllers": "0.0.0-20241209155954"
|
|
66
|
+
},
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"@spectrum-css/actiongroup": "^6.0.0-s2-foundations.15"
|
|
69
|
+
},
|
|
70
|
+
"types": "./src/index.d.ts",
|
|
71
|
+
"customElements": "custom-elements.json",
|
|
72
|
+
"sideEffects": [
|
|
73
|
+
"./sp-*.js",
|
|
74
|
+
"./**/*.dev.js"
|
|
75
|
+
]
|
|
76
|
+
}
|
|
@@ -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'\nimport { defineElement } from '@spectrum-web-components/base/src/define-element.js';\n\ndefineElement('sp-action-group', ActionGroup);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-action-group': ActionGroup;\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAYA,SAAS,mBAAmB;AAC5B,SAAS,qBAAqB;AAE9B,cAAc,mBAAmB,WAAW;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -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.js';\nimport { defineElement } from '@spectrum-web-components/base/src/define-element.js';\n\ndefineElement('sp-action-group', ActionGroup);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-action-group': ActionGroup;\n }\n}\n"],
|
|
5
|
+
"mappings": "aAYA,OAAS,eAAAA,MAAmB,uBAC5B,OAAS,iBAAAC,MAAqB,sDAE9BA,EAAc,kBAAmBD,CAAW",
|
|
6
|
+
"names": ["ActionGroup", "defineElement"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { CSSResultArray, PropertyValues, SpectrumElement, TemplateResult } from '@spectrum-web-components/base';
|
|
2
|
+
import type { ActionButton } from '@spectrum-web-components/action-button';
|
|
3
|
+
import { RovingTabindexController } from '@spectrum-web-components/reactive-controllers/src/RovingTabindex.js';
|
|
4
|
+
declare const ActionGroup_base: typeof SpectrumElement & {
|
|
5
|
+
new (...args: any[]): import("@spectrum-web-components/base").SizedElementInterface;
|
|
6
|
+
prototype: import("@spectrum-web-components/base").SizedElementInterface;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* @element sp-action-group
|
|
10
|
+
* @slot - the sp-action-button elements that make up the group
|
|
11
|
+
*
|
|
12
|
+
* @fires change - Announces that selection state has been changed by user
|
|
13
|
+
*/
|
|
14
|
+
export declare class ActionGroup extends ActionGroup_base {
|
|
15
|
+
static get styles(): CSSResultArray;
|
|
16
|
+
set buttons(buttons: ActionButton[]);
|
|
17
|
+
get buttons(): ActionButton[];
|
|
18
|
+
_buttons: ActionButton[];
|
|
19
|
+
protected _buttonSelector: string;
|
|
20
|
+
constructor();
|
|
21
|
+
rovingTabindexController: RovingTabindexController<ActionButton>;
|
|
22
|
+
compact: boolean;
|
|
23
|
+
emphasized: boolean;
|
|
24
|
+
justified: boolean;
|
|
25
|
+
label: string;
|
|
26
|
+
quiet: boolean;
|
|
27
|
+
selects: undefined | 'single' | 'multiple';
|
|
28
|
+
staticColor?: 'white' | 'black';
|
|
29
|
+
vertical: boolean;
|
|
30
|
+
private _selected;
|
|
31
|
+
set selected(selected: string[]);
|
|
32
|
+
get selected(): string[];
|
|
33
|
+
slotElement: HTMLSlotElement;
|
|
34
|
+
private dispatchChange;
|
|
35
|
+
private setSelected;
|
|
36
|
+
focus(options?: FocusOptions): void;
|
|
37
|
+
private deselectSelectedButtons;
|
|
38
|
+
private handleActionButtonChange;
|
|
39
|
+
private handleClick;
|
|
40
|
+
private applySelects;
|
|
41
|
+
private manageSelects;
|
|
42
|
+
protected render(): TemplateResult;
|
|
43
|
+
protected firstUpdated(changes: PropertyValues): void;
|
|
44
|
+
protected updated(changes: PropertyValues): void;
|
|
45
|
+
private manageChildren;
|
|
46
|
+
private hasManaged;
|
|
47
|
+
private manageButtons;
|
|
48
|
+
}
|
|
49
|
+
export {};
|