@vonage/vivid 4.13.0 → 4.14.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/custom-elements.json +4033 -2662
- package/elevation/index.cjs +1 -1
- package/elevation/index.js +1 -1
- package/index.cjs +70 -136
- package/index.d.ts +0 -1
- package/index.js +60 -62
- package/lib/accordion/accordion.d.ts +2 -2
- package/lib/accordion/accordion.template.d.ts +1 -2
- package/lib/accordion/definition.d.ts +1 -1
- package/lib/accordion-item/accordion-item.d.ts +2 -2
- package/lib/accordion-item/accordion-item.template.d.ts +2 -3
- package/lib/accordion-item/definition.d.ts +1 -1
- package/lib/action-group/action-group.d.ts +2 -2
- package/lib/action-group/action-group.template.d.ts +1 -3
- package/lib/action-group/definition.d.ts +1 -1
- package/lib/alert/alert.d.ts +2 -2
- package/lib/alert/alert.template.d.ts +2 -3
- package/lib/alert/definition.d.ts +1 -1
- package/lib/audio-player/audio-player.d.ts +2 -2
- package/lib/audio-player/audio-player.template.d.ts +2 -3
- package/lib/audio-player/definition.d.ts +1 -3
- package/lib/avatar/avatar.d.ts +2 -2
- package/lib/avatar/avatar.template.d.ts +2 -3
- package/lib/avatar/definition.d.ts +1 -1
- package/lib/badge/badge.d.ts +2 -2
- package/lib/badge/badge.template.d.ts +2 -3
- package/lib/badge/definition.d.ts +1 -3
- package/lib/banner/banner.d.ts +2 -2
- package/lib/banner/banner.template.d.ts +2 -3
- package/lib/banner/definition.d.ts +1 -1
- package/lib/breadcrumb/breadcrumb.d.ts +2 -2
- package/lib/breadcrumb/breadcrumb.template.d.ts +3 -4
- package/lib/breadcrumb/definition.d.ts +1 -1
- package/lib/breadcrumb-item/breadcrumb-item.d.ts +2 -2
- package/lib/breadcrumb-item/breadcrumb-item.template.d.ts +2 -3
- package/lib/breadcrumb-item/definition.d.ts +1 -1
- package/lib/button/button.d.ts +2 -2
- package/lib/button/button.template.d.ts +2 -4
- package/lib/button/definition.d.ts +1 -1
- package/lib/calendar/calendar.d.ts +2 -2
- package/lib/calendar/calendar.template.d.ts +1 -3
- package/lib/calendar/definition.d.ts +1 -1
- package/lib/calendar-event/calendar-event.d.ts +2 -2
- package/lib/calendar-event/calendar-event.template.d.ts +1 -3
- package/lib/calendar-event/definition.d.ts +1 -1
- package/lib/card/card.d.ts +2 -2
- package/lib/card/card.template.d.ts +2 -3
- package/lib/card/definition.d.ts +1 -1
- package/lib/checkbox/checkbox.form-associated.d.ts +3 -2
- package/lib/checkbox/checkbox.template.d.ts +2 -3
- package/lib/checkbox/definition.d.ts +1 -1
- package/lib/combobox/combobox.d.ts +17 -2
- package/lib/combobox/combobox.options.d.ts +7 -0
- package/lib/combobox/combobox.template.d.ts +2 -3
- package/lib/combobox/definition.d.ts +1 -2
- package/lib/data-grid/data-grid-cell.d.ts +16 -13
- package/lib/data-grid/data-grid-cell.template.d.ts +2 -3
- package/lib/data-grid/data-grid-row.d.ts +19 -2
- package/lib/data-grid/data-grid-row.template.d.ts +2 -2
- package/lib/data-grid/data-grid.d.ts +45 -4
- package/lib/data-grid/data-grid.template.d.ts +2 -2
- package/lib/data-grid/definition.d.ts +1 -6
- package/lib/date-picker/definition.d.ts +1 -3
- package/lib/date-range-picker/definition.d.ts +1 -3
- package/lib/dial-pad/definition.d.ts +1 -3
- package/lib/dial-pad/dial-pad.d.ts +2 -2
- package/lib/dial-pad/dial-pad.template.d.ts +2 -3
- package/lib/dialog/definition.d.ts +1 -1
- package/lib/dialog/dialog.d.ts +2 -2
- package/lib/dialog/dialog.template.d.ts +2 -3
- package/lib/divider/definition.d.ts +1 -1
- package/lib/divider/divider.d.ts +2 -2
- package/lib/divider/divider.template.d.ts +1 -3
- package/lib/elevation/definition.d.ts +1 -1
- package/lib/elevation/elevation.d.ts +2 -2
- package/lib/elevation/elevation.template.d.ts +1 -3
- package/lib/empty-state/definition.d.ts +1 -3
- package/lib/empty-state/empty-state.d.ts +2 -2
- package/lib/empty-state/empty-state.template.d.ts +2 -3
- package/lib/fab/definition.d.ts +1 -3
- package/lib/fab/fab.template.d.ts +2 -3
- package/lib/file-picker/definition.d.ts +1 -3
- package/lib/file-picker/file-picker.form-associated.d.ts +3 -2
- package/lib/file-picker/file-picker.template.d.ts +2 -3
- package/lib/header/definition.d.ts +1 -3
- package/lib/header/header.d.ts +2 -2
- package/lib/header/header.template.d.ts +2 -3
- package/lib/icon/definition.d.ts +1 -3
- package/lib/icon/icon.d.ts +2 -2
- package/lib/icon/icon.template.d.ts +1 -3
- package/lib/layout/definition.d.ts +1 -3
- package/lib/layout/layout.d.ts +2 -2
- package/lib/layout/layout.template.d.ts +1 -3
- package/lib/listbox/definition.d.ts +1 -3
- package/lib/listbox/listbox.template.d.ts +1 -3
- package/lib/menu/definition.d.ts +1 -11
- package/lib/menu/menu.d.ts +2 -2
- package/lib/menu/menu.template.d.ts +3 -3
- package/lib/menu-item/definition.d.ts +1 -3
- package/lib/menu-item/menu-item.d.ts +2 -2
- package/lib/menu-item/menu-item.template.d.ts +2 -3
- package/lib/nav/definition.d.ts +1 -3
- package/lib/nav/nav.d.ts +2 -2
- package/lib/nav/nav.template.d.ts +1 -3
- package/lib/nav-disclosure/definition.d.ts +1 -3
- package/lib/nav-disclosure/nav-disclosure.d.ts +2 -2
- package/lib/nav-disclosure/nav-disclosure.template.d.ts +2 -3
- package/lib/nav-item/definition.d.ts +1 -3
- package/lib/nav-item/nav-item.template.d.ts +2 -3
- package/lib/note/definition.d.ts +1 -3
- package/lib/note/note.d.ts +2 -2
- package/lib/note/note.template.d.ts +2 -3
- package/lib/number-field/definition.d.ts +1 -4
- package/lib/number-field/number-field.form-associated.d.ts +3 -2
- package/lib/number-field/number-field.template.d.ts +2 -3
- package/lib/option/definition.d.ts +1 -3
- package/lib/option/option.d.ts +3 -2
- package/lib/option/option.template.d.ts +2 -3
- package/lib/pagination/definition.d.ts +1 -3
- package/lib/pagination/pagination.d.ts +2 -2
- package/lib/pagination/pagination.template.d.ts +2 -3
- package/lib/popup/definition.d.ts +1 -3
- package/lib/popup/popup.template.d.ts +2 -3
- package/lib/progress/definition.d.ts +1 -3
- package/lib/progress/progress.d.ts +1 -1
- package/lib/progress/progress.template.d.ts +1 -4
- package/lib/progress-ring/definition.d.ts +1 -3
- package/lib/progress-ring/progress-ring.d.ts +1 -1
- package/lib/progress-ring/progress-ring.template.d.ts +1 -3
- package/lib/radio/definition.d.ts +1 -3
- package/lib/radio/radio.form-associated.d.ts +3 -2
- package/lib/radio/radio.template.d.ts +1 -3
- package/lib/radio-group/definition.d.ts +1 -11
- package/lib/radio-group/radio-group.d.ts +2 -2
- package/lib/radio-group/radio-group.template.d.ts +2 -3
- package/lib/range-slider/definition.d.ts +1 -3
- package/lib/range-slider/range-slider.form-associated.d.ts +3 -2
- package/lib/range-slider/range-slider.template.d.ts +2 -3
- package/lib/searchable-select/definition.d.ts +1 -4
- package/lib/searchable-select/option-tag.template.d.ts +2 -3
- package/lib/searchable-select/searchable-select.form-associated.d.ts +3 -2
- package/lib/searchable-select/searchable-select.template.d.ts +2 -3
- package/lib/select/definition.d.ts +1 -3
- package/lib/select/select.d.ts +14 -4
- package/lib/select/select.form-associated.d.ts +11 -0
- package/lib/select/select.template.d.ts +2 -3
- package/lib/selectable-box/definition.d.ts +1 -3
- package/lib/selectable-box/selectable-box.d.ts +2 -2
- package/lib/selectable-box/selectable-box.template.d.ts +2 -3
- package/lib/side-drawer/definition.d.ts +1 -3
- package/lib/side-drawer/side-drawer.d.ts +2 -2
- package/lib/side-drawer/side-drawer.template.d.ts +1 -3
- package/lib/slider/definition.d.ts +1 -3
- package/lib/slider/slider.form-associated.d.ts +3 -2
- package/lib/slider/slider.template.d.ts +3 -4
- package/lib/split-button/definition.d.ts +1 -1
- package/lib/split-button/split-button.d.ts +2 -2
- package/lib/split-button/split-button.template.d.ts +2 -3
- package/lib/switch/definition.d.ts +1 -3
- package/lib/switch/switch.form-associated.d.ts +3 -2
- package/lib/switch/switch.template.d.ts +1 -3
- package/lib/tab/definition.d.ts +1 -3
- package/lib/tab/tab.d.ts +2 -2
- package/lib/tab/tab.template.d.ts +2 -2
- package/lib/tab-panel/definition.d.ts +1 -3
- package/lib/tab-panel/tab-panel.d.ts +2 -2
- package/lib/tab-panel/tab-panel.template.d.ts +1 -1
- package/lib/tabs/definition.d.ts +1 -3
- package/lib/tabs/tabs.d.ts +3 -2
- package/lib/tabs/tabs.template.d.ts +1 -1
- package/lib/tag/definition.d.ts +1 -4
- package/lib/tag/tag.d.ts +2 -2
- package/lib/tag/tag.template.d.ts +2 -3
- package/lib/tag-group/definition.d.ts +1 -3
- package/lib/tag-group/tag-group.d.ts +2 -2
- package/lib/tag-group/tag-group.template.d.ts +1 -3
- package/lib/text-anchor/definition.d.ts +1 -3
- package/lib/text-anchor/text-anchor.d.ts +4 -3
- package/lib/text-anchor/text-anchor.template.d.ts +2 -3
- package/lib/text-area/definition.d.ts +1 -3
- package/lib/text-area/text-area.d.ts +1 -1
- package/lib/text-area/{text-field.form-associated.d.ts → text-area.form-associated.d.ts} +3 -2
- package/lib/text-area/text-area.template.d.ts +2 -3
- package/lib/text-field/definition.d.ts +1 -3
- package/lib/text-field/text-field.form-associated.d.ts +3 -2
- package/lib/text-field/text-field.template.d.ts +2 -3
- package/lib/time-picker/definition.d.ts +1 -3
- package/lib/time-picker/time-picker.form-associated.d.ts +3 -2
- package/lib/time-picker/time-picker.template.d.ts +2 -2
- package/lib/toggletip/definition.d.ts +1 -3
- package/lib/toggletip/toggletip.d.ts +2 -2
- package/lib/toggletip/toggletip.template.d.ts +2 -3
- package/lib/tooltip/definition.d.ts +1 -3
- package/lib/tooltip/tooltip.d.ts +2 -2
- package/lib/tooltip/tooltip.template.d.ts +2 -3
- package/lib/tree-item/definition.d.ts +1 -3
- package/lib/tree-item/tree-item.d.ts +11 -2
- package/lib/tree-item/tree-item.template.d.ts +3 -3
- package/lib/tree-view/definition.d.ts +1 -3
- package/lib/tree-view/tree-view.d.ts +16 -2
- package/lib/tree-view/tree-view.template.d.ts +1 -1
- package/lib/video-player/definition.d.ts +1 -3
- package/lib/video-player/video-player.d.ts +2 -2
- package/lib/video-player/video-player.template.d.ts +1 -3
- package/listbox/index.cjs +37 -39
- package/listbox/index.js +37 -39
- package/menu/index.cjs +1 -1
- package/menu/index.js +1 -1
- package/nav/index.cjs +1 -1
- package/nav/index.js +1 -1
- package/nav-disclosure/index.cjs +1 -1
- package/nav-disclosure/index.js +1 -1
- package/nav-item/index.cjs +1 -1
- package/nav-item/index.js +1 -1
- package/note/index.cjs +1 -1
- package/note/index.js +1 -1
- package/number-field/index.cjs +1 -1
- package/number-field/index.js +1 -1
- package/option/index.cjs +1 -1
- package/option/index.js +1 -1
- package/package.json +1 -1
- package/pagination/index.cjs +1 -1
- package/pagination/index.js +1 -1
- package/popup/index.cjs +1 -1
- package/popup/index.js +1 -1
- package/progress/index.cjs +1 -1
- package/progress/index.js +1 -1
- package/progress-ring/index.cjs +1 -1
- package/progress-ring/index.js +1 -1
- package/radio/index.cjs +1 -1
- package/radio/index.js +1 -1
- package/radio-group/index.cjs +1 -1
- package/radio-group/index.js +1 -1
- package/range-slider/index.cjs +1 -1
- package/range-slider/index.js +1 -1
- package/searchable-select/index.cjs +1 -1
- package/searchable-select/index.js +1 -1
- package/select/index.cjs +1 -1
- package/select/index.js +1 -1
- package/selectable-box/index.cjs +1 -1
- package/selectable-box/index.js +1 -1
- package/shared/affix.cjs +10 -10
- package/shared/affix.js +2 -2
- package/shared/anchor.cjs +59 -0
- package/shared/anchor.js +57 -0
- package/shared/anchored.cjs +6 -6
- package/shared/anchored.js +2 -2
- package/shared/apply-mixins.cjs +15 -17
- package/shared/apply-mixins.js +15 -17
- package/shared/apply-mixins2.cjs +25 -0
- package/shared/apply-mixins2.js +23 -0
- package/shared/applyMixinsWithObservables.cjs +4 -4
- package/shared/applyMixinsWithObservables.js +2 -2
- package/shared/aria-global.cjs +86 -67
- package/shared/aria-global.js +86 -67
- package/shared/aria-global2.cjs +68 -86
- package/shared/aria-global2.js +68 -86
- package/shared/base-progress.cjs +70 -63
- package/shared/base-progress.js +69 -62
- package/shared/breadcrumb-item.cjs +7 -58
- package/shared/breadcrumb-item.js +4 -55
- package/shared/button.cjs +178 -0
- package/shared/button.js +176 -0
- package/shared/calendar-event.cjs +10 -9
- package/shared/calendar-event.js +3 -2
- package/shared/children.cjs +2 -2
- package/shared/children.js +1 -1
- package/shared/date-picker/date-picker-base.form-associated.d.ts +3 -2
- package/shared/date-picker/date-picker-base.template.d.ts +2 -3
- package/shared/defineVividComponent.cjs +2612 -0
- package/shared/defineVividComponent.js +2592 -0
- package/shared/definition.cjs +26 -24
- package/shared/definition.js +17 -14
- package/shared/definition10.cjs +15 -12
- package/shared/definition10.js +15 -11
- package/shared/definition11.cjs +52 -248
- package/shared/definition11.js +24 -218
- package/shared/definition12.cjs +18 -14
- package/shared/definition12.js +17 -12
- package/shared/definition13.cjs +20 -19
- package/shared/definition13.js +11 -9
- package/shared/definition14.cjs +36 -38
- package/shared/definition14.js +16 -17
- package/shared/definition15.cjs +28 -26
- package/shared/definition15.js +17 -14
- package/shared/definition16.cjs +478 -611
- package/shared/definition16.js +471 -603
- package/shared/definition17.cjs +934 -1113
- package/shared/definition17.js +912 -1090
- package/shared/definition18.cjs +16 -20
- package/shared/definition18.js +19 -22
- package/shared/definition19.cjs +26 -30
- package/shared/definition19.js +21 -24
- package/shared/definition2.cjs +20 -22
- package/shared/definition2.js +21 -22
- package/shared/definition20.cjs +51 -52
- package/shared/definition20.js +35 -35
- package/shared/definition21.cjs +42 -45
- package/shared/definition21.js +18 -20
- package/shared/definition22.cjs +16 -13
- package/shared/definition22.js +15 -11
- package/shared/definition23.cjs +22 -20
- package/shared/definition23.js +15 -12
- package/shared/definition24.cjs +20 -172
- package/shared/definition24.js +17 -168
- package/shared/definition25.cjs +27 -28
- package/shared/definition25.js +19 -19
- package/shared/definition26.cjs +17 -14
- package/shared/definition26.js +15 -11
- package/shared/definition27.cjs +265 -12
- package/shared/definition27.js +262 -10
- package/shared/definition28.cjs +19 -16
- package/shared/definition28.js +15 -11
- package/shared/definition29.cjs +143 -68
- package/shared/definition29.js +102 -29
- package/shared/definition3.cjs +21 -16
- package/shared/definition3.js +17 -11
- package/shared/definition30.cjs +99 -76
- package/shared/definition30.js +98 -74
- package/shared/definition31.cjs +24 -97
- package/shared/definition31.js +25 -97
- package/shared/definition32.cjs +10 -25
- package/shared/definition32.js +9 -23
- package/shared/definition33.cjs +53 -14
- package/shared/definition33.js +52 -12
- package/shared/definition34.cjs +641 -34
- package/shared/definition34.js +638 -30
- package/shared/definition35.cjs +204 -596
- package/shared/definition35.js +198 -591
- package/shared/definition36.cjs +198 -233
- package/shared/definition36.js +193 -226
- package/shared/definition37.cjs +79 -206
- package/shared/definition37.js +75 -202
- package/shared/definition38.cjs +50 -56
- package/shared/definition38.js +48 -52
- package/shared/definition39.cjs +260 -56
- package/shared/definition39.js +259 -54
- package/shared/definition4.cjs +33 -35
- package/shared/definition4.js +20 -21
- package/shared/definition40.cjs +112 -229
- package/shared/definition40.js +109 -226
- package/shared/definition41.cjs +627 -36
- package/shared/definition41.js +626 -34
- package/shared/definition42.cjs +975 -487
- package/shared/definition42.js +972 -482
- package/shared/definition43.cjs +725 -932
- package/shared/definition43.js +713 -918
- package/shared/definition44.cjs +116 -734
- package/shared/definition44.js +114 -731
- package/shared/definition45.cjs +93 -116
- package/shared/definition45.js +93 -115
- package/shared/definition46.cjs +469 -89
- package/shared/definition46.js +466 -86
- package/shared/definition47.cjs +119 -470
- package/shared/definition47.js +116 -465
- package/shared/definition48.cjs +114 -120
- package/shared/definition48.js +112 -117
- package/shared/definition49.cjs +17 -134
- package/shared/definition49.js +16 -132
- package/shared/definition5.cjs +48 -49
- package/shared/definition5.js +19 -19
- package/shared/definition50.cjs +112 -15
- package/shared/definition50.js +110 -12
- package/shared/definition51.cjs +847 -84
- package/shared/definition51.js +843 -79
- package/shared/definition52.cjs +31 -873
- package/shared/definition52.js +29 -870
- package/shared/definition53.cjs +126 -28
- package/shared/definition53.js +124 -25
- package/shared/definition54.cjs +268 -107
- package/shared/definition54.js +262 -100
- package/shared/definition55.cjs +63 -278
- package/shared/definition55.js +61 -275
- package/shared/definition56.cjs +868 -76
- package/shared/definition56.js +867 -74
- package/shared/definition57.cjs +108 -826
- package/shared/definition57.js +106 -823
- package/shared/definition58.cjs +74 -100
- package/shared/definition58.js +70 -95
- package/shared/definition59.cjs +181 -106
- package/shared/definition59.js +175 -101
- package/shared/definition6.cjs +23 -21
- package/shared/definition6.js +15 -12
- package/shared/definition60.cjs +273 -70
- package/shared/definition60.js +273 -69
- package/shared/definition61.cjs +66157 -271
- package/shared/definition61.js +66156 -269
- package/shared/definition62.cjs +36 -66174
- package/shared/definition62.js +33 -66171
- package/shared/definition63.cjs +2154 -27
- package/shared/definition63.js +2151 -25
- package/shared/definition7.cjs +19 -15
- package/shared/definition7.js +14 -10
- package/shared/definition8.cjs +26 -27
- package/shared/definition8.js +17 -17
- package/shared/definition9.cjs +21 -21
- package/shared/definition9.js +18 -17
- package/shared/design-system/createRegisterFunction.d.ts +2 -0
- package/shared/design-system/defineVividComponent.d.ts +15 -0
- package/shared/{localization.js → direction.js} +11 -11
- package/shared/dom.cjs +0 -13
- package/shared/dom.js +1 -13
- package/shared/form-associated.cjs +422 -457
- package/shared/form-associated.js +422 -457
- package/shared/form-associated2.cjs +383 -0
- package/shared/form-associated2.js +381 -0
- package/shared/form-elements.cjs +15 -42
- package/shared/form-elements.js +2 -29
- package/shared/foundation/anchor/anchor.d.ts +1 -0
- package/shared/foundation/button/button.d.ts +3 -2
- package/shared/foundation/button/button.template.d.ts +2 -4
- package/shared/foundation/form-associated/form-associated.d.ts +51 -0
- package/shared/foundation/listbox/listbox.d.ts +22 -0
- package/shared/foundation/progress/base-progress.d.ts +9 -0
- package/shared/foundation/utilities/apply-mixins.d.ts +1 -0
- package/shared/foundation/vivid-element/vivid-element.d.ts +3 -0
- package/shared/foundation-element.cjs +1417 -0
- package/shared/foundation-element.js +1414 -0
- package/shared/index.cjs +7 -5097
- package/shared/index.js +7 -5079
- package/shared/key-codes.cjs +10 -0
- package/shared/key-codes.js +6 -1
- package/shared/key-codes2.cjs +50 -6
- package/shared/key-codes2.js +50 -4
- package/shared/listbox.cjs +428 -1195
- package/shared/listbox.js +412 -1176
- package/shared/listbox2.cjs +1268 -0
- package/shared/listbox2.js +1265 -0
- package/shared/localized.cjs +2 -2
- package/shared/localized.js +1 -1
- package/shared/numbers.cjs +12 -0
- package/shared/numbers.js +12 -1
- package/shared/patterns/affix.d.ts +2 -2
- package/shared/patterns/chevron.d.ts +2 -2
- package/shared/patterns/form-elements/form-elements.d.ts +2 -2
- package/shared/presentationDate.cjs +50 -49
- package/shared/presentationDate.js +7 -6
- package/shared/ref.cjs +2 -2
- package/shared/ref.js +1 -1
- package/shared/repeat.cjs +22 -22
- package/shared/repeat.js +1 -1
- package/shared/slider.template.cjs +5 -5
- package/shared/slider.template.js +2 -2
- package/shared/slotted.cjs +4 -4
- package/shared/slotted.js +1 -1
- package/shared/strings.cjs +0 -26
- package/shared/strings.js +1 -25
- package/shared/strings2.cjs +37 -0
- package/shared/strings2.js +33 -0
- package/shared/text-anchor.cjs +8 -89
- package/shared/text-anchor.js +5 -86
- package/shared/text-anchor.template.cjs +2 -2
- package/shared/text-anchor.template.js +1 -1
- package/shared/text-field2.cjs +29 -28
- package/shared/text-field2.js +6 -5
- package/shared/vivid-element.cjs +8 -0
- package/shared/vivid-element.js +6 -0
- package/side-drawer/index.cjs +1 -1
- package/side-drawer/index.js +1 -1
- package/slider/index.cjs +1 -1
- package/slider/index.js +1 -1
- package/split-button/index.cjs +1 -1
- package/split-button/index.js +1 -1
- package/styles/core/all.css +1 -1
- package/styles/core/theme.css +1 -1
- package/styles/core/typography.css +1 -1
- package/styles/tokens/theme-dark.css +4 -4
- package/styles/tokens/theme-light.css +4 -4
- package/styles/tokens/vivid-2-compat.css +1 -1
- package/switch/index.cjs +1 -1
- package/switch/index.js +1 -1
- package/tab/index.cjs +1 -1
- package/tab/index.js +1 -1
- package/tab-panel/index.cjs +1 -1
- package/tab-panel/index.js +1 -1
- package/tabs/index.cjs +1 -1
- package/tabs/index.js +1 -1
- package/tag/index.cjs +1 -1
- package/tag/index.js +1 -1
- package/tag-group/index.cjs +1 -1
- package/tag-group/index.js +1 -1
- package/text-anchor/index.cjs +10 -7
- package/text-anchor/index.js +10 -7
- package/text-area/index.cjs +1 -1
- package/text-area/index.js +1 -1
- package/text-field/index.cjs +1 -1
- package/text-field/index.js +1 -1
- package/time-picker/index.cjs +1 -1
- package/time-picker/index.js +1 -1
- package/toggletip/index.cjs +1 -1
- package/toggletip/index.js +1 -1
- package/tooltip/index.cjs +1 -1
- package/tooltip/index.js +1 -1
- package/tree-item/index.cjs +1 -1
- package/tree-item/index.js +1 -1
- package/tree-view/index.cjs +1 -1
- package/tree-view/index.js +1 -1
- package/video-player/index.cjs +1 -1
- package/video-player/index.js +1 -1
- package/vivid.api.json +2846 -7860
- package/shared/definition64.cjs +0 -2175
- package/shared/definition64.js +0 -2170
- package/shared/design-system/index.d.ts +0 -3
- package/shared/icon.cjs +0 -261
- package/shared/icon.js +0 -258
- package/shared/index2.cjs +0 -11
- package/shared/index2.js +0 -9
- package/shared/radio.cjs +0 -126
- package/shared/radio.js +0 -124
- package/shared/select.options.cjs +0 -12
- package/shared/select.options.js +0 -10
- package/shared/start-end.cjs +0 -52
- package/shared/start-end.js +0 -50
- package/shared/tree-item.cjs +0 -154
- package/shared/tree-item.js +0 -151
- package/shared/{localization.cjs → direction.cjs} +9 -9
package/shared/listbox.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { i as isListboxOption } from './definition35.js';
|
|
2
|
+
import { V as VividElement } from './vivid-element.js';
|
|
3
|
+
import { a as keySpace, b as keyEscape, k as keyEnter, c as keyTab, d as keyEnd, e as keyArrowUp, f as keyArrowDown, g as keyHome } from './key-codes.js';
|
|
4
|
+
import { u as uniqueId } from './strings.js';
|
|
5
|
+
import { O as Observable, a as attr, o as observable } from './defineVividComponent.js';
|
|
6
|
+
import { a as applyMixins } from './apply-mixins2.js';
|
|
3
7
|
import { A as ARIAGlobalStatesAndProperties } from './aria-global.js';
|
|
4
|
-
import { S as StartEnd } from './start-end.js';
|
|
5
|
-
import { a as applyMixins } from './apply-mixins.js';
|
|
6
|
-
import { i as isHTMLElement } from './dom.js';
|
|
7
|
-
import { a as keySpace, b as keyEscape, k as keyEnter, c as keyTab, d as keyEnd, e as keyArrowUp, f as keyArrowDown, g as keyHome } from './key-codes2.js';
|
|
8
|
-
import { u as uniqueId, i as inRange } from './strings.js';
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* Returns the index of the last element in the array where predicate is true, and -1 otherwise.
|
|
@@ -23,1237 +22,474 @@ function findLastIndex(array, predicate) {
|
|
|
23
22
|
return -1;
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
* An Option Custom HTML Element.
|
|
39
|
-
* Implements {@link https://www.w3.org/TR/wai-aria-1.1/#option | ARIA option }.
|
|
40
|
-
*
|
|
41
|
-
* @slot start - Content which can be provided before the listbox option content
|
|
42
|
-
* @slot end - Content which can be provided after the listbox option content
|
|
43
|
-
* @slot - The default slot for listbox option content
|
|
44
|
-
* @csspart content - Wraps the listbox option content
|
|
45
|
-
*
|
|
46
|
-
* @public
|
|
47
|
-
*/
|
|
48
|
-
class ListboxOption extends FoundationElement {
|
|
49
|
-
constructor(text, value, defaultSelected, selected) {
|
|
50
|
-
super();
|
|
51
|
-
/**
|
|
52
|
-
* The defaultSelected state of the option.
|
|
53
|
-
* @public
|
|
54
|
-
*/
|
|
55
|
-
this.defaultSelected = false;
|
|
56
|
-
/**
|
|
57
|
-
* Tracks whether the "selected" property has been changed.
|
|
58
|
-
* @internal
|
|
59
|
-
*/
|
|
60
|
-
this.dirtySelected = false;
|
|
61
|
-
/**
|
|
62
|
-
* The checked state of the control.
|
|
63
|
-
*
|
|
64
|
-
* @public
|
|
65
|
-
*/
|
|
66
|
-
this.selected = this.defaultSelected;
|
|
67
|
-
/**
|
|
68
|
-
* Track whether the value has been changed from the initial value
|
|
69
|
-
*/
|
|
70
|
-
this.dirtyValue = false;
|
|
71
|
-
if (text) {
|
|
72
|
-
this.textContent = text;
|
|
73
|
-
}
|
|
74
|
-
if (value) {
|
|
75
|
-
this.initialValue = value;
|
|
76
|
-
}
|
|
77
|
-
if (defaultSelected) {
|
|
78
|
-
this.defaultSelected = defaultSelected;
|
|
79
|
-
}
|
|
80
|
-
if (selected) {
|
|
81
|
-
this.selected = selected;
|
|
82
|
-
}
|
|
83
|
-
this.proxy = new Option(`${this.textContent}`, this.initialValue, this.defaultSelected, this.selected);
|
|
84
|
-
this.proxy.disabled = this.disabled;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Updates the ariaChecked property when the checked property changes.
|
|
88
|
-
*
|
|
89
|
-
* @param prev - the previous checked value
|
|
90
|
-
* @param next - the current checked value
|
|
91
|
-
*
|
|
92
|
-
* @public
|
|
93
|
-
*/
|
|
94
|
-
checkedChanged(prev, next) {
|
|
95
|
-
if (typeof next === "boolean") {
|
|
96
|
-
this.ariaChecked = next ? "true" : "false";
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
this.ariaChecked = null;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Updates the proxy's text content when the default slot changes.
|
|
103
|
-
* @param prev - the previous content value
|
|
104
|
-
* @param next - the current content value
|
|
105
|
-
*
|
|
106
|
-
* @internal
|
|
107
|
-
*/
|
|
108
|
-
contentChanged(prev, next) {
|
|
109
|
-
if (this.proxy instanceof HTMLOptionElement) {
|
|
110
|
-
this.proxy.textContent = this.textContent;
|
|
111
|
-
}
|
|
112
|
-
this.$emit("contentchange", null, { bubbles: true });
|
|
113
|
-
}
|
|
114
|
-
defaultSelectedChanged() {
|
|
115
|
-
if (!this.dirtySelected) {
|
|
116
|
-
this.selected = this.defaultSelected;
|
|
117
|
-
if (this.proxy instanceof HTMLOptionElement) {
|
|
118
|
-
this.proxy.selected = this.defaultSelected;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
disabledChanged(prev, next) {
|
|
123
|
-
this.ariaDisabled = this.disabled ? "true" : "false";
|
|
124
|
-
if (this.proxy instanceof HTMLOptionElement) {
|
|
125
|
-
this.proxy.disabled = this.disabled;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
selectedAttributeChanged() {
|
|
129
|
-
this.defaultSelected = this.selectedAttribute;
|
|
130
|
-
if (this.proxy instanceof HTMLOptionElement) {
|
|
131
|
-
this.proxy.defaultSelected = this.defaultSelected;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
selectedChanged() {
|
|
135
|
-
this.ariaSelected = this.selected ? "true" : "false";
|
|
136
|
-
if (!this.dirtySelected) {
|
|
137
|
-
this.dirtySelected = true;
|
|
138
|
-
}
|
|
139
|
-
if (this.proxy instanceof HTMLOptionElement) {
|
|
140
|
-
this.proxy.selected = this.selected;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
initialValueChanged(previous, next) {
|
|
144
|
-
// If the value is clean and the component is connected to the DOM
|
|
145
|
-
// then set value equal to the attribute value.
|
|
146
|
-
if (!this.dirtyValue) {
|
|
147
|
-
this.value = this.initialValue;
|
|
148
|
-
this.dirtyValue = false;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
get label() {
|
|
152
|
-
var _a;
|
|
153
|
-
return (_a = this.value) !== null && _a !== void 0 ? _a : this.text;
|
|
154
|
-
}
|
|
155
|
-
get text() {
|
|
156
|
-
var _a, _b;
|
|
157
|
-
return (_b = (_a = this.textContent) === null || _a === void 0 ? void 0 : _a.replace(/\s+/g, " ").trim()) !== null && _b !== void 0 ? _b : "";
|
|
158
|
-
}
|
|
159
|
-
set value(next) {
|
|
160
|
-
const newValue = `${next !== null && next !== void 0 ? next : ""}`;
|
|
161
|
-
this._value = newValue;
|
|
162
|
-
this.dirtyValue = true;
|
|
163
|
-
if (this.proxy instanceof HTMLOptionElement) {
|
|
164
|
-
this.proxy.value = newValue;
|
|
165
|
-
}
|
|
166
|
-
Observable.notify(this, "value");
|
|
167
|
-
}
|
|
168
|
-
get value() {
|
|
169
|
-
var _a;
|
|
170
|
-
Observable.track(this, "value");
|
|
171
|
-
return (_a = this._value) !== null && _a !== void 0 ? _a : this.text;
|
|
172
|
-
}
|
|
173
|
-
get form() {
|
|
174
|
-
return this.proxy ? this.proxy.form : null;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
__decorate([
|
|
178
|
-
observable
|
|
179
|
-
], ListboxOption.prototype, "checked", void 0);
|
|
180
|
-
__decorate([
|
|
181
|
-
observable
|
|
182
|
-
], ListboxOption.prototype, "content", void 0);
|
|
183
|
-
__decorate([
|
|
184
|
-
observable
|
|
185
|
-
], ListboxOption.prototype, "defaultSelected", void 0);
|
|
186
|
-
__decorate([
|
|
187
|
-
attr({ mode: "boolean" })
|
|
188
|
-
], ListboxOption.prototype, "disabled", void 0);
|
|
189
|
-
__decorate([
|
|
190
|
-
attr({ attribute: "selected", mode: "boolean" })
|
|
191
|
-
], ListboxOption.prototype, "selectedAttribute", void 0);
|
|
192
|
-
__decorate([
|
|
193
|
-
observable
|
|
194
|
-
], ListboxOption.prototype, "selected", void 0);
|
|
195
|
-
__decorate([
|
|
196
|
-
attr({ attribute: "value", mode: "fromView" })
|
|
197
|
-
], ListboxOption.prototype, "initialValue", void 0);
|
|
198
|
-
/**
|
|
199
|
-
* States and properties relating to the ARIA `option` role.
|
|
200
|
-
*
|
|
201
|
-
* @public
|
|
202
|
-
*/
|
|
203
|
-
class DelegatesARIAListboxOption {
|
|
204
|
-
}
|
|
205
|
-
__decorate([
|
|
206
|
-
observable
|
|
207
|
-
], DelegatesARIAListboxOption.prototype, "ariaChecked", void 0);
|
|
208
|
-
__decorate([
|
|
209
|
-
observable
|
|
210
|
-
], DelegatesARIAListboxOption.prototype, "ariaPosInSet", void 0);
|
|
211
|
-
__decorate([
|
|
212
|
-
observable
|
|
213
|
-
], DelegatesARIAListboxOption.prototype, "ariaSelected", void 0);
|
|
214
|
-
__decorate([
|
|
215
|
-
observable
|
|
216
|
-
], DelegatesARIAListboxOption.prototype, "ariaSetSize", void 0);
|
|
217
|
-
applyMixins(DelegatesARIAListboxOption, ARIAGlobalStatesAndProperties);
|
|
218
|
-
applyMixins(ListboxOption, StartEnd, DelegatesARIAListboxOption);
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* A Listbox Custom HTML Element.
|
|
222
|
-
* Implements the {@link https://www.w3.org/TR/wai-aria-1.1/#listbox | ARIA listbox }.
|
|
223
|
-
*
|
|
224
|
-
* @slot - The default slot for the listbox options
|
|
225
|
-
*
|
|
226
|
-
* @public
|
|
227
|
-
*/
|
|
228
|
-
let Listbox$1 = class Listbox extends FoundationElement {
|
|
229
|
-
constructor() {
|
|
230
|
-
super(...arguments);
|
|
231
|
-
/**
|
|
232
|
-
* The internal unfiltered list of selectable options.
|
|
233
|
-
*
|
|
234
|
-
* @internal
|
|
235
|
-
*/
|
|
236
|
-
this._options = [];
|
|
237
|
-
/**
|
|
238
|
-
* The index of the selected option.
|
|
239
|
-
*
|
|
240
|
-
* @public
|
|
241
|
-
*/
|
|
242
|
-
this.selectedIndex = -1;
|
|
243
|
-
/**
|
|
244
|
-
* A collection of the selected options.
|
|
245
|
-
*
|
|
246
|
-
* @public
|
|
247
|
-
*/
|
|
248
|
-
this.selectedOptions = [];
|
|
249
|
-
/**
|
|
250
|
-
* A standard `click` event creates a `focus` event before firing, so a
|
|
251
|
-
* `mousedown` event is used to skip that initial focus.
|
|
252
|
-
*
|
|
253
|
-
* @internal
|
|
254
|
-
*/
|
|
255
|
-
this.shouldSkipFocus = false;
|
|
256
|
-
/**
|
|
257
|
-
* The current typeahead buffer string.
|
|
258
|
-
*
|
|
259
|
-
* @internal
|
|
260
|
-
*/
|
|
261
|
-
this.typeaheadBuffer = "";
|
|
262
|
-
/**
|
|
263
|
-
* Flag for the typeahead timeout expiration.
|
|
264
|
-
*
|
|
265
|
-
* @internal
|
|
266
|
-
*/
|
|
267
|
-
this.typeaheadExpired = true;
|
|
268
|
-
/**
|
|
269
|
-
* The timeout ID for the typeahead handler.
|
|
270
|
-
*
|
|
271
|
-
* @internal
|
|
272
|
-
*/
|
|
273
|
-
this.typeaheadTimeout = -1;
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* The first selected option.
|
|
277
|
-
*
|
|
278
|
-
* @internal
|
|
279
|
-
*/
|
|
280
|
-
get firstSelectedOption() {
|
|
281
|
-
var _a;
|
|
282
|
-
return (_a = this.selectedOptions[0]) !== null && _a !== void 0 ? _a : null;
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* Returns true if there is one or more selectable option.
|
|
286
|
-
*
|
|
287
|
-
* @internal
|
|
288
|
-
*/
|
|
289
|
-
get hasSelectableOptions() {
|
|
290
|
-
return this.options.length > 0 && !this.options.every(o => o.disabled);
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* The number of options.
|
|
294
|
-
*
|
|
295
|
-
* @public
|
|
296
|
-
*/
|
|
297
|
-
get length() {
|
|
298
|
-
var _a, _b;
|
|
299
|
-
return (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* The list of options.
|
|
303
|
-
*
|
|
304
|
-
* @public
|
|
305
|
-
*/
|
|
306
|
-
get options() {
|
|
307
|
-
Observable.track(this, "options");
|
|
308
|
-
return this._options;
|
|
309
|
-
}
|
|
310
|
-
set options(value) {
|
|
311
|
-
this._options = value;
|
|
312
|
-
Observable.notify(this, "options");
|
|
313
|
-
}
|
|
314
|
-
/**
|
|
315
|
-
* Flag for the typeahead timeout expiration.
|
|
316
|
-
*
|
|
317
|
-
* @deprecated use `Listbox.typeaheadExpired`
|
|
318
|
-
* @internal
|
|
319
|
-
*/
|
|
320
|
-
get typeAheadExpired() {
|
|
321
|
-
return this.typeaheadExpired;
|
|
322
|
-
}
|
|
323
|
-
set typeAheadExpired(value) {
|
|
324
|
-
this.typeaheadExpired = value;
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* Handle click events for listbox options.
|
|
328
|
-
*
|
|
329
|
-
* @internal
|
|
330
|
-
*/
|
|
331
|
-
clickHandler(e) {
|
|
332
|
-
const captured = e.target.closest(`option,[role=option]`);
|
|
333
|
-
if (captured && !captured.disabled) {
|
|
334
|
-
this.selectedIndex = this.options.indexOf(captured);
|
|
335
|
-
return true;
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
/**
|
|
339
|
-
* Ensures that the provided option is focused and scrolled into view.
|
|
340
|
-
*
|
|
341
|
-
* @param optionToFocus - The option to focus
|
|
342
|
-
* @internal
|
|
343
|
-
*/
|
|
344
|
-
focusAndScrollOptionIntoView(optionToFocus = this.firstSelectedOption) {
|
|
345
|
-
// To ensure that the browser handles both `focus()` and `scrollIntoView()`, the
|
|
346
|
-
// timing here needs to guarantee that they happen on different frames. Since this
|
|
347
|
-
// function is typically called from the `openChanged` observer, `DOM.queueUpdate`
|
|
348
|
-
// causes the calls to be grouped into the same frame. To prevent this,
|
|
349
|
-
// `requestAnimationFrame` is used instead of `DOM.queueUpdate`.
|
|
350
|
-
if (this.contains(document.activeElement) && optionToFocus !== null) {
|
|
351
|
-
optionToFocus.focus();
|
|
352
|
-
requestAnimationFrame(() => {
|
|
353
|
-
optionToFocus.scrollIntoView({ block: "nearest" });
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
/**
|
|
358
|
-
* Handles `focusin` actions for the component. When the component receives focus,
|
|
359
|
-
* the list of selected options is refreshed and the first selected option is scrolled
|
|
360
|
-
* into view.
|
|
361
|
-
*
|
|
362
|
-
* @internal
|
|
363
|
-
*/
|
|
364
|
-
focusinHandler(e) {
|
|
365
|
-
if (!this.shouldSkipFocus && e.target === e.currentTarget) {
|
|
366
|
-
this.setSelectedOptions();
|
|
367
|
-
this.focusAndScrollOptionIntoView();
|
|
368
|
-
}
|
|
369
|
-
this.shouldSkipFocus = false;
|
|
370
|
-
}
|
|
371
|
-
/**
|
|
372
|
-
* Returns the options which match the current typeahead buffer.
|
|
373
|
-
*
|
|
374
|
-
* @internal
|
|
375
|
-
*/
|
|
376
|
-
getTypeaheadMatches() {
|
|
377
|
-
const pattern = this.typeaheadBuffer.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&");
|
|
378
|
-
const re = new RegExp(`^${pattern}`, "gi");
|
|
379
|
-
return this.options.filter((o) => o.text.trim().match(re));
|
|
380
|
-
}
|
|
381
|
-
/**
|
|
382
|
-
* Determines the index of the next option which is selectable, if any.
|
|
383
|
-
*
|
|
384
|
-
* @param prev - the previous selected index
|
|
385
|
-
* @param next - the next index to select
|
|
386
|
-
*
|
|
387
|
-
* @internal
|
|
388
|
-
*/
|
|
389
|
-
getSelectableIndex(prev = this.selectedIndex, next) {
|
|
390
|
-
const direction = prev > next ? -1 : prev < next ? 1 : 0;
|
|
391
|
-
const potentialDirection = prev + direction;
|
|
392
|
-
let nextSelectableOption = null;
|
|
393
|
-
switch (direction) {
|
|
394
|
-
case -1: {
|
|
395
|
-
nextSelectableOption = this.options.reduceRight((nextSelectableOption, thisOption, index) => !nextSelectableOption &&
|
|
396
|
-
!thisOption.disabled &&
|
|
397
|
-
index < potentialDirection
|
|
398
|
-
? thisOption
|
|
399
|
-
: nextSelectableOption, nextSelectableOption);
|
|
400
|
-
break;
|
|
401
|
-
}
|
|
402
|
-
case 1: {
|
|
403
|
-
nextSelectableOption = this.options.reduce((nextSelectableOption, thisOption, index) => !nextSelectableOption &&
|
|
404
|
-
!thisOption.disabled &&
|
|
405
|
-
index > potentialDirection
|
|
406
|
-
? thisOption
|
|
407
|
-
: nextSelectableOption, nextSelectableOption);
|
|
408
|
-
break;
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
return this.options.indexOf(nextSelectableOption);
|
|
412
|
-
}
|
|
413
|
-
/**
|
|
414
|
-
* Handles external changes to child options.
|
|
415
|
-
*
|
|
416
|
-
* @param source - the source object
|
|
417
|
-
* @param propertyName - the property
|
|
418
|
-
*
|
|
419
|
-
* @internal
|
|
420
|
-
*/
|
|
421
|
-
handleChange(source, propertyName) {
|
|
422
|
-
switch (propertyName) {
|
|
423
|
-
case "selected": {
|
|
424
|
-
if (Listbox.slottedOptionFilter(source)) {
|
|
425
|
-
this.selectedIndex = this.options.indexOf(source);
|
|
426
|
-
}
|
|
427
|
-
this.setSelectedOptions();
|
|
428
|
-
break;
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
/**
|
|
433
|
-
* Moves focus to an option whose label matches characters typed by the user.
|
|
434
|
-
* Consecutive keystrokes are batched into a buffer of search text used
|
|
435
|
-
* to match against the set of options. If `TYPE_AHEAD_TIMEOUT_MS` passes
|
|
436
|
-
* between consecutive keystrokes, the search restarts.
|
|
437
|
-
*
|
|
438
|
-
* @param key - the key to be evaluated
|
|
439
|
-
*
|
|
440
|
-
* @internal
|
|
441
|
-
*/
|
|
442
|
-
handleTypeAhead(key) {
|
|
443
|
-
if (this.typeaheadTimeout) {
|
|
444
|
-
window.clearTimeout(this.typeaheadTimeout);
|
|
445
|
-
}
|
|
446
|
-
this.typeaheadTimeout = window.setTimeout(() => (this.typeaheadExpired = true), Listbox.TYPE_AHEAD_TIMEOUT_MS);
|
|
447
|
-
if (key.length > 1) {
|
|
448
|
-
return;
|
|
449
|
-
}
|
|
450
|
-
this.typeaheadBuffer = `${this.typeaheadExpired ? "" : this.typeaheadBuffer}${key}`;
|
|
451
|
-
}
|
|
452
|
-
/**
|
|
453
|
-
* Handles `keydown` actions for listbox navigation and typeahead.
|
|
454
|
-
*
|
|
455
|
-
* @internal
|
|
456
|
-
*/
|
|
457
|
-
keydownHandler(e) {
|
|
458
|
-
if (this.disabled) {
|
|
459
|
-
return true;
|
|
460
|
-
}
|
|
461
|
-
this.shouldSkipFocus = false;
|
|
462
|
-
const key = e.key;
|
|
463
|
-
switch (key) {
|
|
464
|
-
// Select the first available option
|
|
465
|
-
case keyHome: {
|
|
466
|
-
if (!e.shiftKey) {
|
|
467
|
-
e.preventDefault();
|
|
468
|
-
this.selectFirstOption();
|
|
469
|
-
}
|
|
470
|
-
break;
|
|
471
|
-
}
|
|
472
|
-
// Select the next selectable option
|
|
473
|
-
case keyArrowDown: {
|
|
474
|
-
if (!e.shiftKey) {
|
|
475
|
-
e.preventDefault();
|
|
476
|
-
this.selectNextOption();
|
|
477
|
-
}
|
|
478
|
-
break;
|
|
479
|
-
}
|
|
480
|
-
// Select the previous selectable option
|
|
481
|
-
case keyArrowUp: {
|
|
482
|
-
if (!e.shiftKey) {
|
|
483
|
-
e.preventDefault();
|
|
484
|
-
this.selectPreviousOption();
|
|
485
|
-
}
|
|
486
|
-
break;
|
|
487
|
-
}
|
|
488
|
-
// Select the last available option
|
|
489
|
-
case keyEnd: {
|
|
490
|
-
e.preventDefault();
|
|
491
|
-
this.selectLastOption();
|
|
492
|
-
break;
|
|
493
|
-
}
|
|
494
|
-
case keyTab: {
|
|
495
|
-
this.focusAndScrollOptionIntoView();
|
|
496
|
-
return true;
|
|
497
|
-
}
|
|
498
|
-
case keyEnter:
|
|
499
|
-
case keyEscape: {
|
|
500
|
-
return true;
|
|
501
|
-
}
|
|
502
|
-
case keySpace: {
|
|
503
|
-
if (this.typeaheadExpired) {
|
|
504
|
-
return true;
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
// Send key to Typeahead handler
|
|
508
|
-
default: {
|
|
509
|
-
if (key.length === 1) {
|
|
510
|
-
this.handleTypeAhead(`${key}`);
|
|
511
|
-
}
|
|
512
|
-
return true;
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
/**
|
|
517
|
-
* Prevents `focusin` events from firing before `click` events when the
|
|
518
|
-
* element is unfocused.
|
|
519
|
-
*
|
|
520
|
-
* @internal
|
|
521
|
-
*/
|
|
522
|
-
mousedownHandler(e) {
|
|
523
|
-
this.shouldSkipFocus = !this.contains(document.activeElement);
|
|
524
|
-
return true;
|
|
525
|
-
}
|
|
526
|
-
/**
|
|
527
|
-
* Switches between single-selection and multi-selection mode.
|
|
528
|
-
*
|
|
529
|
-
* @param prev - the previous value of the `multiple` attribute
|
|
530
|
-
* @param next - the next value of the `multiple` attribute
|
|
531
|
-
*
|
|
532
|
-
* @internal
|
|
533
|
-
*/
|
|
534
|
-
multipleChanged(prev, next) {
|
|
535
|
-
this.ariaMultiSelectable = next ? "true" : null;
|
|
536
|
-
}
|
|
537
|
-
/**
|
|
538
|
-
* Updates the list of selected options when the `selectedIndex` changes.
|
|
539
|
-
*
|
|
540
|
-
* @param prev - the previous selected index value
|
|
541
|
-
* @param next - the current selected index value
|
|
542
|
-
*
|
|
543
|
-
* @internal
|
|
544
|
-
*/
|
|
545
|
-
selectedIndexChanged(prev, next) {
|
|
546
|
-
var _a;
|
|
547
|
-
if (!this.hasSelectableOptions) {
|
|
548
|
-
this.selectedIndex = -1;
|
|
549
|
-
return;
|
|
550
|
-
}
|
|
551
|
-
if (((_a = this.options[this.selectedIndex]) === null || _a === void 0 ? void 0 : _a.disabled) && typeof prev === "number") {
|
|
552
|
-
const selectableIndex = this.getSelectableIndex(prev, next);
|
|
553
|
-
const newNext = selectableIndex > -1 ? selectableIndex : prev;
|
|
554
|
-
this.selectedIndex = newNext;
|
|
555
|
-
if (next === newNext) {
|
|
556
|
-
this.selectedIndexChanged(next, newNext);
|
|
557
|
-
}
|
|
558
|
-
return;
|
|
559
|
-
}
|
|
560
|
-
this.setSelectedOptions();
|
|
561
|
-
}
|
|
562
|
-
/**
|
|
563
|
-
* Updates the selectedness of each option when the list of selected options changes.
|
|
564
|
-
*
|
|
565
|
-
* @param prev - the previous list of selected options
|
|
566
|
-
* @param next - the current list of selected options
|
|
567
|
-
*
|
|
568
|
-
* @internal
|
|
569
|
-
*/
|
|
570
|
-
selectedOptionsChanged(prev, next) {
|
|
571
|
-
var _a;
|
|
572
|
-
const filteredNext = next.filter(Listbox.slottedOptionFilter);
|
|
573
|
-
(_a = this.options) === null || _a === void 0 ? void 0 : _a.forEach(o => {
|
|
574
|
-
const notifier = Observable.getNotifier(o);
|
|
575
|
-
notifier.unsubscribe(this, "selected");
|
|
576
|
-
o.selected = filteredNext.includes(o);
|
|
577
|
-
notifier.subscribe(this, "selected");
|
|
578
|
-
});
|
|
579
|
-
}
|
|
580
|
-
/**
|
|
581
|
-
* Moves focus to the first selectable option.
|
|
582
|
-
*
|
|
583
|
-
* @public
|
|
584
|
-
*/
|
|
585
|
-
selectFirstOption() {
|
|
586
|
-
var _a, _b;
|
|
587
|
-
if (!this.disabled) {
|
|
588
|
-
this.selectedIndex = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.findIndex(o => !o.disabled)) !== null && _b !== void 0 ? _b : -1;
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
/**
|
|
592
|
-
* Moves focus to the last selectable option.
|
|
593
|
-
*
|
|
594
|
-
* @internal
|
|
595
|
-
*/
|
|
596
|
-
selectLastOption() {
|
|
597
|
-
if (!this.disabled) {
|
|
598
|
-
this.selectedIndex = findLastIndex(this.options, o => !o.disabled);
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
/**
|
|
602
|
-
* Moves focus to the next selectable option.
|
|
603
|
-
*
|
|
604
|
-
* @internal
|
|
605
|
-
*/
|
|
606
|
-
selectNextOption() {
|
|
607
|
-
if (!this.disabled && this.selectedIndex < this.options.length - 1) {
|
|
608
|
-
this.selectedIndex += 1;
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
/**
|
|
612
|
-
* Moves focus to the previous selectable option.
|
|
613
|
-
*
|
|
614
|
-
* @internal
|
|
615
|
-
*/
|
|
616
|
-
selectPreviousOption() {
|
|
617
|
-
if (!this.disabled && this.selectedIndex > 0) {
|
|
618
|
-
this.selectedIndex = this.selectedIndex - 1;
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
/**
|
|
622
|
-
* Updates the selected index to match the first selected option.
|
|
623
|
-
*
|
|
624
|
-
* @internal
|
|
625
|
-
*/
|
|
626
|
-
setDefaultSelectedOption() {
|
|
627
|
-
var _a, _b;
|
|
628
|
-
this.selectedIndex = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.findIndex(el => el.defaultSelected)) !== null && _b !== void 0 ? _b : -1;
|
|
629
|
-
}
|
|
630
|
-
/**
|
|
631
|
-
* Sets an option as selected and gives it focus.
|
|
632
|
-
*
|
|
633
|
-
* @public
|
|
634
|
-
*/
|
|
635
|
-
setSelectedOptions() {
|
|
636
|
-
var _a, _b, _c;
|
|
637
|
-
if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.length) {
|
|
638
|
-
this.selectedOptions = [this.options[this.selectedIndex]];
|
|
639
|
-
this.ariaActiveDescendant = (_c = (_b = this.firstSelectedOption) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : "";
|
|
640
|
-
this.focusAndScrollOptionIntoView();
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
/**
|
|
644
|
-
* Updates the list of options and resets the selected option when the slotted option content changes.
|
|
645
|
-
*
|
|
646
|
-
* @param prev - the previous list of slotted options
|
|
647
|
-
* @param next - the current list of slotted options
|
|
648
|
-
*
|
|
649
|
-
* @internal
|
|
650
|
-
*/
|
|
651
|
-
slottedOptionsChanged(prev, next) {
|
|
652
|
-
this.options = next.reduce((options, item) => {
|
|
653
|
-
if (isListboxOption(item)) {
|
|
654
|
-
options.push(item);
|
|
655
|
-
}
|
|
656
|
-
return options;
|
|
657
|
-
}, []);
|
|
658
|
-
const setSize = `${this.options.length}`;
|
|
659
|
-
this.options.forEach((option, index) => {
|
|
660
|
-
if (!option.id) {
|
|
661
|
-
option.id = uniqueId("option-");
|
|
662
|
-
}
|
|
663
|
-
option.ariaPosInSet = `${index + 1}`;
|
|
664
|
-
option.ariaSetSize = setSize;
|
|
665
|
-
});
|
|
666
|
-
if (this.$fastController.isConnected) {
|
|
667
|
-
this.setSelectedOptions();
|
|
668
|
-
this.setDefaultSelectedOption();
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
/**
|
|
672
|
-
* Updates the filtered list of options when the typeahead buffer changes.
|
|
673
|
-
*
|
|
674
|
-
* @param prev - the previous typeahead buffer value
|
|
675
|
-
* @param next - the current typeahead buffer value
|
|
676
|
-
*
|
|
677
|
-
* @internal
|
|
678
|
-
*/
|
|
679
|
-
typeaheadBufferChanged(prev, next) {
|
|
680
|
-
if (this.$fastController.isConnected) {
|
|
681
|
-
const typeaheadMatches = this.getTypeaheadMatches();
|
|
682
|
-
if (typeaheadMatches.length) {
|
|
683
|
-
const selectedIndex = this.options.indexOf(typeaheadMatches[0]);
|
|
684
|
-
if (selectedIndex > -1) {
|
|
685
|
-
this.selectedIndex = selectedIndex;
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
this.typeaheadExpired = false;
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
};
|
|
692
|
-
/**
|
|
693
|
-
* A static filter to include only selectable options.
|
|
694
|
-
*
|
|
695
|
-
* @param n - element to filter
|
|
696
|
-
* @public
|
|
697
|
-
*/
|
|
698
|
-
Listbox$1.slottedOptionFilter = (n) => isListboxOption(n) && !n.hidden;
|
|
699
|
-
/**
|
|
700
|
-
* Typeahead timeout in milliseconds.
|
|
701
|
-
*
|
|
702
|
-
* @internal
|
|
703
|
-
*/
|
|
704
|
-
Listbox$1.TYPE_AHEAD_TIMEOUT_MS = 1000;
|
|
705
|
-
__decorate([
|
|
706
|
-
attr({ mode: "boolean" })
|
|
707
|
-
], Listbox$1.prototype, "disabled", void 0);
|
|
708
|
-
__decorate([
|
|
709
|
-
observable
|
|
710
|
-
], Listbox$1.prototype, "selectedIndex", void 0);
|
|
711
|
-
__decorate([
|
|
712
|
-
observable
|
|
713
|
-
], Listbox$1.prototype, "selectedOptions", void 0);
|
|
714
|
-
__decorate([
|
|
715
|
-
observable
|
|
716
|
-
], Listbox$1.prototype, "slottedOptions", void 0);
|
|
717
|
-
__decorate([
|
|
718
|
-
observable
|
|
719
|
-
], Listbox$1.prototype, "typeaheadBuffer", void 0);
|
|
720
|
-
/**
|
|
721
|
-
* Includes ARIA states and properties relating to the ARIA listbox role
|
|
722
|
-
*
|
|
723
|
-
* @public
|
|
724
|
-
*/
|
|
725
|
-
class DelegatesARIAListbox {
|
|
726
|
-
}
|
|
727
|
-
__decorate([
|
|
728
|
-
observable
|
|
729
|
-
], DelegatesARIAListbox.prototype, "ariaActiveDescendant", void 0);
|
|
730
|
-
__decorate([
|
|
731
|
-
observable
|
|
732
|
-
], DelegatesARIAListbox.prototype, "ariaDisabled", void 0);
|
|
733
|
-
__decorate([
|
|
734
|
-
observable
|
|
735
|
-
], DelegatesARIAListbox.prototype, "ariaExpanded", void 0);
|
|
736
|
-
__decorate([
|
|
737
|
-
observable
|
|
738
|
-
], DelegatesARIAListbox.prototype, "ariaMultiSelectable", void 0);
|
|
739
|
-
applyMixins(DelegatesARIAListbox, ARIAGlobalStatesAndProperties);
|
|
740
|
-
applyMixins(Listbox$1, DelegatesARIAListbox);
|
|
741
|
-
|
|
742
|
-
/**
|
|
743
|
-
* A Listbox Custom HTML Element.
|
|
744
|
-
* Implements the {@link https://w3c.github.io/aria/#listbox | ARIA listbox }.
|
|
745
|
-
*
|
|
746
|
-
* @public
|
|
747
|
-
*/
|
|
748
|
-
class ListboxElement extends Listbox$1 {
|
|
749
|
-
constructor() {
|
|
750
|
-
super(...arguments);
|
|
751
|
-
/**
|
|
752
|
-
* The index of the most recently checked option.
|
|
753
|
-
*
|
|
754
|
-
* @internal
|
|
755
|
-
* @remarks
|
|
756
|
-
* Multiple-selection mode only.
|
|
757
|
-
*/
|
|
758
|
-
this.activeIndex = -1;
|
|
759
|
-
/**
|
|
760
|
-
* The start index when checking a range of options.
|
|
761
|
-
*
|
|
762
|
-
* @internal
|
|
763
|
-
*/
|
|
764
|
-
this.rangeStartIndex = -1;
|
|
765
|
-
}
|
|
766
|
-
/**
|
|
767
|
-
* Returns the last checked option.
|
|
768
|
-
*
|
|
769
|
-
* @internal
|
|
770
|
-
*/
|
|
771
|
-
get activeOption() {
|
|
772
|
-
return this.options[this.activeIndex];
|
|
773
|
-
}
|
|
774
|
-
/**
|
|
775
|
-
* Returns the list of checked options.
|
|
776
|
-
*
|
|
777
|
-
* @internal
|
|
778
|
-
*/
|
|
779
|
-
get checkedOptions() {
|
|
780
|
-
var _a;
|
|
781
|
-
return (_a = this.options) === null || _a === void 0 ? void 0 : _a.filter(o => o.checked);
|
|
782
|
-
}
|
|
783
|
-
/**
|
|
784
|
-
* Returns the index of the first selected option.
|
|
785
|
-
*
|
|
786
|
-
* @internal
|
|
787
|
-
*/
|
|
788
|
-
get firstSelectedOptionIndex() {
|
|
789
|
-
return this.options.indexOf(this.firstSelectedOption);
|
|
790
|
-
}
|
|
791
|
-
/**
|
|
792
|
-
* Updates the `ariaActiveDescendant` property when the active index changes.
|
|
793
|
-
*
|
|
794
|
-
* @param prev - the previous active index
|
|
795
|
-
* @param next - the next active index
|
|
796
|
-
*
|
|
797
|
-
* @internal
|
|
798
|
-
*/
|
|
799
|
-
activeIndexChanged(prev, next) {
|
|
800
|
-
var _a, _b;
|
|
801
|
-
this.ariaActiveDescendant = (_b = (_a = this.options[next]) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : "";
|
|
802
|
-
this.focusAndScrollOptionIntoView();
|
|
803
|
-
}
|
|
804
|
-
/**
|
|
805
|
-
* Toggles the checked state for the currently active option.
|
|
806
|
-
*
|
|
807
|
-
* @remarks
|
|
808
|
-
* Multiple-selection mode only.
|
|
809
|
-
*
|
|
810
|
-
* @internal
|
|
811
|
-
*/
|
|
812
|
-
checkActiveIndex() {
|
|
813
|
-
if (!this.multiple) {
|
|
814
|
-
return;
|
|
815
|
-
}
|
|
816
|
-
const activeItem = this.activeOption;
|
|
817
|
-
if (activeItem) {
|
|
818
|
-
activeItem.checked = true;
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
/**
|
|
822
|
-
* Sets the active index to the first option and marks it as checked.
|
|
823
|
-
*
|
|
824
|
-
* @remarks
|
|
825
|
-
* Multi-selection mode only.
|
|
826
|
-
*
|
|
827
|
-
* @param preserveChecked - mark all options unchecked before changing the active index
|
|
828
|
-
*
|
|
829
|
-
* @internal
|
|
830
|
-
*/
|
|
831
|
-
checkFirstOption(preserveChecked = false) {
|
|
832
|
-
if (preserveChecked) {
|
|
833
|
-
if (this.rangeStartIndex === -1) {
|
|
834
|
-
this.rangeStartIndex = this.activeIndex + 1;
|
|
835
|
-
}
|
|
836
|
-
this.options.forEach((o, i) => {
|
|
837
|
-
o.checked = inRange(i, this.rangeStartIndex);
|
|
838
|
-
});
|
|
839
|
-
}
|
|
840
|
-
else {
|
|
841
|
-
this.uncheckAllOptions();
|
|
842
|
-
}
|
|
843
|
-
this.activeIndex = 0;
|
|
844
|
-
this.checkActiveIndex();
|
|
845
|
-
}
|
|
846
|
-
/**
|
|
847
|
-
* Decrements the active index and sets the matching option as checked.
|
|
848
|
-
*
|
|
849
|
-
* @remarks
|
|
850
|
-
* Multi-selection mode only.
|
|
851
|
-
*
|
|
852
|
-
* @param preserveChecked - mark all options unchecked before changing the active index
|
|
853
|
-
*
|
|
854
|
-
* @internal
|
|
855
|
-
*/
|
|
856
|
-
checkLastOption(preserveChecked = false) {
|
|
857
|
-
if (preserveChecked) {
|
|
858
|
-
if (this.rangeStartIndex === -1) {
|
|
859
|
-
this.rangeStartIndex = this.activeIndex;
|
|
860
|
-
}
|
|
861
|
-
this.options.forEach((o, i) => {
|
|
862
|
-
o.checked = inRange(i, this.rangeStartIndex, this.options.length);
|
|
863
|
-
});
|
|
864
|
-
}
|
|
865
|
-
else {
|
|
866
|
-
this.uncheckAllOptions();
|
|
867
|
-
}
|
|
868
|
-
this.activeIndex = this.options.length - 1;
|
|
869
|
-
this.checkActiveIndex();
|
|
870
|
-
}
|
|
871
|
-
/**
|
|
872
|
-
* @override
|
|
873
|
-
* @internal
|
|
874
|
-
*/
|
|
875
|
-
connectedCallback() {
|
|
876
|
-
super.connectedCallback();
|
|
877
|
-
this.addEventListener("focusout", this.focusoutHandler);
|
|
878
|
-
}
|
|
879
|
-
/**
|
|
880
|
-
* @override
|
|
881
|
-
* @internal
|
|
882
|
-
*/
|
|
883
|
-
disconnectedCallback() {
|
|
884
|
-
this.removeEventListener("focusout", this.focusoutHandler);
|
|
885
|
-
super.disconnectedCallback();
|
|
886
|
-
}
|
|
25
|
+
var __defProp = Object.defineProperty;
|
|
26
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
27
|
+
var result = void 0 ;
|
|
28
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
29
|
+
if (decorator = decorators[i])
|
|
30
|
+
result = (decorator(target, key, result) ) || result;
|
|
31
|
+
if (result) __defProp(target, key, result);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
const _Listbox = class _Listbox extends VividElement {
|
|
35
|
+
constructor() {
|
|
36
|
+
super(...arguments);
|
|
887
37
|
/**
|
|
888
|
-
*
|
|
889
|
-
*
|
|
890
|
-
* @remarks
|
|
891
|
-
* Multiple-selection mode only.
|
|
892
|
-
*
|
|
893
|
-
* @param preserveChecked - mark all options unchecked before changing the active index
|
|
38
|
+
* The internal unfiltered list of selectable options.
|
|
894
39
|
*
|
|
895
40
|
* @internal
|
|
896
41
|
*/
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
this.rangeStartIndex = this.activeIndex;
|
|
901
|
-
}
|
|
902
|
-
this.options.forEach((o, i) => {
|
|
903
|
-
o.checked = inRange(i, this.rangeStartIndex, this.activeIndex + 1);
|
|
904
|
-
});
|
|
905
|
-
}
|
|
906
|
-
else {
|
|
907
|
-
this.uncheckAllOptions();
|
|
908
|
-
}
|
|
909
|
-
this.activeIndex += this.activeIndex < this.options.length - 1 ? 1 : 0;
|
|
910
|
-
this.checkActiveIndex();
|
|
911
|
-
}
|
|
42
|
+
this._options = [];
|
|
43
|
+
this.selectedIndex = -1;
|
|
44
|
+
this.selectedOptions = [];
|
|
912
45
|
/**
|
|
913
|
-
*
|
|
914
|
-
*
|
|
915
|
-
* @remarks
|
|
916
|
-
* Multiple-selection mode only.
|
|
917
|
-
*
|
|
918
|
-
* @param preserveChecked - mark all options unchecked before changing the active index
|
|
46
|
+
* A standard `click` event creates a `focus` event before firing, so a
|
|
47
|
+
* `mousedown` event is used to skip that initial focus.
|
|
919
48
|
*
|
|
920
49
|
* @internal
|
|
921
50
|
*/
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
if (this.rangeStartIndex === -1) {
|
|
925
|
-
this.rangeStartIndex = this.activeIndex;
|
|
926
|
-
}
|
|
927
|
-
if (this.checkedOptions.length === 1) {
|
|
928
|
-
this.rangeStartIndex += 1;
|
|
929
|
-
}
|
|
930
|
-
this.options.forEach((o, i) => {
|
|
931
|
-
o.checked = inRange(i, this.activeIndex, this.rangeStartIndex);
|
|
932
|
-
});
|
|
933
|
-
}
|
|
934
|
-
else {
|
|
935
|
-
this.uncheckAllOptions();
|
|
936
|
-
}
|
|
937
|
-
this.activeIndex -= this.activeIndex > 0 ? 1 : 0;
|
|
938
|
-
this.checkActiveIndex();
|
|
939
|
-
}
|
|
51
|
+
this.shouldSkipFocus = false;
|
|
52
|
+
this.typeaheadBuffer = "";
|
|
940
53
|
/**
|
|
941
|
-
*
|
|
942
|
-
*
|
|
943
|
-
* @param e - the event object
|
|
54
|
+
* Flag for the typeahead timeout expiration.
|
|
944
55
|
*
|
|
945
|
-
* @override
|
|
946
|
-
* @internal
|
|
947
|
-
*/
|
|
948
|
-
clickHandler(e) {
|
|
949
|
-
var _a;
|
|
950
|
-
if (!this.multiple) {
|
|
951
|
-
return super.clickHandler(e);
|
|
952
|
-
}
|
|
953
|
-
const captured = (_a = e.target) === null || _a === void 0 ? void 0 : _a.closest(`[role=option]`);
|
|
954
|
-
if (!captured || captured.disabled) {
|
|
955
|
-
return;
|
|
956
|
-
}
|
|
957
|
-
this.uncheckAllOptions();
|
|
958
|
-
this.activeIndex = this.options.indexOf(captured);
|
|
959
|
-
this.checkActiveIndex();
|
|
960
|
-
this.toggleSelectedForAllCheckedOptions();
|
|
961
|
-
return true;
|
|
962
|
-
}
|
|
963
|
-
/**
|
|
964
|
-
* @override
|
|
965
56
|
* @internal
|
|
966
57
|
*/
|
|
967
|
-
|
|
968
|
-
super.focusAndScrollOptionIntoView(this.activeOption);
|
|
969
|
-
}
|
|
58
|
+
this.typeaheadExpired = true;
|
|
970
59
|
/**
|
|
971
|
-
*
|
|
972
|
-
* If any options are selected, the first selected option is checked when
|
|
973
|
-
* the listbox receives focus. If no options are selected, the first
|
|
974
|
-
* selectable option is checked.
|
|
60
|
+
* The timeout ID for the typeahead handler.
|
|
975
61
|
*
|
|
976
|
-
* @override
|
|
977
62
|
* @internal
|
|
978
63
|
*/
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
64
|
+
this.typeaheadTimeout = -1;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The first selected option.
|
|
68
|
+
*
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
71
|
+
get firstSelectedOption() {
|
|
72
|
+
return this.selectedOptions[0] ?? null;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Returns true if there is one or more selectable option.
|
|
76
|
+
*
|
|
77
|
+
* @internal
|
|
78
|
+
*/
|
|
79
|
+
get hasSelectableOptions() {
|
|
80
|
+
return this.options.length > 0 && !this.options.every((o) => o.disabled);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The number of options.
|
|
84
|
+
*
|
|
85
|
+
* @public
|
|
86
|
+
*/
|
|
87
|
+
get length() {
|
|
88
|
+
return this.options.length;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The list of options.
|
|
92
|
+
*
|
|
93
|
+
* @public
|
|
94
|
+
*/
|
|
95
|
+
get options() {
|
|
96
|
+
Observable.track(this, "options");
|
|
97
|
+
return this._options;
|
|
98
|
+
}
|
|
99
|
+
set options(value) {
|
|
100
|
+
this._options = value;
|
|
101
|
+
Observable.notify(this, "options");
|
|
102
|
+
}
|
|
103
|
+
static {
|
|
997
104
|
/**
|
|
998
|
-
*
|
|
105
|
+
* A static filter to include only selectable options.
|
|
999
106
|
*
|
|
1000
|
-
* @
|
|
107
|
+
* @param n - element to filter
|
|
108
|
+
* @public
|
|
1001
109
|
*/
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
110
|
+
this.slottedOptionFilter = (n) => isListboxOption(n) && !n.hidden;
|
|
111
|
+
}
|
|
112
|
+
static {
|
|
1007
113
|
/**
|
|
1008
|
-
*
|
|
114
|
+
* Typeahead timeout in milliseconds.
|
|
1009
115
|
*
|
|
1010
|
-
* @override
|
|
1011
116
|
* @internal
|
|
1012
117
|
*/
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
}
|
|
1028
|
-
// Select the next selectable option
|
|
1029
|
-
case keyArrowDown: {
|
|
1030
|
-
this.checkNextOption(shiftKey);
|
|
1031
|
-
return;
|
|
1032
|
-
}
|
|
1033
|
-
// Select the previous selectable option
|
|
1034
|
-
case keyArrowUp: {
|
|
1035
|
-
this.checkPreviousOption(shiftKey);
|
|
1036
|
-
return;
|
|
1037
|
-
}
|
|
1038
|
-
// Select the last available option
|
|
1039
|
-
case keyEnd: {
|
|
1040
|
-
this.checkLastOption(shiftKey);
|
|
1041
|
-
return;
|
|
1042
|
-
}
|
|
1043
|
-
case keyTab: {
|
|
1044
|
-
this.focusAndScrollOptionIntoView();
|
|
1045
|
-
return true;
|
|
1046
|
-
}
|
|
1047
|
-
case keyEscape: {
|
|
1048
|
-
this.uncheckAllOptions();
|
|
1049
|
-
this.checkActiveIndex();
|
|
1050
|
-
return true;
|
|
1051
|
-
}
|
|
1052
|
-
case keySpace: {
|
|
1053
|
-
e.preventDefault();
|
|
1054
|
-
if (this.typeAheadExpired) {
|
|
1055
|
-
this.toggleSelectedForAllCheckedOptions();
|
|
1056
|
-
return;
|
|
1057
|
-
}
|
|
1058
|
-
}
|
|
1059
|
-
// Send key to Typeahead handler
|
|
1060
|
-
default: {
|
|
1061
|
-
if (key.length === 1) {
|
|
1062
|
-
this.handleTypeAhead(`${key}`);
|
|
1063
|
-
}
|
|
1064
|
-
return true;
|
|
1065
|
-
}
|
|
1066
|
-
}
|
|
118
|
+
this.TYPE_AHEAD_TIMEOUT_MS = 1e3;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Handle click events for listbox options.
|
|
122
|
+
*
|
|
123
|
+
* @internal
|
|
124
|
+
*/
|
|
125
|
+
clickHandler(e) {
|
|
126
|
+
const captured = e.target.closest(
|
|
127
|
+
`option,[role=option]`
|
|
128
|
+
);
|
|
129
|
+
if (captured && !captured.disabled) {
|
|
130
|
+
this.selectedIndex = this.options.indexOf(captured);
|
|
131
|
+
return true;
|
|
1067
132
|
}
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Ensures that the provided option is focused and scrolled into view.
|
|
136
|
+
*
|
|
137
|
+
* @param optionToFocus - The option to focus
|
|
138
|
+
* @internal
|
|
139
|
+
*/
|
|
140
|
+
focusAndScrollOptionIntoView(optionToFocus = this.firstSelectedOption) {
|
|
141
|
+
if (this.contains(document.activeElement) && optionToFocus !== null) {
|
|
142
|
+
optionToFocus.focus();
|
|
143
|
+
requestAnimationFrame(() => {
|
|
144
|
+
optionToFocus.scrollIntoView({ block: "nearest" });
|
|
145
|
+
});
|
|
1079
146
|
}
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Handles `focusin` actions for the component. When the component receives focus,
|
|
150
|
+
* the list of selected options is refreshed and the first selected option is scrolled
|
|
151
|
+
* into view.
|
|
152
|
+
*
|
|
153
|
+
* @internal
|
|
154
|
+
*/
|
|
155
|
+
focusinHandler(e) {
|
|
156
|
+
if (!this.shouldSkipFocus && e.target === e.currentTarget) {
|
|
157
|
+
this.setSelectedOptions();
|
|
158
|
+
this.focusAndScrollOptionIntoView();
|
|
1092
159
|
}
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
160
|
+
this.shouldSkipFocus = false;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Returns the options which match the current typeahead buffer.
|
|
164
|
+
*
|
|
165
|
+
* @internal
|
|
166
|
+
*/
|
|
167
|
+
getTypeaheadMatches() {
|
|
168
|
+
const pattern = this.typeaheadBuffer.replace(
|
|
169
|
+
/[.*+\-?^${}()|[\]\\]/g,
|
|
170
|
+
"\\$&"
|
|
171
|
+
);
|
|
172
|
+
const re = new RegExp(`^${pattern}`, "gi");
|
|
173
|
+
return this.options.filter((o) => o.text.trim().match(re));
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Determines the index of the next option which is selectable, if any.
|
|
177
|
+
*
|
|
178
|
+
* @param prev - the previous selected index
|
|
179
|
+
* @param next - the next index to select
|
|
180
|
+
*
|
|
181
|
+
* @internal
|
|
182
|
+
*/
|
|
183
|
+
getSelectableIndex(prev, next) {
|
|
184
|
+
const direction = prev > next ? -1 : 1;
|
|
185
|
+
const potentialDirection = prev + direction;
|
|
186
|
+
let nextSelectableOption = null;
|
|
187
|
+
switch (direction) {
|
|
188
|
+
case -1: {
|
|
189
|
+
nextSelectableOption = this.options.reduceRight(
|
|
190
|
+
(nextSelectableOption2, thisOption, index) => !nextSelectableOption2 && !thisOption.disabled && index < potentialDirection ? thisOption : nextSelectableOption2,
|
|
191
|
+
nextSelectableOption
|
|
192
|
+
);
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
case 1: {
|
|
196
|
+
nextSelectableOption = this.options.reduce(
|
|
197
|
+
(nextSelectableOption2, thisOption, index) => !nextSelectableOption2 && !thisOption.disabled && index > potentialDirection ? thisOption : nextSelectableOption2,
|
|
198
|
+
nextSelectableOption
|
|
199
|
+
);
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
1108
202
|
}
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
203
|
+
return this.options.indexOf(nextSelectableOption);
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Handles external changes to child options.
|
|
207
|
+
*
|
|
208
|
+
* @param source - the source object
|
|
209
|
+
* @param propertyName - the property
|
|
210
|
+
*
|
|
211
|
+
* @internal
|
|
212
|
+
*/
|
|
213
|
+
handleChange(source, propertyName) {
|
|
214
|
+
switch (propertyName) {
|
|
215
|
+
case "selected": {
|
|
216
|
+
if (_Listbox.slottedOptionFilter(source)) {
|
|
217
|
+
this.selectedIndex = this.options.indexOf(source);
|
|
1124
218
|
}
|
|
1125
|
-
}
|
|
1126
|
-
/**
|
|
1127
|
-
* Toggles the selected state of the provided options. If any provided items
|
|
1128
|
-
* are in an unselected state, all items are set to selected. If every
|
|
1129
|
-
* provided item is selected, they are all unselected.
|
|
1130
|
-
*
|
|
1131
|
-
* @internal
|
|
1132
|
-
*/
|
|
1133
|
-
toggleSelectedForAllCheckedOptions() {
|
|
1134
|
-
const enabledCheckedOptions = this.checkedOptions.filter(o => !o.disabled);
|
|
1135
|
-
const force = !enabledCheckedOptions.every(o => o.selected);
|
|
1136
|
-
enabledCheckedOptions.forEach(o => (o.selected = force));
|
|
1137
|
-
this.selectedIndex = this.options.indexOf(enabledCheckedOptions[enabledCheckedOptions.length - 1]);
|
|
1138
219
|
this.setSelectedOptions();
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
* @override
|
|
1142
|
-
* @internal
|
|
1143
|
-
*/
|
|
1144
|
-
typeaheadBufferChanged(prev, next) {
|
|
1145
|
-
if (!this.multiple) {
|
|
1146
|
-
super.typeaheadBufferChanged(prev, next);
|
|
1147
|
-
return;
|
|
1148
|
-
}
|
|
1149
|
-
if (this.$fastController.isConnected) {
|
|
1150
|
-
const typeaheadMatches = this.getTypeaheadMatches();
|
|
1151
|
-
const activeIndex = this.options.indexOf(typeaheadMatches[0]);
|
|
1152
|
-
if (activeIndex > -1) {
|
|
1153
|
-
this.activeIndex = activeIndex;
|
|
1154
|
-
this.uncheckAllOptions();
|
|
1155
|
-
this.checkActiveIndex();
|
|
1156
|
-
}
|
|
1157
|
-
this.typeAheadExpired = false;
|
|
1158
|
-
}
|
|
1159
|
-
}
|
|
1160
|
-
/**
|
|
1161
|
-
* Unchecks all options.
|
|
1162
|
-
*
|
|
1163
|
-
* @remarks
|
|
1164
|
-
* Multiple-selection mode only.
|
|
1165
|
-
*
|
|
1166
|
-
* @param preserveChecked - reset the rangeStartIndex
|
|
1167
|
-
*
|
|
1168
|
-
* @internal
|
|
1169
|
-
*/
|
|
1170
|
-
uncheckAllOptions(preserveChecked = false) {
|
|
1171
|
-
this.options.forEach(o => (o.checked = this.multiple ? false : undefined));
|
|
1172
|
-
if (!preserveChecked) {
|
|
1173
|
-
this.rangeStartIndex = -1;
|
|
1174
|
-
}
|
|
1175
|
-
}
|
|
1176
|
-
}
|
|
1177
|
-
__decorate([
|
|
1178
|
-
observable
|
|
1179
|
-
], ListboxElement.prototype, "activeIndex", void 0);
|
|
1180
|
-
__decorate([
|
|
1181
|
-
attr({ mode: "boolean" })
|
|
1182
|
-
], ListboxElement.prototype, "multiple", void 0);
|
|
1183
|
-
__decorate([
|
|
1184
|
-
attr({ converter: nullableNumberConverter })
|
|
1185
|
-
], ListboxElement.prototype, "size", void 0);
|
|
1186
|
-
|
|
1187
|
-
var __defProp = Object.defineProperty;
|
|
1188
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
1189
|
-
var result = void 0 ;
|
|
1190
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1191
|
-
if (decorator = decorators[i])
|
|
1192
|
-
result = (decorator(target, key, result) ) || result;
|
|
1193
|
-
if (result) __defProp(target, key, result);
|
|
1194
|
-
return result;
|
|
1195
|
-
};
|
|
1196
|
-
class Listbox extends ListboxElement {
|
|
1197
|
-
orientationChanged() {
|
|
1198
|
-
if (this.orientation === "horizontal") {
|
|
1199
|
-
this.addEventListener("keydown", this.#horizontalKeydownHandler);
|
|
1200
|
-
} else {
|
|
1201
|
-
this.removeEventListener("keydown", this.#horizontalKeydownHandler);
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
1202
222
|
}
|
|
1203
223
|
}
|
|
1204
224
|
/**
|
|
1205
|
-
*
|
|
225
|
+
* Moves focus to an option whose label matches characters typed by the user.
|
|
226
|
+
* Consecutive keystrokes are batched into a buffer of search text used
|
|
227
|
+
* to match against the set of options. If `TYPE_AHEAD_TIMEOUT_MS` passes
|
|
228
|
+
* between consecutive keystrokes, the search restarts.
|
|
229
|
+
*
|
|
230
|
+
* @param key - the key to be evaluated
|
|
231
|
+
*
|
|
232
|
+
* @internal
|
|
233
|
+
*/
|
|
234
|
+
handleTypeAhead(key) {
|
|
235
|
+
if (this.typeaheadTimeout) {
|
|
236
|
+
window.clearTimeout(this.typeaheadTimeout);
|
|
237
|
+
}
|
|
238
|
+
this.typeaheadTimeout = window.setTimeout(
|
|
239
|
+
() => this.typeaheadExpired = true,
|
|
240
|
+
_Listbox.TYPE_AHEAD_TIMEOUT_MS
|
|
241
|
+
);
|
|
242
|
+
this.typeaheadBuffer = `${this.typeaheadExpired ? "" : this.typeaheadBuffer}${key}`;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Handles `keydown` actions for listbox navigation and typeahead.
|
|
1206
246
|
*
|
|
1207
247
|
* @internal
|
|
1208
248
|
*/
|
|
1209
|
-
|
|
249
|
+
keydownHandler(e) {
|
|
1210
250
|
if (this.disabled) {
|
|
1211
251
|
return true;
|
|
1212
252
|
}
|
|
253
|
+
this.shouldSkipFocus = false;
|
|
1213
254
|
const key = e.key;
|
|
1214
255
|
switch (key) {
|
|
1215
|
-
case
|
|
256
|
+
case keyHome: {
|
|
257
|
+
if (!e.shiftKey) {
|
|
258
|
+
e.preventDefault();
|
|
259
|
+
this.selectFirstOption();
|
|
260
|
+
}
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
case keyArrowDown: {
|
|
1216
264
|
if (!e.shiftKey) {
|
|
1217
265
|
e.preventDefault();
|
|
1218
266
|
this.selectNextOption();
|
|
1219
267
|
}
|
|
1220
268
|
break;
|
|
1221
269
|
}
|
|
1222
|
-
case
|
|
270
|
+
case keyArrowUp: {
|
|
1223
271
|
if (!e.shiftKey) {
|
|
1224
272
|
e.preventDefault();
|
|
1225
273
|
this.selectPreviousOption();
|
|
1226
274
|
}
|
|
1227
275
|
break;
|
|
1228
276
|
}
|
|
277
|
+
case keyEnd: {
|
|
278
|
+
e.preventDefault();
|
|
279
|
+
this.selectLastOption();
|
|
280
|
+
break;
|
|
281
|
+
}
|
|
282
|
+
case keyTab: {
|
|
283
|
+
this.focusAndScrollOptionIntoView();
|
|
284
|
+
return true;
|
|
285
|
+
}
|
|
286
|
+
case keyEnter:
|
|
287
|
+
case keyEscape:
|
|
288
|
+
return true;
|
|
289
|
+
case keySpace:
|
|
290
|
+
if (this.typeaheadExpired) {
|
|
291
|
+
return true;
|
|
292
|
+
}
|
|
293
|
+
default: {
|
|
294
|
+
if (key.length === 1) {
|
|
295
|
+
this.handleTypeAhead(`${key}`);
|
|
296
|
+
}
|
|
297
|
+
return true;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Prevents `focusin` events from firing before `click` events when the
|
|
303
|
+
* element is unfocused.
|
|
304
|
+
*
|
|
305
|
+
* @internal
|
|
306
|
+
*/
|
|
307
|
+
mousedownHandler(_) {
|
|
308
|
+
this.shouldSkipFocus = !this.contains(document.activeElement);
|
|
309
|
+
return true;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Switches between single-selection and multi-selection mode.
|
|
313
|
+
*
|
|
314
|
+
* @internal
|
|
315
|
+
*/
|
|
316
|
+
multipleChanged(_, next) {
|
|
317
|
+
this.ariaMultiSelectable = next ? "true" : null;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Updates the list of selected options when the `selectedIndex` changes.
|
|
321
|
+
*
|
|
322
|
+
* @param prev - the previous selected index value
|
|
323
|
+
* @param next - the current selected index value
|
|
324
|
+
*
|
|
325
|
+
* @internal
|
|
326
|
+
*/
|
|
327
|
+
selectedIndexChanged(prev, next) {
|
|
328
|
+
if (!this.hasSelectableOptions) {
|
|
329
|
+
this.selectedIndex = -1;
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
if (this.options[this.selectedIndex]?.disabled && typeof prev === "number") {
|
|
333
|
+
const selectableIndex = this.getSelectableIndex(prev, next);
|
|
334
|
+
const newNext = selectableIndex > -1 ? selectableIndex : prev;
|
|
335
|
+
this.selectedIndex = newNext;
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
this.setSelectedOptions();
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Updates the selectedness of each option when the list of selected options changes.
|
|
342
|
+
*
|
|
343
|
+
* @internal
|
|
344
|
+
*/
|
|
345
|
+
selectedOptionsChanged(_, next) {
|
|
346
|
+
const filteredNext = next.filter(_Listbox.slottedOptionFilter);
|
|
347
|
+
this.options.forEach((o) => {
|
|
348
|
+
const notifier = Observable.getNotifier(o);
|
|
349
|
+
notifier.unsubscribe(this, "selected");
|
|
350
|
+
o.selected = filteredNext.includes(o);
|
|
351
|
+
notifier.subscribe(this, "selected");
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Moves focus to the first selectable option.
|
|
356
|
+
*
|
|
357
|
+
* @public
|
|
358
|
+
*/
|
|
359
|
+
selectFirstOption() {
|
|
360
|
+
if (!this.disabled) {
|
|
361
|
+
this.selectedIndex = this.options.findIndex((o) => !o.disabled);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Moves focus to the last selectable option.
|
|
366
|
+
*
|
|
367
|
+
* @internal
|
|
368
|
+
*/
|
|
369
|
+
selectLastOption() {
|
|
370
|
+
if (!this.disabled) {
|
|
371
|
+
this.selectedIndex = findLastIndex(this.options, (o) => !o.disabled);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Moves focus to the next selectable option.
|
|
376
|
+
*
|
|
377
|
+
* @internal
|
|
378
|
+
*/
|
|
379
|
+
selectNextOption() {
|
|
380
|
+
if (!this.disabled && this.selectedIndex < this.options.length - 1) {
|
|
381
|
+
this.selectedIndex += 1;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Moves focus to the previous selectable option.
|
|
386
|
+
*
|
|
387
|
+
* @internal
|
|
388
|
+
*/
|
|
389
|
+
selectPreviousOption() {
|
|
390
|
+
if (!this.disabled && this.selectedIndex > 0) {
|
|
391
|
+
this.selectedIndex = this.selectedIndex - 1;
|
|
1229
392
|
}
|
|
1230
393
|
}
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
394
|
+
/**
|
|
395
|
+
* Updates the selected index to match the first selected option.
|
|
396
|
+
*
|
|
397
|
+
* @internal
|
|
398
|
+
*/
|
|
399
|
+
setDefaultSelectedOption() {
|
|
400
|
+
this.selectedIndex = this.options.findIndex((el) => el.defaultSelected);
|
|
1234
401
|
}
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
402
|
+
/**
|
|
403
|
+
* Sets an option as selected and gives it focus.
|
|
404
|
+
*
|
|
405
|
+
* @public
|
|
406
|
+
*/
|
|
407
|
+
setSelectedOptions() {
|
|
408
|
+
if (this.options.length) {
|
|
409
|
+
this.selectedOptions = [this.options[this.selectedIndex]];
|
|
410
|
+
this.ariaActiveDescendant = this.firstSelectedOption?.id ?? "";
|
|
411
|
+
this.focusAndScrollOptionIntoView();
|
|
1239
412
|
}
|
|
1240
413
|
}
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
414
|
+
/**
|
|
415
|
+
* Updates the list of options and resets the selected option when the slotted option content changes.
|
|
416
|
+
*
|
|
417
|
+
* @internal
|
|
418
|
+
*/
|
|
419
|
+
slottedOptionsChanged(_, next) {
|
|
420
|
+
this.options = next.reduce((options, item) => {
|
|
421
|
+
if (isListboxOption(item)) {
|
|
422
|
+
options.push(item);
|
|
423
|
+
}
|
|
424
|
+
return options;
|
|
425
|
+
}, []);
|
|
426
|
+
const setSize = `${this.options.length}`;
|
|
427
|
+
this.options.forEach((option, index) => {
|
|
428
|
+
if (!option.id) {
|
|
429
|
+
option.id = uniqueId("option-");
|
|
1245
430
|
}
|
|
431
|
+
option.ariaPosInSet = `${index + 1}`;
|
|
432
|
+
option.ariaSetSize = setSize;
|
|
1246
433
|
});
|
|
434
|
+
if (this.$fastController.isConnected) {
|
|
435
|
+
this.setSelectedOptions();
|
|
436
|
+
this.setDefaultSelectedOption();
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Updates the filtered list of options when the typeahead buffer changes.
|
|
441
|
+
*
|
|
442
|
+
* @internal
|
|
443
|
+
*/
|
|
444
|
+
typeaheadBufferChanged(_prev, _next) {
|
|
445
|
+
if (this.$fastController.isConnected) {
|
|
446
|
+
const typeaheadMatches = this.getTypeaheadMatches();
|
|
447
|
+
if (typeaheadMatches.length) {
|
|
448
|
+
const selectedIndex = this.options.indexOf(typeaheadMatches[0]);
|
|
449
|
+
if (selectedIndex > -1) {
|
|
450
|
+
this.selectedIndex = selectedIndex;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
this.typeaheadExpired = false;
|
|
454
|
+
}
|
|
1247
455
|
}
|
|
456
|
+
};
|
|
457
|
+
// @ts-expect-error Type is incorrectly non-optional
|
|
458
|
+
__decorateClass([
|
|
459
|
+
attr({ mode: "boolean" })
|
|
460
|
+
], _Listbox.prototype, "disabled");
|
|
461
|
+
__decorateClass([
|
|
462
|
+
observable
|
|
463
|
+
], _Listbox.prototype, "selectedIndex");
|
|
464
|
+
__decorateClass([
|
|
465
|
+
observable
|
|
466
|
+
], _Listbox.prototype, "selectedOptions");
|
|
467
|
+
__decorateClass([
|
|
468
|
+
observable
|
|
469
|
+
], _Listbox.prototype, "slottedOptions");
|
|
470
|
+
__decorateClass([
|
|
471
|
+
observable
|
|
472
|
+
], _Listbox.prototype, "typeaheadBuffer");
|
|
473
|
+
let Listbox = _Listbox;
|
|
474
|
+
class DelegatesARIAListbox {
|
|
1248
475
|
}
|
|
476
|
+
// @ts-expect-error Type is incorrectly non-optional
|
|
1249
477
|
__decorateClass([
|
|
1250
|
-
|
|
1251
|
-
],
|
|
478
|
+
observable
|
|
479
|
+
], DelegatesARIAListbox.prototype, "ariaActiveDescendant");
|
|
480
|
+
// @ts-expect-error Type is incorrectly non-optional
|
|
1252
481
|
__decorateClass([
|
|
1253
|
-
|
|
1254
|
-
],
|
|
482
|
+
observable
|
|
483
|
+
], DelegatesARIAListbox.prototype, "ariaDisabled");
|
|
484
|
+
// @ts-expect-error Type is incorrectly non-optional
|
|
1255
485
|
__decorateClass([
|
|
1256
|
-
|
|
1257
|
-
],
|
|
486
|
+
observable
|
|
487
|
+
], DelegatesARIAListbox.prototype, "ariaExpanded");
|
|
488
|
+
// @ts-expect-error Type is incorrectly non-optional
|
|
489
|
+
__decorateClass([
|
|
490
|
+
observable
|
|
491
|
+
], DelegatesARIAListbox.prototype, "ariaMultiSelectable");
|
|
492
|
+
applyMixins(DelegatesARIAListbox, ARIAGlobalStatesAndProperties);
|
|
493
|
+
applyMixins(Listbox, DelegatesARIAListbox);
|
|
1258
494
|
|
|
1259
|
-
export {
|
|
495
|
+
export { Listbox as L };
|