@brightspace-ui/core 1.177.1 → 1.178.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.
@@ -26,7 +26,7 @@ The `d2l-filter` component allows a user to filter on one or more dimensions of
26
26
  | `disabled` | Boolean, default: `false` | Disables the dropdown opener for the filter |
27
27
 
28
28
  **Events:**
29
- * `d2l-filter-change`: dispatched when any filter value has changed (may contain info about multiple changes)
29
+ * `d2l-filter-change`: dispatched when any filter value has changed (may contain info about multiple dimensions and multiple changes in each)
30
30
  * `d2l-filter-dimension-first-open`: dispatched when a dimension is opened for the first time (if there is only one dimension, this will be dispatched when the dropdown is first opened)
31
31
  * `d2l-filter-dimension-search`: dispatched when a dimension that supports searching and has the "manual" search-type is searched
32
32
 
@@ -50,16 +50,19 @@ class FilterSearchDemo extends LitElement {
50
50
  }
51
51
 
52
52
  _handleFilterChange(e) {
53
- (e.detail.changes.length === 1) ?
54
- console.log(`Filter selection changed for dimension "${e.detail.changes[0].dimension}":`, e.detail.changes[0].value) : // eslint-disable-line no-console
55
- console.log('Batch filter selection changed:', e.detail.changes); // eslint-disable-line no-console
53
+ (e.detail.dimensions.length === 1) ?
54
+ console.log(`Filter selection changed for dimension "${e.detail.dimensions[0].dimensionKey}":`, e.detail.dimensions[0].changes) : // eslint-disable-line no-console
55
+ console.log('Batch filter selection changed:', e.detail.dimensions); // eslint-disable-line no-console
56
56
 
57
- e.detail.changes.forEach(change => {
58
- if (change.dimension === 'event') {
59
- this._fullData.find(value => value.key === change.value.key).selected = change.value.selected;
60
- } else if (change.dimension === 'event-single') {
61
- this._fullDataSingle.find(value => value.key === change.value.key).selected = change.value.selected;
62
- }
57
+ e.detail.dimensions.forEach(dimension => {
58
+ if (!dimension.dimensionKey.includes('event')) return;
59
+ dimension.changes.forEach(change => {
60
+ if (dimension.dimensionKey === 'event') {
61
+ this._fullData.find(value => value.key === change.valueKey).selected = change.selected;
62
+ } else if (change.dimension === 'event-single') {
63
+ this._fullDataSingle.find(value => value.key === change.valueKey).selected = change.selected;
64
+ }
65
+ });
63
66
  });
64
67
  }
65
68
 
@@ -112,9 +112,9 @@
112
112
 
113
113
  <script type="module">
114
114
  document.addEventListener('d2l-filter-change', e => {
115
- (e.detail.changes.length === 1) ?
116
- console.log(`Filter selection changed for dimension "${e.detail.changes[0].dimension}":`, e.detail.changes[0].value) : // eslint-disable-line no-console
117
- console.log('Batch filter selection changed:', e.detail.changes); // eslint-disable-line no-console
115
+ (e.detail.dimensions.length === 1) ?
116
+ console.log(`Filter selection changed for dimension "${e.detail.dimensions[0].dimensionKey}":`, e.detail.dimensions[0].changes) : // eslint-disable-line no-console
117
+ console.log('Batch filter selection changed:', e.detail.dimensions); // eslint-disable-line no-console
118
118
  });
119
119
 
120
120
  document.addEventListener('d2l-filter-dimension-first-open', e => {
@@ -333,22 +333,31 @@ class Filter extends LocalizeCoreElement(RtlMixin(LitElement)) {
333
333
  `;
334
334
  }
335
335
 
336
- _dispatchChangeEvent(eventKey, eventDetail) {
337
- this._changeEventsToDispatch.set(eventKey, eventDetail);
336
+ _dispatchChangeEvent(dimension, change) {
337
+ this._setDimensionChangeEvent(dimension, change);
338
338
 
339
339
  if (!this._changeEventTimeout) {
340
340
  this._changeEventTimeout = setTimeout(() => {
341
- this.dispatchEvent(new CustomEvent('d2l-filter-change', {
342
- bubbles: true,
343
- composed: false,
344
- detail: { changes: Array.from(this._changeEventsToDispatch.values()) }
345
- }));
346
- this._changeEventsToDispatch = new Map();
347
- this._changeEventTimeout = null;
341
+ this._dispatchChangeEventNow();
348
342
  }, 200);
349
343
  }
350
344
  }
351
345
 
346
+ _dispatchChangeEventNow() {
347
+ const dimensions = Array.from(this._changeEventsToDispatch.values());
348
+ dimensions.forEach(dimension => {
349
+ dimension.changes = Array.from(dimension.changes.values());
350
+ });
351
+
352
+ this.dispatchEvent(new CustomEvent('d2l-filter-change', {
353
+ bubbles: true,
354
+ composed: false,
355
+ detail: { dimensions: dimensions }
356
+ }));
357
+ this._changeEventsToDispatch = new Map();
358
+ this._changeEventTimeout = null;
359
+ }
360
+
352
361
  _dispatchDimensionFirstOpenEvent(key) {
353
362
  if (!this._openedDimensions.includes(key)) {
354
363
  this.dispatchEvent(new CustomEvent('d2l-filter-dimension-first-open', { bubbles: true, composed: false, detail: { key: key } }));
@@ -385,7 +394,7 @@ class Filter extends LocalizeCoreElement(RtlMixin(LitElement)) {
385
394
  this._totalAppliedCount--;
386
395
  }
387
396
 
388
- this._dispatchChangeEvent(`${dimensionKey}-${valueKey}`, { dimension: dimensionKey, value: { key: valueKey, selected: selected } });
397
+ this._dispatchChangeEvent(dimension, { valueKey: valueKey, selected: selected });
389
398
  }
390
399
 
391
400
  _handleDimensionDataChange(e) {
@@ -538,6 +547,19 @@ class Filter extends LocalizeCoreElement(RtlMixin(LitElement)) {
538
547
  this.requestUpdate();
539
548
  }
540
549
 
550
+ _setDimensionChangeEvent(dimension, change) {
551
+ if (!this._changeEventsToDispatch.has(dimension.key)) {
552
+ this._changeEventsToDispatch.set(dimension.key, { dimensionKey: dimension.key, changes: new Map() });
553
+ }
554
+ const dimensionChanges = this._changeEventsToDispatch.get(dimension.key);
555
+
556
+ switch (dimension.type) {
557
+ case 'd2l-filter-dimension-set':
558
+ dimensionChanges.changes.set(change.valueKey, change);
559
+ break;
560
+ }
561
+ }
562
+
541
563
  _setFilterCounts(dimensionToRecount) {
542
564
  this._totalAppliedCount = 0;
543
565
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "1.177.1",
3
+ "version": "1.178.0",
4
4
  "description": "A collection of accessible, free, open-source web components for building Brightspace applications",
5
5
  "repository": "https://github.com/BrightspaceUI/core.git",
6
6
  "publishConfig": {