@brightspace-ui/core 3.269.3 → 3.269.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.
@@ -45,8 +45,6 @@ class DemoPageSettings extends LitElement {
45
45
 
46
46
  constructor() {
47
47
  super();
48
- this.#handleFlagsKnownBound = this.#handleFlagsKnown.bind(this);
49
- this.#handleDocumentLanguageChangeBound = this.#handleDocumentLanguageChange.bind(this);
50
48
  const urlParams = new URLSearchParams(window.location.search);
51
49
  if (urlParams.has('lang')) {
52
50
  const newLanguageCode = urlParams.get('lang');
@@ -64,14 +62,14 @@ class DemoPageSettings extends LitElement {
64
62
 
65
63
  connectedCallback() {
66
64
  super.connectedCallback();
67
- document.addEventListener('d2l-flags-known', this.#handleFlagsKnownBound);
68
- localeSettings.addChangeListener(this.#handleDocumentLanguageChangeBound);
65
+ document.addEventListener('d2l-flags-known', this.#handleFlagsKnown);
66
+ localeSettings.addChangeListener(this.#handleDocumentLanguageChange);
69
67
  }
70
68
 
71
69
  disconnectedCallback() {
72
70
  super.disconnectedCallback();
73
- document.removeEventListener('d2l-flags-known', this.#handleFlagsKnownBound);
74
- localeSettings.removeChangeListener(this.#handleDocumentLanguageChangeBound);
71
+ document.removeEventListener('d2l-flags-known', this.#handleFlagsKnown);
72
+ localeSettings.removeChangeListener(this.#handleDocumentLanguageChange);
75
73
  }
76
74
 
77
75
  render() {
@@ -133,8 +131,20 @@ class DemoPageSettings extends LitElement {
133
131
  `;
134
132
  }
135
133
 
136
- #handleDocumentLanguageChangeBound;
137
- #handleFlagsKnownBound;
134
+ #handleDocumentLanguageChange = () => {
135
+ this._language = localeSettings.language;
136
+ const url = new URL(window.location.href);
137
+ if (this._language === 'en-us') {
138
+ url.searchParams.delete('lang');
139
+ } else {
140
+ url.searchParams.set('lang', this._language);
141
+ }
142
+ window.history.replaceState({}, '', url.toString());
143
+ };
144
+
145
+ #handleFlagsKnown = () => {
146
+ this.requestUpdate();
147
+ };
138
148
 
139
149
  #getKnownFlagsSorted() {
140
150
  return new Map([...getKnownFlags().entries()].sort((entry1, entry2) => {
@@ -181,21 +191,6 @@ class DemoPageSettings extends LitElement {
181
191
  window.history.replaceState({}, '', url.toString());
182
192
  }
183
193
 
184
- #handleDocumentLanguageChange() {
185
- this._language = localeSettings.language;
186
- const url = new URL(window.location.href);
187
- if (this._language === 'en-us') {
188
- url.searchParams.delete('lang');
189
- } else {
190
- url.searchParams.set('lang', this._language);
191
- }
192
- window.history.replaceState({}, '', url.toString());
193
- }
194
-
195
- #handleFlagsKnown() {
196
- this.requestUpdate();
197
- }
198
-
199
194
  #handleLanguageChange(e) {
200
195
  const newLanguageCode = e.target[e.target.selectedIndex].value;
201
196
  document.documentElement.dir = newLanguageCode === 'ar-sa' ? 'rtl' : 'ltr';
@@ -162,7 +162,6 @@ class Page extends ProviderMixin(LocalizeCoreElement(LitElement)) {
162
162
  'supporting-mobile': { minSize: DRAWER_MIN_HEIGHT }
163
163
  });
164
164
  this._slotVisibility = {};
165
- this.#handleWindowResizeBound = this.#handleWindowResize.bind(this);
166
165
  this.#resizeObserver = new ResizeObserver(entries => {
167
166
  for (const entry of entries) {
168
167
  if (entry.target.classList.contains('header')) {
@@ -194,13 +193,13 @@ class Page extends ProviderMixin(LocalizeCoreElement(LitElement)) {
194
193
 
195
194
  connectedCallback() {
196
195
  super.connectedCallback();
197
- window.addEventListener('resize', this.#handleWindowResizeBound);
196
+ window.addEventListener('resize', this.#handleWindowResize);
198
197
  }
199
198
 
200
199
  disconnectedCallback() {
201
200
  super.disconnectedCallback();
202
201
  this.#resizeObserver.disconnect();
203
- window.removeEventListener('resize', this.#handleWindowResizeBound);
202
+ window.removeEventListener('resize', this.#handleWindowResize);
204
203
  }
205
204
 
206
205
  firstUpdated() {
@@ -238,9 +237,12 @@ class Page extends ProviderMixin(LocalizeCoreElement(LitElement)) {
238
237
  }
239
238
  }
240
239
 
241
- #handleWindowResizeBound;
242
240
  #resizeObserver;
243
241
 
242
+ #handleWindowResize = () => {
243
+ this._panelState.updateMaxSize('supporting-mobile', this.#getMaxDrawerHeight());
244
+ };
245
+
244
246
  #getMaxDrawerHeight() {
245
247
  const reservedSpace = this._headerHeight + this._footerHeight + DIVIDER_WIDTH;
246
248
  return Math.max(DRAWER_MIN_HEIGHT, window.innerHeight - reservedSpace);
@@ -266,10 +268,6 @@ class Page extends ProviderMixin(LocalizeCoreElement(LitElement)) {
266
268
  this._slotVisibility = { ...this._slotVisibility, [key]: nodes.length !== 0 };
267
269
  }
268
270
 
269
- #handleWindowResize() {
270
- this._panelState.updateMaxSize('supporting-mobile', this.#getMaxDrawerHeight());
271
- };
272
-
273
271
  #initializePanelSizes() {
274
272
  const defaultWidth = Math.floor(this._contentWidth / 3);
275
273
  const defaultHeight = Math.floor(window.innerHeight / 2);
@@ -175,16 +175,6 @@ class Tooltip extends PopoverMixin(LitElement) {
175
175
  this.offset = 10;
176
176
  this.showTruncatedOnly = false;
177
177
  this.state = 'info';
178
-
179
- this.#handleTargetBlurBound = this.#handleTargetBlur.bind(this);
180
- this.#handleTargetClickBound = this.#handleTargetClick.bind(this);
181
- this.#handleTargetFocusBound = this.#handleTargetFocus.bind(this);
182
- this.#handleTargetMouseEnterBound = this.#handleTargetMouseEnter.bind(this);
183
- this.#handleTargetMouseLeaveBound = this.#handleTargetMouseLeave.bind(this);
184
- this.#handleTargetMutationBound = this.#handleTargetMutation.bind(this);
185
- this.#handleTargetResizeBound = this.#handleTargetResize.bind(this);
186
- this.#handleTargetTouchEndBound = this.#handleTargetTouchEnd.bind(this);
187
- this.#handleTargetTouchStartBound = this.#handleTargetTouchStart.bind(this);
188
178
  }
189
179
 
190
180
  /** @ignore */
@@ -204,7 +194,7 @@ class Tooltip extends PopoverMixin(LitElement) {
204
194
  super.connectedCallback();
205
195
  this.showing = false;
206
196
  this.#addListeners();
207
- window.addEventListener('resize', this.#handleTargetResizeBound);
197
+ window.addEventListener('resize', this.#handleTargetResize);
208
198
 
209
199
  requestAnimationFrame(() => this.#updateTarget());
210
200
  }
@@ -214,7 +204,7 @@ class Tooltip extends PopoverMixin(LitElement) {
214
204
  if (activeTooltip === this) activeTooltip = null;
215
205
 
216
206
  this.#removeListeners();
217
- window.removeEventListener('resize', this.#handleTargetResizeBound);
207
+ window.removeEventListener('resize', this.#handleTargetResize);
218
208
 
219
209
  delayTimeoutId = null;
220
210
 
@@ -273,15 +263,6 @@ class Tooltip extends PopoverMixin(LitElement) {
273
263
  return super.position();
274
264
  }
275
265
 
276
- #handleTargetBlurBound;
277
- #handleTargetClickBound;
278
- #handleTargetFocusBound;
279
- #handleTargetMouseEnterBound;
280
- #handleTargetMouseLeaveBound;
281
- #handleTargetMutationBound;
282
- #handleTargetResizeBound;
283
- #handleTargetTouchEndBound;
284
- #handleTargetTouchStartBound;
285
266
  #hoverTimeout;
286
267
  #isFocusing = false;
287
268
  #isHovering = false;
@@ -296,6 +277,77 @@ class Tooltip extends PopoverMixin(LitElement) {
296
277
  #targetSizeObserver;
297
278
  #targetMutationObserver;
298
279
 
280
+ #handleTargetBlur = () => {
281
+ this.#isFocusing = false;
282
+ this.#updateShowing();
283
+ };
284
+
285
+ #handleTargetClick = () => {
286
+ if (this.closeOnClick) this.hide();
287
+ };
288
+
289
+ #handleTargetFocus = async() => {
290
+ if (this.showTruncatedOnly) {
291
+ await this.#updateTruncating();
292
+ if (!this.#isTruncating) return;
293
+ }
294
+
295
+ if (this.disableFocusLock) {
296
+ this.showing = true;
297
+ } else {
298
+ this.#isFocusing = true;
299
+ this.#updateShowing();
300
+ }
301
+ };
302
+
303
+ #handleTargetMouseEnter = () => {
304
+ // came from tooltip so keep showing
305
+ if (this.#mouseLeftTooltip) {
306
+ this.#isHovering = true;
307
+ return;
308
+ }
309
+
310
+ this.#hoverTimeout = setTimeout(async() => {
311
+ if (this.showTruncatedOnly) {
312
+ await this.#updateTruncating();
313
+ if (!this.#isTruncating) return;
314
+ }
315
+
316
+ this.#isHovering = true;
317
+ this.#updateShowing();
318
+ }, getDelay(this.delay));
319
+ };
320
+
321
+ #handleTargetMouseLeave = () => {
322
+ clearTimeout(this.#hoverTimeout);
323
+ this.#isHovering = false;
324
+ if (this.showing) resetDelayTimeout();
325
+ setTimeout(() => this.#updateShowing(), 100); // delay to allow for mouseenter to fire if hovering on tooltip
326
+ };
327
+
328
+ #handleTargetMutation = ([m]) => {
329
+ if (!this.#target.isConnected || (m.target === this.#target && m.attributeName === 'id')) {
330
+ this.#targetMutationObserver.disconnect();
331
+ this.#updateTarget();
332
+ }
333
+ };
334
+
335
+ #handleTargetResize = () => {
336
+ this.#resizeRunSinceTruncationCheck = true;
337
+ if (!this.showing) return;
338
+ super.position();
339
+ };
340
+
341
+ #handleTargetTouchEnd = () => {
342
+ clearTimeout(this.#longPressTimeout);
343
+ };
344
+
345
+ #handleTargetTouchStart = () => {
346
+ this.#longPressTimeout = setTimeout(() => {
347
+ this.#target.focus();
348
+ }, 500);
349
+ };
350
+
299
351
  // for testing only!
300
352
  _getTarget() {
301
353
  return this.#target;
@@ -324,19 +376,19 @@ class Tooltip extends PopoverMixin(LitElement) {
324
376
 
325
377
  if (!this.#target) return;
326
378
 
327
- this.#target.addEventListener('mouseenter', this.#handleTargetMouseEnterBound);
328
- this.#target.addEventListener('mouseleave', this.#handleTargetMouseLeaveBound);
329
- this.#target.addEventListener('focus', this.#handleTargetFocusBound);
330
- this.#target.addEventListener('blur', this.#handleTargetBlurBound);
331
- this.#target.addEventListener('click', this.#handleTargetClickBound);
332
- this.#target.addEventListener('touchstart', this.#handleTargetTouchStartBound, { passive: true });
333
- this.#target.addEventListener('touchcancel', this.#handleTargetTouchEndBound);
334
- this.#target.addEventListener('touchend', this.#handleTargetTouchEndBound);
379
+ this.#target.addEventListener('mouseenter', this.#handleTargetMouseEnter);
380
+ this.#target.addEventListener('mouseleave', this.#handleTargetMouseLeave);
381
+ this.#target.addEventListener('focus', this.#handleTargetFocus);
382
+ this.#target.addEventListener('blur', this.#handleTargetBlur);
383
+ this.#target.addEventListener('click', this.#handleTargetClick);
384
+ this.#target.addEventListener('touchstart', this.#handleTargetTouchStart, { passive: true });
385
+ this.#target.addEventListener('touchcancel', this.#handleTargetTouchEnd);
386
+ this.#target.addEventListener('touchend', this.#handleTargetTouchEnd);
335
387
 
336
- this.#targetSizeObserver = new ResizeObserver(this.#handleTargetResizeBound);
388
+ this.#targetSizeObserver = new ResizeObserver(this.#handleTargetResize);
337
389
  this.#targetSizeObserver.observe(this.#target);
338
390
 
339
- this.#targetMutationObserver = new MutationObserver(this.#handleTargetMutationBound);
391
+ this.#targetMutationObserver = new MutationObserver(this.#handleTargetMutation);
340
392
  this.#targetMutationObserver.observe(this.#target, { attributes: true, attributeFilter: ['id'] });
341
393
  this.#targetMutationObserver.observe(this.#target.parentNode, { childList: true });
342
394
  }
@@ -361,77 +413,6 @@ class Tooltip extends PopoverMixin(LitElement) {
361
413
  return target;
362
414
  }
363
415
 
364
- #handleTargetBlur() {
365
- this.#isFocusing = false;
366
- this.#updateShowing();
367
- }
368
-
369
- #handleTargetClick() {
370
- if (this.closeOnClick) this.hide();
371
- }
372
-
373
- async #handleTargetFocus() {
374
- if (this.showTruncatedOnly) {
375
- await this.#updateTruncating();
376
- if (!this.#isTruncating) return;
377
- }
378
-
379
- if (this.disableFocusLock) {
380
- this.showing = true;
381
- } else {
382
- this.#isFocusing = true;
383
- this.#updateShowing();
384
- }
385
- }
386
-
387
- #handleTargetMouseEnter() {
388
- // came from tooltip so keep showing
389
- if (this.#mouseLeftTooltip) {
390
- this.#isHovering = true;
391
- return;
392
- }
393
-
394
- this.#hoverTimeout = setTimeout(async() => {
395
- if (this.showTruncatedOnly) {
396
- await this.#updateTruncating();
397
- if (!this.#isTruncating) return;
398
- }
399
-
400
- this.#isHovering = true;
401
- this.#updateShowing();
402
- }, getDelay(this.delay));
403
- }
404
-
405
- #handleTargetMouseLeave() {
406
- clearTimeout(this.#hoverTimeout);
407
- this.#isHovering = false;
408
- if (this.showing) resetDelayTimeout();
409
- setTimeout(() => this.#updateShowing(), 100); // delay to allow for mouseenter to fire if hovering on tooltip
410
- }
411
-
412
- #handleTargetMutation([m]) {
413
- if (!this.#target.isConnected || (m.target === this.#target && m.attributeName === 'id')) {
414
- this.#targetMutationObserver.disconnect();
415
- this.#updateTarget();
416
- }
417
- }
418
-
419
- #handleTargetResize() {
420
- this.#resizeRunSinceTruncationCheck = true;
421
- if (!this.showing) return;
422
- super.position();
423
- }
424
-
425
- #handleTargetTouchEnd() {
426
- clearTimeout(this.#longPressTimeout);
427
- }
428
-
429
- #handleTargetTouchStart() {
430
- this.#longPressTimeout = setTimeout(() => {
431
- this.#target.focus();
432
- }, 500);
433
- }
434
-
435
416
  #handleTooltipMouseEnter() {
436
417
  if (!this.showing) return;
437
418
  this.#isHoveringTooltip = true;
@@ -456,14 +437,14 @@ class Tooltip extends PopoverMixin(LitElement) {
456
437
 
457
438
  if (!this.#target) return;
458
439
 
459
- this.#target.removeEventListener('mouseenter', this.#handleTargetMouseEnterBound);
460
- this.#target.removeEventListener('mouseleave', this.#handleTargetMouseLeaveBound);
461
- this.#target.removeEventListener('focus', this.#handleTargetFocusBound);
462
- this.#target.removeEventListener('blur', this.#handleTargetBlurBound);
463
- this.#target.removeEventListener('click', this.#handleTargetClickBound);
464
- this.#target.removeEventListener('touchstart', this.#handleTargetTouchStartBound);
465
- this.#target.removeEventListener('touchcancel', this.#handleTargetTouchEndBound);
466
- this.#target.removeEventListener('touchend', this.#handleTargetTouchEndBound);
440
+ this.#target.removeEventListener('mouseenter', this.#handleTargetMouseEnter);
441
+ this.#target.removeEventListener('mouseleave', this.#handleTargetMouseLeave);
442
+ this.#target.removeEventListener('focus', this.#handleTargetFocus);
443
+ this.#target.removeEventListener('blur', this.#handleTargetBlur);
444
+ this.#target.removeEventListener('click', this.#handleTargetClick);
445
+ this.#target.removeEventListener('touchstart', this.#handleTargetTouchStart);
446
+ this.#target.removeEventListener('touchcancel', this.#handleTargetTouchEnd);
447
+ this.#target.removeEventListener('touchend', this.#handleTargetTouchEnd);
467
448
 
468
449
  if (this.#targetSizeObserver) {
469
450
  this.#targetSizeObserver.disconnect();
@@ -550,7 +531,7 @@ class Tooltip extends PopoverMixin(LitElement) {
550
531
  if (!super._opened) super.open(this.#target, false);
551
532
  else super.position();
552
533
  } else if (!targetDisabled && isComposedAncestor(this.#target, getComposedActiveElement())) {
553
- this.#handleTargetFocusBound();
534
+ this.#handleTargetFocus();
554
535
  }
555
536
  }
556
537
  this.#addListeners();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.269.3",
3
+ "version": "3.269.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",