@brightspace-ui/core 2.137.1 → 2.137.3
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/inputs/demo/input-text.html +7 -0
- package/components/inputs/docs/input-text.md +1 -0
- package/components/inputs/input-date.js +1 -2
- package/components/inputs/input-text.js +12 -2
- package/components/list/demo/list-item-actions.html +6 -0
- package/components/selection/selection-mixin.js +35 -19
- package/custom-elements.json +11 -0
- package/package.json +1 -1
|
@@ -69,6 +69,13 @@
|
|
|
69
69
|
</template>
|
|
70
70
|
</d2l-demo-snippet>
|
|
71
71
|
|
|
72
|
+
<h2>Instructions</h2>
|
|
73
|
+
<d2l-demo-snippet>
|
|
74
|
+
<template>
|
|
75
|
+
<d2l-input-text label="Name" instructions="Use the keyboard to enter some sweet stuff... :)"></d2l-input-text>
|
|
76
|
+
</template>
|
|
77
|
+
</d2l-demo-snippet>
|
|
78
|
+
|
|
72
79
|
<h3>Invalid</h3>
|
|
73
80
|
<d2l-demo-snippet>
|
|
74
81
|
<template>
|
|
@@ -80,6 +80,7 @@ The `<d2l-input-text>` element is a simple wrapper around the native `<input typ
|
|
|
80
80
|
| `description` | String | A description to be added to the `input` for accessibility |
|
|
81
81
|
| `disabled` | Boolean | Disables the input |
|
|
82
82
|
| `input-width` | String, default: `100%` | Restricts the maximum width of the input box without impacting the width of the label |
|
|
83
|
+
| `instructions` | String | Additional information relating to how to use the component |
|
|
83
84
|
| `label-hidden` | Boolean | Hides the label visually (moves it to the input's `aria-label` attribute) |
|
|
84
85
|
| `labelled-by` | String | HTML id of an element in the same shadow root which acts as the input's label |
|
|
85
86
|
| `max` | String | For number inputs, maximum value |
|
|
@@ -242,7 +242,6 @@ class InputDate extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixin(
|
|
|
242
242
|
? html`<d2l-icon icon="tier1:alert" slot="left" style="${styleMap({ color: 'var(--d2l-color-cinnabar)' })}"></d2l-icon>`
|
|
243
243
|
: html`<d2l-icon icon="tier1:calendar" slot="left"></d2l-icon>`;
|
|
244
244
|
const errorTooltip = (this.validationError && !this.opened && this.childErrors.size === 0) ? html`<d2l-tooltip align="start" announced for="${this._inputId}" state="error">${this.validationError}</d2l-tooltip>` : null;
|
|
245
|
-
const infoTooltip = (this._showInfoTooltip && !errorTooltip && !this.invalid && !this.disabled && this.childErrors.size === 0 && !this.skeleton && this._inputTextFocusShowTooltip) ? html`<d2l-tooltip align="start" announced delay="1000" for="${this._inputId}">${this.localize(`${this._namespace}.openInstructions`, { format: shortDateFormat })}</d2l-tooltip>` : null;
|
|
246
245
|
|
|
247
246
|
const dropdownContent = this._dropdownFirstOpened ? html`
|
|
248
247
|
<d2l-dropdown-content
|
|
@@ -276,7 +275,6 @@ class InputDate extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixin(
|
|
|
276
275
|
<div>${this.emptyText}</div>
|
|
277
276
|
</div>
|
|
278
277
|
${errorTooltip}
|
|
279
|
-
${infoTooltip}
|
|
280
278
|
<d2l-dropdown ?disabled="${this.disabled || this.skeleton}" no-auto-open>
|
|
281
279
|
<d2l-input-text
|
|
282
280
|
?novalidate="${this.noValidate}"
|
|
@@ -284,6 +282,7 @@ class InputDate extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixin(
|
|
|
284
282
|
@blur="${this._handleInputTextBlur}"
|
|
285
283
|
@change="${this._handleChange}"
|
|
286
284
|
class="d2l-dropdown-opener"
|
|
285
|
+
instructions="${ifDefined((this._showInfoTooltip && !errorTooltip && !this.invalid && this.childErrors.size === 0 && this._inputTextFocusShowTooltip) ? this.localize(`${this._namespace}.openInstructions`, { format: shortDateFormat }) : undefined)}"
|
|
287
286
|
description="${ifDefined(this.emptyText ? this.emptyText : undefined)}"
|
|
288
287
|
?disabled="${this.disabled}"
|
|
289
288
|
@focus="${this._handleInputTextFocus}"
|
|
@@ -68,6 +68,11 @@ class InputText extends FocusMixin(LabelledMixin(FormElementMixin(SkeletonMixin(
|
|
|
68
68
|
* @type {string}
|
|
69
69
|
*/
|
|
70
70
|
inputWidth: { attribute: 'input-width', type: String },
|
|
71
|
+
/**
|
|
72
|
+
* ADVANCED: Additional information relating to how to use the component
|
|
73
|
+
* @type {string}
|
|
74
|
+
*/
|
|
75
|
+
instructions: { type: String, attribute: 'instructions' },
|
|
71
76
|
/**
|
|
72
77
|
* Hides the label visually (moves it to the input's "aria-label" attribute)
|
|
73
78
|
* @type {boolean}
|
|
@@ -461,8 +466,13 @@ class InputText extends FocusMixin(LabelledMixin(FormElementMixin(SkeletonMixin(
|
|
|
461
466
|
}
|
|
462
467
|
|
|
463
468
|
let tooltip = nothing;
|
|
464
|
-
if (
|
|
465
|
-
|
|
469
|
+
if (!this.skeleton) {
|
|
470
|
+
if (this.validationError && !this.noValidate) {
|
|
471
|
+
// this tooltip is using "announced" since we don't want aria-describedby wire-up which would bury the message in VoiceOver's More Content Available menu
|
|
472
|
+
tooltip = html`<d2l-tooltip state="error" announced align="start">${this.validationError} <span class="d2l-offscreen">${this.description}</span></d2l-tooltip>`;
|
|
473
|
+
} else if (this.instructions) {
|
|
474
|
+
tooltip = html`<d2l-tooltip align="start" for="${this._inputId}" delay="1000">${this.instructions}</d2l-tooltip>`;
|
|
475
|
+
}
|
|
466
476
|
}
|
|
467
477
|
|
|
468
478
|
return html`${tooltip}${label}${input}`;
|
|
@@ -184,6 +184,12 @@
|
|
|
184
184
|
<d2l-list-item selectable key="3" label="Geomorphology and GIS">
|
|
185
185
|
<d2l-list-item-content>Geomorphology and GIS</d2l-list-item-content>
|
|
186
186
|
</d2l-list-item>
|
|
187
|
+
<d2l-list-item selectable key="4" label="Introductory Differential Equations">
|
|
188
|
+
<d2l-list-item-content>Introductory Differential Equations</d2l-list-item-content>
|
|
189
|
+
</d2l-list-item>
|
|
190
|
+
<d2l-list-item selectable key="5" label="Fermentation Biology">
|
|
191
|
+
<d2l-list-item-content>Fermentation Biology</d2l-list-item-content>
|
|
192
|
+
</d2l-list-item>
|
|
187
193
|
</d2l-list>
|
|
188
194
|
</template>
|
|
189
195
|
</d2l-demo-snippet>
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { getFirstFocusableDescendant, getLastFocusableDescendant, getNextFocusable, getPreviousFocusable } from '../../helpers/focus.js';
|
|
1
2
|
import { CollectionMixin } from '../../mixins/collection/collection-mixin.js';
|
|
3
|
+
import { isComposedAncestor } from '../../helpers/dom.js';
|
|
2
4
|
import { RtlMixin } from '../../mixins/rtl/rtl-mixin.js';
|
|
3
5
|
|
|
4
6
|
const keyCodes = {
|
|
@@ -152,29 +154,43 @@ export const SelectionMixin = superclass => class extends RtlMixin(CollectionMix
|
|
|
152
154
|
}
|
|
153
155
|
|
|
154
156
|
_handleRadioKeyUp(e) {
|
|
157
|
+
|
|
158
|
+
const target = e.composedPath()[0];
|
|
159
|
+
|
|
155
160
|
// check composed path for radio (e.target could be d2l-list-item or other element due to retargeting)
|
|
156
|
-
if (!
|
|
161
|
+
if (!target.classList.contains('d2l-selection-input-radio')) return;
|
|
157
162
|
if (e.keyCode < keyCodes.LEFT || e.keyCode > keyCodes.DOWN) return;
|
|
158
163
|
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
164
|
+
const getSelectionInput = (focusable, forward) => {
|
|
165
|
+
while (focusable) {
|
|
166
|
+
if (focusable.classList.contains('d2l-selection-input-radio')) {
|
|
167
|
+
const selectionInput = focusable.getRootNode().host;
|
|
168
|
+
if (!selectionInput.disabled && this._selectionSelectables.has(selectionInput)) return selectionInput;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (!isComposedAncestor(this, focusable)) return null;
|
|
172
|
+
|
|
173
|
+
focusable = forward ? getNextFocusable(focusable, false, true, true) : getPreviousFocusable(focusable, false, true, true);
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
const forward = (this.dir !== 'rtl' && e.keyCode === keyCodes.RIGHT) || (this.dir === 'rtl' && e.keyCode === keyCodes.LEFT) || (e.keyCode === keyCodes.DOWN);
|
|
178
|
+
|
|
179
|
+
// first try to find next/previous selection-input relative to the event target within the selection component sub-tree that also belongs to the selection component
|
|
180
|
+
let focusable = forward ? getNextFocusable(target, false, true, true) : getPreviousFocusable(target, false, true, true);
|
|
181
|
+
let selectionInput = getSelectionInput(focusable, forward);
|
|
182
|
+
|
|
183
|
+
if (!selectionInput) {
|
|
184
|
+
// no selection-input since next/previous focusable is before/after list... cycle to first/last
|
|
185
|
+
focusable = forward ? getFirstFocusableDescendant(this, false) : getLastFocusableDescendant(this, false);
|
|
186
|
+
selectionInput = getSelectionInput(focusable, forward);
|
|
175
187
|
}
|
|
176
|
-
|
|
177
|
-
|
|
188
|
+
|
|
189
|
+
if (selectionInput) {
|
|
190
|
+
selectionInput.selected = true;
|
|
191
|
+
selectionInput.focus();
|
|
192
|
+
}
|
|
193
|
+
|
|
178
194
|
}
|
|
179
195
|
|
|
180
196
|
_handleSelectionChange(e) {
|
package/custom-elements.json
CHANGED
|
@@ -6574,6 +6574,11 @@
|
|
|
6574
6574
|
"description": "Restricts the maximum width of the input box without impacting the width of the label.",
|
|
6575
6575
|
"type": "string"
|
|
6576
6576
|
},
|
|
6577
|
+
{
|
|
6578
|
+
"name": "instructions",
|
|
6579
|
+
"description": "ADVANCED: Additional information relating to how to use the component",
|
|
6580
|
+
"type": "string"
|
|
6581
|
+
},
|
|
6577
6582
|
{
|
|
6578
6583
|
"name": "max",
|
|
6579
6584
|
"description": "For number inputs, maximum value",
|
|
@@ -6741,6 +6746,12 @@
|
|
|
6741
6746
|
"description": "Restricts the maximum width of the input box without impacting the width of the label.",
|
|
6742
6747
|
"type": "string"
|
|
6743
6748
|
},
|
|
6749
|
+
{
|
|
6750
|
+
"name": "instructions",
|
|
6751
|
+
"attribute": "instructions",
|
|
6752
|
+
"description": "ADVANCED: Additional information relating to how to use the component",
|
|
6753
|
+
"type": "string"
|
|
6754
|
+
},
|
|
6744
6755
|
{
|
|
6745
6756
|
"name": "max",
|
|
6746
6757
|
"attribute": "max",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightspace-ui/core",
|
|
3
|
-
"version": "2.137.
|
|
3
|
+
"version": "2.137.3",
|
|
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",
|