@brightspace-ui/core 3.327.2 → 3.329.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.
@@ -0,0 +1,136 @@
1
+ import '../tooltip/tooltip.js';
2
+ import { css, html, LitElement, nothing } from 'lit';
3
+ import { classMap } from 'lit/directives/class-map.js';
4
+ import { DropdownOpenerMixin } from '../dropdown/dropdown-opener-mixin.js';
5
+ import { dropdownOpenerStyles } from '../dropdown/dropdown-opener-styles.js';
6
+ import { FocusMixin } from '../../mixins/focus/focus-mixin.js';
7
+ import { offscreenStyles } from '../offscreen/offscreen.js';
8
+ import { PropertyRequiredMixin } from '../../mixins/property-required/property-required-mixin.js';
9
+ import { SlottedIconMixin } from '../icons/slotted-icon-mixin.js';
10
+ import { ThemeMixin } from '../../mixins/theme/theme-mixin.js';
11
+ import { toolbarButtonStyles } from './toolbar-item-styles.js';
12
+ import { ToolbarItemMixin } from './toolbar-item-mixin.js';
13
+
14
+ /**
15
+ * A toolbar button that opens a dropdown
16
+ */
17
+ class ToolbarDropdown extends FocusMixin(DropdownOpenerMixin(SlottedIconMixin(ToolbarItemMixin(ThemeMixin(PropertyRequiredMixin(LitElement)))))) {
18
+
19
+ static properties = {
20
+ /**
21
+ * Disables the toolbar button
22
+ * @type {boolean}
23
+ */
24
+ disabled: { type: Boolean },
25
+ /**
26
+ * ACCESSIBILITY: REQUIRED: Accessible text for the button
27
+ * @type {string}
28
+ */
29
+ text: { type: String, required: true },
30
+ /**
31
+ * Text describing the value
32
+ * @type {string}
33
+ */
34
+ valueText: { type: String, attribute: 'value-text' }
35
+ };
36
+
37
+ static styles = [super.styles, dropdownOpenerStyles, offscreenStyles, toolbarButtonStyles, css`
38
+ :host {
39
+ font-size: 1rem;
40
+ }
41
+ button {
42
+ align-items: center;
43
+ display: flex;
44
+ font-size: 0.7rem;
45
+ gap: 3px;
46
+ justify-content: center;
47
+ overflow: hidden;
48
+ padding-inline: 6px 4px;
49
+ text-align: start;
50
+ width: 100%;
51
+ }
52
+ button > .value-text {
53
+ flex: auto;
54
+ overflow: hidden;
55
+ text-overflow: ellipsis;
56
+ white-space: nowrap;
57
+ }
58
+ button[aria-expanded="true"] .background {
59
+ background-color: var(--d2l-theme-background-color-interactive-secondary-default);
60
+ transform: scale(1, 1);
61
+ }
62
+ :host([theme="dark"]) button[aria-expanded="true"] .background {
63
+ background-color: var(--d2l-color-tungsten);
64
+ transform: scale(1, 1);
65
+ }
66
+ .tooltip-hidden {
67
+ display: none;
68
+ }
69
+ `];
70
+
71
+ constructor() {
72
+ super();
73
+ this.disabled = false;
74
+ this.text = '';
75
+ }
76
+
77
+ static get focusElementSelector() {
78
+ return 'button';
79
+ }
80
+
81
+ get opened() {
82
+ return this.dropdownOpened;
83
+ }
84
+
85
+ render() {
86
+ const tooltipClasses = {
87
+ 'tooltip-hidden': this.opened,
88
+ 'vdiff-target': true
89
+ };
90
+ return html`
91
+ <button
92
+ aria-disabled="${this.disabled ? 'true' : 'false'}"
93
+ aria-label="${this.text}"
94
+ id="opener"
95
+ @keydown="${this.#handleKeyDown}"
96
+ tabindex="${this._activeFocusable ? 0 : -1}"
97
+ type="button">
98
+ <div class="background"></div>
99
+ ${this._renderIcon()}
100
+ ${this.valueText ? html`<div class="value-text">${this.valueText}</div>` : nothing}
101
+ <d2l-icon icon="tier1:chevron-down-small"></d2l-icon>
102
+ </button>
103
+ <d2l-tooltip class="${classMap(tooltipClasses)}" for="opener">
104
+ ${this.text}
105
+ <span class="d2l-offscreen">${this.valueText}</span>
106
+ </d2l-tooltip>
107
+ <slot></slot>
108
+ `;
109
+ }
110
+
111
+ updated(changedProperties) {
112
+ if (changedProperties.has('disabled') && this.disabled && this.opened) {
113
+ this.closeDropdown(false);
114
+ }
115
+ }
116
+
117
+ /**
118
+ * Gets the "button" opener element (required by dropdown-opener-mixin).
119
+ * @return {HTMLElement}
120
+ */
121
+ getOpenerElement() {
122
+ return this.shadowRoot?.querySelector('button');
123
+ }
124
+
125
+ #handleKeyDown(e) {
126
+ if (e.key !== 'ArrowUp' && e.key !== 'ArrowDown') return;
127
+
128
+ // prevent scroll for up & down keys
129
+ e.preventDefault();
130
+
131
+ if ((e.key === 'ArrowDown' && !this.opened) || (e.key === 'ArrowUp' && this.opened)) this.toggleOpen(true);
132
+ }
133
+
134
+ }
135
+
136
+ customElements.define('d2l-toolbar-dropdown', ToolbarDropdown);
@@ -44,11 +44,10 @@ export const toolbarButtonStyles = css`
44
44
  .background {
45
45
  background-color: transparent;
46
46
  border-radius: 4px;
47
- height: 100%;
47
+ inset: 0;
48
48
  position: absolute;
49
49
  transform: scale(0.89, 0.89);
50
50
  transition: background-color 100ms linear, transform 100ms linear;
51
- width: 100%;
52
51
  z-index: -1;
53
52
  }
54
53
  ${getFocusRingStyles('button')}
@@ -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);
@@ -17430,9 +17430,9 @@
17430
17430
  ]
17431
17431
  },
17432
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",
17433
+ "name": "d2l-toolbar-button",
17434
+ "path": "./components/toolbar/toolbar-button.js",
17435
+ "description": "A toolbar button that performs an action",
17436
17436
  "attributes": [
17437
17437
  {
17438
17438
  "name": "disabled",
@@ -17440,24 +17440,6 @@
17440
17440
  "type": "boolean",
17441
17441
  "default": "false"
17442
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
17443
  {
17462
17444
  "name": "text",
17463
17445
  "description": "ACCESSIBILITY: REQUIRED: Accessible text for the button",
@@ -17474,7 +17456,7 @@
17474
17456
  {
17475
17457
  "name": "styles",
17476
17458
  "type": "array",
17477
- "default": "[[null],\"toolbarButtonStyles\",null]"
17459
+ "default": "[[null],\"toolbarButtonStyles\"]"
17478
17460
  },
17479
17461
  {
17480
17462
  "name": "disabled",
@@ -17484,26 +17466,85 @@
17484
17466
  "default": "false"
17485
17467
  },
17486
17468
  {
17487
- "name": "expandable",
17488
- "attribute": "expandable",
17489
- "description": "Expandable state",
17469
+ "name": "text",
17470
+ "attribute": "text",
17471
+ "description": "ACCESSIBILITY: REQUIRED: Accessible text for the button",
17472
+ "type": "string",
17473
+ "default": "\"\""
17474
+ },
17475
+ {
17476
+ "name": "icon",
17477
+ "attribute": "icon",
17478
+ "description": "Preset icon key (e.g. \"tier1:gear\")",
17479
+ "type": "string"
17480
+ },
17481
+ {
17482
+ "name": "isToolbarItem",
17483
+ "type": "boolean"
17484
+ }
17485
+ ],
17486
+ "events": [
17487
+ {
17488
+ "name": "click",
17489
+ "description": "Dispatched when the toggle is clicked."
17490
+ }
17491
+ ]
17492
+ },
17493
+ {
17494
+ "name": "d2l-toolbar-dropdown",
17495
+ "path": "./components/toolbar/toolbar-dropdown.js",
17496
+ "description": "A toolbar button that opens a dropdown",
17497
+ "attributes": [
17498
+ {
17499
+ "name": "value-text",
17500
+ "description": "Text describing the value",
17501
+ "type": "string"
17502
+ },
17503
+ {
17504
+ "name": "text",
17505
+ "description": "ACCESSIBILITY: REQUIRED: Accessible text for the button",
17506
+ "type": "string",
17507
+ "default": "\"\""
17508
+ },
17509
+ {
17510
+ "name": "no-auto-open",
17511
+ "description": "Prevents the dropdown from opening automatically on or on key press",
17490
17512
  "type": "boolean",
17491
17513
  "default": "false"
17492
17514
  },
17493
17515
  {
17494
- "name": "expanded",
17495
- "attribute": "expanded",
17496
- "description": "Expanded state",
17516
+ "name": "open-on-hover",
17517
+ "description": "Optionally open dropdown on click or hover action",
17497
17518
  "type": "boolean",
17498
17519
  "default": "false"
17499
17520
  },
17500
17521
  {
17501
- "name": "pressed",
17502
- "attribute": "pressed",
17503
- "description": "Pressed state",
17522
+ "name": "disabled",
17523
+ "description": "Disables the toolbar button",
17504
17524
  "type": "boolean",
17505
17525
  "default": "false"
17506
17526
  },
17527
+ {
17528
+ "name": "icon",
17529
+ "description": "Preset icon key (e.g. \"tier1:gear\")",
17530
+ "type": "string"
17531
+ }
17532
+ ],
17533
+ "properties": [
17534
+ {
17535
+ "name": "valueText",
17536
+ "attribute": "value-text",
17537
+ "description": "Text describing the value",
17538
+ "type": "string"
17539
+ },
17540
+ {
17541
+ "name": "styles",
17542
+ "type": "array",
17543
+ "default": "[\"styles\",\"dropdownOpenerStyles\",\"offscreenStyles\",\"toolbarButtonStyles\",null]"
17544
+ },
17545
+ {
17546
+ "name": "opened"
17547
+ },
17507
17548
  {
17508
17549
  "name": "text",
17509
17550
  "attribute": "text",
@@ -17511,6 +17552,37 @@
17511
17552
  "type": "string",
17512
17553
  "default": "\"\""
17513
17554
  },
17555
+ {
17556
+ "name": "dropdownOpener",
17557
+ "type": "boolean",
17558
+ "default": "true"
17559
+ },
17560
+ {
17561
+ "name": "noAutoOpen",
17562
+ "attribute": "no-auto-open",
17563
+ "description": "Prevents the dropdown from opening automatically on or on key press",
17564
+ "type": "boolean",
17565
+ "default": "false"
17566
+ },
17567
+ {
17568
+ "name": "openOnHover",
17569
+ "attribute": "open-on-hover",
17570
+ "description": "Optionally open dropdown on click or hover action",
17571
+ "type": "boolean",
17572
+ "default": "false"
17573
+ },
17574
+ {
17575
+ "name": "disabled",
17576
+ "attribute": "disabled",
17577
+ "description": "Disables the toolbar button",
17578
+ "type": "boolean",
17579
+ "default": "false"
17580
+ },
17581
+ {
17582
+ "name": "dropdownOpened",
17583
+ "type": "boolean",
17584
+ "default": "false"
17585
+ },
17514
17586
  {
17515
17587
  "name": "icon",
17516
17588
  "attribute": "icon",
@@ -17524,25 +17596,54 @@
17524
17596
  ],
17525
17597
  "events": [
17526
17598
  {
17527
- "name": "d2l-toolbar-button-toggle-change",
17528
- "description": "Dispatched when the pressed state changes."
17599
+ "name": "d2l-dropdown-opener-click",
17600
+ "description": "Dispatched when the opener is clicked, useful for when no-auto-open is enabled"
17529
17601
  }
17530
17602
  ]
17531
17603
  },
17532
17604
  {
17533
- "name": "d2l-toolbar-button",
17534
- "path": "./components/toolbar/toolbar-button.js",
17535
- "description": "A toolbar button that performs an action",
17605
+ "name": "d2l-toolbar-separator",
17606
+ "path": "./components/toolbar/toolbar-separator.js",
17607
+ "description": "A toolbar item separator",
17608
+ "properties": [
17609
+ {
17610
+ "name": "styles",
17611
+ "default": "\"css`\\n\\t\\t:host {\\n\\t\\t\\tdisplay: inline-block;\\n\\t\\t}\\n\\t\\t:host([hidden]) {\\n\\t\\t\\tdisplay: none;\\n\\t\\t}\\n\\t\\tdiv {\\n\\t\\t\\tborder-inline-start: 1px solid var(--d2l-theme-border-color-standard);\\n\\t\\t\\tmin-height: 34px;\\n\\t\\t}\\n\\t\\t:host([theme=\\\"dark\\\"]) div {\\n\\t\\t\\tborder-inline-start: 1px solid var(--d2l-color-tungsten);\\n\\t\\t}\\n\\t`\""
17612
+ }
17613
+ ]
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",
17536
17619
  "attributes": [
17537
17620
  {
17538
17621
  "name": "disabled",
17539
- "description": "Disables the toolbar button",
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",
17540
17641
  "type": "boolean",
17541
17642
  "default": "false"
17542
17643
  },
17543
17644
  {
17544
17645
  "name": "text",
17545
- "description": "ACCESSIBILITY: REQUIRED: Accessible text for the button",
17646
+ "description": "ACCESSIBILITY: REQUIRED: Accessible text for the toggle button",
17546
17647
  "type": "string",
17547
17648
  "default": "\"\""
17548
17649
  },
@@ -17556,19 +17657,40 @@
17556
17657
  {
17557
17658
  "name": "styles",
17558
17659
  "type": "array",
17559
- "default": "[[null],\"toolbarButtonStyles\"]"
17660
+ "default": "[[null],\"toolbarButtonStyles\",null]"
17560
17661
  },
17561
17662
  {
17562
17663
  "name": "disabled",
17563
17664
  "attribute": "disabled",
17564
- "description": "Disables the toolbar button",
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",
17565
17687
  "type": "boolean",
17566
17688
  "default": "false"
17567
17689
  },
17568
17690
  {
17569
17691
  "name": "text",
17570
17692
  "attribute": "text",
17571
- "description": "ACCESSIBILITY: REQUIRED: Accessible text for the button",
17693
+ "description": "ACCESSIBILITY: REQUIRED: Accessible text for the toggle button",
17572
17694
  "type": "string",
17573
17695
  "default": "\"\""
17574
17696
  },
@@ -17585,19 +17707,8 @@
17585
17707
  ],
17586
17708
  "events": [
17587
17709
  {
17588
- "name": "click",
17589
- "description": "Dispatched when the toggle is clicked."
17590
- }
17591
- ]
17592
- },
17593
- {
17594
- "name": "d2l-toolbar-separator",
17595
- "path": "./components/toolbar/toolbar-separator.js",
17596
- "description": "A toolbar item separator",
17597
- "properties": [
17598
- {
17599
- "name": "styles",
17600
- "default": "\"css`\\n\\t\\t:host {\\n\\t\\t\\tdisplay: inline-block;\\n\\t\\t}\\n\\t\\t:host([hidden]) {\\n\\t\\t\\tdisplay: none;\\n\\t\\t}\\n\\t\\tdiv {\\n\\t\\t\\tborder-inline-start: 1px solid var(--d2l-theme-border-color-standard);\\n\\t\\t\\tmin-height: 34px;\\n\\t\\t}\\n\\t\\t:host([theme=\\\"dark\\\"]) div {\\n\\t\\t\\tborder-inline-start: 1px solid var(--d2l-color-tungsten);\\n\\t\\t}\\n\\t`\""
17710
+ "name": "d2l-toolbar-toggle-change",
17711
+ "description": "Dispatched when the pressed state changes."
17601
17712
  }
17602
17713
  ]
17603
17714
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.327.2",
3
+ "version": "3.329.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",