@spectrum-web-components/badge 0.3.1 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -102,13 +102,81 @@ The `<sp-badge>` can be customized with either semantic or non-semantic variants
102
102
 
103
103
  ### Non-Semantic
104
104
 
105
+ Non-semantic badge colors are no longer supported directly by Spectrum and Spectrum Web Components. You can mimic their delivery via the following CSS Custom Properties. These values for the `variant` attribute/property have not been marked as deprecated, but will no longer achieve the results you may have relied on in the past.
106
+
105
107
  ```html demo
106
108
  <div style="display: flex; gap: var(--spectrum-global-dimension-size-50);">
107
- <sp-badge variant="fuchsia">Fuchsia</sp-badge>
108
- <sp-badge variant="indigo">Indigo</sp-badge>
109
- <sp-badge variant="magenta">Magenta</sp-badge>
110
- <sp-badge variant="purple">Purple</sp-badge>
111
- <sp-badge variant="seafoam">Seafoam</sp-badge>
112
- <sp-badge variant="yellow">Yellow</sp-badge>
109
+ <sp-badge
110
+ variant="seafoam"
111
+ style="--mod-badge-background-color-default: var(--spectrum-global-color-static-seafoam-600)"
112
+ >
113
+ Seafoam
114
+ </sp-badge>
115
+ <sp-badge
116
+ variant="indigo"
117
+ style="--mod-badge-background-color-default: var(--spectrum-global-color-static-indigo-600)"
118
+ >
119
+ Indigo
120
+ </sp-badge>
121
+ <sp-badge
122
+ variant="purple"
123
+ style="--mod-badge-background-color-default: var(--spectrum-global-color-static-purple-600)"
124
+ >
125
+ Purple
126
+ </sp-badge>
127
+ <sp-badge
128
+ variant="fuchsia"
129
+ style="--mod-badge-background-color-default: var(--spectrum-global-color-static-fuchsia-600)"
130
+ >
131
+ Fuchsia
132
+ </sp-badge>
133
+ <sp-badge
134
+ variant="magenta"
135
+ style="--mod-badge-background-color-default: var(--spectrum-global-color-static-magenta-600)"
136
+ >
137
+ Magenta
138
+ </sp-badge>
139
+ <sp-badge
140
+ variant="yellow"
141
+ style="--mod-badge-background-color-default: var(--spectrum-alias-background-color-yellow-default); --mod-badge-label-icon-color-white: var(--spectrum-global-color-static-black);"
142
+ >
143
+ Yellow
144
+ </sp-badge>
145
+ </div>
146
+ ```
147
+
148
+ ## Fixed
149
+
150
+ When you'd like to have the `<sp-badge>` display as if "fixed" to the edge of a UI, the `fixed` attribute/property can be leveraged to alter the border rounding based on the position you would like to achieve:
151
+
152
+ ```html
153
+ <div
154
+ style="position: relative; width: 400px; height: 200px; background: #eee; max-width: 100%"
155
+ >
156
+ <sp-badge>None</sp-badge>
157
+ <sp-badge
158
+ fixed="block-start"
159
+ style="position: absolute; top: 0; left: 200px;"
160
+ >
161
+ block-start
162
+ </sp-badge>
163
+ <sp-badge
164
+ fixed="inline-end"
165
+ style="position: absolute; right: 0; top: 100px;"
166
+ >
167
+ inline-end
168
+ </sp-badge>
169
+ <sp-badge
170
+ fixed="block-end"
171
+ style="position: absolute; bottom: 0; left: 200px;"
172
+ >
173
+ block-end
174
+ </sp-badge>
175
+ <sp-badge
176
+ fixed="inline-start"
177
+ style="position: absolute; left: 0; top: 100px;"
178
+ >
179
+ inline-start
180
+ </sp-badge>
113
181
  </div>
114
182
  ```
@@ -25,9 +25,25 @@
25
25
  "kind": "variable",
26
26
  "name": "BADGE_VARIANTS",
27
27
  "type": {
28
- "text": "[\n 'neutral',\n 'informative',\n 'positive',\n 'negative',\n 'fuchsia',\n 'indigo',\n 'magenta',\n 'purple',\n 'seafoam',\n 'yellow',\n]"
28
+ "text": "[\n 'accent',\n 'neutral',\n 'informative',\n 'positive',\n 'negative',\n 'fuchsia',\n 'indigo',\n 'magenta',\n 'purple',\n 'seafoam',\n 'yellow',\n]"
29
29
  },
30
- "default": "[\n 'neutral',\n 'informative',\n 'positive',\n 'negative',\n 'fuchsia',\n 'indigo',\n 'magenta',\n 'purple',\n 'seafoam',\n 'yellow',\n]"
30
+ "default": "[\n 'accent',\n 'neutral',\n 'informative',\n 'positive',\n 'negative',\n 'fuchsia',\n 'indigo',\n 'magenta',\n 'purple',\n 'seafoam',\n 'yellow',\n]"
31
+ },
32
+ {
33
+ "kind": "variable",
34
+ "name": "FIXED_VALUES_DEPRECATED",
35
+ "type": {
36
+ "text": "array"
37
+ },
38
+ "default": "['top', 'bottom', 'left', 'right']"
39
+ },
40
+ {
41
+ "kind": "variable",
42
+ "name": "FIXED_VALUES",
43
+ "type": {
44
+ "text": "[\n 'inline-start',\n 'inline-end',\n 'block-start',\n 'block-end',\n]"
45
+ },
46
+ "default": "[\n 'inline-start',\n 'inline-end',\n 'block-start',\n 'block-end',\n]"
31
47
  },
32
48
  {
33
49
  "kind": "class",
@@ -44,6 +60,24 @@
44
60
  }
45
61
  ],
46
62
  "members": [
63
+ {
64
+ "kind": "field",
65
+ "name": "fixed",
66
+ "type": {
67
+ "text": "FixedValues | undefined"
68
+ },
69
+ "privacy": "public",
70
+ "attribute": "fixed",
71
+ "reflects": true
72
+ },
73
+ {
74
+ "kind": "field",
75
+ "name": "_fixed",
76
+ "type": {
77
+ "text": "FixedValues | undefined"
78
+ },
79
+ "privacy": "private"
80
+ },
47
81
  {
48
82
  "kind": "field",
49
83
  "name": "variant",
@@ -54,9 +88,24 @@
54
88
  "default": "'informative'",
55
89
  "attribute": "variant",
56
90
  "reflects": true
91
+ },
92
+ {
93
+ "kind": "field",
94
+ "name": "hasIcon",
95
+ "type": {
96
+ "text": "boolean"
97
+ },
98
+ "privacy": "protected"
57
99
  }
58
100
  ],
59
101
  "attributes": [
102
+ {
103
+ "name": "fixed",
104
+ "type": {
105
+ "text": "FixedValues | undefined"
106
+ },
107
+ "fieldName": "fixed"
108
+ },
60
109
  {
61
110
  "name": "variant",
62
111
  "type": {
@@ -74,6 +123,10 @@
74
123
  {
75
124
  "name": "ObserveSlotText",
76
125
  "package": "@spectrum-web-components/shared/src/observe-slot-text.js"
126
+ },
127
+ {
128
+ "name": "ObserveSlotPresence",
129
+ "package": "@spectrum-web-components/shared/src/observe-slot-presence.js"
77
130
  }
78
131
  ],
79
132
  "superclass": {
@@ -93,6 +146,22 @@
93
146
  "module": "src/Badge.js"
94
147
  }
95
148
  },
149
+ {
150
+ "kind": "js",
151
+ "name": "FIXED_VALUES_DEPRECATED",
152
+ "declaration": {
153
+ "name": "FIXED_VALUES_DEPRECATED",
154
+ "module": "src/Badge.js"
155
+ }
156
+ },
157
+ {
158
+ "kind": "js",
159
+ "name": "FIXED_VALUES",
160
+ "declaration": {
161
+ "name": "FIXED_VALUES",
162
+ "module": "src/Badge.js"
163
+ }
164
+ },
96
165
  {
97
166
  "kind": "js",
98
167
  "name": "Badge",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-web-components/badge",
3
- "version": "0.3.1",
3
+ "version": "0.4.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -57,12 +57,11 @@
57
57
  "lit-html"
58
58
  ],
59
59
  "dependencies": {
60
- "@spectrum-web-components/base": "^0.7.0",
61
- "@spectrum-web-components/shared": "^0.15.1",
62
- "tslib": "^2.0.0"
60
+ "@spectrum-web-components/base": "^0.7.2",
61
+ "@spectrum-web-components/shared": "^0.15.3"
63
62
  },
64
63
  "devDependencies": {
65
- "@spectrum-css/badge": "^1.0.20"
64
+ "@spectrum-css/badge": "^2.0.0"
66
65
  },
67
66
  "types": "./src/index.d.ts",
68
67
  "customElements": "custom-elements.json",
@@ -70,5 +69,5 @@
70
69
  "./sp-*.js",
71
70
  "./**/*.dev.js"
72
71
  ],
73
- "gitHead": "96da2eef637c5d50dd04a75d40a46353116787b4"
72
+ "gitHead": "370295c7ce89dd64d3d9a4373fd84e861904ec5a"
74
73
  }
package/src/Badge.d.ts CHANGED
@@ -1,7 +1,13 @@
1
1
  import { CSSResultArray, SpectrumElement, TemplateResult } from '@spectrum-web-components/base';
2
- export declare const BADGE_VARIANTS: readonly ["neutral", "informative", "positive", "negative", "fuchsia", "indigo", "magenta", "purple", "seafoam", "yellow"];
2
+ export declare const BADGE_VARIANTS: readonly ["accent", "neutral", "informative", "positive", "negative", "fuchsia", "indigo", "magenta", "purple", "seafoam", "yellow"];
3
3
  export declare type BadgeVariant = typeof BADGE_VARIANTS[number];
4
+ export declare const FIXED_VALUES_DEPRECATED: string[];
5
+ export declare const FIXED_VALUES: readonly ["inline-start", "inline-end", "block-start", "block-end"];
6
+ export declare type FixedValues = typeof FIXED_VALUES[number] | typeof FIXED_VALUES_DEPRECATED[number];
4
7
  declare const Badge_base: typeof SpectrumElement & {
8
+ new (...args: any[]): import("@spectrum-web-components/shared/src/observe-slot-presence.js").SlotPresenceObservingInterface;
9
+ prototype: import("@spectrum-web-components/shared/src/observe-slot-presence.js").SlotPresenceObservingInterface;
10
+ } & {
5
11
  new (...args: any[]): import("@spectrum-web-components/shared/src/observe-slot-text.js").SlotTextObservingInterface;
6
12
  prototype: import("@spectrum-web-components/shared/src/observe-slot-text.js").SlotTextObservingInterface;
7
13
  } & {
@@ -16,7 +22,11 @@ declare const Badge_base: typeof SpectrumElement & {
16
22
  */
17
23
  export declare class Badge extends Badge_base {
18
24
  static get styles(): CSSResultArray;
25
+ get fixed(): FixedValues | undefined;
26
+ set fixed(fixed: FixedValues | undefined);
27
+ private _fixed?;
19
28
  variant: BadgeVariant;
29
+ protected get hasIcon(): boolean;
20
30
  protected render(): TemplateResult;
21
31
  }
22
32
  export {};
package/src/Badge.dev.js CHANGED
@@ -17,8 +17,10 @@ import {
17
17
  } from "@spectrum-web-components/base";
18
18
  import { property } from "@spectrum-web-components/base/src/decorators.js";
19
19
  import { ObserveSlotText } from "@spectrum-web-components/shared/src/observe-slot-text.js";
20
+ import { ObserveSlotPresence } from "@spectrum-web-components/shared/src/observe-slot-presence.js";
20
21
  import styles from "./badge.css.js";
21
22
  export const BADGE_VARIANTS = [
23
+ "accent",
22
24
  "neutral",
23
25
  "informative",
24
26
  "positive",
@@ -30,7 +32,16 @@ export const BADGE_VARIANTS = [
30
32
  "seafoam",
31
33
  "yellow"
32
34
  ];
33
- export class Badge extends SizedMixin(ObserveSlotText(SpectrumElement, "")) {
35
+ export const FIXED_VALUES_DEPRECATED = ["top", "bottom", "left", "right"];
36
+ export const FIXED_VALUES = [
37
+ "inline-start",
38
+ "inline-end",
39
+ "block-start",
40
+ "block-end"
41
+ ];
42
+ export class Badge extends SizedMixin(
43
+ ObserveSlotText(ObserveSlotPresence(SpectrumElement, '[slot="icon"]'), "")
44
+ ) {
34
45
  constructor() {
35
46
  super(...arguments);
36
47
  this.variant = "informative";
@@ -38,6 +49,36 @@ export class Badge extends SizedMixin(ObserveSlotText(SpectrumElement, "")) {
38
49
  static get styles() {
39
50
  return [styles];
40
51
  }
52
+ get fixed() {
53
+ return this._fixed;
54
+ }
55
+ set fixed(fixed) {
56
+ if (fixed === this.fixed)
57
+ return;
58
+ const oldValue = this.fixed;
59
+ if (true) {
60
+ if (fixed && FIXED_VALUES_DEPRECATED.includes(fixed)) {
61
+ window.__swc.warn(
62
+ this,
63
+ `The following values for "fixed" in <${this.localName}> have been deprecated. They will be removed in a future release.`,
64
+ "https://opensource.adobe.com/spectrum-web-components/components/badge/#fixed",
65
+ {
66
+ issues: [...FIXED_VALUES_DEPRECATED]
67
+ }
68
+ );
69
+ }
70
+ }
71
+ this._fixed = fixed;
72
+ if (fixed) {
73
+ this.setAttribute("fixed", fixed);
74
+ } else {
75
+ this.removeAttribute("fixed");
76
+ }
77
+ this.requestUpdate("fixed", oldValue);
78
+ }
79
+ get hasIcon() {
80
+ return this.slotContentIsPresent;
81
+ }
41
82
  render() {
42
83
  if (true) {
43
84
  if (!BADGE_VARIANTS.includes(this.variant)) {
@@ -52,13 +93,21 @@ export class Badge extends SizedMixin(ObserveSlotText(SpectrumElement, "")) {
52
93
  }
53
94
  }
54
95
  return html`
55
- <slot name="icon" ?icon-only=${!this.slotHasContent}></slot>
56
- <div id="label">
96
+ ${this.hasIcon ? html`
97
+ <slot
98
+ name="icon"
99
+ ?icon-only=${!this.slotHasContent}
100
+ ></slot>
101
+ ` : html``}
102
+ <div class="label">
57
103
  <slot></slot>
58
104
  </div>
59
105
  `;
60
106
  }
61
107
  }
108
+ __decorateClass([
109
+ property({ reflect: true })
110
+ ], Badge.prototype, "fixed", 1);
62
111
  __decorateClass([
63
112
  property({ type: String, reflect: true })
64
113
  ], Badge.prototype, "variant", 2);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["Badge.ts"],
4
- "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n html,\n SizedMixin,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\n\nimport { ObserveSlotText } from '@spectrum-web-components/shared/src/observe-slot-text.js';\nimport styles from './badge.css.js';\n\nexport const BADGE_VARIANTS = [\n 'neutral',\n 'informative',\n 'positive',\n 'negative',\n 'fuchsia',\n 'indigo',\n 'magenta',\n 'purple',\n 'seafoam',\n 'yellow',\n] as const;\nexport type BadgeVariant = typeof BADGE_VARIANTS[number];\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 SizedMixin(ObserveSlotText(SpectrumElement, '')) {\n public static override get styles(): CSSResultArray {\n return [styles];\n }\n\n @property({ type: String, reflect: true })\n public variant: BadgeVariant = 'informative';\n\n protected override render(): TemplateResult {\n if (window.__swc.DEBUG) {\n if (!BADGE_VARIANTS.includes(this.variant)) {\n window.__swc.warn(\n this,\n `<${this.localName}> element expect the \"variant\" attribute to be one of the following:`,\n 'https://opensource.adobe.com/spectrum-web-components/components/badge/#variants',\n {\n issues: [...BADGE_VARIANTS]\n },\n );\n }\n }\n return html`\n <slot name=\"icon\" ?icon-only=${!this.slotHasContent}></slot>\n <div id=\"label\">\n <slot></slot>\n </div>\n `;\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;AAYA;AAAA,EAEI;AAAA,EACA;AAAA,EACA;AAAA,OAEG;AACP,SAAS,gBAAgB;AAEzB,SAAS,uBAAuB;AAChC,OAAO,YAAY;AAEZ,aAAM,iBAAiB;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ;AASO,aAAM,cAAc,WAAW,gBAAgB,iBAAiB,EAAE,CAAC,EAAE;AAAA,EAArE;AAAA;AAMH,SAAO,UAAwB;AAAA;AAAA,EAL/B,WAA2B,SAAyB;AAChD,WAAO,CAAC,MAAM;AAAA,EAClB;AAAA,EAKmB,SAAyB;AACxC,QAAI,MAAoB;AACpB,UAAI,CAAC,eAAe,SAAS,KAAK,OAAO,GAAG;AACxC,eAAO,MAAM;AAAA,UACT;AAAA,UACA,IAAI,KAAK;AAAA,UACT;AAAA,UACA;AAAA,YACI,QAAQ,CAAC,GAAG,cAAc;AAAA,UAC9B;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ;AACA,WAAO;AAAA,2CAC4B,CAAC,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA,EAK7C;AACJ;AAtBW;AAAA,EADN,SAAS,EAAE,MAAM,QAAQ,SAAS,KAAK,CAAC;AAAA,GALhC,MAMF;",
4
+ "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n html,\n SizedMixin,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\n\nimport { ObserveSlotText } from '@spectrum-web-components/shared/src/observe-slot-text.js';\nimport { ObserveSlotPresence } from '@spectrum-web-components/shared/src/observe-slot-presence.js';\nimport styles from './badge.css.js';\n\nexport const BADGE_VARIANTS = [\n 'accent',\n 'neutral',\n 'informative',\n 'positive',\n 'negative',\n 'fuchsia',\n 'indigo',\n 'magenta',\n 'purple',\n 'seafoam',\n 'yellow',\n] as const;\nexport type BadgeVariant = typeof BADGE_VARIANTS[number];\nexport const FIXED_VALUES_DEPRECATED = ['top', 'bottom', 'left', 'right'];\nexport const FIXED_VALUES = [\n 'inline-start',\n 'inline-end',\n 'block-start',\n 'block-end',\n] as const;\nexport type FixedValues =\n | typeof FIXED_VALUES[number]\n | typeof FIXED_VALUES_DEPRECATED[number];\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 SizedMixin(\n ObserveSlotText(ObserveSlotPresence(SpectrumElement, '[slot=\"icon\"]'), '')\n) {\n public static override get styles(): CSSResultArray {\n return [styles];\n }\n\n @property({ reflect: true })\n public get fixed(): FixedValues | undefined {\n return this._fixed;\n }\n\n public set fixed(fixed: FixedValues | undefined) {\n if (fixed === this.fixed) return;\n const oldValue = this.fixed;\n if (window.__swc.DEBUG) {\n if (fixed && FIXED_VALUES_DEPRECATED.includes(fixed)) {\n window.__swc.warn(\n this,\n `The following values for \"fixed\" in <${this.localName}> have been deprecated. They will be removed in a future release.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/badge/#fixed',\n {\n issues: [...FIXED_VALUES_DEPRECATED],\n }\n );\n }\n }\n this._fixed = fixed;\n if (fixed) {\n this.setAttribute('fixed', fixed);\n } else {\n this.removeAttribute('fixed');\n }\n this.requestUpdate('fixed', oldValue);\n }\n\n private _fixed?: FixedValues;\n\n @property({ type: String, reflect: true })\n public variant: BadgeVariant = 'informative';\n\n protected get hasIcon(): boolean {\n return this.slotContentIsPresent;\n }\n\n protected override render(): TemplateResult {\n if (window.__swc.DEBUG) {\n if (!BADGE_VARIANTS.includes(this.variant)) {\n window.__swc.warn(\n this,\n `<${this.localName}> element expect the \"variant\" attribute to be one of the following:`,\n 'https://opensource.adobe.com/spectrum-web-components/components/badge/#variants',\n {\n issues: [...BADGE_VARIANTS],\n }\n );\n }\n }\n return html`\n ${this.hasIcon\n ? html`\n <slot\n name=\"icon\"\n ?icon-only=${!this.slotHasContent}\n ></slot>\n `\n : html``}\n <div class=\"label\">\n <slot></slot>\n </div>\n `;\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;AAYA;AAAA,EAEI;AAAA,EACA;AAAA,EACA;AAAA,OAEG;AACP,SAAS,gBAAgB;AAEzB,SAAS,uBAAuB;AAChC,SAAS,2BAA2B;AACpC,OAAO,YAAY;AAEZ,aAAM,iBAAiB;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ;AAEO,aAAM,0BAA0B,CAAC,OAAO,UAAU,QAAQ,OAAO;AACjE,aAAM,eAAe;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ;AAWO,aAAM,cAAc;AAAA,EACvB,gBAAgB,oBAAoB,iBAAiB,eAAe,GAAG,EAAE;AAC7E,EAAE;AAAA,EAFK;AAAA;AAuCH,SAAO,UAAwB;AAAA;AAAA,EApC/B,WAA2B,SAAyB;AAChD,WAAO,CAAC,MAAM;AAAA,EAClB;AAAA,EAGA,IAAW,QAAiC;AACxC,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,IAAW,MAAM,OAAgC;AAC7C,QAAI,UAAU,KAAK;AAAO;AAC1B,UAAM,WAAW,KAAK;AACtB,QAAI,MAAoB;AACpB,UAAI,SAAS,wBAAwB,SAAS,KAAK,GAAG;AAClD,eAAO,MAAM;AAAA,UACT;AAAA,UACA,wCAAwC,KAAK;AAAA,UAC7C;AAAA,UACA;AAAA,YACI,QAAQ,CAAC,GAAG,uBAAuB;AAAA,UACvC;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ;AACA,SAAK,SAAS;AACd,QAAI,OAAO;AACP,WAAK,aAAa,SAAS,KAAK;AAAA,IACpC,OAAO;AACH,WAAK,gBAAgB,OAAO;AAAA,IAChC;AACA,SAAK,cAAc,SAAS,QAAQ;AAAA,EACxC;AAAA,EAOA,IAAc,UAAmB;AAC7B,WAAO,KAAK;AAAA,EAChB;AAAA,EAEmB,SAAyB;AACxC,QAAI,MAAoB;AACpB,UAAI,CAAC,eAAe,SAAS,KAAK,OAAO,GAAG;AACxC,eAAO,MAAM;AAAA,UACT;AAAA,UACA,IAAI,KAAK;AAAA,UACT;AAAA,UACA;AAAA,YACI,QAAQ,CAAC,GAAG,cAAc;AAAA,UAC9B;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ;AACA,WAAO;AAAA,cACD,KAAK,UACD;AAAA;AAAA;AAAA,uCAGqB,CAAC,KAAK;AAAA;AAAA,sBAG3B;AAAA;AAAA;AAAA;AAAA;AAAA,EAKd;AACJ;AAhEe;AAAA,EADV,SAAS,EAAE,SAAS,KAAK,CAAC;AAAA,GAPlB,MAQE;AA+BJ;AAAA,EADN,SAAS,EAAE,MAAM,QAAQ,SAAS,KAAK,CAAC;AAAA,GAtChC,MAuCF;",
6
6
  "names": []
7
7
  }
package/src/Badge.js CHANGED
@@ -1,7 +1,12 @@
1
- "use strict";var l=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var a=(r,t,i,o)=>{for(var e=o>1?void 0:o?p(t,i):t,s=r.length-1,n;s>=0;s--)(n=r[s])&&(e=(o?n(t,i,e):n(e))||e);return o&&e&&l(t,i,e),e};import{html as m,SizedMixin as c,SpectrumElement as u}from"@spectrum-web-components/base";import{property as d}from"@spectrum-web-components/base/src/decorators.js";import{ObserveSlotText as f}from"@spectrum-web-components/shared/src/observe-slot-text.js";import A from"./badge.css.js";export const BADGE_VARIANTS=["neutral","informative","positive","negative","fuchsia","indigo","magenta","purple","seafoam","yellow"];export class Badge extends c(f(u,"")){constructor(){super(...arguments);this.variant="informative"}static get styles(){return[A]}render(){return m`
2
- <slot name="icon" ?icon-only=${!this.slotHasContent}></slot>
3
- <div id="label">
1
+ "use strict";var d=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var a=(s,o,e,i)=>{for(var t=i>1?void 0:i?p(o,e):o,r=s.length-1,n;r>=0;r--)(n=s[r])&&(t=(i?n(o,e,t):n(t))||t);return i&&t&&d(o,e,t),t};import{html as l,SizedMixin as u,SpectrumElement as f}from"@spectrum-web-components/base";import{property as c}from"@spectrum-web-components/base/src/decorators.js";import{ObserveSlotText as m}from"@spectrum-web-components/shared/src/observe-slot-text.js";import{ObserveSlotPresence as E}from"@spectrum-web-components/shared/src/observe-slot-presence.js";import h from"./badge.css.js";export const BADGE_VARIANTS=["accent","neutral","informative","positive","negative","fuchsia","indigo","magenta","purple","seafoam","yellow"],FIXED_VALUES_DEPRECATED=["top","bottom","left","right"],FIXED_VALUES=["inline-start","inline-end","block-start","block-end"];export class Badge extends u(m(E(f,'[slot="icon"]'),"")){constructor(){super(...arguments);this.variant="informative"}static get styles(){return[h]}get fixed(){return this._fixed}set fixed(e){if(e===this.fixed)return;const i=this.fixed;this._fixed=e,e?this.setAttribute("fixed",e):this.removeAttribute("fixed"),this.requestUpdate("fixed",i)}get hasIcon(){return this.slotContentIsPresent}render(){return l`
2
+ ${this.hasIcon?l`
3
+ <slot
4
+ name="icon"
5
+ ?icon-only=${!this.slotHasContent}
6
+ ></slot>
7
+ `:l``}
8
+ <div class="label">
4
9
  <slot></slot>
5
10
  </div>
6
- `}}a([d({type:String,reflect:!0})],Badge.prototype,"variant",2);
11
+ `}}a([c({reflect:!0})],Badge.prototype,"fixed",1),a([c({type:String,reflect:!0})],Badge.prototype,"variant",2);
7
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": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n html,\n SizedMixin,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\n\nimport { ObserveSlotText } from '@spectrum-web-components/shared/src/observe-slot-text.js';\nimport styles from './badge.css.js';\n\nexport const BADGE_VARIANTS = [\n 'neutral',\n 'informative',\n 'positive',\n 'negative',\n 'fuchsia',\n 'indigo',\n 'magenta',\n 'purple',\n 'seafoam',\n 'yellow',\n] as const;\nexport type BadgeVariant = typeof BADGE_VARIANTS[number];\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 SizedMixin(ObserveSlotText(SpectrumElement, '')) {\n public static override get styles(): CSSResultArray {\n return [styles];\n }\n\n @property({ type: String, reflect: true })\n public variant: BadgeVariant = 'informative';\n\n protected override render(): TemplateResult {\n if (window.__swc.DEBUG) {\n if (!BADGE_VARIANTS.includes(this.variant)) {\n window.__swc.warn(\n this,\n `<${this.localName}> element expect the \"variant\" attribute to be one of the following:`,\n 'https://opensource.adobe.com/spectrum-web-components/components/badge/#variants',\n {\n issues: [...BADGE_VARIANTS]\n },\n );\n }\n }\n return html`\n <slot name=\"icon\" ?icon-only=${!this.slotHasContent}></slot>\n <div id=\"label\">\n <slot></slot>\n </div>\n `;\n }\n}\n"],
5
- "mappings": "qNAYA,OAEI,QAAAA,EACA,cAAAC,EACA,mBAAAC,MAEG,gCACP,OAAS,YAAAC,MAAgB,kDAEzB,OAAS,mBAAAC,MAAuB,2DAChC,OAAOC,MAAY,iBAEZ,aAAM,eAAiB,CAC1B,UACA,cACA,WACA,WACA,UACA,SACA,UACA,SACA,UACA,QACJ,EASO,aAAM,cAAcJ,EAAWG,EAAgBF,EAAiB,EAAE,CAAC,CAAE,CAArE,kCAMH,KAAO,QAAwB,cAL/B,WAA2B,QAAyB,CAChD,MAAO,CAACG,CAAM,CAClB,CAKmB,QAAyB,CAaxC,OAAOL;AAAA,2CAC4B,CAAC,KAAK;AAAA;AAAA;AAAA;AAAA,SAK7C,CACJ,CAtBWM,EAAA,CADNH,EAAS,CAAE,KAAM,OAAQ,QAAS,EAAK,CAAC,GALhC,MAMF",
6
- "names": ["html", "SizedMixin", "SpectrumElement", "property", "ObserveSlotText", "styles", "__decorateClass"]
4
+ "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n html,\n SizedMixin,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\n\nimport { ObserveSlotText } from '@spectrum-web-components/shared/src/observe-slot-text.js';\nimport { ObserveSlotPresence } from '@spectrum-web-components/shared/src/observe-slot-presence.js';\nimport styles from './badge.css.js';\n\nexport const BADGE_VARIANTS = [\n 'accent',\n 'neutral',\n 'informative',\n 'positive',\n 'negative',\n 'fuchsia',\n 'indigo',\n 'magenta',\n 'purple',\n 'seafoam',\n 'yellow',\n] as const;\nexport type BadgeVariant = typeof BADGE_VARIANTS[number];\nexport const FIXED_VALUES_DEPRECATED = ['top', 'bottom', 'left', 'right'];\nexport const FIXED_VALUES = [\n 'inline-start',\n 'inline-end',\n 'block-start',\n 'block-end',\n] as const;\nexport type FixedValues =\n | typeof FIXED_VALUES[number]\n | typeof FIXED_VALUES_DEPRECATED[number];\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 SizedMixin(\n ObserveSlotText(ObserveSlotPresence(SpectrumElement, '[slot=\"icon\"]'), '')\n) {\n public static override get styles(): CSSResultArray {\n return [styles];\n }\n\n @property({ reflect: true })\n public get fixed(): FixedValues | undefined {\n return this._fixed;\n }\n\n public set fixed(fixed: FixedValues | undefined) {\n if (fixed === this.fixed) return;\n const oldValue = this.fixed;\n if (window.__swc.DEBUG) {\n if (fixed && FIXED_VALUES_DEPRECATED.includes(fixed)) {\n window.__swc.warn(\n this,\n `The following values for \"fixed\" in <${this.localName}> have been deprecated. They will be removed in a future release.`,\n 'https://opensource.adobe.com/spectrum-web-components/components/badge/#fixed',\n {\n issues: [...FIXED_VALUES_DEPRECATED],\n }\n );\n }\n }\n this._fixed = fixed;\n if (fixed) {\n this.setAttribute('fixed', fixed);\n } else {\n this.removeAttribute('fixed');\n }\n this.requestUpdate('fixed', oldValue);\n }\n\n private _fixed?: FixedValues;\n\n @property({ type: String, reflect: true })\n public variant: BadgeVariant = 'informative';\n\n protected get hasIcon(): boolean {\n return this.slotContentIsPresent;\n }\n\n protected override render(): TemplateResult {\n if (window.__swc.DEBUG) {\n if (!BADGE_VARIANTS.includes(this.variant)) {\n window.__swc.warn(\n this,\n `<${this.localName}> element expect the \"variant\" attribute to be one of the following:`,\n 'https://opensource.adobe.com/spectrum-web-components/components/badge/#variants',\n {\n issues: [...BADGE_VARIANTS],\n }\n );\n }\n }\n return html`\n ${this.hasIcon\n ? html`\n <slot\n name=\"icon\"\n ?icon-only=${!this.slotHasContent}\n ></slot>\n `\n : html``}\n <div class=\"label\">\n <slot></slot>\n </div>\n `;\n }\n}\n"],
5
+ "mappings": "qNAYA,OAEI,QAAAA,EACA,cAAAC,EACA,mBAAAC,MAEG,gCACP,OAAS,YAAAC,MAAgB,kDAEzB,OAAS,mBAAAC,MAAuB,2DAChC,OAAS,uBAAAC,MAA2B,+DACpC,OAAOC,MAAY,iBAEZ,aAAM,eAAiB,CAC1B,SACA,UACA,cACA,WACA,WACA,UACA,SACA,UACA,SACA,UACA,QACJ,EAEa,wBAA0B,CAAC,MAAO,SAAU,OAAQ,OAAO,EAC3D,aAAe,CACxB,eACA,aACA,cACA,WACJ,EAWO,aAAM,cAAcL,EACvBG,EAAgBC,EAAoBH,EAAiB,eAAe,EAAG,EAAE,CAC7E,CAAE,CAFK,kCAuCH,KAAO,QAAwB,cApC/B,WAA2B,QAAyB,CAChD,MAAO,CAACI,CAAM,CAClB,CAGA,IAAW,OAAiC,CACxC,OAAO,KAAK,MAChB,CAEA,IAAW,MAAMC,EAAgC,CAC7C,GAAIA,IAAU,KAAK,MAAO,OAC1B,MAAMC,EAAW,KAAK,MAatB,KAAK,OAASD,EACVA,EACA,KAAK,aAAa,QAASA,CAAK,EAEhC,KAAK,gBAAgB,OAAO,EAEhC,KAAK,cAAc,QAASC,CAAQ,CACxC,CAOA,IAAc,SAAmB,CAC7B,OAAO,KAAK,oBAChB,CAEmB,QAAyB,CAaxC,OAAOR;AAAA,cACD,KAAK,QACDA;AAAA;AAAA;AAAA,uCAGqB,CAAC,KAAK;AAAA;AAAA,oBAG3BA;AAAA;AAAA;AAAA;AAAA,SAKd,CACJ,CAhEeS,EAAA,CADVN,EAAS,CAAE,QAAS,EAAK,CAAC,GAPlB,MAQE,qBA+BJM,EAAA,CADNN,EAAS,CAAE,KAAM,OAAQ,QAAS,EAAK,CAAC,GAtChC,MAuCF",
6
+ "names": ["html", "SizedMixin", "SpectrumElement", "property", "ObserveSlotText", "ObserveSlotPresence", "styles", "fixed", "oldValue", "__decorateClass"]
7
7
  }