@brightspace-ui/labs 2.17.0 → 2.19.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
|
@@ -36,6 +36,10 @@
|
|
|
36
36
|
"./components/opt-in-flyout.js": "./src/components/opt-in-flyout/opt-in-flyout.js",
|
|
37
37
|
"./components/opt-out-flyout.js": "./src/components/opt-in-flyout/opt-out-flyout.js",
|
|
38
38
|
"./components/opt-out-reason.js": "./src/components/opt-in-flyout/opt-out-reason.js",
|
|
39
|
+
"./components/ou-filter.js": "./src/components/ou-filter/ou-filter.js",
|
|
40
|
+
"./components/ou-filter/tree-filter.js": "./src/components/ou-filter/tree-filter.js",
|
|
41
|
+
"./components/ou-filter/tree-selector-node.js": "./src/components/ou-filter/tree-selector-node.js",
|
|
42
|
+
"./components/ou-filter/tree-selector.js": "./src/components/ou-filter/tree-selector.js",
|
|
39
43
|
"./components/pager-numeric.js": "./src/components/pagination/pager-numeric.js",
|
|
40
44
|
"./components/view-toggle.js": "./src/components/view-toggle/view-toggle.js",
|
|
41
45
|
"./components/wizard.js": "./src/components/wizard/wizard.js",
|
|
@@ -69,6 +73,7 @@
|
|
|
69
73
|
"eslint": "^9",
|
|
70
74
|
"eslint-config-brightspace": "^2",
|
|
71
75
|
"messageformat-validator": "^2",
|
|
76
|
+
"sinon": "^19",
|
|
72
77
|
"stylelint": "^16"
|
|
73
78
|
},
|
|
74
79
|
"files": [
|
|
@@ -79,9 +84,12 @@
|
|
|
79
84
|
"access": "public"
|
|
80
85
|
},
|
|
81
86
|
"dependencies": {
|
|
87
|
+
"@adobe/lit-mobx": "^2",
|
|
82
88
|
"@brightspace-ui/core": "^3",
|
|
89
|
+
"@brightspace-ui/intl": "^3",
|
|
83
90
|
"@lit/context": "^1.1.3",
|
|
84
|
-
"lit": "^3"
|
|
91
|
+
"lit": "^3",
|
|
92
|
+
"mobx": "^5"
|
|
85
93
|
},
|
|
86
|
-
"version": "2.
|
|
94
|
+
"version": "2.19.0"
|
|
87
95
|
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { css, html } from 'lit';
|
|
2
|
+
import { LocalizeLabsElement } from '../localize-labs-element.js';
|
|
3
|
+
import { MobxLitElement } from '@adobe/lit-mobx';
|
|
4
|
+
import { Tree } from './tree-filter.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Class/interface that satisfies OuFilter API
|
|
8
|
+
*/
|
|
9
|
+
export class OuFilterDataManager {
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Return instance of Tree declared in tree-filter.js
|
|
13
|
+
* NB. Implementation of this class/interface MUST make observable the variable that contains the instance of Tree class
|
|
14
|
+
*/
|
|
15
|
+
get orgUnitTree() {
|
|
16
|
+
return new Tree({});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Applies semester filter if provided
|
|
21
|
+
*/
|
|
22
|
+
get selectedSemesterIds() {
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Fetches children of specified org unit. It's called only when Tree.isDynamic == true.
|
|
28
|
+
* @param {string} id - org unit id
|
|
29
|
+
* @param {string} bookmark
|
|
30
|
+
* @returns {Object} - { PagingInfo: { HasMoreItems: boolean, Bookmark: string }, Items: OrgUnitNode[] }. Fields indices are defined in tree-filter.js
|
|
31
|
+
*/
|
|
32
|
+
// eslint-disable-next-line no-unused-vars
|
|
33
|
+
async fetchRelevantChildren(id, bookmark) {
|
|
34
|
+
return { PagingInfo: {}, Items: [] };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Returns org units for the provided search string. It's called only when Tree.isDynamic == true.
|
|
39
|
+
* @param {string} searchString
|
|
40
|
+
* @param {string} bookmark
|
|
41
|
+
* @returns {Object} - { PagingInfo:{ HasMoreItems: boolean, Bookmark: string }, Items: OrgUnitNode[] }. Fields indices are defined in tree-filter.js
|
|
42
|
+
*/
|
|
43
|
+
// eslint-disable-next-line no-unused-vars
|
|
44
|
+
async orgUnitSearch(searchString, bookmark) {
|
|
45
|
+
return { PagingInfo: {}, Items: [] };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @property {Object} dataManager - an instance of OuFilterDataManager
|
|
52
|
+
* @property {Boolean} isSelectAllVisible - shows Select all button if true
|
|
53
|
+
* @fires d2l-labs-ou-filter-change
|
|
54
|
+
*/
|
|
55
|
+
class OuFilter extends LocalizeLabsElement(MobxLitElement) {
|
|
56
|
+
|
|
57
|
+
static get properties() {
|
|
58
|
+
return {
|
|
59
|
+
dataManager: { type: Object, attribute: false },
|
|
60
|
+
isSelectAllVisible: { type: Boolean, attribute: 'select-all-ui', reflect: true },
|
|
61
|
+
disabled: { type: Boolean, attribute: 'disabled' }
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static get styles() {
|
|
66
|
+
return css`
|
|
67
|
+
:host {
|
|
68
|
+
display: inline-block;
|
|
69
|
+
}
|
|
70
|
+
:host([hidden]) {
|
|
71
|
+
display: none;
|
|
72
|
+
}
|
|
73
|
+
`;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
constructor() {
|
|
77
|
+
super();
|
|
78
|
+
this.dataManager = new OuFilterDataManager();
|
|
79
|
+
this.isSelectAllVisible = false;
|
|
80
|
+
this.disabled = false;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
get selected() {
|
|
84
|
+
return this.dataManager.orgUnitTree.selected;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
render() {
|
|
88
|
+
this.dataManager.orgUnitTree.setAncestorFilter(this.dataManager.selectedSemesterIds);
|
|
89
|
+
return html`
|
|
90
|
+
<d2l-labs-tree-filter
|
|
91
|
+
class="vdiff-target"
|
|
92
|
+
.tree="${this.dataManager.orgUnitTree}"
|
|
93
|
+
opener-text="${this.localize('components:ouFilter:orgUnitFilter:nameAllSelected')}"
|
|
94
|
+
opener-text-selected="${this.localize('components:ouFilter:orgUnitFilter:nameSomeSelected')}"
|
|
95
|
+
?select-all-ui="${this.isSelectAllVisible}"
|
|
96
|
+
?disabled="${this.disabled}"
|
|
97
|
+
@d2l-labs-tree-filter-select="${this._onChange}"
|
|
98
|
+
@d2l-labs-tree-filter-request-children="${this._onRequestChildren}"
|
|
99
|
+
@d2l-labs-tree-filter-search="${this._onSearch}"
|
|
100
|
+
>
|
|
101
|
+
</d2l-labs-tree-filter>`;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Clears search bar and selection
|
|
106
|
+
* @param {boolean?} generateEvent - If set to false, don't fire change event
|
|
107
|
+
*/
|
|
108
|
+
clearSearchAndSelection(generateEvent = true) {
|
|
109
|
+
this.shadowRoot.querySelector('d2l-labs-tree-filter').clearSearchAndSelection(generateEvent);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
_onChange() {
|
|
113
|
+
/**
|
|
114
|
+
* @event d2l-labs-ou-filter-change
|
|
115
|
+
*/
|
|
116
|
+
this.dispatchEvent(new CustomEvent(
|
|
117
|
+
'd2l-labs-ou-filter-change',
|
|
118
|
+
{ bubbles: true, composed: false }
|
|
119
|
+
));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
async _onRequestChildren(event) {
|
|
123
|
+
const el = event.target;
|
|
124
|
+
const id = event.detail.id;
|
|
125
|
+
const bookmark = event.detail.bookmark;
|
|
126
|
+
const results = await this.dataManager.fetchRelevantChildren(id, bookmark);
|
|
127
|
+
el.addChildren(id, results.Items, results.PagingInfo.HasMoreItems, results.PagingInfo.Bookmark);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async _onSearch(event) {
|
|
131
|
+
const el = event.target;
|
|
132
|
+
const searchString = event.detail.searchString;
|
|
133
|
+
const bookmark = event.detail.bookmark;
|
|
134
|
+
const results = await this.dataManager.orgUnitSearch(searchString, bookmark);
|
|
135
|
+
el.addSearchResults(results.Items, results.PagingInfo.HasMoreItems, results.PagingInfo.Bookmark);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
customElements.define('d2l-labs-ou-filter', OuFilter);
|