@brightspace-ui/labs 2.1.0 → 2.2.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.
package/package.json CHANGED
@@ -5,6 +5,7 @@
5
5
  "repository": "https://github.com/BrightspaceUI/labs.git",
6
6
  "exports": {
7
7
  "./components/accessibility-disability-simulator.js": "./src/components/accessibility-disability-simulator/accessibility-disability-simulator.js",
8
+ "./components/attribute-picker.js": "./src/components/attribute-picker/attribute-picker.js",
8
9
  "./components/checkbox-drawer.js": "./src/components/checkbox-drawer/checkbox-drawer.js",
9
10
  "./components/community-button.js": "./src/components/community/community-button.js",
10
11
  "./components/community-link.js": "./src/components/community/community-link.js",
@@ -13,7 +14,6 @@
13
14
  "./components/opt-out-flyout.js": "./src/components/opt-in-flyout/opt-out-flyout.js",
14
15
  "./components/opt-out-reason.js": "./src/components/opt-in-flyout/opt-out-reason.js",
15
16
  "./components/pager-numeric.js": "./src/components/pagination/pager-numeric.js",
16
- "./components/status-icon.js": "./src/components/status-icon/status-icon.js",
17
17
  "./controllers/computed-value.js": "./src/controllers/computed-values/computed-value.js",
18
18
  "./controllers/computed-values.js": "./src/controllers/computed-values/computed-values.js",
19
19
  "./controllers/language-listener.js": "./src/controllers/language-listener/language-listener.js"
@@ -53,5 +53,5 @@
53
53
  "@brightspace-ui/core": "^3",
54
54
  "lit": "^3"
55
55
  },
56
- "version": "2.1.0"
56
+ "version": "2.2.0"
57
57
  }
@@ -0,0 +1,30 @@
1
+ # d2l-labs-attribute-picker
2
+
3
+ The `d2l-labs-attribute-picker` component is an autocompleting dropdown to choose one or more new or pre-existing attributes inline.
4
+
5
+ ## Usage
6
+
7
+ ```html
8
+ <script type="module">
9
+ import '@brightspace-ui/labs/components/attribute-picker.js';
10
+ </script>
11
+ <d2l-labs-attribute-picker></d2l-labs-attribute-picker>
12
+ ```
13
+
14
+ **Properties:**
15
+
16
+ | Property | Type | Description |
17
+ |--|--|--|
18
+ | `allow-freeform` | Boolean | When enabled, the user can manually type any attribute they wish. If false, they must select from the dropdown. |
19
+ | `attribute-list` | Array | An array of string/value pairs representing the attributes currently selected in the picker (eg `[{"name":"shown to user","value":"sent in event"}]`). Only the values are sent in events and the string names are otherwise ignored. |
20
+ | `assignable-attributes` | Array | An array of string/value pairs, just like `attribute-list`, available in the dropdown list |
21
+ | `invalid-tooltip-text` | String (default: At least one attribute must be set) | The text that will appear in the tooltip that informs a user that the state is invalid |
22
+ | `limit` | Number | The maximum length of attribute-list permitted |
23
+ | `required` | Boolean | When true, an error state will appear if no attributes are set. Error state only appear once the user interacts with the component. |
24
+
25
+ **Events:**
26
+
27
+ - `d2l-labs-attribute-picker-attributes-changed`: dispatched when an attribute is added or removed from the list of selected attributes. Event `detail` includes:
28
+ - `attributeList`: an array of the selected attributes, in the order they were selected.
29
+ - `d2l-labs-attribute-picker-limit-reached`: dispatched when a user attempts to add attributes once the limit is hit. Event `detail` includes:
30
+ - `limit`: the limit that was hit
@@ -0,0 +1,104 @@
1
+ import '@brightspace-ui/core/components/button/button-icon.js';
2
+ import '@brightspace-ui/core/components/colors/colors.js';
3
+ import '@brightspace-ui/core/components/tooltip/tooltip.js';
4
+ import { css, html, LitElement } from 'lit';
5
+ import { bodyCompactStyles } from '@brightspace-ui/core/components/typography/styles.js';
6
+ import { LocalizeLabsElement } from '../localize-labs-element.js';
7
+
8
+ class AttributePickerItem extends LocalizeLabsElement(LitElement) {
9
+ static get properties() {
10
+ return {
11
+ deletable: { type: Boolean, reflect: true },
12
+ text: { type: String }
13
+ };
14
+ }
15
+
16
+ static get styles() {
17
+ return [bodyCompactStyles, css`
18
+ :host {
19
+ cursor: pointer;
20
+ display: inline-block;
21
+ width: max-content;
22
+ }
23
+ :host(:focus-visible) {
24
+ outline: none;
25
+ }
26
+ .d2l-labs-attribute-picker-item-wrapper {
27
+ align-items: center;
28
+ background-color: var(--d2l-color-sylvite);
29
+ border: 1px solid var(--d2l-color-gypsum);
30
+ border-radius: 0.3rem;
31
+ display: flex;
32
+ gap: 0.2rem;
33
+ padding: 0.25rem;
34
+ padding-inline: 0.5rem;
35
+ user-select: none;
36
+ }
37
+ :host([deletable]) .d2l-labs-attribute-picker-item-wrapper {
38
+ padding-bottom: 0.15rem;
39
+ padding-inline: 0.5rem 0.1rem;
40
+ padding-top: 0.1rem;
41
+ }
42
+ :host(:hover) .d2l-labs-attribute-picker-item-wrapper {
43
+ background-color: var(--d2l-color-gypsum);
44
+ border-color: var(--d2l-color-mica);
45
+ color: var(--d2l-color-ferrite);
46
+ }
47
+ :host(:focus) .d2l-labs-attribute-picker-item-wrapper {
48
+ background-color: var(--d2l-color-celestine);
49
+ border: 1px solid var(--d2l-color-celestine-minus-1);
50
+ color: var(--d2l-color-regolith);
51
+ }
52
+ .d2l-labs-attribute-picker-item-text {
53
+ -webkit-box-orient: vertical;
54
+ display: -webkit-box;
55
+ -webkit-line-clamp: 1;
56
+ line-height: normal;
57
+ max-width: 18rem;
58
+ overflow: hidden;
59
+ text-overflow: ellipsis;
60
+ word-break: break-all;
61
+ }
62
+ d2l-tooltip {
63
+ word-break: break-word;
64
+ }
65
+ d2l-button-icon {
66
+ --d2l-button-icon-background-color-hover: var(--d2l-color-mica);
67
+ --d2l-button-icon-fill-color: var(--d2l-color-chromite);
68
+ --d2l-button-icon-fill-color-hover: var(--d2l-color-tungsten);
69
+ --d2l-button-icon-min-height: 1.2rem;
70
+ --d2l-button-icon-min-width: 1.2rem;
71
+ }
72
+ :host(:focus) d2l-button-icon {
73
+ --d2l-button-icon-background-color-hover: var(--d2l-color-celestine-plus-1);
74
+ --d2l-button-icon-fill-color: var(--d2l-color-mica);
75
+ --d2l-button-icon-fill-color-hover: var(--d2l-color-sylvite);
76
+ }
77
+ `];
78
+ }
79
+
80
+ constructor() {
81
+ super();
82
+ this.deletable = false;
83
+ }
84
+
85
+ firstUpdated(changedProperties) {
86
+ super.firstUpdated(changedProperties);
87
+ this.tabIndex = 0;
88
+ }
89
+
90
+ render() {
91
+ return html`
92
+ <div class="d2l-labs-attribute-picker-item-wrapper">
93
+ <div id="d2l-labs-attribute-picker-item-text" class="d2l-body-compact d2l-labs-attribute-picker-item-text">${this.text}</div>
94
+ <d2l-button-icon tabindex="-1" text="${this.localize('components:attributePicker:removeValue', 'value', this.text)}" icon="tier1:close-small" ?hidden="${!this.deletable}" @click="${this._onDeleteItem}"></d2l-button-icon>
95
+ </div>
96
+ <d2l-tooltip for="d2l-labs-attribute-picker-item-text" position="top" show-truncated-only offset="16">${this.text}</d2l-tooltip>
97
+ `;
98
+ }
99
+
100
+ _onDeleteItem() {
101
+ this.dispatchEvent(new CustomEvent('d2l-labs-attribute-picker-item-deleted', { bubbles: true, composed: true }));
102
+ }
103
+ }
104
+ customElements.define('d2l-labs-attribute-picker-item', AttributePickerItem);
@@ -0,0 +1,457 @@
1
+ import './attribute-picker-item.js';
2
+ import '@brightspace-ui/core/components/colors/colors.js';
3
+ import '@brightspace-ui/core/components/tooltip/tooltip.js';
4
+ import { css, html, LitElement } from 'lit';
5
+ import { ArrowKeysMixin } from '@brightspace-ui/core/mixins/arrow-keys/arrow-keys-mixin.js';
6
+ import { ifDefined } from 'lit/directives/if-defined.js';
7
+ import { inputStyles } from '@brightspace-ui/core/components/inputs/input-styles.js';
8
+ import { LocalizeLabsElement } from '../localize-labs-element.js';
9
+ import { repeat } from 'lit/directives/repeat.js';
10
+ const keyCodes = {
11
+ ENTER: 13,
12
+ ESCAPE: 27,
13
+ BACKSPACE: 8,
14
+ LEFT: 37,
15
+ RIGHT: 39,
16
+ UP: 38,
17
+ DOWN: 40,
18
+ DELETE: 46
19
+ };
20
+
21
+ class AttributePicker extends ArrowKeysMixin(LocalizeLabsElement(LitElement)) {
22
+ static get properties() {
23
+ return {
24
+ /* When true, the user can manually enter any attribute they wish. If false, they must match a value from the dropdown. */
25
+ allowFreeform: { type: Boolean, attribute: 'allow-freeform', reflect: true },
26
+
27
+ /* An array of strings available in the dropdown list */
28
+ assignableAttributes: { type: Array, attribute: 'assignable-attributes', reflect: true },
29
+
30
+ /* An array of strings representing the attributes currently selected in the picker */
31
+ attributeList: { type: Array, attribute: 'attribute-list', reflect: true },
32
+
33
+ /*
34
+ The text that will appear in the tooltip that informs a user that the state is invalid
35
+ The default value is: 'At least one attribute must be set'
36
+ */
37
+ invalidTooltipText: { type: String, attribute: 'invalid-tooltip-text', reflect: true },
38
+
39
+ /* Required. The label associated with the attribute picker for screen reader users */
40
+ label: { type: String, reflect: true },
41
+
42
+ /* The maximum number of attributes permitted. */
43
+ limit: { type: Number, attribute: 'limit', reflect: true },
44
+
45
+ /* When true, an error state will appear if no attributes are set */
46
+ required: { type: Boolean, attribute: 'required', reflect: true },
47
+
48
+ /* Represents the index of the currently focused attribute. If no attribute is focused, equals -1 */
49
+ _activeAttributeIndex: { state: true },
50
+
51
+ /* Represents the index of the currently focused dropdown list item. If no item is focused, equals -1 */
52
+ _dropdownIndex: { state: true },
53
+
54
+ /* When true, the user currently has focus within the component */
55
+ _hasFocus: { state: true },
56
+
57
+ /* When true, the user has yet to lose focus for the first time, meaning the validation won't be shown until they've lost focus for the first time */
58
+ _initialFocus: { state: true },
59
+
60
+ /* When true, the user currently has focus within the input */
61
+ _inputFocused: { state: true },
62
+
63
+ /* When true, the user has reached the limit of attributes that can be added */
64
+ _limitReached: { state: true },
65
+
66
+ /* The inner text of the input */
67
+ _text: { state: true }
68
+ };
69
+ }
70
+
71
+ static get styles() {
72
+ return [inputStyles, css`
73
+ :host {
74
+ display: inline-block;
75
+ font-size: 0.8rem;
76
+ width: 100%;
77
+ }
78
+ :host:disabled {
79
+ opacity: 0.5;
80
+ }
81
+ :host([hidden]) {
82
+ display: none;
83
+ }
84
+ .d2l-attribute-picker-container {
85
+ padding: 5px;
86
+ }
87
+ .d2l-attribute-picker-container:hover,
88
+ .d2l-attribute-picker-container:focus-within {
89
+ padding: 4px;
90
+ }
91
+ .d2l-attribute-picker-container:focus-within {
92
+ border: 2px solid var(--d2l-color-celestine);
93
+ }
94
+ [aria-invalid="true"].d2l-attribute-picker-container:focus-within {
95
+ border-color: var(--d2l-color-cinnabar);
96
+ }
97
+ .d2l-attribute-picker-content {
98
+ display: flex;
99
+ flex-wrap: wrap;
100
+ gap: 0.2rem;
101
+ }
102
+ .d2l-attribute-picker-attribute {
103
+ height: 1.55rem;
104
+ }
105
+ .d2l-attribute-picker-attribute:focus-visible {
106
+ outline: none;
107
+ }
108
+ .d2l-attribute-picker-input {
109
+ background: transparent;
110
+ border: none;
111
+ box-shadow: none;
112
+ box-sizing: border-box;
113
+ flex-grow: 1;
114
+ min-height: 1.55rem;
115
+ outline: none;
116
+ padding: 0 !important;
117
+ width: 4rem;
118
+ }
119
+ .d2l-attribute-list {
120
+ background-color: white;
121
+ border: 1px solid var(--d2l-color-gypsum);
122
+ border-radius: 0.3rem;
123
+ max-height: 7.8rem;
124
+ overflow-y: auto;
125
+ padding-left: 0;
126
+ text-overflow: ellipsis;
127
+ }
128
+ .d2l-attribute-picker-li {
129
+ cursor: pointer;
130
+ margin: 0;
131
+ padding: 0.4rem 6rem 0.4rem 0.6rem;
132
+ }
133
+ .d2l-attribute-picker-li[aria-selected="true"] {
134
+ background-color: var(--d2l-color-celestine-plus-2);
135
+ color: var(--d2l-color-celestine);
136
+ }
137
+ .d2l-attribute-picker-absolute-container {
138
+ margin: 0 0.3rem 0 -0.3rem;
139
+ position: absolute;
140
+ width: 100%;
141
+ z-index: 1;
142
+ }
143
+ .d2l-input-text-invalid-icon {
144
+ background-image: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjIiIGhlaWdodD0iMjIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgPGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj4KICAgIDxwYXRoIGZpbGw9IiNGRkYiIGQ9Ik0wIDBoMjJ2MjJIMHoiLz4KICAgIDxwYXRoIGQ9Ik0xOC44NjQgMTYuNDdMMTIuNjIzIDMuOTg5YTEuNzgzIDEuNzgzIDAgMDAtMy4xOTIgMEwzLjE4OSAxNi40N2ExLjc2MSAxLjc2MSAwIDAwLjA4IDEuNzNjLjMyNS41MjUuODk4Ljc5OCAxLjUxNi43OTloMTIuNDgzYy42MTggMCAxLjE5Mi0uMjczIDEuNTE2LS44LjIzNy0uMzM1LjI2NS0xLjM3LjA4LTEuNzN6IiBmaWxsPSIjQ0QyMDI2IiBmaWxsLXJ1bGU9Im5vbnplcm8iLz4KICAgIDxwYXRoIGQ9Ik0xMS4wMjcgMTcuMjY0YTEuMzM3IDEuMzM3IDAgMTEwLTIuNjc1IDEuMzM3IDEuMzM3IDAgMDEwIDIuNjc1ek0xMS45IDEyLjk4YS44OTIuODkyIDAgMDEtMS43NDcgMEw5LjI3IDguNTJhLjg5Mi44OTIgMCAwMS44NzQtMS4wNjRoMS43NjhhLjg5Mi44OTIgMCAwMS44NzQgMS4wNjVsLS44ODYgNC40NTh6IiBmaWxsPSIjRkZGIi8+CiAgPC9nPgo8L3N2Zz4K");
145
+ display: flex;
146
+ height: 22px;
147
+ inset-inline-end: 8px;
148
+ position: absolute;
149
+ top: 50%;
150
+ transform: translateY(-50%);
151
+ width: 22px;
152
+ }
153
+ `];
154
+ }
155
+
156
+ constructor() {
157
+ super();
158
+ this.attributeList = [];
159
+ this.assignableAttributes = [];
160
+ this._text = '';
161
+ this._activeAttributeIndex = -1;
162
+ this._dropdownIndex = -1;
163
+ this._initialFocus = true;
164
+ this.arrowKeysNoWrap = true;
165
+ this.arrowKeysDirection = 'leftrightupdown';
166
+ this._inputFocused = false;
167
+ }
168
+
169
+ firstUpdated(changedProperties) {
170
+ super.firstUpdated(changedProperties);
171
+ this.addEventListener('focusin', this._onFocusIn);
172
+ this.addEventListener('focusout', this._onFocusOut);
173
+ }
174
+
175
+ render() {
176
+ const comparableText = this._text.trim().toLowerCase();
177
+ const availableAttributes = this.assignableAttributes.filter(x => this.attributeList.every(a => a.name !== x.name) && (comparableText === '' || x.name?.toLowerCase().includes(comparableText)));
178
+
179
+ const isValid = this._initialFocus || !this.required || this.attributeList.length;
180
+ const ariaInvalid = !isValid ? true : undefined;
181
+ const ariaRequired = this.required ? true : undefined;
182
+
183
+ return html`
184
+ <div role="application" id="d2l-attribute-picker-container" aria-label="${this.label}" class="d2l-attribute-picker-container d2l-input" aria-invalid="${ifDefined(ariaInvalid)}">
185
+ ${this.arrowKeysContainer(html`
186
+ <div class="d2l-attribute-picker-content" role="${this.attributeList.length > 0 ? 'list' : ''}">
187
+ ${repeat(this.attributeList, (item) => item.value, (item, index) => html`
188
+ <d2l-labs-attribute-picker-item class="d2l-attribute-picker-attribute d2l-arrowkeys-focusable"
189
+ role="listitem"
190
+ text="${item.name}"
191
+ .index="${index}"
192
+ ?deletable="${this._hasFocus}"
193
+ @d2l-labs-attribute-picker-item-deleted="${this._onAttributeRemoved}"
194
+ @focus="${this._onAttributeFocus}"
195
+ @keydown="${this._onAttributeKeydown}">
196
+ </d2l-labs-attribute-picker-item>
197
+ `)}
198
+
199
+ <input class="d2l-attribute-picker-input d2l-arrowkeys-focusable"
200
+ role="combobox"
201
+ aria-activedescendant="${this._dropdownIndex > -1 ? `attribute-dropdown-list-item-${this._dropdownIndex}` : ''}"
202
+ aria-autocomplete="list"
203
+ aria-expanded="${this._inputFocused}"
204
+ aria-haspopup="true"
205
+ aria-invalid="${ifDefined(ariaInvalid)}"
206
+ aria-label="${this.label}"
207
+ aria-owns="attribute-dropdown-list"
208
+ aria-required=${ifDefined(ariaRequired)}
209
+ enterkeyhint="enter"
210
+ @blur="${this._onInputBlur}"
211
+ @focus="${this._onInputFocus}"
212
+ @keydown="${this._onInputKeydown}"
213
+ @input="${this._onInputTextChanged}"
214
+ type="text"
215
+ .value="${this._text}">
216
+
217
+ ${(!isValid && !this._inputFocused) ? html`<div class="d2l-input-text-invalid-icon" @click="${this._handleInvalidIconClick}"></div>` : null}
218
+ </div>
219
+ `)}
220
+
221
+ <div class="d2l-attribute-picker-absolute-container">
222
+ <ul class="d2l-attribute-list"
223
+ role="listbox"
224
+ id="attribute-dropdown-list"
225
+ ?hidden="${!this._inputFocused || !availableAttributes.length}">
226
+
227
+ ${repeat(availableAttributes, (item) => item.name, (item, listIndex) => html`
228
+ <li id="attribute-dropdown-list-item-${listIndex}"
229
+ class="d2l-attribute-picker-li"
230
+ role="option"
231
+ aria-label="${this.localize('components:attributePicker:addValue', 'value', item.name)}"
232
+ aria-selected="${this._dropdownIndex === listIndex}"
233
+ .text="${item}"
234
+ .index=${listIndex}
235
+ @mousemove="${this._onListItemMouseMove}"
236
+ @mousedown="${this._onListItemTapped}">
237
+ ${item.name}
238
+ </li>
239
+ `)}
240
+ </ul>
241
+ </div>
242
+ </div>
243
+
244
+ ${!isValid ? html`
245
+ <d2l-tooltip for="d2l-attribute-picker-container" state="error" announced position="top" ?force-show=${this._inputFocused}>${this.invalidTooltipText || this.localize('components:attributePicker:minimumRequirement')}</d2l-tooltip>
246
+ ` : null}
247
+
248
+ ${this.limit && this._limitReached ? html`
249
+ <d2l-tooltip for="d2l-attribute-picker-container" position="top" ?force-show=${this._inputFocused}>${this.localize('components:attributePicker:limitReached', { value: this.limit })}</d2l-tooltip>
250
+ ` : null}
251
+ `;
252
+ }
253
+
254
+ updated(changedProperties) {
255
+ super.updated(changedProperties);
256
+ if (changedProperties.has('_activeAttributeIndex')) {
257
+ const selectedAttributes = this.shadowRoot.querySelectorAll('.d2l-attribute-picker-attribute');
258
+ if (this._activeAttributeIndex >= 0 && this._activeAttributeIndex < selectedAttributes.length) {
259
+ selectedAttributes[this._activeAttributeIndex].focus();
260
+ }
261
+ }
262
+
263
+ if (changedProperties.has('assignableAttributes')) {
264
+ this._dropdownIndex = -1;
265
+ }
266
+ }
267
+
268
+ // Returns true or false depending on if the attribute was successfully added. Fires the d2l-attribute-limit-reached event, if necessary.
269
+ async addAttribute(newAttribute) {
270
+ if (!newAttribute || this.attributeList.findIndex(attribute => attribute.name === newAttribute.name) >= 0) return false;
271
+
272
+ this._limitReached = this.limit && this.attributeList.length >= this.limit;
273
+ if (this._limitReached) {
274
+ this.dispatchEvent(new CustomEvent('d2l-labs-attribute-picker-limit-reached', {
275
+ bubbles: true, composed: true, detail: { limit: this.limit }
276
+ }));
277
+ return false;
278
+ }
279
+
280
+ this.attributeList = [...this.attributeList, newAttribute];
281
+ this._text = '';
282
+
283
+ // Wait until we can get the full list of available list items after clearing the text
284
+ await this.updateComplete;
285
+ const list = this.shadowRoot.querySelectorAll('li');
286
+
287
+ // If we removed the final index of the list, move our index back to compensate
288
+ if (this._dropdownIndex > -1 && this._dropdownIndex > list.length - 1) {
289
+ this._dropdownIndex --;
290
+ }
291
+
292
+ this._dispatchAttributeChangedEvent();
293
+ return true;
294
+ }
295
+
296
+ clearText() {
297
+ this._text = '';
298
+ }
299
+
300
+ _dispatchAttributeChangedEvent() {
301
+ this.dispatchEvent(new CustomEvent('d2l-labs-attribute-picker-attributes-changed', {
302
+ bubbles: true, composed: true, detail: { attributeList: this.attributeList }
303
+ }));
304
+ }
305
+
306
+ _focusAttribute(index) {
307
+ index = Math.min(index, this.attributeList.length - 1);
308
+ const selectedAttributes = this.shadowRoot.querySelectorAll('d2l-labs-attribute-picker-item');
309
+ if (selectedAttributes.length === 0) {
310
+ this.shadowRoot.querySelector('.d2l-attribute-picker-input').focus();
311
+ } else {
312
+ this._activeAttributeIndex = index;
313
+ selectedAttributes[index].focus();
314
+ }
315
+ }
316
+
317
+ _handleInvalidIconClick() {
318
+ const input = this.shadowRoot.querySelector('input');
319
+ if (!input) return;
320
+ this._inputFocused = true;
321
+ input.focus();
322
+ }
323
+
324
+ _onAttributeFocus(e) {
325
+ this._activeAttributeIndex = e.target.index;
326
+ }
327
+
328
+ async _onAttributeKeydown(e) {
329
+ if (e.keyCode === keyCodes.BACKSPACE || e.keyCode === keyCodes.DELETE) {
330
+ await this._removeAttribute(this._activeAttributeIndex);
331
+ if ((e.keyCode === keyCodes.BACKSPACE && this._activeAttributeIndex > 0)) {
332
+ this._activeAttributeIndex--;
333
+ }
334
+ this._focusAttribute(this._activeAttributeIndex);
335
+ }
336
+ if ((e.keyCode === keyCodes.DOWN || e.keyCode === keyCodes.RIGHT) && this._activeAttributeIndex === this.attributeList.length - 1) {
337
+ this.shadowRoot.querySelector('.d2l-attribute-picker-input').focus();
338
+ }
339
+ }
340
+
341
+ async _onAttributeRemoved(e) {
342
+ const index = e.target.index;
343
+ if (index !== -1) {
344
+ await this._removeAttribute(index);
345
+ this._focusAttribute(index);
346
+ this._activeAttributeIndex = Math.min(index, this.attributeList.length - 1);
347
+ }
348
+ }
349
+
350
+ _onFocusIn() {
351
+ this._hasFocus = true;
352
+ }
353
+
354
+ _onFocusOut() {
355
+ this._hasFocus = false;
356
+ }
357
+
358
+ _onInputBlur() {
359
+ this._inputFocused = false;
360
+ this._initialFocus = false;
361
+ }
362
+
363
+ _onInputFocus() {
364
+ this._inputFocused = true;
365
+ this._dropdownIndex = this.shadowRoot.querySelector('li') && !this.allowFreeform ? 0 : -1;
366
+ }
367
+
368
+ async _onInputKeydown(e) {
369
+ if (this.shadowRoot.querySelector('.d2l-attribute-picker-input').selectionStart !== 0 || e.keyCode === keyCodes.RIGHT || e.keyCode === keyCodes.UP || e.keyCode === keyCodes.DOWN) {
370
+ e.stopPropagation();
371
+
372
+ }
373
+ switch (e.keyCode) {
374
+ case keyCodes.ESCAPE: {
375
+ if (this.allowFreeform) { // Unselect any dropdown item so enter will apply to just the typed text instead
376
+ this._dropdownIndex = -1;
377
+ }
378
+ break;
379
+ }
380
+ case keyCodes.BACKSPACE: {
381
+ if (this.shadowRoot.querySelector('.d2l-attribute-picker-input').selectionStart === 0 && this.attributeList.length > 0) {
382
+ e.stopPropagation();
383
+ this._focusAttribute(this.attributeList.length - 1);
384
+ }
385
+ break;
386
+ }
387
+ case keyCodes.UP: {
388
+ const assignableCount = this.shadowRoot.querySelectorAll('li').length;
389
+ if (this._dropdownIndex === -1 || this._dropdownIndex === 0) {
390
+ this._dropdownIndex = assignableCount - 1;
391
+ } else {
392
+ this._dropdownIndex = (this._dropdownIndex - 1) % assignableCount;
393
+ }
394
+ await this._updateDropdownFocus();
395
+ break;
396
+ }
397
+ case keyCodes.DOWN: {
398
+ const assignableCount = this.shadowRoot.querySelectorAll('li').length;
399
+ this._dropdownIndex = (this._dropdownIndex + 1) % assignableCount;
400
+ await this._updateDropdownFocus();
401
+ break;
402
+ }
403
+ case keyCodes.ENTER: {
404
+ const list = this.shadowRoot.querySelectorAll('li');
405
+ if (this._dropdownIndex !== -1 && this._dropdownIndex < list.length) {
406
+ await this.addAttribute(list[this._dropdownIndex].text);
407
+ } else if (this.allowFreeform) {
408
+ const trimmedAttribute = this._text.trim();
409
+ if (trimmedAttribute.length === 0) return;
410
+
411
+ const comparableAttribute = trimmedAttribute.toLowerCase();
412
+ if (this.attributeList.map(a => a.name.toLowerCase()).includes(comparableAttribute)) return;
413
+
414
+ const matchedIndex = this.assignableAttributes.findIndex(a => a.name.toLowerCase() === comparableAttribute);
415
+ await this.addAttribute(matchedIndex >= 0 ? this.assignableAttributes[matchedIndex] : {
416
+ name: trimmedAttribute,
417
+ value: trimmedAttribute
418
+ });
419
+ }
420
+ await this._updateDropdownFocus();
421
+ break;
422
+ }
423
+ }
424
+ }
425
+
426
+ _onInputTextChanged(e) {
427
+ this._text = e.target.value;
428
+ if (this._dropdownIndex >= 0) {
429
+ this.allowFreeform ? this._dropdownIndex = -1 : this._dropdownIndex = 0;
430
+ }
431
+ }
432
+
433
+ _onListItemMouseMove(e) {
434
+ this._dropdownIndex = e.target.index;
435
+ }
436
+
437
+ async _onListItemTapped(e) {
438
+ await this.addAttribute(e.target.text);
439
+ e.preventDefault();
440
+ }
441
+
442
+ async _removeAttribute(index) {
443
+ this.attributeList = this.attributeList.slice(0, index).concat(this.attributeList.slice(index + 1, this.attributeList.length));
444
+ this._dispatchAttributeChangedEvent();
445
+ this._limitReached = this.limit && this.attributeList.length >= this.limit;
446
+ await this.updateComplete;
447
+ }
448
+
449
+ async _updateDropdownFocus() {
450
+ await this.updateComplete;
451
+ const items = this.shadowRoot.querySelectorAll('li');
452
+ if (items.length > 0 && this._dropdownIndex >= 0) {
453
+ items[this._dropdownIndex].scrollIntoView({ block: 'nearest' });
454
+ }
455
+ }
456
+ }
457
+ customElements.define('d2l-labs-attribute-picker', AttributePicker);
package/src/lang/ar.js CHANGED
@@ -11,6 +11,10 @@ export default {
11
11
  "components:accessibilityDisabilitySimulator:none": "لا شيء", // Disability simulation option that represents having no disability
12
12
  "components:accessibilityDisabilitySimulator:screenreaderAndTabAlert": "تمكين قارئ الشاشة وعلامة التبويب في المحتوى", // Alert that prompts the user to use a screenreader and tabbing to view content
13
13
  "components:accessibilityDisabilitySimulator:simulationType": "نوع المحاكاة:", // Label for the disability simulation options
14
+ "components:attributePicker:addValue": "انقر لإضافة القيمة {value}", // Label for screen readers to inform user that they can click to add the given value
15
+ "components:attributePicker:limitReached": "لقد بلغت الحد {value} من القيم المحددة", // Tooltip that appears when the user has reach the maximum amount of attributes
16
+ "components:attributePicker:minimumRequirement": "يجب تعيين قيمة واحدة على الأقل.", // Tooltip that appears when no values have been set and we need to inform the user that this is an invalid state
17
+ "components:attributePicker:removeValue": "انقر فوق، أو اضغط على مسافة للخلف، أو اضغط على مفتاح حذف لإزالة العنصر {value}", // Label to inform user how they can remove the given value
14
18
  "components:checkboxDrawer:checkboxCollapsed": "تم طي خانة الاختيار", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
15
19
  "components:checkboxDrawer:checkboxExpanded": "تم توسيع خانة الاختيار", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
16
20
  "components:optInFlyout:cancel": "إلغاء",
package/src/lang/cy.js CHANGED
@@ -11,6 +11,10 @@ export default {
11
11
  "components:accessibilityDisabilitySimulator:none": "Dim", // Disability simulation option that represents having no disability
12
12
  "components:accessibilityDisabilitySimulator:screenreaderAndTabAlert": "Galluogwch eich darllenydd sgrîn a thab i'r cynnwys", // Alert that prompts the user to use a screenreader and tabbing to view content
13
13
  "components:accessibilityDisabilitySimulator:simulationType": "Math o efelychiad:", // Label for the disability simulation options
14
+ "components:attributePicker:addValue": "Cliciwch i ychwanegu'r gwerth {value}", // Label for screen readers to inform user that they can click to add the given value
15
+ "components:attributePicker:limitReached": "Rydych chi wedi cyrraedd terfyn y gwerthoedd a ddewiswyd {value}", // Tooltip that appears when the user has reach the maximum amount of attributes
16
+ "components:attributePicker:minimumRequirement": "Rhaid gosod o leiaf un gwerth", // Tooltip that appears when no values have been set and we need to inform the user that this is an invalid state
17
+ "components:attributePicker:removeValue": "Cliciwch, pwyswch yn ôl, neu pwyswch y bysell dileu i dynnu’r eitem {value}", // Label to inform user how they can remove the given value
14
18
  "components:checkboxDrawer:checkboxCollapsed": "Wedi crebachu blwch ticio", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
15
19
  "components:checkboxDrawer:checkboxExpanded": "Wedi ehangu blwch ticio", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
16
20
  "components:optInFlyout:cancel": "Canslo",
package/src/lang/da.js CHANGED
@@ -11,6 +11,10 @@ export default {
11
11
  "components:accessibilityDisabilitySimulator:none": "Ingen", // Disability simulation option that represents having no disability
12
12
  "components:accessibilityDisabilitySimulator:screenreaderAndTabAlert": "Aktivér din skærmlæser og fane i indholdet", // Alert that prompts the user to use a screenreader and tabbing to view content
13
13
  "components:accessibilityDisabilitySimulator:simulationType": "Simulationstype:", // Label for the disability simulation options
14
+ "components:attributePicker:addValue": "Klik for at tilføje værdi {value}", // Label for screen readers to inform user that they can click to add the given value
15
+ "components:attributePicker:limitReached": "Du har nået grænsen på {value} valgte værdier", // Tooltip that appears when the user has reach the maximum amount of attributes
16
+ "components:attributePicker:minimumRequirement": "Der skal angives mindst én værdi", // Tooltip that appears when no values have been set and we need to inform the user that this is an invalid state
17
+ "components:attributePicker:removeValue": "Klik, tryk på tilbagetasten, eller tryk på slettasten for at fjerne element {value}", // Label to inform user how they can remove the given value
14
18
  "components:checkboxDrawer:checkboxCollapsed": "Afkrydsningsfelt skjult", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
15
19
  "components:checkboxDrawer:checkboxExpanded": "Afkrydsningsfelt udvidet", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
16
20
  "components:optInFlyout:cancel": "Annuller",
package/src/lang/de.js CHANGED
@@ -11,6 +11,10 @@ export default {
11
11
  "components:accessibilityDisabilitySimulator:none": "Keine", // Disability simulation option that represents having no disability
12
12
  "components:accessibilityDisabilitySimulator:screenreaderAndTabAlert": "Aktivieren Sie Ihre Bildschirmsprachausgabe und tippen Sie den Inhalt an", // Alert that prompts the user to use a screenreader and tabbing to view content
13
13
  "components:accessibilityDisabilitySimulator:simulationType": "Simulationstyp:", // Label for the disability simulation options
14
+ "components:attributePicker:addValue": "Klicken Sie, um den Wert {value} hinzuzufügen", // Label for screen readers to inform user that they can click to add the given value
15
+ "components:attributePicker:limitReached": "Sie haben das Limit von {value} ausgewählten Werten erreicht.", // Tooltip that appears when the user has reach the maximum amount of attributes
16
+ "components:attributePicker:minimumRequirement": "Mindestens ein Wert muss festgelegt werden", // Tooltip that appears when no values have been set and we need to inform the user that this is an invalid state
17
+ "components:attributePicker:removeValue": "Klicken Sie, drücken Sie die Rücktaste, oder drücken Sie die Entfernen-Taste, um das Element {value} zu entfernen", // Label to inform user how they can remove the given value
14
18
  "components:checkboxDrawer:checkboxCollapsed": "Kontrollkästchen ausgeblendet", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
15
19
  "components:checkboxDrawer:checkboxExpanded": "Kontrollkästchen eingeblendet", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
16
20
  "components:optInFlyout:cancel": "Abbrechen",
package/src/lang/en-gb.js CHANGED
@@ -11,6 +11,10 @@ export default {
11
11
  "components:accessibilityDisabilitySimulator:none": "None", // Disability simulation option that represents having no disability
12
12
  "components:accessibilityDisabilitySimulator:screenreaderAndTabAlert": "Enable your screenreader and tab into the content", // Alert that prompts the user to use a screenreader and tabbing to view content
13
13
  "components:accessibilityDisabilitySimulator:simulationType": "Simulation type:", // Label for the disability simulation options
14
+ "components:attributePicker:addValue": "Click to add value {value}", // Label for screen readers to inform user that they can click to add the given value
15
+ "components:attributePicker:limitReached": "You've reached the limit of {value} selected values", // Tooltip that appears when the user has reach the maximum amount of attributes
16
+ "components:attributePicker:minimumRequirement": "At least one value must be set", // Tooltip that appears when no values have been set and we need to inform the user that this is an invalid state
17
+ "components:attributePicker:removeValue": "Click, press backspace, or press delete key to remove item {value}", // Label to inform user how they can remove the given value
14
18
  "components:checkboxDrawer:checkboxCollapsed": "Tick box collapsed", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
15
19
  "components:checkboxDrawer:checkboxExpanded": "Tick box expanded", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
16
20
  "components:optInFlyout:cancel": "Cancel",
package/src/lang/en.js CHANGED
@@ -11,6 +11,10 @@ export default {
11
11
  "components:accessibilityDisabilitySimulator:none": "None", // Disability simulation option that represents having no disability
12
12
  "components:accessibilityDisabilitySimulator:screenreaderAndTabAlert": "Enable your screenreader and tab into the content", // Alert that prompts the user to use a screenreader and tabbing to view content
13
13
  "components:accessibilityDisabilitySimulator:simulationType": "Simulation type:", // Label for the disability simulation options
14
+ "components:attributePicker:addValue": "Click to add value {value}", // Label for screen readers to inform user that they can click to add the given value
15
+ "components:attributePicker:limitReached": "You've reached the limit of {value} selected values", // Tooltip that appears when the user has reach the maximum amount of attributes
16
+ "components:attributePicker:minimumRequirement": "At least one value must be set", // Tooltip that appears when no values have been set and we need to inform the user that this is an invalid state
17
+ "components:attributePicker:removeValue": "Click, press backspace, or press delete key to remove item {value}", // Label to inform user how they can remove the given value
14
18
  "components:checkboxDrawer:checkboxCollapsed": "Checkbox collapsed", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
15
19
  "components:checkboxDrawer:checkboxExpanded": "Checkbox expanded", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
16
20
  "components:optInFlyout:cancel": "Cancel",
package/src/lang/es-es.js CHANGED
@@ -11,6 +11,10 @@ export default {
11
11
  "components:accessibilityDisabilitySimulator:none": "Ninguno", // Disability simulation option that represents having no disability
12
12
  "components:accessibilityDisabilitySimulator:screenreaderAndTabAlert": "Habilite el lector de pantalla y desplácese con el tabulador por el contenido.", // Alert that prompts the user to use a screenreader and tabbing to view content
13
13
  "components:accessibilityDisabilitySimulator:simulationType": "Tipo de simulación:", // Label for the disability simulation options
14
+ "components:attributePicker:addValue": "Haga clic para agregar el valor {value}", // Label for screen readers to inform user that they can click to add the given value
15
+ "components:attributePicker:limitReached": "Ha alcanzado el límite de {value} valores seleccionados", // Tooltip that appears when the user has reach the maximum amount of attributes
16
+ "components:attributePicker:minimumRequirement": "Se debe establecer al menos un valor.", // Tooltip that appears when no values have been set and we need to inform the user that this is an invalid state
17
+ "components:attributePicker:removeValue": "Haga clic, pulse Retroceso o pulse la tecla Supr para eliminar el elemento {value}", // Label to inform user how they can remove the given value
14
18
  "components:checkboxDrawer:checkboxCollapsed": "Casilla de verificación contraída", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
15
19
  "components:checkboxDrawer:checkboxExpanded": "Casilla de verificación expandida", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
16
20
  "components:optInFlyout:cancel": "Cancelar",
package/src/lang/es.js CHANGED
@@ -11,6 +11,10 @@ export default {
11
11
  "components:accessibilityDisabilitySimulator:none": "Ninguno", // Disability simulation option that represents having no disability
12
12
  "components:accessibilityDisabilitySimulator:screenreaderAndTabAlert": "Habilite su lector de pantalla y tableta en el contenido", // Alert that prompts the user to use a screenreader and tabbing to view content
13
13
  "components:accessibilityDisabilitySimulator:simulationType": "Tipo de simulación:", // Label for the disability simulation options
14
+ "components:attributePicker:addValue": "Haga clic para agregar el valor {value}", // Label for screen readers to inform user that they can click to add the given value
15
+ "components:attributePicker:limitReached": "Alcanzó el límite de {value} valores seleccionados", // Tooltip that appears when the user has reach the maximum amount of attributes
16
+ "components:attributePicker:minimumRequirement": "Se debe definir al menos un valor", // Tooltip that appears when no values have been set and we need to inform the user that this is an invalid state
17
+ "components:attributePicker:removeValue": "Haga clic, presione Retroceso o presione la tecla Suprimir para eliminar el elemento {value}", // Label to inform user how they can remove the given value
14
18
  "components:checkboxDrawer:checkboxCollapsed": "Casilla de selección contraída", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
15
19
  "components:checkboxDrawer:checkboxExpanded": "Casilla de selección expandida", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
16
20
  "components:optInFlyout:cancel": "Cancelar",
package/src/lang/fr-fr.js CHANGED
@@ -11,6 +11,10 @@ export default {
11
11
  "components:accessibilityDisabilitySimulator:none": "Aucune", // Disability simulation option that represents having no disability
12
12
  "components:accessibilityDisabilitySimulator:screenreaderAndTabAlert": "Activez votre lecteur d’écran et parcourez le contenu", // Alert that prompts the user to use a screenreader and tabbing to view content
13
13
  "components:accessibilityDisabilitySimulator:simulationType": "Type de simulation :", // Label for the disability simulation options
14
+ "components:attributePicker:addValue": "Cliquer pour ajouter la valeur {value}", // Label for screen readers to inform user that they can click to add the given value
15
+ "components:attributePicker:limitReached": "Vous avez atteint la limite de {value} valeurs sélectionnées", // Tooltip that appears when the user has reach the maximum amount of attributes
16
+ "components:attributePicker:minimumRequirement": "Au moins une valeur doit être définie", // Tooltip that appears when no values have been set and we need to inform the user that this is an invalid state
17
+ "components:attributePicker:removeValue": "Cliquez sur l’élément, appuyez sur la touche Retour arrière ou sur la touche Suppr pour supprimer l’élément {value}", // Label to inform user how they can remove the given value
14
18
  "components:checkboxDrawer:checkboxCollapsed": "Case à cocher réduite", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
15
19
  "components:checkboxDrawer:checkboxExpanded": "Case à cocher développée", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
16
20
  "components:optInFlyout:cancel": "Annuler",
package/src/lang/fr-on.js CHANGED
@@ -11,6 +11,10 @@ export default {
11
11
  "components:accessibilityDisabilitySimulator:none": "Aucun", // Disability simulation option that represents having no disability
12
12
  "components:accessibilityDisabilitySimulator:screenreaderAndTabAlert": "Activez votre lecteur d'écran et utilisez la touche de tabulation pour parcourir le contenu", // Alert that prompts the user to use a screenreader and tabbing to view content
13
13
  "components:accessibilityDisabilitySimulator:simulationType": "Type de simulation :", // Label for the disability simulation options
14
+ "components:attributePicker:addValue": "Cliquer pour ajouter la valeur {value}", // Label for screen readers to inform user that they can click to add the given value
15
+ "components:attributePicker:limitReached": "Vous avez atteint la limite de {value} valeurs sélectionnées", // Tooltip that appears when the user has reach the maximum amount of attributes
16
+ "components:attributePicker:minimumRequirement": "Au moins une valeur doit être définit", // Tooltip that appears when no values have been set and we need to inform the user that this is an invalid state
17
+ "components:attributePicker:removeValue": "Cliquez sur le bouton, appuyez sur retour arrière ou appuyez sur la touche de suppression pour supprimer l’élément {value}", // Label to inform user how they can remove the given value
14
18
  "components:checkboxDrawer:checkboxCollapsed": "Case à cocher réduite", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
15
19
  "components:checkboxDrawer:checkboxExpanded": "Case à cocher agrandie", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
16
20
  "components:optInFlyout:cancel": "Annuler",
package/src/lang/fr.js CHANGED
@@ -11,6 +11,10 @@ export default {
11
11
  "components:accessibilityDisabilitySimulator:none": "Aucun", // Disability simulation option that represents having no disability
12
12
  "components:accessibilityDisabilitySimulator:screenreaderAndTabAlert": "Activez votre lecteur d'écran et utilisez la touche de tabulation pour parcourir le contenu", // Alert that prompts the user to use a screenreader and tabbing to view content
13
13
  "components:accessibilityDisabilitySimulator:simulationType": "Type de simulation :", // Label for the disability simulation options
14
+ "components:attributePicker:addValue": "Cliquer pour ajouter la valeur {value}", // Label for screen readers to inform user that they can click to add the given value
15
+ "components:attributePicker:limitReached": "Vous avez atteint la limite de {value} valeurs sélectionnées", // Tooltip that appears when the user has reach the maximum amount of attributes
16
+ "components:attributePicker:minimumRequirement": "Au moins une valeur doit être définit", // Tooltip that appears when no values have been set and we need to inform the user that this is an invalid state
17
+ "components:attributePicker:removeValue": "Cliquez sur le bouton, appuyez sur retour arrière ou appuyez sur la touche de suppression pour supprimer l’élément {value}", // Label to inform user how they can remove the given value
14
18
  "components:checkboxDrawer:checkboxCollapsed": "Case à cocher réduite", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
15
19
  "components:checkboxDrawer:checkboxExpanded": "Case à cocher agrandie", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
16
20
  "components:optInFlyout:cancel": "Annuler",
package/src/lang/hi.js CHANGED
@@ -11,6 +11,10 @@ export default {
11
11
  "components:accessibilityDisabilitySimulator:none": "कोई नहीं", // Disability simulation option that represents having no disability
12
12
  "components:accessibilityDisabilitySimulator:screenreaderAndTabAlert": "सामग्री में अपना स्क्रीनरीडर और टैब चालू करें", // Alert that prompts the user to use a screenreader and tabbing to view content
13
13
  "components:accessibilityDisabilitySimulator:simulationType": "सिम्युलेशन प्रकार:", // Label for the disability simulation options
14
+ "components:attributePicker:addValue": "मान {value} जोड़ने के लिए क्लिक करें", // Label for screen readers to inform user that they can click to add the given value
15
+ "components:attributePicker:limitReached": "आप {value} चयनित मानों की सीमा तक पहुँच गए हैं", // Tooltip that appears when the user has reach the maximum amount of attributes
16
+ "components:attributePicker:minimumRequirement": "कम से कम एक मान सेट होना चाहिए", // Tooltip that appears when no values have been set and we need to inform the user that this is an invalid state
17
+ "components:attributePicker:removeValue": "{value} को हटाने के लिए क्लिक करें, बैकस्पेस दबाएँ, या हटाएँ कुंजी को दबाएँ", // Label to inform user how they can remove the given value
14
18
  "components:checkboxDrawer:checkboxCollapsed": "चेकबॉक्स छोटा हो गया", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
15
19
  "components:checkboxDrawer:checkboxExpanded": "चेकबॉक्स बड़ा हो गया", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
16
20
  "components:optInFlyout:cancel": "कैंसल करें",
package/src/lang/ja.js CHANGED
@@ -11,6 +11,10 @@ export default {
11
11
  "components:accessibilityDisabilitySimulator:none": "なし", // Disability simulation option that represents having no disability
12
12
  "components:accessibilityDisabilitySimulator:screenreaderAndTabAlert": "スクリーンリーダーを有効にして、コンテンツを利用します", // Alert that prompts the user to use a screenreader and tabbing to view content
13
13
  "components:accessibilityDisabilitySimulator:simulationType": "シミュレーションタイプ: ", // Label for the disability simulation options
14
+ "components:attributePicker:addValue": "クリックして値 {value} を追加", // Label for screen readers to inform user that they can click to add the given value
15
+ "components:attributePicker:limitReached": "{value} 個の選択した値の上限に達しました", // Tooltip that appears when the user has reach the maximum amount of attributes
16
+ "components:attributePicker:minimumRequirement": "少なくとも 1 つの値を設定する必要があります", // Tooltip that appears when no values have been set and we need to inform the user that this is an invalid state
17
+ "components:attributePicker:removeValue": "クリックする、Backspace キーを押す、または Delete キーを押すと項目 {value} が削除されます", // Label to inform user how they can remove the given value
14
18
  "components:checkboxDrawer:checkboxCollapsed": "折りたたまれたチェックボックス", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
15
19
  "components:checkboxDrawer:checkboxExpanded": "展開されたチェックボックス", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
16
20
  "components:optInFlyout:cancel": "キャンセル",
package/src/lang/ko.js CHANGED
@@ -11,6 +11,10 @@ export default {
11
11
  "components:accessibilityDisabilitySimulator:none": "없음", // Disability simulation option that represents having no disability
12
12
  "components:accessibilityDisabilitySimulator:screenreaderAndTabAlert": "스크린 리더를 활성화하고 콘텐츠를 탭합니다", // Alert that prompts the user to use a screenreader and tabbing to view content
13
13
  "components:accessibilityDisabilitySimulator:simulationType": "시뮬레이션 유형:", // Label for the disability simulation options
14
+ "components:attributePicker:addValue": "클릭하여 값 {value}을(를) 추가합니다.", // Label for screen readers to inform user that they can click to add the given value
15
+ "components:attributePicker:limitReached": "{value} 선택한 값의 제한에 도달했습니다.", // Tooltip that appears when the user has reach the maximum amount of attributes
16
+ "components:attributePicker:minimumRequirement": "하나 이상의 값을 설정해야 합니다.", // Tooltip that appears when no values have been set and we need to inform the user that this is an invalid state
17
+ "components:attributePicker:removeValue": "항목 {value}을(를) 제거하려면 클릭하거나, 백스페이스 또는 삭제 키를 누릅니다.", // Label to inform user how they can remove the given value
14
18
  "components:checkboxDrawer:checkboxCollapsed": "확인란이 축소됨", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
15
19
  "components:checkboxDrawer:checkboxExpanded": "확인란이 확장됨", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
16
20
  "components:optInFlyout:cancel": "취소",
package/src/lang/nl.js CHANGED
@@ -11,6 +11,10 @@ export default {
11
11
  "components:accessibilityDisabilitySimulator:none": "Geen", // Disability simulation option that represents having no disability
12
12
  "components:accessibilityDisabilitySimulator:screenreaderAndTabAlert": "Schakel uw schermlezer in en druk op tab om naar de inhoud te gaan", // Alert that prompts the user to use a screenreader and tabbing to view content
13
13
  "components:accessibilityDisabilitySimulator:simulationType": "Simulatietype:", // Label for the disability simulation options
14
+ "components:attributePicker:addValue": "Klik om waarde {value} toe te voegen", // Label for screen readers to inform user that they can click to add the given value
15
+ "components:attributePicker:limitReached": "U hebt de limiet van {value} geselecteerde waarden bereikt", // Tooltip that appears when the user has reach the maximum amount of attributes
16
+ "components:attributePicker:minimumRequirement": "Er moet ten minste één waarde worden ingesteld", // Tooltip that appears when no values have been set and we need to inform the user that this is an invalid state
17
+ "components:attributePicker:removeValue": "Klik, druk op Backspace of druk op de Delete-toets om item {value} te verwijderen", // Label to inform user how they can remove the given value
14
18
  "components:checkboxDrawer:checkboxCollapsed": "Selectievakje samengevouwen", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
15
19
  "components:checkboxDrawer:checkboxExpanded": "Selectievakje uitgevouwen", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
16
20
  "components:optInFlyout:cancel": "Annuleren",
package/src/lang/pt.js CHANGED
@@ -11,6 +11,10 @@ export default {
11
11
  "components:accessibilityDisabilitySimulator:none": "Nenhuma", // Disability simulation option that represents having no disability
12
12
  "components:accessibilityDisabilitySimulator:screenreaderAndTabAlert": "Ative seu leitor de tela e insira o conteúdo", // Alert that prompts the user to use a screenreader and tabbing to view content
13
13
  "components:accessibilityDisabilitySimulator:simulationType": "Tipo de simulação:", // Label for the disability simulation options
14
+ "components:attributePicker:addValue": "Clique para adicionar valor {value}", // Label for screen readers to inform user that they can click to add the given value
15
+ "components:attributePicker:limitReached": "Você atingiu o limite de {value} valores selecionados", // Tooltip that appears when the user has reach the maximum amount of attributes
16
+ "components:attributePicker:minimumRequirement": "Pelo menos um valor deve ser definido", // Tooltip that appears when no values have been set and we need to inform the user that this is an invalid state
17
+ "components:attributePicker:removeValue": "Clique em, pressione Backspace ou pressione a tecla Delete para remover o item {value}", // Label to inform user how they can remove the given value
14
18
  "components:checkboxDrawer:checkboxCollapsed": "Caixa de seleção recolhida", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
15
19
  "components:checkboxDrawer:checkboxExpanded": "Caixa de seleção expandida", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
16
20
  "components:optInFlyout:cancel": "Cancelar",
package/src/lang/sv.js CHANGED
@@ -11,6 +11,10 @@ export default {
11
11
  "components:accessibilityDisabilitySimulator:none": "Inga", // Disability simulation option that represents having no disability
12
12
  "components:accessibilityDisabilitySimulator:screenreaderAndTabAlert": "Aktivera skärmläsaren och använd Tabb till att förflytta dig i innehållet", // Alert that prompts the user to use a screenreader and tabbing to view content
13
13
  "components:accessibilityDisabilitySimulator:simulationType": "Simuleringstyp:", // Label for the disability simulation options
14
+ "components:attributePicker:addValue": "Klicka för att lägga till värde {value}", // Label for screen readers to inform user that they can click to add the given value
15
+ "components:attributePicker:limitReached": "Du har nått gränsen på {value} valda värden", // Tooltip that appears when the user has reach the maximum amount of attributes
16
+ "components:attributePicker:minimumRequirement": "Minst ett värde måste anges", // Tooltip that appears when no values have been set and we need to inform the user that this is an invalid state
17
+ "components:attributePicker:removeValue": "Klicka, tryck på backstegstangenten eller Delete-tangenten för att ta bort objektet {value}", // Label to inform user how they can remove the given value
14
18
  "components:checkboxDrawer:checkboxCollapsed": "Komprimerad kryssruta", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
15
19
  "components:checkboxDrawer:checkboxExpanded": "Expanderad kryssruta", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
16
20
  "components:optInFlyout:cancel": "Avbryt",
package/src/lang/tr.js CHANGED
@@ -11,6 +11,10 @@ export default {
11
11
  "components:accessibilityDisabilitySimulator:none": "Yok", // Disability simulation option that represents having no disability
12
12
  "components:accessibilityDisabilitySimulator:screenreaderAndTabAlert": "Ekran okuyucunuzu etkinleştirin ve içeriğe erişin", // Alert that prompts the user to use a screenreader and tabbing to view content
13
13
  "components:accessibilityDisabilitySimulator:simulationType": "Simülasyon türü:", // Label for the disability simulation options
14
+ "components:attributePicker:addValue": "{value} değeri eklemek için tıklayın", // Label for screen readers to inform user that they can click to add the given value
15
+ "components:attributePicker:limitReached": "{value} seçili değer sınırına ulaştınız", // Tooltip that appears when the user has reach the maximum amount of attributes
16
+ "components:attributePicker:minimumRequirement": "En az bir değer ayarlanmalıdır", // Tooltip that appears when no values have been set and we need to inform the user that this is an invalid state
17
+ "components:attributePicker:removeValue": "Öğe {value} değerini kaldırmak için tıklatın, geri al tuşuna veya sil tuşuna basın", // Label to inform user how they can remove the given value
14
18
  "components:checkboxDrawer:checkboxCollapsed": "Onay kutusu daraltıldı", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
15
19
  "components:checkboxDrawer:checkboxExpanded": "Onay kutusu genişletildi", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
16
20
  "components:optInFlyout:cancel": "İptal et",
package/src/lang/zh-cn.js CHANGED
@@ -11,6 +11,10 @@ export default {
11
11
  "components:accessibilityDisabilitySimulator:none": "无", // Disability simulation option that represents having no disability
12
12
  "components:accessibilityDisabilitySimulator:screenreaderAndTabAlert": "启用屏幕阅读器并按 Tab 键进入内容", // Alert that prompts the user to use a screenreader and tabbing to view content
13
13
  "components:accessibilityDisabilitySimulator:simulationType": "模拟类型:", // Label for the disability simulation options
14
+ "components:attributePicker:addValue": "单击以添加值 {value}", // Label for screen readers to inform user that they can click to add the given value
15
+ "components:attributePicker:limitReached": "您已达到所选值 {value} 的限制", // Tooltip that appears when the user has reach the maximum amount of attributes
16
+ "components:attributePicker:minimumRequirement": "必须设置至少一个值", // Tooltip that appears when no values have been set and we need to inform the user that this is an invalid state
17
+ "components:attributePicker:removeValue": "单击、按退格键或按 Delete 键以移除项目 {value}", // Label to inform user how they can remove the given value
14
18
  "components:checkboxDrawer:checkboxCollapsed": "复选框已折叠", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
15
19
  "components:checkboxDrawer:checkboxExpanded": "复选框已展开", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
16
20
  "components:optInFlyout:cancel": "取消",
package/src/lang/zh-tw.js CHANGED
@@ -11,6 +11,10 @@ export default {
11
11
  "components:accessibilityDisabilitySimulator:none": "無", // Disability simulation option that represents having no disability
12
12
  "components:accessibilityDisabilitySimulator:screenreaderAndTabAlert": "啟用畫面閱讀程式並使用 Tab 鍵進入內容", // Alert that prompts the user to use a screenreader and tabbing to view content
13
13
  "components:accessibilityDisabilitySimulator:simulationType": "模擬類型:", // Label for the disability simulation options
14
+ "components:attributePicker:addValue": "按一下以新增值 {value}", // Label for screen readers to inform user that they can click to add the given value
15
+ "components:attributePicker:limitReached": "您已達到 {value} 個選取值的限制", // Tooltip that appears when the user has reach the maximum amount of attributes
16
+ "components:attributePicker:minimumRequirement": "至少必須設定一個值", // Tooltip that appears when no values have been set and we need to inform the user that this is an invalid state
17
+ "components:attributePicker:removeValue": "按一下、按下退格鍵或按下刪除鍵以移除項目 {value}", // Label to inform user how they can remove the given value
14
18
  "components:checkboxDrawer:checkboxCollapsed": "核取方塊已摺疊", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
15
19
  "components:checkboxDrawer:checkboxExpanded": "核取方塊已展開", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
16
20
  "components:optInFlyout:cancel": "取消",
@@ -1,21 +0,0 @@
1
- # d2l-labs-status-icon
2
-
3
- Displays an icon as well as optional text to show the state/status of some feature or tool
4
-
5
- ## Usage
6
-
7
- ```html
8
- <script type="module">
9
- import '@brightspace-ui-labs/status-icon/status-icon.js';
10
- </script>
11
- <d2l-labs-status-icon state="failure" message="Failure"></d2l-labs-status-icon>
12
- ```
13
-
14
- ![Status Icons preview](./StatusIconPreview.PNG)
15
-
16
- **Properties:**
17
-
18
- | Property | Type | Description |
19
- |--|--|--|
20
- | `message` | String | Message to be displayed |
21
- | `state` | String, default: `'failure'` | State of the status. Can be one of `failure`, `warning`, `success`. |
@@ -1,67 +0,0 @@
1
- import '@brightspace-ui/core/components/colors/colors.js';
2
- import '@brightspace-ui/core/components/icons/icon.js';
3
- import { css, html, LitElement } from 'lit';
4
- import { RtlMixin } from '@brightspace-ui/core/mixins/rtl-mixin.js';
5
-
6
- function getIcon(state) {
7
- switch (state) {
8
- case 'success':
9
- return 'tier1:check-circle';
10
- case 'warning':
11
- return 'tier1:alert';
12
- default:
13
- return 'tier1:close-circle';
14
- }
15
- }
16
-
17
- class StatusIcon extends RtlMixin(LitElement) {
18
-
19
- static get properties() {
20
- return {
21
- state: { type: String, reflect: true },
22
- message: { type: String, reflect: true }
23
- };
24
- }
25
-
26
- static get styles() {
27
- return css`
28
- :host {
29
- align-items: center;
30
- display: inline-flex;
31
- }
32
- :host([hidden]) {
33
- display: none;
34
- }
35
- :host,
36
- d2l-icon {
37
- color: var(--d2l-color-cinnabar);
38
- }
39
- :host([state="warning"]),
40
- :host([state="warning"]) d2l-icon {
41
- color: var(--d2l-color-citrine);
42
- }
43
- :host([state="success"]),
44
- :host([state="success"]) d2l-icon {
45
- color: var(--d2l-color-olivine);
46
- }
47
- span {
48
- margin-inline-start: 0.4em;
49
- }
50
- `;
51
- }
52
-
53
- constructor() {
54
- super();
55
- this.state = 'failure';
56
- }
57
-
58
- render() {
59
- const icon = getIcon(this.state);
60
- return html`
61
- <d2l-icon icon="${icon}"></d2l-icon>
62
- <span>${this.message} </span>
63
- `;
64
- }
65
-
66
- }
67
- customElements.define('d2l-labs-status-icon', StatusIcon);