@brightspace-ui/core 3.204.8 → 3.205.1

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.
@@ -31,6 +31,7 @@ import { formatNumber } from '@brightspace-ui/intl/lib/number.js';
31
31
  import { ifDefined } from 'lit/directives/if-defined.js';
32
32
  import { LocalizeCoreElement } from '../../helpers/localize-core-element.js';
33
33
  import { offscreenStyles } from '../offscreen/offscreen.js';
34
+ import { styleMap } from 'lit/directives/style-map.js';
34
35
  import { SubscriberRegistryController } from '../../controllers/subscriber/subscriberControllers.js';
35
36
 
36
37
  const ARROWLEFT_KEY_CODE = 37;
@@ -635,6 +636,10 @@ class Filter extends FocusMixin(LocalizeCoreElement(LitElement)) {
635
636
  listItems = dimension.values.map(item => this._createSetDimensionItem(item));
636
637
  }
637
638
 
639
+ const listStyles = {
640
+ paddingBlockEnd: dimension.hasMore ? '10px' : undefined
641
+ };
642
+
638
643
  return html`
639
644
  ${searchResults}
640
645
  <d2l-list
@@ -644,7 +649,8 @@ class Filter extends FocusMixin(LocalizeCoreElement(LitElement)) {
644
649
  grid
645
650
  label="${ifDefined(listLabel)}"
646
651
  ?selection-single="${dimension.selectionSingle}"
647
- separators="between">
652
+ separators="between"
653
+ style=${styleMap(listStyles)}>
648
654
  ${selectedListItems}
649
655
  ${listHeader}
650
656
  ${listItems}
@@ -27,8 +27,11 @@ const defaultPreferredPosition = {
27
27
  span: positionSpans.all,
28
28
  allowFlip: true
29
29
  };
30
+ const defaultMinWidth = 70;
31
+ const inlineMargin = 20;
30
32
  const minBackdropHeightMobile = 42;
31
33
  const minBackdropWidthMobile = 30;
34
+ const minOpenerSizeNoShift = 52;
32
35
  const pointerLength = 16;
33
36
  const pointerRotatedLength = Math.SQRT2 * parseFloat(pointerLength);
34
37
  const isSupported = ('popover' in HTMLElement.prototype);
@@ -165,6 +168,7 @@ export const PopoverMixin = superclass => class extends superclass {
165
168
  border-radius: 0.1rem;
166
169
  box-shadow: -4px -4px 12px -5px rgba(32, 33, 34, 0.2); /* ferrite */
167
170
  height: ${pointerLength}px;
171
+ outline: var(--d2l-popover-outline-width, 0) solid var(--d2l-popover-outline-color, transparent);
168
172
  transform: rotate(45deg);
169
173
  width: ${pointerLength}px;
170
174
  }
@@ -392,6 +396,13 @@ export const PopoverMixin = superclass => class extends superclass {
392
396
 
393
397
  await this.updateComplete;
394
398
 
399
+ const getSpaceRequired = (height, contentRect) => {
400
+ return {
401
+ height: height + 10,
402
+ width: contentRect.width
403
+ };
404
+ };
405
+
395
406
  const adjustPosition = async() => {
396
407
 
397
408
  const scrollHeight = document.documentElement.scrollHeight;
@@ -399,11 +410,7 @@ export const PopoverMixin = superclass => class extends superclass {
399
410
  contentRect = contentRect ?? content.getBoundingClientRect();
400
411
 
401
412
  const height = this._minHeight ?? Math.min(this._maxHeight ?? Number.MAX_VALUE, contentRect.height);
402
-
403
- const spaceRequired = {
404
- height: height + 10,
405
- width: contentRect.width
406
- };
413
+ let spaceRequired = getSpaceRequired(height, contentRect);
407
414
 
408
415
  // space in viewport
409
416
  const prefersInline = this._preferredPosition.location === positionLocations.inlineStart || this._preferredPosition.location === positionLocations.inlineEnd;
@@ -424,6 +431,34 @@ export const PopoverMixin = superclass => class extends superclass {
424
431
  below: scrollHeight - openerRect.bottom - document.documentElement.scrollTop
425
432
  }, spaceRequired, openerRect);
426
433
 
434
+ if (prefersInline) {
435
+ const minWidth = this.minWidth || defaultMinWidth;
436
+ if (!this._rtl) {
437
+ if (this._preferredPosition.location === positionLocations.inlineStart && (spaceAround.left - inlineMargin) > minWidth) {
438
+ this._width = spaceAround.left - inlineMargin;
439
+ } else if (this._preferredPosition.location === positionLocations.inlineStart && (spaceAround.right - inlineMargin) > minWidth) {
440
+ this._width = spaceAround.right - inlineMargin;
441
+ } else if (this._preferredPosition.location === positionLocations.inlineEnd && (spaceAround.right - inlineMargin) > minWidth) {
442
+ this._width = spaceAround.right - inlineMargin;
443
+ } else if (this._preferredPosition.location === positionLocations.inlineEnd && (spaceAround.left - inlineMargin) > minWidth) {
444
+ this._width = spaceAround.left - inlineMargin;
445
+ }
446
+ } else {
447
+ if (this._preferredPosition.location === positionLocations.inlineStart && (spaceAround.right - inlineMargin) > minWidth) {
448
+ this._width = spaceAround.right - inlineMargin;
449
+ } else if (this._preferredPosition.location === positionLocations.inlineStart && (spaceAround.left - inlineMargin) > minWidth) {
450
+ this._width = spaceAround.left - inlineMargin;
451
+ } else if (this._preferredPosition.location === positionLocations.inlineEnd && (spaceAround.left - inlineMargin) > minWidth) {
452
+ this._width = spaceAround.left - inlineMargin;
453
+ } else if (this._preferredPosition.location === positionLocations.inlineEnd && (spaceAround.right - inlineMargin) > minWidth) {
454
+ this._width = spaceAround.right - inlineMargin;
455
+ }
456
+ }
457
+ await this.updateComplete;
458
+ contentRect = content.getBoundingClientRect();
459
+ spaceRequired = getSpaceRequired(height, contentRect);
460
+ }
461
+
427
462
  if (options.updateLocation) {
428
463
  this._location = this.#getLocation(spaceAround, spaceAroundScroll, spaceRequired);
429
464
  }
@@ -969,21 +1004,24 @@ export const PopoverMixin = superclass => class extends superclass {
969
1004
  return (contentXAdjustment + 1.5) * -1; // 1.5px to account for extra 3px that is being applied to width
970
1005
  }
971
1006
 
1007
+ // extra offset for small openers (so pointer does not look broken from content)
1008
+ const extraOffset = (!this._noPointer && this._preferredPosition.span !== positionSpans.all && openerRect.width < minOpenerSizeNoShift ? ((minOpenerSizeNoShift / 2) - (openerRect.width / 2)) : 0);
1009
+
972
1010
  if (!this._rtl) {
973
1011
  if (spaceAround.left < contentXAdjustment) {
974
1012
  // slide content right (not enough space to center)
975
- return spaceAround.left * -1;
1013
+ return (spaceAround.left * -1) - extraOffset;
976
1014
  } else if (spaceAround.right < contentXAdjustment) {
977
1015
  // slide content left (not enough space to center)
978
- return (centerDelta * -1) + spaceAround.right;
1016
+ return (centerDelta * -1) + spaceAround.right + extraOffset;
979
1017
  }
980
1018
  } else {
981
1019
  if (spaceAround.left < contentXAdjustment) {
982
1020
  // slide content right (not enough space to center)
983
- return (centerDelta * -1) + spaceAround.left;
1021
+ return (centerDelta * -1) + spaceAround.left + extraOffset;
984
1022
  } else if (spaceAround.right < contentXAdjustment) {
985
1023
  // slide content left (not enough space to center)
986
- return spaceAround.right * -1;
1024
+ return (spaceAround.right * -1) - extraOffset;
987
1025
  }
988
1026
  }
989
1027
 
@@ -13,7 +13,7 @@ import ResizeObserver from 'resize-observer-polyfill/dist/ResizeObserver.es.js';
13
13
  import { RtlMixin } from '../../mixins/rtl/rtl-mixin.js';
14
14
  import { styleMap } from 'lit/directives/style-map.js';
15
15
 
16
- const usePopoverMixin = getFlag('GAUD-7355-tooltip-popover', false);
16
+ const usePopoverMixin = getFlag('GAUD-7355-tooltip-popover', true);
17
17
 
18
18
  const contentBorderSize = 1;
19
19
  const contentHorizontalPadding = 15;
@@ -144,8 +144,10 @@ if (usePopoverMixin) {
144
144
  --d2l-tooltip-border-color: var(--d2l-color-ferrite); /* Deprecated, use state attribute instead */
145
145
  --d2l-tooltip-outline-color: rgba(255, 255, 255, 0.32);
146
146
  --d2l-popover-background-color: var(--d2l-tooltip-background-color);
147
- --d2l-popover-border-color: var(--d2l-tooltip-outline-color);
147
+ --d2l-popover-border-color: var(--d2l-tooltip-border-color);
148
148
  --d2l-popover-border-radius: 0.3rem;
149
+ --d2l-popover-outline-color: var(--d2l-tooltip-outline-color);
150
+ --d2l-popover-outline-width: 1px;
149
151
  }
150
152
  :host([state="error"]) {
151
153
  --d2l-tooltip-background-color: var(--d2l-color-cinnabar);
@@ -155,12 +157,13 @@ if (usePopoverMixin) {
155
157
  box-sizing: border-box;
156
158
  color: white;
157
159
  max-width: 17.5rem;
158
- min-height: 1.95rem;
160
+ min-height: 1.85rem;
159
161
  min-width: 2.1rem;
160
162
  overflow: hidden;
161
163
  overflow-wrap: anywhere;
162
164
  padding-block: ${10 - contentBorderSize}px ${11 - contentBorderSize}px;
163
165
  padding-inline: ${contentHorizontalPadding - contentBorderSize}px;
166
+ white-space: normal;
164
167
  }
165
168
  ::slotted(ul),
166
169
  ::slotted(ol) {
@@ -226,9 +229,7 @@ if (usePopoverMixin) {
226
229
  this.#removeListeners();
227
230
  window.removeEventListener('resize', this.#handleTargetResizeBound);
228
231
 
229
- clearDismissible(this.#dismissibleId);
230
232
  delayTimeoutId = null;
231
- this.#dismissibleId = null;
232
233
 
233
234
  if (this.#target) {
234
235
  elemIdListRemove(this.#target, 'aria-labelledby', this.id);
@@ -257,6 +258,8 @@ if (usePopoverMixin) {
257
258
 
258
259
  if (changedProperties.has('align') || changedProperties.has('forceShow') || changedProperties.has('offset') || changedProperties.has('positionLocation')) {
259
260
  super.configure({
261
+ maxWidth: '350',
262
+ minWidth: '48',
260
263
  noAutoClose: this.forceShow,
261
264
  offset: (this.offset !== undefined ? Number.parseInt(this.offset) : undefined),
262
265
  position: { location: this.#adaptPositionLocation(this.positionLocation), span: this.#adaptPositionSpan(this.align) },
@@ -283,7 +286,6 @@ if (usePopoverMixin) {
283
286
  return super.position();
284
287
  }
285
288
 
286
- #dismissibleId = null;
287
289
  #handleTargetBlurBound;
288
290
  #handleTargetClickBound;
289
291
  #handleTargetFocusBound;
@@ -307,6 +309,11 @@ if (usePopoverMixin) {
307
309
  #targetSizeObserver;
308
310
  #targetMutationObserver;
309
311
 
312
+ // for testing only!
313
+ _getTarget() {
314
+ return this.#target;
315
+ }
316
+
310
317
  #adaptPositionLocation(val) {
311
318
  switch (val) {
312
319
  case 'bottom': return 'block-end';
@@ -326,6 +333,8 @@ if (usePopoverMixin) {
326
333
  }
327
334
 
328
335
  #addListeners() {
336
+ this.addEventListener('d2l-popover-close', this.hide);
337
+
329
338
  if (!this.#target) return;
330
339
 
331
340
  this.#target.addEventListener('mouseenter', this.#handleTargetMouseEnterBound);
@@ -416,7 +425,7 @@ if (usePopoverMixin) {
416
425
  #handleTargetMutation([m]) {
417
426
  if (!this.#target.isConnected || (m.target === this.#target && m.attributeName === 'id')) {
418
427
  this.#targetMutationObserver.disconnect();
419
- this._updateTarget();
428
+ this.#updateTarget();
420
429
  }
421
430
  }
422
431
 
@@ -456,6 +465,8 @@ if (usePopoverMixin) {
456
465
  }
457
466
 
458
467
  #removeListeners() {
468
+ this.removeEventListener('d2l-popover-close', this.hide);
469
+
459
470
  if (!this.#target) return;
460
471
 
461
472
  this.#target.removeEventListener('mouseenter', this.#handleTargetMouseEnterBound);
@@ -488,11 +499,11 @@ if (usePopoverMixin) {
488
499
  activeTooltip = this;
489
500
  }
490
501
 
491
- this.#dismissibleId = setDismissible(() => this.hide());
492
502
  this.setAttribute('aria-hidden', 'false');
493
503
  await this.updateComplete;
494
504
 
495
- super.open(this.#target, false);
505
+ // wait for popover before dispatching (ex. otherwise visual-diff won't capture complete target area)
506
+ await super.open(this.#target, false);
496
507
 
497
508
  if (dispatch) {
498
509
  this.dispatchEvent(new CustomEvent('d2l-tooltip-show', { bubbles: true, composed: true }));
@@ -503,10 +514,6 @@ if (usePopoverMixin) {
503
514
  if (activeTooltip === this) activeTooltip = null;
504
515
 
505
516
  this.setAttribute('aria-hidden', 'true');
506
- if (this.#dismissibleId) {
507
- clearDismissible(this.#dismissibleId);
508
- this.#dismissibleId = null;
509
- }
510
517
 
511
518
  super.close();
512
519
 
@@ -1353,6 +1360,11 @@ if (usePopoverMixin) {
1353
1360
  return this.shadowRoot && this.shadowRoot.querySelector('.d2l-tooltip-content');
1354
1361
  }
1355
1362
 
1363
+ // for testing only!
1364
+ _getTarget() {
1365
+ return this._target;
1366
+ }
1367
+
1356
1368
  _isAboveOrBelow() {
1357
1369
  return this._openDir === 'bottom' || this._openDir === 'top';
1358
1370
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.204.8",
3
+ "version": "3.205.1",
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",