@brightspace-ui/core 3.153.4 → 3.155.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.
- package/components/dialog/demo/dialog.html +34 -0
- package/components/dialog/dialog-mixin.js +4 -10
- package/components/filter/demo/filter.html +5 -0
- package/components/filter/filter-dimension-set.js +6 -1
- package/custom-elements.json +13 -0
- package/helpers/README.md +8 -2
- package/helpers/dom.js +14 -3
- package/helpers/focus.js +19 -6
- package/package.json +1 -1
@@ -12,11 +12,15 @@
|
|
12
12
|
import '../../button/button.js';
|
13
13
|
import '../../dropdown/dropdown-button-subtle.js';
|
14
14
|
import '../../dropdown/dropdown-content.js';
|
15
|
+
import '../../dropdown/dropdown.js';
|
16
|
+
import '../../dropdown/dropdown-menu.js';
|
15
17
|
import '../../filter/filter.js';
|
16
18
|
import '../../filter/filter-dimension-set.js';
|
17
19
|
import '../../filter/filter-dimension-set-value.js';
|
18
20
|
import '../../inputs/input-checkbox.js';
|
19
21
|
import '../../list/demo/demo-list.js';
|
22
|
+
import '../../menu/menu.js';
|
23
|
+
import '../../menu/menu-item.js';
|
20
24
|
import '../dialog.js';
|
21
25
|
import './dialog-async-content.js';
|
22
26
|
import './dialog-async-content-until.js';
|
@@ -82,6 +86,36 @@
|
|
82
86
|
</template>
|
83
87
|
</d2l-demo-snippet>
|
84
88
|
|
89
|
+
<h2>Dialog with complex opener</h2>
|
90
|
+
|
91
|
+
<d2l-demo-snippet>
|
92
|
+
<template>
|
93
|
+
<d2l-dropdown>
|
94
|
+
<button class="d2l-dropdown-opener">Open it!</button>
|
95
|
+
<d2l-dropdown-menu id="dropdown">
|
96
|
+
<d2l-menu label="Astronomy">
|
97
|
+
<d2l-menu-item id="complex-opener" text="Open dialog"></d2l-menu-item>
|
98
|
+
<d2l-menu-item text="Item 2"></d2l-menu-item>
|
99
|
+
<d2l-menu-item text="Item 3"></d2l-menu-item>
|
100
|
+
<d2l-menu-item text="Item 4"></d2l-menu-item>
|
101
|
+
</d2l-menu>
|
102
|
+
</d2l-dropdown-menu>
|
103
|
+
</d2l-dropdown>
|
104
|
+
<d2l-dialog id="complex-opener-dialog" title-text="Dialog Title">
|
105
|
+
<div>
|
106
|
+
Hello
|
107
|
+
</div>
|
108
|
+
<d2l-button slot="footer" primary data-dialog-action="ok">Click Me!</d2l-button>
|
109
|
+
<d2l-button slot="footer" data-dialog-action>Cancel</d2l-button>
|
110
|
+
</d2l-dialog>
|
111
|
+
<script>
|
112
|
+
document.querySelector('#complex-opener').addEventListener('d2l-menu-item-select', () => {
|
113
|
+
document.querySelector('#complex-opener-dialog').opened = true;
|
114
|
+
});
|
115
|
+
</script>
|
116
|
+
</template>
|
117
|
+
</d2l-demo-snippet>
|
118
|
+
|
85
119
|
<h2>Dialog (with promise)</h2>
|
86
120
|
|
87
121
|
<d2l-demo-snippet>
|
@@ -3,7 +3,7 @@ import '../../helpers/viewport-size.js';
|
|
3
3
|
import { allowBodyScroll, preventBodyScroll } from '../backdrop/backdrop.js';
|
4
4
|
import { clearDismissible, setDismissible } from '../../helpers/dismissible.js';
|
5
5
|
import { findComposedAncestor, getComposedChildren, isComposedAncestor } from '../../helpers/dom.js';
|
6
|
-
import { getComposedActiveElement, getFirstFocusableDescendant, getNextFocusable, isFocusable } from '../../helpers/focus.js';
|
6
|
+
import { getComposedActiveElement, getFirstFocusableDescendant, getFirstFocusableRelative, getNextFocusable, isFocusable } from '../../helpers/focus.js';
|
7
7
|
import { classMap } from 'lit/directives/class-map.js';
|
8
8
|
import { getUniqueId } from '../../helpers/uniqueId.js';
|
9
9
|
import { html } from 'lit';
|
@@ -530,15 +530,9 @@ export const DialogMixin = superclass => class extends RtlMixin(superclass) {
|
|
530
530
|
|
531
531
|
}
|
532
532
|
|
533
|
-
_tryApplyFocus(
|
534
|
-
|
535
|
-
|
536
|
-
if (focusable === null) return;
|
537
|
-
if (!isFocusable(focusable)) {
|
538
|
-
focusable = getFirstFocusableDescendant(focusable);
|
539
|
-
}
|
540
|
-
}
|
541
|
-
if (isFocusable(focusable)) focusable.focus();
|
533
|
+
_tryApplyFocus(node) {
|
534
|
+
const focusable = getFirstFocusableRelative(node);
|
535
|
+
if (focusable) focusable.focus();
|
542
536
|
}
|
543
537
|
|
544
538
|
_updateFocusableContentElemPresent() {
|
@@ -175,6 +175,11 @@
|
|
175
175
|
<d2l-filter-dimension-set-date-text-value key="6months2" range="6months"></d2l-filter-dimension-set-date-text-value>
|
176
176
|
<d2l-filter-dimension-set-date-time-range-value key="custom3" text="Custom Date Range with Time" start-value="2024-10-12T12:00:00Z"></d2l-filter-dimension-set-date-time-range-value>
|
177
177
|
</d2l-filter-dimension-set>
|
178
|
+
<d2l-filter-dimension-set key="dates3" text="Start and End Ranges" ignore-enforce-selection-single>
|
179
|
+
<d2l-filter-dimension-set-date-text-value key="6months" range="6months"></d2l-filter-dimension-set-date-text-value>
|
180
|
+
<d2l-filter-dimension-set-date-time-range-value key="custom4" text="Start Date"></d2l-filter-dimension-set-date-time-range-value>
|
181
|
+
<d2l-filter-dimension-set-date-time-range-value key="custom5" text="End Date"></d2l-filter-dimension-set-date-time-range-value>
|
182
|
+
</d2l-filter-dimension-set>
|
178
183
|
<d2l-filter-dimension-set key="role" text="Role" selected-first>
|
179
184
|
<d2l-filter-dimension-set-value key="admin" text="Admin" count="0"></d2l-filter-dimension-set-value>
|
180
185
|
<d2l-filter-dimension-set-value key="instructor" text="Instructor" count="22"></d2l-filter-dimension-set-value>
|
@@ -40,6 +40,10 @@ class FilterDimensionSet extends LitElement {
|
|
40
40
|
* @ignore
|
41
41
|
*/
|
42
42
|
minWidth: { type: Number },
|
43
|
+
/**
|
44
|
+
* ADVANCED: Whether to ignore the enforce single selection setting for this dimension.
|
45
|
+
*/
|
46
|
+
ignoreEnforceSelectionSingle: { type: Boolean, attribute: 'ignore-enforce-selection-single' },
|
43
47
|
/**
|
44
48
|
* Whether to hide the search input, perform a simple text search, or fire an event on search
|
45
49
|
* @type {'none'|'automatic'|'manual'}
|
@@ -79,6 +83,7 @@ class FilterDimensionSet extends LitElement {
|
|
79
83
|
this.introductoryText = '';
|
80
84
|
this.loading = false;
|
81
85
|
this.hasMore = false;
|
86
|
+
this.ignoreEnforceSelectionSingle = false;
|
82
87
|
this.searchType = 'automatic';
|
83
88
|
this.selectAll = false;
|
84
89
|
this.selectedFirst = false;
|
@@ -151,7 +156,7 @@ class FilterDimensionSet extends LitElement {
|
|
151
156
|
return value.getValueDetails();
|
152
157
|
});
|
153
158
|
if (noSearchSupport) this.searchType = 'none';
|
154
|
-
if (enforceSingleSelection) this.selectionSingle = true;
|
159
|
+
if (enforceSingleSelection && !this.ignoreEnforceSelectionSingle) this.selectionSingle = true;
|
155
160
|
if (minWidth) this.minWidth = minWidth;
|
156
161
|
return values;
|
157
162
|
}
|
package/custom-elements.json
CHANGED
@@ -4440,6 +4440,12 @@
|
|
4440
4440
|
"type": "boolean",
|
4441
4441
|
"default": "false"
|
4442
4442
|
},
|
4443
|
+
{
|
4444
|
+
"name": "ignore-enforce-selection-single",
|
4445
|
+
"description": "ADVANCED: Whether to ignore the enforce single selection setting for this dimension.",
|
4446
|
+
"type": "boolean",
|
4447
|
+
"default": "false"
|
4448
|
+
},
|
4443
4449
|
{
|
4444
4450
|
"name": "search-type",
|
4445
4451
|
"description": "Whether to hide the search input, perform a simple text search, or fire an event on search",
|
@@ -4512,6 +4518,13 @@
|
|
4512
4518
|
"type": "boolean",
|
4513
4519
|
"default": "false"
|
4514
4520
|
},
|
4521
|
+
{
|
4522
|
+
"name": "ignoreEnforceSelectionSingle",
|
4523
|
+
"attribute": "ignore-enforce-selection-single",
|
4524
|
+
"description": "ADVANCED: Whether to ignore the enforce single selection setting for this dimension.",
|
4525
|
+
"type": "boolean",
|
4526
|
+
"default": "false"
|
4527
|
+
},
|
4515
4528
|
{
|
4516
4529
|
"name": "searchType",
|
4517
4530
|
"attribute": "search-type",
|
package/helpers/README.md
CHANGED
@@ -107,7 +107,10 @@ getOffsetParent(node);
|
|
107
107
|
isComposedAncestor(ancestorNode, node);
|
108
108
|
|
109
109
|
// returns true/false whether the element is visible regardless of positioning
|
110
|
-
isVisible(node);
|
110
|
+
isVisible(node, { checkAncestors: true });
|
111
|
+
|
112
|
+
// returns the first visible ancestor of the given node
|
113
|
+
getFirstVisibleAncestor(node)
|
111
114
|
|
112
115
|
// similar to document.querySelector or element.querySelector,
|
113
116
|
// except it queries not just the light DOM but also shadow DOM
|
@@ -125,7 +128,10 @@ import { ... } from '@brightspace-ui/core/helpers/focus.js';
|
|
125
128
|
getComposedActiveElement()
|
126
129
|
|
127
130
|
// gets the first focusable descendant given a node, including those within the shadow DOM
|
128
|
-
getFirstFocusableDescendant(node, includeHidden, predicate, includeTabbablesOnly)
|
131
|
+
getFirstFocusableDescendant(node, includeHidden, predicate, includeTabbablesOnly, checkNodeVisibility = true)
|
132
|
+
|
133
|
+
// gets the first focusable relative given a node, checking first itself, its children, and lastly, recursively its parent
|
134
|
+
getFirstFocusableRelative(node, { includeHidden, predicate, includeTabbablesOnly, checkNodeVisibility: true })
|
129
135
|
|
130
136
|
// gets the focusable elements within the specified element
|
131
137
|
getFocusableDescendants(node, { deep: false, disabled: false, hidden: false, predicate: elem => false, tabbablesOnly: true })
|
package/helpers/dom.js
CHANGED
@@ -206,7 +206,7 @@ export function isComposedAncestor(ancestorNode, node) {
|
|
206
206
|
}) !== null;
|
207
207
|
}
|
208
208
|
|
209
|
-
export function isVisible(node) {
|
209
|
+
export function isVisible(node, { checkAncestors = true } = {}) {
|
210
210
|
|
211
211
|
/* this helper is different from checking offsetParent because offsetParent
|
212
212
|
returns null for fixed position elements regardless of visibility */
|
@@ -223,13 +223,24 @@ export function isVisible(node) {
|
|
223
223
|
if (computedStyle.getPropertyValue('visibility') === 'hidden') return false;
|
224
224
|
}
|
225
225
|
|
226
|
-
|
227
|
-
|
226
|
+
if (checkAncestors) {
|
227
|
+
const parentNode = getComposedParent(node);
|
228
|
+
if (parentNode) return isVisible(parentNode);
|
229
|
+
}
|
228
230
|
|
229
231
|
return true;
|
230
232
|
|
231
233
|
}
|
232
234
|
|
235
|
+
export function getFirstVisibleAncestor(node) {
|
236
|
+
let hiddenAncestor = findComposedAncestor(node, n => !isVisible(n, { checkAncestors: false }));
|
237
|
+
while (hiddenAncestor) {
|
238
|
+
node = getComposedParent(hiddenAncestor);
|
239
|
+
hiddenAncestor = findComposedAncestor(node, n => !isVisible(n, { checkAncestors: false }));
|
240
|
+
}
|
241
|
+
return node;
|
242
|
+
}
|
243
|
+
|
233
244
|
export function querySelectorComposed(node, selector) {
|
234
245
|
|
235
246
|
if (!node || (node.nodeType !== 1 && node.nodeType !== 9 && node.nodeType !== 11)) {
|
package/helpers/focus.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { css, unsafeCSS } from 'lit';
|
2
|
-
import { getComposedChildren, getComposedParent, getNextAncestorSibling, getPreviousAncestorSibling, isVisible } from './dom.js';
|
2
|
+
import { getComposedChildren, getComposedParent, getFirstVisibleAncestor, getNextAncestorSibling, getPreviousAncestorSibling, isVisible } from './dom.js';
|
3
3
|
|
4
4
|
const focusableElements = {
|
5
5
|
a: true,
|
@@ -26,21 +26,34 @@ export function getComposedActiveElement() {
|
|
26
26
|
return node;
|
27
27
|
}
|
28
28
|
|
29
|
-
export function getFirstFocusableDescendant(node, includeHidden, predicate, includeTabbablesOnly) {
|
30
|
-
if (predicate === undefined) predicate = () => true;
|
31
|
-
|
29
|
+
export function getFirstFocusableDescendant(node, includeHidden, predicate = () => true, includeTabbablesOnly, nodeVisibilityUnknown = true) {
|
32
30
|
const composedChildren = getComposedChildren(node);
|
31
|
+
if (!composedChildren?.length || (!includeHidden && nodeVisibilityUnknown && !isVisible(node))) return null;
|
33
32
|
|
34
33
|
for (let i = 0; i < composedChildren.length; i++) {
|
35
|
-
if (
|
34
|
+
if (!includeHidden && !isVisible(composedChildren[i], { checkAncestors: false })) continue;
|
35
|
+
if (isFocusable(composedChildren[i], true, includeTabbablesOnly) && predicate(composedChildren[i])) return composedChildren[i];
|
36
36
|
|
37
|
-
const focusable = getFirstFocusableDescendant(composedChildren[i], includeHidden, predicate, includeTabbablesOnly);
|
37
|
+
const focusable = getFirstFocusableDescendant(composedChildren[i], includeHidden, predicate, includeTabbablesOnly, false);
|
38
38
|
if (focusable) return focusable;
|
39
39
|
}
|
40
40
|
|
41
41
|
return null;
|
42
42
|
}
|
43
43
|
|
44
|
+
export function getFirstFocusableRelative(node, { includeHidden, predicate = () => true, includeTabbablesOnly, nodeVisibilityUnknown = true } = {}) {
|
45
|
+
if (!node) return null;
|
46
|
+
|
47
|
+
if (!includeHidden && nodeVisibilityUnknown) node = getFirstVisibleAncestor(node);
|
48
|
+
|
49
|
+
if (isFocusable(node, true) && predicate(node)) return node;
|
50
|
+
|
51
|
+
const focusableDescendant = getFirstFocusableDescendant(node, includeHidden, predicate, includeTabbablesOnly, false);
|
52
|
+
if (focusableDescendant !== null) return focusableDescendant;
|
53
|
+
|
54
|
+
return getFirstFocusableRelative(getComposedParent(node), { includeHidden, predicate, includeTabbablesOnly, nodeVisibilityUnknown: false });
|
55
|
+
}
|
56
|
+
|
44
57
|
export function getFocusableDescendants(node, options) {
|
45
58
|
let focusables = [];
|
46
59
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@brightspace-ui/core",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.155.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",
|