@spectrum-web-components/button 1.12.0-testing.20260223092154 → 2.0.0-next.20260512072922
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 +74 -11
- package/custom-elements.json +90 -9
- package/package.json +11 -10
- package/src/Button.d.ts +38 -6
- package/src/Button.dev.js +26 -2
- package/src/Button.dev.js.map +2 -2
- package/src/Button.js +2 -2
- package/src/Button.js.map +3 -3
- package/src/ButtonBase.d.ts +3 -2
- package/src/ButtonBase.dev.js +21 -4
- package/src/ButtonBase.dev.js.map +2 -2
- package/src/ButtonBase.js +3 -3
- package/src/ButtonBase.js.map +2 -2
- package/src/ClearButton.d.ts +1 -4
- package/src/CloseButton.d.ts +1 -4
package/README.md
CHANGED
|
@@ -90,7 +90,7 @@ fulfill the accessibility contract of the button.
|
|
|
90
90
|
<sp-tab-panel value="icon-only">
|
|
91
91
|
|
|
92
92
|
```html demo
|
|
93
|
-
<sp-button variant="primary" label="Icon only">
|
|
93
|
+
<sp-button variant="primary" icon-only label="Icon only">
|
|
94
94
|
<sp-icon-help slot="icon"></sp-icon-help>
|
|
95
95
|
</sp-button>
|
|
96
96
|
```
|
|
@@ -251,7 +251,7 @@ The `treatment` attribute accepts `fill` and `outline` as values, and defaults t
|
|
|
251
251
|
|
|
252
252
|
```html demo
|
|
253
253
|
<sp-button-group
|
|
254
|
-
style="background: var(--spectrum-
|
|
254
|
+
style="background: var(--spectrum-docs-static-black-background-color); padding: 0.5em; min-width: max-content"
|
|
255
255
|
>
|
|
256
256
|
<sp-button treatment="outline" static-color="black">Label only</sp-button>
|
|
257
257
|
<sp-button treatment="outline" static-color="black">
|
|
@@ -275,7 +275,7 @@ The `treatment` attribute accepts `fill` and `outline` as values, and defaults t
|
|
|
275
275
|
|
|
276
276
|
```html demo
|
|
277
277
|
<sp-button-group
|
|
278
|
-
style="background: var(--spectrum-
|
|
278
|
+
style="background: var(--spectrum-docs-static-white-background-color); padding: 0.5em; min-width: max-content"
|
|
279
279
|
>
|
|
280
280
|
<sp-button treatment="outline" static-color="white">Label only</sp-button>
|
|
281
281
|
<sp-button treatment="outline" static-color="white">
|
|
@@ -336,17 +336,39 @@ Events handlers for clicks and other user actions can be registered on a
|
|
|
336
336
|
<sp-button onclick="spAlert(this, '<sp-button> clicked!')">Click me</sp-button>
|
|
337
337
|
```
|
|
338
338
|
|
|
339
|
-
|
|
339
|
+
#### Link API deprecation
|
|
340
340
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
341
|
+
> **Deprecated**: The `href`, `target`, `download`, `referrerpolicy`, and `rel` attributes on `<sp-button>` are deprecated and will be removed in a future release. Use a native HTML anchor (`<a>`) element with the `spectrum-Button` class instead.
|
|
342
|
+
|
|
343
|
+
Using `<sp-button href="...">` conflates button and link semantics, which creates accessibility issues: screen reader users navigating by form controls will not find link-styled buttons, and vice versa. Native HTML elements provide correct semantics by default.
|
|
344
|
+
|
|
345
|
+
If you intend to create a link with a `href` attribute, we instead offer CSS classes for creating button-styled links. To migrate, import the global elements stylesheet and apply button classes to native `<a>` elements:
|
|
346
|
+
|
|
347
|
+
```css
|
|
348
|
+
@import '@spectrum-web-components/styles/global-elements.css';
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
**Before (deprecated):**
|
|
352
|
+
|
|
353
|
+
```html
|
|
354
|
+
<sp-button href="https://opensource.adobe.com/spectrum-web-components">
|
|
355
|
+
Visit docs
|
|
347
356
|
</sp-button>
|
|
348
357
|
```
|
|
349
358
|
|
|
359
|
+
**After (recommended):**
|
|
360
|
+
|
|
361
|
+
```html
|
|
362
|
+
<a
|
|
363
|
+
class="spectrum-Button spectrum-Button--accent"
|
|
364
|
+
href="https://opensource.adobe.com/spectrum-web-components"
|
|
365
|
+
>
|
|
366
|
+
Visit docs
|
|
367
|
+
</a>
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
See the [accessibility section](#use-a-static-button-styled-native-link-if-including-href) for more details.
|
|
371
|
+
|
|
350
372
|
#### Autofocus
|
|
351
373
|
|
|
352
374
|
The `autofocus` attribute sets focus on the `<sp-button>` when the component
|
|
@@ -374,14 +396,55 @@ or on an `<sp-icon*>` element child.
|
|
|
374
396
|
|
|
375
397
|
Do not use custom colors for buttons. The colors of different button variations have been designed to be consistent and accessible.
|
|
376
398
|
|
|
399
|
+
#### Use a static button-styled native link if including href
|
|
400
|
+
|
|
401
|
+
> **Deprecated**: The `href` attribute and other link-related properties (`target`, `download`, `referrerpolicy`, `rel`) on `<sp-button>` are deprecated and will be removed in a future release.
|
|
402
|
+
|
|
403
|
+
You may use a native link with classes to style it like a button. Refer to [the Storybook examples](https://opensource.adobe.com/spectrum-web-components/storybook/index.html?path=/story/button/) that include `href` for the appropriate classes to use.
|
|
404
|
+
|
|
405
|
+
For styles to be fully available to slotted links, you must include the stylesheet for `@spectrum-web-components/styles/global-elements.css`.
|
|
406
|
+
|
|
407
|
+
To successfully receive button styling, the link must be one of the following:
|
|
408
|
+
|
|
409
|
+
- A direct child of `<sp-theme>`
|
|
410
|
+
- A slotted child of a component within `<sp-theme>`
|
|
411
|
+
|
|
412
|
+
To allow button-styled native links in the shadow DOM of extended components, ensure their stylesheet also imports `@spectrum-web-components/styles/global-elements.css`.
|
|
413
|
+
|
|
414
|
+
**Note**: native button-styled links do not support disabled or pending states.
|
|
415
|
+
|
|
416
|
+
```html
|
|
417
|
+
<!--
|
|
418
|
+
Include in your own application stylesheet and extended component styles:
|
|
419
|
+
@import '@spectrum-web-components/styles/global-elements.css';
|
|
420
|
+
-->
|
|
421
|
+
|
|
422
|
+
<a
|
|
423
|
+
class="spectrum-Button spectrum-Button--accent"
|
|
424
|
+
href="https://github.com/adobe/spectrum-web-components"
|
|
425
|
+
>
|
|
426
|
+
Accent link button
|
|
427
|
+
</a>
|
|
428
|
+
<a
|
|
429
|
+
class="spectrum-Button spectrum-Button--secondary spectrum-Button--outline"
|
|
430
|
+
href="https://github.com/adobe/spectrum-web-components"
|
|
431
|
+
>
|
|
432
|
+
<!-- Use icon components and continue to define slot="icon" for the best styling support -->
|
|
433
|
+
<sp-icon-help slot="icon"></sp-icon-help>
|
|
434
|
+
Secondary outline link button
|
|
435
|
+
</a>
|
|
436
|
+
```
|
|
437
|
+
|
|
377
438
|
#### Don't mix href and non-href buttons in a set of buttons
|
|
378
439
|
|
|
379
|
-
A screen reader user will not encounter href buttons when navigating by buttons or form controls. While they can both be used in the same page problems could occur if mixing the types in close proximity to each other.
|
|
440
|
+
A screen reader user will not encounter href buttons when navigating by buttons or form controls. While they can both be used in the same page, problems could occur if mixing the types in close proximity to each other.
|
|
380
441
|
|
|
381
442
|
#### Use static black or static white to contrast with backgrounds and images
|
|
382
443
|
|
|
383
444
|
To ensure maximum contrast with the background, use static black for light backgrounds and images, and static white for dark backgrounds and images. Avoid placing static components on top of busy images with a lot of variance in contrast.
|
|
384
445
|
|
|
446
|
+
> **Contrast requirement**: When using `treatment="outline"` with `static-color`, the button's text, icons, and border must maintain a minimum **3:1** contrast ratio against the background per [WCAG 1.4.11 Non-text Contrast](https://www.w3.org/WAI/WCAG22/Understanding/non-text-contrast). Choose background colors carefully to meet this threshold. For example, `--spectrum-seafoam-600` provides only **2.5:1** contrast with white, which fails the requirement.
|
|
447
|
+
|
|
385
448
|
<sp-tabs selected="black" auto label="Static variants for contrast">
|
|
386
449
|
<sp-tab value="black">Static black on light background</sp-tab>
|
|
387
450
|
<sp-tab-panel value="black">
|
package/custom-elements.json
CHANGED
|
@@ -57,7 +57,8 @@
|
|
|
57
57
|
"type": {
|
|
58
58
|
"text": "array"
|
|
59
59
|
},
|
|
60
|
-
"default": "[ 'accent', 'primary', 'secondary', 'negative', 'white', 'black', ]"
|
|
60
|
+
"default": "[ 'accent', 'primary', 'secondary', 'negative', 'white', 'black', ]",
|
|
61
|
+
"deprecated": "The `VALID_VARIANTS` export is deprecated and will be removed\nin a future release."
|
|
61
62
|
},
|
|
62
63
|
{
|
|
63
64
|
"kind": "variable",
|
|
@@ -65,7 +66,8 @@
|
|
|
65
66
|
"type": {
|
|
66
67
|
"text": "array"
|
|
67
68
|
},
|
|
68
|
-
"default": "['white', 'black']"
|
|
69
|
+
"default": "['white', 'black']",
|
|
70
|
+
"deprecated": "The `VALID_STATIC_COLORS` export is deprecated and will be\nremoved in a future release."
|
|
69
71
|
},
|
|
70
72
|
{
|
|
71
73
|
"kind": "class",
|
|
@@ -169,6 +171,7 @@
|
|
|
169
171
|
"privacy": "public",
|
|
170
172
|
"default": "'fill'",
|
|
171
173
|
"description": "The visual treatment to apply to this button.",
|
|
174
|
+
"deprecated": "The `treatment` property is deprecated and will be replaced by\n`fill-style` in a future release.",
|
|
172
175
|
"attribute": "treatment",
|
|
173
176
|
"reflects": true
|
|
174
177
|
},
|
|
@@ -176,7 +179,8 @@
|
|
|
176
179
|
"kind": "field",
|
|
177
180
|
"name": "quiet",
|
|
178
181
|
"privacy": "public",
|
|
179
|
-
"description": "Style this button to be less obvious",
|
|
182
|
+
"description": "Style this button to be less obvious.",
|
|
183
|
+
"deprecated": "The `quiet` property is deprecated and will be removed in a\nfuture release.",
|
|
180
184
|
"type": {
|
|
181
185
|
"text": "boolean"
|
|
182
186
|
},
|
|
@@ -185,15 +189,24 @@
|
|
|
185
189
|
{
|
|
186
190
|
"kind": "field",
|
|
187
191
|
"name": "noWrap",
|
|
192
|
+
"privacy": "public",
|
|
193
|
+
"description": "Disables text wrapping within the button component's label.\nPlease note that this option is not a part of the design specification\nand should be used carefully, with consideration of this overflow behavior\nand the readability of the button's content.",
|
|
194
|
+
"deprecated": "The `no-wrap` attribute is deprecated and will be replaced by\n`truncate` in a future release.",
|
|
188
195
|
"type": {
|
|
189
196
|
"text": "boolean"
|
|
190
197
|
},
|
|
191
|
-
"privacy": "public",
|
|
192
|
-
"default": "false",
|
|
193
|
-
"description": "Disables text wrapping within the button component's label.\nPlease note that this option is not a part of the design specification\nand should be used carefully, with consideration of this overflow behavior\nand the readability of the button's content.",
|
|
194
198
|
"attribute": "no-wrap",
|
|
195
199
|
"reflects": true
|
|
196
200
|
},
|
|
201
|
+
{
|
|
202
|
+
"kind": "field",
|
|
203
|
+
"name": "_noWrap",
|
|
204
|
+
"type": {
|
|
205
|
+
"text": "boolean"
|
|
206
|
+
},
|
|
207
|
+
"privacy": "private",
|
|
208
|
+
"default": "false"
|
|
209
|
+
},
|
|
197
210
|
{
|
|
198
211
|
"kind": "method",
|
|
199
212
|
"name": "renderButton",
|
|
@@ -442,6 +455,20 @@
|
|
|
442
455
|
"name": "ButtonBase",
|
|
443
456
|
"module": "src/ButtonBase.js"
|
|
444
457
|
}
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
"kind": "method",
|
|
461
|
+
"name": "warnLinkAPIDeprecation",
|
|
462
|
+
"privacy": "private",
|
|
463
|
+
"return": {
|
|
464
|
+
"type": {
|
|
465
|
+
"text": "void"
|
|
466
|
+
}
|
|
467
|
+
},
|
|
468
|
+
"inheritedFrom": {
|
|
469
|
+
"name": "ButtonBase",
|
|
470
|
+
"module": "src/ButtonBase.js"
|
|
471
|
+
}
|
|
445
472
|
}
|
|
446
473
|
],
|
|
447
474
|
"attributes": [
|
|
@@ -484,11 +511,13 @@
|
|
|
484
511
|
},
|
|
485
512
|
"default": "'fill'",
|
|
486
513
|
"description": "The visual treatment to apply to this button.",
|
|
514
|
+
"deprecated": "The `treatment` property is deprecated and will be replaced by\n`fill-style` in a future release.",
|
|
487
515
|
"fieldName": "treatment"
|
|
488
516
|
},
|
|
489
517
|
{
|
|
490
518
|
"name": "quiet",
|
|
491
|
-
"description": "Style this button to be less obvious",
|
|
519
|
+
"description": "Style this button to be less obvious.",
|
|
520
|
+
"deprecated": "The `quiet` property is deprecated and will be removed in a\nfuture release.",
|
|
492
521
|
"type": {
|
|
493
522
|
"text": "boolean"
|
|
494
523
|
},
|
|
@@ -496,11 +525,11 @@
|
|
|
496
525
|
},
|
|
497
526
|
{
|
|
498
527
|
"name": "no-wrap",
|
|
528
|
+
"description": "Disables text wrapping within the button component's label.\nPlease note that this option is not a part of the design specification\nand should be used carefully, with consideration of this overflow behavior\nand the readability of the button's content.",
|
|
529
|
+
"deprecated": "The `no-wrap` attribute is deprecated and will be replaced by\n`truncate` in a future release.",
|
|
499
530
|
"type": {
|
|
500
531
|
"text": "boolean"
|
|
501
532
|
},
|
|
502
|
-
"default": "false",
|
|
503
|
-
"description": "Disables text wrapping within the button component's label.\nPlease note that this option is not a part of the design specification\nand should be used carefully, with consideration of this overflow behavior\nand the readability of the button's content.",
|
|
504
533
|
"fieldName": "noWrap"
|
|
505
534
|
},
|
|
506
535
|
{
|
|
@@ -777,6 +806,16 @@
|
|
|
777
806
|
"text": "void"
|
|
778
807
|
}
|
|
779
808
|
}
|
|
809
|
+
},
|
|
810
|
+
{
|
|
811
|
+
"kind": "method",
|
|
812
|
+
"name": "warnLinkAPIDeprecation",
|
|
813
|
+
"privacy": "private",
|
|
814
|
+
"return": {
|
|
815
|
+
"type": {
|
|
816
|
+
"text": "void"
|
|
817
|
+
}
|
|
818
|
+
}
|
|
780
819
|
}
|
|
781
820
|
],
|
|
782
821
|
"attributes": [
|
|
@@ -1134,6 +1173,20 @@
|
|
|
1134
1173
|
"name": "ButtonBase",
|
|
1135
1174
|
"module": "src/ButtonBase.js"
|
|
1136
1175
|
}
|
|
1176
|
+
},
|
|
1177
|
+
{
|
|
1178
|
+
"kind": "method",
|
|
1179
|
+
"name": "warnLinkAPIDeprecation",
|
|
1180
|
+
"privacy": "private",
|
|
1181
|
+
"return": {
|
|
1182
|
+
"type": {
|
|
1183
|
+
"text": "void"
|
|
1184
|
+
}
|
|
1185
|
+
},
|
|
1186
|
+
"inheritedFrom": {
|
|
1187
|
+
"name": "ButtonBase",
|
|
1188
|
+
"module": "src/ButtonBase.js"
|
|
1189
|
+
}
|
|
1137
1190
|
}
|
|
1138
1191
|
],
|
|
1139
1192
|
"attributes": [
|
|
@@ -1536,6 +1589,20 @@
|
|
|
1536
1589
|
"name": "ButtonBase",
|
|
1537
1590
|
"module": "src/ButtonBase.js"
|
|
1538
1591
|
}
|
|
1592
|
+
},
|
|
1593
|
+
{
|
|
1594
|
+
"kind": "method",
|
|
1595
|
+
"name": "warnLinkAPIDeprecation",
|
|
1596
|
+
"privacy": "private",
|
|
1597
|
+
"return": {
|
|
1598
|
+
"type": {
|
|
1599
|
+
"text": "void"
|
|
1600
|
+
}
|
|
1601
|
+
},
|
|
1602
|
+
"inheritedFrom": {
|
|
1603
|
+
"name": "ButtonBase",
|
|
1604
|
+
"module": "src/ButtonBase.js"
|
|
1605
|
+
}
|
|
1539
1606
|
}
|
|
1540
1607
|
],
|
|
1541
1608
|
"attributes": [
|
|
@@ -1912,6 +1979,20 @@
|
|
|
1912
1979
|
"name": "ButtonBase",
|
|
1913
1980
|
"module": "src/ButtonBase.js"
|
|
1914
1981
|
}
|
|
1982
|
+
},
|
|
1983
|
+
{
|
|
1984
|
+
"kind": "method",
|
|
1985
|
+
"name": "warnLinkAPIDeprecation",
|
|
1986
|
+
"privacy": "private",
|
|
1987
|
+
"return": {
|
|
1988
|
+
"type": {
|
|
1989
|
+
"text": "void"
|
|
1990
|
+
}
|
|
1991
|
+
},
|
|
1992
|
+
"inheritedFrom": {
|
|
1993
|
+
"name": "ButtonBase",
|
|
1994
|
+
"module": "src/ButtonBase.js"
|
|
1995
|
+
}
|
|
1915
1996
|
}
|
|
1916
1997
|
]
|
|
1917
1998
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/button",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-next.20260512072922",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Adobe",
|
|
@@ -79,14 +79,14 @@
|
|
|
79
79
|
],
|
|
80
80
|
"types": "./src/index.d.ts",
|
|
81
81
|
"dependencies": {
|
|
82
|
-
"@spectrum-web-components/base": "
|
|
83
|
-
"@spectrum-web-components/clear-button": "
|
|
84
|
-
"@spectrum-web-components/close-button": "
|
|
85
|
-
"@spectrum-web-components/icon": "
|
|
86
|
-
"@spectrum-web-components/icons-ui": "
|
|
87
|
-
"@spectrum-web-components/progress-circle": "
|
|
88
|
-
"@spectrum-web-components/reactive-controllers": "
|
|
89
|
-
"@spectrum-web-components/shared": "
|
|
82
|
+
"@spectrum-web-components/base": "2.0.0-next.20260512072922",
|
|
83
|
+
"@spectrum-web-components/clear-button": "2.0.0-next.20260512072922",
|
|
84
|
+
"@spectrum-web-components/close-button": "2.0.0-next.20260512072922",
|
|
85
|
+
"@spectrum-web-components/icon": "2.0.0-next.20260512072922",
|
|
86
|
+
"@spectrum-web-components/icons-ui": "2.0.0-next.20260512072922",
|
|
87
|
+
"@spectrum-web-components/progress-circle": "2.0.0-next.20260512072922",
|
|
88
|
+
"@spectrum-web-components/reactive-controllers": "2.0.0-next.20260512072922",
|
|
89
|
+
"@spectrum-web-components/shared": "2.0.0-next.20260512072922"
|
|
90
90
|
},
|
|
91
91
|
"keywords": [
|
|
92
92
|
"design-system",
|
|
@@ -103,5 +103,6 @@
|
|
|
103
103
|
"publishConfig": {
|
|
104
104
|
"access": "public"
|
|
105
105
|
},
|
|
106
|
-
"customElements": "custom-elements.json"
|
|
106
|
+
"customElements": "custom-elements.json",
|
|
107
|
+
"deprecationNotice": "The link API features (href, target, download, referrerpolicy, rel) in @spectrum-web-components/button are deprecated and will be removed in a future release. Use a native HTML anchor element with the spectrum-Button class and @spectrum-web-components/styles/global-elements.css instead."
|
|
107
108
|
}
|
package/src/Button.d.ts
CHANGED
|
@@ -12,16 +12,37 @@
|
|
|
12
12
|
import { CSSResultArray, PropertyValues, TemplateResult } from '@spectrum-web-components/base';
|
|
13
13
|
import { PendingStateController } from '@spectrum-web-components/reactive-controllers/src/PendingState.js';
|
|
14
14
|
import { ButtonBase } from './ButtonBase.js';
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated The `DeprecatedButtonVariants` type export is deprecated and will
|
|
17
|
+
* be removed in a future release.
|
|
18
|
+
*/
|
|
15
19
|
export type DeprecatedButtonVariants = 'cta' | 'overBackground';
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated The `ButtonStaticColors` type export is deprecated and will be
|
|
22
|
+
* removed in a future release.
|
|
23
|
+
*/
|
|
16
24
|
export type ButtonStaticColors = 'white' | 'black';
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated The `ButtonVariants` type export is deprecated and will be
|
|
27
|
+
* removed in a future release.
|
|
28
|
+
*/
|
|
17
29
|
export type ButtonVariants = 'accent' | 'primary' | 'secondary' | 'negative' | ButtonStaticColors | DeprecatedButtonVariants;
|
|
30
|
+
/**
|
|
31
|
+
* @deprecated The `VALID_VARIANTS` export is deprecated and will be removed
|
|
32
|
+
* in a future release.
|
|
33
|
+
*/
|
|
18
34
|
export declare const VALID_VARIANTS: string[];
|
|
35
|
+
/**
|
|
36
|
+
* @deprecated The `VALID_STATIC_COLORS` export is deprecated and will be
|
|
37
|
+
* removed in a future release.
|
|
38
|
+
*/
|
|
19
39
|
export declare const VALID_STATIC_COLORS: string[];
|
|
40
|
+
/**
|
|
41
|
+
* @deprecated The `ButtonTreatments` type export is deprecated and will be
|
|
42
|
+
* removed in a future release.
|
|
43
|
+
*/
|
|
20
44
|
export type ButtonTreatments = 'fill' | 'outline';
|
|
21
|
-
declare const Button_base: typeof ButtonBase &
|
|
22
|
-
new (...args: any[]): import("@spectrum-web-components/base").SizedElementInterface;
|
|
23
|
-
prototype: import("@spectrum-web-components/base").SizedElementInterface;
|
|
24
|
-
} & import("@spectrum-web-components/core/mixins").SizedElementConstructor;
|
|
45
|
+
declare const Button_base: typeof ButtonBase & import("@spectrum-web-components/base").Constructor<import("@spectrum-web-components/base").SizedElementInterface> & import("@spectrum-web-components/base").SizedElementConstructor;
|
|
25
46
|
/**
|
|
26
47
|
* @element sp-button
|
|
27
48
|
*
|
|
@@ -51,10 +72,16 @@ export declare class Button extends Button_base {
|
|
|
51
72
|
staticColor?: 'black' | 'white';
|
|
52
73
|
/**
|
|
53
74
|
* The visual treatment to apply to this button.
|
|
75
|
+
*
|
|
76
|
+
* @deprecated The `treatment` property is deprecated and will be replaced by
|
|
77
|
+
* `fill-style` in a future release.
|
|
54
78
|
*/
|
|
55
79
|
treatment: ButtonTreatments;
|
|
56
80
|
/**
|
|
57
|
-
* Style this button to be less obvious
|
|
81
|
+
* Style this button to be less obvious.
|
|
82
|
+
*
|
|
83
|
+
* @deprecated The `quiet` property is deprecated and will be removed in a
|
|
84
|
+
* future release.
|
|
58
85
|
*/
|
|
59
86
|
set quiet(quiet: boolean);
|
|
60
87
|
/**
|
|
@@ -62,8 +89,13 @@ export declare class Button extends Button_base {
|
|
|
62
89
|
* Please note that this option is not a part of the design specification
|
|
63
90
|
* and should be used carefully, with consideration of this overflow behavior
|
|
64
91
|
* and the readability of the button's content.
|
|
92
|
+
*
|
|
93
|
+
* @deprecated The `no-wrap` attribute is deprecated and will be replaced by
|
|
94
|
+
* `truncate` in a future release.
|
|
65
95
|
*/
|
|
66
|
-
noWrap: boolean;
|
|
96
|
+
set noWrap(value: boolean);
|
|
97
|
+
get noWrap(): boolean;
|
|
98
|
+
private _noWrap;
|
|
67
99
|
get quiet(): boolean;
|
|
68
100
|
protected firstUpdated(changes: PropertyValues<this>): void;
|
|
69
101
|
protected renderButton(): TemplateResult;
|
package/src/Button.dev.js
CHANGED
|
@@ -37,7 +37,7 @@ export class Button extends SizedMixin(ButtonBase, { noDefaultSize: true }) {
|
|
|
37
37
|
this.pending = false;
|
|
38
38
|
this._variant = "accent";
|
|
39
39
|
this.treatment = "fill";
|
|
40
|
-
this.
|
|
40
|
+
this._noWrap = false;
|
|
41
41
|
this.pendingStateController = new PendingStateController(this);
|
|
42
42
|
}
|
|
43
43
|
static get styles() {
|
|
@@ -118,6 +118,30 @@ export class Button extends SizedMixin(ButtonBase, { noDefaultSize: true }) {
|
|
|
118
118
|
}
|
|
119
119
|
set quiet(quiet) {
|
|
120
120
|
this.treatment = quiet ? "outline" : "fill";
|
|
121
|
+
if (true) {
|
|
122
|
+
window.__swc.warn(
|
|
123
|
+
this,
|
|
124
|
+
`The "quiet" property on <${this.localName}> has been deprecated and will be removed in a future release.`,
|
|
125
|
+
"https://opensource.adobe.com/spectrum-web-components/components/button",
|
|
126
|
+
{ level: "deprecation" }
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
set noWrap(value) {
|
|
131
|
+
const oldValue = this._noWrap;
|
|
132
|
+
this._noWrap = value;
|
|
133
|
+
this.requestUpdate("noWrap", oldValue);
|
|
134
|
+
if (true) {
|
|
135
|
+
window.__swc.warn(
|
|
136
|
+
this,
|
|
137
|
+
`The "no-wrap" attribute on <${this.localName}> has been deprecated and will be replaced by "truncate" in a future release.`,
|
|
138
|
+
"https://opensource.adobe.com/spectrum-web-components/components/button",
|
|
139
|
+
{ level: "deprecation" }
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
get noWrap() {
|
|
144
|
+
return this._noWrap;
|
|
121
145
|
}
|
|
122
146
|
get quiet() {
|
|
123
147
|
return this.treatment === "outline";
|
|
@@ -157,5 +181,5 @@ __decorateClass([
|
|
|
157
181
|
], Button.prototype, "quiet", 1);
|
|
158
182
|
__decorateClass([
|
|
159
183
|
property({ type: Boolean, attribute: "no-wrap", reflect: true })
|
|
160
|
-
], Button.prototype, "noWrap",
|
|
184
|
+
], Button.prototype, "noWrap", 1);
|
|
161
185
|
//# sourceMappingURL=Button.dev.js.map
|
package/src/Button.dev.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["Button.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport {\n CSSResultArray,\n html,\n PropertyValues,\n SizedMixin,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport { PendingStateController } from '@spectrum-web-components/reactive-controllers/src/PendingState.js';\n\nimport buttonStyles from './button.css.js';\nimport { ButtonBase } from './ButtonBase.dev.js'\n\nexport type DeprecatedButtonVariants = 'cta' | 'overBackground';\nexport type ButtonStaticColors = 'white' | 'black';\nexport type ButtonVariants =\n | 'accent'\n | 'primary'\n | 'secondary'\n | 'negative'\n | ButtonStaticColors\n | DeprecatedButtonVariants;\nexport const VALID_VARIANTS = [\n 'accent',\n 'primary',\n 'secondary',\n 'negative',\n 'white',\n 'black',\n];\nexport const VALID_STATIC_COLORS = ['white', 'black'];\n\nexport type ButtonTreatments = 'fill' | 'outline';\n\n/**\n * @element sp-button\n *\n * @slot - text label of the Button\n * @slot icon - The icon to use for Button\n */\nexport class Button extends SizedMixin(ButtonBase, { noDefaultSize: true }) {\n public static override get styles(): CSSResultArray {\n return [...super.styles, buttonStyles];\n }\n\n @property({ type: String, attribute: 'pending-label' })\n public pendingLabel = 'Pending';\n\n // Use this property to set the button into a pending state\n @property({ type: Boolean, reflect: true, attribute: true })\n public pending = false;\n\n public pendingStateController: PendingStateController<this>;\n\n /**\n * Initializes the `PendingStateController` for the Button component.\n * The `PendingStateController` manages the pending state of the Button.\n */\n constructor() {\n super();\n this.pendingStateController = new PendingStateController(this);\n }\n\n public override click(): void {\n if (this.pending) {\n return;\n }\n super.click();\n }\n\n /**\n * The visual variant to apply to this button.\n */\n @property()\n public get variant(): ButtonVariants {\n return this._variant;\n }\n public set variant(variant: ButtonVariants) {\n if (variant === this.variant) {\n return;\n }\n\n this.requestUpdate('variant', this.variant);\n switch (variant) {\n case 'cta':\n this._variant = 'accent';\n if (window.__swc?.DEBUG) {\n window.__swc.warn(\n this,\n `The \"cta\" value of the \"variant\" attribute on <${this.localName}> has been deprecated and will be removed in a future release. Use \"variant='accent'\" instead.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/button/#variants',\n { level: 'deprecation' }\n );\n }\n break;\n case 'overBackground':\n this.removeAttribute('variant');\n this.staticColor = 'white';\n this.treatment = 'outline';\n if (window.__swc?.DEBUG) {\n window.__swc.warn(\n this,\n `The \"overBackground\" value of the \"variant\" attribute on <${this.localName}> has been deprecated and will be removed in a future release. Use \"staticColor='white'\" with \"treatment='outline'\" instead.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/button',\n { level: 'deprecation' }\n );\n }\n return;\n case 'white':\n this.staticColor = 'white';\n if (window.__swc?.DEBUG) {\n window.__swc.warn(\n this,\n `The \"white\" value of the \"variant\" attribute on <${this.localName}> has been deprecated and will be removed in a future release. Use \"static-color='white'\" instead.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/button/api',\n { level: 'deprecation' }\n );\n }\n return;\n case 'black':\n this.staticColor = 'black';\n if (window.__swc?.DEBUG) {\n window.__swc.warn(\n this,\n `The \"black\" value of the \"variant\" attribute on <${this.localName}> has been deprecated and will be removed in a future release. Use \"static-color='black'\" instead.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/button/api',\n { level: 'deprecation' }\n );\n }\n return;\n case null:\n return;\n default:\n if (!VALID_VARIANTS.includes(variant)) {\n this._variant = 'accent';\n } else {\n this._variant = variant;\n }\n break;\n }\n this.setAttribute('variant', this.variant);\n }\n private _variant: ButtonVariants = 'accent';\n\n /**\n * The static color variant to use for this button.\n */\n @property({ reflect: true, attribute: 'static-color' })\n public staticColor?: 'black' | 'white';\n\n /**\n * The visual treatment to apply to this button.\n */\n @property({ reflect: true })\n public treatment: ButtonTreatments = 'fill';\n\n /**\n * Style this button to be less obvious\n */\n @property({ type: Boolean })\n public set quiet(quiet: boolean) {\n this.treatment = quiet ? 'outline' : 'fill';\n }\n\n /**\n * Disables text wrapping within the button component's label.\n * Please note that this option is not a part of the design specification\n * and should be used carefully, with consideration of this overflow behavior\n * and the readability of the button's content.\n */\n @property({ type: Boolean, attribute: 'no-wrap', reflect: true })\n public noWrap = false;\n\n public get quiet(): boolean {\n return this.treatment === 'outline';\n }\n\n protected override firstUpdated(changes: PropertyValues<this>): void {\n super.firstUpdated(changes);\n // There is no Spectrum design context for an `<sp-button>` without a variant\n // apply one manually when a consumer has not applied one themselves.\n\n if (!this.hasAttribute('variant')) {\n this.setAttribute('variant', this.variant);\n }\n if (this.pending) {\n this.pendingStateController.hostUpdated();\n }\n }\n\n protected override renderButton(): TemplateResult {\n return html`\n ${this.buttonContent} ${this.pendingStateController.renderPendingState()}\n `;\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;AAWA;AAAA,EAEE;AAAA,EAEA;AAAA,OAEK;AACP,SAAS,gBAAgB;AACzB,SAAS,8BAA8B;AAEvC,OAAO,kBAAkB;AACzB,SAAS,kBAAkB;
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport {\n CSSResultArray,\n html,\n PropertyValues,\n SizedMixin,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport { PendingStateController } from '@spectrum-web-components/reactive-controllers/src/PendingState.js';\n\nimport buttonStyles from './button.css.js';\nimport { ButtonBase } from './ButtonBase.dev.js'\n\n/**\n * @deprecated The `DeprecatedButtonVariants` type export is deprecated and will\n * be removed in a future release.\n */\nexport type DeprecatedButtonVariants = 'cta' | 'overBackground';\n\n/**\n * @deprecated The `ButtonStaticColors` type export is deprecated and will be\n * removed in a future release.\n */\nexport type ButtonStaticColors = 'white' | 'black';\n\n/**\n * @deprecated The `ButtonVariants` type export is deprecated and will be\n * removed in a future release.\n */\nexport type ButtonVariants =\n | 'accent'\n | 'primary'\n | 'secondary'\n | 'negative'\n | ButtonStaticColors\n | DeprecatedButtonVariants;\n\n/**\n * @deprecated The `VALID_VARIANTS` export is deprecated and will be removed\n * in a future release.\n */\nexport const VALID_VARIANTS = [\n 'accent',\n 'primary',\n 'secondary',\n 'negative',\n 'white',\n 'black',\n];\n\n/**\n * @deprecated The `VALID_STATIC_COLORS` export is deprecated and will be\n * removed in a future release.\n */\nexport const VALID_STATIC_COLORS = ['white', 'black'];\n\n/**\n * @deprecated The `ButtonTreatments` type export is deprecated and will be\n * removed in a future release.\n */\nexport type ButtonTreatments = 'fill' | 'outline';\n\n/**\n * @element sp-button\n *\n * @slot - text label of the Button\n * @slot icon - The icon to use for Button\n */\nexport class Button extends SizedMixin(ButtonBase, { noDefaultSize: true }) {\n public static override get styles(): CSSResultArray {\n return [...super.styles, buttonStyles];\n }\n\n @property({ type: String, attribute: 'pending-label' })\n public pendingLabel = 'Pending';\n\n // Use this property to set the button into a pending state\n @property({ type: Boolean, reflect: true, attribute: true })\n public pending = false;\n\n public pendingStateController: PendingStateController<this>;\n\n /**\n * Initializes the `PendingStateController` for the Button component.\n * The `PendingStateController` manages the pending state of the Button.\n */\n constructor() {\n super();\n this.pendingStateController = new PendingStateController(this);\n }\n\n public override click(): void {\n if (this.pending) {\n return;\n }\n super.click();\n }\n\n /**\n * The visual variant to apply to this button.\n */\n @property()\n public get variant(): ButtonVariants {\n return this._variant;\n }\n public set variant(variant: ButtonVariants) {\n if (variant === this.variant) {\n return;\n }\n\n this.requestUpdate('variant', this.variant);\n switch (variant) {\n case 'cta':\n this._variant = 'accent';\n if (window.__swc?.DEBUG) {\n window.__swc.warn(\n this,\n `The \"cta\" value of the \"variant\" attribute on <${this.localName}> has been deprecated and will be removed in a future release. Use \"variant='accent'\" instead.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/button/#variants',\n { level: 'deprecation' }\n );\n }\n break;\n case 'overBackground':\n this.removeAttribute('variant');\n this.staticColor = 'white';\n this.treatment = 'outline';\n if (window.__swc?.DEBUG) {\n window.__swc.warn(\n this,\n `The \"overBackground\" value of the \"variant\" attribute on <${this.localName}> has been deprecated and will be removed in a future release. Use \"staticColor='white'\" with \"treatment='outline'\" instead.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/button',\n { level: 'deprecation' }\n );\n }\n return;\n case 'white':\n this.staticColor = 'white';\n if (window.__swc?.DEBUG) {\n window.__swc.warn(\n this,\n `The \"white\" value of the \"variant\" attribute on <${this.localName}> has been deprecated and will be removed in a future release. Use \"static-color='white'\" instead.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/button/api',\n { level: 'deprecation' }\n );\n }\n return;\n case 'black':\n this.staticColor = 'black';\n if (window.__swc?.DEBUG) {\n window.__swc.warn(\n this,\n `The \"black\" value of the \"variant\" attribute on <${this.localName}> has been deprecated and will be removed in a future release. Use \"static-color='black'\" instead.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/button/api',\n { level: 'deprecation' }\n );\n }\n return;\n case null:\n return;\n default:\n if (!VALID_VARIANTS.includes(variant)) {\n this._variant = 'accent';\n } else {\n this._variant = variant;\n }\n break;\n }\n this.setAttribute('variant', this.variant);\n }\n private _variant: ButtonVariants = 'accent';\n\n /**\n * The static color variant to use for this button.\n */\n @property({ reflect: true, attribute: 'static-color' })\n public staticColor?: 'black' | 'white';\n\n /**\n * The visual treatment to apply to this button.\n *\n * @deprecated The `treatment` property is deprecated and will be replaced by\n * `fill-style` in a future release.\n */\n @property({ reflect: true })\n public treatment: ButtonTreatments = 'fill';\n\n /**\n * Style this button to be less obvious.\n *\n * @deprecated The `quiet` property is deprecated and will be removed in a\n * future release.\n */\n @property({ type: Boolean })\n public set quiet(quiet: boolean) {\n this.treatment = quiet ? 'outline' : 'fill';\n if (window.__swc?.DEBUG) {\n window.__swc.warn(\n this,\n `The \"quiet\" property on <${this.localName}> has been deprecated and will be removed in a future release.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/button',\n { level: 'deprecation' }\n );\n }\n }\n\n /**\n * Disables text wrapping within the button component's label.\n * Please note that this option is not a part of the design specification\n * and should be used carefully, with consideration of this overflow behavior\n * and the readability of the button's content.\n *\n * @deprecated The `no-wrap` attribute is deprecated and will be replaced by\n * `truncate` in a future release.\n */\n @property({ type: Boolean, attribute: 'no-wrap', reflect: true })\n public set noWrap(value: boolean) {\n const oldValue = this._noWrap;\n this._noWrap = value;\n this.requestUpdate('noWrap', oldValue);\n if (window.__swc?.DEBUG) {\n window.__swc.warn(\n this,\n `The \"no-wrap\" attribute on <${this.localName}> has been deprecated and will be replaced by \"truncate\" in a future release.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/button',\n { level: 'deprecation' }\n );\n }\n }\n\n public get noWrap(): boolean {\n return this._noWrap;\n }\n private _noWrap = false;\n\n public get quiet(): boolean {\n return this.treatment === 'outline';\n }\n\n protected override firstUpdated(changes: PropertyValues<this>): void {\n super.firstUpdated(changes);\n // There is no Spectrum design context for an `<sp-button>` without a variant\n // apply one manually when a consumer has not applied one themselves.\n\n if (!this.hasAttribute('variant')) {\n this.setAttribute('variant', this.variant);\n }\n if (this.pending) {\n this.pendingStateController.hostUpdated();\n }\n }\n\n protected override renderButton(): TemplateResult {\n return html`\n ${this.buttonContent} ${this.pendingStateController.renderPendingState()}\n `;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;AAWA;AAAA,EAEE;AAAA,EAEA;AAAA,OAEK;AACP,SAAS,gBAAgB;AACzB,SAAS,8BAA8B;AAEvC,OAAO,kBAAkB;AACzB,SAAS,kBAAkB;AA8BpB,aAAM,iBAA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AA,IAC3C;AACA,QAAI,KAAK,SAAS;AAChB,WAAK,uBAAuB,YAAY;AAAA,IAC1C;AAAA,EACF;AAAA,EAEmB,eAA+B;AAChD,WAAO;AAAA,QACH,KAAK,aAAa,IAAI,KAAK,uBAAuB,mBAAmB,CAAC;AAAA;AAAA,EAE5E;AACF;AAvLS;AAAA,EADN,SAAS,EAAE,MAAM,QAAQ,WAAW,gBAAgB,CAAC;AAAA,GAL3C,OAMJ;AAIA;AAAA,EADN,SAAS,EAAE,MAAM,SAAS,SAAS,MAAM,WAAW,KAAK,CAAC;AAAA,GAThD,OAUJ;AAwBI;AAAA,EADV,SAAS;AAAA,GAjCC,OAkCA;AA0EJ;AAAA,EADN,SAAS,EAAE,SAAS,MAAM,WAAW,eAAe,CAAC;AAAA,GA3G3C,OA4GJ;AASA;AAAA,EADN,SAAS,EAAE,SAAS,KAAK,CAAC;AAAA,GApHhB,OAqHJ;AASI;AAAA,EADV,SAAS,EAAE,MAAM,QAAQ,CAAC;AAAA,GA7HhB,OA8HA;AAsBA;AAAA,EADV,SAAS,EAAE,MAAM,SAAS,WAAW,WAAW,SAAS,KAAK,CAAC;AAAA,GAnJrD,OAoJA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/Button.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var l=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var t=(o,i,e,n)=>{for(var a=n>1?void 0:n?p(i,e):i,s=o.length-1,c;s>=0;s--)(c=o[s])&&(a=(n?c(i,e,a):c(a))||a);return n&&a&&l(i,e,a),a};import{html as u,SizedMixin as d}from"@spectrum-web-components/base";import{property as r}from"@spectrum-web-components/base/src/decorators.js";import{PendingStateController as h}from"@spectrum-web-components/reactive-controllers/src/PendingState.js";import b from"./button.css.js";import{ButtonBase as w}from"./ButtonBase.js";export const VALID_VARIANTS=["accent","primary","secondary","negative","white","black"],VALID_STATIC_COLORS=["white","black"];export class Button extends d(w,{noDefaultSize:!0}){constructor(){super();this.pendingLabel="Pending";this.pending=!1;this._variant="accent";this.treatment="fill";this._noWrap=!1;this.pendingStateController=new h(this)}static get styles(){return[...super.styles,b]}click(){this.pending||super.click()}get variant(){return this._variant}set variant(e){if(e!==this.variant){switch(this.requestUpdate("variant",this.variant),e){case"cta":this._variant="accent";break;case"overBackground":this.removeAttribute("variant"),this.staticColor="white",this.treatment="outline";return;case"white":this.staticColor="white";return;case"black":this.staticColor="black";return;case null:return;default:VALID_VARIANTS.includes(e)?this._variant=e:this._variant="accent";break}this.setAttribute("variant",this.variant)}}set quiet(e){this.treatment=e?"outline":"fill"}set noWrap(e){const n=this._noWrap;this._noWrap=e,this.requestUpdate("noWrap",n)}get noWrap(){return this._noWrap}get quiet(){return this.treatment==="outline"}firstUpdated(e){super.firstUpdated(e),this.hasAttribute("variant")||this.setAttribute("variant",this.variant),this.pending&&this.pendingStateController.hostUpdated()}renderButton(){return u`
|
|
2
2
|
${this.buttonContent} ${this.pendingStateController.renderPendingState()}
|
|
3
|
-
`}}
|
|
3
|
+
`}}t([r({type:String,attribute:"pending-label"})],Button.prototype,"pendingLabel",2),t([r({type:Boolean,reflect:!0,attribute:!0})],Button.prototype,"pending",2),t([r()],Button.prototype,"variant",1),t([r({reflect:!0,attribute:"static-color"})],Button.prototype,"staticColor",2),t([r({reflect:!0})],Button.prototype,"treatment",2),t([r({type:Boolean})],Button.prototype,"quiet",1),t([r({type:Boolean,attribute:"no-wrap",reflect:!0})],Button.prototype,"noWrap",1);
|
|
4
4
|
//# sourceMappingURL=Button.js.map
|
package/src/Button.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["Button.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport {\n CSSResultArray,\n html,\n PropertyValues,\n SizedMixin,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport { PendingStateController } from '@spectrum-web-components/reactive-controllers/src/PendingState.js';\n\nimport buttonStyles from './button.css.js';\nimport { ButtonBase } from './ButtonBase.js';\n\nexport type DeprecatedButtonVariants = 'cta' | 'overBackground';\nexport type ButtonStaticColors = 'white' | 'black';\nexport type ButtonVariants =\n | 'accent'\n | 'primary'\n | 'secondary'\n | 'negative'\n | ButtonStaticColors\n | DeprecatedButtonVariants;\nexport const VALID_VARIANTS = [\n 'accent',\n 'primary',\n 'secondary',\n 'negative',\n 'white',\n 'black',\n];\nexport const VALID_STATIC_COLORS = ['white', 'black'];\n\nexport type ButtonTreatments = 'fill' | 'outline';\n\n/**\n * @element sp-button\n *\n * @slot - text label of the Button\n * @slot icon - The icon to use for Button\n */\nexport class Button extends SizedMixin(ButtonBase, { noDefaultSize: true }) {\n public static override get styles(): CSSResultArray {\n return [...super.styles, buttonStyles];\n }\n\n @property({ type: String, attribute: 'pending-label' })\n public pendingLabel = 'Pending';\n\n // Use this property to set the button into a pending state\n @property({ type: Boolean, reflect: true, attribute: true })\n public pending = false;\n\n public pendingStateController: PendingStateController<this>;\n\n /**\n * Initializes the `PendingStateController` for the Button component.\n * The `PendingStateController` manages the pending state of the Button.\n */\n constructor() {\n super();\n this.pendingStateController = new PendingStateController(this);\n }\n\n public override click(): void {\n if (this.pending) {\n return;\n }\n super.click();\n }\n\n /**\n * The visual variant to apply to this button.\n */\n @property()\n public get variant(): ButtonVariants {\n return this._variant;\n }\n public set variant(variant: ButtonVariants) {\n if (variant === this.variant) {\n return;\n }\n\n this.requestUpdate('variant', this.variant);\n switch (variant) {\n case 'cta':\n this._variant = 'accent';\n if (window.__swc?.DEBUG) {\n window.__swc.warn(\n this,\n `The \"cta\" value of the \"variant\" attribute on <${this.localName}> has been deprecated and will be removed in a future release. Use \"variant='accent'\" instead.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/button/#variants',\n { level: 'deprecation' }\n );\n }\n break;\n case 'overBackground':\n this.removeAttribute('variant');\n this.staticColor = 'white';\n this.treatment = 'outline';\n if (window.__swc?.DEBUG) {\n window.__swc.warn(\n this,\n `The \"overBackground\" value of the \"variant\" attribute on <${this.localName}> has been deprecated and will be removed in a future release. Use \"staticColor='white'\" with \"treatment='outline'\" instead.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/button',\n { level: 'deprecation' }\n );\n }\n return;\n case 'white':\n this.staticColor = 'white';\n if (window.__swc?.DEBUG) {\n window.__swc.warn(\n this,\n `The \"white\" value of the \"variant\" attribute on <${this.localName}> has been deprecated and will be removed in a future release. Use \"static-color='white'\" instead.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/button/api',\n { level: 'deprecation' }\n );\n }\n return;\n case 'black':\n this.staticColor = 'black';\n if (window.__swc?.DEBUG) {\n window.__swc.warn(\n this,\n `The \"black\" value of the \"variant\" attribute on <${this.localName}> has been deprecated and will be removed in a future release. Use \"static-color='black'\" instead.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/button/api',\n { level: 'deprecation' }\n );\n }\n return;\n case null:\n return;\n default:\n if (!VALID_VARIANTS.includes(variant)) {\n this._variant = 'accent';\n } else {\n this._variant = variant;\n }\n break;\n }\n this.setAttribute('variant', this.variant);\n }\n private _variant: ButtonVariants = 'accent';\n\n /**\n * The static color variant to use for this button.\n */\n @property({ reflect: true, attribute: 'static-color' })\n public staticColor?: 'black' | 'white';\n\n /**\n * The visual treatment to apply to this button.\n */\n @property({ reflect: true })\n public treatment: ButtonTreatments = 'fill';\n\n /**\n * Style this button to be less obvious\n */\n @property({ type: Boolean })\n public set quiet(quiet: boolean) {\n this.treatment = quiet ? 'outline' : 'fill';\n }\n\n /**\n * Disables text wrapping within the button component's label.\n * Please note that this option is not a part of the design specification\n * and should be used carefully, with consideration of this overflow behavior\n * and the readability of the button's content.\n */\n @property({ type: Boolean, attribute: 'no-wrap', reflect: true })\n public noWrap = false;\n\n public get quiet(): boolean {\n return this.treatment === 'outline';\n }\n\n protected override firstUpdated(changes: PropertyValues<this>): void {\n super.firstUpdated(changes);\n // There is no Spectrum design context for an `<sp-button>` without a variant\n // apply one manually when a consumer has not applied one themselves.\n\n if (!this.hasAttribute('variant')) {\n this.setAttribute('variant', this.variant);\n }\n if (this.pending) {\n this.pendingStateController.hostUpdated();\n }\n }\n\n protected override renderButton(): TemplateResult {\n return html`\n ${this.buttonContent} ${this.pendingStateController.renderPendingState()}\n `;\n }\n}\n"],
|
|
5
|
-
"mappings": "qNAWA,OAEE,QAAAA,EAEA,cAAAC,MAEK,gCACP,OAAS,YAAAC,MAAgB,kDACzB,OAAS,0BAAAC,MAA8B,oEAEvC,OAAOC,MAAkB,kBACzB,OAAS,cAAAC,MAAkB,
|
|
6
|
-
"names": ["html", "SizedMixin", "property", "PendingStateController", "buttonStyles", "ButtonBase", "variant", "quiet", "changes", "__decorateClass"]
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport {\n CSSResultArray,\n html,\n PropertyValues,\n SizedMixin,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport { PendingStateController } from '@spectrum-web-components/reactive-controllers/src/PendingState.js';\n\nimport buttonStyles from './button.css.js';\nimport { ButtonBase } from './ButtonBase.js';\n\n/**\n * @deprecated The `DeprecatedButtonVariants` type export is deprecated and will\n * be removed in a future release.\n */\nexport type DeprecatedButtonVariants = 'cta' | 'overBackground';\n\n/**\n * @deprecated The `ButtonStaticColors` type export is deprecated and will be\n * removed in a future release.\n */\nexport type ButtonStaticColors = 'white' | 'black';\n\n/**\n * @deprecated The `ButtonVariants` type export is deprecated and will be\n * removed in a future release.\n */\nexport type ButtonVariants =\n | 'accent'\n | 'primary'\n | 'secondary'\n | 'negative'\n | ButtonStaticColors\n | DeprecatedButtonVariants;\n\n/**\n * @deprecated The `VALID_VARIANTS` export is deprecated and will be removed\n * in a future release.\n */\nexport const VALID_VARIANTS = [\n 'accent',\n 'primary',\n 'secondary',\n 'negative',\n 'white',\n 'black',\n];\n\n/**\n * @deprecated The `VALID_STATIC_COLORS` export is deprecated and will be\n * removed in a future release.\n */\nexport const VALID_STATIC_COLORS = ['white', 'black'];\n\n/**\n * @deprecated The `ButtonTreatments` type export is deprecated and will be\n * removed in a future release.\n */\nexport type ButtonTreatments = 'fill' | 'outline';\n\n/**\n * @element sp-button\n *\n * @slot - text label of the Button\n * @slot icon - The icon to use for Button\n */\nexport class Button extends SizedMixin(ButtonBase, { noDefaultSize: true }) {\n public static override get styles(): CSSResultArray {\n return [...super.styles, buttonStyles];\n }\n\n @property({ type: String, attribute: 'pending-label' })\n public pendingLabel = 'Pending';\n\n // Use this property to set the button into a pending state\n @property({ type: Boolean, reflect: true, attribute: true })\n public pending = false;\n\n public pendingStateController: PendingStateController<this>;\n\n /**\n * Initializes the `PendingStateController` for the Button component.\n * The `PendingStateController` manages the pending state of the Button.\n */\n constructor() {\n super();\n this.pendingStateController = new PendingStateController(this);\n }\n\n public override click(): void {\n if (this.pending) {\n return;\n }\n super.click();\n }\n\n /**\n * The visual variant to apply to this button.\n */\n @property()\n public get variant(): ButtonVariants {\n return this._variant;\n }\n public set variant(variant: ButtonVariants) {\n if (variant === this.variant) {\n return;\n }\n\n this.requestUpdate('variant', this.variant);\n switch (variant) {\n case 'cta':\n this._variant = 'accent';\n if (window.__swc?.DEBUG) {\n window.__swc.warn(\n this,\n `The \"cta\" value of the \"variant\" attribute on <${this.localName}> has been deprecated and will be removed in a future release. Use \"variant='accent'\" instead.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/button/#variants',\n { level: 'deprecation' }\n );\n }\n break;\n case 'overBackground':\n this.removeAttribute('variant');\n this.staticColor = 'white';\n this.treatment = 'outline';\n if (window.__swc?.DEBUG) {\n window.__swc.warn(\n this,\n `The \"overBackground\" value of the \"variant\" attribute on <${this.localName}> has been deprecated and will be removed in a future release. Use \"staticColor='white'\" with \"treatment='outline'\" instead.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/button',\n { level: 'deprecation' }\n );\n }\n return;\n case 'white':\n this.staticColor = 'white';\n if (window.__swc?.DEBUG) {\n window.__swc.warn(\n this,\n `The \"white\" value of the \"variant\" attribute on <${this.localName}> has been deprecated and will be removed in a future release. Use \"static-color='white'\" instead.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/button/api',\n { level: 'deprecation' }\n );\n }\n return;\n case 'black':\n this.staticColor = 'black';\n if (window.__swc?.DEBUG) {\n window.__swc.warn(\n this,\n `The \"black\" value of the \"variant\" attribute on <${this.localName}> has been deprecated and will be removed in a future release. Use \"static-color='black'\" instead.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/button/api',\n { level: 'deprecation' }\n );\n }\n return;\n case null:\n return;\n default:\n if (!VALID_VARIANTS.includes(variant)) {\n this._variant = 'accent';\n } else {\n this._variant = variant;\n }\n break;\n }\n this.setAttribute('variant', this.variant);\n }\n private _variant: ButtonVariants = 'accent';\n\n /**\n * The static color variant to use for this button.\n */\n @property({ reflect: true, attribute: 'static-color' })\n public staticColor?: 'black' | 'white';\n\n /**\n * The visual treatment to apply to this button.\n *\n * @deprecated The `treatment` property is deprecated and will be replaced by\n * `fill-style` in a future release.\n */\n @property({ reflect: true })\n public treatment: ButtonTreatments = 'fill';\n\n /**\n * Style this button to be less obvious.\n *\n * @deprecated The `quiet` property is deprecated and will be removed in a\n * future release.\n */\n @property({ type: Boolean })\n public set quiet(quiet: boolean) {\n this.treatment = quiet ? 'outline' : 'fill';\n if (window.__swc?.DEBUG) {\n window.__swc.warn(\n this,\n `The \"quiet\" property on <${this.localName}> has been deprecated and will be removed in a future release.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/button',\n { level: 'deprecation' }\n );\n }\n }\n\n /**\n * Disables text wrapping within the button component's label.\n * Please note that this option is not a part of the design specification\n * and should be used carefully, with consideration of this overflow behavior\n * and the readability of the button's content.\n *\n * @deprecated The `no-wrap` attribute is deprecated and will be replaced by\n * `truncate` in a future release.\n */\n @property({ type: Boolean, attribute: 'no-wrap', reflect: true })\n public set noWrap(value: boolean) {\n const oldValue = this._noWrap;\n this._noWrap = value;\n this.requestUpdate('noWrap', oldValue);\n if (window.__swc?.DEBUG) {\n window.__swc.warn(\n this,\n `The \"no-wrap\" attribute on <${this.localName}> has been deprecated and will be replaced by \"truncate\" in a future release.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/button',\n { level: 'deprecation' }\n );\n }\n }\n\n public get noWrap(): boolean {\n return this._noWrap;\n }\n private _noWrap = false;\n\n public get quiet(): boolean {\n return this.treatment === 'outline';\n }\n\n protected override firstUpdated(changes: PropertyValues<this>): void {\n super.firstUpdated(changes);\n // There is no Spectrum design context for an `<sp-button>` without a variant\n // apply one manually when a consumer has not applied one themselves.\n\n if (!this.hasAttribute('variant')) {\n this.setAttribute('variant', this.variant);\n }\n if (this.pending) {\n this.pendingStateController.hostUpdated();\n }\n }\n\n protected override renderButton(): TemplateResult {\n return html`\n ${this.buttonContent} ${this.pendingStateController.renderPendingState()}\n `;\n }\n}\n"],
|
|
5
|
+
"mappings": "qNAWA,OAEE,QAAAA,EAEA,cAAAC,MAEK,gCACP,OAAS,YAAAC,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,IAAW,OAAiB,CAC1B,OAAO,KAAK,YAAc,SAC5B,CAEmB,aAAaC,EAAqC,CACnE,MAAM,aAAaA,CAAO,EAIrB,KAAK,aAAa,SAAS,GAC9B,KAAK,aAAa,UAAW,KAAK,OAAO,EAEvC,KAAK,SACP,KAAK,uBAAuB,YAAY,CAE5C,CAEmB,cAA+B,CAChD,OAAOV;AAAA,QACH,KAAK,aAAa,IAAI,KAAK,uBAAuB,mBAAmB,CAAC;AAAA,KAE5E,CACF,CAvLSW,EAAA,CADNT,EAAS,CAAE,KAAM,OAAQ,UAAW,eAAgB,CAAC,GAL3C,OAMJ,4BAIAS,EAAA,CADNT,EAAS,CAAE,KAAM,QAAS,QAAS,GAAM,UAAW,EAAK,CAAC,GAThD,OAUJ,uBAwBIS,EAAA,CADVT,EAAS,GAjCC,OAkCA,uBA0EJS,EAAA,CADNT,EAAS,CAAE,QAAS,GAAM,UAAW,cAAe,CAAC,GA3G3C,OA4GJ,2BASAS,EAAA,CADNT,EAAS,CAAE,QAAS,EAAK,CAAC,GApHhB,OAqHJ,yBASIS,EAAA,CADVT,EAAS,CAAE,KAAM,OAAQ,CAAC,GA7HhB,OA8HA,qBAsBAS,EAAA,CADVT,EAAS,CAAE,KAAM,QAAS,UAAW,UAAW,QAAS,EAAK,CAAC,GAnJrD,OAoJA",
|
|
6
|
+
"names": ["html", "SizedMixin", "property", "PendingStateController", "buttonStyles", "ButtonBase", "variant", "quiet", "value", "oldValue", "changes", "__decorateClass"]
|
|
7
7
|
}
|
package/src/ButtonBase.d.ts
CHANGED
|
@@ -15,8 +15,8 @@ declare const ButtonBase_base: typeof Focusable & {
|
|
|
15
15
|
new (...args: any[]): import("@spectrum-web-components/shared/src/like-anchor.js").LikeAnchorInterface;
|
|
16
16
|
prototype: import("@spectrum-web-components/shared/src/like-anchor.js").LikeAnchorInterface;
|
|
17
17
|
} & {
|
|
18
|
-
new (...args: any[]): import("@spectrum-web-components/
|
|
19
|
-
prototype: import("@spectrum-web-components/
|
|
18
|
+
new (...args: any[]): import("@spectrum-web-components/shared/src/observe-slot-text.js").SlotTextObservingInterface;
|
|
19
|
+
prototype: import("@spectrum-web-components/shared/src/observe-slot-text.js").SlotTextObservingInterface;
|
|
20
20
|
};
|
|
21
21
|
/**
|
|
22
22
|
* @slot - text content to be displayed in the Button element
|
|
@@ -49,6 +49,7 @@ export declare class ButtonBase extends ButtonBase_base {
|
|
|
49
49
|
protected handleKeyup(event: KeyboardEvent): void;
|
|
50
50
|
private manageAnchor;
|
|
51
51
|
protected firstUpdated(changed: PropertyValues): void;
|
|
52
|
+
private warnLinkAPIDeprecation;
|
|
52
53
|
protected updated(changed: PropertyValues): void;
|
|
53
54
|
}
|
|
54
55
|
export {};
|
package/src/ButtonBase.dev.js
CHANGED
|
@@ -73,8 +73,13 @@ export class ButtonBase extends ObserveSlotText(LikeAnchor(Focusable), "", [
|
|
|
73
73
|
return false;
|
|
74
74
|
}
|
|
75
75
|
if (this.anchorElement) {
|
|
76
|
+
const path = (event == null ? void 0 : event.composedPath()) || [];
|
|
77
|
+
if (path.includes(this.anchorElement)) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
76
80
|
this.anchorElement.click();
|
|
77
81
|
handled = true;
|
|
82
|
+
return handled;
|
|
78
83
|
} else if (this.type !== "button") {
|
|
79
84
|
const proxy = document.createElement("button");
|
|
80
85
|
proxy.type = this.type;
|
|
@@ -109,10 +114,8 @@ export class ButtonBase extends ObserveSlotText(LikeAnchor(Focusable), "", [
|
|
|
109
114
|
switch (code) {
|
|
110
115
|
case "Space":
|
|
111
116
|
event.preventDefault();
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
this.active = true;
|
|
115
|
-
}
|
|
117
|
+
this.addEventListener("keyup", this.handleKeyup);
|
|
118
|
+
this.active = true;
|
|
116
119
|
break;
|
|
117
120
|
default:
|
|
118
121
|
break;
|
|
@@ -161,10 +164,24 @@ export class ButtonBase extends ObserveSlotText(LikeAnchor(Focusable), "", [
|
|
|
161
164
|
this.addEventListener("keydown", this.handleKeydown);
|
|
162
165
|
this.addEventListener("keypress", this.handleKeypress);
|
|
163
166
|
}
|
|
167
|
+
warnLinkAPIDeprecation() {
|
|
168
|
+
if (true) {
|
|
169
|
+
const componentSlug = this.localName === "sp-action-button" ? "action-button" : "button";
|
|
170
|
+
window.__swc.warn(
|
|
171
|
+
this,
|
|
172
|
+
`The "href" attribute on <${this.localName}> is deprecated and will be removed in a future release. Use a native HTML anchor (<a>) element with Spectrum global element styling instead. Import "@spectrum-web-components/styles/global-elements.css" to enable button styling on native elements.`,
|
|
173
|
+
`'https://opensource.adobe.com/spectrum-web-components/components/${componentSlug}/#accessibility'`,
|
|
174
|
+
{ level: "deprecation" }
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
164
178
|
updated(changed) {
|
|
165
179
|
super.updated(changed);
|
|
166
180
|
if (changed.has("href")) {
|
|
167
181
|
this.manageAnchor();
|
|
182
|
+
if (this.href && this.href.length > 0) {
|
|
183
|
+
this.warnLinkAPIDeprecation();
|
|
184
|
+
}
|
|
168
185
|
}
|
|
169
186
|
if (changed.has("label")) {
|
|
170
187
|
if (this.label) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["ButtonBase.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n CSSResultArray,\n html,\n PropertyValues,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n query,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { Focusable } from '@spectrum-web-components/shared/src/focusable.js';\nimport { LikeAnchor } from '@spectrum-web-components/shared/src/like-anchor.js';\nimport { ObserveSlotText } from '@spectrum-web-components/shared/src/observe-slot-text.js';\n\nimport buttonStyles from './button-base.css.js';\n\n/**\n * @slot - text content to be displayed in the Button element\n * @slot icon - icon element(s) to display at the start of the button\n */\nexport class ButtonBase extends ObserveSlotText(LikeAnchor(Focusable), '', [\n 'sp-overlay,sp-tooltip',\n]) {\n public static override get styles(): CSSResultArray {\n return [buttonStyles];\n }\n\n // TODO we need to document this property for consumers,\n // as it's not a 1:1 equivalent to active\n @property({ type: Boolean, reflect: true })\n public active = false;\n\n /**\n * The default behavior of the button.\n * Possible values are: `button` (default), `submit`, and `reset`.\n */\n @property({ type: String })\n public type: 'button' | 'submit' | 'reset' = 'button';\n\n /**\n * HTML anchor element that component clicks by proxy\n */\n @query('.anchor')\n private anchorElement!: HTMLAnchorElement;\n\n public override get focusElement(): HTMLElement {\n return this;\n }\n\n protected get hasLabel(): boolean {\n return this.slotHasContent;\n }\n\n protected get buttonContent(): TemplateResult[] {\n const content = [\n html`\n <slot name=\"icon\" ?icon-only=${!this.hasLabel}></slot>\n `,\n html`\n <span id=\"label\">\n <slot @slotchange=${this.manageTextObservedSlot}></slot>\n </span>\n `,\n ];\n return content;\n }\n\n constructor() {\n super();\n this.proxyFocus = this.proxyFocus.bind(this);\n\n this.addEventListener('click', this.handleClickCapture, {\n capture: true,\n });\n }\n\n private handleClickCapture(event: Event): void | boolean {\n if (this.disabled) {\n event.preventDefault();\n event.stopImmediatePropagation();\n return false;\n }\n\n if (this.shouldProxyClick(event as MouseEvent)) {\n return;\n }\n }\n\n private proxyFocus(): void {\n this.focus();\n }\n\n private shouldProxyClick(event?: MouseEvent): boolean {\n let handled = false;\n\n // Don't proxy clicks with modifier keys (Command/Meta, Ctrl, Shift, Alt)\n if (\n event &&\n (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey)\n ) {\n return false;\n }\n\n if (this.anchorElement) {\n // Click HTML anchor element by proxy, but only for non-modified clicks\n this.anchorElement.click();\n handled = true;\n // if the button type is `submit` or `reset`\n } else if (this.type !== 'button') {\n // create an HTML Button Element by proxy, click it, and remove it\n const proxy = document.createElement('button');\n proxy.type = this.type;\n this.insertAdjacentElement('afterend', proxy);\n proxy.click();\n proxy.remove();\n handled = true;\n }\n return handled;\n }\n\n public override renderAnchor(): TemplateResult {\n return html`\n ${this.buttonContent}\n ${super.renderAnchor({\n id: 'button',\n ariaHidden: true,\n className: 'button anchor',\n tabindex: -1,\n })}\n `;\n }\n\n protected renderButton(): TemplateResult {\n return html`\n ${this.buttonContent}\n `;\n }\n\n protected override render(): TemplateResult {\n return this.href && this.href.length > 0\n ? this.renderAnchor()\n : this.renderButton();\n }\n\n protected handleKeydown(event: KeyboardEvent): void {\n const { code } = event;\n switch (code) {\n case 'Space':\n event.preventDefault();\n // allows button to activate when `Space` is pressed\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;AAYA;AAAA,EAEE;AAAA,OAGK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAEhC,OAAO,kBAAkB;AAMlB,aAAM,mBAAmB,gBAAgB,WAAW,SAAS,GAAG,IAAI;AAAA,EACzE;AACF,CAAC,EAAE;AAAA,EA6CD,cAAc;AACZ,UAAM;AAtCR,SAAO,SAAS;AAOhB,SAAO,OAAsC;AAgC3C,SAAK,aAAa,KAAK,WAAW,KAAK,IAAI;AAE3C,SAAK,iBAAiB,SAAS,KAAK,oBAAoB;AAAA,MACtD,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AAAA,EAnDA,WAA2B,SAAyB;AAClD,WAAO,CAAC,YAAY;AAAA,EACtB;AAAA,EAoBA,IAAoB,eAA4B;AAC9C,WAAO;AAAA,EACT;AAAA,EAEA,IAAc,WAAoB;AAChC,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAc,gBAAkC;AAC9C,UAAM,UAAU;AAAA,MACd;AAAA,uCACiC,CAAC,KAAK,QAAQ;AAAA;AAAA,MAE/C;AAAA;AAAA,8BAEwB,KAAK,sBAAsB;AAAA;AAAA;AAAA,IAGrD;AACA,WAAO;AAAA,EACT;AAAA,EAWQ,mBAAmB,OAA8B;AACvD,QAAI,KAAK,UAAU;AACjB,YAAM,eAAe;AACrB,YAAM,yBAAyB;AAC/B,aAAO;AAAA,IACT;AAEA,QAAI,KAAK,iBAAiB,KAAmB,GAAG;AAC9C;AAAA,IACF;AAAA,EACF;AAAA,EAEQ,aAAmB;AACzB,SAAK,MAAM;AAAA,EACb;AAAA,EAEQ,iBAAiB,OAA6B;AACpD,QAAI,UAAU;AAGd,QACE,UACC,MAAM,WAAW,MAAM,WAAW,MAAM,YAAY,MAAM,SAC3D;AACA,aAAO;AAAA,IACT;AAEA,QAAI,KAAK,eAAe;
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n CSSResultArray,\n html,\n PropertyValues,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n query,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { Focusable } from '@spectrum-web-components/shared/src/focusable.js';\nimport { LikeAnchor } from '@spectrum-web-components/shared/src/like-anchor.js';\nimport { ObserveSlotText } from '@spectrum-web-components/shared/src/observe-slot-text.js';\n\nimport buttonStyles from './button-base.css.js';\n\n/**\n * @slot - text content to be displayed in the Button element\n * @slot icon - icon element(s) to display at the start of the button\n */\nexport class ButtonBase extends ObserveSlotText(LikeAnchor(Focusable), '', [\n 'sp-overlay,sp-tooltip',\n]) {\n public static override get styles(): CSSResultArray {\n return [buttonStyles];\n }\n\n // TODO we need to document this property for consumers,\n // as it's not a 1:1 equivalent to active\n @property({ type: Boolean, reflect: true })\n public active = false;\n\n /**\n * The default behavior of the button.\n * Possible values are: `button` (default), `submit`, and `reset`.\n */\n @property({ type: String })\n public type: 'button' | 'submit' | 'reset' = 'button';\n\n /**\n * HTML anchor element that component clicks by proxy\n */\n @query('.anchor')\n private anchorElement!: HTMLAnchorElement;\n\n public override get focusElement(): HTMLElement {\n return this;\n }\n\n protected get hasLabel(): boolean {\n return this.slotHasContent;\n }\n\n protected get buttonContent(): TemplateResult[] {\n const content = [\n html`\n <slot name=\"icon\" ?icon-only=${!this.hasLabel}></slot>\n `,\n html`\n <span id=\"label\">\n <slot @slotchange=${this.manageTextObservedSlot}></slot>\n </span>\n `,\n ];\n return content;\n }\n\n constructor() {\n super();\n this.proxyFocus = this.proxyFocus.bind(this);\n\n this.addEventListener('click', this.handleClickCapture, {\n capture: true,\n });\n }\n\n private handleClickCapture(event: Event): void | boolean {\n if (this.disabled) {\n event.preventDefault();\n event.stopImmediatePropagation();\n return false;\n }\n\n if (this.shouldProxyClick(event as MouseEvent)) {\n return;\n }\n }\n\n private proxyFocus(): void {\n this.focus();\n }\n\n private shouldProxyClick(event?: MouseEvent): boolean {\n let handled = false;\n\n // Don't proxy clicks with modifier keys (Command/Meta, Ctrl, Shift, Alt)\n if (\n event &&\n (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey)\n ) {\n return false;\n }\n\n if (this.anchorElement) {\n // Check if the click already went through the anchor element.\n // If so, the browser will handle navigation naturally and we\n // don't need to proxy the click (which would cause double navigation).\n const path = event?.composedPath() || [];\n if (path.includes(this.anchorElement)) {\n return false;\n }\n // Click HTML anchor element by proxy, but only for non-modified clicks\n this.anchorElement.click();\n handled = true;\n return handled;\n // if the button type is `submit` or `reset`\n } else if (this.type !== 'button') {\n // create an HTML Button Element by proxy, click it, and remove it\n const proxy = document.createElement('button');\n proxy.type = this.type;\n this.insertAdjacentElement('afterend', proxy);\n proxy.click();\n proxy.remove();\n handled = true;\n }\n return handled;\n }\n\n public override renderAnchor(): TemplateResult {\n return html`\n ${this.buttonContent}\n ${super.renderAnchor({\n id: 'button',\n ariaHidden: true,\n className: 'button anchor',\n tabindex: -1,\n })}\n `;\n }\n\n protected renderButton(): TemplateResult {\n return html`\n ${this.buttonContent}\n `;\n }\n\n protected override render(): TemplateResult {\n return this.href && this.href.length > 0\n ? this.renderAnchor()\n : this.renderButton();\n }\n\n protected handleKeydown(event: KeyboardEvent): void {\n const { code } = event;\n switch (code) {\n case 'Space':\n event.preventDefault();\n // allows button or link to activate when `Space` is pressed\n this.addEventListener('keyup', this.handleKeyup);\n this.active = true;\n break;\n default:\n break;\n }\n }\n\n private handleKeypress(event: KeyboardEvent): void {\n const { code } = event;\n switch (code) {\n case 'Enter':\n case 'NumpadEnter':\n // allows button or link to be activated with `Enter` and `NumpadEnter`\n this.click();\n break;\n default:\n break;\n }\n }\n\n protected handleKeyup(event: KeyboardEvent): void {\n const { code } = event;\n switch (code) {\n case 'Space':\n this.removeEventListener('keyup', this.handleKeyup);\n this.active = false;\n this.click();\n break;\n default:\n break;\n }\n }\n\n private manageAnchor(): void {\n // for a link\n if (this.href && this.href.length > 0) {\n // if the role is set to button\n if (\n !this.hasAttribute('role') ||\n this.getAttribute('role') === 'button'\n ) {\n // change role to link\n this.setAttribute('role', 'link');\n }\n // else for a button\n } else {\n // if the role is set to link\n if (!this.hasAttribute('role') || this.getAttribute('role') === 'link') {\n // change role to button\n this.setAttribute('role', 'button');\n }\n }\n }\n\n protected override firstUpdated(changed: PropertyValues): void {\n super.firstUpdated(changed);\n if (!this.hasAttribute('tabindex')) {\n this.setAttribute('tabindex', '0');\n }\n\n this.manageAnchor();\n this.addEventListener('keydown', this.handleKeydown);\n this.addEventListener('keypress', this.handleKeypress);\n }\n\n private warnLinkAPIDeprecation(): void {\n if (window.__swc?.DEBUG) {\n const componentSlug =\n this.localName === 'sp-action-button' ? 'action-button' : 'button';\n window.__swc.warn(\n this,\n `The \"href\" attribute on <${this.localName}> is deprecated and will be removed in a future release. Use a native HTML anchor (<a>) element with Spectrum global element styling instead. Import \"@spectrum-web-components/styles/global-elements.css\" to enable button styling on native elements.`,\n `'https://opensource.adobe.com/spectrum-web-components/components/${componentSlug}/#accessibility'`,\n { level: 'deprecation' }\n );\n }\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n if (changed.has('href')) {\n this.manageAnchor();\n if (this.href && this.href.length > 0) {\n this.warnLinkAPIDeprecation();\n }\n }\n\n if (changed.has('label')) {\n if (this.label) {\n this.setAttribute('aria-label', this.label);\n } else {\n this.removeAttribute('aria-label');\n }\n }\n\n if (this.anchorElement) {\n // Ensure the anchor element is not focusable directly via tab\n this.anchorElement.tabIndex = -1;\n\n // Make sure it has proper ARIA attributes\n if (!this.anchorElement.hasAttribute('aria-hidden')) {\n this.anchorElement.setAttribute('aria-hidden', 'true');\n }\n\n // Set up focus delegation\n this.anchorElement.addEventListener('focus', this.proxyFocus);\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;AAYA;AAAA,EAEE;AAAA,OAGK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAEhC,OAAO,kBAAkB;AAMlB,aAAM,mBAAmB,gBAAgB,WAAW,SAAS,GAAG,IAAI;AAAA,EACzE;AACF,CAAC,EAAE;AAAA,EA6CD,cAAc;AACZ,UAAM;AAtCR,SAAO,SAAS;AAOhB,SAAO,OAAsC;AAgC3C,SAAK,aAAa,KAAK,WAAW,KAAK,IAAI;AAE3C,SAAK,iBAAiB,SAAS,KAAK,oBAAoB;AAAA,MACtD,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AAAA,EAnDA,WAA2B,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|
"names": []
|
|
7
7
|
}
|
package/src/ButtonBase.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var c=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var s=(n,i,e,t)=>{for(var r=t>1?void 0:t?u(i,e):i,a=n.length-1,l;a>=0;a--)(l=n[a])&&(r=(t?l(i,e,r):l(r))||r);return t&&r&&c(i,e,r),r};import{html as o}from"@spectrum-web-components/base";import{property as h,query as d}from"@spectrum-web-components/base/src/decorators.js";import{Focusable as p}from"@spectrum-web-components/shared/src/focusable.js";import{LikeAnchor as b}from"@spectrum-web-components/shared/src/like-anchor.js";import{ObserveSlotText as m}from"@spectrum-web-components/shared/src/observe-slot-text.js";import f from"./button-base.css.js";export class ButtonBase extends m(b(p),"",["sp-overlay,sp-tooltip"]){constructor(){super();this.active=!1;this.type="button";this.proxyFocus=this.proxyFocus.bind(this),this.addEventListener("click",this.handleClickCapture,{capture:!0})}static get styles(){return[f]}get focusElement(){return this}get hasLabel(){return this.slotHasContent}get buttonContent(){return[o`
|
|
2
2
|
<slot name="icon" ?icon-only=${!this.hasLabel}></slot>
|
|
3
3
|
`,o`
|
|
4
4
|
<span id="label">
|
|
5
5
|
<slot @slotchange=${this.manageTextObservedSlot}></slot>
|
|
6
6
|
</span>
|
|
7
|
-
`]}handleClickCapture(e){if(this.disabled)return e.preventDefault(),e.stopImmediatePropagation(),!1;this.shouldProxyClick(e)}proxyFocus(){this.focus()}shouldProxyClick(e){let t=!1;if(e&&(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey))return!1;if(this.anchorElement)this.anchorElement.click(),t=!0;
|
|
7
|
+
`]}handleClickCapture(e){if(this.disabled)return e.preventDefault(),e.stopImmediatePropagation(),!1;this.shouldProxyClick(e)}proxyFocus(){this.focus()}shouldProxyClick(e){let t=!1;if(e&&(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey))return!1;if(this.anchorElement)return((e==null?void 0:e.composedPath())||[]).includes(this.anchorElement)?!1:(this.anchorElement.click(),t=!0,t);if(this.type!=="button"){const r=document.createElement("button");r.type=this.type,this.insertAdjacentElement("afterend",r),r.click(),r.remove(),t=!0}return t}renderAnchor(){return o`
|
|
8
8
|
${this.buttonContent}
|
|
9
9
|
${super.renderAnchor({id:"button",ariaHidden:!0,className:"button anchor",tabindex:-1})}
|
|
10
10
|
`}renderButton(){return o`
|
|
11
11
|
${this.buttonContent}
|
|
12
|
-
`}render(){return this.href&&this.href.length>0?this.renderAnchor():this.renderButton()}handleKeydown(e){const{code:t}=e;switch(t){case"Space":e.preventDefault(),
|
|
12
|
+
`}render(){return this.href&&this.href.length>0?this.renderAnchor():this.renderButton()}handleKeydown(e){const{code:t}=e;switch(t){case"Space":e.preventDefault(),this.addEventListener("keyup",this.handleKeyup),this.active=!0;break;default:break}}handleKeypress(e){const{code:t}=e;switch(t){case"Enter":case"NumpadEnter":this.click();break;default:break}}handleKeyup(e){const{code:t}=e;switch(t){case"Space":this.removeEventListener("keyup",this.handleKeyup),this.active=!1,this.click();break;default:break}}manageAnchor(){this.href&&this.href.length>0?(!this.hasAttribute("role")||this.getAttribute("role")==="button")&&this.setAttribute("role","link"):(!this.hasAttribute("role")||this.getAttribute("role")==="link")&&this.setAttribute("role","button")}firstUpdated(e){super.firstUpdated(e),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.manageAnchor(),this.addEventListener("keydown",this.handleKeydown),this.addEventListener("keypress",this.handleKeypress)}warnLinkAPIDeprecation(){}updated(e){super.updated(e),e.has("href")&&(this.manageAnchor(),this.href&&this.href.length>0&&this.warnLinkAPIDeprecation()),e.has("label")&&(this.label?this.setAttribute("aria-label",this.label):this.removeAttribute("aria-label")),this.anchorElement&&(this.anchorElement.tabIndex=-1,this.anchorElement.hasAttribute("aria-hidden")||this.anchorElement.setAttribute("aria-hidden","true"),this.anchorElement.addEventListener("focus",this.proxyFocus))}}s([h({type:Boolean,reflect:!0})],ButtonBase.prototype,"active",2),s([h({type:String})],ButtonBase.prototype,"type",2),s([d(".anchor")],ButtonBase.prototype,"anchorElement",2);
|
|
13
13
|
//# sourceMappingURL=ButtonBase.js.map
|
package/src/ButtonBase.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["ButtonBase.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n CSSResultArray,\n html,\n PropertyValues,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n query,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { Focusable } from '@spectrum-web-components/shared/src/focusable.js';\nimport { LikeAnchor } from '@spectrum-web-components/shared/src/like-anchor.js';\nimport { ObserveSlotText } from '@spectrum-web-components/shared/src/observe-slot-text.js';\n\nimport buttonStyles from './button-base.css.js';\n\n/**\n * @slot - text content to be displayed in the Button element\n * @slot icon - icon element(s) to display at the start of the button\n */\nexport class ButtonBase extends ObserveSlotText(LikeAnchor(Focusable), '', [\n 'sp-overlay,sp-tooltip',\n]) {\n public static override get styles(): CSSResultArray {\n return [buttonStyles];\n }\n\n // TODO we need to document this property for consumers,\n // as it's not a 1:1 equivalent to active\n @property({ type: Boolean, reflect: true })\n public active = false;\n\n /**\n * The default behavior of the button.\n * Possible values are: `button` (default), `submit`, and `reset`.\n */\n @property({ type: String })\n public type: 'button' | 'submit' | 'reset' = 'button';\n\n /**\n * HTML anchor element that component clicks by proxy\n */\n @query('.anchor')\n private anchorElement!: HTMLAnchorElement;\n\n public override get focusElement(): HTMLElement {\n return this;\n }\n\n protected get hasLabel(): boolean {\n return this.slotHasContent;\n }\n\n protected get buttonContent(): TemplateResult[] {\n const content = [\n html`\n <slot name=\"icon\" ?icon-only=${!this.hasLabel}></slot>\n `,\n html`\n <span id=\"label\">\n <slot @slotchange=${this.manageTextObservedSlot}></slot>\n </span>\n `,\n ];\n return content;\n }\n\n constructor() {\n super();\n this.proxyFocus = this.proxyFocus.bind(this);\n\n this.addEventListener('click', this.handleClickCapture, {\n capture: true,\n });\n }\n\n private handleClickCapture(event: Event): void | boolean {\n if (this.disabled) {\n event.preventDefault();\n event.stopImmediatePropagation();\n return false;\n }\n\n if (this.shouldProxyClick(event as MouseEvent)) {\n return;\n }\n }\n\n private proxyFocus(): void {\n this.focus();\n }\n\n private shouldProxyClick(event?: MouseEvent): boolean {\n let handled = false;\n\n // Don't proxy clicks with modifier keys (Command/Meta, Ctrl, Shift, Alt)\n if (\n event &&\n (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey)\n ) {\n return false;\n }\n\n if (this.anchorElement) {\n // Click HTML anchor element by proxy, but only for non-modified clicks\n this.anchorElement.click();\n handled = true;\n // if the button type is `submit` or `reset`\n } else if (this.type !== 'button') {\n // create an HTML Button Element by proxy, click it, and remove it\n const proxy = document.createElement('button');\n proxy.type = this.type;\n this.insertAdjacentElement('afterend', proxy);\n proxy.click();\n proxy.remove();\n handled = true;\n }\n return handled;\n }\n\n public override renderAnchor(): TemplateResult {\n return html`\n ${this.buttonContent}\n ${super.renderAnchor({\n id: 'button',\n ariaHidden: true,\n className: 'button anchor',\n tabindex: -1,\n })}\n `;\n }\n\n protected renderButton(): TemplateResult {\n return html`\n ${this.buttonContent}\n `;\n }\n\n protected override render(): TemplateResult {\n return this.href && this.href.length > 0\n ? this.renderAnchor()\n : this.renderButton();\n }\n\n protected handleKeydown(event: KeyboardEvent): void {\n const { code } = event;\n switch (code) {\n case 'Space':\n event.preventDefault();\n // allows button to activate when `Space` is pressed\n
|
|
5
|
-
"mappings": "qNAYA,OAEE,QAAAA,MAGK,gCACP,OACE,YAAAC,EACA,SAAAC,MACK,kDACP,OAAS,aAAAC,MAAiB,mDAC1B,OAAS,cAAAC,MAAkB,qDAC3B,OAAS,mBAAAC,MAAuB,2DAEhC,OAAOC,MAAkB,uBAMlB,aAAM,mBAAmBD,EAAgBD,EAAWD,CAAS,EAAG,GAAI,CACzE,uBACF,CAAC,CAAE,CA6CD,aAAc,CACZ,MAAM,EAtCR,KAAO,OAAS,GAOhB,KAAO,KAAsC,SAgC3C,KAAK,WAAa,KAAK,WAAW,KAAK,IAAI,EAE3C,KAAK,iBAAiB,QAAS,KAAK,mBAAoB,CACtD,QAAS,EACX,CAAC,CACH,CAnDA,WAA2B,QAAyB,CAClD,MAAO,CAACG,CAAY,CACtB,CAoBA,IAAoB,cAA4B,CAC9C,OAAO,IACT,CAEA,IAAc,UAAoB,CAChC,OAAO,KAAK,cACd,CAEA,IAAc,eAAkC,CAW9C,MAVgB,CACdN;AAAA,uCACiC,CAAC,KAAK,QAAQ;AAAA,QAE/CA;AAAA;AAAA,8BAEwB,KAAK,sBAAsB;AAAA;AAAA,OAGrD,CAEF,CAWQ,mBAAmBO,EAA8B,CACvD,GAAI,KAAK,SACP,OAAAA,EAAM,eAAe,EACrBA,EAAM,yBAAyB,EACxB,GAGL,KAAK,iBAAiBA,CAAmB,CAG/C,CAEQ,YAAmB,CACzB,KAAK,MAAM,CACb,CAEQ,iBAAiBA,EAA6B,CACpD,IAAIC,EAAU,GAGd,GACED,IACCA,EAAM,SAAWA,EAAM,SAAWA,EAAM,UAAYA,EAAM,QAE3D,MAAO,GAGT,GAAI,KAAK,
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n CSSResultArray,\n html,\n PropertyValues,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n query,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { Focusable } from '@spectrum-web-components/shared/src/focusable.js';\nimport { LikeAnchor } from '@spectrum-web-components/shared/src/like-anchor.js';\nimport { ObserveSlotText } from '@spectrum-web-components/shared/src/observe-slot-text.js';\n\nimport buttonStyles from './button-base.css.js';\n\n/**\n * @slot - text content to be displayed in the Button element\n * @slot icon - icon element(s) to display at the start of the button\n */\nexport class ButtonBase extends ObserveSlotText(LikeAnchor(Focusable), '', [\n 'sp-overlay,sp-tooltip',\n]) {\n public static override get styles(): CSSResultArray {\n return [buttonStyles];\n }\n\n // TODO we need to document this property for consumers,\n // as it's not a 1:1 equivalent to active\n @property({ type: Boolean, reflect: true })\n public active = false;\n\n /**\n * The default behavior of the button.\n * Possible values are: `button` (default), `submit`, and `reset`.\n */\n @property({ type: String })\n public type: 'button' | 'submit' | 'reset' = 'button';\n\n /**\n * HTML anchor element that component clicks by proxy\n */\n @query('.anchor')\n private anchorElement!: HTMLAnchorElement;\n\n public override get focusElement(): HTMLElement {\n return this;\n }\n\n protected get hasLabel(): boolean {\n return this.slotHasContent;\n }\n\n protected get buttonContent(): TemplateResult[] {\n const content = [\n html`\n <slot name=\"icon\" ?icon-only=${!this.hasLabel}></slot>\n `,\n html`\n <span id=\"label\">\n <slot @slotchange=${this.manageTextObservedSlot}></slot>\n </span>\n `,\n ];\n return content;\n }\n\n constructor() {\n super();\n this.proxyFocus = this.proxyFocus.bind(this);\n\n this.addEventListener('click', this.handleClickCapture, {\n capture: true,\n });\n }\n\n private handleClickCapture(event: Event): void | boolean {\n if (this.disabled) {\n event.preventDefault();\n event.stopImmediatePropagation();\n return false;\n }\n\n if (this.shouldProxyClick(event as MouseEvent)) {\n return;\n }\n }\n\n private proxyFocus(): void {\n this.focus();\n }\n\n private shouldProxyClick(event?: MouseEvent): boolean {\n let handled = false;\n\n // Don't proxy clicks with modifier keys (Command/Meta, Ctrl, Shift, Alt)\n if (\n event &&\n (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey)\n ) {\n return false;\n }\n\n if (this.anchorElement) {\n // Check if the click already went through the anchor element.\n // If so, the browser will handle navigation naturally and we\n // don't need to proxy the click (which would cause double navigation).\n const path = event?.composedPath() || [];\n if (path.includes(this.anchorElement)) {\n return false;\n }\n // Click HTML anchor element by proxy, but only for non-modified clicks\n this.anchorElement.click();\n handled = true;\n return handled;\n // if the button type is `submit` or `reset`\n } else if (this.type !== 'button') {\n // create an HTML Button Element by proxy, click it, and remove it\n const proxy = document.createElement('button');\n proxy.type = this.type;\n this.insertAdjacentElement('afterend', proxy);\n proxy.click();\n proxy.remove();\n handled = true;\n }\n return handled;\n }\n\n public override renderAnchor(): TemplateResult {\n return html`\n ${this.buttonContent}\n ${super.renderAnchor({\n id: 'button',\n ariaHidden: true,\n className: 'button anchor',\n tabindex: -1,\n })}\n `;\n }\n\n protected renderButton(): TemplateResult {\n return html`\n ${this.buttonContent}\n `;\n }\n\n protected override render(): TemplateResult {\n return this.href && this.href.length > 0\n ? this.renderAnchor()\n : this.renderButton();\n }\n\n protected handleKeydown(event: KeyboardEvent): void {\n const { code } = event;\n switch (code) {\n case 'Space':\n event.preventDefault();\n // allows button or link to activate when `Space` is pressed\n this.addEventListener('keyup', this.handleKeyup);\n this.active = true;\n break;\n default:\n break;\n }\n }\n\n private handleKeypress(event: KeyboardEvent): void {\n const { code } = event;\n switch (code) {\n case 'Enter':\n case 'NumpadEnter':\n // allows button or link to be activated with `Enter` and `NumpadEnter`\n this.click();\n break;\n default:\n break;\n }\n }\n\n protected handleKeyup(event: KeyboardEvent): void {\n const { code } = event;\n switch (code) {\n case 'Space':\n this.removeEventListener('keyup', this.handleKeyup);\n this.active = false;\n this.click();\n break;\n default:\n break;\n }\n }\n\n private manageAnchor(): void {\n // for a link\n if (this.href && this.href.length > 0) {\n // if the role is set to button\n if (\n !this.hasAttribute('role') ||\n this.getAttribute('role') === 'button'\n ) {\n // change role to link\n this.setAttribute('role', 'link');\n }\n // else for a button\n } else {\n // if the role is set to link\n if (!this.hasAttribute('role') || this.getAttribute('role') === 'link') {\n // change role to button\n this.setAttribute('role', 'button');\n }\n }\n }\n\n protected override firstUpdated(changed: PropertyValues): void {\n super.firstUpdated(changed);\n if (!this.hasAttribute('tabindex')) {\n this.setAttribute('tabindex', '0');\n }\n\n this.manageAnchor();\n this.addEventListener('keydown', this.handleKeydown);\n this.addEventListener('keypress', this.handleKeypress);\n }\n\n private warnLinkAPIDeprecation(): void {\n if (window.__swc?.DEBUG) {\n const componentSlug =\n this.localName === 'sp-action-button' ? 'action-button' : 'button';\n window.__swc.warn(\n this,\n `The \"href\" attribute on <${this.localName}> is deprecated and will be removed in a future release. Use a native HTML anchor (<a>) element with Spectrum global element styling instead. Import \"@spectrum-web-components/styles/global-elements.css\" to enable button styling on native elements.`,\n `'https://opensource.adobe.com/spectrum-web-components/components/${componentSlug}/#accessibility'`,\n { level: 'deprecation' }\n );\n }\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n if (changed.has('href')) {\n this.manageAnchor();\n if (this.href && this.href.length > 0) {\n this.warnLinkAPIDeprecation();\n }\n }\n\n if (changed.has('label')) {\n if (this.label) {\n this.setAttribute('aria-label', this.label);\n } else {\n this.removeAttribute('aria-label');\n }\n }\n\n if (this.anchorElement) {\n // Ensure the anchor element is not focusable directly via tab\n this.anchorElement.tabIndex = -1;\n\n // Make sure it has proper ARIA attributes\n if (!this.anchorElement.hasAttribute('aria-hidden')) {\n this.anchorElement.setAttribute('aria-hidden', 'true');\n }\n\n // Set up focus delegation\n this.anchorElement.addEventListener('focus', this.proxyFocus);\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "qNAYA,OAEE,QAAAA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B,KAAK,aAAa,UAAU,GAC/B,KAAK,aAAa,WAAY,GAAG,EAGnC,KAAK,aAAa,EAClB,KAAK,iBAAiB,UAAW,KAAK,aAAa,EACnD,KAAK,iBAAiB,WAAY,KAAK,cAAc,CACvD,CAEQ,wBAA+B,CAWvC,CAEmB,QAAQA,EAA+B,CACxD,MAAM,QAAQA,CAAO,EACjBA,EAAQ,IAAI,MAAM,IACpB,KAAK,aAAa,EACd,KAAK,MAAQ,KAAK,KAAK,OAAS,GAClC,KAAK,uBAAuB,GAI5BA,EAAQ,IAAI,OAAO,IACjB,KAAK,MACP,KAAK,aAAa,aAAc,KAAK,KAAK,EAE1C,KAAK,gBAAgB,YAAY,GAIjC,KAAK,gBAEP,KAAK,cAAc,SAAW,GAGzB,KAAK,cAAc,aAAa,aAAa,GAChD,KAAK,cAAc,aAAa,cAAe,MAAM,EAIvD,KAAK,cAAc,iBAAiB,QAAS,KAAK,UAAU,EAEhE,CACF,CA7OSC,EAAA,CADNX,EAAS,CAAE,KAAM,QAAS,QAAS,EAAK,CAAC,GAT/B,WAUJ,sBAOAW,EAAA,CADNX,EAAS,CAAE,KAAM,MAAO,CAAC,GAhBf,WAiBJ,oBAMCW,EAAA,CADPV,EAAM,SAAS,GAtBL,WAuBH",
|
|
6
6
|
"names": ["html", "property", "query", "Focusable", "LikeAnchor", "ObserveSlotText", "buttonStyles", "event", "handled", "proxy", "code", "changed", "__decorateClass"]
|
|
7
7
|
}
|
package/src/ClearButton.d.ts
CHANGED
|
@@ -15,10 +15,7 @@ import '@spectrum-web-components/icons-ui/icons/sp-icon-cross100.js';
|
|
|
15
15
|
import '@spectrum-web-components/icons-ui/icons/sp-icon-cross200.js';
|
|
16
16
|
import '@spectrum-web-components/icons-ui/icons/sp-icon-cross300.js';
|
|
17
17
|
import { StyledButton } from './StyledButton.js';
|
|
18
|
-
declare const ClearButton_base: typeof StyledButton &
|
|
19
|
-
new (...args: any[]): import("@spectrum-web-components/base").SizedElementInterface;
|
|
20
|
-
prototype: import("@spectrum-web-components/base").SizedElementInterface;
|
|
21
|
-
} & import("@spectrum-web-components/core/mixins").SizedElementConstructor;
|
|
18
|
+
declare const ClearButton_base: typeof StyledButton & import("@spectrum-web-components/base").Constructor<import("@spectrum-web-components/base").SizedElementInterface> & import("@spectrum-web-components/base").SizedElementConstructor;
|
|
22
19
|
/**
|
|
23
20
|
* @element sp-clear-button
|
|
24
21
|
*
|
package/src/CloseButton.d.ts
CHANGED
|
@@ -16,10 +16,7 @@ import '@spectrum-web-components/icons-ui/icons/sp-icon-cross400.js';
|
|
|
16
16
|
import '@spectrum-web-components/icons-ui/icons/sp-icon-cross500.js';
|
|
17
17
|
import type { ButtonStaticColors } from './Button.js';
|
|
18
18
|
import { StyledButton } from './StyledButton.js';
|
|
19
|
-
declare const CloseButton_base: typeof StyledButton &
|
|
20
|
-
new (...args: any[]): import("@spectrum-web-components/base").SizedElementInterface;
|
|
21
|
-
prototype: import("@spectrum-web-components/base").SizedElementInterface;
|
|
22
|
-
} & import("@spectrum-web-components/core/mixins").SizedElementConstructor;
|
|
19
|
+
declare const CloseButton_base: typeof StyledButton & import("@spectrum-web-components/base").Constructor<import("@spectrum-web-components/base").SizedElementInterface> & import("@spectrum-web-components/base").SizedElementConstructor;
|
|
23
20
|
/**
|
|
24
21
|
* @element sp-close-button
|
|
25
22
|
*
|