@brightspace-ui/core 1.217.0 → 1.218.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/filter/README.md +1 -0
- package/components/filter/filter-dimension-set.js +7 -1
- package/components/filter/filter.js +58 -0
- package/controllers/subscriber/README.md +3 -3
- package/controllers/subscriber/subscriberControllers.js +4 -4
- package/custom-elements.json +13 -0
- package/package.json +1 -1
|
@@ -189,6 +189,7 @@ Set dimension on mobile:
|
|
|
189
189
|
| `select-all` | Boolean | Whether to show a select all checkbox and selection summary for this dimension |
|
|
190
190
|
| `selection-single` | Boolean | Whether only one value can be selected at a time for this dimension |
|
|
191
191
|
| `text` | String, required | Text for the dimension in the menu |
|
|
192
|
+
| `value-only-active-filter-text` | Boolean | Whether to hide the dimension in the text sent to active filter subscribers |
|
|
192
193
|
<!-- docs: end hidden content -->
|
|
193
194
|
|
|
194
195
|
## Filter Dimension: Set Value [d2l-filter-dimension-set-value]
|
|
@@ -38,7 +38,12 @@ class FilterDimensionSet extends LitElement {
|
|
|
38
38
|
* REQUIRED: The text that is displayed for the dimension title
|
|
39
39
|
* @type {string}
|
|
40
40
|
*/
|
|
41
|
-
text: { type: String }
|
|
41
|
+
text: { type: String },
|
|
42
|
+
/**
|
|
43
|
+
* Whether to hide the dimension in the text sent to active filter subscribers
|
|
44
|
+
* @type {boolean}
|
|
45
|
+
*/
|
|
46
|
+
valueOnlyActiveFilterText: { type: Boolean, attribute: 'value-only-active-filter-text' }
|
|
42
47
|
};
|
|
43
48
|
}
|
|
44
49
|
|
|
@@ -49,6 +54,7 @@ class FilterDimensionSet extends LitElement {
|
|
|
49
54
|
this.selectAll = false;
|
|
50
55
|
this.selectionSingle = false;
|
|
51
56
|
this.text = '';
|
|
57
|
+
this.valueOnlyActiveFilterText = false;
|
|
52
58
|
this._slot = null;
|
|
53
59
|
}
|
|
54
60
|
|
|
@@ -23,6 +23,7 @@ import { ifDefined } from 'lit-html/directives/if-defined.js';
|
|
|
23
23
|
import { LocalizeCoreElement } from '../../lang/localize-core-element.js';
|
|
24
24
|
import { offscreenStyles } from '../offscreen/offscreen.js';
|
|
25
25
|
import { RtlMixin } from '../../mixins/rtl-mixin.js';
|
|
26
|
+
import { SubscriberRegistryController } from '../../controllers/subscriber/subscriberControllers.js';
|
|
26
27
|
|
|
27
28
|
const ARROWLEFT_KEY_CODE = 37;
|
|
28
29
|
const ESCAPE_KEY_CODE = 27;
|
|
@@ -143,6 +144,22 @@ class Filter extends LocalizeCoreElement(RtlMixin(LitElement)) {
|
|
|
143
144
|
this._dimensions = [];
|
|
144
145
|
this._openedDimensions = [];
|
|
145
146
|
this._totalAppliedCount = 0;
|
|
147
|
+
|
|
148
|
+
this._activeFilters = null;
|
|
149
|
+
this._activeFiltersSubscribers = new SubscriberRegistryController(this,
|
|
150
|
+
{ onSubscribe: this._updateActiveFiltersSubscriber.bind(this), updateSubscribers: this._updateActiveFiltersSubscribers.bind(this) },
|
|
151
|
+
{}
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
connectedCallback() {
|
|
156
|
+
super.connectedCallback();
|
|
157
|
+
this._activeFiltersSubscribers.hostConnected();
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
disconnectedCallback() {
|
|
161
|
+
super.disconnectedCallback();
|
|
162
|
+
this._activeFiltersSubscribers.hostDisconnected();
|
|
146
163
|
}
|
|
147
164
|
|
|
148
165
|
firstUpdated(changedProperties) {
|
|
@@ -217,6 +234,10 @@ class Filter extends LocalizeCoreElement(RtlMixin(LitElement)) {
|
|
|
217
234
|
if (opener) opener.focus();
|
|
218
235
|
}
|
|
219
236
|
|
|
237
|
+
getSubscriberController() {
|
|
238
|
+
return this._activeFiltersSubscribers;
|
|
239
|
+
}
|
|
240
|
+
|
|
220
241
|
requestFilterClearAll() {
|
|
221
242
|
this._handleClearAll();
|
|
222
243
|
}
|
|
@@ -423,6 +444,8 @@ class Filter extends LocalizeCoreElement(RtlMixin(LitElement)) {
|
|
|
423
444
|
}));
|
|
424
445
|
this._changeEventsToDispatch = new Map();
|
|
425
446
|
this._changeEventTimeout = null;
|
|
447
|
+
|
|
448
|
+
this._activeFiltersSubscribers.updateSubscribers();
|
|
426
449
|
}
|
|
427
450
|
|
|
428
451
|
_dispatchDimensionFirstOpenEvent(key) {
|
|
@@ -511,9 +534,11 @@ class Filter extends LocalizeCoreElement(RtlMixin(LitElement)) {
|
|
|
511
534
|
dimension.appliedCount--;
|
|
512
535
|
this._totalAppliedCount--;
|
|
513
536
|
}
|
|
537
|
+
this._activeFiltersSubscribers.updateSubscribers();
|
|
514
538
|
} else if (prop === 'values') {
|
|
515
539
|
if (dimension.searchValue) shouldSearch = true;
|
|
516
540
|
shouldRecount = true;
|
|
541
|
+
this._activeFiltersSubscribers.updateSubscribers();
|
|
517
542
|
}
|
|
518
543
|
});
|
|
519
544
|
|
|
@@ -609,6 +634,7 @@ class Filter extends LocalizeCoreElement(RtlMixin(LitElement)) {
|
|
|
609
634
|
info.searchType = dimension.searchType;
|
|
610
635
|
info.selectionSingle = dimension.selectionSingle;
|
|
611
636
|
if (dimension.selectAll && !dimension.selectionSingle) info.selectAllIdPrefix = SET_DIMENSION_ID_PREFIX;
|
|
637
|
+
info.valueOnlyActiveFilterText = dimension.valueOnlyActiveFilterText;
|
|
612
638
|
const values = dimension._getValues();
|
|
613
639
|
info.values = values;
|
|
614
640
|
break;
|
|
@@ -619,6 +645,7 @@ class Filter extends LocalizeCoreElement(RtlMixin(LitElement)) {
|
|
|
619
645
|
});
|
|
620
646
|
|
|
621
647
|
this._setFilterCounts();
|
|
648
|
+
this._activeFiltersSubscribers.updateSubscribers();
|
|
622
649
|
}
|
|
623
650
|
|
|
624
651
|
_isDimensionEmpty(dimension) {
|
|
@@ -717,6 +744,37 @@ class Filter extends LocalizeCoreElement(RtlMixin(LitElement)) {
|
|
|
717
744
|
e.stopPropagation();
|
|
718
745
|
}
|
|
719
746
|
|
|
747
|
+
_updateActiveFilters() {
|
|
748
|
+
const activeFilters = [];
|
|
749
|
+
|
|
750
|
+
this._dimensions.forEach(dimension => {
|
|
751
|
+
switch (dimension.type) {
|
|
752
|
+
case 'd2l-filter-dimension-set': {
|
|
753
|
+
dimension.values.forEach(value => {
|
|
754
|
+
if (value.selected) {
|
|
755
|
+
const keyObject = { dimension: dimension.key, value: value.key };
|
|
756
|
+
const text = dimension.valueOnlyActiveFilterText ? value.text : `${dimension.text}: ${value.text}`;
|
|
757
|
+
activeFilters.push({ keyObject: keyObject, text: text });
|
|
758
|
+
}
|
|
759
|
+
});
|
|
760
|
+
break;
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
});
|
|
764
|
+
|
|
765
|
+
this._activeFilters = activeFilters;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
_updateActiveFiltersSubscriber(subscriber) {
|
|
769
|
+
if (!this._activeFilters) this._updateActiveFilters();
|
|
770
|
+
subscriber.updateActiveFilters(this.id, this._activeFilters);
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
_updateActiveFiltersSubscribers(subscribers) {
|
|
774
|
+
this._updateActiveFilters();
|
|
775
|
+
subscribers.forEach(subscriber => subscriber.updateActiveFilters(this.id, this._activeFilters));
|
|
776
|
+
}
|
|
777
|
+
|
|
720
778
|
}
|
|
721
779
|
|
|
722
780
|
customElements.define('d2l-filter', Filter);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Subscriber Controllers
|
|
2
2
|
|
|
3
|
-
The `SubscriberRegistryController` and the corresponding `*SubscriberController`s can be used to create a subscription system within your app. Components can
|
|
3
|
+
The `SubscriberRegistryController` and the corresponding `*SubscriberController`s can be used to create a subscription system within your app. Components can set up a subscriber registry instance to keep track of all components subscribed to them with the `SubscriberRegistryController`. Whenever it makes sense to do so, they can iterate over their subscribers to perform some action, update them with new data, etc. Components can subscribe themselves to different registries using the `IdSubscriberController` or the `EventSubscriberController`. This system supports a many-to-many relationship - registry components can contain multiple registry instances with multiple subscribers in each, and subscriber components can subscribe to multiple different registries.
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
@@ -27,7 +27,7 @@ class CableSubscription extends LitElement {
|
|
|
27
27
|
{ onSubscribe: this._unlockKidsChannels.bind(this) }, {});
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
getSubscriberController(controllerId) {
|
|
31
31
|
if (controllerId === 'sports') {
|
|
32
32
|
return this._sportsSubscribers;
|
|
33
33
|
} else if (controllerId === 'movies') {
|
|
@@ -51,7 +51,7 @@ class CableSubscription extends LitElement {
|
|
|
51
51
|
|
|
52
52
|
When creating the controller, you can pass in callbacks to run whenever a subscriber is added, removed, or `updateSubscribers` is called (which handles request debouncing for you).
|
|
53
53
|
|
|
54
|
-
The `*subscriberController`s will use a `
|
|
54
|
+
The `*subscriberController`s will use a `getSubscriberController` method that needs to be exposed on the registry component. If you only have one `SubscriberRegistryController` you can simple return that. If you have multiple, you will return the proper controller depending on the id the subscriber component passed to you.
|
|
55
55
|
|
|
56
56
|
Once this has been set up, components can subscribe to particular registries two different ways:
|
|
57
57
|
1. Using a matching event name with `EventSubscriberController`. The component will need to be a child of the registry component for this to work.
|
|
@@ -90,7 +90,7 @@ export class EventSubscriberController {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
hostDisconnected() {
|
|
93
|
-
if (this._registry) this._registry.
|
|
93
|
+
if (this._registry) this._registry.getSubscriberController(this._controllerId).unsubscribe(this._host);
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
}
|
|
@@ -114,7 +114,7 @@ export class IdSubscriberController {
|
|
|
114
114
|
if (this._registryObserver) this._registryObserver.disconnect();
|
|
115
115
|
this._timeouts.forEach(timeoutId => clearTimeout(timeoutId));
|
|
116
116
|
this._registries.forEach(registry => {
|
|
117
|
-
registry.
|
|
117
|
+
registry.getSubscriberController(this._controllerId).unsubscribe(this._host);
|
|
118
118
|
});
|
|
119
119
|
}
|
|
120
120
|
|
|
@@ -123,7 +123,7 @@ export class IdSubscriberController {
|
|
|
123
123
|
|
|
124
124
|
if (this._registryObserver) this._registryObserver.disconnect();
|
|
125
125
|
this._registries.forEach(registry => {
|
|
126
|
-
registry.
|
|
126
|
+
registry.getSubscriberController(this._controllerId).unsubscribe(this._host);
|
|
127
127
|
if (this._callbacks.onUnsubscribe) this._callbacks.onUnsubscribe(registry.id);
|
|
128
128
|
});
|
|
129
129
|
this._registries = new Map();
|
|
@@ -168,7 +168,7 @@ export class IdSubscriberController {
|
|
|
168
168
|
if (this._registries.get(registryId) === registryComponent) return;
|
|
169
169
|
|
|
170
170
|
if (registryComponent) {
|
|
171
|
-
registryComponent.
|
|
171
|
+
registryComponent.getSubscriberController(this._controllerId).subscribe(this._host);
|
|
172
172
|
this._registries.set(registryId, registryComponent);
|
|
173
173
|
if (this._callbacks.onSubscribe) this._callbacks.onSubscribe(registryComponent);
|
|
174
174
|
} else {
|
package/custom-elements.json
CHANGED
|
@@ -2992,6 +2992,12 @@
|
|
|
2992
2992
|
"description": "REQUIRED: The text that is displayed for the dimension title",
|
|
2993
2993
|
"type": "string",
|
|
2994
2994
|
"default": "\"\""
|
|
2995
|
+
},
|
|
2996
|
+
{
|
|
2997
|
+
"name": "value-only-active-filter-text",
|
|
2998
|
+
"description": "Whether to hide the dimension in the text sent to active filter subscribers",
|
|
2999
|
+
"type": "boolean",
|
|
3000
|
+
"default": "false"
|
|
2995
3001
|
}
|
|
2996
3002
|
],
|
|
2997
3003
|
"properties": [
|
|
@@ -3035,6 +3041,13 @@
|
|
|
3035
3041
|
"description": "REQUIRED: The text that is displayed for the dimension title",
|
|
3036
3042
|
"type": "string",
|
|
3037
3043
|
"default": "\"\""
|
|
3044
|
+
},
|
|
3045
|
+
{
|
|
3046
|
+
"name": "valueOnlyActiveFilterText",
|
|
3047
|
+
"attribute": "value-only-active-filter-text",
|
|
3048
|
+
"description": "Whether to hide the dimension in the text sent to active filter subscribers",
|
|
3049
|
+
"type": "boolean",
|
|
3050
|
+
"default": "false"
|
|
3038
3051
|
}
|
|
3039
3052
|
],
|
|
3040
3053
|
"slots": [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightspace-ui/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.218.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",
|