@brightspace-ui/core 3.324.0 → 3.325.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,111 @@
|
|
|
1
|
+
import { css, html, LitElement } from 'lit';
|
|
2
|
+
import { FocusMixin } from '../../mixins/focus/focus-mixin.js';
|
|
3
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
4
|
+
import { PropertyRequiredMixin } from '../../mixins/property-required/property-required-mixin.js';
|
|
5
|
+
import { SlottedIconMixin } from '../icons/slotted-icon-mixin.js';
|
|
6
|
+
import { ThemeMixin } from '../../mixins/theme/theme-mixin.js';
|
|
7
|
+
import { toolbarButtonStyles } from './toolbar-item-styles.js';
|
|
8
|
+
import { ToolbarItemMixin } from './toolbar-item-mixin.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A toolbar toggle button that performs an action and supports pressed and expanded states
|
|
12
|
+
*/
|
|
13
|
+
class ToolbarButtonToggle extends SlottedIconMixin(FocusMixin(ToolbarItemMixin(ThemeMixin(PropertyRequiredMixin(LitElement))))) {
|
|
14
|
+
|
|
15
|
+
static properties = {
|
|
16
|
+
/**
|
|
17
|
+
* Disables the toolbar button
|
|
18
|
+
* @type {boolean}
|
|
19
|
+
*/
|
|
20
|
+
disabled: { type: Boolean },
|
|
21
|
+
/**
|
|
22
|
+
* Expandable state
|
|
23
|
+
* @type {boolean}
|
|
24
|
+
*/
|
|
25
|
+
expandable: { type: Boolean },
|
|
26
|
+
/**
|
|
27
|
+
* Expanded state
|
|
28
|
+
* @type {boolean}
|
|
29
|
+
*/
|
|
30
|
+
expanded: { type: Boolean },
|
|
31
|
+
/**
|
|
32
|
+
* Pressed state
|
|
33
|
+
* @type {boolean}
|
|
34
|
+
*/
|
|
35
|
+
pressed: { type: Boolean },
|
|
36
|
+
/**
|
|
37
|
+
* ACCESSIBILITY: REQUIRED: Accessible text for the button
|
|
38
|
+
* @type {string}
|
|
39
|
+
*/
|
|
40
|
+
text: { type: String, required: true }
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
static styles = [super.styles, toolbarButtonStyles, css`
|
|
44
|
+
button[aria-pressed="true"] > .background {
|
|
45
|
+
background-color: var(--d2l-color-celestine-plus-2);
|
|
46
|
+
transform: scale(1, 1);
|
|
47
|
+
}
|
|
48
|
+
button[aria-pressed="true"]:hover > .background {
|
|
49
|
+
background-color: #dbf5ff; /* not a daylight color */
|
|
50
|
+
}
|
|
51
|
+
button[aria-pressed="true"] ::slotted(d2l-icon-custom),
|
|
52
|
+
button[aria-pressed="true"] d2l-icon {
|
|
53
|
+
fill: var(--d2l-color-celestine);
|
|
54
|
+
}
|
|
55
|
+
:host([theme="dark"]) button[aria-pressed="true"] > .background,
|
|
56
|
+
:host([theme="dark"]) button[aria-pressed="true"]:hover > .background {
|
|
57
|
+
background-color: var(--d2l-color-tungsten);
|
|
58
|
+
}
|
|
59
|
+
:host([theme="dark"]) button[aria-pressed="true"] ::slotted(d2l-icon-custom),
|
|
60
|
+
:host([theme="dark"]) button[aria-pressed="true"] d2l-icon {
|
|
61
|
+
fill: var(--d2l-color-regolith);
|
|
62
|
+
}
|
|
63
|
+
`];
|
|
64
|
+
|
|
65
|
+
constructor() {
|
|
66
|
+
super();
|
|
67
|
+
this.disabled = false;
|
|
68
|
+
this.expandable = false;
|
|
69
|
+
this.expanded = false;
|
|
70
|
+
this.pressed = false;
|
|
71
|
+
this.text = '';
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
static get focusElementSelector() {
|
|
75
|
+
return 'button';
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
render() {
|
|
79
|
+
return html`
|
|
80
|
+
<button
|
|
81
|
+
aria-disabled="${this.disabled ? 'true' : 'false'}"
|
|
82
|
+
aria-expanded="${ifDefined(this.expandable ? (this.expanded ? 'true' : 'false') : undefined)}"
|
|
83
|
+
aria-label="${this.text}"
|
|
84
|
+
aria-pressed="${ifDefined(!this.expandable ? (this.pressed ? 'true' : 'false') : undefined)}"
|
|
85
|
+
@click="${this.#handleClick}"
|
|
86
|
+
tabindex="${this._activeFocusable ? 0 : -1}"
|
|
87
|
+
title="${this.text}"
|
|
88
|
+
type="button">
|
|
89
|
+
<div class="background"></div>
|
|
90
|
+
${this._renderIcon()}
|
|
91
|
+
</button>
|
|
92
|
+
`;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
#handleClick(e) {
|
|
96
|
+
e.stopPropagation();
|
|
97
|
+
if (this.disabled) return;
|
|
98
|
+
|
|
99
|
+
if (this.expandable) {
|
|
100
|
+
this.expanded = !this.expanded;
|
|
101
|
+
} else {
|
|
102
|
+
this.pressed = !this.pressed;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Dispatched when the pressed state changes. */
|
|
106
|
+
this.dispatchEvent(new CustomEvent('d2l-toolbar-button-toggle-change'));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
customElements.define('d2l-toolbar-button-toggle', ToolbarButtonToggle);
|
|
@@ -4,11 +4,12 @@ import { PropertyRequiredMixin } from '../../mixins/property-required/property-r
|
|
|
4
4
|
import { SlottedIconMixin } from '../icons/slotted-icon-mixin.js';
|
|
5
5
|
import { ThemeMixin } from '../../mixins/theme/theme-mixin.js';
|
|
6
6
|
import { toolbarButtonStyles } from './toolbar-item-styles.js';
|
|
7
|
+
import { ToolbarItemMixin } from './toolbar-item-mixin.js';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* A toolbar button that performs an action
|
|
10
11
|
*/
|
|
11
|
-
class ToolbarButton extends SlottedIconMixin(FocusMixin(ThemeMixin(PropertyRequiredMixin(LitElement)))) {
|
|
12
|
+
class ToolbarButton extends SlottedIconMixin(FocusMixin(ToolbarItemMixin(ThemeMixin(PropertyRequiredMixin(LitElement))))) {
|
|
12
13
|
|
|
13
14
|
static properties = {
|
|
14
15
|
/**
|
|
@@ -20,8 +21,7 @@ class ToolbarButton extends SlottedIconMixin(FocusMixin(ThemeMixin(PropertyRequi
|
|
|
20
21
|
* ACCESSIBILITY: REQUIRED: Accessible text for the button
|
|
21
22
|
* @type {string}
|
|
22
23
|
*/
|
|
23
|
-
text: { type: String, required: true }
|
|
24
|
-
_activeFocusable: { state: true }
|
|
24
|
+
text: { type: String, required: true }
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
static styles = [super.styles, toolbarButtonStyles];
|
|
@@ -30,7 +30,6 @@ class ToolbarButton extends SlottedIconMixin(FocusMixin(ThemeMixin(PropertyRequi
|
|
|
30
30
|
super();
|
|
31
31
|
this.disabled = false;
|
|
32
32
|
this.text = '';
|
|
33
|
-
this._activeFocusable = false;
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
static get focusElementSelector() {
|
|
@@ -53,7 +52,11 @@ class ToolbarButton extends SlottedIconMixin(FocusMixin(ThemeMixin(PropertyRequi
|
|
|
53
52
|
}
|
|
54
53
|
|
|
55
54
|
#handleClick(e) {
|
|
56
|
-
|
|
55
|
+
e.stopPropagation();
|
|
56
|
+
if (this.disabled) return;
|
|
57
|
+
|
|
58
|
+
/** Dispatched when the toggle is clicked. */
|
|
59
|
+
this.dispatchEvent(new CustomEvent('click'));
|
|
57
60
|
}
|
|
58
61
|
|
|
59
62
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const ToolbarItemMixin = superclass => class extends superclass {
|
|
2
|
+
|
|
3
|
+
static properties = {
|
|
4
|
+
_activeFocusable: { state: true }
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
this._activeFocusable = false;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
get isToolbarItem() {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
};
|
|
@@ -81,7 +81,7 @@ class Toolbar extends PropertyRequiredMixin(LitElement) {
|
|
|
81
81
|
|
|
82
82
|
#getFocusables() {
|
|
83
83
|
return this.#slotRef.value?.assignedElements({ flatten: true })
|
|
84
|
-
.filter(elem => elem.
|
|
84
|
+
.filter(elem => elem.isToolbarItem) ?? [];
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
async #handleKeyDown(e) {
|
package/custom-elements.json
CHANGED
|
@@ -17365,6 +17365,106 @@
|
|
|
17365
17365
|
}
|
|
17366
17366
|
]
|
|
17367
17367
|
},
|
|
17368
|
+
{
|
|
17369
|
+
"name": "d2l-toolbar-button-toggle",
|
|
17370
|
+
"path": "./components/toolbar/toolbar-button-toggle.js",
|
|
17371
|
+
"description": "A toolbar toggle button that performs an action and supports pressed and expanded states",
|
|
17372
|
+
"attributes": [
|
|
17373
|
+
{
|
|
17374
|
+
"name": "disabled",
|
|
17375
|
+
"description": "Disables the toolbar button",
|
|
17376
|
+
"type": "boolean",
|
|
17377
|
+
"default": "false"
|
|
17378
|
+
},
|
|
17379
|
+
{
|
|
17380
|
+
"name": "expandable",
|
|
17381
|
+
"description": "Expandable state",
|
|
17382
|
+
"type": "boolean",
|
|
17383
|
+
"default": "false"
|
|
17384
|
+
},
|
|
17385
|
+
{
|
|
17386
|
+
"name": "expanded",
|
|
17387
|
+
"description": "Expanded state",
|
|
17388
|
+
"type": "boolean",
|
|
17389
|
+
"default": "false"
|
|
17390
|
+
},
|
|
17391
|
+
{
|
|
17392
|
+
"name": "pressed",
|
|
17393
|
+
"description": "Pressed state",
|
|
17394
|
+
"type": "boolean",
|
|
17395
|
+
"default": "false"
|
|
17396
|
+
},
|
|
17397
|
+
{
|
|
17398
|
+
"name": "text",
|
|
17399
|
+
"description": "ACCESSIBILITY: REQUIRED: Accessible text for the button",
|
|
17400
|
+
"type": "string",
|
|
17401
|
+
"default": "\"\""
|
|
17402
|
+
},
|
|
17403
|
+
{
|
|
17404
|
+
"name": "icon",
|
|
17405
|
+
"description": "Preset icon key (e.g. \"tier1:gear\")",
|
|
17406
|
+
"type": "string"
|
|
17407
|
+
}
|
|
17408
|
+
],
|
|
17409
|
+
"properties": [
|
|
17410
|
+
{
|
|
17411
|
+
"name": "styles",
|
|
17412
|
+
"type": "array",
|
|
17413
|
+
"default": "[[null],\"toolbarButtonStyles\",null]"
|
|
17414
|
+
},
|
|
17415
|
+
{
|
|
17416
|
+
"name": "disabled",
|
|
17417
|
+
"attribute": "disabled",
|
|
17418
|
+
"description": "Disables the toolbar button",
|
|
17419
|
+
"type": "boolean",
|
|
17420
|
+
"default": "false"
|
|
17421
|
+
},
|
|
17422
|
+
{
|
|
17423
|
+
"name": "expandable",
|
|
17424
|
+
"attribute": "expandable",
|
|
17425
|
+
"description": "Expandable state",
|
|
17426
|
+
"type": "boolean",
|
|
17427
|
+
"default": "false"
|
|
17428
|
+
},
|
|
17429
|
+
{
|
|
17430
|
+
"name": "expanded",
|
|
17431
|
+
"attribute": "expanded",
|
|
17432
|
+
"description": "Expanded state",
|
|
17433
|
+
"type": "boolean",
|
|
17434
|
+
"default": "false"
|
|
17435
|
+
},
|
|
17436
|
+
{
|
|
17437
|
+
"name": "pressed",
|
|
17438
|
+
"attribute": "pressed",
|
|
17439
|
+
"description": "Pressed state",
|
|
17440
|
+
"type": "boolean",
|
|
17441
|
+
"default": "false"
|
|
17442
|
+
},
|
|
17443
|
+
{
|
|
17444
|
+
"name": "text",
|
|
17445
|
+
"attribute": "text",
|
|
17446
|
+
"description": "ACCESSIBILITY: REQUIRED: Accessible text for the button",
|
|
17447
|
+
"type": "string",
|
|
17448
|
+
"default": "\"\""
|
|
17449
|
+
},
|
|
17450
|
+
{
|
|
17451
|
+
"name": "icon",
|
|
17452
|
+
"attribute": "icon",
|
|
17453
|
+
"description": "Preset icon key (e.g. \"tier1:gear\")",
|
|
17454
|
+
"type": "string"
|
|
17455
|
+
},
|
|
17456
|
+
{
|
|
17457
|
+
"name": "isToolbarItem",
|
|
17458
|
+
"type": "boolean"
|
|
17459
|
+
}
|
|
17460
|
+
],
|
|
17461
|
+
"events": [
|
|
17462
|
+
{
|
|
17463
|
+
"name": "d2l-toolbar-button-toggle-change",
|
|
17464
|
+
"description": "Dispatched when the pressed state changes."
|
|
17465
|
+
}
|
|
17466
|
+
]
|
|
17467
|
+
},
|
|
17368
17468
|
{
|
|
17369
17469
|
"name": "d2l-toolbar-button",
|
|
17370
17470
|
"path": "./components/toolbar/toolbar-button.js",
|
|
@@ -17413,6 +17513,16 @@
|
|
|
17413
17513
|
"attribute": "icon",
|
|
17414
17514
|
"description": "Preset icon key (e.g. \"tier1:gear\")",
|
|
17415
17515
|
"type": "string"
|
|
17516
|
+
},
|
|
17517
|
+
{
|
|
17518
|
+
"name": "isToolbarItem",
|
|
17519
|
+
"type": "boolean"
|
|
17520
|
+
}
|
|
17521
|
+
],
|
|
17522
|
+
"events": [
|
|
17523
|
+
{
|
|
17524
|
+
"name": "click",
|
|
17525
|
+
"description": "Dispatched when the toggle is clicked."
|
|
17416
17526
|
}
|
|
17417
17527
|
]
|
|
17418
17528
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightspace-ui/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.325.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",
|