@spectrum-web-components/progress-bar 0.34.1-rc.0 → 0.35.0
Sign up to get free protection for your applications and to get access to all the features.
- package/custom-elements.json +27 -4
- package/package.json +5 -5
- package/src/ProgressBar.d.ts +5 -0
- package/src/ProgressBar.dev.js +36 -11
- package/src/ProgressBar.dev.js.map +2 -2
- package/src/ProgressBar.js +11 -6
- package/src/ProgressBar.js.map +3 -3
- package/test/progress-bar.test.js +9 -0
- package/test/progress-bar.test.js.map +2 -2
package/custom-elements.json
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
"modules": [
|
5
5
|
{
|
6
6
|
"kind": "javascript-module",
|
7
|
-
"path": "sp-progress-bar.
|
7
|
+
"path": "sp-progress-bar.js",
|
8
8
|
"declarations": [],
|
9
9
|
"exports": [
|
10
10
|
{
|
@@ -19,7 +19,7 @@
|
|
19
19
|
},
|
20
20
|
{
|
21
21
|
"kind": "javascript-module",
|
22
|
-
"path": "src/ProgressBar.
|
22
|
+
"path": "src/ProgressBar.js",
|
23
23
|
"declarations": [
|
24
24
|
{
|
25
25
|
"kind": "class",
|
@@ -45,7 +45,8 @@
|
|
45
45
|
},
|
46
46
|
"privacy": "public",
|
47
47
|
"default": "''",
|
48
|
-
"attribute": "label"
|
48
|
+
"attribute": "label",
|
49
|
+
"reflects": true
|
49
50
|
},
|
50
51
|
{
|
51
52
|
"kind": "field",
|
@@ -94,6 +95,24 @@
|
|
94
95
|
"privacy": "public",
|
95
96
|
"attribute": "static",
|
96
97
|
"reflects": true
|
98
|
+
},
|
99
|
+
{
|
100
|
+
"kind": "field",
|
101
|
+
"name": "slotEl",
|
102
|
+
"type": {
|
103
|
+
"text": "HTMLSlotElement"
|
104
|
+
},
|
105
|
+
"privacy": "private"
|
106
|
+
},
|
107
|
+
{
|
108
|
+
"kind": "method",
|
109
|
+
"name": "handleSlotchange",
|
110
|
+
"privacy": "protected",
|
111
|
+
"return": {
|
112
|
+
"type": {
|
113
|
+
"text": "void"
|
114
|
+
}
|
115
|
+
}
|
97
116
|
}
|
98
117
|
],
|
99
118
|
"attributes": [
|
@@ -149,6 +168,10 @@
|
|
149
168
|
{
|
150
169
|
"name": "SizedMixin",
|
151
170
|
"package": "@spectrum-web-components/base"
|
171
|
+
},
|
172
|
+
{
|
173
|
+
"name": "ObserveSlotText",
|
174
|
+
"package": "@spectrum-web-components/shared/src/observe-slot-text.js"
|
152
175
|
}
|
153
176
|
],
|
154
177
|
"superclass": {
|
@@ -165,7 +188,7 @@
|
|
165
188
|
"name": "ProgressBar",
|
166
189
|
"declaration": {
|
167
190
|
"name": "ProgressBar",
|
168
|
-
"module": "src/ProgressBar.
|
191
|
+
"module": "src/ProgressBar.js"
|
169
192
|
}
|
170
193
|
}
|
171
194
|
]
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@spectrum-web-components/progress-bar",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.35.0",
|
4
4
|
"publishConfig": {
|
5
5
|
"access": "public"
|
6
6
|
},
|
@@ -57,11 +57,11 @@
|
|
57
57
|
"lit-html"
|
58
58
|
],
|
59
59
|
"dependencies": {
|
60
|
-
"@spectrum-web-components/base": "^0.
|
61
|
-
"@spectrum-web-components/field-label": "^0.
|
60
|
+
"@spectrum-web-components/base": "^0.35.0",
|
61
|
+
"@spectrum-web-components/field-label": "^0.35.0"
|
62
62
|
},
|
63
63
|
"devDependencies": {
|
64
|
-
"@spectrum-css/progressbar": "^3.0.
|
64
|
+
"@spectrum-css/progressbar": "^3.0.54"
|
65
65
|
},
|
66
66
|
"types": "./src/index.d.ts",
|
67
67
|
"customElements": "custom-elements.json",
|
@@ -69,5 +69,5 @@
|
|
69
69
|
"./sp-*.js",
|
70
70
|
"./**/*.dev.js"
|
71
71
|
],
|
72
|
-
"gitHead": "
|
72
|
+
"gitHead": "1ee5a6c92838cdf48321276d97f61c20f8476ac1"
|
73
73
|
}
|
package/src/ProgressBar.d.ts
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
import { CSSResultArray, PropertyValues, SpectrumElement, TemplateResult } from '@spectrum-web-components/base';
|
2
2
|
import '@spectrum-web-components/field-label/sp-field-label.js';
|
3
3
|
declare const ProgressBar_base: typeof SpectrumElement & {
|
4
|
+
new (...args: any[]): import("@spectrum-web-components/shared/src/observe-slot-text.js").SlotTextObservingInterface;
|
5
|
+
prototype: import("@spectrum-web-components/shared/src/observe-slot-text.js").SlotTextObservingInterface;
|
6
|
+
} & {
|
4
7
|
new (...args: any[]): import("@spectrum-web-components/base").SizedElementInterface;
|
5
8
|
prototype: import("@spectrum-web-components/base").SizedElementInterface;
|
6
9
|
};
|
@@ -16,7 +19,9 @@ export declare class ProgressBar extends ProgressBar_base {
|
|
16
19
|
sideLabel: boolean;
|
17
20
|
progress: number;
|
18
21
|
static: 'white' | undefined;
|
22
|
+
private slotEl;
|
19
23
|
protected render(): TemplateResult;
|
24
|
+
protected handleSlotchange(): void;
|
20
25
|
protected firstUpdated(changes: PropertyValues): void;
|
21
26
|
protected updated(changes: PropertyValues): void;
|
22
27
|
}
|
package/src/ProgressBar.dev.js
CHANGED
@@ -15,11 +15,18 @@ import {
|
|
15
15
|
SizedMixin,
|
16
16
|
SpectrumElement
|
17
17
|
} from "@spectrum-web-components/base";
|
18
|
-
import {
|
18
|
+
import {
|
19
|
+
property,
|
20
|
+
query
|
21
|
+
} from "@spectrum-web-components/base/src/decorators.js";
|
22
|
+
import { getLabelFromSlot } from "@spectrum-web-components/shared/src/get-label-from-slot.js";
|
23
|
+
import { ObserveSlotText } from "@spectrum-web-components/shared/src/observe-slot-text.js";
|
19
24
|
import { LanguageResolutionController } from "@spectrum-web-components/reactive-controllers/src/LanguageResolution.js";
|
20
25
|
import "@spectrum-web-components/field-label/sp-field-label.js";
|
21
26
|
import styles from "./progress-bar.css.js";
|
22
|
-
export class ProgressBar extends SizedMixin(
|
27
|
+
export class ProgressBar extends SizedMixin(
|
28
|
+
ObserveSlotText(SpectrumElement, "")
|
29
|
+
) {
|
23
30
|
constructor() {
|
24
31
|
super(...arguments);
|
25
32
|
this.indeterminate = false;
|
@@ -34,10 +41,15 @@ export class ProgressBar extends SizedMixin(SpectrumElement) {
|
|
34
41
|
}
|
35
42
|
render() {
|
36
43
|
return html`
|
37
|
-
${this.label ? html`
|
44
|
+
${this.slotHasContent || this.label ? html`
|
38
45
|
<sp-field-label size=${this.size} class="label">
|
39
|
-
${this.label}
|
46
|
+
${this.slotHasContent ? html`` : this.label}
|
47
|
+
<slot @slotchange=${this.handleSlotchange}>
|
48
|
+
${this.label}
|
49
|
+
</slot>
|
40
50
|
</sp-field-label>
|
51
|
+
` : html``}
|
52
|
+
${this.label ? html`
|
41
53
|
${this.indeterminate ? html`` : html`
|
42
54
|
<sp-field-label
|
43
55
|
size=${this.size}
|
@@ -61,6 +73,12 @@ export class ProgressBar extends SizedMixin(SpectrumElement) {
|
|
61
73
|
</div>
|
62
74
|
`;
|
63
75
|
}
|
76
|
+
handleSlotchange() {
|
77
|
+
const labelFromSlot = getLabelFromSlot(this.label, this.slotEl);
|
78
|
+
if (labelFromSlot) {
|
79
|
+
this.label = labelFromSlot;
|
80
|
+
}
|
81
|
+
}
|
64
82
|
firstUpdated(changes) {
|
65
83
|
super.firstUpdated(changes);
|
66
84
|
if (!this.hasAttribute("role")) {
|
@@ -73,6 +91,7 @@ export class ProgressBar extends SizedMixin(SpectrumElement) {
|
|
73
91
|
if (this.indeterminate) {
|
74
92
|
this.removeAttribute("aria-valuemin");
|
75
93
|
this.removeAttribute("aria-valuemax");
|
94
|
+
this.removeAttribute("aria-valuenow");
|
76
95
|
} else {
|
77
96
|
this.setAttribute("aria-valuemin", "0");
|
78
97
|
this.setAttribute("aria-valuemax", "100");
|
@@ -80,22 +99,25 @@ export class ProgressBar extends SizedMixin(SpectrumElement) {
|
|
80
99
|
}
|
81
100
|
if (!this.indeterminate && changes.has("progress")) {
|
82
101
|
this.setAttribute("aria-valuenow", "" + this.progress);
|
83
|
-
} else if (this.hasAttribute("aria-valuenow")) {
|
84
|
-
this.removeAttribute("aria-valuenow");
|
85
102
|
}
|
86
|
-
if (
|
87
|
-
this.
|
103
|
+
if (changes.has("label")) {
|
104
|
+
if (this.label.length) {
|
105
|
+
this.setAttribute("aria-label", this.label);
|
106
|
+
} else {
|
107
|
+
this.removeAttribute("aria-label");
|
108
|
+
}
|
88
109
|
}
|
89
110
|
if (true) {
|
90
|
-
if (!this.label && !this.getAttribute("aria-label") && !this.getAttribute("aria-labelledby")) {
|
111
|
+
if (!this.label && !this.getAttribute("aria-label") && !this.getAttribute("aria-labelledby") && !this.slotHasContent) {
|
91
112
|
window.__swc.warn(
|
92
113
|
this,
|
93
|
-
"<sp-progress-bar> elements
|
114
|
+
"<sp-progress-bar> elements need one of the following to be accessible:",
|
94
115
|
"https://opensource.adobe.com/spectrum-web-components/components/progress-bar/#accessibility",
|
95
116
|
{
|
96
117
|
type: "accessibility",
|
97
118
|
issues: [
|
98
119
|
'value supplied to the "label" attribute, which will be displayed visually as part of the element, or',
|
120
|
+
"text content supplied directly to the <sp-progress-circle> element, or",
|
99
121
|
'value supplied to the "aria-label" attribute, which will only be provided to screen readers, or',
|
100
122
|
'an element ID reference supplied to the "aria-labelledby" attribute, which will be provided by screen readers and will need to be managed manually by the parent application.'
|
101
123
|
]
|
@@ -109,7 +131,7 @@ __decorateClass([
|
|
109
131
|
property({ type: Boolean, reflect: true })
|
110
132
|
], ProgressBar.prototype, "indeterminate", 2);
|
111
133
|
__decorateClass([
|
112
|
-
property({ type: String })
|
134
|
+
property({ type: String, reflect: true })
|
113
135
|
], ProgressBar.prototype, "label", 2);
|
114
136
|
__decorateClass([
|
115
137
|
property({ type: Boolean, reflect: true, attribute: "over-background" })
|
@@ -123,4 +145,7 @@ __decorateClass([
|
|
123
145
|
__decorateClass([
|
124
146
|
property({ type: String, reflect: true })
|
125
147
|
], ProgressBar.prototype, "static", 2);
|
148
|
+
__decorateClass([
|
149
|
+
query("slot")
|
150
|
+
], ProgressBar.prototype, "slotEl", 2);
|
126
151
|
//# sourceMappingURL=ProgressBar.dev.js.map
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["ProgressBar.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 PropertyValues,\n SizedMixin,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {
|
5
|
-
"mappings": ";;;;;;;;;;;;AAYA;AAAA,EAEI;AAAA,EAEA;AAAA,EACA;AAAA,OAEG;AACP,SAAS,
|
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 PropertyValues,\n SizedMixin,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n query,\n} from '@spectrum-web-components/base/src/decorators.js';\n\nimport { getLabelFromSlot } from '@spectrum-web-components/shared/src/get-label-from-slot.js';\nimport { ObserveSlotText } from '@spectrum-web-components/shared/src/observe-slot-text.js';\nimport { LanguageResolutionController } from '@spectrum-web-components/reactive-controllers/src/LanguageResolution.js';\nimport '@spectrum-web-components/field-label/sp-field-label.js';\nimport styles from './progress-bar.css.js';\n\n/**\n * @element sp-progress-bar\n */\nexport class ProgressBar extends SizedMixin(\n ObserveSlotText(SpectrumElement, '')\n) {\n public static override get styles(): CSSResultArray {\n return [styles];\n }\n\n @property({ type: Boolean, reflect: true })\n public indeterminate = false;\n\n @property({ type: String, reflect: true })\n public label = '';\n\n private languageResolver = new LanguageResolutionController(this);\n\n @property({ type: Boolean, reflect: true, attribute: 'over-background' })\n public overBackground = false;\n\n @property({ type: Boolean, reflect: true, attribute: 'side-label' })\n public sideLabel = false;\n\n @property({ type: Number })\n public progress = 0;\n\n @property({ type: String, reflect: true })\n public static: 'white' | undefined;\n\n @query('slot')\n private slotEl!: HTMLSlotElement;\n\n protected override render(): TemplateResult {\n return html`\n ${this.slotHasContent || this.label\n ? html`\n <sp-field-label size=${this.size} class=\"label\">\n ${this.slotHasContent ? html`` : this.label}\n <slot @slotchange=${this.handleSlotchange}>\n ${this.label}\n </slot>\n </sp-field-label>\n `\n : html``}\n ${this.label\n ? html`\n ${this.indeterminate\n ? html``\n : html`\n <sp-field-label\n size=${this.size}\n class=\"percentage\"\n >\n ${new Intl.NumberFormat(\n this.languageResolver.language,\n {\n style: 'percent',\n unitDisplay: 'narrow',\n }\n ).format(this.progress / 100)}\n </sp-field-label>\n `}\n `\n : html``}\n <div class=\"track\">\n <div\n class=\"fill\"\n style=\"transform: scaleX(calc(${this.progress} / 100));\"\n ></div>\n </div>\n `;\n }\n\n protected handleSlotchange(): void {\n const labelFromSlot = getLabelFromSlot(this.label, this.slotEl);\n if (labelFromSlot) {\n this.label = labelFromSlot;\n }\n }\n\n protected override firstUpdated(changes: PropertyValues): void {\n super.firstUpdated(changes);\n if (!this.hasAttribute('role')) {\n this.setAttribute('role', 'progressbar');\n }\n }\n\n protected override updated(changes: PropertyValues): void {\n super.updated(changes);\n if (changes.has('indeterminate')) {\n if (this.indeterminate) {\n this.removeAttribute('aria-valuemin');\n this.removeAttribute('aria-valuemax');\n this.removeAttribute('aria-valuenow');\n } else {\n this.setAttribute('aria-valuemin', '0');\n this.setAttribute('aria-valuemax', '100');\n }\n }\n if (!this.indeterminate && changes.has('progress')) {\n this.setAttribute('aria-valuenow', '' + this.progress);\n }\n if (changes.has('label')) {\n if (this.label.length) {\n this.setAttribute('aria-label', this.label);\n } else {\n this.removeAttribute('aria-label');\n }\n }\n\n if (window.__swc.DEBUG) {\n if (\n !this.label &&\n !this.getAttribute('aria-label') &&\n !this.getAttribute('aria-labelledby') &&\n !this.slotHasContent\n ) {\n window.__swc.warn(\n this,\n '<sp-progress-bar> elements need one of the following to be accessible:',\n 'https://opensource.adobe.com/spectrum-web-components/components/progress-bar/#accessibility',\n {\n type: 'accessibility',\n issues: [\n 'value supplied to the \"label\" attribute, which will be displayed visually as part of the element, or',\n 'text content supplied directly to the <sp-progress-circle> element, or',\n 'value supplied to the \"aria-label\" attribute, which will only be provided to screen readers, or',\n 'an element ID reference supplied to the \"aria-labelledby\" attribute, which will be provided by screen readers and will need to be managed manually by the parent application.',\n ],\n }\n );\n }\n }\n }\n}\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;AAYA;AAAA,EAEI;AAAA,EAEA;AAAA,EACA;AAAA,OAEG;AACP;AAAA,EACI;AAAA,EACA;AAAA,OACG;AAEP,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAChC,SAAS,oCAAoC;AAC7C,OAAO;AACP,OAAO,YAAY;AAKZ,aAAM,oBAAoB;AAAA,EAC7B,gBAAgB,iBAAiB,EAAE;AACvC,EAAE;AAAA,EAFK;AAAA;AAQH,SAAO,gBAAgB;AAGvB,SAAO,QAAQ;AAEf,SAAQ,mBAAmB,IAAI,6BAA6B,IAAI;AAGhE,SAAO,iBAAiB;AAGxB,SAAO,YAAY;AAGnB,SAAO,WAAW;AAAA;AAAA,EAnBlB,WAA2B,SAAyB;AAChD,WAAO,CAAC,MAAM;AAAA,EAClB;AAAA,EAyBmB,SAAyB;AACxC,WAAO;AAAA,cACD,K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UAAI,KAAK,MAAM,QAAQ;AACnB,aAAK,aAAa,cAAc,KAAK,KAAK;AAAA,MAC9C,OAAO;AACH,aAAK,gBAAgB,YAAY;AAAA,MACrC;AAAA,IACJ;AAEA,QAAI,MAAoB;AACpB,UACI,CAAC,KAAK,SACN,CAAC,KAAK,aAAa,YAAY,KAC/B,CAAC,KAAK,aAAa,iBAAiB,KACpC,CAAC,KAAK,gBACR;AACE,eAAO,MAAM;AAAA,UACT;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,YACI,MAAM;AAAA,YACN,QAAQ;AAAA,cACJ;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,YACJ;AAAA,UACJ;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AACJ;AA5HW;AAAA,EADN,SAAS,EAAE,MAAM,SAAS,SAAS,KAAK,CAAC;AAAA,GAPjC,YAQF;AAGA;AAAA,EADN,SAAS,EAAE,MAAM,QAAQ,SAAS,KAAK,CAAC;AAAA,GAVhC,YAWF;AAKA;AAAA,EADN,SAAS,EAAE,MAAM,SAAS,SAAS,MAAM,WAAW,kBAAkB,CAAC;AAAA,GAf/D,YAgBF;AAGA;AAAA,EADN,SAAS,EAAE,MAAM,SAAS,SAAS,MAAM,WAAW,aAAa,CAAC;AAAA,GAlB1D,YAmBF;AAGA;AAAA,EADN,SAAS,EAAE,MAAM,OAAO,CAAC;AAAA,GArBjB,YAsBF;AAGA;AAAA,EADN,SAAS,EAAE,MAAM,QAAQ,SAAS,KAAK,CAAC;AAAA,GAxBhC,YAyBF;AAGC;AAAA,EADP,MAAM,MAAM;AAAA,GA3BJ,YA4BD;",
|
6
6
|
"names": []
|
7
7
|
}
|
package/src/ProgressBar.js
CHANGED
@@ -1,9 +1,14 @@
|
|
1
|
-
"use strict";var
|
2
|
-
${this.label?
|
1
|
+
"use strict";var b=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var t=(o,s,e,a)=>{for(var i=a>1?void 0:a?u(s,e):s,n=o.length-1,p;n>=0;n--)(p=o[n])&&(i=(a?p(s,e,i):p(i))||i);return a&&i&&b(s,e,i),i};import{html as l,SizedMixin as d,SpectrumElement as h}from"@spectrum-web-components/base";import{property as r,query as c}from"@spectrum-web-components/base/src/decorators.js";import{getLabelFromSlot as m}from"@spectrum-web-components/shared/src/get-label-from-slot.js";import{ObserveSlotText as f}from"@spectrum-web-components/shared/src/observe-slot-text.js";import{LanguageResolutionController as v}from"@spectrum-web-components/reactive-controllers/src/LanguageResolution.js";import"@spectrum-web-components/field-label/sp-field-label.js";import y from"./progress-bar.css.js";export class ProgressBar extends d(f(h,"")){constructor(){super(...arguments);this.indeterminate=!1;this.label="";this.languageResolver=new v(this);this.overBackground=!1;this.sideLabel=!1;this.progress=0}static get styles(){return[y]}render(){return l`
|
2
|
+
${this.slotHasContent||this.label?l`
|
3
3
|
<sp-field-label size=${this.size} class="label">
|
4
|
-
${this.label}
|
4
|
+
${this.slotHasContent?l``:this.label}
|
5
|
+
<slot @slotchange=${this.handleSlotchange}>
|
6
|
+
${this.label}
|
7
|
+
</slot>
|
5
8
|
</sp-field-label>
|
6
|
-
|
9
|
+
`:l``}
|
10
|
+
${this.label?l`
|
11
|
+
${this.indeterminate?l``:l`
|
7
12
|
<sp-field-label
|
8
13
|
size=${this.size}
|
9
14
|
class="percentage"
|
@@ -11,12 +16,12 @@
|
|
11
16
|
${new Intl.NumberFormat(this.languageResolver.language,{style:"percent",unitDisplay:"narrow"}).format(this.progress/100)}
|
12
17
|
</sp-field-label>
|
13
18
|
`}
|
14
|
-
`:
|
19
|
+
`:l``}
|
15
20
|
<div class="track">
|
16
21
|
<div
|
17
22
|
class="fill"
|
18
23
|
style="transform: scaleX(calc(${this.progress} / 100));"
|
19
24
|
></div>
|
20
25
|
</div>
|
21
|
-
`}firstUpdated(e){super.firstUpdated(e),this.hasAttribute("role")||this.setAttribute("role","progressbar")}updated(e){super.updated(e),e.has("indeterminate")&&(this.indeterminate?(this.removeAttribute("aria-valuemin"),this.removeAttribute("aria-valuemax")):(this.setAttribute("aria-valuemin","0"),this.setAttribute("aria-valuemax","100"))),!this.indeterminate&&e.has("progress")
|
26
|
+
`}handleSlotchange(){const e=m(this.label,this.slotEl);e&&(this.label=e)}firstUpdated(e){super.firstUpdated(e),this.hasAttribute("role")||this.setAttribute("role","progressbar")}updated(e){super.updated(e),e.has("indeterminate")&&(this.indeterminate?(this.removeAttribute("aria-valuemin"),this.removeAttribute("aria-valuemax"),this.removeAttribute("aria-valuenow")):(this.setAttribute("aria-valuemin","0"),this.setAttribute("aria-valuemax","100"))),!this.indeterminate&&e.has("progress")&&this.setAttribute("aria-valuenow",""+this.progress),e.has("label")&&(this.label.length?this.setAttribute("aria-label",this.label):this.removeAttribute("aria-label"))}}t([r({type:Boolean,reflect:!0})],ProgressBar.prototype,"indeterminate",2),t([r({type:String,reflect:!0})],ProgressBar.prototype,"label",2),t([r({type:Boolean,reflect:!0,attribute:"over-background"})],ProgressBar.prototype,"overBackground",2),t([r({type:Boolean,reflect:!0,attribute:"side-label"})],ProgressBar.prototype,"sideLabel",2),t([r({type:Number})],ProgressBar.prototype,"progress",2),t([r({type:String,reflect:!0})],ProgressBar.prototype,"static",2),t([c("slot")],ProgressBar.prototype,"slotEl",2);
|
22
27
|
//# sourceMappingURL=ProgressBar.js.map
|
package/src/ProgressBar.js.map
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["ProgressBar.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 PropertyValues,\n SizedMixin,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {
|
5
|
-
"mappings": "qNAYA,OAEI,QAAAA,EAEA,cAAAC,EACA,mBAAAC,MAEG,gCACP,
|
6
|
-
"names": ["html", "SizedMixin", "SpectrumElement", "property", "LanguageResolutionController", "styles", "changes", "__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 PropertyValues,\n SizedMixin,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n query,\n} from '@spectrum-web-components/base/src/decorators.js';\n\nimport { getLabelFromSlot } from '@spectrum-web-components/shared/src/get-label-from-slot.js';\nimport { ObserveSlotText } from '@spectrum-web-components/shared/src/observe-slot-text.js';\nimport { LanguageResolutionController } from '@spectrum-web-components/reactive-controllers/src/LanguageResolution.js';\nimport '@spectrum-web-components/field-label/sp-field-label.js';\nimport styles from './progress-bar.css.js';\n\n/**\n * @element sp-progress-bar\n */\nexport class ProgressBar extends SizedMixin(\n ObserveSlotText(SpectrumElement, '')\n) {\n public static override get styles(): CSSResultArray {\n return [styles];\n }\n\n @property({ type: Boolean, reflect: true })\n public indeterminate = false;\n\n @property({ type: String, reflect: true })\n public label = '';\n\n private languageResolver = new LanguageResolutionController(this);\n\n @property({ type: Boolean, reflect: true, attribute: 'over-background' })\n public overBackground = false;\n\n @property({ type: Boolean, reflect: true, attribute: 'side-label' })\n public sideLabel = false;\n\n @property({ type: Number })\n public progress = 0;\n\n @property({ type: String, reflect: true })\n public static: 'white' | undefined;\n\n @query('slot')\n private slotEl!: HTMLSlotElement;\n\n protected override render(): TemplateResult {\n return html`\n ${this.slotHasContent || this.label\n ? html`\n <sp-field-label size=${this.size} class=\"label\">\n ${this.slotHasContent ? html`` : this.label}\n <slot @slotchange=${this.handleSlotchange}>\n ${this.label}\n </slot>\n </sp-field-label>\n `\n : html``}\n ${this.label\n ? html`\n ${this.indeterminate\n ? html``\n : html`\n <sp-field-label\n size=${this.size}\n class=\"percentage\"\n >\n ${new Intl.NumberFormat(\n this.languageResolver.language,\n {\n style: 'percent',\n unitDisplay: 'narrow',\n }\n ).format(this.progress / 100)}\n </sp-field-label>\n `}\n `\n : html``}\n <div class=\"track\">\n <div\n class=\"fill\"\n style=\"transform: scaleX(calc(${this.progress} / 100));\"\n ></div>\n </div>\n `;\n }\n\n protected handleSlotchange(): void {\n const labelFromSlot = getLabelFromSlot(this.label, this.slotEl);\n if (labelFromSlot) {\n this.label = labelFromSlot;\n }\n }\n\n protected override firstUpdated(changes: PropertyValues): void {\n super.firstUpdated(changes);\n if (!this.hasAttribute('role')) {\n this.setAttribute('role', 'progressbar');\n }\n }\n\n protected override updated(changes: PropertyValues): void {\n super.updated(changes);\n if (changes.has('indeterminate')) {\n if (this.indeterminate) {\n this.removeAttribute('aria-valuemin');\n this.removeAttribute('aria-valuemax');\n this.removeAttribute('aria-valuenow');\n } else {\n this.setAttribute('aria-valuemin', '0');\n this.setAttribute('aria-valuemax', '100');\n }\n }\n if (!this.indeterminate && changes.has('progress')) {\n this.setAttribute('aria-valuenow', '' + this.progress);\n }\n if (changes.has('label')) {\n if (this.label.length) {\n this.setAttribute('aria-label', this.label);\n } else {\n this.removeAttribute('aria-label');\n }\n }\n\n if (window.__swc.DEBUG) {\n if (\n !this.label &&\n !this.getAttribute('aria-label') &&\n !this.getAttribute('aria-labelledby') &&\n !this.slotHasContent\n ) {\n window.__swc.warn(\n this,\n '<sp-progress-bar> elements need one of the following to be accessible:',\n 'https://opensource.adobe.com/spectrum-web-components/components/progress-bar/#accessibility',\n {\n type: 'accessibility',\n issues: [\n 'value supplied to the \"label\" attribute, which will be displayed visually as part of the element, or',\n 'text content supplied directly to the <sp-progress-circle> element, or',\n 'value supplied to the \"aria-label\" attribute, which will only be provided to screen readers, or',\n 'an element ID reference supplied to the \"aria-labelledby\" attribute, which will be provided by screen readers and will need to be managed manually by the parent application.',\n ],\n }\n );\n }\n }\n }\n}\n"],
|
5
|
+
"mappings": "qNAYA,OAEI,QAAAA,EAEA,cAAAC,EACA,mBAAAC,MAEG,gCACP,OACI,YAAAC,EACA,SAAAC,MACG,kDAEP,OAAS,oBAAAC,MAAwB,6DACjC,OAAS,mBAAAC,MAAuB,2DAChC,OAAS,gCAAAC,MAAoC,0EAC7C,MAAO,yDACP,OAAOC,MAAY,wBAKZ,aAAM,oBAAoBP,EAC7BK,EAAgBJ,EAAiB,EAAE,CACvC,CAAE,CAFK,kCAQH,KAAO,cAAgB,GAGvB,KAAO,MAAQ,GAEf,KAAQ,iBAAmB,IAAIK,EAA6B,IAAI,EAGhE,KAAO,eAAiB,GAGxB,KAAO,UAAY,GAGnB,KAAO,SAAW,EAnBlB,WAA2B,QAAyB,CAChD,MAAO,CAACC,CAAM,CAClB,CAyBmB,QAAyB,CACxC,OAAOR;AAAA,cACD,KAAK,gBAAkB,KAAK,MACxBA;AAAA,6CAC2B,KAAK;AAAA,4BACtB,KAAK,eAAiBA,IAAS,KAAK;AAAA,8CAClB,KAAK;AAAA,gCACnB,KAAK;AAAA;AAAA;AAAA,oBAInBA;AAAA,cACJ,KAAK,MACDA;AAAA,wBACM,KAAK,cACDA,IACAA;AAAA;AAAA,2CAEe,KAAK;AAAA;AAAA;AAAA,sCAGV,IAAI,KAAK,aACP,KAAK,iBAAiB,SACtB,CACI,MAAO,UACP,YAAa,QACjB,CACJ,EAAE,OAAO,KAAK,SAAW,GAAG;AAAA;AAAA;AAAA,oBAI9CA;AAAA;AAAA;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J,YA4BD",
|
6
|
+
"names": ["html", "SizedMixin", "SpectrumElement", "property", "query", "getLabelFromSlot", "ObserveSlotText", "LanguageResolutionController", "styles", "labelFromSlot", "changes", "__decorateClass"]
|
7
7
|
}
|
@@ -22,6 +22,15 @@ describe("ProgressBar", () => {
|
|
22
22
|
expect(el).to.not.be.undefined;
|
23
23
|
await expect(el).to.be.accessible();
|
24
24
|
});
|
25
|
+
it("accepts label from `slot`", async () => {
|
26
|
+
const el = await fixture(html`
|
27
|
+
<sp-progress-bar role="progressbar">
|
28
|
+
Label From Slot
|
29
|
+
</sp-progress-bar>
|
30
|
+
`);
|
31
|
+
await elementUpdated(el);
|
32
|
+
expect(el.getAttribute("label")).to.equal("Label From Slot");
|
33
|
+
});
|
25
34
|
it("accepts a changing progress", async () => {
|
26
35
|
const el = await fixture(html`
|
27
36
|
<sp-progress-bar label="Changing value"></sp-progress-bar>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["progress-bar.test.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 { elementUpdated, expect, fixture, html } from '@open-wc/testing';\n\nimport '@spectrum-web-components/progress-bar/sp-progress-bar.js';\nimport { ProgressBar } from '@spectrum-web-components/progress-bar';\nimport { stub } from 'sinon';\nimport { testForLitDevWarnings } from '../../../test/testing-helpers.js';\nimport { createLanguageContext } from '../../../tools/reactive-controllers/test/helpers.js';\n\ndescribe('ProgressBar', () => {\n testForLitDevWarnings(\n async () =>\n await fixture<ProgressBar>(\n html`\n <sp-progress-bar label=\"Loading\"></sp-progress-bar>\n `\n )\n );\n it('loads default progress-bar accessibly', async () => {\n const el = await fixture<ProgressBar>(\n html`\n <sp-progress-bar label=\"Loading\"></sp-progress-bar>\n `\n );\n\n await elementUpdated(el);\n expect(el).to.not.be.undefined;\n\n await expect(el).to.be.accessible();\n });\n\n it('accepts a changing progress', async () => {\n const el = await fixture<ProgressBar>(html`\n <sp-progress-bar label=\"Changing value\"></sp-progress-bar>\n `);\n\n await elementUpdated(el);\n\n expect(el.hasAttribute('aria-valuenow')).to.be.true;\n expect(el.getAttribute('aria-valuenow')).to.equal('0');\n\n el.progress = 50;\n\n await elementUpdated(el);\n\n expect(el.hasAttribute('aria-valuenow')).to.be.true;\n expect(el.getAttribute('aria-valuenow')).to.equal('50');\n\n el.progress = 100;\n\n await elementUpdated(el);\n\n expect(el.hasAttribute('aria-valuenow')).to.be.true;\n expect(el.getAttribute('aria-valuenow')).to.equal('100');\n });\n it('loads - [indeterminate]', async () => {\n const el = await fixture<ProgressBar>(html`\n <sp-progress-bar indeterminate label=\"Loading\"></sp-progress-bar>\n `);\n\n await elementUpdated(el);\n expect(el).to.not.be.undefined;\n\n await expect(el).to.be.accessible();\n });\n it('accepts user `role`', async () => {\n const el = await fixture<ProgressBar>(html`\n <sp-progress-bar\n role=\"progressbar\"\n label=\"With user role\"\n ></sp-progress-bar>\n `);\n\n await elementUpdated(el);\n\n expect(el.getAttribute('role')).to.equal('progressbar');\n });\n it('returns to indeterminate', async () => {\n const el = await fixture<ProgressBar>(html`\n <sp-progress-bar\n progress=\"50\"\n label=\"Sometimes indeterminate\"\n ></sp-progress-bar>\n `);\n\n await elementUpdated(el);\n\n expect(el.hasAttribute('aria-valuenow')).to.be.true;\n expect(el.getAttribute('aria-valuenow')).to.equal('50');\n\n el.indeterminate = true;\n\n await elementUpdated(el);\n\n expect(el.hasAttribute('aria-valuenow')).to.be.false;\n });\n it('warns in Dev Mode when accessible attributes are not leveraged', async () => {\n const consoleWarnStub = stub(console, 'warn');\n const el = await fixture<ProgressBar>(html`\n <sp-progress-bar progress=\"50\"></sp-progress-bar>\n `);\n\n await elementUpdated(el);\n\n expect(consoleWarnStub.called).to.be.true;\n const spyCall = consoleWarnStub.getCall(0);\n expect(\n spyCall.args.at(0).includes('accessible'),\n 'confirm accessibility-centric message'\n ).to.be.true;\n expect(spyCall.args.at(-1), 'confirm `data` shape').to.deep.equal({\n data: {\n localName: 'sp-progress-bar',\n type: 'accessibility',\n level: 'default',\n },\n });\n consoleWarnStub.restore();\n });\n\n it('resolves a language (en-US)', async () => {\n const [languageContext] = createLanguageContext('en-US');\n const test = await fixture(html`\n <div @sp-language-context=${languageContext}>\n <sp-progress-bar\n label=\"Changing Value\"\n progress=\"45\"\n ></sp-progress-bar>\n </div>\n `);\n const el = test.querySelector('sp-progress-bar') as ProgressBar;\n const percentage = el.shadowRoot.querySelector(\n '.percentage'\n ) as HTMLElement;\n expect(percentage.textContent?.search('%')).to.not.equal(-1);\n });\n\n it('resolves a language (ar-sa)', async () => {\n const [languageContext] = createLanguageContext('ar-sa');\n const test = await fixture(html`\n <div @sp-language-context=${languageContext}>\n <sp-progress-bar\n label=\"Changing Value\"\n progress=\"45\"\n ></sp-progress-bar>\n </div>\n `);\n const el = test.querySelector('sp-progress-bar') as ProgressBar;\n const percentage = el.shadowRoot.querySelector(\n '.percentage'\n ) as HTMLElement;\n expect(percentage.textContent?.search('\u066A')).to.not.equal(-1);\n });\n});\n"],
|
5
|
-
"mappings": ";AAYA,SAAS,gBAAgB,QAAQ,SAAS,YAAY;AAEtD,OAAO;AAEP,SAAS,YAAY;AACrB,SAAS,6BAA6B;AACtC,SAAS,6BAA6B;AAEtC,SAAS,eAAe,MAAM;AAC1B;AAAA,IACI,YACI,MAAM;AAAA,MACF;AAAA;AAAA;AAAA,IAGJ;AAAA,EACR;AACA,KAAG,yCAAyC,YAAY;AACpD,UAAM,KAAK,MAAM;AAAA,MACb;AAAA;AAAA;AAAA,IAGJ;AAE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,CAAC,EAAE,GAAG,GAAG;AAC/C,WAAO,GAAG,aAAa,eAAe,CAAC,EAAE,GAAG,MAAM,IAAI;AAEtD,OAAG,gBAAgB;AAEnB,UAAM,eAAe,EAAE;AAEvB,WAAO,GAAG,aAAa,eAAe,CAAC,EAAE,GAAG,GAAG;AAAA,EACnD,CAAC;AACD,KAAG,kEAAkE,YAAY;AAC7E,UAAM,kBAAkB,KAAK,SAAS,MAAM;AAC5C,UAAM,KAAK,MAAM,QAAqB;AAAA;AAAA,SAErC;AAED,UAAM,eAAe,EAAE;AAEvB,WAAO,gBAAgB,MAAM,EAAE,GAAG,GAAG;AACrC,UAAM,UAAU,gBAAgB,QAAQ,CAAC;AACzC;AAAA,MACI,QAAQ,KAAK,GAAG,CAAC,EAAE,SAAS,YAAY;AAAA,MACxC;AAAA,IACJ,EAAE,GAAG,GAAG;AACR,WAAO,QAAQ,KAAK,GAAG,EAAE,GAAG,sBAAsB,EAAE,GAAG,KAAK,MAAM;AAAA,MAC9D,MAAM;AAAA,QACF,WAAW;AAAA,QACX,MAAM;AAAA,QACN,OAAO;AAAA,MACX;AAAA,IACJ,CAAC;AACD,oBAAgB,QAAQ;AAAA,EAC5B,CAAC;AAED,KAAG,+BAA+B,YAAY;
|
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 { elementUpdated, expect, fixture, html } from '@open-wc/testing';\n\nimport '@spectrum-web-components/progress-bar/sp-progress-bar.js';\nimport { ProgressBar } from '@spectrum-web-components/progress-bar';\nimport { stub } from 'sinon';\nimport { testForLitDevWarnings } from '../../../test/testing-helpers.js';\nimport { createLanguageContext } from '../../../tools/reactive-controllers/test/helpers.js';\n\ndescribe('ProgressBar', () => {\n testForLitDevWarnings(\n async () =>\n await fixture<ProgressBar>(\n html`\n <sp-progress-bar label=\"Loading\"></sp-progress-bar>\n `\n )\n );\n it('loads default progress-bar accessibly', async () => {\n const el = await fixture<ProgressBar>(\n html`\n <sp-progress-bar label=\"Loading\"></sp-progress-bar>\n `\n );\n\n await elementUpdated(el);\n expect(el).to.not.be.undefined;\n\n await expect(el).to.be.accessible();\n });\n\n it('accepts label from `slot`', async () => {\n const el = await fixture<ProgressBar>(html`\n <sp-progress-bar role=\"progressbar\">\n Label From Slot\n </sp-progress-bar>\n `);\n\n await elementUpdated(el);\n\n expect(el.getAttribute('label')).to.equal('Label From Slot');\n });\n it('accepts a changing progress', async () => {\n const el = await fixture<ProgressBar>(html`\n <sp-progress-bar label=\"Changing value\"></sp-progress-bar>\n `);\n\n await elementUpdated(el);\n\n expect(el.hasAttribute('aria-valuenow')).to.be.true;\n expect(el.getAttribute('aria-valuenow')).to.equal('0');\n\n el.progress = 50;\n\n await elementUpdated(el);\n\n expect(el.hasAttribute('aria-valuenow')).to.be.true;\n expect(el.getAttribute('aria-valuenow')).to.equal('50');\n\n el.progress = 100;\n\n await elementUpdated(el);\n\n expect(el.hasAttribute('aria-valuenow')).to.be.true;\n expect(el.getAttribute('aria-valuenow')).to.equal('100');\n });\n it('loads - [indeterminate]', async () => {\n const el = await fixture<ProgressBar>(html`\n <sp-progress-bar indeterminate label=\"Loading\"></sp-progress-bar>\n `);\n\n await elementUpdated(el);\n expect(el).to.not.be.undefined;\n\n await expect(el).to.be.accessible();\n });\n it('accepts user `role`', async () => {\n const el = await fixture<ProgressBar>(html`\n <sp-progress-bar\n role=\"progressbar\"\n label=\"With user role\"\n ></sp-progress-bar>\n `);\n\n await elementUpdated(el);\n\n expect(el.getAttribute('role')).to.equal('progressbar');\n });\n it('returns to indeterminate', async () => {\n const el = await fixture<ProgressBar>(html`\n <sp-progress-bar\n progress=\"50\"\n label=\"Sometimes indeterminate\"\n ></sp-progress-bar>\n `);\n\n await elementUpdated(el);\n\n expect(el.hasAttribute('aria-valuenow')).to.be.true;\n expect(el.getAttribute('aria-valuenow')).to.equal('50');\n\n el.indeterminate = true;\n\n await elementUpdated(el);\n\n expect(el.hasAttribute('aria-valuenow')).to.be.false;\n });\n it('warns in Dev Mode when accessible attributes are not leveraged', async () => {\n const consoleWarnStub = stub(console, 'warn');\n const el = await fixture<ProgressBar>(html`\n <sp-progress-bar progress=\"50\"></sp-progress-bar>\n `);\n\n await elementUpdated(el);\n\n expect(consoleWarnStub.called).to.be.true;\n const spyCall = consoleWarnStub.getCall(0);\n expect(\n spyCall.args.at(0).includes('accessible'),\n 'confirm accessibility-centric message'\n ).to.be.true;\n expect(spyCall.args.at(-1), 'confirm `data` shape').to.deep.equal({\n data: {\n localName: 'sp-progress-bar',\n type: 'accessibility',\n level: 'default',\n },\n });\n consoleWarnStub.restore();\n });\n\n it('resolves a language (en-US)', async () => {\n const [languageContext] = createLanguageContext('en-US');\n const test = await fixture(html`\n <div @sp-language-context=${languageContext}>\n <sp-progress-bar\n label=\"Changing Value\"\n progress=\"45\"\n ></sp-progress-bar>\n </div>\n `);\n const el = test.querySelector('sp-progress-bar') as ProgressBar;\n const percentage = el.shadowRoot.querySelector(\n '.percentage'\n ) as HTMLElement;\n expect(percentage.textContent?.search('%')).to.not.equal(-1);\n });\n\n it('resolves a language (ar-sa)', async () => {\n const [languageContext] = createLanguageContext('ar-sa');\n const test = await fixture(html`\n <div @sp-language-context=${languageContext}>\n <sp-progress-bar\n label=\"Changing Value\"\n progress=\"45\"\n ></sp-progress-bar>\n </div>\n `);\n const el = test.querySelector('sp-progress-bar') as ProgressBar;\n const percentage = el.shadowRoot.querySelector(\n '.percentage'\n ) as HTMLElement;\n expect(percentage.textContent?.search('\u066A')).to.not.equal(-1);\n });\n});\n"],
|
5
|
+
"mappings": ";AAYA,SAAS,gBAAg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