@brightspace-ui/core 3.221.2 → 3.223.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.
@@ -37,7 +37,7 @@ Alerts communicate critical information relating to the state of the system and
37
37
  Inline Alerts can be placed anywhere in the page content
38
38
  </d2l-alert>
39
39
  <d2l-alert-toast id="alert-toast" type="success" open no-auto-close>
40
- Toast Alerts appear at the botttom of the viewport
40
+ Toast Alerts appear at the bottom of the viewport
41
41
  </d2l-alert-toast>
42
42
  ```
43
43
 
@@ -5,6 +5,7 @@ import { getComposedActiveElement } from '../../helpers/focus.js';
5
5
 
6
6
  const BACKDROP_HIDDEN = 'data-d2l-backdrop-hidden';
7
7
  const BACKDROP_ARIA_HIDDEN = 'data-d2l-backdrop-aria-hidden';
8
+ const BACKDROP_TABINDEX = 'data-d2l-backdrop-tabindex';
8
9
  const TRANSITION_DURATION = 200;
9
10
 
10
11
  const reduceMotion = matchMedia('(prefers-reduced-motion: reduce)').matches;
@@ -174,6 +175,11 @@ function hideAccessible(target) {
174
175
  }
175
176
  child.setAttribute('aria-hidden', 'true');
176
177
 
178
+ if (child.hasAttribute('tabindex')) {
179
+ child.setAttribute(BACKDROP_TABINDEX, child.getAttribute('tabindex'));
180
+ }
181
+ child.setAttribute('tabindex', '-1');
182
+
177
183
  child.setAttribute(BACKDROP_HIDDEN, BACKDROP_HIDDEN);
178
184
  hiddenElements.push(child);
179
185
  }
@@ -201,6 +207,12 @@ function showAccessible(elems) {
201
207
  } else {
202
208
  elem.removeAttribute('aria-hidden');
203
209
  }
210
+ if (elem.hasAttribute(BACKDROP_TABINDEX)) {
211
+ elem.setAttribute('tabindex', elem.getAttribute(BACKDROP_TABINDEX));
212
+ elem.removeAttribute(BACKDROP_TABINDEX);
213
+ } else {
214
+ elem.removeAttribute('tabindex');
215
+ }
204
216
  elem.removeAttribute(BACKDROP_HIDDEN);
205
217
  }
206
218
  }
@@ -32,15 +32,15 @@ The `d2l-dialog` element is a generic dialog that provides a slot for arbitrary
32
32
  * Label primary actions with clear and predictable language. Use verbs like, “Add” or “Save” that indicate the outcome of a dialog rather than, “OK” or “Close”
33
33
  * Keep dialog titles concise
34
34
  * Maintain a language relationship between the action that triggered the dialog, dialog title, and dialog primary button.
35
- * When it is necessary to stack multiple dialogs, ensure the stacked dialog is nested within the DOM of the dialog containing the opener
35
+ * When it is necessary to nest multiple dialogs, ensure the nested dialog is within the DOM of the dialog containing the opener
36
36
  <!-- docs: end dos -->
37
37
 
38
38
  <!-- docs: start donts -->
39
39
  * Don’t use a dialog when you could reasonably use an alternative that preserves user context, like expanding options inline
40
40
  * Don’t use a dialog to show error, success, or warning messages. Use an inline or toast alert instead.
41
- * Avoid creating large, complex dialogs
42
- * Avoid opening a dialog from within other dialogs (stacking dialogs)
43
- * Avoid a title length that could easily wrap to two lines
41
+ * Avoid opening a dialog from another dialog (nesting) since this can increase cognitive load and disorient users
42
+ * Exception: confirmation dialogs that protect users from losing unsaved work
43
+ * Avoid titles that are long enough to wrap onto multiple lines
44
44
  <!-- docs: end donts -->
45
45
  <!-- docs: end best practices -->
46
46
 
@@ -57,6 +57,14 @@ class ScrollWrapper extends LocalizeCoreElement(LitElement) {
57
57
  attribute: 'hide-actions',
58
58
  type: Boolean
59
59
  },
60
+ /**
61
+ * The area in pixels to offset scroll width calculations
62
+ * @type {number}
63
+ */
64
+ scrollAreaOffset: {
65
+ attribute: 'scroll-area-offset',
66
+ type: Number
67
+ },
60
68
  _hScrollbar: {
61
69
  attribute: 'h-scrollbar',
62
70
  reflect: true,
@@ -156,6 +164,7 @@ class ScrollWrapper extends LocalizeCoreElement(LitElement) {
156
164
  super();
157
165
  this.customScrollers = {};
158
166
  this.hideActions = false;
167
+ this.scrollAreaOffset = 0;
159
168
  this._allScrollers = [];
160
169
  this._baseContainer = null;
161
170
  this._container = null;
@@ -258,16 +267,19 @@ class ScrollWrapper extends LocalizeCoreElement(LitElement) {
258
267
  });
259
268
  }
260
269
  }
270
+ _getScrollDistance() {
271
+ return Math.max((this._container.clientWidth - this.scrollAreaOffset) * SCROLL_AMOUNT, 1); // guard against offset being larger than content
272
+ }
261
273
 
262
274
  _scrollLeft() {
263
275
  if (!this._container) return;
264
- const scrollDistance = this._container.clientWidth * SCROLL_AMOUNT * -1;
276
+ const scrollDistance = this._getScrollDistance() * -1;
265
277
  this.scrollDistance(scrollDistance, true);
266
278
  }
267
279
 
268
280
  _scrollRight() {
269
281
  if (!this._container) return;
270
- const scrollDistance = this._container.clientWidth * SCROLL_AMOUNT;
282
+ const scrollDistance = this._getScrollDistance();
271
283
  this.scrollDistance(scrollDistance, true);
272
284
  }
273
285
 
@@ -4,6 +4,8 @@ import '../backdrop/backdrop-loading.js';
4
4
  import { css, html, LitElement, nothing } from 'lit';
5
5
  import { cssSizes } from '../inputs/input-checkbox.js';
6
6
  import { getComposedParent } from '../../helpers/dom.js';
7
+ import { getFlag } from '../../helpers/flags.js';
8
+ import { ifDefined } from 'lit/directives/if-defined.js';
7
9
  import { isPopoverSupported } from '../popover/popover-mixin.js';
8
10
  import { PageableMixin } from '../paging/pageable-mixin.js';
9
11
  import { SelectionMixin } from '../selection/selection-mixin.js';
@@ -296,6 +298,7 @@ export class TableWrapper extends PageableMixin(SelectionMixin(LitElement)) {
296
298
  reflect: true,
297
299
  type: Boolean
298
300
  },
301
+ _stickyWidth: { state: true },
299
302
  /**
300
303
  * Type of table style to apply. The "light" style has fewer borders and tighter padding.
301
304
  * @type {'default'|'light'}
@@ -376,6 +379,7 @@ export class TableWrapper extends PageableMixin(SelectionMixin(LitElement)) {
376
379
  this.noColumnBorder = false;
377
380
  this.stickyHeaders = false;
378
381
  this.stickyHeadersScrollWrapper = false;
382
+ this._stickyWidth = 0;
379
383
  this.type = 'default';
380
384
 
381
385
  this._controls = null;
@@ -388,6 +392,8 @@ export class TableWrapper extends PageableMixin(SelectionMixin(LitElement)) {
388
392
  this._tableMutationObserver = null;
389
393
  this._tableScrollers = {};
390
394
  this.loading = false;
395
+
396
+ this._excludeStickyColumnsFromScrollCalculations = getFlag('GAUD-9530-exclude-sticky-columns-from-scroll-calculations', false);
391
397
  }
392
398
 
393
399
  connectedCallback() {
@@ -424,7 +430,7 @@ export class TableWrapper extends PageableMixin(SelectionMixin(LitElement)) {
424
430
  return html`
425
431
  <slot name="controls" @slotchange="${this._handleControlsSlotChange}"></slot>
426
432
  ${this.stickyHeaders && this._controlsScrolled ? html`<div class="d2l-sticky-headers-backdrop"></div>` : nothing}
427
- ${useScrollWrapper ? html`<d2l-scroll-wrapper .customScrollers="${this._tableScrollers}">${slot}</d2l-scroll-wrapper>` : slot}
433
+ ${useScrollWrapper ? html`<d2l-scroll-wrapper scroll-area-offset=${ifDefined(this._excludeStickyColumnsFromScrollCalculations ? this._stickyWidth : undefined)} .customScrollers="${this._tableScrollers}">${slot}</d2l-scroll-wrapper>` : slot}
428
434
  ${this._renderPagerContainer()}
429
435
  `;
430
436
  }
@@ -722,21 +728,25 @@ export class TableWrapper extends PageableMixin(SelectionMixin(LitElement)) {
722
728
 
723
729
  if (candidateRowHeadCells.length !== candidateRowBodyLength) return;
724
730
 
731
+ let stickyWidth = 0;
725
732
  for (let i = 0; i < candidateRowHeadCells.length; i++) {
726
733
  const headCell = candidateRowHeadCells[i];
727
734
  const headStyle = getComputedStyle(headCell);
728
735
 
729
736
  const bodyCell = candidateRowBody.cells[i];
730
737
  const bodyStyle = getComputedStyle(bodyCell);
731
-
738
+ let cellWidth = headCell.clientWidth + parseFloat(headStyle.borderLeft) + parseFloat(headStyle.borderRight);
732
739
  if (headCell.clientWidth > bodyCell.clientWidth) {
733
740
  const headOverallWidth = parseFloat(headStyle.width) + parseFloat(headStyle.paddingLeft) + parseFloat(headStyle.paddingRight);
734
741
  bodyCell.style.minWidth = `${headOverallWidth - parseFloat(bodyStyle.paddingLeft) - parseFloat(bodyStyle.paddingRight)}px`;
735
742
  } else if (headCell.clientWidth < bodyCell.clientWidth) {
736
743
  const bodyOverallWidth = parseFloat(bodyStyle.width) + parseFloat(bodyStyle.paddingLeft) + parseFloat(bodyStyle.paddingRight);
737
744
  headCell.style.minWidth = `${bodyOverallWidth - parseFloat(headStyle.paddingLeft) - parseFloat(headStyle.paddingRight)}px`;
745
+ cellWidth = bodyCell.clientWidth + parseFloat(bodyStyle.borderLeft) + parseFloat(bodyStyle.borderRight);
738
746
  }
747
+ if (headCell.hasAttribute('sticky')) stickyWidth += cellWidth;
739
748
  }
749
+ if (this._excludeStickyColumnsFromScrollCalculations) this._stickyWidth = stickyWidth;
740
750
  }
741
751
 
742
752
  _updateStickyAncestor(node, popoverOpened) {
@@ -12523,6 +12523,12 @@
12523
12523
  "description": "Whether to hide left/right scroll buttons",
12524
12524
  "type": "boolean",
12525
12525
  "default": "false"
12526
+ },
12527
+ {
12528
+ "name": "scroll-area-offset",
12529
+ "description": "The area in pixels to offset scroll width calculations",
12530
+ "type": "number",
12531
+ "default": "0"
12526
12532
  }
12527
12533
  ],
12528
12534
  "properties": [
@@ -12538,6 +12544,13 @@
12538
12544
  "description": "Whether to hide left/right scroll buttons",
12539
12545
  "type": "boolean",
12540
12546
  "default": "false"
12547
+ },
12548
+ {
12549
+ "name": "scrollAreaOffset",
12550
+ "attribute": "scroll-area-offset",
12551
+ "description": "The area in pixels to offset scroll width calculations",
12552
+ "type": "number",
12553
+ "default": "0"
12541
12554
  }
12542
12555
  ],
12543
12556
  "slots": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.221.2",
3
+ "version": "3.223.0",
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",