@spectrum-web-components/badge 1.7.0 → 1.9.0-nightly.20251013134115
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 +156 -13
- package/package.json +7 -6
- package/sp-badge.d.ts +11 -0
- package/sp-badge.dev.js.map +1 -1
- package/sp-badge.js.map +1 -1
- package/src/Badge.d.ts +48 -20
- package/src/Badge.dev.js +24 -71
- package/src/Badge.dev.js.map +2 -2
- package/src/Badge.js +4 -4
- package/src/Badge.js.map +3 -3
- package/src/badge-overrides.css.dev.js.map +1 -1
- package/src/badge-overrides.css.js.map +1 -1
- package/src/badge.css.dev.js +1 -1
- package/src/badge.css.dev.js.map +1 -1
- package/src/badge.css.js +1 -1
- package/src/badge.css.js.map +1 -1
- package/src/index.d.ts +11 -0
- package/src/index.dev.js.map +1 -1
- package/src/index.js.map +1 -1
- package/src/spectrum-badge.css.dev.js +1 -1
- package/src/spectrum-badge.css.dev.js.map +1 -1
- package/src/spectrum-badge.css.js +1 -1
- package/src/spectrum-badge.css.js.map +1 -1
- package/custom-elements.json +0 -161
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
##
|
|
1
|
+
## Overview
|
|
2
2
|
|
|
3
3
|
`<sp-badge>` elements display a small amount of color-categorized metadata. They're ideal for getting a user's attention.
|
|
4
4
|
|
|
@@ -7,23 +7,50 @@
|
|
|
7
7
|
[](https://www.npmjs.com/package/@spectrum-web-components/badge)
|
|
8
8
|
[](https://bundlephobia.com/result?p=@spectrum-web-components/badge)
|
|
9
9
|
|
|
10
|
-
```
|
|
10
|
+
```bash
|
|
11
11
|
yarn add @spectrum-web-components/badge
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
Import the side effectful registration of `<sp-badge>` via:
|
|
15
15
|
|
|
16
|
-
```
|
|
16
|
+
```js
|
|
17
17
|
import '@spectrum-web-components/badge/sp-badge.js';
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
When looking to leverage the `Badge` base class as a type and/or for extension purposes, do so via:
|
|
21
21
|
|
|
22
|
-
```
|
|
22
|
+
```js
|
|
23
23
|
import { Badge } from '@spectrum-web-components/badge';
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
### Anatomy
|
|
27
|
+
|
|
28
|
+
A badge is made up of the following parts:
|
|
29
|
+
|
|
30
|
+
- **Icon**: an `<sp-icon-*>` element can be used to display an icon within the badge.
|
|
31
|
+
- **Label**: text can be displayed within the badge by using the default slot.
|
|
32
|
+
|
|
33
|
+
Badges can contain either a label, an icon, or both.
|
|
34
|
+
|
|
35
|
+
```html demo
|
|
36
|
+
<sp-badge size="s">Label only</sp-badge>
|
|
37
|
+
<sp-badge size="s">
|
|
38
|
+
<sp-icon-checkmark-circle
|
|
39
|
+
label="Icon-only badge"
|
|
40
|
+
slot="icon"
|
|
41
|
+
></sp-icon-checkmark-circle>
|
|
42
|
+
</sp-badge>
|
|
43
|
+
<sp-badge size="s">
|
|
44
|
+
<sp-icon-settings slot="icon"></sp-icon-settings>
|
|
45
|
+
Icon and label
|
|
46
|
+
</sp-badge>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Options
|
|
50
|
+
|
|
51
|
+
It is not recommended to make badges interactive. Consider using a different component if you need interactivity, such as buttons, tags, or links.
|
|
52
|
+
|
|
53
|
+
#### Sizes
|
|
27
54
|
|
|
28
55
|
<sp-tabs selected="m" auto label="Size Attribute Options">
|
|
29
56
|
<sp-tab value="s">Small</sp-tab>
|
|
@@ -32,6 +59,12 @@ import { Badge } from '@spectrum-web-components/badge';
|
|
|
32
59
|
```html demo
|
|
33
60
|
<div style="display: flex; gap: var(--spectrum-spacing-75);">
|
|
34
61
|
<sp-badge size="s">Label</sp-badge>
|
|
62
|
+
<sp-badge size="s">
|
|
63
|
+
<sp-icon-checkmark-circle
|
|
64
|
+
label="Icon-only badge"
|
|
65
|
+
slot="icon"
|
|
66
|
+
></sp-icon-checkmark-circle>
|
|
67
|
+
</sp-badge>
|
|
35
68
|
<sp-badge size="s">
|
|
36
69
|
<sp-icon-checkmark-circle slot="icon"></sp-icon-checkmark-circle>
|
|
37
70
|
Icon and label
|
|
@@ -46,6 +79,12 @@ import { Badge } from '@spectrum-web-components/badge';
|
|
|
46
79
|
```html demo
|
|
47
80
|
<div style="display: flex; gap: var(--spectrum-spacing-75);">
|
|
48
81
|
<sp-badge size="m">Label</sp-badge>
|
|
82
|
+
<sp-badge size="m">
|
|
83
|
+
<sp-icon-checkmark-circle
|
|
84
|
+
label="Icon-only badge"
|
|
85
|
+
slot="icon"
|
|
86
|
+
></sp-icon-checkmark-circle>
|
|
87
|
+
</sp-badge>
|
|
49
88
|
<sp-badge size="m">
|
|
50
89
|
<sp-icon-checkmark-circle slot="icon"></sp-icon-checkmark-circle>
|
|
51
90
|
Icon and label
|
|
@@ -60,6 +99,12 @@ import { Badge } from '@spectrum-web-components/badge';
|
|
|
60
99
|
```html demo
|
|
61
100
|
<div style="display: flex; gap: var(--spectrum-spacing-75);">
|
|
62
101
|
<sp-badge size="l">Label</sp-badge>
|
|
102
|
+
<sp-badge size="l">
|
|
103
|
+
<sp-icon-checkmark-circle
|
|
104
|
+
label="Icon-only badge"
|
|
105
|
+
slot="icon"
|
|
106
|
+
></sp-icon-checkmark-circle>
|
|
107
|
+
</sp-badge>
|
|
63
108
|
<sp-badge size="l">
|
|
64
109
|
<sp-icon-checkmark-circle slot="icon"></sp-icon-checkmark-circle>
|
|
65
110
|
Icon and label
|
|
@@ -74,6 +119,12 @@ import { Badge } from '@spectrum-web-components/badge';
|
|
|
74
119
|
```html demo
|
|
75
120
|
<div style="display: flex; gap: var(--spectrum-spacing-75);">
|
|
76
121
|
<sp-badge size="xl">Label</sp-badge>
|
|
122
|
+
<sp-badge size="xl">
|
|
123
|
+
<sp-icon-checkmark-circle
|
|
124
|
+
label="Icon-only badge"
|
|
125
|
+
slot="icon"
|
|
126
|
+
></sp-icon-checkmark-circle>
|
|
127
|
+
</sp-badge>
|
|
77
128
|
<sp-badge size="xl">
|
|
78
129
|
<sp-icon-checkmark-circle slot="icon"></sp-icon-checkmark-circle>
|
|
79
130
|
Icon and label
|
|
@@ -84,15 +135,24 @@ import { Badge } from '@spectrum-web-components/badge';
|
|
|
84
135
|
</sp-tab-panel>
|
|
85
136
|
</sp-tabs>
|
|
86
137
|
|
|
87
|
-
|
|
138
|
+
#### Variants
|
|
139
|
+
|
|
140
|
+
The `<sp-badge>` can be customized with either semantic or non-semantic variants. Badges are intended as display elements (like status lights), so avoid using badges for critical actions.
|
|
88
141
|
|
|
89
|
-
|
|
142
|
+
<sp-tabs selected="semantic" auto label="Semantic and non-semantic variants">
|
|
143
|
+
<sp-tab value="semantic">Semantic</sp-tab>
|
|
144
|
+
<sp-tab-panel value="semantic">
|
|
90
145
|
|
|
91
|
-
|
|
146
|
+
When badges have a semantic meaning, they use semantic colors. Use these variants for the following statuses:
|
|
147
|
+
|
|
148
|
+
- **Positive**: approved, complete, success, new, purchased, licensed
|
|
149
|
+
- **Informative**: active, in use, live, published
|
|
150
|
+
- **Negative**: error, alert, rejected, failed
|
|
151
|
+
- **Neutral**: archived, deleted, paused, draft, not started, ended
|
|
92
152
|
|
|
93
153
|
```html demo
|
|
94
154
|
<div style="display: flex; gap: var(--spectrum-spacing-75);">
|
|
95
|
-
<sp-badge variant="accent">
|
|
155
|
+
<sp-badge variant="accent">Accent</sp-badge>
|
|
96
156
|
<sp-badge variant="neutral">Neutral</sp-badge>
|
|
97
157
|
<sp-badge variant="informative">Informative</sp-badge>
|
|
98
158
|
<sp-badge variant="positive">Positive</sp-badge>
|
|
@@ -101,9 +161,11 @@ The `<sp-badge>` can be customized with either semantic or non-semantic variants
|
|
|
101
161
|
</div>
|
|
102
162
|
```
|
|
103
163
|
|
|
104
|
-
|
|
164
|
+
</sp-tab-panel>
|
|
165
|
+
<sp-tab value="nonsemantic">Non-semantic</sp-tab>
|
|
166
|
+
<sp-tab-panel value="nonsemantic">
|
|
105
167
|
|
|
106
|
-
|
|
168
|
+
When badges are for color-coded categories, they use non-semantic colors. Non-semantic variants are ideally used for when there are 8 categories or less.
|
|
107
169
|
|
|
108
170
|
```html demo
|
|
109
171
|
<div style="display: flex; gap: var(--spectrum-spacing-75); flex-wrap:wrap;">
|
|
@@ -124,9 +186,12 @@ Non-semantic badge colors are no longer supported directly by Spectrum and Spect
|
|
|
124
186
|
</div>
|
|
125
187
|
```
|
|
126
188
|
|
|
127
|
-
|
|
189
|
+
</sp-tab-panel>
|
|
190
|
+
</sp-tabs>
|
|
191
|
+
|
|
192
|
+
#### Fixed positioning
|
|
128
193
|
|
|
129
|
-
|
|
194
|
+
`<sp-badge>` can be displayed as if it is "fixed" to the edge of a UI. The `fixed` attribute can be leveraged to alter the border rounding based on the position you would like to achieve. Fixed positioning options include `block-start`, `block-end`, `inline-start`, and `inline-end`.
|
|
130
195
|
|
|
131
196
|
```html
|
|
132
197
|
<div
|
|
@@ -159,3 +224,81 @@ When you'd like to have the `<sp-badge>` display as if "fixed" to the edge of a
|
|
|
159
224
|
</sp-badge>
|
|
160
225
|
</div>
|
|
161
226
|
```
|
|
227
|
+
|
|
228
|
+
### Behaviors
|
|
229
|
+
|
|
230
|
+
Badges are not interactive by default.
|
|
231
|
+
|
|
232
|
+
When a badge's label is too long for the available horizontal space, it wraps to form another line. Text wrapping can be enforced when a `max-inline-size` is applied to the badge. If there is no room for a second line of text, the badge should truncate and include a tooltip to expose the full text upon hover.
|
|
233
|
+
|
|
234
|
+
```html demo
|
|
235
|
+
<overlay-trigger>
|
|
236
|
+
<sp-badge style="max-inline-size: 350px;" slot="trigger">
|
|
237
|
+
Wikipedia is the best thing ever. Anyone in the world can write anything
|
|
238
|
+
they want about any subject so you know you are getting the best
|
|
239
|
+
possible information.
|
|
240
|
+
</sp-badge>
|
|
241
|
+
<sp-tooltip slot="hover-content">
|
|
242
|
+
Wikipedia is the best thing ever. Anyone in the world can write anything
|
|
243
|
+
they want about any subject so you know you are getting the best
|
|
244
|
+
possible information.
|
|
245
|
+
</sp-tooltip>
|
|
246
|
+
</overlay-trigger>
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### Accessibility
|
|
250
|
+
|
|
251
|
+
<div style="margin-block-end: 2rem">
|
|
252
|
+
<sp-table>
|
|
253
|
+
<sp-table-head>
|
|
254
|
+
<sp-table-head-cell>Do ✅</sp-table-head-cell>
|
|
255
|
+
<sp-table-head-cell>Don't ❌</sp-table-head-cell>
|
|
256
|
+
</sp-table-head>
|
|
257
|
+
<sp-table-body>
|
|
258
|
+
<sp-table-row>
|
|
259
|
+
<sp-table-cell>Use badges for status indication</sp-table-cell>
|
|
260
|
+
<sp-table-cell>Use badges for critical actions</sp-table-cell>
|
|
261
|
+
</sp-table-row>
|
|
262
|
+
<sp-table-row>
|
|
263
|
+
<sp-table-cell>Use visible labels most often</sp-table-cell>
|
|
264
|
+
<sp-table-cell>Overwhelm a user with too much critical information</sp-table-cell>
|
|
265
|
+
</sp-table-row>
|
|
266
|
+
<sp-table-row>
|
|
267
|
+
<sp-table-cell>Use icon-only badges with aria-label</sp-table-cell>
|
|
268
|
+
</sp-table-row>
|
|
269
|
+
<sp-table-row>
|
|
270
|
+
<sp-table-cell>Use badges for supplemental information</sp-table-cell>
|
|
271
|
+
</sp-table-row>
|
|
272
|
+
</sp-table-body>
|
|
273
|
+
</sp-table>
|
|
274
|
+
</div>
|
|
275
|
+
|
|
276
|
+
#### Always include a label
|
|
277
|
+
|
|
278
|
+
Badges should always have a label for accessibility and clear comprehension. When the label is not defined, a badge becomes icon-only. If a visible label isn't specified, an `aria-label` must be provided to the icon for accessibility. An icon-only badge is best for very small spaces, and it should include a tooltip on hover to provide more context for the icon's meaning.
|
|
279
|
+
|
|
280
|
+
Remember that a tooltip does not replace an accessible label.
|
|
281
|
+
|
|
282
|
+
```html demo
|
|
283
|
+
<overlay-trigger>
|
|
284
|
+
<sp-badge size="m" slot="trigger">
|
|
285
|
+
<sp-icon-checkmark-circle
|
|
286
|
+
label="Labels are important"
|
|
287
|
+
slot="icon"
|
|
288
|
+
></sp-icon-checkmark-circle>
|
|
289
|
+
</sp-badge>
|
|
290
|
+
<sp-tooltip placement="top" slot="hover-content">
|
|
291
|
+
<sp-icon-checkmark-circle slot="icon"></sp-icon-checkmark-circle>
|
|
292
|
+
Labels are important
|
|
293
|
+
</sp-tooltip>
|
|
294
|
+
</overlay-trigger>
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
#### Keyboard interactions
|
|
298
|
+
|
|
299
|
+
- <kbd>Tab</kbd>: Places focus on the badge if it is interactive.
|
|
300
|
+
- <kbd>Space</kbd> or <kbd>Enter</kbd>: Filters results by the selected badge or performs the action associated with the badge.
|
|
301
|
+
|
|
302
|
+
#### Don't override semantic colors
|
|
303
|
+
|
|
304
|
+
The badge's variants provide semantic meaning through both color and ARIA attributes, ensuring that information is not conveyed through color alone.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/badge",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0-nightly.20251013134115",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "https://github.com/adobe/spectrum-web-components.git",
|
|
12
|
-
"directory": "packages/badge"
|
|
12
|
+
"directory": "first-gen/packages/badge"
|
|
13
13
|
},
|
|
14
14
|
"author": "Adobe",
|
|
15
15
|
"homepage": "https://opensource.adobe.com/spectrum-web-components/components/badge",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
},
|
|
27
27
|
"./package.json": "./package.json",
|
|
28
28
|
"./src/Badge.js": {
|
|
29
|
-
"
|
|
30
|
-
"
|
|
29
|
+
"default": "./src/Badge.js",
|
|
30
|
+
"development": "./src/Badge.dev.js"
|
|
31
31
|
},
|
|
32
32
|
"./src/badge-overrides.css.js": "./src/badge-overrides.css.js",
|
|
33
33
|
"./src/badge.css.js": "./src/badge.css.js",
|
|
@@ -64,8 +64,9 @@
|
|
|
64
64
|
"css"
|
|
65
65
|
],
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@spectrum-web-components/base": "1.
|
|
68
|
-
"@spectrum-web-components/
|
|
67
|
+
"@spectrum-web-components/base": "1.9.0-nightly.20251013134115",
|
|
68
|
+
"@spectrum-web-components/core-next": "workspace:*",
|
|
69
|
+
"@spectrum-web-components/shared": "1.9.0-nightly.20251013134115"
|
|
69
70
|
},
|
|
70
71
|
"types": "./src/index.d.ts",
|
|
71
72
|
"customElements": "custom-elements.json",
|
package/sp-badge.d.ts
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
1
12
|
import { Badge } from './src/Badge.js';
|
|
2
13
|
declare global {
|
|
3
14
|
interface HTMLElementTagNameMap {
|
package/sp-badge.dev.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["sp-badge.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 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 { Badge } from './src/Badge.dev.js'\nimport { defineElement } from '@spectrum-web-components/base/src/define-element.js';\n\ndefineElement('sp-badge', Badge);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-badge': Badge;\n }\n}\n"],
|
|
5
5
|
"mappings": ";AAYA,SAAS,aAAa;AACtB,SAAS,qBAAqB;AAE9B,cAAc,YAAY,KAAK;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/sp-badge.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["sp-badge.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 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 { Badge } from './src/Badge.js';\nimport { defineElement } from '@spectrum-web-components/base/src/define-element.js';\n\ndefineElement('sp-badge', Badge);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-badge': Badge;\n }\n}\n"],
|
|
5
5
|
"mappings": "aAYA,OAAS,SAAAA,MAAa,iBACtB,OAAS,iBAAAC,MAAqB,sDAE9BA,EAAc,WAAYD,CAAK",
|
|
6
6
|
"names": ["Badge", "defineElement"]
|
|
7
7
|
}
|
package/src/Badge.d.ts
CHANGED
|
@@ -1,31 +1,59 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import { CSSResultArray, TemplateResult } from '@spectrum-web-components/base';
|
|
13
|
+
import { BadgeBase, type BadgeVariantS1, type FixedValues as FixedValuesBase } from '@spectrum-web-components/core-next/components/badge';
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated The `BADGE_VARIANTS` export is deprecated and will be removed
|
|
16
|
+
* in a future release. If needed, you can access the internal
|
|
17
|
+
* `Badge.VARIANTS` property from the constructor.
|
|
18
|
+
*/
|
|
2
19
|
export declare const BADGE_VARIANTS: readonly ["accent", "neutral", "informative", "positive", "negative", "notice", "fuchsia", "indigo", "magenta", "purple", "seafoam", "yellow", "gray", "red", "orange", "chartreuse", "celery", "green", "cyan", "blue"];
|
|
3
|
-
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated The `FIXED_VALUES` export is deprecated and will be removed
|
|
22
|
+
* in a future release. If needed, you can access the internal
|
|
23
|
+
* `Badge.FIXED_VALUES` property from the constructor.
|
|
24
|
+
*/
|
|
4
25
|
export declare const FIXED_VALUES: readonly ["inline-start", "inline-end", "block-start", "block-end"];
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated The `BadgeVariant` type export is deprecated and will be removed
|
|
28
|
+
* in a future release. If needed, you can infer this type from the `Badge`
|
|
29
|
+
* prototype as follows: `typeof Badge.prototype.variant`
|
|
30
|
+
*/
|
|
31
|
+
export type BadgeVariant = BadgeVariantS1;
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated The `FixedValues` type export is deprecated and will be removed
|
|
34
|
+
* in a future release. If needed, you can infer this type from the `Badge`
|
|
35
|
+
* constructor as follows: `typeof Badge.FIXED_VALUES`
|
|
36
|
+
*/
|
|
37
|
+
export type FixedValues = FixedValuesBase;
|
|
16
38
|
/**
|
|
17
39
|
* @element sp-badge
|
|
18
40
|
*
|
|
19
41
|
* @slot - Text label of the badge
|
|
20
42
|
* @slot icon - Optional icon that appears to the left of the label
|
|
21
43
|
*/
|
|
22
|
-
export declare class Badge extends
|
|
44
|
+
export declare class Badge extends BadgeBase {
|
|
45
|
+
/**
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
static readonly VARIANTS_COLOR: readonly ["fuchsia", "indigo", "magenta", "purple", "seafoam", "yellow", "gray", "red", "orange", "chartreuse", "celery", "green", "cyan", "blue"];
|
|
49
|
+
/**
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
|
+
static readonly VARIANTS: readonly ["accent", "neutral", "informative", "positive", "negative", "notice", "fuchsia", "indigo", "magenta", "purple", "seafoam", "yellow", "gray", "red", "orange", "chartreuse", "celery", "green", "cyan", "blue"];
|
|
53
|
+
/**
|
|
54
|
+
* The variant of the badge.
|
|
55
|
+
*/
|
|
56
|
+
variant: BadgeVariantS1;
|
|
23
57
|
static get styles(): CSSResultArray;
|
|
24
|
-
get fixed(): FixedValues | undefined;
|
|
25
|
-
set fixed(fixed: FixedValues | undefined);
|
|
26
|
-
private _fixed?;
|
|
27
|
-
variant: BadgeVariant;
|
|
28
|
-
protected get hasIcon(): boolean;
|
|
29
58
|
protected render(): TemplateResult;
|
|
30
59
|
}
|
|
31
|
-
export {};
|
package/src/Badge.dev.js
CHANGED
|
@@ -11,85 +11,30 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
11
11
|
};
|
|
12
12
|
import {
|
|
13
13
|
html,
|
|
14
|
-
nothing
|
|
15
|
-
SizedMixin,
|
|
16
|
-
SpectrumElement
|
|
14
|
+
nothing
|
|
17
15
|
} from "@spectrum-web-components/base";
|
|
18
16
|
import { property } from "@spectrum-web-components/base/src/decorators.js";
|
|
19
|
-
import {
|
|
20
|
-
|
|
17
|
+
import {
|
|
18
|
+
BADGE_VARIANTS_COLOR_S1,
|
|
19
|
+
BADGE_VARIANTS_S1,
|
|
20
|
+
BadgeBase,
|
|
21
|
+
FIXED_VALUES as FIXED_VALUES_BASE
|
|
22
|
+
} from "@spectrum-web-components/core-next/components/badge";
|
|
21
23
|
import styles from "./badge.css.js";
|
|
22
|
-
export const BADGE_VARIANTS =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"informative",
|
|
26
|
-
"positive",
|
|
27
|
-
"negative",
|
|
28
|
-
"notice",
|
|
29
|
-
"fuchsia",
|
|
30
|
-
"indigo",
|
|
31
|
-
"magenta",
|
|
32
|
-
"purple",
|
|
33
|
-
"seafoam",
|
|
34
|
-
"yellow",
|
|
35
|
-
"gray",
|
|
36
|
-
"red",
|
|
37
|
-
"orange",
|
|
38
|
-
"chartreuse",
|
|
39
|
-
"celery",
|
|
40
|
-
"green",
|
|
41
|
-
"cyan",
|
|
42
|
-
"blue"
|
|
43
|
-
];
|
|
44
|
-
export const FIXED_VALUES = [
|
|
45
|
-
"inline-start",
|
|
46
|
-
"inline-end",
|
|
47
|
-
"block-start",
|
|
48
|
-
"block-end"
|
|
49
|
-
];
|
|
50
|
-
export class Badge extends SizedMixin(
|
|
51
|
-
ObserveSlotText(ObserveSlotPresence(SpectrumElement, '[slot="icon"]'), ""),
|
|
52
|
-
{
|
|
53
|
-
noDefaultSize: true
|
|
54
|
-
}
|
|
55
|
-
) {
|
|
24
|
+
export const BADGE_VARIANTS = BADGE_VARIANTS_S1;
|
|
25
|
+
export const FIXED_VALUES = FIXED_VALUES_BASE;
|
|
26
|
+
export class Badge extends BadgeBase {
|
|
56
27
|
constructor() {
|
|
57
28
|
super(...arguments);
|
|
58
29
|
this.variant = "informative";
|
|
59
30
|
}
|
|
31
|
+
// ──────────────────────────────
|
|
32
|
+
// RENDERING & STYLING
|
|
33
|
+
// ──────────────────────────────
|
|
60
34
|
static get styles() {
|
|
61
35
|
return [styles];
|
|
62
36
|
}
|
|
63
|
-
get fixed() {
|
|
64
|
-
return this._fixed;
|
|
65
|
-
}
|
|
66
|
-
set fixed(fixed) {
|
|
67
|
-
if (fixed === this.fixed) return;
|
|
68
|
-
const oldValue = this.fixed;
|
|
69
|
-
this._fixed = fixed;
|
|
70
|
-
if (fixed) {
|
|
71
|
-
this.setAttribute("fixed", fixed);
|
|
72
|
-
} else {
|
|
73
|
-
this.removeAttribute("fixed");
|
|
74
|
-
}
|
|
75
|
-
this.requestUpdate("fixed", oldValue);
|
|
76
|
-
}
|
|
77
|
-
get hasIcon() {
|
|
78
|
-
return this.slotContentIsPresent;
|
|
79
|
-
}
|
|
80
37
|
render() {
|
|
81
|
-
if (true) {
|
|
82
|
-
if (!BADGE_VARIANTS.includes(this.variant)) {
|
|
83
|
-
window.__swc.warn(
|
|
84
|
-
this,
|
|
85
|
-
`<${this.localName}> element expect the "variant" attribute to be one of the following:`,
|
|
86
|
-
"https://opensource.adobe.com/spectrum-web-components/components/badge/#variants",
|
|
87
|
-
{
|
|
88
|
-
issues: [...BADGE_VARIANTS]
|
|
89
|
-
}
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
38
|
return html`
|
|
94
39
|
${this.hasIcon ? html`
|
|
95
40
|
<slot
|
|
@@ -103,9 +48,17 @@ export class Badge extends SizedMixin(
|
|
|
103
48
|
`;
|
|
104
49
|
}
|
|
105
50
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
51
|
+
// ────────────────────
|
|
52
|
+
// API OVERRIDES
|
|
53
|
+
// ────────────────────
|
|
54
|
+
/**
|
|
55
|
+
* @internal
|
|
56
|
+
*/
|
|
57
|
+
Badge.VARIANTS_COLOR = BADGE_VARIANTS_COLOR_S1;
|
|
58
|
+
/**
|
|
59
|
+
* @internal
|
|
60
|
+
*/
|
|
61
|
+
Badge.VARIANTS = BADGE_VARIANTS_S1;
|
|
109
62
|
__decorateClass([
|
|
110
63
|
property({ type: String, reflect: true })
|
|
111
64
|
], Badge.prototype, "variant", 2);
|
package/src/Badge.dev.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["Badge.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";;;;;;;;;;;AAYA;AAAA,EAEI;AAAA,EACA;AAAA,
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 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 nothing,\n TemplateResult,\n} from '@spectrum-web-components/base';\n\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\n\nimport {\n BADGE_VARIANTS_COLOR_S1,\n BADGE_VARIANTS_S1,\n BadgeBase,\n type BadgeVariantS1,\n FIXED_VALUES as FIXED_VALUES_BASE,\n type FixedValues as FixedValuesBase,\n} from '@spectrum-web-components/core-next/components/badge';\n\nimport styles from './badge.css.js';\n\n/**\n * @deprecated The `BADGE_VARIANTS` export is deprecated and will be removed\n * in a future release. If needed, you can access the internal\n * `Badge.VARIANTS` property from the constructor.\n */\nexport const BADGE_VARIANTS = BADGE_VARIANTS_S1;\n\n/**\n * @deprecated The `FIXED_VALUES` export is deprecated and will be removed\n * in a future release. If needed, you can access the internal\n * `Badge.FIXED_VALUES` property from the constructor.\n */\nexport const FIXED_VALUES = FIXED_VALUES_BASE;\n\n/**\n * @deprecated The `BadgeVariant` type export is deprecated and will be removed\n * in a future release. If needed, you can infer this type from the `Badge`\n * prototype as follows: `typeof Badge.prototype.variant`\n */\nexport type BadgeVariant = BadgeVariantS1;\n\n/**\n * @deprecated The `FixedValues` type export is deprecated and will be removed\n * in a future release. If needed, you can infer this type from the `Badge`\n * constructor as follows: `typeof Badge.FIXED_VALUES`\n */\nexport type FixedValues = FixedValuesBase;\n\n/**\n * @element sp-badge\n *\n * @slot - Text label of the badge\n * @slot icon - Optional icon that appears to the left of the label\n */\nexport class Badge extends BadgeBase {\n // \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n // API OVERRIDES\n // \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n /**\n * @internal\n */\n static override readonly VARIANTS_COLOR = BADGE_VARIANTS_COLOR_S1;\n\n /**\n * @internal\n */\n static override readonly VARIANTS = BADGE_VARIANTS_S1;\n\n /**\n * The variant of the badge.\n */\n @property({ type: String, reflect: true })\n public override variant: BadgeVariantS1 = 'informative';\n\n // \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n // RENDERING & STYLING\n // \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n public static override get styles(): CSSResultArray {\n return [styles];\n }\n\n protected override render(): TemplateResult {\n return html`\n ${this.hasIcon\n ? html`\n <slot\n name=\"icon\"\n ?icon-only=${!this.slotHasContent}\n ></slot>\n `\n : nothing}\n <div class=\"label\">\n <slot></slot>\n </div>\n `;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;AAYA;AAAA,EAEI;AAAA,EACA;AAAA,OAEG;AAEP,SAAS,gBAAgB;AAEzB;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EAEA,gBAAgB;AAAA,OAEb;AAEP,OAAO,YAAY;AAOZ,aAAM,iBAAiB;AAOvB,aAAM,eAAe;AAsBrB,aAAM,cAAc,UAAU;AAAA,EAA9B;AAAA;AAmBH,SAAgB,UAA0B;AAAA;AAAA;AAAA;AAAA;AAAA,EAM1C,WAA2B,SAAyB;AAChD,WAAO,CAAC,MAAM;AAAA,EAClB;AAAA,EAEmB,SAAyB;AACxC,WAAO;AAAA,cACD,KAAK,UACD;AAAA;AAAA;AAAA,uCAGqB,CAAC,KAAK,cAAc;AAAA;AAAA,sBAGzC,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKrB;AACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA5Ca,MAQgB,iBAAiB;AAAA;AAAA;AAAA;AARjC,MAagB,WAAW;AAMpB;AAAA,EADf,SAAS,EAAE,MAAM,QAAQ,SAAS,KAAK,CAAC;AAAA,GAlBhC,MAmBO;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/Badge.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
${this.hasIcon?
|
|
1
|
+
"use strict";var d=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var l=(a,t,o,r)=>{for(var e=r>1?void 0:r?A(t,o):t,s=a.length-1,i;s>=0;s--)(i=a[s])&&(e=(r?i(t,o,e):i(e))||e);return r&&e&&d(t,o,e),e};import{html as n,nothing as S}from"@spectrum-web-components/base";import{property as V}from"@spectrum-web-components/base/src/decorators.js";import{BADGE_VARIANTS_COLOR_S1 as c,BADGE_VARIANTS_S1 as p,BadgeBase as m,FIXED_VALUES as u}from"@spectrum-web-components/core-next/components/badge";import y from"./badge.css.js";export const BADGE_VARIANTS=p,FIXED_VALUES=u;export class Badge extends m{constructor(){super(...arguments);this.variant="informative"}static get styles(){return[y]}render(){return n`
|
|
2
|
+
${this.hasIcon?n`
|
|
3
3
|
<slot
|
|
4
4
|
name="icon"
|
|
5
5
|
?icon-only=${!this.slotHasContent}
|
|
6
6
|
></slot>
|
|
7
|
-
`:
|
|
7
|
+
`:S}
|
|
8
8
|
<div class="label">
|
|
9
9
|
<slot></slot>
|
|
10
10
|
</div>
|
|
11
|
-
`}}
|
|
11
|
+
`}}Badge.VARIANTS_COLOR=c,Badge.VARIANTS=p,l([V({type:String,reflect:!0})],Badge.prototype,"variant",2);
|
|
12
12
|
//# sourceMappingURL=Badge.js.map
|
package/src/Badge.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["Badge.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "qNAYA,OAEI,QAAAA,EACA,WAAAC,
|
|
6
|
-
"names": ["html", "nothing", "
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 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 nothing,\n TemplateResult,\n} from '@spectrum-web-components/base';\n\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\n\nimport {\n BADGE_VARIANTS_COLOR_S1,\n BADGE_VARIANTS_S1,\n BadgeBase,\n type BadgeVariantS1,\n FIXED_VALUES as FIXED_VALUES_BASE,\n type FixedValues as FixedValuesBase,\n} from '@spectrum-web-components/core-next/components/badge';\n\nimport styles from './badge.css.js';\n\n/**\n * @deprecated The `BADGE_VARIANTS` export is deprecated and will be removed\n * in a future release. If needed, you can access the internal\n * `Badge.VARIANTS` property from the constructor.\n */\nexport const BADGE_VARIANTS = BADGE_VARIANTS_S1;\n\n/**\n * @deprecated The `FIXED_VALUES` export is deprecated and will be removed\n * in a future release. If needed, you can access the internal\n * `Badge.FIXED_VALUES` property from the constructor.\n */\nexport const FIXED_VALUES = FIXED_VALUES_BASE;\n\n/**\n * @deprecated The `BadgeVariant` type export is deprecated and will be removed\n * in a future release. If needed, you can infer this type from the `Badge`\n * prototype as follows: `typeof Badge.prototype.variant`\n */\nexport type BadgeVariant = BadgeVariantS1;\n\n/**\n * @deprecated The `FixedValues` type export is deprecated and will be removed\n * in a future release. If needed, you can infer this type from the `Badge`\n * constructor as follows: `typeof Badge.FIXED_VALUES`\n */\nexport type FixedValues = FixedValuesBase;\n\n/**\n * @element sp-badge\n *\n * @slot - Text label of the badge\n * @slot icon - Optional icon that appears to the left of the label\n */\nexport class Badge extends BadgeBase {\n // \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n // API OVERRIDES\n // \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n /**\n * @internal\n */\n static override readonly VARIANTS_COLOR = BADGE_VARIANTS_COLOR_S1;\n\n /**\n * @internal\n */\n static override readonly VARIANTS = BADGE_VARIANTS_S1;\n\n /**\n * The variant of the badge.\n */\n @property({ type: String, reflect: true })\n public override variant: BadgeVariantS1 = 'informative';\n\n // \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n // RENDERING & STYLING\n // \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n public static override get styles(): CSSResultArray {\n return [styles];\n }\n\n protected override render(): TemplateResult {\n return html`\n ${this.hasIcon\n ? html`\n <slot\n name=\"icon\"\n ?icon-only=${!this.slotHasContent}\n ></slot>\n `\n : nothing}\n <div class=\"label\">\n <slot></slot>\n </div>\n `;\n }\n}\n"],
|
|
5
|
+
"mappings": "qNAYA,OAEI,QAAAA,EACA,WAAAC,MAEG,gCAEP,OAAS,YAAAC,MAAgB,kDAEzB,OACI,2BAAAC,EACA,qBAAAC,EACA,aAAAC,EAEA,gBAAgBC,MAEb,sDAEP,OAAOC,MAAY,iBAOZ,aAAM,eAAiBH,EAOjB,aAAeE,EAsBrB,aAAM,cAAcD,CAAU,CAA9B,kCAmBH,KAAgB,QAA0B,cAM1C,WAA2B,QAAyB,CAChD,MAAO,CAACE,CAAM,CAClB,CAEmB,QAAyB,CACxC,OAAOP;AAAA,cACD,KAAK,QACDA;AAAA;AAAA;AAAA,uCAGqB,CAAC,KAAK,cAAc;AAAA;AAAA,oBAGzCC,CAAO;AAAA;AAAA;AAAA;AAAA,SAKrB,CACJ,CA5Ca,MAQgB,eAAiBE,EARjC,MAagB,SAAWC,EAMpBI,EAAA,CADfN,EAAS,CAAE,KAAM,OAAQ,QAAS,EAAK,CAAC,GAlBhC,MAmBO",
|
|
6
|
+
"names": ["html", "nothing", "property", "BADGE_VARIANTS_COLOR_S1", "BADGE_VARIANTS_S1", "BadgeBase", "FIXED_VALUES_BASE", "styles", "__decorateClass"]
|
|
7
7
|
}
|