@brightspace-ui/core 2.112.1 → 2.112.3

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.
@@ -2,11 +2,12 @@ import '../button/button-icon.js';
2
2
  import '../loading-spinner/loading-spinner.js';
3
3
  import { css, html, nothing } from 'lit';
4
4
  import { EventSubscriberController } from '../../controllers/subscriber/subscriberControllers.js';
5
+ import { SkeletonMixin } from '../skeleton/skeleton-mixin.js';
5
6
 
6
7
  const dragIntervalDelay = 100;
7
8
  const dragHoverDropTime = 1000;
8
9
 
9
- export const ListItemExpandCollapseMixin = superclass => class extends superclass {
10
+ export const ListItemExpandCollapseMixin = superclass => class extends SkeletonMixin(superclass) {
10
11
 
11
12
  static get properties() {
12
13
  return {
@@ -127,6 +128,7 @@ export const ListItemExpandCollapseMixin = superclass => class extends superclas
127
128
  }
128
129
  return html`
129
130
  <d2l-button-icon
131
+ class="d2l-skeletize"
130
132
  icon="${this.expanded ? 'tier1:arrow-collapse-small' : 'tier1:arrow-expand-small' }"
131
133
  aria-expanded="${this.expanded ? 'true' : 'false'}"
132
134
  text="${this.label}"
@@ -56,12 +56,13 @@ export const PageableMixin = superclass => class extends CollectionMixin(supercl
56
56
  this._itemShowingCount = this._getItemShowingCount();
57
57
  }
58
58
 
59
- _updatePageableSubscriber(subscriber) {
59
+ _updatePageableSubscriber(subscriber, doUpdate = true) {
60
+ if (doUpdate) this._updateItemShowingCount();
60
61
  subscriber._pageableInfo = { itemShowingCount: this._itemShowingCount, itemCount: this.itemCount };
61
62
  }
62
63
 
63
64
  _updatePageableSubscribers(subscribers) {
64
- subscribers.forEach(subscriber => this._updatePageableSubscriber(subscriber));
65
+ subscribers.forEach(subscriber => this._updatePageableSubscriber(subscriber, false));
65
66
  }
66
67
 
67
68
  };
@@ -170,8 +170,8 @@
170
170
  <li><d2l-selection-input key="tom" label="Tomato"></d2l-selection-input>Tomato</li>
171
171
  <li><d2l-selection-input key="onion" label="Onion"></d2l-selection-input>Onion</li>
172
172
  </ul>
173
- <d2l-pager-load-more has-more page-size="1"></d2l-pager-load-more>
174
173
  </d2l-demo-selection-pageable>
174
+ <d2l-pager-load-more has-more page-size="1" pageable-for="collection-1"></d2l-pager-load-more>
175
175
  <d2l-selection-action selection-for="collection-1" text="Save" requires-selection></d2l-selection-action>
176
176
  </div>
177
177
 
@@ -9,11 +9,39 @@ class BaseController {
9
9
  this._name = name;
10
10
  this._options = options;
11
11
  this._eventName = `d2l-subscribe-${this._name}`;
12
- this._subscriptionComplete = Promise.resolve();
13
12
  }
14
13
  }
15
14
 
16
15
  class BaseSubscriber extends BaseController {
16
+ constructor() {
17
+ super(...arguments);
18
+
19
+ this._subscriptionComplete = Promise.resolve();
20
+ this._timeouts = new Set();
21
+ }
22
+
23
+ hostDisconnected() {
24
+ this._timeouts.forEach(timeoutId => clearTimeout(timeoutId));
25
+ }
26
+
27
+ _keepTrying(callback, interval, maxTime, errorPayload, elapsedTime = 0) {
28
+ const response = callback();
29
+
30
+ if (response) return response;
31
+ if (elapsedTime >= maxTime) {
32
+ if (this._options.onError) this._options.onError(errorPayload);
33
+ return response;
34
+ }
35
+
36
+ return new Promise(resolve => {
37
+ const timeoutId = setTimeout(async() => {
38
+ this._timeouts.delete(timeoutId);
39
+ resolve(await this._keepTrying(callback, interval, maxTime, errorPayload, elapsedTime + interval));
40
+ }, interval);
41
+ this._timeouts.add(timeoutId);
42
+ });
43
+ }
44
+
17
45
  _subscribe(target = this._host, targetLabel) {
18
46
  const isBroadcast = target === this._host;
19
47
 
@@ -25,10 +53,7 @@ class BaseSubscriber extends BaseController {
25
53
  target.dispatchEvent(evt);
26
54
 
27
55
  const { registry, registryController } = evt.detail;
28
- if (!registry) {
29
- if (this._options.onError) this._options.onError();
30
- return;
31
- }
56
+ if (!registry) return false;
32
57
 
33
58
  if (targetLabel) {
34
59
  this._registries.set(targetLabel, registry);
@@ -39,6 +64,7 @@ class BaseSubscriber extends BaseController {
39
64
  }
40
65
 
41
66
  if (this._options.onSubscribe) this._options.onSubscribe(registry);
67
+ return true;
42
68
  }
43
69
  }
44
70
 
@@ -111,16 +137,11 @@ export class EventSubscriberController extends BaseSubscriber {
111
137
  }
112
138
 
113
139
  hostConnected() {
114
- // delay subscription otherwise import/upgrade order can cause selection mixin to miss event
115
- this._subscriptionComplete = new Promise(resolve => {
116
- requestAnimationFrame(() => {
117
- this._subscribe();
118
- resolve();
119
- });
120
- });
140
+ this._subscriptionComplete = this._keepTrying(() => this._subscribe(), 40, 400);
121
141
  }
122
142
 
123
143
  hostDisconnected() {
144
+ super.hostDisconnected();
124
145
  if (this._registryController) this._registryController.unsubscribe(this._host);
125
146
  }
126
147
 
@@ -135,7 +156,6 @@ export class IdSubscriberController extends BaseSubscriber {
135
156
  this._idPropertyValue = this._idPropertyName ? this._host[this._idPropertyName] : undefined;
136
157
  this._registries = new Map();
137
158
  this._registryControllers = new Map();
138
- this._timeouts = new Set();
139
159
  }
140
160
 
141
161
  get registries() {
@@ -143,8 +163,8 @@ export class IdSubscriberController extends BaseSubscriber {
143
163
  }
144
164
 
145
165
  hostDisconnected() {
166
+ super.hostDisconnected();
146
167
  if (this._registryObserver) this._registryObserver.disconnect();
147
- this._timeouts.forEach(timeoutId => clearTimeout(timeoutId));
148
168
  this._registryControllers.forEach(controller => {
149
169
  controller.unsubscribe(this._host);
150
170
  });
@@ -182,33 +202,25 @@ export class IdSubscriberController extends BaseSubscriber {
182
202
 
183
203
  registryIds = registryIds.trim().split(' ');
184
204
  registryIds.forEach(registryId => {
185
- this._updateRegistry(registryId, 0);
205
+ this._keepTrying(() => this._updateRegistry(registryId), 100, 3000, registryId);
186
206
  });
187
207
  }
188
208
 
189
- _updateRegistry(registryId, elapsedTime) {
190
- let registryComponent = this._host.getRootNode().querySelector(`#${cssEscape(registryId)}`);
191
- if (!registryComponent && this._options.onError) {
192
- if (elapsedTime < 3000) {
193
- const timeoutId = setTimeout(() => {
194
- this._timeouts.delete(timeoutId);
195
- this._updateRegistry(registryId, elapsedTime + 100);
196
- }, 100);
197
- this._timeouts.add(timeoutId);
198
- } else {
199
- this._options.onError(registryId);
200
- }
201
- }
209
+ _updateRegistry(registryId) {
210
+ const registryComponent = this._host.getRootNode().querySelector(`#${cssEscape(registryId)}`) || undefined;
202
211
 
203
- registryComponent = registryComponent || undefined;
204
- if (this._registries.get(registryId) === registryComponent) return;
212
+ if (this._registries.get(registryId) === registryComponent) return registryComponent;
205
213
 
206
- if (registryComponent) this._subscribe(registryComponent, registryId);
207
- else {
214
+ if (registryComponent) {
215
+ const success = this._subscribe(registryComponent, registryId);
216
+ if (!success && this._options.onError) this._options.onError(registryId);
217
+ } else {
208
218
  this._registries.delete(registryId);
209
219
  this._registryControllers.delete(registryId);
210
220
  if (this._options.onUnsubscribe) this._options.onUnsubscribe(registryId);
211
221
  }
222
+
223
+ return registryComponent;
212
224
  }
213
225
 
214
226
  }
@@ -7815,12 +7815,6 @@
7815
7815
  "type": "boolean",
7816
7816
  "default": "false"
7817
7817
  },
7818
- {
7819
- "name": "skeleton",
7820
- "description": "Renders the input as a [skeleton loader](https://github.com/BrightspaceUI/core/tree/main/components/skeleton)",
7821
- "type": "boolean",
7822
- "default": "false"
7823
- },
7824
7818
  {
7825
7819
  "name": "drag-handle-text",
7826
7820
  "description": "**Drag & drop:** The drag-handle label for assistive technology. If implementing drag & drop, you should change this to dynamically announce what the drag-handle is moving for assistive technology in keyboard mode.",
@@ -7858,6 +7852,12 @@
7858
7852
  "description": "Default state for expand collapse toggle - if not set, collapsed will be the default state",
7859
7853
  "type": "boolean"
7860
7854
  },
7855
+ {
7856
+ "name": "skeleton",
7857
+ "description": "Renders the input as a [skeleton loader](https://github.com/BrightspaceUI/core/tree/main/components/skeleton)",
7858
+ "type": "boolean",
7859
+ "default": "false"
7860
+ },
7861
7861
  {
7862
7862
  "name": "labelled-by",
7863
7863
  "description": "The id of element that provides the label for this element",
@@ -7921,13 +7921,6 @@
7921
7921
  {
7922
7922
  "name": "selectionInfo"
7923
7923
  },
7924
- {
7925
- "name": "skeleton",
7926
- "attribute": "skeleton",
7927
- "description": "Renders the input as a [skeleton loader](https://github.com/BrightspaceUI/core/tree/main/components/skeleton)",
7928
- "type": "boolean",
7929
- "default": "false"
7930
- },
7931
7924
  {
7932
7925
  "name": "dragHandleText",
7933
7926
  "attribute": "drag-handle-text",
@@ -7972,6 +7965,13 @@
7972
7965
  "description": "Default state for expand collapse toggle - if not set, collapsed will be the default state",
7973
7966
  "type": "boolean"
7974
7967
  },
7968
+ {
7969
+ "name": "skeleton",
7970
+ "attribute": "skeleton",
7971
+ "description": "Renders the input as a [skeleton loader](https://github.com/BrightspaceUI/core/tree/main/components/skeleton)",
7972
+ "type": "boolean",
7973
+ "default": "false"
7974
+ },
7975
7975
  {
7976
7976
  "name": "documentLocaleSettings",
7977
7977
  "default": "\"getDocumentLocaleSettings()\""
@@ -8149,12 +8149,6 @@
8149
8149
  "type": "boolean",
8150
8150
  "default": "false"
8151
8151
  },
8152
- {
8153
- "name": "skeleton",
8154
- "description": "Renders the input as a [skeleton loader](https://github.com/BrightspaceUI/core/tree/main/components/skeleton)",
8155
- "type": "boolean",
8156
- "default": "false"
8157
- },
8158
8152
  {
8159
8153
  "name": "drag-handle-text",
8160
8154
  "description": "**Drag & drop:** The drag-handle label for assistive technology. If implementing drag & drop, you should change this to dynamically announce what the drag-handle is moving for assistive technology in keyboard mode.",
@@ -8192,6 +8186,12 @@
8192
8186
  "description": "Default state for expand collapse toggle - if not set, collapsed will be the default state",
8193
8187
  "type": "boolean"
8194
8188
  },
8189
+ {
8190
+ "name": "skeleton",
8191
+ "description": "Renders the input as a [skeleton loader](https://github.com/BrightspaceUI/core/tree/main/components/skeleton)",
8192
+ "type": "boolean",
8193
+ "default": "false"
8194
+ },
8195
8195
  {
8196
8196
  "name": "labelled-by",
8197
8197
  "description": "The id of element that provides the label for this element",
@@ -8262,13 +8262,6 @@
8262
8262
  {
8263
8263
  "name": "selectionInfo"
8264
8264
  },
8265
- {
8266
- "name": "skeleton",
8267
- "attribute": "skeleton",
8268
- "description": "Renders the input as a [skeleton loader](https://github.com/BrightspaceUI/core/tree/main/components/skeleton)",
8269
- "type": "boolean",
8270
- "default": "false"
8271
- },
8272
8265
  {
8273
8266
  "name": "dragHandleText",
8274
8267
  "attribute": "drag-handle-text",
@@ -8313,6 +8306,13 @@
8313
8306
  "description": "Default state for expand collapse toggle - if not set, collapsed will be the default state",
8314
8307
  "type": "boolean"
8315
8308
  },
8309
+ {
8310
+ "name": "skeleton",
8311
+ "attribute": "skeleton",
8312
+ "description": "Renders the input as a [skeleton loader](https://github.com/BrightspaceUI/core/tree/main/components/skeleton)",
8313
+ "type": "boolean",
8314
+ "default": "false"
8315
+ },
8316
8316
  {
8317
8317
  "name": "documentLocaleSettings",
8318
8318
  "default": "\"getDocumentLocaleSettings()\""
@@ -8623,12 +8623,6 @@
8623
8623
  "type": "boolean",
8624
8624
  "default": "false"
8625
8625
  },
8626
- {
8627
- "name": "skeleton",
8628
- "description": "Renders the input as a [skeleton loader](https://github.com/BrightspaceUI/core/tree/main/components/skeleton)",
8629
- "type": "boolean",
8630
- "default": "false"
8631
- },
8632
8626
  {
8633
8627
  "name": "drag-handle-text",
8634
8628
  "description": "**Drag & drop:** The drag-handle label for assistive technology. If implementing drag & drop, you should change this to dynamically announce what the drag-handle is moving for assistive technology in keyboard mode.",
@@ -8666,6 +8660,12 @@
8666
8660
  "description": "Default state for expand collapse toggle - if not set, collapsed will be the default state",
8667
8661
  "type": "boolean"
8668
8662
  },
8663
+ {
8664
+ "name": "skeleton",
8665
+ "description": "Renders the input as a [skeleton loader](https://github.com/BrightspaceUI/core/tree/main/components/skeleton)",
8666
+ "type": "boolean",
8667
+ "default": "false"
8668
+ },
8669
8669
  {
8670
8670
  "name": "labelled-by",
8671
8671
  "description": "The id of element that provides the label for this element",
@@ -8741,13 +8741,6 @@
8741
8741
  {
8742
8742
  "name": "selectionInfo"
8743
8743
  },
8744
- {
8745
- "name": "skeleton",
8746
- "attribute": "skeleton",
8747
- "description": "Renders the input as a [skeleton loader](https://github.com/BrightspaceUI/core/tree/main/components/skeleton)",
8748
- "type": "boolean",
8749
- "default": "false"
8750
- },
8751
8744
  {
8752
8745
  "name": "dragHandleText",
8753
8746
  "attribute": "drag-handle-text",
@@ -8792,6 +8785,13 @@
8792
8785
  "description": "Default state for expand collapse toggle - if not set, collapsed will be the default state",
8793
8786
  "type": "boolean"
8794
8787
  },
8788
+ {
8789
+ "name": "skeleton",
8790
+ "attribute": "skeleton",
8791
+ "description": "Renders the input as a [skeleton loader](https://github.com/BrightspaceUI/core/tree/main/components/skeleton)",
8792
+ "type": "boolean",
8793
+ "default": "false"
8794
+ },
8795
8795
  {
8796
8796
  "name": "documentLocaleSettings",
8797
8797
  "default": "\"getDocumentLocaleSettings()\""
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "2.112.1",
3
+ "version": "2.112.3",
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",