@brightspace-ui/core 2.152.0 → 2.152.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.
@@ -6,6 +6,13 @@ import ResizeObserver from 'resize-observer-polyfill/dist/ResizeObserver.es.js';
6
6
  import { styleMap } from 'lit/directives/style-map.js';
7
7
 
8
8
  const reduceMotion = matchMedia('(prefers-reduced-motion: reduce)').matches;
9
+ let activeReduceMotion = reduceMotion;
10
+ export function disableReducedMotionForTesting() {
11
+ activeReduceMotion = false;
12
+ }
13
+ export function restoreReducedMotionForTesting() {
14
+ activeReduceMotion = reduceMotion;
15
+ }
9
16
 
10
17
  const states = {
11
18
  CLOSED: 'closed', // the toast is closed
@@ -331,10 +338,10 @@ class AlertToast extends LitElement {
331
338
  this._totalSiblingHeightBelow += e.detail.heightDifference;
332
339
  if (e.detail.opening) {
333
340
  this._numAlertsBelow += 1;
334
- if (!reduceMotion) this._state = states.SLIDING;
341
+ if (!activeReduceMotion) this._state = states.SLIDING;
335
342
  } else if (e.detail.closing) {
336
343
  this._numAlertsBelow -= 1;
337
- if (!reduceMotion) this._state = states.SLIDING;
344
+ if (!activeReduceMotion) this._state = states.SLIDING;
338
345
  }
339
346
  }
340
347
 
@@ -396,7 +403,7 @@ class AlertToast extends LitElement {
396
403
  if (this._state === states.CLOSING) {
397
404
  this._state = states.OPENING;
398
405
  } else if (this._state === states.CLOSED) {
399
- if (!reduceMotion) {
406
+ if (!activeReduceMotion) {
400
407
  this._state = states.PREOPENING;
401
408
  // pause before running the opening animation because transitions won't run when changing from 'diplay: none' to 'display: block'
402
409
  this._preopenFrame = requestAnimationFrame(() => {
@@ -412,7 +419,7 @@ class AlertToast extends LitElement {
412
419
  } else {
413
420
  if (!this._innerContainer) return;
414
421
 
415
- if (reduceMotion || this._state === states.PREOPENING) {
422
+ if (activeReduceMotion || this._state === states.PREOPENING) {
416
423
  cancelAnimationFrame(this._preopenFrame);
417
424
  this.removeAttribute('role');
418
425
  } else if (this._state === states.OPENING || this._state === states.OPEN || this._state === states.SLIDING) {
@@ -425,7 +432,7 @@ class AlertToast extends LitElement {
425
432
  requestAnimationFrame(() => {
426
433
  const bottom = this._innerContainer.getBoundingClientRect().bottom;
427
434
 
428
- if (reduceMotion || this._state === states.PREOPENING) {
435
+ if (activeReduceMotion || this._state === states.PREOPENING) {
429
436
  this._state = states.CLOSED;
430
437
  this._totalSiblingHeightBelow = 0;
431
438
  this._numAlertsBelow = 0;
@@ -444,8 +451,14 @@ class AlertToast extends LitElement {
444
451
  }
445
452
 
446
453
  _stateChanged(newState, oldState) {
447
- const newlyOpened = (newState === states.OPEN && oldState === states.OPENING);
448
- const newlyOpenedReduceMotion = (newState === states.OPEN && oldState === states.CLOSED);
454
+ /**
455
+ * Opening state changes:
456
+ * - OPENING -> OPEN
457
+ * - OPENING -> SLIDING (multiple alerts opened rapidly)
458
+ * - CLOSED -> OPEN (prefers-reduced-motion)
459
+ */
460
+ const newlyOpened = oldState === states.OPENING && (newState === states.OPEN || newState === states.SLIDING);
461
+ const newlyOpenedReduceMotion = oldState === states.CLOSED && newState === states.OPEN;
449
462
  if (newlyOpened || newlyOpenedReduceMotion) {
450
463
  this._closeTimerStart();
451
464
  } else if (newState !== states.SLIDING && newState !== states.OPEN) {
@@ -217,8 +217,8 @@ class InputDateTimeRange extends FocusMixin(SkeletonMixin(FormElementMixin(RtlMi
217
217
  const startDateTimeInput = this.shadowRoot && this.shadowRoot.querySelector('.d2l-input-date-time-range-start');
218
218
  const endDateTimeInput = this.shadowRoot && this.shadowRoot.querySelector('.d2l-input-date-time-range-end');
219
219
 
220
- const tooltipStart = (this.validationError && !this.startOpened && !this.childErrors.has(startDateTimeInput)) ? html`<d2l-tooltip align="start" announced for="${this._startInputId}" position="bottom" state="error">${this.validationError}</d2l-tooltip>` : null;
221
- const tooltipEnd = (this.validationError && !this.endOpened && !this.childErrors.has(endDateTimeInput)) ? html`<d2l-tooltip align="start" announced for="${this._endInputId}" position="bottom" state="error">${this.validationError}</d2l-tooltip>` : null;
220
+ const tooltipStart = (this.validationError && !this.startOpened && !this.childErrors.has(startDateTimeInput)) ? html`<d2l-tooltip align="start" announced for="${this._startInputId}" position="bottom" state="error" class="vdiff-target">${this.validationError}</d2l-tooltip>` : null;
221
+ const tooltipEnd = (this.validationError && !this.endOpened && !this.childErrors.has(endDateTimeInput)) ? html`<d2l-tooltip align="start" announced for="${this._endInputId}" position="bottom" state="error" class="vdiff-target">${this.validationError}</d2l-tooltip>` : null;
222
222
  return html`
223
223
  ${tooltipStart}
224
224
  ${tooltipEnd}
@@ -236,7 +236,7 @@ class InputDateTimeRange extends FocusMixin(SkeletonMixin(FormElementMixin(RtlMi
236
236
  <d2l-input-date-time
237
237
  ?novalidate="${this.noValidate}"
238
238
  @change="${this._handleChange}"
239
- class="d2l-input-date-time-range-start"
239
+ class="d2l-input-date-time-range-start vdiff-target"
240
240
  @d2l-input-date-time-dropdown-toggle="${this._handleDropdownToggle}"
241
241
  ?disabled="${this.disabled}"
242
242
  .forceInvalid=${this.invalid}
@@ -258,7 +258,7 @@ class InputDateTimeRange extends FocusMixin(SkeletonMixin(FormElementMixin(RtlMi
258
258
  <d2l-input-date-time
259
259
  ?novalidate="${this.noValidate}"
260
260
  @change="${this._handleChange}"
261
- class="d2l-input-date-time-range-end"
261
+ class="d2l-input-date-time-range-end vdiff-target"
262
262
  @d2l-input-date-time-dropdown-toggle="${this._handleDropdownToggle}"
263
263
  ?disabled="${this.disabled}"
264
264
  .forceInvalid=${this.invalid}
@@ -230,11 +230,12 @@ class InputDateTime extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMi
230
230
 
231
231
  const dateOpened = this.opened && !this._timeOpened && !this.disabled && !this.skeleton;
232
232
  const parsedValue = this.value ? (this.localized ? this.value : getLocalDateTimeFromUTCDateTime(this.value)) : '';
233
- const tooltip = (this.validationError && !this.opened && this.childErrors.size === 0) ? html`<d2l-tooltip align="start" announced for="${this._inputId}" state="error">${this.validationError}</d2l-tooltip>` : null;
233
+ const tooltip = (this.validationError && !this.opened && this.childErrors.size === 0) ? html`<d2l-tooltip align="start" announced for="${this._inputId}" state="error" class="vdiff-target">${this.validationError}</d2l-tooltip>` : null;
234
234
  const inputTime = !timeHidden ? html`<d2l-input-time
235
235
  ?novalidate="${this.noValidate}"
236
236
  @blur="${this._handleInputTimeBlur}"
237
237
  @change="${this._handleTimeChange}"
238
+ class="vdiff-target"
238
239
  @d2l-input-time-dropdown-toggle="${this._handleDropdownToggle}"
239
240
  default-value="${ifDefined(this.timeDefaultValue)}"
240
241
  ?disabled="${this.disabled}"
@@ -264,6 +265,7 @@ class InputDateTime extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMi
264
265
  novalidateminmax
265
266
  has-now
266
267
  @change="${this._handleDateChange}"
268
+ class="vdiff-target"
267
269
  @d2l-input-date-dropdown-toggle="${this._handleDropdownToggle}"
268
270
  ?disabled="${this.disabled}"
269
271
  .forceInvalid=${this.invalid}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "2.152.0",
3
+ "version": "2.152.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",