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