@brightspace-ui/labs 2.41.1 → 2.42.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/package.json
CHANGED
|
@@ -592,7 +592,6 @@ class TreeFilter extends LocalizeLabsElement(MobxLitElement) {
|
|
|
592
592
|
this.isSelectAllVisible = false;
|
|
593
593
|
this.disabled = false;
|
|
594
594
|
|
|
595
|
-
this._needResize = false;
|
|
596
595
|
this._searchBookmark = null;
|
|
597
596
|
}
|
|
598
597
|
|
|
@@ -632,13 +631,6 @@ class TreeFilter extends LocalizeLabsElement(MobxLitElement) {
|
|
|
632
631
|
</div>`;
|
|
633
632
|
}
|
|
634
633
|
|
|
635
|
-
async updated() {
|
|
636
|
-
if (!this._needResize) return;
|
|
637
|
-
|
|
638
|
-
await this.resize();
|
|
639
|
-
this._needResize = false;
|
|
640
|
-
}
|
|
641
|
-
|
|
642
634
|
/**
|
|
643
635
|
* Adds the given children to the given parent. See Tree.addNodes().
|
|
644
636
|
* @param parent
|
|
@@ -647,7 +639,6 @@ class TreeFilter extends LocalizeLabsElement(MobxLitElement) {
|
|
|
647
639
|
* @param bookmark - Opaque data that will be sent in the request-children event if the user asks to load more results
|
|
648
640
|
*/
|
|
649
641
|
addChildren(parent, children, hasMore, bookmark) {
|
|
650
|
-
this._needResize = true;
|
|
651
642
|
this.tree.addNodes(parent, children, hasMore, bookmark);
|
|
652
643
|
}
|
|
653
644
|
|
|
@@ -658,7 +649,6 @@ class TreeFilter extends LocalizeLabsElement(MobxLitElement) {
|
|
|
658
649
|
* @param {Object}bookmark - Opaque data that will be sent in the search event if the user asks to load more results
|
|
659
650
|
*/
|
|
660
651
|
addSearchResults(nodes, hasMore, bookmark) {
|
|
661
|
-
this._needResize = true;
|
|
662
652
|
this.tree.addTree(nodes);
|
|
663
653
|
this.isLoadMoreSearch = hasMore;
|
|
664
654
|
this._searchBookmark = bookmark;
|
|
@@ -669,12 +659,6 @@ class TreeFilter extends LocalizeLabsElement(MobxLitElement) {
|
|
|
669
659
|
this.shadowRoot.querySelector('d2l-labs-tree-selector').clearSearchAndSelection(generateEvent);
|
|
670
660
|
}
|
|
671
661
|
|
|
672
|
-
async resize() {
|
|
673
|
-
await this.updateComplete;
|
|
674
|
-
const treeSelector = this.shadowRoot?.querySelector('d2l-labs-tree-selector');
|
|
675
|
-
treeSelector && treeSelector.resize();
|
|
676
|
-
}
|
|
677
|
-
|
|
678
662
|
get _isSearch() {
|
|
679
663
|
return this.searchString.length > 0;
|
|
680
664
|
}
|
|
@@ -715,7 +699,6 @@ class TreeFilter extends LocalizeLabsElement(MobxLitElement) {
|
|
|
715
699
|
|
|
716
700
|
_onOpen(event) {
|
|
717
701
|
event.stopPropagation();
|
|
718
|
-
this._needResize = true;
|
|
719
702
|
this.tree.setOpen(event.detail.id, event.detail.isOpen);
|
|
720
703
|
}
|
|
721
704
|
|
|
@@ -727,7 +710,6 @@ class TreeFilter extends LocalizeLabsElement(MobxLitElement) {
|
|
|
727
710
|
|
|
728
711
|
_onSearch(event) {
|
|
729
712
|
event.stopPropagation();
|
|
730
|
-
this._needResize = true;
|
|
731
713
|
this.searchString = event.detail.value;
|
|
732
714
|
|
|
733
715
|
if (this.tree.isDynamic) {
|
|
@@ -10,6 +10,10 @@ import { classMap } from 'lit/directives/class-map.js';
|
|
|
10
10
|
import { LocalizeLabsElement } from '../localize-labs-element.js';
|
|
11
11
|
import { selectStyles } from '@brightspace-ui/core/components/inputs/input-select-styles';
|
|
12
12
|
|
|
13
|
+
const MOBILE_BREAKPOINT = 616;
|
|
14
|
+
const DROPDOWN_MOBILE_WIDTH = 320;
|
|
15
|
+
const DROPDOWN_WIDTH = 368;
|
|
16
|
+
|
|
13
17
|
/**
|
|
14
18
|
* @property {String} name
|
|
15
19
|
* @property {Boolean} isSearch - if true, show "search-results" slot instead of "tree" slot
|
|
@@ -26,7 +30,9 @@ class TreeSelector extends LocalizeLabsElement(LitElement) {
|
|
|
26
30
|
disabled: { type: Boolean, attribute: 'disabled' },
|
|
27
31
|
isSelectAllVisible: { type: Boolean, attribute: 'select-all-ui', reflect: true },
|
|
28
32
|
isSearch: { type: Boolean, attribute: 'search', reflect: true },
|
|
29
|
-
isSelected: { type: Boolean, attribute: 'selected', reflect: true }
|
|
33
|
+
isSelected: { type: Boolean, attribute: 'selected', reflect: true },
|
|
34
|
+
_dropdownMinWidth: { type: Number },
|
|
35
|
+
_dropdownMaxWidth: { type: Number },
|
|
30
36
|
};
|
|
31
37
|
}
|
|
32
38
|
|
|
@@ -89,6 +95,8 @@ class TreeSelector extends LocalizeLabsElement(LitElement) {
|
|
|
89
95
|
this._isSearch = false;
|
|
90
96
|
this.isSelectAllVisible = false;
|
|
91
97
|
this.disabled = false;
|
|
98
|
+
this._dropdownMinWidth = DROPDOWN_WIDTH;
|
|
99
|
+
this._dropdownMaxWidth = DROPDOWN_WIDTH;
|
|
92
100
|
}
|
|
93
101
|
|
|
94
102
|
/**
|
|
@@ -99,13 +107,10 @@ class TreeSelector extends LocalizeLabsElement(LitElement) {
|
|
|
99
107
|
}
|
|
100
108
|
|
|
101
109
|
render() {
|
|
102
|
-
// Using no-auto-fit on d2l-dropdown-content to avoid having the component jump to the top on every
|
|
103
|
-
// node open and load. The tradeoff is that the user has to scroll the whole page now.
|
|
104
|
-
// We have a defect logged to improve this in future.
|
|
105
110
|
return html`
|
|
106
111
|
<d2l-dropdown>
|
|
107
|
-
<d2l-dropdown-button-subtle text="${this.name}" ?disabled=${this.disabled}>
|
|
108
|
-
<d2l-dropdown-content align="start"
|
|
112
|
+
<d2l-dropdown-button-subtle text="${this.name}" ?disabled=${this.disabled} @d2l-dropdown-opener-click="${this._onDropdownOpenerClick}">
|
|
113
|
+
<d2l-dropdown-content align="start" min-width=${this._dropdownMinWidth} max-width=${this._dropdownMaxWidth} mobile-breakpoint=${MOBILE_BREAKPOINT} class="vdiff-target">
|
|
109
114
|
<div class="d2l-labs-filter-dropdown-content-header" slot="header">
|
|
110
115
|
<span>${this.localize('components:ouFilter:treeSelector:filterBy')}</span>
|
|
111
116
|
|
|
@@ -143,12 +148,6 @@ class TreeSelector extends LocalizeLabsElement(LitElement) {
|
|
|
143
148
|
this._onClear(generateEvent);
|
|
144
149
|
}
|
|
145
150
|
|
|
146
|
-
async resize() {
|
|
147
|
-
await this.treeUpdateComplete;
|
|
148
|
-
const content = this.shadowRoot?.querySelector('d2l-dropdown-content');
|
|
149
|
-
content && await content.resize();
|
|
150
|
-
}
|
|
151
|
-
|
|
152
151
|
simulateSearch(searchString) {
|
|
153
152
|
this._onSearch({
|
|
154
153
|
detail: {
|
|
@@ -206,6 +205,12 @@ class TreeSelector extends LocalizeLabsElement(LitElement) {
|
|
|
206
205
|
));
|
|
207
206
|
}
|
|
208
207
|
|
|
208
|
+
_onDropdownOpenerClick() {
|
|
209
|
+
const isMobile = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT}px)`).matches;
|
|
210
|
+
this._dropdownMinWidth = isMobile ? DROPDOWN_MOBILE_WIDTH : DROPDOWN_WIDTH;
|
|
211
|
+
this._dropdownMaxWidth = isMobile ? DROPDOWN_MOBILE_WIDTH : DROPDOWN_WIDTH;
|
|
212
|
+
}
|
|
213
|
+
|
|
209
214
|
_onSearch(event, generateEvent = true) {
|
|
210
215
|
if (!generateEvent) {
|
|
211
216
|
return;
|