@brightspace-ui/core 3.65.0 → 3.66.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.
|
@@ -2,6 +2,7 @@ import { css, html, LitElement } from 'lit';
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* A button container component for button toggles.
|
|
5
|
+
* @fires click - Internal event
|
|
5
6
|
*/
|
|
6
7
|
class ButtonToggle extends LitElement {
|
|
7
8
|
|
|
@@ -78,17 +79,28 @@ class ButtonToggle extends LitElement {
|
|
|
78
79
|
elem.focus();
|
|
79
80
|
}
|
|
80
81
|
|
|
82
|
+
_clickCancelled(e) {
|
|
83
|
+
e.stopPropagation();
|
|
84
|
+
const customClick = new CustomEvent('click', {
|
|
85
|
+
cancelable: true
|
|
86
|
+
});
|
|
87
|
+
e.target.dispatchEvent(customClick);
|
|
88
|
+
return customClick.defaultPrevented;
|
|
89
|
+
}
|
|
90
|
+
|
|
81
91
|
async _handleClick(pressed) {
|
|
82
92
|
this.pressed = pressed;
|
|
83
93
|
await this.updateComplete;
|
|
84
94
|
this.focus();
|
|
85
95
|
}
|
|
86
96
|
|
|
87
|
-
_handleNotPressedClick() {
|
|
97
|
+
_handleNotPressedClick(e) {
|
|
98
|
+
if (this._clickCancelled(e)) return;
|
|
88
99
|
this._handleClick(true);
|
|
89
100
|
}
|
|
90
101
|
|
|
91
|
-
_handlePressedClick() {
|
|
102
|
+
_handlePressedClick(e) {
|
|
103
|
+
if (this._clickCancelled(e)) return;
|
|
92
104
|
this._handleClick(false);
|
|
93
105
|
}
|
|
94
106
|
|
|
@@ -54,6 +54,30 @@
|
|
|
54
54
|
</template>
|
|
55
55
|
</d2l-demo-snippet>
|
|
56
56
|
|
|
57
|
+
<h2>Toggle Button (consumer manages state)</h2>
|
|
58
|
+
|
|
59
|
+
<d2l-demo-snippet>
|
|
60
|
+
<template>
|
|
61
|
+
<d2l-button-toggle id="toggle-button-icon-consumer-manage-state">
|
|
62
|
+
<d2l-button-icon slot="not-pressed" icon="tier1:pin-hollow" text="Unpinned, click to pin." id="button-icon-not-pressed"></d2l-button-icon>
|
|
63
|
+
<d2l-button-icon slot="pressed" icon="tier1:pin-filled" text="Pinned, click to unpin." id="button-icon-pressed"></d2l-button-icon>
|
|
64
|
+
</d2l-button-toggle>
|
|
65
|
+
<script>
|
|
66
|
+
const buttonToggle = document.querySelector('#toggle-button-icon-consumer-manage-state');
|
|
67
|
+
buttonToggle.addEventListener('d2l-button-toggle-change', e => console.log(e));
|
|
68
|
+
|
|
69
|
+
document.querySelector('#button-icon-not-pressed').addEventListener('click', (e) => {
|
|
70
|
+
e.preventDefault();
|
|
71
|
+
buttonToggle.pressed = true;
|
|
72
|
+
});
|
|
73
|
+
document.querySelector('#button-icon-pressed').addEventListener('click', (e) => {
|
|
74
|
+
e.preventDefault();
|
|
75
|
+
buttonToggle.pressed = false;
|
|
76
|
+
});
|
|
77
|
+
</script>
|
|
78
|
+
</template>
|
|
79
|
+
</d2l-demo-snippet>
|
|
80
|
+
|
|
57
81
|
</d2l-demo-page>
|
|
58
82
|
|
|
59
83
|
</body>
|
package/custom-elements.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightspace-ui/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.66.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",
|