@brightspace-ui/core 3.181.0 → 3.183.0
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.
|
@@ -18,7 +18,37 @@ A progress bar communicates information relating to the progress of completion o
|
|
|
18
18
|
|---|---|---|
|
|
19
19
|
| `max` | Number | The maximum value of the progress bar |
|
|
20
20
|
| `value` | Number | The current value of the progress bar |
|
|
21
|
-
| `label` | String | Label for the progress bar |
|
|
21
|
+
| `label` | String, required | Label for the progress bar |
|
|
22
22
|
| `label-hidden` | Boolean | Hide the bar's label |
|
|
23
|
+
| `announce-label` | Boolean | Announce the label when it changes |
|
|
23
24
|
| `value-hidden` | Boolean | Hide the bar's value |
|
|
24
25
|
<!-- docs: end hidden content -->
|
|
26
|
+
|
|
27
|
+
### Announce Label
|
|
28
|
+
|
|
29
|
+
Use the `announce-label` property to announce changes to the progress label. This can be helpful to announce steps or completion to users.
|
|
30
|
+
|
|
31
|
+
<!-- docs: demo code -->
|
|
32
|
+
```html
|
|
33
|
+
<script type="module">
|
|
34
|
+
import '@brightspace-ui/core/components/progress/progress.js';
|
|
35
|
+
</script>
|
|
36
|
+
<script>
|
|
37
|
+
const button = document.querySelector('button');
|
|
38
|
+
const progress = document.querySelector('d2l-progress');
|
|
39
|
+
button.addEventListener('click', () => {
|
|
40
|
+
for (let i = 0; i < 5; i++) {
|
|
41
|
+
setTimeout(() => {
|
|
42
|
+
if (i === 4) progress.label = 'Complete';
|
|
43
|
+
else if (i >= 2) progress.label = 'Validating...';
|
|
44
|
+
else progress.label = 'Uploading...';
|
|
45
|
+
progress.value = i * 25;
|
|
46
|
+
}, i * 1000);
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
<button>Start Animation</button>
|
|
53
|
+
<d2l-progress label="Uploading..." announce-label></d2l-progress>
|
|
54
|
+
```
|
|
@@ -69,14 +69,19 @@
|
|
|
69
69
|
<d2l-demo-snippet>
|
|
70
70
|
<template>
|
|
71
71
|
<button>Start Animation</button>
|
|
72
|
-
<d2l-progress label="
|
|
72
|
+
<d2l-progress label="Uploading..." announce-label></d2l-progress>
|
|
73
73
|
<script data-demo-hide>
|
|
74
74
|
(demo => {
|
|
75
75
|
const button = demo.querySelector('button');
|
|
76
76
|
const progress = demo.querySelector('d2l-progress');
|
|
77
77
|
button.addEventListener('click', () => {
|
|
78
78
|
for (let i = 0; i < 5; i++) {
|
|
79
|
-
setTimeout(() =>
|
|
79
|
+
setTimeout(() => {
|
|
80
|
+
if (i === 4) progress.label = 'Complete';
|
|
81
|
+
else if (i >= 2) progress.label = 'Validating...';
|
|
82
|
+
else progress.label = 'Uploading...';
|
|
83
|
+
progress.value = i * 25;
|
|
84
|
+
}, i * 1000);
|
|
80
85
|
|
|
81
86
|
}
|
|
82
87
|
});
|
|
@@ -21,7 +21,7 @@ class Progress extends LocalizeCoreElement(LitElement) {
|
|
|
21
21
|
*/
|
|
22
22
|
value: { type: Number },
|
|
23
23
|
/**
|
|
24
|
-
* Label for the progress bar
|
|
24
|
+
* REQUIRED: Label for the progress bar
|
|
25
25
|
* @type {string}
|
|
26
26
|
*/
|
|
27
27
|
label: { type: String },
|
|
@@ -30,6 +30,11 @@ class Progress extends LocalizeCoreElement(LitElement) {
|
|
|
30
30
|
* @type {boolean}
|
|
31
31
|
*/
|
|
32
32
|
labelHidden: { type: Boolean, attribute: 'label-hidden' },
|
|
33
|
+
/**
|
|
34
|
+
* Announce the label when it changes
|
|
35
|
+
* @type {boolean}
|
|
36
|
+
*/
|
|
37
|
+
announceLabel: { type: Boolean, attribute: 'announce-label' },
|
|
33
38
|
/**
|
|
34
39
|
* Hide the bar's value
|
|
35
40
|
* @type {boolean}
|
|
@@ -39,7 +44,7 @@ class Progress extends LocalizeCoreElement(LitElement) {
|
|
|
39
44
|
* The size of the progress bar
|
|
40
45
|
* @type {'small'|'medium'|'large'}
|
|
41
46
|
*/
|
|
42
|
-
size: { type: String, reflect: true }
|
|
47
|
+
size: { type: String, reflect: true }
|
|
43
48
|
};
|
|
44
49
|
}
|
|
45
50
|
|
|
@@ -136,16 +141,21 @@ class Progress extends LocalizeCoreElement(LitElement) {
|
|
|
136
141
|
|
|
137
142
|
constructor() {
|
|
138
143
|
super();
|
|
144
|
+
this.announceLabel = false;
|
|
139
145
|
this.labelHidden = false;
|
|
140
146
|
this.max = 100;
|
|
147
|
+
this.size = 'medium';
|
|
141
148
|
this.value = 0;
|
|
142
149
|
this.valueHidden = false;
|
|
143
|
-
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
get isComplete() {
|
|
153
|
+
return this.value >= this.max;
|
|
144
154
|
}
|
|
145
155
|
|
|
146
156
|
render() {
|
|
147
157
|
const classes = {
|
|
148
|
-
'complete': this.
|
|
158
|
+
'complete': this.isComplete
|
|
149
159
|
};
|
|
150
160
|
const textClasses = {
|
|
151
161
|
'd2l-body-small': this.size === 'small',
|
|
@@ -153,21 +163,18 @@ class Progress extends LocalizeCoreElement(LitElement) {
|
|
|
153
163
|
};
|
|
154
164
|
const valueClasses = { ...textClasses, value: true };
|
|
155
165
|
|
|
156
|
-
const
|
|
157
|
-
const perecentageText = formatPercent(percentage);
|
|
158
|
-
|
|
166
|
+
const percentageText = formatPercent(this.isComplete ? 1 : Math.floor(100 * this.value / this.max) / 100);
|
|
159
167
|
return html`
|
|
160
|
-
<div ?hidden=${this.labelHidden} id="label" class=${classMap(textClasses)}>${this.label}</div>
|
|
168
|
+
<div aria-live=${this.announceLabel ? 'polite' : 'off'} ?hidden=${this.labelHidden} id="label" class=${classMap(textClasses)}>${this.label}</div>
|
|
161
169
|
<progress
|
|
162
170
|
aria-labelledby="${ifDefined(this.labelHidden ? undefined : 'label')}"
|
|
163
171
|
aria-label="${ifDefined(this.labelHidden ? this.label : undefined)}"
|
|
164
|
-
aria-valuetext="${
|
|
172
|
+
aria-valuetext="${percentageText}"
|
|
165
173
|
class="${classMap(classes)}"
|
|
166
174
|
value="${this.value}"
|
|
167
175
|
max="${this.max}">
|
|
168
176
|
</progress>
|
|
169
|
-
<div ?hidden=${this.valueHidden} class=${classMap(valueClasses)}>${
|
|
170
|
-
|
|
177
|
+
<div ?hidden=${this.valueHidden} class=${classMap(valueClasses)}>${percentageText}</div>
|
|
171
178
|
`;
|
|
172
179
|
}
|
|
173
180
|
|
package/custom-elements.json
CHANGED
|
@@ -11966,9 +11966,15 @@
|
|
|
11966
11966
|
"attributes": [
|
|
11967
11967
|
{
|
|
11968
11968
|
"name": "label",
|
|
11969
|
-
"description": "Label for the progress bar",
|
|
11969
|
+
"description": "REQUIRED: Label for the progress bar",
|
|
11970
11970
|
"type": "string"
|
|
11971
11971
|
},
|
|
11972
|
+
{
|
|
11973
|
+
"name": "announce-label",
|
|
11974
|
+
"description": "Announce the label when it changes",
|
|
11975
|
+
"type": "boolean",
|
|
11976
|
+
"default": "false"
|
|
11977
|
+
},
|
|
11972
11978
|
{
|
|
11973
11979
|
"name": "label-hidden",
|
|
11974
11980
|
"description": "Hide the bar's label",
|
|
@@ -11981,6 +11987,12 @@
|
|
|
11981
11987
|
"type": "number",
|
|
11982
11988
|
"default": "100"
|
|
11983
11989
|
},
|
|
11990
|
+
{
|
|
11991
|
+
"name": "size",
|
|
11992
|
+
"description": "The size of the progress bar",
|
|
11993
|
+
"type": "'small'|'medium'|'large'",
|
|
11994
|
+
"default": "\"medium\""
|
|
11995
|
+
},
|
|
11984
11996
|
{
|
|
11985
11997
|
"name": "value",
|
|
11986
11998
|
"description": "The current value of the progress bar",
|
|
@@ -11992,21 +12004,26 @@
|
|
|
11992
12004
|
"description": "Hide the bar's value",
|
|
11993
12005
|
"type": "boolean",
|
|
11994
12006
|
"default": "false"
|
|
11995
|
-
},
|
|
11996
|
-
{
|
|
11997
|
-
"name": "size",
|
|
11998
|
-
"description": "The size of the progress bar",
|
|
11999
|
-
"type": "'small'|'medium'|'large'",
|
|
12000
|
-
"default": "\"medium\""
|
|
12001
12007
|
}
|
|
12002
12008
|
],
|
|
12003
12009
|
"properties": [
|
|
12004
12010
|
{
|
|
12005
12011
|
"name": "label",
|
|
12006
12012
|
"attribute": "label",
|
|
12007
|
-
"description": "Label for the progress bar",
|
|
12013
|
+
"description": "REQUIRED: Label for the progress bar",
|
|
12008
12014
|
"type": "string"
|
|
12009
12015
|
},
|
|
12016
|
+
{
|
|
12017
|
+
"name": "isComplete",
|
|
12018
|
+
"type": "boolean"
|
|
12019
|
+
},
|
|
12020
|
+
{
|
|
12021
|
+
"name": "announceLabel",
|
|
12022
|
+
"attribute": "announce-label",
|
|
12023
|
+
"description": "Announce the label when it changes",
|
|
12024
|
+
"type": "boolean",
|
|
12025
|
+
"default": "false"
|
|
12026
|
+
},
|
|
12010
12027
|
{
|
|
12011
12028
|
"name": "labelHidden",
|
|
12012
12029
|
"attribute": "label-hidden",
|
|
@@ -12021,6 +12038,13 @@
|
|
|
12021
12038
|
"type": "number",
|
|
12022
12039
|
"default": "100"
|
|
12023
12040
|
},
|
|
12041
|
+
{
|
|
12042
|
+
"name": "size",
|
|
12043
|
+
"attribute": "size",
|
|
12044
|
+
"description": "The size of the progress bar",
|
|
12045
|
+
"type": "'small'|'medium'|'large'",
|
|
12046
|
+
"default": "\"medium\""
|
|
12047
|
+
},
|
|
12024
12048
|
{
|
|
12025
12049
|
"name": "value",
|
|
12026
12050
|
"attribute": "value",
|
|
@@ -12034,13 +12058,6 @@
|
|
|
12034
12058
|
"description": "Hide the bar's value",
|
|
12035
12059
|
"type": "boolean",
|
|
12036
12060
|
"default": "false"
|
|
12037
|
-
},
|
|
12038
|
-
{
|
|
12039
|
-
"name": "size",
|
|
12040
|
-
"attribute": "size",
|
|
12041
|
-
"description": "The size of the progress bar",
|
|
12042
|
-
"type": "'small'|'medium'|'large'",
|
|
12043
|
-
"default": "\"medium\""
|
|
12044
12061
|
}
|
|
12045
12062
|
]
|
|
12046
12063
|
},
|
package/helpers/focus.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { css, unsafeCSS } from 'lit';
|
|
2
2
|
import { getComposedChildren, getComposedParent, getFirstVisibleAncestor, getNextAncestorSibling, getPreviousAncestorSibling, isVisible } from './dom.js';
|
|
3
|
-
import { getFlag } from './flags.js';
|
|
4
3
|
|
|
5
4
|
const focusableElements = {
|
|
6
5
|
a: true,
|
|
@@ -15,9 +14,6 @@ const focusableElements = {
|
|
|
15
14
|
textarea: true
|
|
16
15
|
};
|
|
17
16
|
|
|
18
|
-
// The default here cannot be changed, as BSI relies on it being true. Do not change the default without adding a way for BSI to override it.
|
|
19
|
-
const focusVisibleSupportChangesEnabled = getFlag('focus-visible-support-changes-for-focus-rings', true);
|
|
20
|
-
|
|
21
17
|
export function getComposedActiveElement() {
|
|
22
18
|
let node = document.activeElement;
|
|
23
19
|
|
|
@@ -80,22 +76,6 @@ export function getFocusPseudoClass() {
|
|
|
80
76
|
return isFocusVisibleSupported() ? 'focus-visible' : 'focus';
|
|
81
77
|
}
|
|
82
78
|
export function getFocusRingStyles(selector, { extraStyles = null } = {}) {
|
|
83
|
-
// Remove when cleaning up focus-visible-support-changes-for-focus-rings
|
|
84
|
-
if (!focusVisibleSupportChangesEnabled) {
|
|
85
|
-
const selectorDelegate = typeof selector === 'string' ? pseudoClass => `${selector}:${pseudoClass}` : selector;
|
|
86
|
-
const cssSelector = unsafeCSS(selectorDelegate(getFocusPseudoClass()));
|
|
87
|
-
return css`${cssSelector} {
|
|
88
|
-
${extraStyles ?? css``}
|
|
89
|
-
outline: 2px solid var(--d2l-focus-ring-color, var(--d2l-color-celestine));
|
|
90
|
-
outline-offset: var(--d2l-focus-ring-offset, 2px);
|
|
91
|
-
}
|
|
92
|
-
@media (prefers-contrast: more) {
|
|
93
|
-
${cssSelector} {
|
|
94
|
-
outline-color: Highlight;
|
|
95
|
-
}
|
|
96
|
-
}`;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
79
|
const stylesDelegate = selector => css`
|
|
100
80
|
${selector} {
|
|
101
81
|
${extraStyles ?? css``}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightspace-ui/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.183.0",
|
|
4
4
|
"description": "A collection of accessible, free, open-source web components for building Brightspace applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": "https://github.com/BrightspaceUI/core.git",
|