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