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