@brightspace-ui/core 2.58.0 → 2.59.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.
|
@@ -32,13 +32,14 @@ The `d2l-dialog` element is a generic dialog that provides a slot for arbitrary
|
|
|
32
32
|
* Label primary actions with clear and predictable language. Use verbs like, “Add” or “Save” that indicate the outcome of a dialog rather than, “OK” or “Close”
|
|
33
33
|
* Keep dialog titles concise
|
|
34
34
|
* Maintain a language relationship between the action that triggered the dialog, dialog title, and dialog primary button.
|
|
35
|
+
* When it is necessary to stack multiple dialogs, ensure the stacked dialog is nested within the DOM of the dialog containing the opener
|
|
35
36
|
<!-- docs: end dos -->
|
|
36
37
|
|
|
37
38
|
<!-- docs: start donts -->
|
|
38
39
|
* Don’t use a dialog when you could reasonably use an alternative that preserves user context, like expanding options inline
|
|
39
40
|
* Don’t use a dialog to show error, success, or warning messages. Use an inline or toast alert instead.
|
|
40
41
|
* Avoid creating large, complex dialogs
|
|
41
|
-
* Avoid
|
|
42
|
+
* Avoid opening a dialog from within other dialogs (stacking dialogs)
|
|
42
43
|
* Avoid a title length that could easily wrap to two lines
|
|
43
44
|
<!-- docs: end donts -->
|
|
44
45
|
<!-- docs: end best practices -->
|
|
@@ -28,9 +28,14 @@ export const SelectionObserverMixin = superclass => class extends superclass {
|
|
|
28
28
|
|
|
29
29
|
connectedCallback() {
|
|
30
30
|
super.connectedCallback();
|
|
31
|
+
this.addEventListener('d2l-selection-observer-subscribe', this._handleSelectionObserverSubscribe);
|
|
32
|
+
|
|
31
33
|
// delay subscription otherwise import/upgrade order can cause selection mixin to miss event
|
|
32
34
|
requestAnimationFrame(() => {
|
|
33
|
-
if (this.selectionFor)
|
|
35
|
+
if (this.selectionFor) {
|
|
36
|
+
this._handleSelectionFor();
|
|
37
|
+
return this._provider?.subscribeObserver(this);
|
|
38
|
+
}
|
|
34
39
|
|
|
35
40
|
const evt = new CustomEvent('d2l-selection-observer-subscribe', {
|
|
36
41
|
bubbles: true,
|
|
@@ -44,34 +49,57 @@ export const SelectionObserverMixin = superclass => class extends superclass {
|
|
|
44
49
|
|
|
45
50
|
disconnectedCallback() {
|
|
46
51
|
super.disconnectedCallback();
|
|
47
|
-
|
|
48
|
-
|
|
52
|
+
this._disconnectSelectionForObserver();
|
|
53
|
+
this._disconnectProvider();
|
|
54
|
+
this.removeEventListener('d2l-selection-observer-subscribe', this._handleSelectionObserverSubscribe);
|
|
49
55
|
}
|
|
50
56
|
|
|
51
57
|
updated(changedProperties) {
|
|
52
58
|
super.updated(changedProperties);
|
|
53
59
|
|
|
54
|
-
if (
|
|
60
|
+
if (changedProperties.has('selectionFor')) this._handleSelectionFor();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
_disconnectProvider() {
|
|
64
|
+
if (!this._provider) return;
|
|
65
|
+
this._provider.unsubscribeObserver(this);
|
|
66
|
+
this._provider = undefined;
|
|
67
|
+
}
|
|
55
68
|
|
|
56
|
-
|
|
57
|
-
if (this.
|
|
69
|
+
_disconnectSelectionForObserver() {
|
|
70
|
+
if (!this._selectionForObserver) return;
|
|
71
|
+
this._selectionForObserver.disconnect();
|
|
72
|
+
this._selectionForObserver = undefined;
|
|
73
|
+
}
|
|
58
74
|
|
|
75
|
+
_handleSelectionFor() {
|
|
76
|
+
this._disconnectSelectionForObserver();
|
|
59
77
|
this._updateProvider();
|
|
60
78
|
|
|
61
|
-
this.
|
|
62
|
-
this._updateProvider();
|
|
63
|
-
});
|
|
79
|
+
if (this.selectionFor) {
|
|
80
|
+
this._selectionForObserver = new MutationObserver(() => this._updateProvider());
|
|
64
81
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
82
|
+
this._selectionForObserver.observe(this.getRootNode(), {
|
|
83
|
+
childList: true,
|
|
84
|
+
subtree: true
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
_handleSelectionObserverSubscribe(e) {
|
|
90
|
+
if (e.target !== this && this._provider) {
|
|
91
|
+
e.stopPropagation();
|
|
92
|
+
e.detail.provider = this._provider;
|
|
93
|
+
const target = e.composedPath()[0];
|
|
94
|
+
this._provider.subscribeObserver(target);
|
|
95
|
+
}
|
|
69
96
|
}
|
|
70
97
|
|
|
71
98
|
_updateProvider() {
|
|
72
|
-
const selectionComponent = this.getRootNode().querySelector(`#${cssEscape(this.selectionFor)}`);
|
|
99
|
+
const selectionComponent = this.selectionFor ? this.getRootNode().querySelector(`#${cssEscape(this.selectionFor)}`) : undefined;
|
|
73
100
|
if (this._provider === selectionComponent) return;
|
|
74
101
|
|
|
102
|
+
this._disconnectProvider();
|
|
75
103
|
this._provider = selectionComponent;
|
|
76
104
|
if (this._provider) {
|
|
77
105
|
this._provider.subscribeObserver(this);
|
package/custom-elements.json
CHANGED
|
@@ -10001,6 +10001,37 @@
|
|
|
10001
10001
|
}
|
|
10002
10002
|
]
|
|
10003
10003
|
},
|
|
10004
|
+
{
|
|
10005
|
+
"name": "d2l-test-selection-observer",
|
|
10006
|
+
"path": "./components/selection/test/selection-component.js",
|
|
10007
|
+
"attributes": [
|
|
10008
|
+
{
|
|
10009
|
+
"name": "selection-for",
|
|
10010
|
+
"description": "Id of the `SelectionMixin` component this component wants to observe (if not located within that component)",
|
|
10011
|
+
"type": "string"
|
|
10012
|
+
}
|
|
10013
|
+
],
|
|
10014
|
+
"properties": [
|
|
10015
|
+
{
|
|
10016
|
+
"name": "selectionFor",
|
|
10017
|
+
"attribute": "selection-for",
|
|
10018
|
+
"description": "Id of the `SelectionMixin` component this component wants to observe (if not located within that component)",
|
|
10019
|
+
"type": "string"
|
|
10020
|
+
},
|
|
10021
|
+
{
|
|
10022
|
+
"name": "selectionInfo"
|
|
10023
|
+
}
|
|
10024
|
+
],
|
|
10025
|
+
"events": [
|
|
10026
|
+
{
|
|
10027
|
+
"name": "d2l-selection-observer-subscribe"
|
|
10028
|
+
}
|
|
10029
|
+
]
|
|
10030
|
+
},
|
|
10031
|
+
{
|
|
10032
|
+
"name": "d2l-test-selection-observer-shadow",
|
|
10033
|
+
"path": "./components/selection/test/selection-component.js"
|
|
10034
|
+
},
|
|
10004
10035
|
{
|
|
10005
10036
|
"name": "d2l-test-skeleton-box",
|
|
10006
10037
|
"path": "./components/skeleton/demo/skeleton-test-box.js",
|
package/helpers/announce.js
CHANGED
|
@@ -25,9 +25,13 @@ export function announce(message) {
|
|
|
25
25
|
/* Need to give browser enough time to create the live region so that it will
|
|
26
26
|
treat the change as an update. Firefox sometimes ignores changes if the region
|
|
27
27
|
and update are made too quickly in succession. RequestAnimationFrame is not
|
|
28
|
-
sufficient here.
|
|
28
|
+
sufficient here. Also, for some strange reason, sometimes VO will not announce
|
|
29
|
+
duplicate messages even if we remove the child so we also append a non-breaking space. */
|
|
29
30
|
const elem = [...container.childNodes].find((c) => c.textContent === message);
|
|
30
|
-
if (elem)
|
|
31
|
+
if (elem) {
|
|
32
|
+
elem.parentNode.removeChild(elem);
|
|
33
|
+
message = message.concat('\u00A0');
|
|
34
|
+
}
|
|
31
35
|
setTimeout(() => {
|
|
32
36
|
container.appendChild(document.createTextNode(message));
|
|
33
37
|
}, 200);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightspace-ui/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.59.1",
|
|
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",
|