@brightspace-ui/core 3.345.0 → 3.347.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.
- package/components/alert/README.md +1 -1
- package/components/alert/alert-toast.js +7 -2
- package/components/toolbar/toolbar-button.js +1 -0
- package/components/toolbar/toolbar-dropdown.js +5 -4
- package/components/toolbar/toolbar-item-styles.js +15 -15
- package/components/toolbar/toolbar-link.js +69 -0
- package/components/toolbar/toolbar-toggle.js +9 -8
- package/custom-elements.json +78 -1
- package/package.json +1 -1
|
@@ -147,7 +147,7 @@ Use a toast alert to provide feedback about an operation the user has just initi
|
|
|
147
147
|
|`type`| String, default: `'default'` | The type of the alert being displayed. Can be one of `default`, `critical`, `success` , `warning` |
|
|
148
148
|
|
|
149
149
|
### Events
|
|
150
|
-
* `d2l-alert-toast-close`: dispatched when the toast is closed
|
|
150
|
+
* `d2l-alert-toast-close`: dispatched when the toast is closed. The `detail` contains a `closeComplete` promise that resolves when the toast's animation completes or it is reopened.
|
|
151
151
|
<!-- docs: end hidden content -->
|
|
152
152
|
|
|
153
153
|
### Multiple Toast Alerts
|
|
@@ -41,7 +41,7 @@ let ALERT_HAS_HOVER = false; // if this alert or sibling alert is hovered on
|
|
|
41
41
|
* A component for communicating important information relating to the state of the system and the user's work flow, displayed as a pop-up at the bottom of the screen that automatically dismisses itself by default.
|
|
42
42
|
* @slot - Default content placed inside of the component
|
|
43
43
|
* @fires d2l-alert-toast-button-press - Dispatched when the toast's action button is clicked
|
|
44
|
-
* @fires d2l-alert-toast-close - Dispatched when the toast is closed
|
|
44
|
+
* @fires d2l-alert-toast-close - Dispatched when the toast is closed. The `detail` contains a `closeComplete` promise that resolves when the toast's animation completes or it is reopened.
|
|
45
45
|
*/
|
|
46
46
|
class AlertToast extends LitElement {
|
|
47
47
|
|
|
@@ -403,6 +403,7 @@ class AlertToast extends LitElement {
|
|
|
403
403
|
this._totalSiblingHeightBelow = 0;
|
|
404
404
|
this._numAlertsBelow = 0;
|
|
405
405
|
this._closeClicked = false;
|
|
406
|
+
this._closeCompleteResolve?.();
|
|
406
407
|
}
|
|
407
408
|
|
|
408
409
|
_onTransitionEnd() {
|
|
@@ -425,6 +426,8 @@ class AlertToast extends LitElement {
|
|
|
425
426
|
|
|
426
427
|
if (this._state === states.CLOSING) {
|
|
427
428
|
this._state = states.OPENING;
|
|
429
|
+
// Make sure to resolve the previous closeComplete promise if we are reopening mid-close
|
|
430
|
+
this._closeCompleteResolve?.();
|
|
428
431
|
} else if (this._state === states.CLOSED) {
|
|
429
432
|
if (!activeReduceMotion) {
|
|
430
433
|
this._state = states.PREOPENING;
|
|
@@ -441,6 +444,8 @@ class AlertToast extends LitElement {
|
|
|
441
444
|
} else {
|
|
442
445
|
if (!this._innerContainer) return;
|
|
443
446
|
|
|
447
|
+
const closeComplete = new Promise(resolve => this._closeCompleteResolve = resolve);
|
|
448
|
+
|
|
444
449
|
if (activeReduceMotion || this._state === states.PREOPENING) {
|
|
445
450
|
cancelAnimationFrame(this._preopenFrame);
|
|
446
451
|
} else if (this._state === states.OPENING || this._state === states.OPEN || this._state === states.SLIDING) {
|
|
@@ -461,7 +466,7 @@ class AlertToast extends LitElement {
|
|
|
461
466
|
'd2l-alert-toast-close', {
|
|
462
467
|
bubbles: true,
|
|
463
468
|
composed: true,
|
|
464
|
-
detail: { bottom, heightDifference: -this._height, opening: false, closing: true }
|
|
469
|
+
detail: { bottom, closeComplete, heightDifference: -this._height, opening: false, closing: true }
|
|
465
470
|
}
|
|
466
471
|
));
|
|
467
472
|
});
|
|
@@ -41,6 +41,7 @@ class ToolbarButton extends SlottedIconMixin(FocusMixin(ToolbarItemMixin(ThemeMi
|
|
|
41
41
|
return html`
|
|
42
42
|
<button
|
|
43
43
|
aria-disabled="${this.disabled ? 'true' : 'false'}"
|
|
44
|
+
class="item"
|
|
44
45
|
@click="${this.#handleClick}"
|
|
45
46
|
id="action-button"
|
|
46
47
|
tabindex="${this._activeFocusable ? 0 : -1}"
|
|
@@ -38,7 +38,7 @@ class ToolbarDropdown extends FocusMixin(DropdownOpenerMixin(SlottedIconMixin(To
|
|
|
38
38
|
:host {
|
|
39
39
|
font-size: 1rem;
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
.item {
|
|
42
42
|
align-items: center;
|
|
43
43
|
display: flex;
|
|
44
44
|
font-size: 0.7rem;
|
|
@@ -49,17 +49,17 @@ class ToolbarDropdown extends FocusMixin(DropdownOpenerMixin(SlottedIconMixin(To
|
|
|
49
49
|
text-align: start;
|
|
50
50
|
width: 100%;
|
|
51
51
|
}
|
|
52
|
-
|
|
52
|
+
.item > .value-text {
|
|
53
53
|
flex: auto;
|
|
54
54
|
overflow: hidden;
|
|
55
55
|
text-overflow: ellipsis;
|
|
56
56
|
white-space: nowrap;
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
.item[aria-expanded="true"] .background {
|
|
59
59
|
background-color: var(--d2l-theme-background-color-interactive-secondary-default);
|
|
60
60
|
transform: scale(1, 1);
|
|
61
61
|
}
|
|
62
|
-
:host([theme="dark"])
|
|
62
|
+
:host([theme="dark"]) .item[aria-expanded="true"] .background {
|
|
63
63
|
background-color: var(--d2l-color-tungsten);
|
|
64
64
|
transform: scale(1, 1);
|
|
65
65
|
}
|
|
@@ -90,6 +90,7 @@ class ToolbarDropdown extends FocusMixin(DropdownOpenerMixin(SlottedIconMixin(To
|
|
|
90
90
|
return html`
|
|
91
91
|
<button
|
|
92
92
|
aria-disabled="${this.disabled ? 'true' : 'false'}"
|
|
93
|
+
class="item"
|
|
93
94
|
id="opener"
|
|
94
95
|
@keydown="${this.#handleKeyDown}"
|
|
95
96
|
tabindex="${this._activeFocusable ? 0 : -1}"
|
|
@@ -9,7 +9,7 @@ export const toolbarButtonStyles = css`
|
|
|
9
9
|
:host([hidden]) {
|
|
10
10
|
display: none;
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
.item {
|
|
13
13
|
--d2l-focus-ring-offset: 0;
|
|
14
14
|
align-items: center;
|
|
15
15
|
background-color: transparent;
|
|
@@ -50,28 +50,28 @@ export const toolbarButtonStyles = css`
|
|
|
50
50
|
transition: background-color 100ms linear, transform 100ms linear;
|
|
51
51
|
z-index: -1;
|
|
52
52
|
}
|
|
53
|
-
${getFocusRingStyles('
|
|
53
|
+
${getFocusRingStyles('.item')}
|
|
54
54
|
@supports not selector(:focus-visible) {
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
.item:hover > .background,
|
|
56
|
+
.item:focus > .background {
|
|
57
57
|
background-color: var(--d2l-theme-background-color-interactive-secondary-default);
|
|
58
58
|
transform: scale(1, 1);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
@supports selector(:focus-visible) {
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
.item:hover > .background,
|
|
63
|
+
.item:focus-visible > .background {
|
|
64
64
|
background-color: var(--d2l-theme-background-color-interactive-secondary-default);
|
|
65
65
|
transform: scale(1, 1);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
.item[disabled],
|
|
69
|
+
.item[aria-disabled="true"] {
|
|
70
70
|
cursor: default;
|
|
71
71
|
opacity: var(--d2l-theme-opacity-disabled-control);
|
|
72
72
|
}
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
.item[disabled]:hover,
|
|
74
|
+
.item[disabled]:focus {
|
|
75
75
|
background-color: transparent;
|
|
76
76
|
fill: var(--d2l-theme-text-color-static-standard);
|
|
77
77
|
}
|
|
@@ -82,18 +82,18 @@ export const toolbarButtonStyles = css`
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
@supports not selector(:focus-visible) {
|
|
85
|
-
:host([theme="dark"])
|
|
86
|
-
:host([theme="dark"])
|
|
85
|
+
:host([theme="dark"]) .item:hover > .background,
|
|
86
|
+
:host([theme="dark"]) .item:focus > .background {
|
|
87
87
|
background-color: var(--d2l-color-tungsten);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
@supports selector(:focus-visible) {
|
|
91
|
-
:host([theme="dark"])
|
|
92
|
-
:host([theme="dark"])
|
|
91
|
+
:host([theme="dark"]) .item:hover > .background,
|
|
92
|
+
:host([theme="dark"]) .item:focus-visible > .background {
|
|
93
93
|
background-color: var(--d2l-color-tungsten);
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
-
:host([theme="dark"])
|
|
96
|
+
:host([theme="dark"]) .item,
|
|
97
97
|
:host([theme="dark"]) ::slotted(d2l-icon-custom),
|
|
98
98
|
:host([theme="dark"]) d2l-icon {
|
|
99
99
|
color: var(--d2l-color-regolith);
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import '../tooltip/tooltip.js';
|
|
2
|
+
import { html, LitElement } from 'lit';
|
|
3
|
+
import { FocusMixin } from '../../mixins/focus/focus-mixin.js';
|
|
4
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
5
|
+
import { LocalizeCoreElement } from '../../helpers/localize-core-element.js';
|
|
6
|
+
import { PropertyRequiredMixin } from '../../mixins/property-required/property-required-mixin.js';
|
|
7
|
+
import { SlottedIconMixin } from '../icons/slotted-icon-mixin.js';
|
|
8
|
+
import { ThemeMixin } from '../../mixins/theme/theme-mixin.js';
|
|
9
|
+
import { toolbarButtonStyles } from './toolbar-item-styles.js';
|
|
10
|
+
import { ToolbarItemMixin } from './toolbar-item-mixin.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* An icon-only link for use in a toolbar.
|
|
14
|
+
*/
|
|
15
|
+
class ToolbarLink extends LocalizeCoreElement(SlottedIconMixin(FocusMixin(ToolbarItemMixin(ThemeMixin(PropertyRequiredMixin(LitElement)))))) {
|
|
16
|
+
|
|
17
|
+
static properties = {
|
|
18
|
+
/** Disables navigation while keeping the link focusable in the toolbar. */
|
|
19
|
+
disabled: { type: Boolean },
|
|
20
|
+
/** REQUIRED: URL or URL fragment of the link. */
|
|
21
|
+
href: { type: String, required: true },
|
|
22
|
+
/** Where to display the linked URL. */
|
|
23
|
+
target: { type: String },
|
|
24
|
+
/** ACCESSIBILITY: REQUIRED: Accessible label and tooltip text for the link. */
|
|
25
|
+
text: { type: String, required: true }
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
static styles = [super.styles, toolbarButtonStyles];
|
|
29
|
+
|
|
30
|
+
constructor() {
|
|
31
|
+
super();
|
|
32
|
+
this.disabled = false;
|
|
33
|
+
this.text = '';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static get focusElementSelector() {
|
|
37
|
+
return 'a';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
render() {
|
|
41
|
+
const opensInNewWindow = !this.disabled && this.target === '_blank';
|
|
42
|
+
return html`
|
|
43
|
+
<a
|
|
44
|
+
aria-description="${ifDefined(opensInNewWindow ? this.localize('components.link.open-in-new-window') : undefined)}"
|
|
45
|
+
aria-disabled="${ifDefined(this.disabled ? 'true' : undefined)}"
|
|
46
|
+
class="item"
|
|
47
|
+
@click="${this.#handleClick}"
|
|
48
|
+
href="${ifDefined(this.disabled ? undefined : this.href)}"
|
|
49
|
+
id="action-link"
|
|
50
|
+
rel="${ifDefined(opensInNewWindow ? 'noopener noreferrer' : undefined)}"
|
|
51
|
+
role="${ifDefined(this.disabled ? 'link' : undefined)}"
|
|
52
|
+
tabindex="${this._activeFocusable ? 0 : -1}"
|
|
53
|
+
target="${ifDefined(this.target)}">
|
|
54
|
+
<span class="background"></span>
|
|
55
|
+
${this._renderIcon()}
|
|
56
|
+
</a>
|
|
57
|
+
<d2l-tooltip class="vdiff-target" for="action-link" for-type="label">${this.text}</d2l-tooltip>
|
|
58
|
+
`;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
#handleClick(event) {
|
|
62
|
+
if (!this.disabled) return;
|
|
63
|
+
event.preventDefault();
|
|
64
|
+
event.stopPropagation();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
customElements.define('d2l-toolbar-link', ToolbarLink);
|
|
@@ -42,23 +42,23 @@ class ToolbarToggle extends SlottedIconMixin(FocusMixin(ToolbarItemMixin(ThemeMi
|
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
static styles = [super.styles, toolbarButtonStyles, css`
|
|
45
|
-
|
|
45
|
+
.item[aria-pressed="true"] > .background {
|
|
46
46
|
background-color: var(--d2l-color-celestine-plus-2);
|
|
47
47
|
transform: scale(1, 1);
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
.item[aria-pressed="true"]:hover > .background {
|
|
50
50
|
background-color: #dbf5ff; /* not a daylight color */
|
|
51
51
|
}
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
.item[aria-pressed="true"] ::slotted(d2l-icon-custom),
|
|
53
|
+
.item[aria-pressed="true"] d2l-icon {
|
|
54
54
|
fill: var(--d2l-color-celestine);
|
|
55
55
|
}
|
|
56
|
-
:host([theme="dark"])
|
|
57
|
-
:host([theme="dark"])
|
|
56
|
+
:host([theme="dark"]) .item[aria-pressed="true"] > .background,
|
|
57
|
+
:host([theme="dark"]) .item[aria-pressed="true"]:hover > .background {
|
|
58
58
|
background-color: var(--d2l-color-tungsten);
|
|
59
59
|
}
|
|
60
|
-
:host([theme="dark"])
|
|
61
|
-
:host([theme="dark"])
|
|
60
|
+
:host([theme="dark"]) .item[aria-pressed="true"] ::slotted(d2l-icon-custom),
|
|
61
|
+
:host([theme="dark"]) .item[aria-pressed="true"] d2l-icon {
|
|
62
62
|
fill: var(--d2l-color-regolith);
|
|
63
63
|
}
|
|
64
64
|
`];
|
|
@@ -82,6 +82,7 @@ class ToolbarToggle extends SlottedIconMixin(FocusMixin(ToolbarItemMixin(ThemeMi
|
|
|
82
82
|
aria-disabled="${this.disabled ? 'true' : 'false'}"
|
|
83
83
|
aria-expanded="${ifDefined(this.expandable ? (this.expanded ? 'true' : 'false') : undefined)}"
|
|
84
84
|
aria-pressed="${ifDefined(!this.expandable ? (this.pressed ? 'true' : 'false') : undefined)}"
|
|
85
|
+
class="item"
|
|
85
86
|
@click="${this.#handleClick}"
|
|
86
87
|
id="action-button"
|
|
87
88
|
tabindex="${this._activeFocusable ? 0 : -1}"
|
package/custom-elements.json
CHANGED
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
},
|
|
95
95
|
{
|
|
96
96
|
"name": "d2l-alert-toast-close",
|
|
97
|
-
"description": "Dispatched when the toast is closed"
|
|
97
|
+
"description": "Dispatched when the toast is closed. The `detail` contains a `closeComplete` promise that resolves when the toast's animation completes or it is reopened."
|
|
98
98
|
}
|
|
99
99
|
],
|
|
100
100
|
"slots": [
|
|
@@ -17594,6 +17594,83 @@
|
|
|
17594
17594
|
}
|
|
17595
17595
|
]
|
|
17596
17596
|
},
|
|
17597
|
+
{
|
|
17598
|
+
"name": "d2l-toolbar-link",
|
|
17599
|
+
"path": "./components/toolbar/toolbar-link.js",
|
|
17600
|
+
"description": "An icon-only link for use in a toolbar.",
|
|
17601
|
+
"attributes": [
|
|
17602
|
+
{
|
|
17603
|
+
"name": "href",
|
|
17604
|
+
"description": "REQUIRED: URL or URL fragment of the link.",
|
|
17605
|
+
"type": "string"
|
|
17606
|
+
},
|
|
17607
|
+
{
|
|
17608
|
+
"name": "target",
|
|
17609
|
+
"description": "Where to display the linked URL.",
|
|
17610
|
+
"type": "string"
|
|
17611
|
+
},
|
|
17612
|
+
{
|
|
17613
|
+
"name": "disabled",
|
|
17614
|
+
"description": "Disables navigation while keeping the link focusable in the toolbar.",
|
|
17615
|
+
"type": "boolean",
|
|
17616
|
+
"default": "false"
|
|
17617
|
+
},
|
|
17618
|
+
{
|
|
17619
|
+
"name": "text",
|
|
17620
|
+
"description": "ACCESSIBILITY: REQUIRED: Accessible label and tooltip text for the link.",
|
|
17621
|
+
"type": "string",
|
|
17622
|
+
"default": "\"\""
|
|
17623
|
+
},
|
|
17624
|
+
{
|
|
17625
|
+
"name": "icon",
|
|
17626
|
+
"description": "Preset icon key (e.g. \"tier1:gear\")",
|
|
17627
|
+
"type": "string"
|
|
17628
|
+
}
|
|
17629
|
+
],
|
|
17630
|
+
"properties": [
|
|
17631
|
+
{
|
|
17632
|
+
"name": "href",
|
|
17633
|
+
"attribute": "href",
|
|
17634
|
+
"description": "REQUIRED: URL or URL fragment of the link.",
|
|
17635
|
+
"type": "string"
|
|
17636
|
+
},
|
|
17637
|
+
{
|
|
17638
|
+
"name": "target",
|
|
17639
|
+
"attribute": "target",
|
|
17640
|
+
"description": "Where to display the linked URL.",
|
|
17641
|
+
"type": "string"
|
|
17642
|
+
},
|
|
17643
|
+
{
|
|
17644
|
+
"name": "styles",
|
|
17645
|
+
"type": "array",
|
|
17646
|
+
"default": "[\"styles\",\"toolbarButtonStyles\"]"
|
|
17647
|
+
},
|
|
17648
|
+
{
|
|
17649
|
+
"name": "disabled",
|
|
17650
|
+
"attribute": "disabled",
|
|
17651
|
+
"description": "Disables navigation while keeping the link focusable in the toolbar.",
|
|
17652
|
+
"type": "boolean",
|
|
17653
|
+
"default": "false"
|
|
17654
|
+
},
|
|
17655
|
+
{
|
|
17656
|
+
"name": "text",
|
|
17657
|
+
"attribute": "text",
|
|
17658
|
+
"description": "ACCESSIBILITY: REQUIRED: Accessible label and tooltip text for the link.",
|
|
17659
|
+
"type": "string",
|
|
17660
|
+
"default": "\"\""
|
|
17661
|
+
},
|
|
17662
|
+
{
|
|
17663
|
+
"name": "icon",
|
|
17664
|
+
"attribute": "icon",
|
|
17665
|
+
"description": "Preset icon key (e.g. \"tier1:gear\")",
|
|
17666
|
+
"type": "string"
|
|
17667
|
+
},
|
|
17668
|
+
{
|
|
17669
|
+
"name": "isToolbarItem",
|
|
17670
|
+
"type": "boolean"
|
|
17671
|
+
}
|
|
17672
|
+
]
|
|
17673
|
+
},
|
|
17597
17674
|
{
|
|
17598
17675
|
"name": "d2l-toolbar-menu-item",
|
|
17599
17676
|
"path": "./components/toolbar/toolbar-menu-item.js",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightspace-ui/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.347.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",
|