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