@brightspace-ui/core 3.328.0 → 3.329.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.
@@ -309,18 +309,13 @@ class InputDate extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixin(
309
309
  super.updated(changedProperties);
310
310
 
311
311
  changedProperties.forEach((oldVal, prop) => {
312
- if (prop === '_dateTimeDescriptor' || prop === 'value') {
313
- this._shownValue = this.value;
314
- this._setFormattedValue();
315
-
316
- if (prop === 'value') {
317
- this.setFormValue(this.value);
318
- this.setValidity({
319
- rangeUnderflow: !this.noValidateMinMax && this.value && this.minValue && getDateFromISODate(this.value).getTime() < getDateFromISODate(this.minValue).getTime(),
320
- rangeOverflow: !this.noValidateMinMax && this.value && this.maxValue && getDateFromISODate(this.value).getTime() > getDateFromISODate(this.maxValue).getTime()
321
- });
322
- this.requestValidate(false);
323
- }
312
+ if (prop === 'value') {
313
+ this.setFormValue(this.value);
314
+ this.setValidity({
315
+ rangeUnderflow: !this.noValidateMinMax && this.value && this.minValue && getDateFromISODate(this.value).getTime() < getDateFromISODate(this.minValue).getTime(),
316
+ rangeOverflow: !this.noValidateMinMax && this.value && this.maxValue && getDateFromISODate(this.value).getTime() > getDateFromISODate(this.maxValue).getTime()
317
+ });
318
+ this.requestValidate(false);
324
319
  } else if (prop === 'opened') {
325
320
  if (this.opened) this._open();
326
321
  else this._close();
@@ -333,6 +328,10 @@ class InputDate extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixin(
333
328
  willUpdate(changedProperties) {
334
329
  super.willUpdate(changedProperties);
335
330
  if (changedProperties.has('_hiddenContentWidth')) this.style.maxWidth = this.inputTextWidth;
331
+ if (changedProperties.has('_dateTimeDescriptor') || changedProperties.has('value')) {
332
+ this._shownValue = this.value;
333
+ this._setFormattedValue();
334
+ }
336
335
  }
337
336
 
338
337
  async validate() {
@@ -397,38 +396,31 @@ class InputDate extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixin(
397
396
  this.requestValidate(true);
398
397
  }
399
398
 
400
- async _handleChange() {
399
+ _handleChange() {
401
400
  this._showRevertTooltip = false;
402
401
  const value = this._textInput.value;
403
402
  const isNewVal = value !== this.value;
404
403
  if (!value && !this.required) {
405
404
  if (isNewVal) {
406
- await this._updateValueDispatchEvent('');
407
- if (this._calendar) {
408
- await this.updateComplete;
409
- await this._calendar.reset();
410
- }
405
+ this._updateValueDispatchEvent('');
406
+ this.calendar?.reset();
411
407
  }
412
408
  return;
413
409
  }
414
- this._formattedValue = value;
415
- await this.updateComplete;
416
410
  try {
417
411
  const date = parseDate(value);
418
- await this._updateValueDispatchEvent(formatDateInISO({ year: date.getFullYear(), month: (parseInt(date.getMonth()) + 1), date: date.getDate() }));
412
+ this._updateValueDispatchEvent(formatDateInISO({ year: date.getFullYear(), month: (parseInt(date.getMonth()) + 1), date: date.getDate() }));
419
413
  } catch {
420
414
  // leave value the same when invalid input
421
415
  if (isNewVal) this._showRevertTooltip = true;
416
+ this._textInput.value = this._formattedValue; // Template only reset if property changes, this line forces same prop on live value
422
417
  }
423
418
  this._setFormattedValue(); // keep out here in case parseDate is same date, e.g., user adds invalid text to end of parseable date
424
- if (this._calendar) {
425
- await this.updateComplete;
426
- await this._calendar.reset(true);
427
- }
419
+ this._calendar?.reset(true);
428
420
  }
429
421
 
430
422
  async _handleClear() {
431
- await this._updateValueDispatchEvent('');
423
+ this._updateValueDispatchEvent('');
432
424
  if (this._dropdown) {
433
425
  this._dropdown.close();
434
426
  }
@@ -438,7 +430,7 @@ class InputDate extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixin(
438
430
  async _handleDateSelected(e) {
439
431
  this._showRevertTooltip = false;
440
432
  const value = e.target.selectedValue;
441
- await this._updateValueDispatchEvent(value);
433
+ this._updateValueDispatchEvent(value);
442
434
  if (this._dropdown) {
443
435
  this._dropdown.close();
444
436
  }
@@ -484,6 +476,7 @@ class InputDate extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixin(
484
476
  await this.updateComplete;
485
477
  if (!this.shadowRoot) return;
486
478
  this._calendar = this.shadowRoot.querySelector('d2l-calendar');
479
+ await this._calendar.reset(true);
487
480
  this._dropdown = this.shadowRoot.querySelector('d2l-dropdown-content');
488
481
  await this._calendar.updateComplete;
489
482
  }
@@ -534,7 +527,7 @@ class InputDate extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixin(
534
527
 
535
528
  async _handleSetToToday(_, setToNow) {
536
529
  const date = getToday();
537
- await this._updateValueDispatchEvent(formatDateInISO(date), setToNow);
530
+ this._updateValueDispatchEvent(formatDateInISO(date), setToNow);
538
531
  if (this._dropdown) {
539
532
  this._dropdown.close();
540
533
  }
@@ -543,10 +536,9 @@ class InputDate extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixin(
543
536
 
544
537
  async _open() {
545
538
  if (this.disabled || this.skeleton) return;
539
+ this._handleChange();
546
540
  if (!this._dropdownFirstOpened || !this._dropdown) await this._handleFirstDropdownOpen();
547
541
 
548
- await this._handleChange();
549
-
550
542
  // on small screens, only open calendar if calendar icon is selected,
551
543
  // otherwise only open text input
552
544
  if (mediaQueryList.matches && this._openCalendarOnly) {
@@ -570,10 +562,14 @@ class InputDate extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixin(
570
562
  }
571
563
 
572
564
  _setFormattedValue() {
573
- this._formattedValue = this._shownValue ? formatISODateInUserCalDescriptor(this._shownValue) : '';
565
+ try {
566
+ this._formattedValue = this._shownValue ? formatISODateInUserCalDescriptor(this._shownValue) : '';
567
+ } catch {
568
+ // don't set the value if it's invalid
569
+ }
574
570
  }
575
571
 
576
- async _updateValueDispatchEvent(dateInISO, setToNow) {
572
+ _updateValueDispatchEvent(dateInISO, setToNow) {
577
573
  // prevent validation from happening multiple times for same change,
578
574
  // except for now button that affects time
579
575
  if (!setToNow && dateInISO === this._shownValue) return;
@@ -10,11 +10,11 @@ import { ToolbarItemMixin } from './toolbar-item-mixin.js';
10
10
  /**
11
11
  * A toolbar toggle button that performs an action and supports pressed and expanded states
12
12
  */
13
- class ToolbarButtonToggle extends SlottedIconMixin(FocusMixin(ToolbarItemMixin(ThemeMixin(PropertyRequiredMixin(LitElement))))) {
13
+ class ToolbarToggle extends SlottedIconMixin(FocusMixin(ToolbarItemMixin(ThemeMixin(PropertyRequiredMixin(LitElement))))) {
14
14
 
15
15
  static properties = {
16
16
  /**
17
- * Disables the toolbar button
17
+ * Disables the toolbar toggle button
18
18
  * @type {boolean}
19
19
  */
20
20
  disabled: { type: Boolean },
@@ -34,7 +34,7 @@ class ToolbarButtonToggle extends SlottedIconMixin(FocusMixin(ToolbarItemMixin(T
34
34
  */
35
35
  pressed: { type: Boolean },
36
36
  /**
37
- * ACCESSIBILITY: REQUIRED: Accessible text for the button
37
+ * ACCESSIBILITY: REQUIRED: Accessible text for the toggle button
38
38
  * @type {string}
39
39
  */
40
40
  text: { type: String, required: true }
@@ -103,9 +103,9 @@ class ToolbarButtonToggle extends SlottedIconMixin(FocusMixin(ToolbarItemMixin(T
103
103
  }
104
104
 
105
105
  /** Dispatched when the pressed state changes. */
106
- this.dispatchEvent(new CustomEvent('d2l-toolbar-button-toggle-change'));
106
+ this.dispatchEvent(new CustomEvent('d2l-toolbar-toggle-change'));
107
107
  }
108
108
 
109
109
  }
110
110
 
111
- customElements.define('d2l-toolbar-button-toggle', ToolbarButtonToggle);
111
+ customElements.define('d2l-toolbar-toggle', ToolbarToggle);
@@ -17429,106 +17429,6 @@
17429
17429
  }
17430
17430
  ]
17431
17431
  },
17432
- {
17433
- "name": "d2l-toolbar-button-toggle",
17434
- "path": "./components/toolbar/toolbar-button-toggle.js",
17435
- "description": "A toolbar toggle button that performs an action and supports pressed and expanded states",
17436
- "attributes": [
17437
- {
17438
- "name": "disabled",
17439
- "description": "Disables the toolbar button",
17440
- "type": "boolean",
17441
- "default": "false"
17442
- },
17443
- {
17444
- "name": "expandable",
17445
- "description": "Expandable state",
17446
- "type": "boolean",
17447
- "default": "false"
17448
- },
17449
- {
17450
- "name": "expanded",
17451
- "description": "Expanded state",
17452
- "type": "boolean",
17453
- "default": "false"
17454
- },
17455
- {
17456
- "name": "pressed",
17457
- "description": "Pressed state",
17458
- "type": "boolean",
17459
- "default": "false"
17460
- },
17461
- {
17462
- "name": "text",
17463
- "description": "ACCESSIBILITY: REQUIRED: Accessible text for the button",
17464
- "type": "string",
17465
- "default": "\"\""
17466
- },
17467
- {
17468
- "name": "icon",
17469
- "description": "Preset icon key (e.g. \"tier1:gear\")",
17470
- "type": "string"
17471
- }
17472
- ],
17473
- "properties": [
17474
- {
17475
- "name": "styles",
17476
- "type": "array",
17477
- "default": "[[null],\"toolbarButtonStyles\",null]"
17478
- },
17479
- {
17480
- "name": "disabled",
17481
- "attribute": "disabled",
17482
- "description": "Disables the toolbar button",
17483
- "type": "boolean",
17484
- "default": "false"
17485
- },
17486
- {
17487
- "name": "expandable",
17488
- "attribute": "expandable",
17489
- "description": "Expandable state",
17490
- "type": "boolean",
17491
- "default": "false"
17492
- },
17493
- {
17494
- "name": "expanded",
17495
- "attribute": "expanded",
17496
- "description": "Expanded state",
17497
- "type": "boolean",
17498
- "default": "false"
17499
- },
17500
- {
17501
- "name": "pressed",
17502
- "attribute": "pressed",
17503
- "description": "Pressed state",
17504
- "type": "boolean",
17505
- "default": "false"
17506
- },
17507
- {
17508
- "name": "text",
17509
- "attribute": "text",
17510
- "description": "ACCESSIBILITY: REQUIRED: Accessible text for the button",
17511
- "type": "string",
17512
- "default": "\"\""
17513
- },
17514
- {
17515
- "name": "icon",
17516
- "attribute": "icon",
17517
- "description": "Preset icon key (e.g. \"tier1:gear\")",
17518
- "type": "string"
17519
- },
17520
- {
17521
- "name": "isToolbarItem",
17522
- "type": "boolean"
17523
- }
17524
- ],
17525
- "events": [
17526
- {
17527
- "name": "d2l-toolbar-button-toggle-change",
17528
- "description": "Dispatched when the pressed state changes."
17529
- }
17530
- ]
17531
- },
17532
17432
  {
17533
17433
  "name": "d2l-toolbar-button",
17534
17434
  "path": "./components/toolbar/toolbar-button.js",
@@ -17712,6 +17612,106 @@
17712
17612
  }
17713
17613
  ]
17714
17614
  },
17615
+ {
17616
+ "name": "d2l-toolbar-toggle",
17617
+ "path": "./components/toolbar/toolbar-toggle.js",
17618
+ "description": "A toolbar toggle button that performs an action and supports pressed and expanded states",
17619
+ "attributes": [
17620
+ {
17621
+ "name": "disabled",
17622
+ "description": "Disables the toolbar toggle button",
17623
+ "type": "boolean",
17624
+ "default": "false"
17625
+ },
17626
+ {
17627
+ "name": "expandable",
17628
+ "description": "Expandable state",
17629
+ "type": "boolean",
17630
+ "default": "false"
17631
+ },
17632
+ {
17633
+ "name": "expanded",
17634
+ "description": "Expanded state",
17635
+ "type": "boolean",
17636
+ "default": "false"
17637
+ },
17638
+ {
17639
+ "name": "pressed",
17640
+ "description": "Pressed state",
17641
+ "type": "boolean",
17642
+ "default": "false"
17643
+ },
17644
+ {
17645
+ "name": "text",
17646
+ "description": "ACCESSIBILITY: REQUIRED: Accessible text for the toggle button",
17647
+ "type": "string",
17648
+ "default": "\"\""
17649
+ },
17650
+ {
17651
+ "name": "icon",
17652
+ "description": "Preset icon key (e.g. \"tier1:gear\")",
17653
+ "type": "string"
17654
+ }
17655
+ ],
17656
+ "properties": [
17657
+ {
17658
+ "name": "styles",
17659
+ "type": "array",
17660
+ "default": "[[null],\"toolbarButtonStyles\",null]"
17661
+ },
17662
+ {
17663
+ "name": "disabled",
17664
+ "attribute": "disabled",
17665
+ "description": "Disables the toolbar toggle button",
17666
+ "type": "boolean",
17667
+ "default": "false"
17668
+ },
17669
+ {
17670
+ "name": "expandable",
17671
+ "attribute": "expandable",
17672
+ "description": "Expandable state",
17673
+ "type": "boolean",
17674
+ "default": "false"
17675
+ },
17676
+ {
17677
+ "name": "expanded",
17678
+ "attribute": "expanded",
17679
+ "description": "Expanded state",
17680
+ "type": "boolean",
17681
+ "default": "false"
17682
+ },
17683
+ {
17684
+ "name": "pressed",
17685
+ "attribute": "pressed",
17686
+ "description": "Pressed state",
17687
+ "type": "boolean",
17688
+ "default": "false"
17689
+ },
17690
+ {
17691
+ "name": "text",
17692
+ "attribute": "text",
17693
+ "description": "ACCESSIBILITY: REQUIRED: Accessible text for the toggle button",
17694
+ "type": "string",
17695
+ "default": "\"\""
17696
+ },
17697
+ {
17698
+ "name": "icon",
17699
+ "attribute": "icon",
17700
+ "description": "Preset icon key (e.g. \"tier1:gear\")",
17701
+ "type": "string"
17702
+ },
17703
+ {
17704
+ "name": "isToolbarItem",
17705
+ "type": "boolean"
17706
+ }
17707
+ ],
17708
+ "events": [
17709
+ {
17710
+ "name": "d2l-toolbar-toggle-change",
17711
+ "description": "Dispatched when the pressed state changes."
17712
+ }
17713
+ ]
17714
+ },
17715
17715
  {
17716
17716
  "name": "d2l-toolbar",
17717
17717
  "path": "./components/toolbar/toolbar.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.328.0",
3
+ "version": "3.329.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",