@brightspace-ui/core 3.67.0 → 3.68.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -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 d2l-button-toggle-before-change - Dispatched before pressed state is updated. Can be canceled to allow the consumer to handle toggling pressed state. This is useful if something needs to happen prior to the pressed state being toggled.
|
5
6
|
*/
|
6
7
|
class ButtonToggle extends LitElement {
|
7
8
|
|
@@ -79,9 +80,16 @@ class ButtonToggle extends LitElement {
|
|
79
80
|
}
|
80
81
|
|
81
82
|
async _handleClick(pressed) {
|
82
|
-
|
83
|
-
|
84
|
-
|
83
|
+
const beforeToggleEvent = new CustomEvent('d2l-button-toggle-before-change', {
|
84
|
+
detail: {
|
85
|
+
update: (newPressed) => this._updatePressedState(newPressed)
|
86
|
+
},
|
87
|
+
cancelable: true
|
88
|
+
});
|
89
|
+
this.dispatchEvent(beforeToggleEvent);
|
90
|
+
if (beforeToggleEvent.defaultPrevented) return;
|
91
|
+
|
92
|
+
this._updatePressedState(pressed);
|
85
93
|
}
|
86
94
|
|
87
95
|
_handleNotPressedClick() {
|
@@ -92,6 +100,12 @@ class ButtonToggle extends LitElement {
|
|
92
100
|
this._handleClick(false);
|
93
101
|
}
|
94
102
|
|
103
|
+
async _updatePressedState(newPressed) {
|
104
|
+
this.pressed = newPressed;
|
105
|
+
await this.updateComplete;
|
106
|
+
this.focus();
|
107
|
+
}
|
108
|
+
|
95
109
|
}
|
96
110
|
|
97
111
|
customElements.define('d2l-button-toggle', ButtonToggle);
|
@@ -54,6 +54,26 @@
|
|
54
54
|
</template>
|
55
55
|
</d2l-demo-snippet>
|
56
56
|
|
57
|
+
<h2>Toggle Button (with consumer specifying when to toggle)</h2>
|
58
|
+
|
59
|
+
<d2l-demo-snippet>
|
60
|
+
<template>
|
61
|
+
<d2l-button-toggle id="toggle-button-icon-promise-delay">
|
62
|
+
<d2l-button-icon slot="not-pressed" icon="tier1:pin-hollow" text="Unpinned, click to pin."></d2l-button-icon>
|
63
|
+
<d2l-button-icon slot="pressed" icon="tier1:pin-filled" text="Pinned, click to unpin."></d2l-button-icon>
|
64
|
+
</d2l-button-toggle>
|
65
|
+
<script>
|
66
|
+
document.querySelector('#toggle-button-icon-promise-delay').addEventListener('d2l-button-toggle-before-change', e => {
|
67
|
+
e.preventDefault();
|
68
|
+
setTimeout(() => {
|
69
|
+
e.detail.update(!e.target.pressed);
|
70
|
+
}, 2000);
|
71
|
+
});
|
72
|
+
document.querySelector('#toggle-button-icon-promise-delay').addEventListener('d2l-button-toggle-change', e => console.log(e));
|
73
|
+
</script>
|
74
|
+
</template>
|
75
|
+
</d2l-demo-snippet>
|
76
|
+
|
57
77
|
</d2l-demo-page>
|
58
78
|
|
59
79
|
</body>
|
package/custom-elements.json
CHANGED
@@ -739,6 +739,10 @@
|
|
739
739
|
}
|
740
740
|
],
|
741
741
|
"events": [
|
742
|
+
{
|
743
|
+
"name": "d2l-button-toggle-before-change",
|
744
|
+
"description": "Dispatched before pressed state is updated. Can be canceled to allow the consumer to handle toggling pressed state. This is useful if something needs to happen prior to the pressed state being toggled."
|
745
|
+
},
|
742
746
|
{
|
743
747
|
"name": "d2l-button-toggle-change",
|
744
748
|
"description": "Dispatched when the pressed state changes"
|
package/lang/fr.js
CHANGED
@@ -117,7 +117,7 @@ export default {
|
|
117
117
|
"components.selection-controls.label": "Actions à sélectionner",
|
118
118
|
"components.switch.visible": "Visible",
|
119
119
|
"components.switch.visibleWithPeriod": "Visible.",
|
120
|
-
"components.switch.hidden": "Masqué
|
120
|
+
"components.switch.hidden": "Masqué",
|
121
121
|
"components.switch.conditions": "Les conditions doivent être remplies",
|
122
122
|
"components.table-col-sort-button.addSortOrder": "Sélectionner pour ajouter un ordre de tri",
|
123
123
|
"components.table-col-sort-button.changeSortOrder": "Sélectionner pour modifier l'ordre de tri",
|
package/lang/hi.js
CHANGED
@@ -43,7 +43,7 @@ export default {
|
|
43
43
|
"components.form-element.input.number.rangeUnderflow": "{minExclusive, select, true {संख्या {min} से ज़्यादा होनी चाहिए.} other {संख्या {min} से ज़्यादा या उसके बराबर होनी चाहिए.}}",
|
44
44
|
"components.form-element.input.text.tooShort": "{label} कम से कम {minlength} वर्णों का होना चाहिए",
|
45
45
|
"components.form-element.input.url.typeMismatch": "URL मान्य नहीं है",
|
46
|
-
"components.form-element.valueMissing": "{label}
|
46
|
+
"components.form-element.valueMissing": "{label} ज़रूरी है",
|
47
47
|
"components.form-error-summary.errorSummary": "{count, plural, one {आपके द्वारा सबमिट की गई जानकारी में {count} त्रुटियाँ पाई गईं} other {आपके द्वारा सबमिट की गई जानकारी में {count} त्रुटियाँ पाई गईं}}",
|
48
48
|
"components.form-error-summary.text": "त्रुटि विवरण टॉगल करें",
|
49
49
|
"components.input-color.backgroundColor": "पृष्ठभूमि का रंग",
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@brightspace-ui/core",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.68.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",
|