@brightspace-ui/core 2.181.0 → 2.182.1
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.
@@ -22,6 +22,7 @@ A switch is used to toggle between two states, on and off, just like a light swi
|
|
22
22
|
|
23
23
|
<!-- docs: start donts -->
|
24
24
|
* Don't toggle the language in the label, it should remain static
|
25
|
+
* The [Visibility Switch](#d2l-switch-visibility) is a necessary exception to this rule
|
25
26
|
* Don't use a switch in a form, use a checkbox or radio options in stead
|
26
27
|
<!-- docs: end donts -->
|
27
28
|
<!-- docs: end best practices -->
|
@@ -18,6 +18,25 @@ const keyCodes = {
|
|
18
18
|
ENTER: 13,
|
19
19
|
SPACE: 32
|
20
20
|
};
|
21
|
+
let hasDisplayedKeyboardTooltip = false;
|
22
|
+
let tabPressed = false;
|
23
|
+
let tabListenerAdded = false;
|
24
|
+
function addTabListener() {
|
25
|
+
if (tabListenerAdded) return;
|
26
|
+
tabListenerAdded = true;
|
27
|
+
document.addEventListener('keydown', e => {
|
28
|
+
if (e.keyCode !== 9) return;
|
29
|
+
tabPressed = true;
|
30
|
+
});
|
31
|
+
document.addEventListener('keyup', e => {
|
32
|
+
if (e.keyCode !== 9) return;
|
33
|
+
tabPressed = false;
|
34
|
+
});
|
35
|
+
}
|
36
|
+
|
37
|
+
export function resetHasDisplayedKeyboardTooltip() {
|
38
|
+
hasDisplayedKeyboardTooltip = false;
|
39
|
+
}
|
21
40
|
|
22
41
|
export const TagListItemMixin = superclass => class extends LocalizeCoreElement(PropertyRequiredMixin(RtlMixin(superclass))) {
|
23
42
|
|
@@ -37,10 +56,6 @@ export const TagListItemMixin = superclass => class extends LocalizeCoreElement(
|
|
37
56
|
* @ignore
|
38
57
|
*/
|
39
58
|
keyboardTooltipItem: { type: Boolean, attribute: 'keyboard-tooltip-item' },
|
40
|
-
/**
|
41
|
-
* @ignore
|
42
|
-
*/
|
43
|
-
keyboardTooltipShown: { type: Boolean, attribute: 'keyboard-tooltip-shown' },
|
44
59
|
/**
|
45
60
|
* @ignore
|
46
61
|
*/
|
@@ -49,7 +64,8 @@ export const TagListItemMixin = superclass => class extends LocalizeCoreElement(
|
|
49
64
|
required: {
|
50
65
|
message: (_value, elem) => `TagListItemMixin: "${elem.tagName.toLowerCase()}" called "_renderTag()" with empty "plainText" option`
|
51
66
|
}
|
52
|
-
}
|
67
|
+
},
|
68
|
+
_displayKeyboardTooltip: { state: true }
|
53
69
|
};
|
54
70
|
}
|
55
71
|
|
@@ -143,11 +159,16 @@ export const TagListItemMixin = superclass => class extends LocalizeCoreElement(
|
|
143
159
|
this.clearable = false;
|
144
160
|
/** @ignore */
|
145
161
|
this.keyboardTooltipItem = false;
|
146
|
-
this.
|
162
|
+
this._displayKeyboardTooltip = false;
|
147
163
|
this._id = getUniqueId();
|
148
164
|
this._plainText = '';
|
149
165
|
}
|
150
166
|
|
167
|
+
connectedCallback() {
|
168
|
+
super.connectedCallback();
|
169
|
+
addTabListener();
|
170
|
+
}
|
171
|
+
|
151
172
|
firstUpdated(changedProperties) {
|
152
173
|
super.firstUpdated(changedProperties);
|
153
174
|
|
@@ -157,7 +178,7 @@ export const TagListItemMixin = superclass => class extends LocalizeCoreElement(
|
|
157
178
|
// ignore focus events coming from inside the tag content
|
158
179
|
if (e.composedPath()[0] !== this) return;
|
159
180
|
const tagList = findComposedAncestor(this, elem => elem.tagName === 'D2L-TAG-LIST');
|
160
|
-
if (this.keyboardTooltipItem &&
|
181
|
+
if (this.keyboardTooltipItem && hasDisplayedKeyboardTooltip && !isComposedAncestor(tagList, e.relatedTarget)) {
|
161
182
|
const arrows = this.localize('components.tag-list-item.tooltip-arrow-keys');
|
162
183
|
const arrowsDescription = this.localize('components.tag-list-item.tooltip-arrow-keys-desc');
|
163
184
|
|
@@ -173,7 +194,10 @@ export const TagListItemMixin = superclass => class extends LocalizeCoreElement(
|
|
173
194
|
|
174
195
|
await this.updateComplete;
|
175
196
|
// delay the focus to allow focusin to fire
|
176
|
-
setTimeout(() =>
|
197
|
+
setTimeout(() => {
|
198
|
+
this._onFocusIn();
|
199
|
+
container.focus();
|
200
|
+
});
|
177
201
|
});
|
178
202
|
|
179
203
|
this.addEventListener('keydown', this._handleKeydown);
|
@@ -192,27 +216,22 @@ export const TagListItemMixin = superclass => class extends LocalizeCoreElement(
|
|
192
216
|
}
|
193
217
|
|
194
218
|
_handleKeyboardTooltipHide() {
|
195
|
-
this.
|
196
|
-
}
|
197
|
-
|
198
|
-
_handleKeyboardTooltipShow() {
|
199
|
-
/** @ignore */
|
200
|
-
this.dispatchEvent(new CustomEvent(
|
201
|
-
'd2l-tag-list-item-tooltip-show',
|
202
|
-
{ bubbles: true, composed: true }
|
203
|
-
));
|
219
|
+
this._displayKeyboardTooltip = false;
|
204
220
|
}
|
205
221
|
|
206
222
|
_handleKeydown(e) {
|
207
|
-
const openKeys = e.keyCode === keyCodes.SPACE || e.keyCode === keyCodes.ENTER;
|
208
|
-
if (this.keyboardTooltipItem && !this.keyboardTooltipShown && openKeys) this.keyboardTooltipShown = true;
|
209
|
-
|
210
223
|
const clearKeys = e.keyCode === keyCodes.BACKSPACE || e.keyCode === keyCodes.DELETE;
|
211
224
|
if (!this.clearable || !clearKeys) return;
|
212
225
|
e.preventDefault();
|
213
226
|
this._handleClearItem();
|
214
227
|
}
|
215
228
|
|
229
|
+
_onFocusIn() {
|
230
|
+
if (!tabPressed || hasDisplayedKeyboardTooltip || !this.keyboardTooltipItem) return;
|
231
|
+
this._displayKeyboardTooltip = true;
|
232
|
+
hasDisplayedKeyboardTooltip = true;
|
233
|
+
}
|
234
|
+
|
216
235
|
_renderKeyboardTooltipContent() {
|
217
236
|
return html`
|
218
237
|
<div class="d2l-tag-list-item-tooltip-title-key">${this.localize('components.tag-list-item.tooltip-title')}</div>
|
@@ -233,13 +252,12 @@ export const TagListItemMixin = superclass => class extends LocalizeCoreElement(
|
|
233
252
|
const hasDescription = !!options.description;
|
234
253
|
|
235
254
|
let tooltip = nothing;
|
236
|
-
if (this.
|
255
|
+
if (this._displayKeyboardTooltip) {
|
237
256
|
tooltip = html`
|
238
257
|
<d2l-tooltip
|
239
258
|
class="vdiff-target"
|
240
259
|
align="start"
|
241
260
|
@d2l-tooltip-hide="${this._handleKeyboardTooltipHide}"
|
242
|
-
@d2l-tooltip-show="${this._handleKeyboardTooltipShow}"
|
243
261
|
for="${this._id}">
|
244
262
|
${this._renderKeyboardTooltipContent()}
|
245
263
|
</d2l-tooltip>`;
|
@@ -104,7 +104,6 @@ class TagList extends LocalizeCoreElement(InteractiveMixin(ArrowKeysMixin(LitEle
|
|
104
104
|
this._clearButtonWidth = 0;
|
105
105
|
this._contentReady = false;
|
106
106
|
this._hasResized = false;
|
107
|
-
this._hasShownKeyboardTooltip = false;
|
108
107
|
this._itemHeight = 0;
|
109
108
|
this._listContainerObserver = null;
|
110
109
|
this._resizeObserver = null;
|
@@ -196,8 +195,7 @@ class TagList extends LocalizeCoreElement(InteractiveMixin(ArrowKeysMixin(LitEle
|
|
196
195
|
class="${classMap(containerClasses)}"
|
197
196
|
role="group"
|
198
197
|
aria-roledescription="${this.localize('components.tag-list.role-description')}"
|
199
|
-
@d2l-tag-list-item-clear="${this._handleItemDeleted}"
|
200
|
-
@d2l-tag-list-item-tooltip-show="${this._handleKeyboardTooltipShown}">
|
198
|
+
@d2l-tag-list-item-clear="${this._handleItemDeleted}">
|
201
199
|
<slot @slotchange="${this._handleSlotChange}" @focusout="${this._handleSlotFocusOut}" @focusin="${this._handleSlotFocusIn}"></slot>
|
202
200
|
${overflowButton}
|
203
201
|
<d2l-button-subtle
|
@@ -359,10 +357,6 @@ class TagList extends LocalizeCoreElement(InteractiveMixin(ArrowKeysMixin(LitEle
|
|
359
357
|
}, this.clearFocusTimeout);
|
360
358
|
}
|
361
359
|
|
362
|
-
_handleKeyboardTooltipShown() {
|
363
|
-
if (!this._hasShownKeyboardTooltip) this._hasShownKeyboardTooltip = true;
|
364
|
-
}
|
365
|
-
|
366
360
|
async _handleResize() {
|
367
361
|
const refocus = getComposedActiveElement();
|
368
362
|
this._contentReady = false;
|
@@ -408,7 +402,6 @@ class TagList extends LocalizeCoreElement(InteractiveMixin(ArrowKeysMixin(LitEle
|
|
408
402
|
|
409
403
|
this._contentReady = true;
|
410
404
|
this._items[0].setAttribute('keyboard-tooltip-item', true);
|
411
|
-
if (this._hasShownKeyboardTooltip) this._items[0].setAttribute('keyboard-tooltip-shown', true);
|
412
405
|
await this.updateComplete;
|
413
406
|
if (this._refocus?.classList.contains('d2l-tag-list-button')) {
|
414
407
|
this._refocus = this.shadowRoot.querySelector('.d2l-tag-list-button');
|
package/custom-elements.json
CHANGED
@@ -12538,11 +12538,6 @@
|
|
12538
12538
|
"type": "boolean",
|
12539
12539
|
"default": "false"
|
12540
12540
|
},
|
12541
|
-
{
|
12542
|
-
"name": "keyboardTooltipShown",
|
12543
|
-
"type": "boolean",
|
12544
|
-
"default": "false"
|
12545
|
-
},
|
12546
12541
|
{
|
12547
12542
|
"name": "documentLocaleSettings",
|
12548
12543
|
"default": "\"getDocumentLocaleSettings()\""
|
@@ -12659,11 +12654,6 @@
|
|
12659
12654
|
"type": "boolean",
|
12660
12655
|
"default": "false"
|
12661
12656
|
},
|
12662
|
-
{
|
12663
|
-
"name": "keyboardTooltipShown",
|
12664
|
-
"type": "boolean",
|
12665
|
-
"default": "false"
|
12666
|
-
},
|
12667
12657
|
{
|
12668
12658
|
"name": "documentLocaleSettings",
|
12669
12659
|
"default": "\"getDocumentLocaleSettings()\""
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@brightspace-ui/core",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.182.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",
|