@brightspace-ui/core 3.184.0 → 3.184.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.
|
@@ -22,7 +22,7 @@ const FullData = [
|
|
|
22
22
|
{ key: 'stats', selected:false, text: 'Statistics' },
|
|
23
23
|
{ key: 'writerscraft', selected:true, text: 'Writer\'s Craft' },
|
|
24
24
|
],
|
|
25
|
-
|
|
25
|
+
loadCount: 6
|
|
26
26
|
},
|
|
27
27
|
{
|
|
28
28
|
key: 'role',
|
|
@@ -32,7 +32,7 @@ const FullData = [
|
|
|
32
32
|
{ key: 'instructor', selected:false, text: 'Instructor' },
|
|
33
33
|
{ key: 'student', selected:false, text: 'Student' }
|
|
34
34
|
],
|
|
35
|
-
|
|
35
|
+
loadCount: 2
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
38
|
key: 'dep',
|
|
@@ -42,7 +42,7 @@ const FullData = [
|
|
|
42
42
|
{ key: 'spanish', selected:false, text: 'Spanish' },
|
|
43
43
|
{ key: 'science', selected:false, text: 'Science' }
|
|
44
44
|
],
|
|
45
|
-
|
|
45
|
+
loadCount: 2
|
|
46
46
|
},
|
|
47
47
|
{
|
|
48
48
|
key: 'grad',
|
|
@@ -52,7 +52,7 @@ const FullData = [
|
|
|
52
52
|
{ key: '2', selected:false, text: '2nd Grade' },
|
|
53
53
|
{ key: '3', selected:false, text: '3rd Grade' }
|
|
54
54
|
],
|
|
55
|
-
|
|
55
|
+
loadCount: 2
|
|
56
56
|
}
|
|
57
57
|
,
|
|
58
58
|
{
|
|
@@ -63,7 +63,7 @@ const FullData = [
|
|
|
63
63
|
{ key: '2', selected:false, text: '2nd City' },
|
|
64
64
|
{ key: '3', selected:false, text: '3rd City' }
|
|
65
65
|
],
|
|
66
|
-
|
|
66
|
+
loadCount: 2
|
|
67
67
|
}
|
|
68
68
|
];
|
|
69
69
|
|
|
@@ -77,24 +77,7 @@ class FilterLoadMoreDemo extends LitElement {
|
|
|
77
77
|
|
|
78
78
|
constructor() {
|
|
79
79
|
super();
|
|
80
|
-
|
|
81
|
-
for (const dim of FullData) {
|
|
82
|
-
const values = {};
|
|
83
|
-
let selectedCount = 0;
|
|
84
|
-
for (const v of dim.values) {
|
|
85
|
-
if (!v.selected) continue;
|
|
86
|
-
values[v.key] = { ...v };
|
|
87
|
-
selectedCount++;
|
|
88
|
-
}
|
|
89
|
-
const data = {
|
|
90
|
-
key: dim.key,
|
|
91
|
-
text: dim.text,
|
|
92
|
-
values
|
|
93
|
-
};
|
|
94
|
-
this._addKeys(data, dim.initialCount - selectedCount);
|
|
95
|
-
dimensions.push(data);
|
|
96
|
-
}
|
|
97
|
-
this._dimensions = dimensions;
|
|
80
|
+
this._dimensions = FullData.map(dim => ({ ...dim }));
|
|
98
81
|
}
|
|
99
82
|
|
|
100
83
|
render() {
|
|
@@ -117,26 +100,22 @@ class FilterLoadMoreDemo extends LitElement {
|
|
|
117
100
|
}
|
|
118
101
|
|
|
119
102
|
_addKeys(dimension, addCount, searchValue = '') {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
dimension.hasMore = false;
|
|
130
|
-
for (const v of dimData.values) {
|
|
131
|
-
if (v.key in dimension.values || !this._textIsInSearch(searchValue, v.text)) continue;
|
|
132
|
-
if (total <= keys.length) {
|
|
133
|
-
dimension.hasMore = true;
|
|
134
|
-
break;
|
|
103
|
+
dimension.loadCount += addCount;
|
|
104
|
+
const keys = dimension.values.filter(val => this._textIsInSearch(searchValue, val.text));
|
|
105
|
+
const selectedKeys = [];
|
|
106
|
+
const unselectedKeys = [];
|
|
107
|
+
for (const val of keys) {
|
|
108
|
+
if (val.selected) {
|
|
109
|
+
selectedKeys.push(val.key);
|
|
110
|
+
} else {
|
|
111
|
+
unselectedKeys.push(val.key);
|
|
135
112
|
}
|
|
136
|
-
dimension.values[v.key] = { ...v };
|
|
137
|
-
keys.push(v.key);
|
|
138
113
|
}
|
|
139
|
-
|
|
114
|
+
|
|
115
|
+
dimension.loadCount = Math.max(selectedKeys.length, dimension.loadCount);
|
|
116
|
+
dimension.hasMore = keys.length > dimension.loadCount;
|
|
117
|
+
|
|
118
|
+
return selectedKeys.concat(unselectedKeys).slice(0, dimension.loadCount);
|
|
140
119
|
}
|
|
141
120
|
|
|
142
121
|
_handleFilterChange(e) {
|
|
@@ -171,12 +150,8 @@ class FilterLoadMoreDemo extends LitElement {
|
|
|
171
150
|
const dimension = this._dimensions.find(dim => dim.key === dimensionKey);
|
|
172
151
|
const dimData = FullData.find(dim => dim.key === dimensionKey);
|
|
173
152
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
if (!dimension.values[valKey].selected) delete dimension.values[valKey];
|
|
177
|
-
else if (this._textIsInSearch(e.detail.value, dimension.values[valKey].text)) selectedCount++;
|
|
178
|
-
}
|
|
179
|
-
const keysToDisplay = this._addKeys(dimension, dimData.initialCount - selectedCount, e.detail.value);
|
|
153
|
+
dimension.loadCount = 0;
|
|
154
|
+
const keysToDisplay = this._addKeys(dimension, dimData.loadCount, e.detail.value);
|
|
180
155
|
|
|
181
156
|
this.requestUpdate();
|
|
182
157
|
await this.updateComplete;
|
|
@@ -887,7 +887,7 @@ class Filter extends FocusMixin(LocalizeCoreElement(LitElement)) {
|
|
|
887
887
|
const dimensionKey = e.target.parentNode.id.slice(SET_DIMENSION_ID_PREFIX.length);
|
|
888
888
|
const dimension = this._getDimensionByKey(dimensionKey);
|
|
889
889
|
|
|
890
|
-
this.requestFilterLoadMoreEvent(dimensionKey, dimension.
|
|
890
|
+
this.requestFilterLoadMoreEvent(dimensionKey, dimension.searchValue, () => {
|
|
891
891
|
const menu = this.shadowRoot.querySelector('d2l-dropdown-menu');
|
|
892
892
|
menu ? menu.addEventListener('d2l-dropdown-position', e.detail.complete, { once: true }) : e.detail.complete();
|
|
893
893
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightspace-ui/core",
|
|
3
|
-
"version": "3.184.
|
|
3
|
+
"version": "3.184.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",
|