@brightspace-ui/core 2.112.2 → 2.112.4

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.
@@ -8,6 +8,7 @@ import { SkeletonMixin } from '../skeleton/skeleton-mixin.js';
8
8
  /**
9
9
  * A dot-separated list of object properties.
10
10
  * @slot - Items of the type d2l-object-property-list-item* to be added to the container
11
+ * @slot status - Slot for a single `d2l-status-indicator` to be rendered before the list
11
12
  */
12
13
  class ObjectPropertyList extends LocalizeCoreElement(SkeletonMixin(LitElement)) {
13
14
  static get properties() {
@@ -4,6 +4,7 @@ import { RtlMixin } from '../../mixins/rtl/rtl-mixin.js';
4
4
  export const offscreenStyles = css`
5
5
  .d2l-offscreen {
6
6
  height: 1px;
7
+ inset-inline-start: -10000px;
7
8
  left: -10000px;
8
9
  overflow: hidden;
9
10
  position: absolute !important;
@@ -25,6 +26,7 @@ class Offscreen extends RtlMixin(LitElement) {
25
26
  return css`
26
27
  :host {
27
28
  height: 1px;
29
+ inset-inline-start: -10000px;
28
30
  left: -10000px;
29
31
  overflow: hidden;
30
32
  position: absolute !important;
@@ -3,6 +3,7 @@
3
3
  $offset: -10000px;
4
4
 
5
5
  position: absolute !important;
6
+ inset-inline-start: $offset;
6
7
  left: $offset;
7
8
  overflow: hidden;
8
9
  width: 1px;
@@ -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
  }
@@ -9962,6 +9962,10 @@
9962
9962
  {
9963
9963
  "name": "",
9964
9964
  "description": "Items of the type d2l-object-property-list-item* to be added to the container"
9965
+ },
9966
+ {
9967
+ "name": "status",
9968
+ "description": "Slot for a single `d2l-status-indicator` to be rendered before the list"
9965
9969
  }
9966
9970
  ]
9967
9971
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "2.112.2",
3
+ "version": "2.112.4",
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",