@api-client/ui 0.5.52 → 0.5.53
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/build/src/md/menu/internal/SubMenu.styles.d.ts.map +1 -1
- package/build/src/md/menu/internal/SubMenu.styles.js +22 -1
- package/build/src/md/menu/internal/SubMenu.styles.js.map +1 -1
- package/build/src/md/select/internals/Select.d.ts +41 -7
- package/build/src/md/select/internals/Select.d.ts.map +1 -1
- package/build/src/md/select/internals/Select.js +150 -32
- package/build/src/md/select/internals/Select.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/md/menu/internal/SubMenu.styles.ts +22 -1
- package/src/md/select/internals/Select.ts +167 -26
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubMenu.styles.d.ts","sourceRoot":"","sources":["../../../../../src/md/menu/internal/SubMenu.styles.ts"],"names":[],"mappings":";AAEA,
|
|
1
|
+
{"version":3,"file":"SubMenu.styles.d.ts","sourceRoot":"","sources":["../../../../../src/md/menu/internal/SubMenu.styles.ts"],"names":[],"mappings":";AAEA,wBA0BC"}
|
|
@@ -2,7 +2,28 @@ import { css } from 'lit';
|
|
|
2
2
|
export default css `
|
|
3
3
|
:host {
|
|
4
4
|
position-area: span-bottom right;
|
|
5
|
-
position-try
|
|
5
|
+
position-try:
|
|
6
|
+
--submenu-fallback-left,
|
|
7
|
+
--submenu-fallback-top-right,
|
|
8
|
+
--submenu-fallback-top-left,
|
|
9
|
+
--submenu-fallback-bottom-left,
|
|
10
|
+
flip-block flip-inline;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@position-try --submenu-fallback-left {
|
|
14
|
+
position-area: span-bottom left;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@position-try --submenu-fallback-top-right {
|
|
18
|
+
position-area: span-top right;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@position-try --submenu-fallback-top-left {
|
|
22
|
+
position-area: span-top left;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@position-try --submenu-fallback-bottom-left {
|
|
26
|
+
position-area: span-bottom left;
|
|
6
27
|
}
|
|
7
28
|
`;
|
|
8
29
|
//# sourceMappingURL=SubMenu.styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubMenu.styles.js","sourceRoot":"","sources":["../../../../../src/md/menu/internal/SubMenu.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEzB,eAAe,GAAG,CAAA
|
|
1
|
+
{"version":3,"file":"SubMenu.styles.js","sourceRoot":"","sources":["../../../../../src/md/menu/internal/SubMenu.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEzB,eAAe,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BjB,CAAA","sourcesContent":["import { css } from 'lit'\n\nexport default css`\n :host {\n position-area: span-bottom right;\n position-try:\n --submenu-fallback-left,\n --submenu-fallback-top-right,\n --submenu-fallback-top-left,\n --submenu-fallback-bottom-left,\n flip-block flip-inline;\n }\n\n @position-try --submenu-fallback-left {\n position-area: span-bottom left;\n }\n\n @position-try --submenu-fallback-top-right {\n position-area: span-top right;\n }\n\n @position-try --submenu-fallback-top-left {\n position-area: span-top left;\n }\n\n @position-try --submenu-fallback-bottom-left {\n position-area: span-bottom left;\n }\n`\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PropertyValues, TemplateResult } from 'lit';
|
|
2
|
+
import { UiElement } from '../../UiElement.js';
|
|
2
3
|
import type UiOption from './Option.js';
|
|
3
4
|
import type { UiMenuElement } from '../../menu/ui-menu.js';
|
|
4
5
|
import '../../text-field/ui-outlined-text-field.js';
|
|
@@ -17,7 +18,7 @@ export interface UiSelectChangeEvent {
|
|
|
17
18
|
* @fires open - Dispatched when the dropdown opens
|
|
18
19
|
* @fires close - Dispatched when the dropdown closes
|
|
19
20
|
*/
|
|
20
|
-
export default class UiSelect extends
|
|
21
|
+
export default class UiSelect extends UiElement {
|
|
21
22
|
#private;
|
|
22
23
|
static readonly formAssociated = true;
|
|
23
24
|
/**
|
|
@@ -134,7 +135,6 @@ export default class UiSelect extends LitElement {
|
|
|
134
135
|
*/
|
|
135
136
|
accessor open: boolean;
|
|
136
137
|
accessor selectedOption: UiOption | null;
|
|
137
|
-
accessor ariaActiveDescendant: string | undefined;
|
|
138
138
|
accessor menu: UiMenuElement;
|
|
139
139
|
/**
|
|
140
140
|
* Returns the currently selected option element. This provides access to the
|
|
@@ -244,15 +244,49 @@ export default class UiSelect extends LitElement {
|
|
|
244
244
|
protected setCurrentOption(): void;
|
|
245
245
|
protected handleKeydown(e: KeyboardEvent): void;
|
|
246
246
|
protected handleBlur(e: FocusEvent): void;
|
|
247
|
-
|
|
247
|
+
handleClick(e: Event): void;
|
|
248
248
|
protected handleOpenChange(): Promise<void>;
|
|
249
|
+
/**
|
|
250
|
+
* Focus the next menu item in the dropdown, skipping disabled options
|
|
251
|
+
*/
|
|
252
|
+
focusNextMenuItem(): void;
|
|
253
|
+
/**
|
|
254
|
+
* Focus the previous menu item in the dropdown, skipping disabled options
|
|
255
|
+
*/
|
|
256
|
+
focusPreviousMenuItem(): void;
|
|
257
|
+
/**
|
|
258
|
+
* Focus the first menu item in the dropdown, skipping disabled options
|
|
259
|
+
*/
|
|
260
|
+
focusFirstMenuItem(): void;
|
|
261
|
+
/**
|
|
262
|
+
* Focus the last menu item in the dropdown, skipping disabled options
|
|
263
|
+
*/
|
|
264
|
+
focusLastMenuItem(): void;
|
|
265
|
+
/**
|
|
266
|
+
* Gets the first selectable (non-disabled) option
|
|
267
|
+
*/
|
|
268
|
+
getFirstSelectableOption(): UiOption | null;
|
|
269
|
+
/**
|
|
270
|
+
* Gets the last selectable (non-disabled) option
|
|
271
|
+
*/
|
|
272
|
+
getLastSelectableOption(): UiOption | null;
|
|
273
|
+
/**
|
|
274
|
+
* Gets the next selectable option after the current one, wrapping around if needed
|
|
275
|
+
*/
|
|
276
|
+
protected getNextSelectableOption(currentOption: UiOption): UiOption | null;
|
|
277
|
+
/**
|
|
278
|
+
* Gets the previous selectable option before the current one, wrapping around if needed
|
|
279
|
+
*/
|
|
280
|
+
protected getPreviousSelectableOption(currentOption: UiOption): UiOption | null;
|
|
281
|
+
/**
|
|
282
|
+
* Checks if an option is selectable (not disabled and not hidden)
|
|
283
|
+
*/
|
|
284
|
+
protected isOptionSelectable(option: UiOption): boolean;
|
|
249
285
|
handleSelect(e: CustomEvent<{
|
|
250
286
|
item: UiOption;
|
|
251
287
|
}>): void;
|
|
252
|
-
handleHighlightChange(e: CustomEvent<{
|
|
253
|
-
item: UiOption | null;
|
|
254
|
-
}>): void;
|
|
255
288
|
handleMenuClose(): void;
|
|
289
|
+
handleMenuToggle(e: ToggleEvent): void;
|
|
256
290
|
protected renderInput(): TemplateResult;
|
|
257
291
|
protected renderMenu(): TemplateResult;
|
|
258
292
|
protected handleSlotChange(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../../../src/md/select/internals/Select.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,
|
|
1
|
+
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../../../src/md/select/internals/Select.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,cAAc,EAAE,cAAc,EAAE,MAAM,KAAK,CAAA;AAK1D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,KAAK,QAAQ,MAAM,aAAa,CAAA;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAG1D,OAAO,4CAA4C,CAAA;AACnD,OAAO,uBAAuB,CAAA;AAC9B,OAAO,wBAAwB,CAAA;AAC/B,OAAO,mCAAmC,CAAA;AAE1C,MAAM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EG;IACH,SAAS,CAAC,kBAAkB,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO;IAavD,YAAY,CAAC,CAAC,EAAE,WAAW,CAAC;QAAE,IAAI,EAAE,QAAQ,CAAA;KAAE,CAAC,GAAG,IAAI;IAsBtD,eAAe,IAAI,IAAI;IAKvB,gBAAgB,CAAC,CAAC,EAAE,WAAW,GAAG,IAAI;IAMtC,SAAS,CAAC,WAAW,IAAI,cAAc;IAyBvC,SAAS,CAAC,UAAU,IAAI,cAAc;cAmBtB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IASjD,SAAS,CAAC,eAAe,IAAI,cAAc;IAIlC,MAAM,IAAI,cAAc;CASlC"}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { __esDecorate, __runInitializers } from "tslib";
|
|
2
|
-
import { html
|
|
2
|
+
import { html } from 'lit';
|
|
3
3
|
import { property, query, state } from 'lit/decorators.js';
|
|
4
4
|
import { classMap } from 'lit/directives/class-map.js';
|
|
5
5
|
import { styleMap } from 'lit/directives/style-map.js';
|
|
6
6
|
import { setDisabled } from '../../../lib/disabled.js';
|
|
7
|
+
import { UiElement } from '../../UiElement.js';
|
|
7
8
|
import { nanoid } from 'nanoid';
|
|
8
9
|
import '../../text-field/ui-outlined-text-field.js';
|
|
9
10
|
import '../../menu/ui-menu.js';
|
|
10
11
|
import '../../icons/ui-icon.js';
|
|
11
12
|
import '../../focus-ring/ui-focus-ring.js';
|
|
12
13
|
let UiSelect = (() => {
|
|
13
|
-
let _classSuper =
|
|
14
|
+
let _classSuper = UiElement;
|
|
14
15
|
let _instanceExtraInitializers = [];
|
|
15
16
|
let _set_value_decorators;
|
|
16
17
|
let _name_decorators;
|
|
@@ -40,9 +41,6 @@ let UiSelect = (() => {
|
|
|
40
41
|
let _selectedOption_decorators;
|
|
41
42
|
let _selectedOption_initializers = [];
|
|
42
43
|
let _selectedOption_extraInitializers = [];
|
|
43
|
-
let _ariaActiveDescendant_decorators;
|
|
44
|
-
let _ariaActiveDescendant_initializers = [];
|
|
45
|
-
let _ariaActiveDescendant_extraInitializers = [];
|
|
46
44
|
let _menu_decorators;
|
|
47
45
|
let _menu_initializers = [];
|
|
48
46
|
let _menu_extraInitializers = [];
|
|
@@ -59,7 +57,6 @@ let UiSelect = (() => {
|
|
|
59
57
|
_disabled_decorators = [property({ type: Boolean, reflect: true })];
|
|
60
58
|
_open_decorators = [property({ type: Boolean, reflect: true })];
|
|
61
59
|
_selectedOption_decorators = [state()];
|
|
62
|
-
_ariaActiveDescendant_decorators = [state()];
|
|
63
60
|
_menu_decorators = [query('.menu')];
|
|
64
61
|
__esDecorate(this, null, _set_value_decorators, { kind: "setter", name: "value", static: false, private: false, access: { has: obj => "value" in obj, set: (obj, value) => { obj.value = value; } }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
65
62
|
__esDecorate(this, null, _name_decorators, { kind: "accessor", name: "name", static: false, private: false, access: { has: obj => "name" in obj, get: obj => obj.name, set: (obj, value) => { obj.name = value; } }, metadata: _metadata }, _name_initializers, _name_extraInitializers);
|
|
@@ -71,7 +68,6 @@ let UiSelect = (() => {
|
|
|
71
68
|
__esDecorate(this, null, _disabled_decorators, { kind: "accessor", name: "disabled", static: false, private: false, access: { has: obj => "disabled" in obj, get: obj => obj.disabled, set: (obj, value) => { obj.disabled = value; } }, metadata: _metadata }, _disabled_initializers, _disabled_extraInitializers);
|
|
72
69
|
__esDecorate(this, null, _open_decorators, { kind: "accessor", name: "open", static: false, private: false, access: { has: obj => "open" in obj, get: obj => obj.open, set: (obj, value) => { obj.open = value; } }, metadata: _metadata }, _open_initializers, _open_extraInitializers);
|
|
73
70
|
__esDecorate(this, null, _selectedOption_decorators, { kind: "accessor", name: "selectedOption", static: false, private: false, access: { has: obj => "selectedOption" in obj, get: obj => obj.selectedOption, set: (obj, value) => { obj.selectedOption = value; } }, metadata: _metadata }, _selectedOption_initializers, _selectedOption_extraInitializers);
|
|
74
|
-
__esDecorate(this, null, _ariaActiveDescendant_decorators, { kind: "accessor", name: "ariaActiveDescendant", static: false, private: false, access: { has: obj => "ariaActiveDescendant" in obj, get: obj => obj.ariaActiveDescendant, set: (obj, value) => { obj.ariaActiveDescendant = value; } }, metadata: _metadata }, _ariaActiveDescendant_initializers, _ariaActiveDescendant_extraInitializers);
|
|
75
71
|
__esDecorate(this, null, _menu_decorators, { kind: "accessor", name: "menu", static: false, private: false, access: { has: obj => "menu" in obj, get: obj => obj.menu, set: (obj, value) => { obj.menu = value; } }, metadata: _metadata }, _menu_initializers, _menu_extraInitializers);
|
|
76
72
|
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
77
73
|
}
|
|
@@ -250,10 +246,7 @@ let UiSelect = (() => {
|
|
|
250
246
|
#selectedOption_accessor_storage = (__runInitializers(this, _open_extraInitializers), __runInitializers(this, _selectedOption_initializers, null));
|
|
251
247
|
get selectedOption() { return this.#selectedOption_accessor_storage; }
|
|
252
248
|
set selectedOption(value) { this.#selectedOption_accessor_storage = value; }
|
|
253
|
-
#
|
|
254
|
-
get ariaActiveDescendant() { return this.#ariaActiveDescendant_accessor_storage; }
|
|
255
|
-
set ariaActiveDescendant(value) { this.#ariaActiveDescendant_accessor_storage = value; }
|
|
256
|
-
#menu_accessor_storage = (__runInitializers(this, _ariaActiveDescendant_extraInitializers), __runInitializers(this, _menu_initializers, void 0));
|
|
249
|
+
#menu_accessor_storage = (__runInitializers(this, _selectedOption_extraInitializers), __runInitializers(this, _menu_initializers, void 0));
|
|
257
250
|
get menu() { return this.#menu_accessor_storage; }
|
|
258
251
|
set menu(value) { this.#menu_accessor_storage = value; }
|
|
259
252
|
/**
|
|
@@ -477,27 +470,29 @@ let UiSelect = (() => {
|
|
|
477
470
|
}
|
|
478
471
|
case 'ArrowDown':
|
|
479
472
|
e.preventDefault();
|
|
480
|
-
this.
|
|
473
|
+
this.focusNextMenuItem();
|
|
481
474
|
return;
|
|
482
475
|
case 'ArrowUp':
|
|
483
476
|
e.preventDefault();
|
|
484
|
-
this.
|
|
477
|
+
this.focusPreviousMenuItem();
|
|
485
478
|
return;
|
|
486
479
|
case 'Home':
|
|
487
480
|
e.preventDefault();
|
|
488
|
-
this.
|
|
481
|
+
this.focusFirstMenuItem();
|
|
489
482
|
return;
|
|
490
483
|
case 'End':
|
|
491
484
|
e.preventDefault();
|
|
492
|
-
this.
|
|
485
|
+
this.focusLastMenuItem();
|
|
493
486
|
return;
|
|
494
487
|
case 'Enter':
|
|
495
|
-
case ' ':
|
|
496
|
-
|
|
488
|
+
case ' ': {
|
|
489
|
+
const currentItem = this.querySelector(':focus');
|
|
490
|
+
if (currentItem && this.isOptionSelectable(currentItem)) {
|
|
497
491
|
e.preventDefault();
|
|
498
|
-
this.menu.notifySelect(
|
|
492
|
+
this.menu.notifySelect(currentItem);
|
|
499
493
|
}
|
|
500
494
|
return;
|
|
495
|
+
}
|
|
501
496
|
}
|
|
502
497
|
}
|
|
503
498
|
else {
|
|
@@ -555,24 +550,147 @@ let UiSelect = (() => {
|
|
|
555
550
|
this.setAttribute('aria-expanded', String(this.open));
|
|
556
551
|
if (this.open) {
|
|
557
552
|
menu.showPopover();
|
|
558
|
-
// menu
|
|
559
|
-
if (this.selectedOption) {
|
|
560
|
-
this.
|
|
553
|
+
// Focus on the selected option or first selectable option when menu opens
|
|
554
|
+
if (this.selectedOption && this.isOptionSelectable(this.selectedOption)) {
|
|
555
|
+
this.selectedOption.focus();
|
|
561
556
|
}
|
|
562
557
|
else {
|
|
563
|
-
this.
|
|
558
|
+
const firstSelectableOption = this.getFirstSelectableOption();
|
|
559
|
+
if (firstSelectableOption) {
|
|
560
|
+
firstSelectableOption.focus();
|
|
561
|
+
}
|
|
564
562
|
}
|
|
565
563
|
this.dispatchEvent(new CustomEvent('open', { bubbles: false, composed: true }));
|
|
566
|
-
this.focus();
|
|
567
564
|
}
|
|
568
565
|
else {
|
|
569
566
|
menu.hidePopover();
|
|
570
567
|
this.dispatchEvent(new CustomEvent('close', { bubbles: false, composed: true }));
|
|
568
|
+
// Return focus to the select element when menu closes
|
|
569
|
+
this.focus();
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
/**
|
|
573
|
+
* Focus the next menu item in the dropdown, skipping disabled options
|
|
574
|
+
*/
|
|
575
|
+
focusNextMenuItem() {
|
|
576
|
+
const currentItem = this.querySelector(':focus');
|
|
577
|
+
const nextItem = currentItem ? this.getNextSelectableOption(currentItem) : this.getFirstSelectableOption();
|
|
578
|
+
if (nextItem) {
|
|
579
|
+
nextItem.focus();
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* Focus the previous menu item in the dropdown, skipping disabled options
|
|
584
|
+
*/
|
|
585
|
+
focusPreviousMenuItem() {
|
|
586
|
+
const currentItem = this.querySelector(':focus');
|
|
587
|
+
const previousItem = currentItem ? this.getPreviousSelectableOption(currentItem) : this.getLastSelectableOption();
|
|
588
|
+
if (previousItem) {
|
|
589
|
+
previousItem.focus();
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
593
|
+
* Focus the first menu item in the dropdown, skipping disabled options
|
|
594
|
+
*/
|
|
595
|
+
focusFirstMenuItem() {
|
|
596
|
+
const firstItem = this.getFirstSelectableOption();
|
|
597
|
+
if (firstItem) {
|
|
598
|
+
firstItem.focus();
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
/**
|
|
602
|
+
* Focus the last menu item in the dropdown, skipping disabled options
|
|
603
|
+
*/
|
|
604
|
+
focusLastMenuItem() {
|
|
605
|
+
const lastItem = this.getLastSelectableOption();
|
|
606
|
+
if (lastItem) {
|
|
607
|
+
lastItem.focus();
|
|
571
608
|
}
|
|
572
609
|
}
|
|
610
|
+
/**
|
|
611
|
+
* Gets the first selectable (non-disabled) option
|
|
612
|
+
*/
|
|
613
|
+
getFirstSelectableOption() {
|
|
614
|
+
const options = this.querySelectorAll('ui-option');
|
|
615
|
+
for (const option of options) {
|
|
616
|
+
if (this.isOptionSelectable(option)) {
|
|
617
|
+
return option;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
return null;
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* Gets the last selectable (non-disabled) option
|
|
624
|
+
*/
|
|
625
|
+
getLastSelectableOption() {
|
|
626
|
+
const options = Array.from(this.querySelectorAll('ui-option')).reverse();
|
|
627
|
+
for (const option of options) {
|
|
628
|
+
if (this.isOptionSelectable(option)) {
|
|
629
|
+
return option;
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
return null;
|
|
633
|
+
}
|
|
634
|
+
/**
|
|
635
|
+
* Gets the next selectable option after the current one, wrapping around if needed
|
|
636
|
+
*/
|
|
637
|
+
getNextSelectableOption(currentOption) {
|
|
638
|
+
const options = Array.from(this.querySelectorAll('ui-option'));
|
|
639
|
+
const currentIndex = options.indexOf(currentOption);
|
|
640
|
+
if (currentIndex === -1) {
|
|
641
|
+
return this.getFirstSelectableOption();
|
|
642
|
+
}
|
|
643
|
+
// Start from the next option and wrap around
|
|
644
|
+
for (let i = 1; i < options.length; i++) {
|
|
645
|
+
const nextIndex = (currentIndex + i) % options.length;
|
|
646
|
+
const option = options[nextIndex];
|
|
647
|
+
if (this.isOptionSelectable(option)) {
|
|
648
|
+
return option;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
return currentOption; // Return current if no other selectable option found
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* Gets the previous selectable option before the current one, wrapping around if needed
|
|
655
|
+
*/
|
|
656
|
+
getPreviousSelectableOption(currentOption) {
|
|
657
|
+
const options = Array.from(this.querySelectorAll('ui-option'));
|
|
658
|
+
const currentIndex = options.indexOf(currentOption);
|
|
659
|
+
if (currentIndex === -1) {
|
|
660
|
+
return this.getLastSelectableOption();
|
|
661
|
+
}
|
|
662
|
+
// Start from the previous option and wrap around
|
|
663
|
+
for (let i = 1; i < options.length; i++) {
|
|
664
|
+
const prevIndex = (currentIndex - i + options.length) % options.length;
|
|
665
|
+
const option = options[prevIndex];
|
|
666
|
+
if (this.isOptionSelectable(option)) {
|
|
667
|
+
return option;
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
return currentOption; // Return current if no other selectable option found
|
|
671
|
+
}
|
|
672
|
+
/**
|
|
673
|
+
* Checks if an option is selectable (not disabled and not hidden)
|
|
674
|
+
*/
|
|
675
|
+
isOptionSelectable(option) {
|
|
676
|
+
if (option.disabled) {
|
|
677
|
+
return false;
|
|
678
|
+
}
|
|
679
|
+
if (option.hasAttribute('disabled')) {
|
|
680
|
+
return false;
|
|
681
|
+
}
|
|
682
|
+
if (option.hidden && option.hasAttribute('hidden')) {
|
|
683
|
+
return false;
|
|
684
|
+
}
|
|
685
|
+
return true;
|
|
686
|
+
}
|
|
573
687
|
handleSelect(e) {
|
|
574
688
|
e.stopPropagation();
|
|
575
689
|
const item = e.detail.item;
|
|
690
|
+
if (this.selectedOption && this.selectedOption !== item) {
|
|
691
|
+
this.selectedOption.selected = false;
|
|
692
|
+
}
|
|
693
|
+
item.selected = true;
|
|
576
694
|
this.selectedOption = item;
|
|
577
695
|
this.#value = item.value;
|
|
578
696
|
this.#internals.setFormValue(this.value ?? null);
|
|
@@ -584,14 +702,16 @@ let UiSelect = (() => {
|
|
|
584
702
|
composed: true,
|
|
585
703
|
});
|
|
586
704
|
this.dispatchEvent(changeEvent);
|
|
587
|
-
|
|
588
|
-
}
|
|
589
|
-
handleHighlightChange(e) {
|
|
590
|
-
this.ariaActiveDescendant = e.detail.item?.id;
|
|
705
|
+
// Focus will be returned to select element by handleOpenChange when open=false
|
|
591
706
|
}
|
|
592
707
|
handleMenuClose() {
|
|
593
708
|
this.open = false;
|
|
594
|
-
|
|
709
|
+
// Focus will be returned to select element by handleOpenChange when open=false
|
|
710
|
+
}
|
|
711
|
+
handleMenuToggle(e) {
|
|
712
|
+
if (e.newState === 'closed') {
|
|
713
|
+
this.open = false;
|
|
714
|
+
}
|
|
595
715
|
}
|
|
596
716
|
renderInput() {
|
|
597
717
|
const styles = {
|
|
@@ -630,7 +750,7 @@ let UiSelect = (() => {
|
|
|
630
750
|
selector="ui-option"
|
|
631
751
|
@select="${this.handleSelect}"
|
|
632
752
|
@close="${this.handleMenuClose}"
|
|
633
|
-
@
|
|
753
|
+
@toggle="${this.handleMenuToggle}"
|
|
634
754
|
>
|
|
635
755
|
<slot @slotchange="${this.handleSlotChange}"></slot>
|
|
636
756
|
</ui-menu>`;
|
|
@@ -653,9 +773,7 @@ let UiSelect = (() => {
|
|
|
653
773
|
'disabled': this.disabled,
|
|
654
774
|
});
|
|
655
775
|
return html `${this.renderFocusRing()}
|
|
656
|
-
<div class="${classes}"
|
|
657
|
-
${this.renderInput()} ${this.renderMenu()}
|
|
658
|
-
</div> `;
|
|
776
|
+
<div class="${classes}">${this.renderInput()} ${this.renderMenu()}</div> `;
|
|
659
777
|
}
|
|
660
778
|
};
|
|
661
779
|
})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.js","sourceRoot":"","sources":["../../../../../src/md/select/internals/Select.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAkC,MAAM,KAAK,CAAA;AACtE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAGtD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,OAAO,4CAA4C,CAAA;AACnD,OAAO,uBAAuB,CAAA;AAC9B,OAAO,wBAAwB,CAAA;AAC/B,OAAO,mCAAmC,CAAA;;sBAeJ,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAA3B,QAAS,SAAQ,WAAU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rH,CAAC;QAEQ,MAAM;YACb,MAAM,OAAO,GAAG,QAAQ,CAAC;gBACvB,WAAW,EAAE,IAAI;gBACjB,MAAM,EAAE,IAAI,CAAC,IAAI;gBACjB,UAAU,EAAE,IAAI,CAAC,QAAQ;aAC1B,CAAC,CAAA;YACF,OAAO,IAAI,CAAA,GAAG,IAAI,CAAC,eAAe,EAAE;oBACpB,OAAO,2BAA2B,IAAI,CAAC,oBAAoB,IAAI,EAAE;UAC3E,IAAI,CAAC,WAAW,EAAE,IAAI,IAAI,CAAC,UAAU,EAAE;cACnC,CAAA;QACZ,CAAC;;;AA5jBH;;;;;;;GAOG;AACH","sourcesContent":["import { html, LitElement, PropertyValues, TemplateResult } from 'lit'\nimport { property, query, state } from 'lit/decorators.js'\nimport { classMap } from 'lit/directives/class-map.js'\nimport { styleMap } from 'lit/directives/style-map.js'\nimport { setDisabled } from '../../../lib/disabled.js'\nimport type UiOption from './Option.js'\nimport type { UiMenuElement } from '../../menu/ui-menu.js'\nimport { nanoid } from 'nanoid'\n\nimport '../../text-field/ui-outlined-text-field.js'\nimport '../../menu/ui-menu.js'\nimport '../../icons/ui-icon.js'\nimport '../../focus-ring/ui-focus-ring.js'\n\nexport interface UiSelectChangeEvent {\n value: string | undefined\n item: UiOption | null\n}\n\n/**\n * Material Design 3 Select component that behaves like an outlined text field with dropdown.\n *\n * @fires change - Dispatched when the selection changes. The event is non-bubbling and non-cancelable.\n * The `event.detail` object contains the `value` and `item` properties.\n * @fires open - Dispatched when the dropdown opens\n * @fires close - Dispatched when the dropdown closes\n */\nexport default class UiSelect extends LitElement {\n static readonly formAssociated = true\n #internals = this.attachInternals()\n\n /**\n * The value has a private member so that we can set the value without triggering\n * the side effects.\n */\n #value: string | undefined\n\n /**\n * The currently selected value. Corresponds to the `value` attribute of the selected `ui-option`.\n * When set programmatically, it will update the selected option if a matching option exists.\n *\n * @attribute\n * @example\n * ```html\n * <ui-select value=\"apple\">\n * <ui-option value=\"apple\">Apple</ui-option>\n * <ui-option value=\"banana\">Banana</ui-option>\n * </ui-select>\n * ```\n */\n get value(): string | undefined {\n return this.#value\n }\n\n @property({ type: String })\n set value(newValue: string | undefined) {\n const oldValue = this.#value\n if (newValue === oldValue) return\n this.#value = newValue\n this.requestUpdate()\n }\n\n /**\n * The name attribute for form submission. This value will be used as the key\n * when the form is submitted.\n *\n * @attribute\n * @example\n * ```html\n * <ui-select name=\"country\" value=\"us\">\n * <ui-option value=\"us\">United States</ui-option>\n * </ui-select>\n * ```\n */\n @property({ type: String }) accessor name: string | undefined\n\n /**\n * The label text displayed in the select field. Provides accessible labeling\n * and is shown as the floating label in the outlined text field.\n *\n * @attribute\n * @example\n * ```html\n * <ui-select label=\"Select a country\">\n * <ui-option value=\"us\">United States</ui-option>\n * </ui-select>\n * ```\n */\n @property({ type: String }) accessor label: string | undefined\n\n /**\n * Whether the select is required for form validation. When true, the select\n * must have a value selected for the form to be valid.\n *\n * @attribute\n * @example\n * ```html\n * <ui-select required label=\"Required field\">\n * <ui-option value=\"option1\">Option 1</ui-option>\n * </ui-select>\n * ```\n */\n @property({ type: Boolean }) accessor required = false\n\n /**\n * Whether the select is in an invalid state. This is typically set automatically\n * during validation, but can be set manually to indicate validation errors.\n *\n * @attribute\n * @example\n * ```html\n * <ui-select invalid invalidText=\"Please select a valid option\">\n * <ui-option value=\"option1\">Option 1</ui-option>\n * </ui-select>\n * ```\n */\n @property({ type: Boolean }) accessor invalid: boolean | undefined\n\n /**\n * The error message to display when the select is invalid. This text is shown\n * below the select field when `invalid` is true.\n *\n * @attribute\n * @example\n * ```html\n * <ui-select invalid invalidText=\"This field is required\">\n * <ui-option value=\"option1\">Option 1</ui-option>\n * </ui-select>\n * ```\n */\n @property({ type: String }) accessor invalidText: string | undefined\n\n /**\n * @attribute\n */\n @property({ type: String }) accessor supportingText: string | undefined\n\n /**\n * Whether the select is disabled. When disabled, the select cannot be interacted\n * with and will not receive focus or respond to user input.\n *\n * @default false\n * @attribute\n * @example\n * ```html\n * <ui-select disabled label=\"Disabled select\">\n * <ui-option value=\"option1\">Option 1</ui-option>\n * </ui-select>\n * ```\n */\n @property({ type: Boolean, reflect: true }) accessor disabled = false\n\n /**\n * Whether the dropdown menu is currently open. This property reflects the\n * current state of the dropdown and can be set programmatically to open/close it.\n *\n * @default false\n * @example\n * ```javascript\n * // Open the dropdown programmatically\n * selectElement.open = true;\n *\n * // Close the dropdown\n * selectElement.open = false;\n * ```\n */\n @property({ type: Boolean, reflect: true }) accessor open = false\n\n @state() accessor selectedOption: UiOption | null = null\n @state() accessor ariaActiveDescendant: string | undefined\n @query('.menu') accessor menu!: UiMenuElement\n\n /**\n * Returns the currently selected option element. This provides access to the\n * full `ui-option` element, not just its value.\n *\n * @readonly\n * @example\n * ```javascript\n * const select = document.querySelector('ui-select');\n * const selectedItem = select.selectedItem;\n * if (selectedItem) {\n * console.log('Selected option:', selectedItem.textContent);\n * }\n * ```\n */\n get selectedItem(): UiOption | null {\n return this.selectedOption\n }\n\n /**\n * Returns the text content that should be displayed in the select field.\n * This is the rendered value of the currently selected option.\n *\n * @readonly\n * @example\n * ```javascript\n * const select = document.querySelector('ui-select');\n * console.log('Display text:', select.renderValue);\n * ```\n */\n get renderValue(): string {\n const item = this.selectedOption\n return item ? item.renderValue : ''\n }\n\n /**\n * Returns the form element that contains this select, if any.\n * Part of the form-associated custom element API.\n *\n * @readonly\n */\n get form(): HTMLFormElement | null {\n return this.#internals.form\n }\n\n /**\n * Returns the validity state of the select element.\n * Part of the form-associated custom element API.\n *\n * @readonly\n */\n get validity(): ValidityState {\n return this.#internals.validity\n }\n\n /**\n * Returns the validation message for the select element.\n * Part of the form-associated custom element API.\n *\n * @readonly\n */\n get validationMessage(): string {\n return this.#internals.validationMessage\n }\n\n /**\n * Returns whether the select element will be validated when the form is submitted.\n * Part of the form-associated custom element API.\n *\n * @readonly\n */\n get willValidate(): boolean {\n return this.#internals.willValidate\n }\n\n /**\n * Checks the validity of the select element and returns true if valid.\n * Part of the form-associated custom element API.\n *\n * @returns {boolean} True if the element is valid, false otherwise\n * @example\n * ```javascript\n * const select = document.querySelector('ui-select');\n * if (!select.checkValidity()) {\n * console.log('Select is invalid:', select.validationMessage);\n * }\n * ```\n */\n checkValidity(): boolean {\n return this.#internals.checkValidity()\n }\n\n constructor() {\n super()\n this.addEventListener('click', this.handleClick.bind(this))\n this.addEventListener('blur', this.handleBlur.bind(this))\n this.addEventListener('keydown', this.handleKeydown.bind(this))\n }\n\n override connectedCallback(): void {\n super.connectedCallback()\n this.setAttribute('role', 'combobox')\n this.setAttribute('aria-haspopup', 'listbox')\n this.setAttribute('aria-controls', 'menu')\n if (!this.disabled) {\n this.setAttribute('tabindex', '0')\n }\n if (!this.id) {\n this.id = `select-${nanoid(6)}`\n }\n }\n\n /**\n * Resets the select to its initial state. Called automatically when the parent\n * form is reset. Part of the form-associated custom element API.\n *\n * @example\n * ```javascript\n * const select = document.querySelector('ui-select');\n * select.formResetCallback(); // Clears the selection\n * ```\n */\n formResetCallback(): void {\n this.value = undefined\n }\n\n /**\n * Restores the select's state from saved form data. Called automatically when\n * the browser restores form state. Part of the form-associated custom element API.\n *\n * @param {string | null} state - The saved state to restore\n */\n formStateRestoreCallback(state: string | null): void {\n this.value = state ?? undefined\n }\n\n /**\n * Validates the select element and updates its validity state. This is called\n * automatically during property changes, but can be called manually to trigger validation.\n *\n * @example\n * ```javascript\n * const select = document.querySelector('ui-select');\n * select.validate();\n * if (select.invalid) {\n * console.log('Validation failed:', select.invalidText);\n * }\n * ```\n */\n validate(): void {\n let message = ''\n if (this.required && !this.value) {\n message = 'Please select an item.'\n this.#internals.setValidity({ valueMissing: true }, message)\n } else {\n this.#internals.setValidity({})\n }\n this.invalid = !this.#internals.validity.valid\n this.invalidText = message\n }\n\n protected override willUpdate(changedProperties: PropertyValues<this>): void {\n super.willUpdate(changedProperties)\n if (changedProperties.has('disabled')) {\n setDisabled(this, this.disabled)\n }\n if (changedProperties.has('open')) {\n this.handleOpenChange()\n }\n if (changedProperties.has('value')) {\n this.setCurrentOption()\n this.#internals.setFormValue(this.value ?? null)\n this.validate()\n }\n if (changedProperties.has('label')) {\n if (this.label) {\n this.setAttribute('aria-label', this.label)\n } else {\n this.removeAttribute('aria-label')\n }\n }\n }\n\n protected override firstUpdated(cp: PropertyValues): void {\n super.firstUpdated(cp)\n this.updateComplete.then(() => {\n this.setCurrentOption()\n this.#internals.setFormValue(this.value ?? null)\n // We need to update here as event with `value` and `selectedOption`\n // already set, the `renderValue` might have incorrect value\n // due to the DOM update.\n this.requestUpdate()\n })\n }\n\n protected setCurrentOption(): void {\n const options = this.querySelectorAll<UiOption>('ui-option')\n if (this.value) {\n this.selectedOption = Array.from(options).find((option) => option.value === this.value) || null\n } else {\n const selected = Array.from(options).find((option) => option.selected)\n if (selected) {\n this.selectedOption = selected\n this.#value = selected.value\n } else {\n this.selectedOption = null\n }\n }\n }\n\n protected handleKeydown(e: KeyboardEvent): void {\n if (this.disabled || e.defaultPrevented) return\n if (this.open) {\n switch (e.key) {\n case 'Tab': {\n // If menu is open and Tab is pressed, close it and allow normal tab navigation\n if (this.open) {\n this.open = false\n }\n break\n }\n case 'Escape': {\n if (this.open) {\n e.preventDefault()\n this.open = false\n this.focus() // Return focus to the select element\n }\n break\n }\n case 'ArrowDown':\n e.preventDefault()\n this.menu.highlightNext()\n return\n case 'ArrowUp':\n e.preventDefault()\n this.menu.highlightPrevious()\n return\n case 'Home':\n e.preventDefault()\n this.menu.highlightFirst()\n return\n case 'End':\n e.preventDefault()\n this.menu.highlightLast()\n return\n case 'Enter':\n case ' ':\n if (this.menu.highlightListItem) {\n e.preventDefault()\n this.menu.notifySelect(this.menu.highlightListItem as UiOption)\n }\n return\n }\n } else {\n switch (e.key) {\n case 'Enter':\n case ' ': {\n if (!this.open) {\n e.preventDefault()\n this.open = true\n }\n break\n }\n case 'ArrowDown':\n case 'ArrowUp': {\n if (!this.open) {\n e.preventDefault()\n this.open = true\n }\n // If menu is open, let the menu handle arrow keys\n break\n }\n }\n }\n }\n\n protected handleBlur(e: FocusEvent): void {\n if (this.disabled) return\n\n // Check if focus is moving to the menu or one of its children\n const relatedTarget = e.relatedTarget as HTMLElement\n\n if (relatedTarget && this.contains(relatedTarget)) {\n // Focus is moving to the menu, keep it open\n return\n }\n\n // Close the menu when focus leaves the component\n this.open = false\n }\n\n protected handleClick(e: Event): void {\n if (this.disabled || e.defaultPrevented) return\n e.preventDefault()\n e.stopPropagation()\n if (this.open && e.target === this) {\n // If the select is already open and clicked again, close it\n this.open = false\n return\n }\n this.open = true\n }\n\n protected async handleOpenChange(): Promise<void> {\n const menu = this.menu\n if (!menu) {\n // The status can be set before the menu is rendered\n return\n }\n this.setAttribute('aria-expanded', String(this.open))\n if (this.open) {\n menu.showPopover()\n // menu.focus()\n if (this.selectedOption) {\n this.menu.highlightItem(this.selectedOption)\n } else {\n this.menu.highlightFirst()\n }\n this.dispatchEvent(new CustomEvent('open', { bubbles: false, composed: true }))\n this.focus()\n } else {\n menu.hidePopover()\n this.dispatchEvent(new CustomEvent('close', { bubbles: false, composed: true }))\n }\n }\n\n handleSelect(e: CustomEvent<{ item: UiOption }>): void {\n e.stopPropagation()\n const item = e.detail.item\n this.selectedOption = item\n this.#value = item.value\n this.#internals.setFormValue(this.value ?? null)\n this.open = false\n\n // Dispatch change event\n const changeEvent = new CustomEvent<UiSelectChangeEvent>('change', {\n detail: { value: this.value, item: item },\n bubbles: false,\n composed: true,\n })\n this.dispatchEvent(changeEvent)\n this.focus()\n }\n\n handleHighlightChange(e: CustomEvent<{ item: UiOption | null }>): void {\n this.ariaActiveDescendant = e.detail.item?.id\n }\n\n handleMenuClose(): void {\n this.open = false\n this.focus()\n }\n\n protected renderInput(): TemplateResult {\n const styles = {\n 'anchor-name': `--${this.id}`,\n }\n return html`<ui-outlined-text-field\n .name=${this.name}\n .label=${this.label}\n .value=${this.renderValue}\n .disabled=${this.disabled}\n .required=${this.required}\n readonly\n tabindex=\"-1\"\n .inert=${true}\n aria-hidden=\"true\"\n .invalid=${this.invalid}\n .invalidText=${this.invalidText || ''}\n .supportingText=${this.supportingText || ''}\n class=\"input\"\n style=${styleMap(styles)}\n part=\"input\"\n >\n <ui-icon part=\"icon\" slot=\"suffix\">arrow_drop_down</ui-icon>\n </ui-outlined-text-field>`\n }\n\n protected renderMenu(): TemplateResult {\n const styles = {\n 'position-anchor': `--${this.id}`,\n }\n return html`<ui-menu\n id=\"menu\"\n class=\"menu\"\n part=\"menu\"\n style=${styleMap(styles)}\n popover=\"auto\"\n selector=\"ui-option\"\n @select=\"${this.handleSelect}\"\n @close=\"${this.handleMenuClose}\"\n @highlightchange=\"${this.handleHighlightChange}\"\n >\n <slot @slotchange=\"${this.handleSlotChange}\"></slot>\n </ui-menu>`\n }\n\n protected async handleSlotChange(): Promise<void> {\n // When options change, re-evaluate the current selection\n // only if we don't have an explicit value set\n if (!this.value) {\n this.setCurrentOption()\n this.requestUpdate()\n }\n }\n\n protected renderFocusRing(): TemplateResult {\n return html`<ui-focus-ring part=\"focus-ring\" class=\"focus-ring\" .control=\"${this as HTMLElement}\"></ui-focus-ring>`\n }\n\n override render(): TemplateResult {\n const classes = classMap({\n 'ui-select': true,\n 'open': this.open,\n 'disabled': this.disabled,\n })\n return html`${this.renderFocusRing()}\n <div class=\"${classes}\" aria-activedescendant=${this.ariaActiveDescendant || ''}>\n ${this.renderInput()} ${this.renderMenu()}\n </div> `\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Select.js","sourceRoot":"","sources":["../../../../../src/md/select/internals/Select.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAkC,MAAM,KAAK,CAAA;AAC1D,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0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,CAAC,gBAAgB;eACjC,CAAA;QACb,CAAC;QAES,KAAK,CAAC,gBAAgB;YAC9B,yDAAyD;YACzD,8CAA8C;YAC9C,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;gBAChB,IAAI,CAAC,gBAAgB,EAAE,CAAA;gBACvB,IAAI,CAAC,aAAa,EAAE,CAAA;YACtB,CAAC;QACH,CAAC;QAES,eAAe;YACvB,OAAO,IAAI,CAAA,iEAAiE,IAAmB,oBAAoB,CAAA;QACrH,CAAC;QAEQ,MAAM;YACb,MAAM,OAAO,GAAG,QAAQ,CAAC;gBACvB,WAAW,EAAE,IAAI;gBACjB,MAAM,EAAE,IAAI,CAAC,IAAI;gBACjB,UAAU,EAAE,IAAI,CAAC,QAAQ;aAC1B,CAAC,CAAA;YACF,OAAO,IAAI,CAAA,GAAG,IAAI,CAAC,eAAe,EAAE;oBACpB,OAAO,KAAK,IAAI,CAAC,WAAW,EAAE,IAAI,IAAI,CAAC,UAAU,EAAE,SAAS,CAAA;QAC9E,CAAC;;;AAxsBH;;;;;;;GAOG;AACH","sourcesContent":["import { html, PropertyValues, TemplateResult } from 'lit'\nimport { property, query, state } from 'lit/decorators.js'\nimport { classMap } from 'lit/directives/class-map.js'\nimport { styleMap } from 'lit/directives/style-map.js'\nimport { setDisabled } from '../../../lib/disabled.js'\nimport { UiElement } from '../../UiElement.js'\nimport type UiOption from './Option.js'\nimport type { UiMenuElement } from '../../menu/ui-menu.js'\nimport { nanoid } from 'nanoid'\n\nimport '../../text-field/ui-outlined-text-field.js'\nimport '../../menu/ui-menu.js'\nimport '../../icons/ui-icon.js'\nimport '../../focus-ring/ui-focus-ring.js'\n\nexport interface UiSelectChangeEvent {\n value: string | undefined\n item: UiOption | null\n}\n\n/**\n * Material Design 3 Select component that behaves like an outlined text field with dropdown.\n *\n * @fires change - Dispatched when the selection changes. The event is non-bubbling and non-cancelable.\n * The `event.detail` object contains the `value` and `item` properties.\n * @fires open - Dispatched when the dropdown opens\n * @fires close - Dispatched when the dropdown closes\n */\nexport default class UiSelect extends UiElement {\n static readonly formAssociated = true\n #internals = this.attachInternals()\n\n /**\n * The value has a private member so that we can set the value without triggering\n * the side effects.\n */\n #value: string | undefined\n\n /**\n * The currently selected value. Corresponds to the `value` attribute of the selected `ui-option`.\n * When set programmatically, it will update the selected option if a matching option exists.\n *\n * @attribute\n * @example\n * ```html\n * <ui-select value=\"apple\">\n * <ui-option value=\"apple\">Apple</ui-option>\n * <ui-option value=\"banana\">Banana</ui-option>\n * </ui-select>\n * ```\n */\n get value(): string | undefined {\n return this.#value\n }\n\n @property({ type: String })\n set value(newValue: string | undefined) {\n const oldValue = this.#value\n if (newValue === oldValue) return\n this.#value = newValue\n this.requestUpdate()\n }\n\n /**\n * The name attribute for form submission. This value will be used as the key\n * when the form is submitted.\n *\n * @attribute\n * @example\n * ```html\n * <ui-select name=\"country\" value=\"us\">\n * <ui-option value=\"us\">United States</ui-option>\n * </ui-select>\n * ```\n */\n @property({ type: String }) accessor name: string | undefined\n\n /**\n * The label text displayed in the select field. Provides accessible labeling\n * and is shown as the floating label in the outlined text field.\n *\n * @attribute\n * @example\n * ```html\n * <ui-select label=\"Select a country\">\n * <ui-option value=\"us\">United States</ui-option>\n * </ui-select>\n * ```\n */\n @property({ type: String }) accessor label: string | undefined\n\n /**\n * Whether the select is required for form validation. When true, the select\n * must have a value selected for the form to be valid.\n *\n * @attribute\n * @example\n * ```html\n * <ui-select required label=\"Required field\">\n * <ui-option value=\"option1\">Option 1</ui-option>\n * </ui-select>\n * ```\n */\n @property({ type: Boolean }) accessor required = false\n\n /**\n * Whether the select is in an invalid state. This is typically set automatically\n * during validation, but can be set manually to indicate validation errors.\n *\n * @attribute\n * @example\n * ```html\n * <ui-select invalid invalidText=\"Please select a valid option\">\n * <ui-option value=\"option1\">Option 1</ui-option>\n * </ui-select>\n * ```\n */\n @property({ type: Boolean }) accessor invalid: boolean | undefined\n\n /**\n * The error message to display when the select is invalid. This text is shown\n * below the select field when `invalid` is true.\n *\n * @attribute\n * @example\n * ```html\n * <ui-select invalid invalidText=\"This field is required\">\n * <ui-option value=\"option1\">Option 1</ui-option>\n * </ui-select>\n * ```\n */\n @property({ type: String }) accessor invalidText: string | undefined\n\n /**\n * @attribute\n */\n @property({ type: String }) accessor supportingText: string | undefined\n\n /**\n * Whether the select is disabled. When disabled, the select cannot be interacted\n * with and will not receive focus or respond to user input.\n *\n * @default false\n * @attribute\n * @example\n * ```html\n * <ui-select disabled label=\"Disabled select\">\n * <ui-option value=\"option1\">Option 1</ui-option>\n * </ui-select>\n * ```\n */\n @property({ type: Boolean, reflect: true }) accessor disabled = false\n\n /**\n * Whether the dropdown menu is currently open. This property reflects the\n * current state of the dropdown and can be set programmatically to open/close it.\n *\n * @default false\n * @example\n * ```javascript\n * // Open the dropdown programmatically\n * selectElement.open = true;\n *\n * // Close the dropdown\n * selectElement.open = false;\n * ```\n */\n @property({ type: Boolean, reflect: true }) accessor open = false\n\n @state() accessor selectedOption: UiOption | null = null\n\n @query('.menu') accessor menu!: UiMenuElement\n\n /**\n * Returns the currently selected option element. This provides access to the\n * full `ui-option` element, not just its value.\n *\n * @readonly\n * @example\n * ```javascript\n * const select = document.querySelector('ui-select');\n * const selectedItem = select.selectedItem;\n * if (selectedItem) {\n * console.log('Selected option:', selectedItem.textContent);\n * }\n * ```\n */\n get selectedItem(): UiOption | null {\n return this.selectedOption\n }\n\n /**\n * Returns the text content that should be displayed in the select field.\n * This is the rendered value of the currently selected option.\n *\n * @readonly\n * @example\n * ```javascript\n * const select = document.querySelector('ui-select');\n * console.log('Display text:', select.renderValue);\n * ```\n */\n get renderValue(): string {\n const item = this.selectedOption\n return item ? item.renderValue : ''\n }\n\n /**\n * Returns the form element that contains this select, if any.\n * Part of the form-associated custom element API.\n *\n * @readonly\n */\n get form(): HTMLFormElement | null {\n return this.#internals.form\n }\n\n /**\n * Returns the validity state of the select element.\n * Part of the form-associated custom element API.\n *\n * @readonly\n */\n get validity(): ValidityState {\n return this.#internals.validity\n }\n\n /**\n * Returns the validation message for the select element.\n * Part of the form-associated custom element API.\n *\n * @readonly\n */\n get validationMessage(): string {\n return this.#internals.validationMessage\n }\n\n /**\n * Returns whether the select element will be validated when the form is submitted.\n * Part of the form-associated custom element API.\n *\n * @readonly\n */\n get willValidate(): boolean {\n return this.#internals.willValidate\n }\n\n /**\n * Checks the validity of the select element and returns true if valid.\n * Part of the form-associated custom element API.\n *\n * @returns {boolean} True if the element is valid, false otherwise\n * @example\n * ```javascript\n * const select = document.querySelector('ui-select');\n * if (!select.checkValidity()) {\n * console.log('Select is invalid:', select.validationMessage);\n * }\n * ```\n */\n checkValidity(): boolean {\n return this.#internals.checkValidity()\n }\n\n constructor() {\n super()\n this.addEventListener('click', this.handleClick.bind(this))\n this.addEventListener('blur', this.handleBlur.bind(this))\n this.addEventListener('keydown', this.handleKeydown.bind(this))\n }\n\n override connectedCallback(): void {\n super.connectedCallback()\n this.setAttribute('role', 'combobox')\n this.setAttribute('aria-haspopup', 'listbox')\n this.setAttribute('aria-controls', 'menu')\n if (!this.disabled) {\n this.setAttribute('tabindex', '0')\n }\n if (!this.id) {\n this.id = `select-${nanoid(6)}`\n }\n }\n\n /**\n * Resets the select to its initial state. Called automatically when the parent\n * form is reset. Part of the form-associated custom element API.\n *\n * @example\n * ```javascript\n * const select = document.querySelector('ui-select');\n * select.formResetCallback(); // Clears the selection\n * ```\n */\n formResetCallback(): void {\n this.value = undefined\n }\n\n /**\n * Restores the select's state from saved form data. Called automatically when\n * the browser restores form state. Part of the form-associated custom element API.\n *\n * @param {string | null} state - The saved state to restore\n */\n formStateRestoreCallback(state: string | null): void {\n this.value = state ?? undefined\n }\n\n /**\n * Validates the select element and updates its validity state. This is called\n * automatically during property changes, but can be called manually to trigger validation.\n *\n * @example\n * ```javascript\n * const select = document.querySelector('ui-select');\n * select.validate();\n * if (select.invalid) {\n * console.log('Validation failed:', select.invalidText);\n * }\n * ```\n */\n validate(): void {\n let message = ''\n if (this.required && !this.value) {\n message = 'Please select an item.'\n this.#internals.setValidity({ valueMissing: true }, message)\n } else {\n this.#internals.setValidity({})\n }\n this.invalid = !this.#internals.validity.valid\n this.invalidText = message\n }\n\n protected override willUpdate(changedProperties: PropertyValues<this>): void {\n super.willUpdate(changedProperties)\n if (changedProperties.has('disabled')) {\n setDisabled(this, this.disabled)\n }\n if (changedProperties.has('open')) {\n this.handleOpenChange()\n }\n if (changedProperties.has('value')) {\n this.setCurrentOption()\n this.#internals.setFormValue(this.value ?? null)\n this.validate()\n }\n if (changedProperties.has('label')) {\n if (this.label) {\n this.setAttribute('aria-label', this.label)\n } else {\n this.removeAttribute('aria-label')\n }\n }\n }\n\n protected override firstUpdated(cp: PropertyValues): void {\n super.firstUpdated(cp)\n this.updateComplete.then(() => {\n this.setCurrentOption()\n this.#internals.setFormValue(this.value ?? null)\n // We need to update here as event with `value` and `selectedOption`\n // already set, the `renderValue` might have incorrect value\n // due to the DOM update.\n this.requestUpdate()\n })\n }\n\n protected setCurrentOption(): void {\n const options = this.querySelectorAll<UiOption>('ui-option')\n if (this.value) {\n this.selectedOption = Array.from(options).find((option) => option.value === this.value) || null\n } else {\n const selected = Array.from(options).find((option) => option.selected)\n if (selected) {\n this.selectedOption = selected\n this.#value = selected.value\n } else {\n this.selectedOption = null\n }\n }\n }\n\n protected handleKeydown(e: KeyboardEvent): void {\n if (this.disabled || e.defaultPrevented) return\n if (this.open) {\n switch (e.key) {\n case 'Tab': {\n // If menu is open and Tab is pressed, close it and allow normal tab navigation\n if (this.open) {\n this.open = false\n }\n break\n }\n case 'Escape': {\n if (this.open) {\n e.preventDefault()\n this.open = false\n this.focus() // Return focus to the select element\n }\n break\n }\n case 'ArrowDown':\n e.preventDefault()\n this.focusNextMenuItem()\n return\n case 'ArrowUp':\n e.preventDefault()\n this.focusPreviousMenuItem()\n return\n case 'Home':\n e.preventDefault()\n this.focusFirstMenuItem()\n return\n case 'End':\n e.preventDefault()\n this.focusLastMenuItem()\n return\n case 'Enter':\n case ' ': {\n const currentItem = this.querySelector<UiOption>(':focus')\n if (currentItem && this.isOptionSelectable(currentItem)) {\n e.preventDefault()\n this.menu.notifySelect(currentItem)\n }\n return\n }\n }\n } else {\n switch (e.key) {\n case 'Enter':\n case ' ': {\n if (!this.open) {\n e.preventDefault()\n this.open = true\n }\n break\n }\n case 'ArrowDown':\n case 'ArrowUp': {\n if (!this.open) {\n e.preventDefault()\n this.open = true\n }\n // If menu is open, let the menu handle arrow keys\n break\n }\n }\n }\n }\n\n protected handleBlur(e: FocusEvent): void {\n if (this.disabled) return\n\n // Check if focus is moving to the menu or one of its children\n const relatedTarget = e.relatedTarget as HTMLElement\n\n if (relatedTarget && this.contains(relatedTarget)) {\n // Focus is moving to the menu, keep it open\n return\n }\n\n // Close the menu when focus leaves the component\n this.open = false\n }\n\n override handleClick(e: Event): void {\n if (this.disabled || e.defaultPrevented) return\n e.preventDefault()\n e.stopPropagation()\n if (this.open && e.target === this) {\n // If the select is already open and clicked again, close it\n this.open = false\n return\n }\n this.open = true\n }\n\n protected async handleOpenChange(): Promise<void> {\n const menu = this.menu\n if (!menu) {\n // The status can be set before the menu is rendered\n return\n }\n this.setAttribute('aria-expanded', String(this.open))\n if (this.open) {\n menu.showPopover()\n // Focus on the selected option or first selectable option when menu opens\n if (this.selectedOption && this.isOptionSelectable(this.selectedOption)) {\n this.selectedOption.focus()\n } else {\n const firstSelectableOption = this.getFirstSelectableOption()\n if (firstSelectableOption) {\n firstSelectableOption.focus()\n }\n }\n this.dispatchEvent(new CustomEvent('open', { bubbles: false, composed: true }))\n } else {\n menu.hidePopover()\n this.dispatchEvent(new CustomEvent('close', { bubbles: false, composed: true }))\n // Return focus to the select element when menu closes\n this.focus()\n }\n }\n\n /**\n * Focus the next menu item in the dropdown, skipping disabled options\n */\n focusNextMenuItem(): void {\n const currentItem = this.querySelector<UiOption>(':focus')\n const nextItem = currentItem ? this.getNextSelectableOption(currentItem) : this.getFirstSelectableOption()\n if (nextItem) {\n nextItem.focus()\n }\n }\n\n /**\n * Focus the previous menu item in the dropdown, skipping disabled options\n */\n focusPreviousMenuItem(): void {\n const currentItem = this.querySelector<UiOption>(':focus')\n const previousItem = currentItem ? this.getPreviousSelectableOption(currentItem) : this.getLastSelectableOption()\n if (previousItem) {\n previousItem.focus()\n }\n }\n\n /**\n * Focus the first menu item in the dropdown, skipping disabled options\n */\n focusFirstMenuItem(): void {\n const firstItem = this.getFirstSelectableOption()\n if (firstItem) {\n firstItem.focus()\n }\n }\n\n /**\n * Focus the last menu item in the dropdown, skipping disabled options\n */\n focusLastMenuItem(): void {\n const lastItem = this.getLastSelectableOption()\n if (lastItem) {\n lastItem.focus()\n }\n }\n\n /**\n * Gets the first selectable (non-disabled) option\n */\n getFirstSelectableOption(): UiOption | null {\n const options = this.querySelectorAll<UiOption>('ui-option')\n for (const option of options) {\n if (this.isOptionSelectable(option)) {\n return option\n }\n }\n return null\n }\n\n /**\n * Gets the last selectable (non-disabled) option\n */\n getLastSelectableOption(): UiOption | null {\n const options = Array.from(this.querySelectorAll<UiOption>('ui-option')).reverse()\n for (const option of options) {\n if (this.isOptionSelectable(option)) {\n return option\n }\n }\n return null\n }\n\n /**\n * Gets the next selectable option after the current one, wrapping around if needed\n */\n protected getNextSelectableOption(currentOption: UiOption): UiOption | null {\n const options = Array.from(this.querySelectorAll<UiOption>('ui-option'))\n const currentIndex = options.indexOf(currentOption)\n\n if (currentIndex === -1) {\n return this.getFirstSelectableOption()\n }\n\n // Start from the next option and wrap around\n for (let i = 1; i < options.length; i++) {\n const nextIndex = (currentIndex + i) % options.length\n const option = options[nextIndex]\n if (this.isOptionSelectable(option)) {\n return option\n }\n }\n\n return currentOption // Return current if no other selectable option found\n }\n\n /**\n * Gets the previous selectable option before the current one, wrapping around if needed\n */\n protected getPreviousSelectableOption(currentOption: UiOption): UiOption | null {\n const options = Array.from(this.querySelectorAll<UiOption>('ui-option'))\n const currentIndex = options.indexOf(currentOption)\n\n if (currentIndex === -1) {\n return this.getLastSelectableOption()\n }\n\n // Start from the previous option and wrap around\n for (let i = 1; i < options.length; i++) {\n const prevIndex = (currentIndex - i + options.length) % options.length\n const option = options[prevIndex]\n if (this.isOptionSelectable(option)) {\n return option\n }\n }\n\n return currentOption // Return current if no other selectable option found\n }\n\n /**\n * Checks if an option is selectable (not disabled and not hidden)\n */\n protected isOptionSelectable(option: UiOption): boolean {\n if (option.disabled) {\n return false\n }\n if (option.hasAttribute('disabled')) {\n return false\n }\n if (option.hidden && option.hasAttribute('hidden')) {\n return false\n }\n return true\n }\n\n handleSelect(e: CustomEvent<{ item: UiOption }>): void {\n e.stopPropagation()\n const item = e.detail.item\n if (this.selectedOption && this.selectedOption !== item) {\n this.selectedOption.selected = false\n }\n item.selected = true\n this.selectedOption = item\n this.#value = item.value\n this.#internals.setFormValue(this.value ?? null)\n this.open = false\n\n // Dispatch change event\n const changeEvent = new CustomEvent<UiSelectChangeEvent>('change', {\n detail: { value: this.value, item: item },\n bubbles: false,\n composed: true,\n })\n this.dispatchEvent(changeEvent)\n // Focus will be returned to select element by handleOpenChange when open=false\n }\n\n handleMenuClose(): void {\n this.open = false\n // Focus will be returned to select element by handleOpenChange when open=false\n }\n\n handleMenuToggle(e: ToggleEvent): void {\n if (e.newState === 'closed') {\n this.open = false\n }\n }\n\n protected renderInput(): TemplateResult {\n const styles = {\n 'anchor-name': `--${this.id}`,\n }\n return html`<ui-outlined-text-field\n .name=${this.name}\n .label=${this.label}\n .value=${this.renderValue}\n .disabled=${this.disabled}\n .required=${this.required}\n readonly\n tabindex=\"-1\"\n .inert=${true}\n aria-hidden=\"true\"\n .invalid=${this.invalid}\n .invalidText=${this.invalidText || ''}\n .supportingText=${this.supportingText || ''}\n class=\"input\"\n style=${styleMap(styles)}\n part=\"input\"\n >\n <ui-icon part=\"icon\" slot=\"suffix\">arrow_drop_down</ui-icon>\n </ui-outlined-text-field>`\n }\n\n protected renderMenu(): TemplateResult {\n const styles = {\n 'position-anchor': `--${this.id}`,\n }\n return html`<ui-menu\n id=\"menu\"\n class=\"menu\"\n part=\"menu\"\n style=${styleMap(styles)}\n popover=\"auto\"\n selector=\"ui-option\"\n @select=\"${this.handleSelect}\"\n @close=\"${this.handleMenuClose}\"\n @toggle=\"${this.handleMenuToggle}\"\n >\n <slot @slotchange=\"${this.handleSlotChange}\"></slot>\n </ui-menu>`\n }\n\n protected async handleSlotChange(): Promise<void> {\n // When options change, re-evaluate the current selection\n // only if we don't have an explicit value set\n if (!this.value) {\n this.setCurrentOption()\n this.requestUpdate()\n }\n }\n\n protected renderFocusRing(): TemplateResult {\n return html`<ui-focus-ring part=\"focus-ring\" class=\"focus-ring\" .control=\"${this as HTMLElement}\"></ui-focus-ring>`\n }\n\n override render(): TemplateResult {\n const classes = classMap({\n 'ui-select': true,\n 'open': this.open,\n 'disabled': this.disabled,\n })\n return html`${this.renderFocusRing()}\n <div class=\"${classes}\">${this.renderInput()} ${this.renderMenu()}</div> `\n }\n}\n"]}
|