@six-group/ui-library 3.0.0-beta.1.7 → 3.0.0-beta.1.8
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/dist/cjs/{event-listeners-4a8d66d5.js → event-listeners-74715e62.js} +38 -38
- package/dist/cjs/{execution-control-3bc9c7c4.js → execution-control-46f388e0.js} +35 -35
- package/dist/cjs/{focus-visible-b08d956f.js → focus-visible-0b352c74.js} +40 -40
- package/dist/cjs/{form-control-9e4dffd1.js → form-control-866bbece.js} +25 -25
- package/dist/cjs/{modal-a9679ddf.js → modal-48d42228.js} +41 -41
- package/dist/cjs/{popover-e3781f5a.js → popover-1d2a037c.js} +95 -95
- package/dist/cjs/{scroll-5b8676ba.js → scroll-76e6f5d7.js} +57 -57
- package/dist/cjs/set-attributes_2.cjs.entry.js +57 -57
- package/dist/cjs/six-alert.cjs.entry.js +131 -131
- package/dist/cjs/six-avatar.cjs.entry.js +28 -28
- package/dist/cjs/six-badge.cjs.entry.js +26 -26
- package/dist/cjs/six-button.cjs.entry.js +97 -97
- package/dist/cjs/six-card.cjs.entry.js +8 -8
- package/dist/cjs/six-checkbox.cjs.entry.js +152 -152
- package/dist/cjs/six-datepicker.cjs.entry.js +1189 -1189
- package/dist/cjs/six-details.cjs.entry.js +139 -139
- package/dist/cjs/six-dialog.cjs.entry.js +152 -152
- package/dist/cjs/six-drawer.cjs.entry.js +174 -174
- package/dist/cjs/six-dropdown_3.cjs.entry.js +728 -728
- package/dist/cjs/six-error-page.cjs.entry.js +94 -94
- package/dist/cjs/six-file-list-item.cjs.entry.js +38 -38
- package/dist/cjs/six-file-list.cjs.entry.js +8 -8
- package/dist/cjs/six-file-upload.cjs.entry.js +96 -96
- package/dist/cjs/six-footer.cjs.entry.js +8 -8
- package/dist/cjs/six-form.cjs.entry.js +219 -219
- package/dist/cjs/six-group-label.cjs.entry.js +46 -46
- package/dist/cjs/six-header.cjs.entry.js +149 -149
- package/dist/cjs/six-icon-button.cjs.entry.js +33 -33
- package/dist/cjs/six-icon.cjs.entry.js +24 -24
- package/dist/cjs/six-input.cjs.entry.js +230 -230
- package/dist/cjs/six-item-picker.cjs.entry.js +361 -361
- package/dist/cjs/six-language-switcher.cjs.entry.js +52 -52
- package/dist/cjs/six-layout-grid.cjs.entry.js +19 -19
- package/dist/cjs/six-main-container.cjs.entry.js +11 -11
- package/dist/cjs/six-menu-divider.cjs.entry.js +8 -8
- package/dist/cjs/six-menu-label.cjs.entry.js +8 -8
- package/dist/cjs/six-picto.cjs.entry.js +15 -15
- package/dist/cjs/six-progress-bar.cjs.entry.js +17 -17
- package/dist/cjs/six-progress-ring.cjs.entry.js +31 -31
- package/dist/cjs/six-radio.cjs.entry.js +121 -121
- package/dist/cjs/six-range.cjs.entry.js +198 -198
- package/dist/cjs/six-root.cjs.entry.js +34 -34
- package/dist/cjs/six-search-field.cjs.entry.js +43 -43
- package/dist/cjs/six-select.cjs.entry.js +447 -447
- package/dist/cjs/six-sidebar-item-group.cjs.entry.js +42 -42
- package/dist/cjs/six-sidebar-item.cjs.entry.js +18 -18
- package/dist/cjs/six-sidebar.cjs.entry.js +171 -171
- package/dist/cjs/six-spinner.cjs.entry.js +16 -16
- package/dist/cjs/six-switch.cjs.entry.js +100 -100
- package/dist/cjs/six-tab-group.cjs.entry.js +226 -226
- package/dist/cjs/six-tab-panel.cjs.entry.js +17 -17
- package/dist/cjs/six-tab.cjs.entry.js +42 -42
- package/dist/cjs/six-table-cell_4.cjs.entry.js +70 -70
- package/dist/cjs/six-table.cjs.entry.js +145 -145
- package/dist/cjs/six-tag.cjs.entry.js +40 -40
- package/dist/cjs/six-textarea.cjs.entry.js +211 -211
- package/dist/cjs/six-tile.cjs.entry.js +89 -89
- package/dist/cjs/six-timepicker.cjs.entry.js +489 -489
- package/dist/cjs/{six-timepicker.types-c58cc88b.js → six-timepicker.types-c19ebff3.js} +43 -43
- package/dist/cjs/six-tooltip.cjs.entry.js +172 -172
- package/dist/cjs/{slot-8abe833c.js → slot-ad537f24.js} +42 -42
- package/dist/cjs/{types-65e5c95b.js → types-581e8ff0.js} +12 -12
- package/dist/cjs/{types-0c28e484.js → types-64878648.js} +12 -12
- package/dist/collection/components/six-alert/six-alert.js +366 -366
- package/dist/collection/components/six-avatar/six-avatar.js +131 -131
- package/dist/collection/components/six-badge/six-badge.js +101 -101
- package/dist/collection/components/six-button/six-button.js +466 -466
- package/dist/collection/components/six-card/six-card.js +21 -21
- package/dist/collection/components/six-checkbox/six-checkbox.js +550 -550
- package/dist/collection/components/six-datepicker/components/day-selection.js +13 -13
- package/dist/collection/components/six-datepicker/components/month-selection.js +12 -12
- package/dist/collection/components/six-datepicker/components/year-selection.js +10 -10
- package/dist/collection/components/six-datepicker/six-date-formats.js +23 -23
- package/dist/collection/components/six-datepicker/six-datepicker.js +1343 -1343
- package/dist/collection/components/six-datepicker/test/six-datepicker.test-helpers.js +16 -16
- package/dist/collection/components/six-details/six-details.js +432 -432
- package/dist/collection/components/six-dialog/six-dialog.js +401 -401
- package/dist/collection/components/six-drawer/six-drawer.js +458 -458
- package/dist/collection/components/six-dropdown/six-dropdown.js +939 -939
- package/dist/collection/components/six-error-page/six-error-page.js +199 -199
- package/dist/collection/components/six-file-list/six-file-list.js +20 -20
- package/dist/collection/components/six-file-list-item/six-file-list-item.js +203 -203
- package/dist/collection/components/six-file-upload/six-file-upload.js +272 -272
- package/dist/collection/components/six-footer/six-footer.js +21 -21
- package/dist/collection/components/six-form/six-form.js +408 -408
- package/dist/collection/components/six-group-label/six-group-label.js +166 -166
- package/dist/collection/components/six-header/six-header.js +420 -420
- package/dist/collection/components/six-icon/six-icon.js +77 -77
- package/dist/collection/components/six-icon-button/six-icon-button.js +142 -142
- package/dist/collection/components/six-input/six-input.js +1141 -1141
- package/dist/collection/components/six-item-picker/six-item-picker.js +688 -688
- package/dist/collection/components/six-item-picker/types.js +13 -13
- package/dist/collection/components/six-language-switcher/six-language-switcher.js +128 -128
- package/dist/collection/components/six-layout-grid/six-layout-grid.js +52 -52
- package/dist/collection/components/six-main-container/six-main-container.js +53 -53
- package/dist/collection/components/six-menu/six-menu.js +406 -406
- package/dist/collection/components/six-menu-divider/six-menu-divider.js +22 -22
- package/dist/collection/components/six-menu-item/six-menu-item.js +177 -177
- package/dist/collection/components/six-menu-label/six-menu-label.js +25 -25
- package/dist/collection/components/six-picto/six-picto.js +50 -50
- package/dist/collection/components/six-progress-bar/six-progress-bar.js +77 -77
- package/dist/collection/components/six-progress-ring/six-progress-ring.js +111 -111
- package/dist/collection/components/six-radio/six-radio.js +410 -410
- package/dist/collection/components/six-range/six-range.js +620 -620
- package/dist/collection/components/six-root/six-root.js +167 -167
- package/dist/collection/components/six-search-field/six-search-field.js +171 -171
- package/dist/collection/components/six-select/six-select.js +1105 -1105
- package/dist/collection/components/six-sidebar/six-sidebar.js +455 -455
- package/dist/collection/components/six-sidebar-item/six-sidebar-item.js +89 -89
- package/dist/collection/components/six-sidebar-item-group/six-sidebar-item-group.js +158 -158
- package/dist/collection/components/six-spinner/six-spinner.js +55 -55
- package/dist/collection/components/six-stage-indicator/six-stage-indicator.js +46 -46
- package/dist/collection/components/six-switch/six-switch.js +393 -393
- package/dist/collection/components/six-tab/six-tab.js +198 -198
- package/dist/collection/components/six-tab-group/six-tab-group.js +362 -362
- package/dist/collection/components/six-tab-panel/six-tab-panel.js +75 -75
- package/dist/collection/components/six-table/six-table.js +209 -209
- package/dist/collection/components/six-table/test/helpers.js +13 -13
- package/dist/collection/components/six-table/types.js +8 -8
- package/dist/collection/components/six-table/util/filter-by.js +34 -34
- package/dist/collection/components/six-table/util/from-data.js +33 -33
- package/dist/collection/components/six-table/util/is.js +3 -3
- package/dist/collection/components/six-table/util/quick-filter-by.js +13 -13
- package/dist/collection/components/six-table/util/sort-by.js +25 -25
- package/dist/collection/components/six-table-cell/six-table-cell.js +21 -21
- package/dist/collection/components/six-table-header/six-table-header.js +21 -21
- package/dist/collection/components/six-table-header-cell/get-next-state.js +7 -7
- package/dist/collection/components/six-table-header-cell/icons.js +12 -12
- package/dist/collection/components/six-table-header-cell/six-table-header-cell.js +174 -174
- package/dist/collection/components/six-table-header-cell/types.js +13 -13
- package/dist/collection/components/six-table-header-cell/util/create-model.js +6 -6
- package/dist/collection/components/six-table-header-cell/util/get-next-state.js +7 -7
- package/dist/collection/components/six-table-row/six-table-row.js +21 -21
- package/dist/collection/components/six-tag/six-tag.js +157 -157
- package/dist/collection/components/six-textarea/six-textarea.js +912 -912
- package/dist/collection/components/six-tile/six-tile.js +315 -315
- package/dist/collection/components/six-timepicker/six-time-format.js +14 -14
- package/dist/collection/components/six-timepicker/six-timepicker.js +980 -980
- package/dist/collection/components/six-timepicker/six-timepicker.types.js +40 -40
- package/dist/collection/components/six-tooltip/six-tooltip.js +435 -435
- package/dist/collection/functional-components/form-control/form-control.js +28 -28
- package/dist/collection/index.js +1 -1
- package/dist/collection/testUtil/delay.js +3 -3
- package/dist/collection/utils/as-array.js +1 -1
- package/dist/collection/utils/date-util.js +712 -712
- package/dist/collection/utils/event-listeners.js +39 -39
- package/dist/collection/utils/execution-control.js +38 -38
- package/dist/collection/utils/focus-visible.js +41 -41
- package/dist/collection/utils/matchers.js +2 -2
- package/dist/collection/utils/modal.js +28 -28
- package/dist/collection/utils/offset.js +13 -13
- package/dist/collection/utils/popover.js +113 -113
- package/dist/collection/utils/scroll.js +47 -47
- package/dist/collection/utils/slot.js +59 -59
- package/dist/collection/utils/support.js +15 -15
- package/dist/collection/utils/tabbable.js +22 -22
- package/dist/collection/utils/testing.js +38 -38
- package/dist/collection/utils/time.util.js +74 -74
- package/dist/collection/utils/type-check.js +5 -5
- package/dist/collection/utils/types.js +1 -1
- package/dist/collection/wrappers/set-attributes/set-attributes.js +68 -68
- package/dist/components.json +1 -1
- package/dist/custom-elements/index.js +7595 -7595
- package/dist/esm/{event-listeners-1bef934e.js → event-listeners-570a24ea.js} +38 -38
- package/dist/esm/{execution-control-235f5126.js → execution-control-1a60d709.js} +35 -35
- package/dist/esm/{focus-visible-4b7946aa.js → focus-visible-97933ea9.js} +40 -40
- package/dist/esm/{form-control-17478ad2.js → form-control-24f446af.js} +25 -25
- package/dist/esm/{modal-e5709f6b.js → modal-5ebdc320.js} +41 -41
- package/dist/esm/polyfills/core-js.js +0 -0
- package/dist/esm/polyfills/dom.js +0 -0
- package/dist/esm/polyfills/es5-html-element.js +0 -0
- package/dist/esm/polyfills/index.js +0 -0
- package/dist/esm/polyfills/system.js +0 -0
- package/dist/esm/{popover-5a51f84d.js → popover-1c7a1139.js} +95 -95
- package/dist/esm/{scroll-99b214c2.js → scroll-180b53fd.js} +57 -57
- package/dist/esm/set-attributes_2.entry.js +57 -57
- package/dist/esm/six-alert.entry.js +131 -131
- package/dist/esm/six-avatar.entry.js +28 -28
- package/dist/esm/six-badge.entry.js +26 -26
- package/dist/esm/six-button.entry.js +97 -97
- package/dist/esm/six-card.entry.js +8 -8
- package/dist/esm/six-checkbox.entry.js +152 -152
- package/dist/esm/six-datepicker.entry.js +1189 -1189
- package/dist/esm/six-details.entry.js +139 -139
- package/dist/esm/six-dialog.entry.js +152 -152
- package/dist/esm/six-drawer.entry.js +174 -174
- package/dist/esm/six-dropdown_3.entry.js +728 -728
- package/dist/esm/six-error-page.entry.js +94 -94
- package/dist/esm/six-file-list-item.entry.js +38 -38
- package/dist/esm/six-file-list.entry.js +8 -8
- package/dist/esm/six-file-upload.entry.js +96 -96
- package/dist/esm/six-footer.entry.js +8 -8
- package/dist/esm/six-form.entry.js +219 -219
- package/dist/esm/six-group-label.entry.js +46 -46
- package/dist/esm/six-header.entry.js +149 -149
- package/dist/esm/six-icon-button.entry.js +33 -33
- package/dist/esm/six-icon.entry.js +24 -24
- package/dist/esm/six-input.entry.js +230 -230
- package/dist/esm/six-item-picker.entry.js +361 -361
- package/dist/esm/six-language-switcher.entry.js +52 -52
- package/dist/esm/six-layout-grid.entry.js +19 -19
- package/dist/esm/six-main-container.entry.js +11 -11
- package/dist/esm/six-menu-divider.entry.js +8 -8
- package/dist/esm/six-menu-label.entry.js +8 -8
- package/dist/esm/six-picto.entry.js +15 -15
- package/dist/esm/six-progress-bar.entry.js +17 -17
- package/dist/esm/six-progress-ring.entry.js +31 -31
- package/dist/esm/six-radio.entry.js +121 -121
- package/dist/esm/six-range.entry.js +198 -198
- package/dist/esm/six-root.entry.js +34 -34
- package/dist/esm/six-search-field.entry.js +43 -43
- package/dist/esm/six-select.entry.js +447 -447
- package/dist/esm/six-sidebar-item-group.entry.js +42 -42
- package/dist/esm/six-sidebar-item.entry.js +18 -18
- package/dist/esm/six-sidebar.entry.js +171 -171
- package/dist/esm/six-spinner.entry.js +16 -16
- package/dist/esm/six-switch.entry.js +100 -100
- package/dist/esm/six-tab-group.entry.js +226 -226
- package/dist/esm/six-tab-panel.entry.js +17 -17
- package/dist/esm/six-tab.entry.js +42 -42
- package/dist/esm/six-table-cell_4.entry.js +70 -70
- package/dist/esm/six-table.entry.js +145 -145
- package/dist/esm/six-tag.entry.js +40 -40
- package/dist/esm/six-textarea.entry.js +211 -211
- package/dist/esm/six-tile.entry.js +89 -89
- package/dist/esm/six-timepicker.entry.js +489 -489
- package/dist/esm/{six-timepicker.types-cd6bac03.js → six-timepicker.types-e161a447.js} +43 -43
- package/dist/esm/six-tooltip.entry.js +172 -172
- package/dist/esm/{slot-5253e199.js → slot-6f3984c7.js} +42 -42
- package/dist/esm/{types-a37c1695.js → types-4b10b413.js} +12 -12
- package/dist/esm/{types-33d15673.js → types-ed860f7c.js} +12 -12
- package/dist/types/components/six-alert/six-alert.d.ts +60 -60
- package/dist/types/components/six-avatar/six-avatar.d.ts +27 -27
- package/dist/types/components/six-badge/six-badge.d.ts +20 -20
- package/dist/types/components/six-button/six-button.d.ts +69 -69
- package/dist/types/components/six-card/six-card.d.ts +9 -9
- package/dist/types/components/six-checkbox/six-checkbox.d.ts +86 -86
- package/dist/types/components/six-datepicker/components/day-selection.d.ts +5 -5
- package/dist/types/components/six-datepicker/components/month-selection.d.ts +5 -5
- package/dist/types/components/six-datepicker/components/year-selection.d.ts +5 -5
- package/dist/types/components/six-datepicker/six-date-formats.d.ts +22 -22
- package/dist/types/components/six-datepicker/six-datepicker.d.ts +214 -214
- package/dist/types/components/six-datepicker/test/six-datepicker.test-helpers.d.ts +1 -1
- package/dist/types/components/six-details/six-details.d.ts +61 -61
- package/dist/types/components/six-dialog/six-dialog.d.ts +75 -75
- package/dist/types/components/six-drawer/six-drawer.d.ts +82 -82
- package/dist/types/components/six-dropdown/six-dropdown.d.ts +140 -140
- package/dist/types/components/six-error-page/six-error-page.d.ts +27 -27
- package/dist/types/components/six-file-list/six-file-list.d.ts +8 -8
- package/dist/types/components/six-file-list-item/six-file-list-item.d.ts +35 -35
- package/dist/types/components/six-file-upload/six-file-upload.d.ts +42 -42
- package/dist/types/components/six-footer/six-footer.d.ts +9 -9
- package/dist/types/components/six-form/six-form.d.ts +69 -69
- package/dist/types/components/six-group-label/six-group-label.d.ts +37 -37
- package/dist/types/components/six-header/six-header.d.ts +90 -90
- package/dist/types/components/six-icon/six-icon.d.ts +13 -13
- package/dist/types/components/six-icon-button/six-icon-button.d.ts +28 -28
- package/dist/types/components/six-input/six-input.d.ts +165 -165
- package/dist/types/components/six-item-picker/six-item-picker.d.ts +106 -106
- package/dist/types/components/six-item-picker/types.d.ts +11 -11
- package/dist/types/components/six-language-switcher/six-language-switcher.d.ts +25 -25
- package/dist/types/components/six-layout-grid/six-layout-grid.d.ts +14 -14
- package/dist/types/components/six-main-container/six-main-container.d.ts +16 -16
- package/dist/types/components/six-menu/six-menu.d.ts +81 -81
- package/dist/types/components/six-menu-divider/six-menu-divider.d.ts +11 -11
- package/dist/types/components/six-menu-item/six-menu-item.d.ts +36 -36
- package/dist/types/components/six-menu-label/six-menu-label.d.ts +13 -13
- package/dist/types/components/six-picto/six-picto.d.ts +14 -14
- package/dist/types/components/six-progress-bar/six-progress-bar.d.ts +19 -19
- package/dist/types/components/six-progress-ring/six-progress-ring.d.ts +24 -24
- package/dist/types/components/six-radio/six-radio.d.ts +66 -66
- package/dist/types/components/six-range/six-range.d.ts +101 -101
- package/dist/types/components/six-root/six-root.d.ts +34 -34
- package/dist/types/components/six-search-field/six-search-field.d.ts +32 -32
- package/dist/types/components/six-select/six-select.d.ts +163 -163
- package/dist/types/components/six-sidebar/six-sidebar.d.ts +55 -55
- package/dist/types/components/six-sidebar-item/six-sidebar-item.d.ts +15 -15
- package/dist/types/components/six-sidebar-item-group/six-sidebar-item-group.d.ts +26 -26
- package/dist/types/components/six-spinner/six-spinner.d.ts +15 -15
- package/dist/types/components/six-stage-indicator/six-stage-indicator.d.ts +6 -6
- package/dist/types/components/six-switch/six-switch.d.ts +62 -62
- package/dist/types/components/six-tab/six-tab.d.ts +35 -35
- package/dist/types/components/six-tab-group/six-tab-group.d.ts +62 -62
- package/dist/types/components/six-tab-panel/six-tab-panel.d.ts +19 -19
- package/dist/types/components/six-table/six-table.d.ts +30 -30
- package/dist/types/components/six-table/test/helpers.d.ts +2 -2
- package/dist/types/components/six-table/types.d.ts +33 -33
- package/dist/types/components/six-table/util/filter-by.d.ts +2 -2
- package/dist/types/components/six-table/util/from-data.d.ts +8 -8
- package/dist/types/components/six-table/util/is.d.ts +3 -3
- package/dist/types/components/six-table/util/quick-filter-by.d.ts +2 -2
- package/dist/types/components/six-table/util/sort-by.d.ts +2 -2
- package/dist/types/components/six-table-cell/six-table-cell.d.ts +9 -9
- package/dist/types/components/six-table-header/six-table-header.d.ts +9 -9
- package/dist/types/components/six-table-header-cell/get-next-state.d.ts +2 -2
- package/dist/types/components/six-table-header-cell/icons.d.ts +3 -3
- package/dist/types/components/six-table-header-cell/six-table-header-cell.d.ts +32 -32
- package/dist/types/components/six-table-header-cell/types.d.ts +11 -11
- package/dist/types/components/six-table-header-cell/util/create-model.d.ts +4 -4
- package/dist/types/components/six-table-header-cell/util/get-next-state.d.ts +3 -3
- package/dist/types/components/six-table-row/six-table-row.d.ts +9 -9
- package/dist/types/components/six-tag/six-tag.d.ts +30 -30
- package/dist/types/components/six-textarea/six-textarea.d.ts +134 -134
- package/dist/types/components/six-tile/six-tile.d.ts +40 -40
- package/dist/types/components/six-timepicker/six-time-format.d.ts +13 -13
- package/dist/types/components/six-timepicker/six-timepicker.d.ts +184 -184
- package/dist/types/components/six-timepicker/six-timepicker.types.d.ts +36 -36
- package/dist/types/components/six-tooltip/six-tooltip.d.ts +72 -72
- package/dist/types/functional-components/form-control/form-control.d.ts +34 -34
- package/dist/types/index.d.ts +1 -1
- package/dist/types/testUtil/delay.d.ts +1 -1
- package/dist/types/utils/as-array.d.ts +1 -1
- package/dist/types/utils/date-util.d.ts +194 -194
- package/dist/types/utils/event-listeners.d.ts +15 -15
- package/dist/types/utils/execution-control.d.ts +26 -26
- package/dist/types/utils/focus-visible.d.ts +6 -6
- package/dist/types/utils/matchers.d.ts +2 -2
- package/dist/types/utils/modal.d.ts +13 -13
- package/dist/types/utils/offset.d.ts +4 -4
- package/dist/types/utils/popover.d.ts +27 -27
- package/dist/types/utils/scroll.d.ts +3 -3
- package/dist/types/utils/slot.d.ts +9 -9
- package/dist/types/utils/support.d.ts +1 -1
- package/dist/types/utils/tabbable.d.ts +2 -2
- package/dist/types/utils/testing.d.ts +2 -2
- package/dist/types/utils/time.util.d.ts +10 -10
- package/dist/types/utils/type-check.d.ts +4 -4
- package/dist/types/utils/types.d.ts +4 -4
- package/dist/types/wrappers/set-attributes/set-attributes.d.ts +9 -9
- package/dist/ui-library/{p-a8c225f2.entry.js → p-007bc8e8.entry.js} +1 -1
- package/dist/ui-library/{p-f9c0cfb7.entry.js → p-044b784e.entry.js} +1 -1
- package/dist/ui-library/{p-c733dead.js → p-0786fa7c.js} +0 -0
- package/dist/ui-library/{p-12cc24c3.js → p-07d1e830.js} +0 -0
- package/dist/ui-library/{p-48ea4419.entry.js → p-09cb13fa.entry.js} +1 -1
- package/dist/ui-library/{p-e96dcf96.entry.js → p-0c596054.entry.js} +1 -1
- package/dist/ui-library/{p-a77a6442.entry.js → p-1b8dc7b7.entry.js} +1 -1
- package/dist/ui-library/{p-68d31736.js → p-25a3bf57.js} +0 -0
- package/dist/ui-library/{p-ebaea182.entry.js → p-281e8c2d.entry.js} +1 -1
- package/dist/ui-library/{p-9f2dc381.entry.js → p-2924f82f.entry.js} +1 -1
- package/dist/ui-library/{p-ea1fcff2.entry.js → p-2d7ed407.entry.js} +1 -1
- package/dist/ui-library/{p-89f68e76.entry.js → p-4162dcdd.entry.js} +1 -1
- package/dist/ui-library/{p-6f67f986.entry.js → p-4d3a4e93.entry.js} +1 -1
- package/dist/ui-library/{p-8bd0873f.entry.js → p-4ed023b8.entry.js} +1 -1
- package/dist/ui-library/{p-af3d757c.js → p-4f8394d7.js} +0 -0
- package/dist/ui-library/{p-1b92cc7a.entry.js → p-530ea6ec.entry.js} +1 -1
- package/dist/ui-library/{p-19543c96.entry.js → p-531ab886.entry.js} +1 -1
- package/dist/ui-library/{p-fdb455d7.entry.js → p-54c48654.entry.js} +1 -1
- package/dist/ui-library/{p-c948d3db.entry.js → p-55c64cbc.entry.js} +1 -1
- package/dist/ui-library/{p-1c9f0dc6.js → p-5f1c6a5f.js} +0 -0
- package/dist/ui-library/{p-60491176.entry.js → p-675a8243.entry.js} +1 -1
- package/dist/ui-library/{p-b9fb8455.entry.js → p-6d622ed0.entry.js} +1 -1
- package/dist/ui-library/{p-572e3690.js → p-75297ad7.js} +0 -0
- package/dist/ui-library/{p-2ff97cdf.entry.js → p-90b26447.entry.js} +1 -1
- package/dist/ui-library/{p-fcd2356c.entry.js → p-93945629.entry.js} +1 -1
- package/dist/ui-library/{p-7735d99f.js → p-9a860acc.js} +0 -0
- package/dist/ui-library/{p-4cc01afc.entry.js → p-aa37e45a.entry.js} +1 -1
- package/dist/ui-library/{p-191f958b.js → p-b1e66136.js} +0 -0
- package/dist/ui-library/{p-c09dc3a9.js → p-b4dfb7cf.js} +0 -0
- package/dist/ui-library/{p-968c5169.entry.js → p-c24292b3.entry.js} +1 -1
- package/dist/ui-library/{p-ed21cc57.entry.js → p-cd79de73.entry.js} +1 -1
- package/dist/ui-library/{p-34e6d8e8.js → p-d12c6092.js} +0 -0
- package/dist/ui-library/{p-f0e91e17.entry.js → p-d28ac80a.entry.js} +1 -1
- package/dist/ui-library/{p-5ead7b2f.entry.js → p-d837e5a8.entry.js} +1 -1
- package/dist/ui-library/{p-ec1ecc2a.entry.js → p-dd3cae68.entry.js} +1 -1
- package/dist/ui-library/{p-044c6bf9.js → p-eb8f05a9.js} +0 -0
- package/dist/ui-library/ui-library.esm.js +1 -1
- package/package.json +1 -1
|
@@ -3,747 +3,747 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-341df120.js');
|
|
6
|
-
const scroll = require('./scroll-
|
|
7
|
-
const popover = require('./popover-
|
|
8
|
-
const eventListeners = require('./event-listeners-
|
|
9
|
-
const slot = require('./slot-
|
|
10
|
-
const executionControl = require('./execution-control-
|
|
6
|
+
const scroll = require('./scroll-76e6f5d7.js');
|
|
7
|
+
const popover = require('./popover-1d2a037c.js');
|
|
8
|
+
const eventListeners = require('./event-listeners-74715e62.js');
|
|
9
|
+
const slot = require('./slot-ad537f24.js');
|
|
10
|
+
const executionControl = require('./execution-control-46f388e0.js');
|
|
11
11
|
|
|
12
|
-
function isTabbable(el) {
|
|
13
|
-
const tabIndex = el.tabIndex;
|
|
14
|
-
return tabIndex > -1;
|
|
15
|
-
}
|
|
16
|
-
function getNearestTabbableElement(el) {
|
|
17
|
-
// Check the element
|
|
18
|
-
if (isTabbable(el)) {
|
|
19
|
-
return el;
|
|
20
|
-
}
|
|
21
|
-
// Check the element's shadow root
|
|
22
|
-
if (el.shadowRoot) {
|
|
23
|
-
const tabbableShadowChild = [...el.shadowRoot.children].find(isTabbable);
|
|
24
|
-
if (tabbableShadowChild) {
|
|
25
|
-
return tabbableShadowChild;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
// Check the element's children
|
|
29
|
-
if (el.children) {
|
|
30
|
-
return [...el.children].map(getNearestTabbableElement)[0];
|
|
31
|
-
}
|
|
32
|
-
return null;
|
|
12
|
+
function isTabbable(el) {
|
|
13
|
+
const tabIndex = el.tabIndex;
|
|
14
|
+
return tabIndex > -1;
|
|
15
|
+
}
|
|
16
|
+
function getNearestTabbableElement(el) {
|
|
17
|
+
// Check the element
|
|
18
|
+
if (isTabbable(el)) {
|
|
19
|
+
return el;
|
|
20
|
+
}
|
|
21
|
+
// Check the element's shadow root
|
|
22
|
+
if (el.shadowRoot) {
|
|
23
|
+
const tabbableShadowChild = [...el.shadowRoot.children].find(isTabbable);
|
|
24
|
+
if (tabbableShadowChild) {
|
|
25
|
+
return tabbableShadowChild;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
// Check the element's children
|
|
29
|
+
if (el.children) {
|
|
30
|
+
return [...el.children].map(getNearestTabbableElement)[0];
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
const sixDropdownCss = ":host{position:relative;box-sizing:border-box}:host *,:host *:before,:host *:after{box-sizing:inherit}:host{display:inline-block}.dropdown{position:relative}.dropdown__trigger{display:block}.dropdown__positioner{position:absolute;z-index:var(--six-z-index-dropdown)}.dropdown__positioner__filtered{width:100%}.dropdown__panel{max-height:50vh;font-family:var(--six-font-sans);font-size:var(--six-font-size-small);font-weight:var(--six-font-weight-normal);color:var(--color);background-color:var(--six-panel-background-color);border-radius:var(--six-border-radius-medium);box-shadow:var(--six-elevation-2dp);opacity:0;overflow:auto;overscroll-behavior:none;pointer-events:none;transform:scale(0.9);transition:var(--six-transition-fast) opacity, var(--six-transition-fast) transform;scrollbar-width:thin}.filter-hidden{display:none}.dropdown__positioner[data-popper-placement^=top] .dropdown__panel{transform-origin:bottom}.dropdown__positioner[data-popper-placement^=bottom] .dropdown__panel{transform-origin:top}.dropdown__positioner[data-popper-placement^=left] .dropdown__panel{transform-origin:right}.dropdown__positioner[data-popper-placement^=right] .dropdown__panel{transform-origin:left}.dropdown__positioner.popover-visible .dropdown__panel{opacity:1;transform:none;pointer-events:all}";
|
|
36
36
|
|
|
37
|
-
const isTagName = (name) => (el) => (el === null || el === void 0 ? void 0 : el.tagName.toLowerCase()) === name.toLowerCase();
|
|
38
|
-
const isSixMenu = isTagName('six-menu');
|
|
39
|
-
const isSixMenuItem = isTagName('six-menu-item');
|
|
40
|
-
let id = 0;
|
|
41
|
-
let SixDropdown = class {
|
|
42
|
-
constructor(hostRef) {
|
|
43
|
-
index.registerInstance(this, hostRef);
|
|
44
|
-
this.sixShow = index.createEvent(this, "six-dropdown-show", 7);
|
|
45
|
-
this.sixAfterShow = index.createEvent(this, "six-dropdown-after-show", 7);
|
|
46
|
-
this.sixHide = index.createEvent(this, "six-dropdown-hide", 7);
|
|
47
|
-
this.sixAfterHide = index.createEvent(this, "six-dropdown-after-hide", 7);
|
|
48
|
-
this.sixAutoFilterFired = index.createEvent(this, "six-dropdown-auto-filter-fired", 7);
|
|
49
|
-
this.sixAsyncFilterFired = index.createEvent(this, "six-async-filter-fired", 7);
|
|
50
|
-
this.sixScroll = index.createEvent(this, "six-dropdown-scroll", 7);
|
|
51
|
-
this.componentId = `dropdown-${++id}`;
|
|
52
|
-
this.isVisible = false;
|
|
53
|
-
this.hasBeenInitialized = false;
|
|
54
|
-
/** Indicates whether or not the dropdown is open. You can use this in lieu of the show/hide methods. */
|
|
55
|
-
this.open = false;
|
|
56
|
-
/**
|
|
57
|
-
* The preferred placement of the dropdown panel. Note that the actual placement may vary as needed to keep the panel
|
|
58
|
-
* inside of the viewport.
|
|
59
|
-
*/
|
|
60
|
-
this.placement = 'bottom-start';
|
|
61
|
-
/** Determines whether the dropdown should hide when a menu item is selected. */
|
|
62
|
-
this.closeOnSelect = true;
|
|
63
|
-
/** The distance in pixels from which to offset the panel away from its trigger. */
|
|
64
|
-
this.distance = 0;
|
|
65
|
-
/** The distance in pixels from which to offset the panel along its trigger. */
|
|
66
|
-
this.skidding = 0;
|
|
67
|
-
/**
|
|
68
|
-
* Enable this option to prevent the panel from being clipped when the component is placed inside a container with
|
|
69
|
-
* `overflow: auto|scroll`.
|
|
70
|
-
*/
|
|
71
|
-
this.hoist = false;
|
|
72
|
-
/**
|
|
73
|
-
* Set to true to allow auto filtering for entries in the dropdown.
|
|
74
|
-
* With this flag the dropdown will automatically filter itsel.
|
|
75
|
-
* If you need to coordinate the shown elements yourself,
|
|
76
|
-
* e.g. because you need to call an endpoint use asyncFilter instead
|
|
77
|
-
*/
|
|
78
|
-
this.filter = false;
|
|
79
|
-
/**
|
|
80
|
-
* Set to true to allow async filtering.
|
|
81
|
-
* When you enter something in the search field the component will only emit an event but not filter any elements itself.
|
|
82
|
-
* You can then simply listen to the 'six-async-filter-fired' event to manage the shown menu-items yourself
|
|
83
|
-
*/
|
|
84
|
-
this.asyncFilter = false;
|
|
85
|
-
/** The filter's placeholder text. */
|
|
86
|
-
this.filterPlaceholder = 'Filter...';
|
|
87
|
-
/** By default the search field will be focused when opening a dropdown with filtering enabled. */
|
|
88
|
-
this.autofocusFilter = true;
|
|
89
|
-
/** The debounce for the filter callbacks. */
|
|
90
|
-
this.filterDebounce = executionControl.DEFAULT_DEBOUNCE_FAST;
|
|
91
|
-
/** The panel can be opend/closed by pressing the spacebar or the enter key. In some cases you might want to avoid this */
|
|
92
|
-
this.disableHideOnEnterAndSpace = false;
|
|
93
|
-
/** Set the options to be shown in the dropdown (alternative to setting the elements via html)*/
|
|
94
|
-
this.options = null;
|
|
95
|
-
/** Defines whether the menu list will be rendered virtually i.e. only the elements actually shown (and a couple around)
|
|
96
|
-
* are actually rendered in the DOM. If you use virtual scrolling pass the elements via prop instead of via slot. */
|
|
97
|
-
this.virtualScroll = false;
|
|
98
|
-
this.eventListeners = new eventListeners.EventListeners();
|
|
99
|
-
// internal representation of options, so we don't have to make options mutable
|
|
100
|
-
this._options = null;
|
|
101
|
-
this.getMenuItems = () => {
|
|
102
|
-
if (this._options !== null) {
|
|
103
|
-
return this._options.map((option) => index.h("six-menu-item", { value: option.value }, option.label));
|
|
104
|
-
}
|
|
105
|
-
const [panel] = slot.getSlotChildren(this.panel);
|
|
106
|
-
// the menu-items can be in a slot e.g. in six-select or direct children of the panel
|
|
107
|
-
return slot.getSlotChildren(panel) || Array.from(panel.querySelectorAll('six-menu-item'));
|
|
108
|
-
};
|
|
109
|
-
this.handleFilterInputChange = () => {
|
|
110
|
-
var _a, _b;
|
|
111
|
-
const lowerCaseFilterTerm = ((_b = (_a = this.filterInputElement.value) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === null || _b === void 0 ? void 0 : _b.trim()) || '';
|
|
112
|
-
if (this._options) {
|
|
113
|
-
this.handleFilteringForAttributeItems(lowerCaseFilterTerm);
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
this.handleFilteringForSlotItems(lowerCaseFilterTerm);
|
|
117
|
-
}
|
|
118
|
-
this.sixAutoFilterFired.emit({ filterValue: lowerCaseFilterTerm });
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
get hasFilterEnabled() {
|
|
122
|
-
return this.filter || this.asyncFilter;
|
|
123
|
-
}
|
|
124
|
-
get container() {
|
|
125
|
-
return this.containingElement || this.host;
|
|
126
|
-
}
|
|
127
|
-
handleOpenChange() {
|
|
128
|
-
this.open ? this.show() : this.hide();
|
|
129
|
-
this.updateAccessibleTrigger();
|
|
130
|
-
}
|
|
131
|
-
handlePopoverOptionsChange() {
|
|
132
|
-
this.popover.setOptions({
|
|
133
|
-
strategy: this.hoist ? 'fixed' : 'absolute',
|
|
134
|
-
placement: this.placement,
|
|
135
|
-
distance: this.distance,
|
|
136
|
-
skidding: this.skidding,
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
handleOptionsChange() {
|
|
140
|
-
this._options = [...this.options];
|
|
141
|
-
}
|
|
142
|
-
connectedCallback() {
|
|
143
|
-
if (this.virtualScroll && this.options === null) {
|
|
144
|
-
console.error('Options must be defined when using virtual scrolling');
|
|
145
|
-
}
|
|
146
|
-
if (this.options !== null) {
|
|
147
|
-
this._options = [...this.options];
|
|
148
|
-
}
|
|
149
|
-
this.handleDocumentKeyDown = this.handleDocumentKeyDown.bind(this);
|
|
150
|
-
this.handleDocumentMouseDown = this.handleDocumentMouseDown.bind(this);
|
|
151
|
-
this.handleMenuItemActivate = this.handleMenuItemActivate.bind(this);
|
|
152
|
-
this.handlePanelSelect = this.handlePanelSelect.bind(this);
|
|
153
|
-
this.handleTriggerClick = this.handleTriggerClick.bind(this);
|
|
154
|
-
this.handleTriggerKeyDown = this.handleTriggerKeyDown.bind(this);
|
|
155
|
-
this.handleTriggerKeyUp = this.handleTriggerKeyUp.bind(this);
|
|
156
|
-
this.handleTriggerSlotChange = this.handleTriggerSlotChange.bind(this);
|
|
157
|
-
this.handleDropdownScroll = this.handleDropdownScroll.bind(this);
|
|
158
|
-
if (this.hasBeenInitialized && !this.popover) {
|
|
159
|
-
// there was a weird bug when using six-dropdown inside an ag-grid filter. When closing the ag-grid filter
|
|
160
|
-
// disconnectedCallback() is executed. However since componentDidLoad() will not be rerendered the popover was had
|
|
161
|
-
// no longer a connected transitionEnd callback to the dropdown. To fix this, we have this sanity check here,
|
|
162
|
-
// to re-initialize the popover in case the component has already been initialized but the popover is undefined.
|
|
163
|
-
this.initializePopover();
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
componentDidLoad() {
|
|
167
|
-
this.hasBeenInitialized = true;
|
|
168
|
-
this.initializePopover();
|
|
169
|
-
// Show on init if open
|
|
170
|
-
if (this.open) {
|
|
171
|
-
void this.show();
|
|
172
|
-
}
|
|
173
|
-
if (this.filter) {
|
|
174
|
-
this.setupFiltering(this.handleFilterInputChange);
|
|
175
|
-
}
|
|
176
|
-
else if (this.asyncFilter) {
|
|
177
|
-
this.setupFiltering(() => this.sixAsyncFilterFired.emit({ filterValue: this.filterInputElement.value }));
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
initializePopover() {
|
|
181
|
-
const onAfterHide = () => {
|
|
182
|
-
if (this.filter) {
|
|
183
|
-
this.filterInputElement.value = '';
|
|
184
|
-
if (this._options !== null) {
|
|
185
|
-
this._options = [...this.options];
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
const menuItems = this.getMenuItems();
|
|
189
|
-
menuItems.forEach((item) => (item.style.display = 'unset'));
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
this.sixAfterHide.emit();
|
|
193
|
-
};
|
|
194
|
-
const onAfterShow = async () => {
|
|
195
|
-
if (this.hasFilterEnabled && this.autofocusFilter) {
|
|
196
|
-
// if dropdown filter is enabled we should autofocus the search field
|
|
197
|
-
await this.filterInputElement.setFocus();
|
|
198
|
-
}
|
|
199
|
-
this.sixAfterShow.emit();
|
|
200
|
-
};
|
|
201
|
-
const onTransitionEnd = () => {
|
|
202
|
-
if (!this.open) {
|
|
203
|
-
this.panel.scrollTop = 0;
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
this.popover = new popover.Popover(this.trigger, this.positioner, {
|
|
207
|
-
strategy: this.hoist ? 'fixed' : 'absolute',
|
|
208
|
-
placement: this.placement,
|
|
209
|
-
distance: this.distance,
|
|
210
|
-
skidding: this.skidding,
|
|
211
|
-
transitionElement: this.panel,
|
|
212
|
-
onAfterHide,
|
|
213
|
-
onAfterShow,
|
|
214
|
-
onTransitionEnd,
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
setupFiltering(callback) {
|
|
218
|
-
this.eventListeners.add(this.filterInputElement, 'six-input-input', executionControl.debounce(callback, this.filterDebounce));
|
|
219
|
-
}
|
|
220
|
-
handleFilteringForAttributeItems(lowerCaseFilterTerm) {
|
|
221
|
-
if (lowerCaseFilterTerm === '') {
|
|
222
|
-
this._options = [...this.options];
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
this._options = this.options.filter((option) => {
|
|
226
|
-
var _a, _b, _c, _d;
|
|
227
|
-
return (option.label && ((_b = (_a = String(option.label)) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === null || _b === void 0 ? void 0 : _b.includes(lowerCaseFilterTerm))) ||
|
|
228
|
-
(option.value && ((_d = (_c = String(option.value)) === null || _c === void 0 ? void 0 : _c.toLowerCase()) === null || _d === void 0 ? void 0 : _d.includes(lowerCaseFilterTerm)));
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
handleFilteringForSlotItems(lowerCaseFilterTerm) {
|
|
232
|
-
const menuItems = this.getMenuItems();
|
|
233
|
-
menuItems.forEach((menuItem) => {
|
|
234
|
-
var _a, _b;
|
|
235
|
-
const lowerCaseMenuItemValue = (_a = menuItem === null || menuItem === void 0 ? void 0 : menuItem.value) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
236
|
-
const lowerCaseMenuText = (_b = menuItem === null || menuItem === void 0 ? void 0 : menuItem.innerText) === null || _b === void 0 ? void 0 : _b.toLowerCase();
|
|
237
|
-
// hide all elements which don't contain the entered substring
|
|
238
|
-
const elementContainsFilterTerm = (lowerCaseMenuItemValue === null || lowerCaseMenuItemValue === void 0 ? void 0 : lowerCaseMenuItemValue.includes(lowerCaseFilterTerm)) || (lowerCaseMenuText === null || lowerCaseMenuText === void 0 ? void 0 : lowerCaseMenuText.includes(lowerCaseFilterTerm));
|
|
239
|
-
menuItem.style.display = elementContainsFilterTerm ? 'unset' : 'none';
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
disconnectedCallback() {
|
|
243
|
-
this.eventListeners.removeAll();
|
|
244
|
-
void this.hide();
|
|
245
|
-
this.popover.destroy();
|
|
246
|
-
this.popover = null;
|
|
247
|
-
}
|
|
248
|
-
/** Shows the dropdown panel */
|
|
249
|
-
async show() {
|
|
250
|
-
// Prevent subsequent calls to the method, whether manually or triggered by the `open` watcher
|
|
251
|
-
if (this.isVisible) {
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
const sixShow = this.sixShow.emit();
|
|
255
|
-
if (sixShow.defaultPrevented) {
|
|
256
|
-
this.open = false;
|
|
257
|
-
return;
|
|
258
|
-
}
|
|
259
|
-
this.eventListeners.add(this.panel, 'six-menu-item-selected', this.handlePanelSelect);
|
|
260
|
-
this.eventListeners.add(document, 'keydown', this.handleDocumentKeyDown);
|
|
261
|
-
this.eventListeners.add(document, 'mousedown', this.handleDocumentMouseDown);
|
|
262
|
-
this.isVisible = true;
|
|
263
|
-
this.open = true;
|
|
264
|
-
this.popover.show();
|
|
265
|
-
}
|
|
266
|
-
/** Hides the dropdown panel */
|
|
267
|
-
async hide() {
|
|
268
|
-
// Prevent subsequent calls to the method, whether manually or triggered by the `open` watcher
|
|
269
|
-
if (!this.isVisible) {
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
const sixHide = this.sixHide.emit();
|
|
273
|
-
if (sixHide.defaultPrevented) {
|
|
274
|
-
this.open = true;
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
this.eventListeners.remove(this.panel, 'six-menu-item-selected', this.handlePanelSelect);
|
|
278
|
-
this.eventListeners.remove(document, 'keydown', this.handleDocumentKeyDown);
|
|
279
|
-
this.eventListeners.remove(document, 'mousedown', this.handleDocumentMouseDown);
|
|
280
|
-
this.isVisible = false;
|
|
281
|
-
this.open = false;
|
|
282
|
-
this.popover.hide();
|
|
283
|
-
}
|
|
284
|
-
focusOnTrigger() {
|
|
285
|
-
const [trigger] = slot.getSlotChildren(this.trigger);
|
|
286
|
-
if (trigger) {
|
|
287
|
-
if (typeof trigger.setFocus === 'function') {
|
|
288
|
-
trigger.setFocus();
|
|
289
|
-
}
|
|
290
|
-
else if (typeof trigger.focus === 'function') {
|
|
291
|
-
trigger.focus();
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
getMenu() {
|
|
296
|
-
const [menu] = slot.getSlotChildren(this.panel).filter(isSixMenu);
|
|
297
|
-
return menu;
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* Instructs the dropdown menu to reposition. Useful when the position or size of the trigger changes when the menu
|
|
301
|
-
* is activated.
|
|
302
|
-
*/
|
|
303
|
-
async reposition() {
|
|
304
|
-
if (!this.open) {
|
|
305
|
-
return;
|
|
306
|
-
}
|
|
307
|
-
this.popover.reposition();
|
|
308
|
-
}
|
|
309
|
-
handleDocumentKeyDown(event) {
|
|
310
|
-
// Close when escape is pressed
|
|
311
|
-
if (event.key === 'Escape') {
|
|
312
|
-
void this.hide();
|
|
313
|
-
this.focusOnTrigger();
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
if (this.filterInputElement === this.host.shadowRoot.activeElement) {
|
|
317
|
-
if (event.key === 'ArrowDown') {
|
|
318
|
-
const item = this.getMenuItems().find((item) => item.style.display !== 'none');
|
|
319
|
-
if (item) {
|
|
320
|
-
item.setFocus();
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
// Handle tabbing
|
|
325
|
-
if (event.key === 'Tab') {
|
|
326
|
-
// Tabbing within an open menu should close the dropdown and refocus the trigger
|
|
327
|
-
if (this.open && isSixMenuItem(document.activeElement)) {
|
|
328
|
-
event.preventDefault();
|
|
329
|
-
void this.hide();
|
|
330
|
-
this.focusOnTrigger();
|
|
331
|
-
return;
|
|
332
|
-
}
|
|
333
|
-
// Tabbing outside of the containing element closes the panel
|
|
334
|
-
//
|
|
335
|
-
// If the dropdown is used within a shadow DOM, we need to obtain the activeElement within that shadowRoot,
|
|
336
|
-
// otherwise `document.activeElement` will only return the name of the parent shadow DOM element.
|
|
337
|
-
setTimeout(() => {
|
|
338
|
-
var _a;
|
|
339
|
-
const activeElement = this.container.getRootNode() instanceof ShadowRoot
|
|
340
|
-
? (_a = document.activeElement.shadowRoot) === null || _a === void 0 ? void 0 : _a.activeElement
|
|
341
|
-
: document.activeElement;
|
|
342
|
-
if ((activeElement === null || activeElement === void 0 ? void 0 : activeElement.closest(this.container.tagName.toLowerCase())) !== this.container) {
|
|
343
|
-
void this.hide();
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
handleDocumentMouseDown(event) {
|
|
350
|
-
// Close when clicking outside of the containing element
|
|
351
|
-
const path = event.composedPath();
|
|
352
|
-
if (!path.includes(this.container)) {
|
|
353
|
-
void this.hide();
|
|
354
|
-
return;
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
handleMenuItemActivate(event) {
|
|
358
|
-
const item = event.target;
|
|
359
|
-
scroll.scrollIntoView(item, this.panel);
|
|
360
|
-
}
|
|
361
|
-
handlePanelSelect(event) {
|
|
362
|
-
const target = event.target;
|
|
363
|
-
// Hide the dropdown when a menu item is selected
|
|
364
|
-
if (this.closeOnSelect && isSixMenu(target)) {
|
|
365
|
-
void this.hide();
|
|
366
|
-
this.focusOnTrigger();
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
handleTriggerClick() {
|
|
370
|
-
this.open ? this.hide() : this.show();
|
|
371
|
-
}
|
|
372
|
-
handleTriggerKeyDown(event) {
|
|
373
|
-
const menu = this.getMenu();
|
|
374
|
-
const menuItems = menu ? [...menu.querySelectorAll('six-menu-item')] : null;
|
|
375
|
-
const firstMenuItem = menuItems[0];
|
|
376
|
-
const lastMenuItem = menuItems[menuItems.length - 1];
|
|
377
|
-
// Close when escape or tab is pressed
|
|
378
|
-
if (event.key === 'Escape') {
|
|
379
|
-
this.focusOnTrigger();
|
|
380
|
-
void this.hide();
|
|
381
|
-
return;
|
|
382
|
-
}
|
|
383
|
-
// When spacebar/enter is pressed, show the panel but don't focus on the menu. This let's the user press the same
|
|
384
|
-
// key again to hide the menu in case they don't want to make a selection.
|
|
385
|
-
if (!this.disableHideOnEnterAndSpace && [' ', 'Enter'].includes(event.key)) {
|
|
386
|
-
event.preventDefault();
|
|
387
|
-
this.open ? void this.hide() : void this.show();
|
|
388
|
-
return;
|
|
389
|
-
}
|
|
390
|
-
// When up/down is pressed, we make the assumption that the user is familiar with the menu and plans to make a
|
|
391
|
-
// selection. Rather than toggle the panel, we focus on the menu (if one exists) and activate the first item for
|
|
392
|
-
// faster navigation.
|
|
393
|
-
if (['ArrowDown', 'ArrowUp'].includes(event.key)) {
|
|
394
|
-
event.preventDefault();
|
|
395
|
-
// Show the menu if it's not already open
|
|
396
|
-
if (!this.open) {
|
|
397
|
-
void this.show();
|
|
398
|
-
}
|
|
399
|
-
// Focus on a menu item
|
|
400
|
-
if (event.key === 'ArrowDown' && firstMenuItem) {
|
|
401
|
-
firstMenuItem.setFocus();
|
|
402
|
-
return;
|
|
403
|
-
}
|
|
404
|
-
if (event.key === 'ArrowUp' && lastMenuItem) {
|
|
405
|
-
lastMenuItem.setFocus();
|
|
406
|
-
return;
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
// Other keys bring focus to the menu and initiate type-to-select behavior
|
|
410
|
-
const ignoredKeys = ['Tab', 'Shift', 'Meta', 'Ctrl', 'Alt'];
|
|
411
|
-
if (this.open && menu && !ignoredKeys.includes(event.key)) {
|
|
412
|
-
void menu.typeToSelect(event.key);
|
|
413
|
-
return;
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
handleTriggerKeyUp(event) {
|
|
417
|
-
// Prevent space from triggering a click event in Firefox
|
|
418
|
-
if (event.key === ' ') {
|
|
419
|
-
event.preventDefault();
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
handleTriggerSlotChange() {
|
|
423
|
-
this.updateAccessibleTrigger();
|
|
424
|
-
}
|
|
425
|
-
handleDropdownScroll() {
|
|
426
|
-
this.sixScroll.emit({
|
|
427
|
-
scrollHeight: this.panel.scrollHeight,
|
|
428
|
-
scrollTop: this.panel.scrollTop,
|
|
429
|
-
scrollbarHeight: this.panel.offsetHeight * (this.panel.offsetHeight / this.panel.scrollHeight),
|
|
430
|
-
scrollRatio: this.panel.scrollTop / (this.panel.scrollHeight - this.panel.clientHeight),
|
|
431
|
-
});
|
|
432
|
-
}
|
|
433
|
-
//
|
|
434
|
-
// Slotted triggers can be arbitrary content, but we need to link them to the dropdown panel with `aria-haspopup` and
|
|
435
|
-
// `aria-expanded`. These must be applied to the "accessible trigger" (the tabbable portion of the trigger element
|
|
436
|
-
// that gets slotted in) so screen readers will understand them. The accessible trigger could be the slotted element,
|
|
437
|
-
// a child of the slotted element, or an element in the slotted element's shadow root.
|
|
438
|
-
//
|
|
439
|
-
// For example, the accessible trigger of an <sl-button> is a <button> located inside its shadow root.
|
|
440
|
-
//
|
|
441
|
-
// To determine this, we assume the first tabbable element in the trigger slot is the "accessible trigger."
|
|
442
|
-
//
|
|
443
|
-
updateAccessibleTrigger() {
|
|
444
|
-
const [accessibleTrigger] = slot.getSlotChildren(this.trigger).map(getNearestTabbableElement);
|
|
445
|
-
if (accessibleTrigger) {
|
|
446
|
-
accessibleTrigger.setAttribute('aria-haspopup', 'true');
|
|
447
|
-
accessibleTrigger.setAttribute('aria-expanded', this.open ? 'true' : 'false');
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
render() {
|
|
451
|
-
return (index.h("div", { part: "base", id: this.componentId, class: {
|
|
452
|
-
dropdown: true,
|
|
453
|
-
'dropdown--open': this.open,
|
|
454
|
-
} }, index.h("span", { part: "trigger", class: "dropdown__trigger", ref: (el) => (this.trigger = el), onClick: this.handleTriggerClick, onKeyDown: this.handleTriggerKeyDown, onKeyUp: this.handleTriggerKeyUp }, index.h("slot", { name: "trigger", onSlotchange: this.handleTriggerSlotChange })), index.h("div", { ref: (el) => (this.positioner = el), class: {
|
|
455
|
-
dropdown__positioner: true,
|
|
456
|
-
dropdown__positioner__filtered: (this.filter || this.asyncFilter) && !this.hoist,
|
|
457
|
-
} }, this.hasFilterEnabled && (index.h("six-input", { class: {
|
|
458
|
-
'filter-hidden': !this.open,
|
|
459
|
-
}, "aria-hidden": this.open ? 'false' : 'true', ref: (el) => (this.filterInputElement = el), placeholder: this.filterPlaceholder })), index.h("div", { ref: (el) => (this.panel = el), part: "panel", class: "dropdown__panel", role: "menu", "aria-hidden": this.open ? 'false' : 'true', "aria-labelledby": this.componentId, onScroll: this.handleDropdownScroll }, index.h("slot", null), this._options && (index.h("six-menu", { part: "menu", items: this._options, virtualScroll: this.virtualScroll }))))));
|
|
460
|
-
}
|
|
461
|
-
get host() { return index.getElement(this); }
|
|
462
|
-
static get watchers() { return {
|
|
463
|
-
"open": ["handleOpenChange"],
|
|
464
|
-
"distance": ["handlePopoverOptionsChange"],
|
|
465
|
-
"hoist": ["handlePopoverOptionsChange"],
|
|
466
|
-
"placement": ["handlePopoverOptionsChange"],
|
|
467
|
-
"skidding": ["handlePopoverOptionsChange"],
|
|
468
|
-
"options": ["handleOptionsChange"]
|
|
469
|
-
}; }
|
|
470
|
-
};
|
|
37
|
+
const isTagName = (name) => (el) => (el === null || el === void 0 ? void 0 : el.tagName.toLowerCase()) === name.toLowerCase();
|
|
38
|
+
const isSixMenu = isTagName('six-menu');
|
|
39
|
+
const isSixMenuItem = isTagName('six-menu-item');
|
|
40
|
+
let id = 0;
|
|
41
|
+
let SixDropdown = class {
|
|
42
|
+
constructor(hostRef) {
|
|
43
|
+
index.registerInstance(this, hostRef);
|
|
44
|
+
this.sixShow = index.createEvent(this, "six-dropdown-show", 7);
|
|
45
|
+
this.sixAfterShow = index.createEvent(this, "six-dropdown-after-show", 7);
|
|
46
|
+
this.sixHide = index.createEvent(this, "six-dropdown-hide", 7);
|
|
47
|
+
this.sixAfterHide = index.createEvent(this, "six-dropdown-after-hide", 7);
|
|
48
|
+
this.sixAutoFilterFired = index.createEvent(this, "six-dropdown-auto-filter-fired", 7);
|
|
49
|
+
this.sixAsyncFilterFired = index.createEvent(this, "six-async-filter-fired", 7);
|
|
50
|
+
this.sixScroll = index.createEvent(this, "six-dropdown-scroll", 7);
|
|
51
|
+
this.componentId = `dropdown-${++id}`;
|
|
52
|
+
this.isVisible = false;
|
|
53
|
+
this.hasBeenInitialized = false;
|
|
54
|
+
/** Indicates whether or not the dropdown is open. You can use this in lieu of the show/hide methods. */
|
|
55
|
+
this.open = false;
|
|
56
|
+
/**
|
|
57
|
+
* The preferred placement of the dropdown panel. Note that the actual placement may vary as needed to keep the panel
|
|
58
|
+
* inside of the viewport.
|
|
59
|
+
*/
|
|
60
|
+
this.placement = 'bottom-start';
|
|
61
|
+
/** Determines whether the dropdown should hide when a menu item is selected. */
|
|
62
|
+
this.closeOnSelect = true;
|
|
63
|
+
/** The distance in pixels from which to offset the panel away from its trigger. */
|
|
64
|
+
this.distance = 0;
|
|
65
|
+
/** The distance in pixels from which to offset the panel along its trigger. */
|
|
66
|
+
this.skidding = 0;
|
|
67
|
+
/**
|
|
68
|
+
* Enable this option to prevent the panel from being clipped when the component is placed inside a container with
|
|
69
|
+
* `overflow: auto|scroll`.
|
|
70
|
+
*/
|
|
71
|
+
this.hoist = false;
|
|
72
|
+
/**
|
|
73
|
+
* Set to true to allow auto filtering for entries in the dropdown.
|
|
74
|
+
* With this flag the dropdown will automatically filter itsel.
|
|
75
|
+
* If you need to coordinate the shown elements yourself,
|
|
76
|
+
* e.g. because you need to call an endpoint use asyncFilter instead
|
|
77
|
+
*/
|
|
78
|
+
this.filter = false;
|
|
79
|
+
/**
|
|
80
|
+
* Set to true to allow async filtering.
|
|
81
|
+
* When you enter something in the search field the component will only emit an event but not filter any elements itself.
|
|
82
|
+
* You can then simply listen to the 'six-async-filter-fired' event to manage the shown menu-items yourself
|
|
83
|
+
*/
|
|
84
|
+
this.asyncFilter = false;
|
|
85
|
+
/** The filter's placeholder text. */
|
|
86
|
+
this.filterPlaceholder = 'Filter...';
|
|
87
|
+
/** By default the search field will be focused when opening a dropdown with filtering enabled. */
|
|
88
|
+
this.autofocusFilter = true;
|
|
89
|
+
/** The debounce for the filter callbacks. */
|
|
90
|
+
this.filterDebounce = executionControl.DEFAULT_DEBOUNCE_FAST;
|
|
91
|
+
/** The panel can be opend/closed by pressing the spacebar or the enter key. In some cases you might want to avoid this */
|
|
92
|
+
this.disableHideOnEnterAndSpace = false;
|
|
93
|
+
/** Set the options to be shown in the dropdown (alternative to setting the elements via html)*/
|
|
94
|
+
this.options = null;
|
|
95
|
+
/** Defines whether the menu list will be rendered virtually i.e. only the elements actually shown (and a couple around)
|
|
96
|
+
* are actually rendered in the DOM. If you use virtual scrolling pass the elements via prop instead of via slot. */
|
|
97
|
+
this.virtualScroll = false;
|
|
98
|
+
this.eventListeners = new eventListeners.EventListeners();
|
|
99
|
+
// internal representation of options, so we don't have to make options mutable
|
|
100
|
+
this._options = null;
|
|
101
|
+
this.getMenuItems = () => {
|
|
102
|
+
if (this._options !== null) {
|
|
103
|
+
return this._options.map((option) => index.h("six-menu-item", { value: option.value }, option.label));
|
|
104
|
+
}
|
|
105
|
+
const [panel] = slot.getSlotChildren(this.panel);
|
|
106
|
+
// the menu-items can be in a slot e.g. in six-select or direct children of the panel
|
|
107
|
+
return slot.getSlotChildren(panel) || Array.from(panel.querySelectorAll('six-menu-item'));
|
|
108
|
+
};
|
|
109
|
+
this.handleFilterInputChange = () => {
|
|
110
|
+
var _a, _b;
|
|
111
|
+
const lowerCaseFilterTerm = ((_b = (_a = this.filterInputElement.value) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === null || _b === void 0 ? void 0 : _b.trim()) || '';
|
|
112
|
+
if (this._options) {
|
|
113
|
+
this.handleFilteringForAttributeItems(lowerCaseFilterTerm);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
this.handleFilteringForSlotItems(lowerCaseFilterTerm);
|
|
117
|
+
}
|
|
118
|
+
this.sixAutoFilterFired.emit({ filterValue: lowerCaseFilterTerm });
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
get hasFilterEnabled() {
|
|
122
|
+
return this.filter || this.asyncFilter;
|
|
123
|
+
}
|
|
124
|
+
get container() {
|
|
125
|
+
return this.containingElement || this.host;
|
|
126
|
+
}
|
|
127
|
+
handleOpenChange() {
|
|
128
|
+
this.open ? this.show() : this.hide();
|
|
129
|
+
this.updateAccessibleTrigger();
|
|
130
|
+
}
|
|
131
|
+
handlePopoverOptionsChange() {
|
|
132
|
+
this.popover.setOptions({
|
|
133
|
+
strategy: this.hoist ? 'fixed' : 'absolute',
|
|
134
|
+
placement: this.placement,
|
|
135
|
+
distance: this.distance,
|
|
136
|
+
skidding: this.skidding,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
handleOptionsChange() {
|
|
140
|
+
this._options = [...this.options];
|
|
141
|
+
}
|
|
142
|
+
connectedCallback() {
|
|
143
|
+
if (this.virtualScroll && this.options === null) {
|
|
144
|
+
console.error('Options must be defined when using virtual scrolling');
|
|
145
|
+
}
|
|
146
|
+
if (this.options !== null) {
|
|
147
|
+
this._options = [...this.options];
|
|
148
|
+
}
|
|
149
|
+
this.handleDocumentKeyDown = this.handleDocumentKeyDown.bind(this);
|
|
150
|
+
this.handleDocumentMouseDown = this.handleDocumentMouseDown.bind(this);
|
|
151
|
+
this.handleMenuItemActivate = this.handleMenuItemActivate.bind(this);
|
|
152
|
+
this.handlePanelSelect = this.handlePanelSelect.bind(this);
|
|
153
|
+
this.handleTriggerClick = this.handleTriggerClick.bind(this);
|
|
154
|
+
this.handleTriggerKeyDown = this.handleTriggerKeyDown.bind(this);
|
|
155
|
+
this.handleTriggerKeyUp = this.handleTriggerKeyUp.bind(this);
|
|
156
|
+
this.handleTriggerSlotChange = this.handleTriggerSlotChange.bind(this);
|
|
157
|
+
this.handleDropdownScroll = this.handleDropdownScroll.bind(this);
|
|
158
|
+
if (this.hasBeenInitialized && !this.popover) {
|
|
159
|
+
// there was a weird bug when using six-dropdown inside an ag-grid filter. When closing the ag-grid filter
|
|
160
|
+
// disconnectedCallback() is executed. However since componentDidLoad() will not be rerendered the popover was had
|
|
161
|
+
// no longer a connected transitionEnd callback to the dropdown. To fix this, we have this sanity check here,
|
|
162
|
+
// to re-initialize the popover in case the component has already been initialized but the popover is undefined.
|
|
163
|
+
this.initializePopover();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
componentDidLoad() {
|
|
167
|
+
this.hasBeenInitialized = true;
|
|
168
|
+
this.initializePopover();
|
|
169
|
+
// Show on init if open
|
|
170
|
+
if (this.open) {
|
|
171
|
+
void this.show();
|
|
172
|
+
}
|
|
173
|
+
if (this.filter) {
|
|
174
|
+
this.setupFiltering(this.handleFilterInputChange);
|
|
175
|
+
}
|
|
176
|
+
else if (this.asyncFilter) {
|
|
177
|
+
this.setupFiltering(() => this.sixAsyncFilterFired.emit({ filterValue: this.filterInputElement.value }));
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
initializePopover() {
|
|
181
|
+
const onAfterHide = () => {
|
|
182
|
+
if (this.filter) {
|
|
183
|
+
this.filterInputElement.value = '';
|
|
184
|
+
if (this._options !== null) {
|
|
185
|
+
this._options = [...this.options];
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
const menuItems = this.getMenuItems();
|
|
189
|
+
menuItems.forEach((item) => (item.style.display = 'unset'));
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
this.sixAfterHide.emit();
|
|
193
|
+
};
|
|
194
|
+
const onAfterShow = async () => {
|
|
195
|
+
if (this.hasFilterEnabled && this.autofocusFilter) {
|
|
196
|
+
// if dropdown filter is enabled we should autofocus the search field
|
|
197
|
+
await this.filterInputElement.setFocus();
|
|
198
|
+
}
|
|
199
|
+
this.sixAfterShow.emit();
|
|
200
|
+
};
|
|
201
|
+
const onTransitionEnd = () => {
|
|
202
|
+
if (!this.open) {
|
|
203
|
+
this.panel.scrollTop = 0;
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
this.popover = new popover.Popover(this.trigger, this.positioner, {
|
|
207
|
+
strategy: this.hoist ? 'fixed' : 'absolute',
|
|
208
|
+
placement: this.placement,
|
|
209
|
+
distance: this.distance,
|
|
210
|
+
skidding: this.skidding,
|
|
211
|
+
transitionElement: this.panel,
|
|
212
|
+
onAfterHide,
|
|
213
|
+
onAfterShow,
|
|
214
|
+
onTransitionEnd,
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
setupFiltering(callback) {
|
|
218
|
+
this.eventListeners.add(this.filterInputElement, 'six-input-input', executionControl.debounce(callback, this.filterDebounce));
|
|
219
|
+
}
|
|
220
|
+
handleFilteringForAttributeItems(lowerCaseFilterTerm) {
|
|
221
|
+
if (lowerCaseFilterTerm === '') {
|
|
222
|
+
this._options = [...this.options];
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
this._options = this.options.filter((option) => {
|
|
226
|
+
var _a, _b, _c, _d;
|
|
227
|
+
return (option.label && ((_b = (_a = String(option.label)) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === null || _b === void 0 ? void 0 : _b.includes(lowerCaseFilterTerm))) ||
|
|
228
|
+
(option.value && ((_d = (_c = String(option.value)) === null || _c === void 0 ? void 0 : _c.toLowerCase()) === null || _d === void 0 ? void 0 : _d.includes(lowerCaseFilterTerm)));
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
handleFilteringForSlotItems(lowerCaseFilterTerm) {
|
|
232
|
+
const menuItems = this.getMenuItems();
|
|
233
|
+
menuItems.forEach((menuItem) => {
|
|
234
|
+
var _a, _b;
|
|
235
|
+
const lowerCaseMenuItemValue = (_a = menuItem === null || menuItem === void 0 ? void 0 : menuItem.value) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
236
|
+
const lowerCaseMenuText = (_b = menuItem === null || menuItem === void 0 ? void 0 : menuItem.innerText) === null || _b === void 0 ? void 0 : _b.toLowerCase();
|
|
237
|
+
// hide all elements which don't contain the entered substring
|
|
238
|
+
const elementContainsFilterTerm = (lowerCaseMenuItemValue === null || lowerCaseMenuItemValue === void 0 ? void 0 : lowerCaseMenuItemValue.includes(lowerCaseFilterTerm)) || (lowerCaseMenuText === null || lowerCaseMenuText === void 0 ? void 0 : lowerCaseMenuText.includes(lowerCaseFilterTerm));
|
|
239
|
+
menuItem.style.display = elementContainsFilterTerm ? 'unset' : 'none';
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
disconnectedCallback() {
|
|
243
|
+
this.eventListeners.removeAll();
|
|
244
|
+
void this.hide();
|
|
245
|
+
this.popover.destroy();
|
|
246
|
+
this.popover = null;
|
|
247
|
+
}
|
|
248
|
+
/** Shows the dropdown panel */
|
|
249
|
+
async show() {
|
|
250
|
+
// Prevent subsequent calls to the method, whether manually or triggered by the `open` watcher
|
|
251
|
+
if (this.isVisible) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
const sixShow = this.sixShow.emit();
|
|
255
|
+
if (sixShow.defaultPrevented) {
|
|
256
|
+
this.open = false;
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
this.eventListeners.add(this.panel, 'six-menu-item-selected', this.handlePanelSelect);
|
|
260
|
+
this.eventListeners.add(document, 'keydown', this.handleDocumentKeyDown);
|
|
261
|
+
this.eventListeners.add(document, 'mousedown', this.handleDocumentMouseDown);
|
|
262
|
+
this.isVisible = true;
|
|
263
|
+
this.open = true;
|
|
264
|
+
this.popover.show();
|
|
265
|
+
}
|
|
266
|
+
/** Hides the dropdown panel */
|
|
267
|
+
async hide() {
|
|
268
|
+
// Prevent subsequent calls to the method, whether manually or triggered by the `open` watcher
|
|
269
|
+
if (!this.isVisible) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
const sixHide = this.sixHide.emit();
|
|
273
|
+
if (sixHide.defaultPrevented) {
|
|
274
|
+
this.open = true;
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
this.eventListeners.remove(this.panel, 'six-menu-item-selected', this.handlePanelSelect);
|
|
278
|
+
this.eventListeners.remove(document, 'keydown', this.handleDocumentKeyDown);
|
|
279
|
+
this.eventListeners.remove(document, 'mousedown', this.handleDocumentMouseDown);
|
|
280
|
+
this.isVisible = false;
|
|
281
|
+
this.open = false;
|
|
282
|
+
this.popover.hide();
|
|
283
|
+
}
|
|
284
|
+
focusOnTrigger() {
|
|
285
|
+
const [trigger] = slot.getSlotChildren(this.trigger);
|
|
286
|
+
if (trigger) {
|
|
287
|
+
if (typeof trigger.setFocus === 'function') {
|
|
288
|
+
trigger.setFocus();
|
|
289
|
+
}
|
|
290
|
+
else if (typeof trigger.focus === 'function') {
|
|
291
|
+
trigger.focus();
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
getMenu() {
|
|
296
|
+
const [menu] = slot.getSlotChildren(this.panel).filter(isSixMenu);
|
|
297
|
+
return menu;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Instructs the dropdown menu to reposition. Useful when the position or size of the trigger changes when the menu
|
|
301
|
+
* is activated.
|
|
302
|
+
*/
|
|
303
|
+
async reposition() {
|
|
304
|
+
if (!this.open) {
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
this.popover.reposition();
|
|
308
|
+
}
|
|
309
|
+
handleDocumentKeyDown(event) {
|
|
310
|
+
// Close when escape is pressed
|
|
311
|
+
if (event.key === 'Escape') {
|
|
312
|
+
void this.hide();
|
|
313
|
+
this.focusOnTrigger();
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
if (this.filterInputElement === this.host.shadowRoot.activeElement) {
|
|
317
|
+
if (event.key === 'ArrowDown') {
|
|
318
|
+
const item = this.getMenuItems().find((item) => item.style.display !== 'none');
|
|
319
|
+
if (item) {
|
|
320
|
+
item.setFocus();
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
// Handle tabbing
|
|
325
|
+
if (event.key === 'Tab') {
|
|
326
|
+
// Tabbing within an open menu should close the dropdown and refocus the trigger
|
|
327
|
+
if (this.open && isSixMenuItem(document.activeElement)) {
|
|
328
|
+
event.preventDefault();
|
|
329
|
+
void this.hide();
|
|
330
|
+
this.focusOnTrigger();
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
// Tabbing outside of the containing element closes the panel
|
|
334
|
+
//
|
|
335
|
+
// If the dropdown is used within a shadow DOM, we need to obtain the activeElement within that shadowRoot,
|
|
336
|
+
// otherwise `document.activeElement` will only return the name of the parent shadow DOM element.
|
|
337
|
+
setTimeout(() => {
|
|
338
|
+
var _a;
|
|
339
|
+
const activeElement = this.container.getRootNode() instanceof ShadowRoot
|
|
340
|
+
? (_a = document.activeElement.shadowRoot) === null || _a === void 0 ? void 0 : _a.activeElement
|
|
341
|
+
: document.activeElement;
|
|
342
|
+
if ((activeElement === null || activeElement === void 0 ? void 0 : activeElement.closest(this.container.tagName.toLowerCase())) !== this.container) {
|
|
343
|
+
void this.hide();
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
handleDocumentMouseDown(event) {
|
|
350
|
+
// Close when clicking outside of the containing element
|
|
351
|
+
const path = event.composedPath();
|
|
352
|
+
if (!path.includes(this.container)) {
|
|
353
|
+
void this.hide();
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
handleMenuItemActivate(event) {
|
|
358
|
+
const item = event.target;
|
|
359
|
+
scroll.scrollIntoView(item, this.panel);
|
|
360
|
+
}
|
|
361
|
+
handlePanelSelect(event) {
|
|
362
|
+
const target = event.target;
|
|
363
|
+
// Hide the dropdown when a menu item is selected
|
|
364
|
+
if (this.closeOnSelect && isSixMenu(target)) {
|
|
365
|
+
void this.hide();
|
|
366
|
+
this.focusOnTrigger();
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
handleTriggerClick() {
|
|
370
|
+
this.open ? this.hide() : this.show();
|
|
371
|
+
}
|
|
372
|
+
handleTriggerKeyDown(event) {
|
|
373
|
+
const menu = this.getMenu();
|
|
374
|
+
const menuItems = menu ? [...menu.querySelectorAll('six-menu-item')] : null;
|
|
375
|
+
const firstMenuItem = menuItems[0];
|
|
376
|
+
const lastMenuItem = menuItems[menuItems.length - 1];
|
|
377
|
+
// Close when escape or tab is pressed
|
|
378
|
+
if (event.key === 'Escape') {
|
|
379
|
+
this.focusOnTrigger();
|
|
380
|
+
void this.hide();
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
// When spacebar/enter is pressed, show the panel but don't focus on the menu. This let's the user press the same
|
|
384
|
+
// key again to hide the menu in case they don't want to make a selection.
|
|
385
|
+
if (!this.disableHideOnEnterAndSpace && [' ', 'Enter'].includes(event.key)) {
|
|
386
|
+
event.preventDefault();
|
|
387
|
+
this.open ? void this.hide() : void this.show();
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
// When up/down is pressed, we make the assumption that the user is familiar with the menu and plans to make a
|
|
391
|
+
// selection. Rather than toggle the panel, we focus on the menu (if one exists) and activate the first item for
|
|
392
|
+
// faster navigation.
|
|
393
|
+
if (['ArrowDown', 'ArrowUp'].includes(event.key)) {
|
|
394
|
+
event.preventDefault();
|
|
395
|
+
// Show the menu if it's not already open
|
|
396
|
+
if (!this.open) {
|
|
397
|
+
void this.show();
|
|
398
|
+
}
|
|
399
|
+
// Focus on a menu item
|
|
400
|
+
if (event.key === 'ArrowDown' && firstMenuItem) {
|
|
401
|
+
firstMenuItem.setFocus();
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
if (event.key === 'ArrowUp' && lastMenuItem) {
|
|
405
|
+
lastMenuItem.setFocus();
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
// Other keys bring focus to the menu and initiate type-to-select behavior
|
|
410
|
+
const ignoredKeys = ['Tab', 'Shift', 'Meta', 'Ctrl', 'Alt'];
|
|
411
|
+
if (this.open && menu && !ignoredKeys.includes(event.key)) {
|
|
412
|
+
void menu.typeToSelect(event.key);
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
handleTriggerKeyUp(event) {
|
|
417
|
+
// Prevent space from triggering a click event in Firefox
|
|
418
|
+
if (event.key === ' ') {
|
|
419
|
+
event.preventDefault();
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
handleTriggerSlotChange() {
|
|
423
|
+
this.updateAccessibleTrigger();
|
|
424
|
+
}
|
|
425
|
+
handleDropdownScroll() {
|
|
426
|
+
this.sixScroll.emit({
|
|
427
|
+
scrollHeight: this.panel.scrollHeight,
|
|
428
|
+
scrollTop: this.panel.scrollTop,
|
|
429
|
+
scrollbarHeight: this.panel.offsetHeight * (this.panel.offsetHeight / this.panel.scrollHeight),
|
|
430
|
+
scrollRatio: this.panel.scrollTop / (this.panel.scrollHeight - this.panel.clientHeight),
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
//
|
|
434
|
+
// Slotted triggers can be arbitrary content, but we need to link them to the dropdown panel with `aria-haspopup` and
|
|
435
|
+
// `aria-expanded`. These must be applied to the "accessible trigger" (the tabbable portion of the trigger element
|
|
436
|
+
// that gets slotted in) so screen readers will understand them. The accessible trigger could be the slotted element,
|
|
437
|
+
// a child of the slotted element, or an element in the slotted element's shadow root.
|
|
438
|
+
//
|
|
439
|
+
// For example, the accessible trigger of an <sl-button> is a <button> located inside its shadow root.
|
|
440
|
+
//
|
|
441
|
+
// To determine this, we assume the first tabbable element in the trigger slot is the "accessible trigger."
|
|
442
|
+
//
|
|
443
|
+
updateAccessibleTrigger() {
|
|
444
|
+
const [accessibleTrigger] = slot.getSlotChildren(this.trigger).map(getNearestTabbableElement);
|
|
445
|
+
if (accessibleTrigger) {
|
|
446
|
+
accessibleTrigger.setAttribute('aria-haspopup', 'true');
|
|
447
|
+
accessibleTrigger.setAttribute('aria-expanded', this.open ? 'true' : 'false');
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
render() {
|
|
451
|
+
return (index.h("div", { part: "base", id: this.componentId, class: {
|
|
452
|
+
dropdown: true,
|
|
453
|
+
'dropdown--open': this.open,
|
|
454
|
+
} }, index.h("span", { part: "trigger", class: "dropdown__trigger", ref: (el) => (this.trigger = el), onClick: this.handleTriggerClick, onKeyDown: this.handleTriggerKeyDown, onKeyUp: this.handleTriggerKeyUp }, index.h("slot", { name: "trigger", onSlotchange: this.handleTriggerSlotChange })), index.h("div", { ref: (el) => (this.positioner = el), class: {
|
|
455
|
+
dropdown__positioner: true,
|
|
456
|
+
dropdown__positioner__filtered: (this.filter || this.asyncFilter) && !this.hoist,
|
|
457
|
+
} }, this.hasFilterEnabled && (index.h("six-input", { class: {
|
|
458
|
+
'filter-hidden': !this.open,
|
|
459
|
+
}, "aria-hidden": this.open ? 'false' : 'true', ref: (el) => (this.filterInputElement = el), placeholder: this.filterPlaceholder })), index.h("div", { ref: (el) => (this.panel = el), part: "panel", class: "dropdown__panel", role: "menu", "aria-hidden": this.open ? 'false' : 'true', "aria-labelledby": this.componentId, onScroll: this.handleDropdownScroll }, index.h("slot", null), this._options && (index.h("six-menu", { part: "menu", items: this._options, virtualScroll: this.virtualScroll }))))));
|
|
460
|
+
}
|
|
461
|
+
get host() { return index.getElement(this); }
|
|
462
|
+
static get watchers() { return {
|
|
463
|
+
"open": ["handleOpenChange"],
|
|
464
|
+
"distance": ["handlePopoverOptionsChange"],
|
|
465
|
+
"hoist": ["handlePopoverOptionsChange"],
|
|
466
|
+
"placement": ["handlePopoverOptionsChange"],
|
|
467
|
+
"skidding": ["handlePopoverOptionsChange"],
|
|
468
|
+
"options": ["handleOptionsChange"]
|
|
469
|
+
}; }
|
|
470
|
+
};
|
|
471
471
|
SixDropdown.style = sixDropdownCss;
|
|
472
472
|
|
|
473
473
|
const sixMenuCss = ":host{position:relative;box-sizing:border-box}:host *,:host *:before,:host *:after{box-sizing:inherit}:host{display:block}.menu{padding:0 0;border:none;box-shadow:var(--six-elevation-2dp)}.menu:focus{outline:none}.menu--noshadow{box-shadow:none}.menu__wrapper--scrollable{overflow-y:auto}";
|
|
474
474
|
|
|
475
|
-
const isFocusedMenuItem = (menuItem) => { var _a, _b, _c; return (_c = (_b = (_a = menuItem === null || menuItem === void 0 ? void 0 : menuItem.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.menu-item')) === null || _b === void 0 ? void 0 : _b.classList) === null || _c === void 0 ? void 0 : _c.contains('menu-item--focused'); };
|
|
476
|
-
const isSIXMenuItemElement = (el) => (el === null || el === void 0 ? void 0 : el.tagName.toLowerCase()) === 'six-menu-item';
|
|
477
|
-
const mapToMenuItem = ({ value, label }) => index.h("six-menu-item", { value: value }, label);
|
|
478
|
-
const DEFAULT_NUMBER_OF_ITEMS_SHOWN_FOR_VIRTUAL_SCROLLING = 5;
|
|
479
|
-
const DEFAULT_SIX_MENU_ITEM_HEIGHT = 64;
|
|
480
|
-
const ITEMS_SHOWN_NOT_SET = undefined;
|
|
481
|
-
let SixMenu = class {
|
|
482
|
-
constructor(hostRef) {
|
|
483
|
-
index.registerInstance(this, hostRef);
|
|
484
|
-
this.sixMenuItemSelected = index.createEvent(this, "six-menu-item-selected", 7);
|
|
485
|
-
this.eventListeners = new eventListeners.EventListeners();
|
|
486
|
-
this.typeToSelectString = '';
|
|
487
|
-
/** Set to true to remove the box-shadow */
|
|
488
|
-
this.removeBoxShadow = false;
|
|
489
|
-
/** Set the options to be shown in the dropdown */
|
|
490
|
-
this.items = null;
|
|
491
|
-
/** Defines how many items should be shown. If the number of items is larger than this properties a scrollbar will be shown */
|
|
492
|
-
this.itemsShown = ITEMS_SHOWN_NOT_SET;
|
|
493
|
-
/** Defines whether the menu list will be rendered virtually i.e. only the elements actually shown (and a couple around)
|
|
494
|
-
* are actually rendered in the DOM. If you use virtual scrolling pass the elements via prop instead of via slot. */
|
|
495
|
-
this.virtualScroll = false;
|
|
496
|
-
/**
|
|
497
|
-
* Used for virtual scrolling
|
|
498
|
-
* Define how many items should be rendered in the DOM when using virtual scrolling
|
|
499
|
-
*/
|
|
500
|
-
this.itemSize = 10;
|
|
501
|
-
/**
|
|
502
|
-
* Used for virtual scrolling
|
|
503
|
-
* Define the debounce for listening on scrolling changes in milliseconds.
|
|
504
|
-
* The lower the number the more sensitive the component reacts to scrolling changes.
|
|
505
|
-
*/
|
|
506
|
-
this.scrollingDebounce = 15;
|
|
507
|
-
/**
|
|
508
|
-
* Used to calculate which items should be rendered in the DOM
|
|
509
|
-
*/
|
|
510
|
-
this.scrollingIndex = 0;
|
|
511
|
-
// set a default item height, this variable will be updated with the real value after the first render.
|
|
512
|
-
// However, it's necessary to have a default value because we can only fetch the proper hight after the first render
|
|
513
|
-
this.sixMenuItemHeight = DEFAULT_SIX_MENU_ITEM_HEIGHT;
|
|
514
|
-
this.handleScrolling = () => {
|
|
515
|
-
// for performance improvements we only update the DOM if the scrollRatio change "enough"
|
|
516
|
-
this.scrollingIndex = Math.floor(this.menuWrapper.scrollTop / this.sixMenuItemHeight);
|
|
517
|
-
};
|
|
518
|
-
}
|
|
519
|
-
connectedCallback() {
|
|
520
|
-
this.handleClick = this.handleClick.bind(this);
|
|
521
|
-
this.handleKeyDown = this.handleKeyDown.bind(this);
|
|
522
|
-
}
|
|
523
|
-
componentWillLoad() {
|
|
524
|
-
if (this.items === null) {
|
|
525
|
-
return;
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
componentDidLoad() {
|
|
529
|
-
this.setupForVirtualScrollingAfterRendering();
|
|
530
|
-
}
|
|
531
|
-
disconnectedCallback() {
|
|
532
|
-
this.eventListeners.removeAll();
|
|
533
|
-
}
|
|
534
|
-
/**
|
|
535
|
-
* Initiates type-to-select logic, which automatically selects an option based on what the user is currently typing.
|
|
536
|
-
* The key passed will be appended to the internal query and the selection will be updated. After a brief period, the
|
|
537
|
-
* internal query is cleared automatically. This method is intended to be used with the keydown event. Useful for
|
|
538
|
-
* enabling type-to-select when the menu doesn't have focus.
|
|
539
|
-
*/
|
|
540
|
-
async typeToSelect(key) {
|
|
541
|
-
var _a;
|
|
542
|
-
clearTimeout(this.typeToSelectTimeout);
|
|
543
|
-
this.typeToSelectTimeout = setTimeout(() => (this.typeToSelectString = ''), 750);
|
|
544
|
-
this.typeToSelectString += key.toLowerCase();
|
|
545
|
-
const items = this.getItems();
|
|
546
|
-
for (const item of items) {
|
|
547
|
-
const slot$1 = (_a = item.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('slot:not([name])');
|
|
548
|
-
const label = slot.getTextContent(slot$1).toLowerCase().trim();
|
|
549
|
-
if (label.substring(0, this.typeToSelectString.length) === this.typeToSelectString) {
|
|
550
|
-
item.setFocus();
|
|
551
|
-
break;
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
getItemsShown() {
|
|
556
|
-
var _a;
|
|
557
|
-
const defaultItemsShown = this.virtualScroll
|
|
558
|
-
? DEFAULT_NUMBER_OF_ITEMS_SHOWN_FOR_VIRTUAL_SCROLLING
|
|
559
|
-
: ITEMS_SHOWN_NOT_SET;
|
|
560
|
-
return (_a = this.itemsShown) !== null && _a !== void 0 ? _a : defaultItemsShown;
|
|
561
|
-
}
|
|
562
|
-
setupForVirtualScrollingAfterRendering() {
|
|
563
|
-
var _a, _b;
|
|
564
|
-
if (!this.virtualScroll) {
|
|
565
|
-
return;
|
|
566
|
-
}
|
|
567
|
-
this.eventListeners.add(this.menuWrapper, 'scroll', executionControl.debounce(this.handleScrolling, this.scrollingDebounce));
|
|
568
|
-
// set menu height to proper height once the item is rendered.
|
|
569
|
-
const menuItemHeight = (_b = (_a = this.menu) === null || _a === void 0 ? void 0 : _a.querySelector('six-menu-item')) === null || _b === void 0 ? void 0 : _b.clientHeight;
|
|
570
|
-
if (menuItemHeight && menuItemHeight > 0) {
|
|
571
|
-
this.sixMenuItemHeight = menuItemHeight;
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
getItems() {
|
|
575
|
-
if (this.items !== null && this.items !== undefined) {
|
|
576
|
-
return this.items.map(mapToMenuItem);
|
|
577
|
-
}
|
|
578
|
-
const slot = this.menu.querySelector('slot');
|
|
579
|
-
return [...slot.assignedElements({ flatten: true })].filter((el) => isSIXMenuItemElement(el) && !el.disabled);
|
|
580
|
-
}
|
|
581
|
-
getActiveItemIndex() {
|
|
582
|
-
const items = this.getItems();
|
|
583
|
-
const selectedItem = this.getActiveItem();
|
|
584
|
-
const itemIndex = items.indexOf(selectedItem);
|
|
585
|
-
if (itemIndex > -1) {
|
|
586
|
-
return itemIndex;
|
|
587
|
-
}
|
|
588
|
-
const sixMenuItems = this.extractItemsFromDOM();
|
|
589
|
-
return sixMenuItems.findIndex(isFocusedMenuItem);
|
|
590
|
-
}
|
|
591
|
-
getActiveItem() {
|
|
592
|
-
var _a;
|
|
593
|
-
const activeElement = this.getItems().find((i) => i === document.activeElement);
|
|
594
|
-
if (activeElement) {
|
|
595
|
-
return activeElement;
|
|
596
|
-
}
|
|
597
|
-
return (_a = this.extractItemsFromDOM()) === null || _a === void 0 ? void 0 : _a.find(isFocusedMenuItem);
|
|
598
|
-
}
|
|
599
|
-
extractItemsFromDOM() {
|
|
600
|
-
var _a, _b;
|
|
601
|
-
return Array.from((_b = (_a = this.host) === null || _a === void 0 ? void 0 : _a.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelectorAll('six-menu-item'));
|
|
602
|
-
}
|
|
603
|
-
setActiveItem(item) {
|
|
604
|
-
item.setFocus();
|
|
605
|
-
}
|
|
606
|
-
handleClick(event) {
|
|
607
|
-
const target = event.target;
|
|
608
|
-
const clickedItem = target.closest('six-menu-item');
|
|
609
|
-
if (clickedItem && !clickedItem.disabled) {
|
|
610
|
-
this.sixMenuItemSelected.emit({ name: clickedItem.value, item: clickedItem });
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
handleKeyDown(event) {
|
|
614
|
-
// Make a selection when pressing enter
|
|
615
|
-
if (event.key === 'Enter') {
|
|
616
|
-
const activeItem = this.getActiveItem();
|
|
617
|
-
event.preventDefault();
|
|
618
|
-
if (activeItem) {
|
|
619
|
-
this.sixMenuItemSelected.emit({ name: activeItem.value, item: activeItem });
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
// Prevent scrolling when space is pressed
|
|
623
|
-
if (event.key === ' ') {
|
|
624
|
-
event.preventDefault();
|
|
625
|
-
}
|
|
626
|
-
// Move the selection when pressing down or up
|
|
627
|
-
if (['ArrowDown', 'ArrowUp', 'Home', 'End'].includes(event.key)) {
|
|
628
|
-
const items = this.items === null ? this.getItems() : this.extractItemsFromDOM();
|
|
629
|
-
let indexOfActiveItem = this.getActiveItemIndex();
|
|
630
|
-
if (items.length) {
|
|
631
|
-
event.preventDefault();
|
|
632
|
-
if (event.key === 'ArrowDown') {
|
|
633
|
-
indexOfActiveItem++;
|
|
634
|
-
}
|
|
635
|
-
else if (event.key === 'ArrowUp') {
|
|
636
|
-
indexOfActiveItem--;
|
|
637
|
-
}
|
|
638
|
-
else if (event.key === 'Home') {
|
|
639
|
-
indexOfActiveItem = 0;
|
|
640
|
-
}
|
|
641
|
-
else if (event.key === 'End') {
|
|
642
|
-
indexOfActiveItem = items.length - 1;
|
|
643
|
-
}
|
|
644
|
-
if (indexOfActiveItem < 0)
|
|
645
|
-
indexOfActiveItem = 0;
|
|
646
|
-
if (indexOfActiveItem > items.length - 1)
|
|
647
|
-
indexOfActiveItem = items.length - 1;
|
|
648
|
-
this.setActiveItem(items[indexOfActiveItem]);
|
|
649
|
-
return;
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
void this.typeToSelect(event.key);
|
|
653
|
-
}
|
|
654
|
-
getMenuWrapperStyle() {
|
|
655
|
-
const styles = {};
|
|
656
|
-
if (this.getItemsShown() > 0) {
|
|
657
|
-
// calculate the proper height to show the correct number of items
|
|
658
|
-
styles.height = `${this.getItemsShown() * this.sixMenuItemHeight}px`;
|
|
659
|
-
}
|
|
660
|
-
return Object.assign({}, styles);
|
|
661
|
-
}
|
|
662
|
-
getMenuContainerStyle() {
|
|
663
|
-
const styles = {};
|
|
664
|
-
if (this.virtualScroll) {
|
|
665
|
-
// calculate height of content are if all items would be rendered so the scrollbar has the proper size
|
|
666
|
-
styles.transform = `translateY(${this.sixMenuItemHeight * this.scrollingIndex}px)`;
|
|
667
|
-
}
|
|
668
|
-
return Object.assign({}, styles);
|
|
669
|
-
}
|
|
670
|
-
getScrollbarGhostStyle() {
|
|
671
|
-
const styles = {};
|
|
672
|
-
if (this.virtualScroll && this.items !== null) {
|
|
673
|
-
styles.height = `${this.items.length * this.sixMenuItemHeight - this.itemSize * this.sixMenuItemHeight}px`;
|
|
674
|
-
}
|
|
675
|
-
return Object.assign({}, styles);
|
|
676
|
-
}
|
|
677
|
-
renderItems() {
|
|
678
|
-
if (this.items === undefined || this.items === null) {
|
|
679
|
-
return;
|
|
680
|
-
}
|
|
681
|
-
if (!this.virtualScroll) {
|
|
682
|
-
return this.items.map(mapToMenuItem);
|
|
683
|
-
}
|
|
684
|
-
return this.items
|
|
685
|
-
.slice(this.scrollingIndex, Math.min(this.items.length, this.itemSize + this.scrollingIndex))
|
|
686
|
-
.map(mapToMenuItem);
|
|
687
|
-
}
|
|
688
|
-
render() {
|
|
689
|
-
return (index.h("div", { ref: (el) => (this.menuWrapper = el), style: this.getMenuWrapperStyle(), part: "wrapper", class: {
|
|
690
|
-
menu: true,
|
|
691
|
-
'menu--noshadow': this.removeBoxShadow,
|
|
692
|
-
'menu__wrapper--scrollable': this.getItemsShown() > 0,
|
|
693
|
-
} }, index.h("div", { ref: (el) => (this.menu = el), part: "base", role: "menu", onClick: this.handleClick, onKeyDown: this.handleKeyDown, tabIndex: 0, style: this.getMenuContainerStyle() }, index.h("slot", null), this.renderItems()), this.virtualScroll && index.h("div", { style: this.getScrollbarGhostStyle() })));
|
|
694
|
-
}
|
|
695
|
-
get host() { return index.getElement(this); }
|
|
696
|
-
};
|
|
475
|
+
const isFocusedMenuItem = (menuItem) => { var _a, _b, _c; return (_c = (_b = (_a = menuItem === null || menuItem === void 0 ? void 0 : menuItem.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.menu-item')) === null || _b === void 0 ? void 0 : _b.classList) === null || _c === void 0 ? void 0 : _c.contains('menu-item--focused'); };
|
|
476
|
+
const isSIXMenuItemElement = (el) => (el === null || el === void 0 ? void 0 : el.tagName.toLowerCase()) === 'six-menu-item';
|
|
477
|
+
const mapToMenuItem = ({ value, label }) => index.h("six-menu-item", { value: value }, label);
|
|
478
|
+
const DEFAULT_NUMBER_OF_ITEMS_SHOWN_FOR_VIRTUAL_SCROLLING = 5;
|
|
479
|
+
const DEFAULT_SIX_MENU_ITEM_HEIGHT = 64;
|
|
480
|
+
const ITEMS_SHOWN_NOT_SET = undefined;
|
|
481
|
+
let SixMenu = class {
|
|
482
|
+
constructor(hostRef) {
|
|
483
|
+
index.registerInstance(this, hostRef);
|
|
484
|
+
this.sixMenuItemSelected = index.createEvent(this, "six-menu-item-selected", 7);
|
|
485
|
+
this.eventListeners = new eventListeners.EventListeners();
|
|
486
|
+
this.typeToSelectString = '';
|
|
487
|
+
/** Set to true to remove the box-shadow */
|
|
488
|
+
this.removeBoxShadow = false;
|
|
489
|
+
/** Set the options to be shown in the dropdown */
|
|
490
|
+
this.items = null;
|
|
491
|
+
/** Defines how many items should be shown. If the number of items is larger than this properties a scrollbar will be shown */
|
|
492
|
+
this.itemsShown = ITEMS_SHOWN_NOT_SET;
|
|
493
|
+
/** Defines whether the menu list will be rendered virtually i.e. only the elements actually shown (and a couple around)
|
|
494
|
+
* are actually rendered in the DOM. If you use virtual scrolling pass the elements via prop instead of via slot. */
|
|
495
|
+
this.virtualScroll = false;
|
|
496
|
+
/**
|
|
497
|
+
* Used for virtual scrolling
|
|
498
|
+
* Define how many items should be rendered in the DOM when using virtual scrolling
|
|
499
|
+
*/
|
|
500
|
+
this.itemSize = 10;
|
|
501
|
+
/**
|
|
502
|
+
* Used for virtual scrolling
|
|
503
|
+
* Define the debounce for listening on scrolling changes in milliseconds.
|
|
504
|
+
* The lower the number the more sensitive the component reacts to scrolling changes.
|
|
505
|
+
*/
|
|
506
|
+
this.scrollingDebounce = 15;
|
|
507
|
+
/**
|
|
508
|
+
* Used to calculate which items should be rendered in the DOM
|
|
509
|
+
*/
|
|
510
|
+
this.scrollingIndex = 0;
|
|
511
|
+
// set a default item height, this variable will be updated with the real value after the first render.
|
|
512
|
+
// However, it's necessary to have a default value because we can only fetch the proper hight after the first render
|
|
513
|
+
this.sixMenuItemHeight = DEFAULT_SIX_MENU_ITEM_HEIGHT;
|
|
514
|
+
this.handleScrolling = () => {
|
|
515
|
+
// for performance improvements we only update the DOM if the scrollRatio change "enough"
|
|
516
|
+
this.scrollingIndex = Math.floor(this.menuWrapper.scrollTop / this.sixMenuItemHeight);
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
connectedCallback() {
|
|
520
|
+
this.handleClick = this.handleClick.bind(this);
|
|
521
|
+
this.handleKeyDown = this.handleKeyDown.bind(this);
|
|
522
|
+
}
|
|
523
|
+
componentWillLoad() {
|
|
524
|
+
if (this.items === null) {
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
componentDidLoad() {
|
|
529
|
+
this.setupForVirtualScrollingAfterRendering();
|
|
530
|
+
}
|
|
531
|
+
disconnectedCallback() {
|
|
532
|
+
this.eventListeners.removeAll();
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* Initiates type-to-select logic, which automatically selects an option based on what the user is currently typing.
|
|
536
|
+
* The key passed will be appended to the internal query and the selection will be updated. After a brief period, the
|
|
537
|
+
* internal query is cleared automatically. This method is intended to be used with the keydown event. Useful for
|
|
538
|
+
* enabling type-to-select when the menu doesn't have focus.
|
|
539
|
+
*/
|
|
540
|
+
async typeToSelect(key) {
|
|
541
|
+
var _a;
|
|
542
|
+
clearTimeout(this.typeToSelectTimeout);
|
|
543
|
+
this.typeToSelectTimeout = setTimeout(() => (this.typeToSelectString = ''), 750);
|
|
544
|
+
this.typeToSelectString += key.toLowerCase();
|
|
545
|
+
const items = this.getItems();
|
|
546
|
+
for (const item of items) {
|
|
547
|
+
const slot$1 = (_a = item.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('slot:not([name])');
|
|
548
|
+
const label = slot.getTextContent(slot$1).toLowerCase().trim();
|
|
549
|
+
if (label.substring(0, this.typeToSelectString.length) === this.typeToSelectString) {
|
|
550
|
+
item.setFocus();
|
|
551
|
+
break;
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
getItemsShown() {
|
|
556
|
+
var _a;
|
|
557
|
+
const defaultItemsShown = this.virtualScroll
|
|
558
|
+
? DEFAULT_NUMBER_OF_ITEMS_SHOWN_FOR_VIRTUAL_SCROLLING
|
|
559
|
+
: ITEMS_SHOWN_NOT_SET;
|
|
560
|
+
return (_a = this.itemsShown) !== null && _a !== void 0 ? _a : defaultItemsShown;
|
|
561
|
+
}
|
|
562
|
+
setupForVirtualScrollingAfterRendering() {
|
|
563
|
+
var _a, _b;
|
|
564
|
+
if (!this.virtualScroll) {
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
this.eventListeners.add(this.menuWrapper, 'scroll', executionControl.debounce(this.handleScrolling, this.scrollingDebounce));
|
|
568
|
+
// set menu height to proper height once the item is rendered.
|
|
569
|
+
const menuItemHeight = (_b = (_a = this.menu) === null || _a === void 0 ? void 0 : _a.querySelector('six-menu-item')) === null || _b === void 0 ? void 0 : _b.clientHeight;
|
|
570
|
+
if (menuItemHeight && menuItemHeight > 0) {
|
|
571
|
+
this.sixMenuItemHeight = menuItemHeight;
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
getItems() {
|
|
575
|
+
if (this.items !== null && this.items !== undefined) {
|
|
576
|
+
return this.items.map(mapToMenuItem);
|
|
577
|
+
}
|
|
578
|
+
const slot = this.menu.querySelector('slot');
|
|
579
|
+
return [...slot.assignedElements({ flatten: true })].filter((el) => isSIXMenuItemElement(el) && !el.disabled);
|
|
580
|
+
}
|
|
581
|
+
getActiveItemIndex() {
|
|
582
|
+
const items = this.getItems();
|
|
583
|
+
const selectedItem = this.getActiveItem();
|
|
584
|
+
const itemIndex = items.indexOf(selectedItem);
|
|
585
|
+
if (itemIndex > -1) {
|
|
586
|
+
return itemIndex;
|
|
587
|
+
}
|
|
588
|
+
const sixMenuItems = this.extractItemsFromDOM();
|
|
589
|
+
return sixMenuItems.findIndex(isFocusedMenuItem);
|
|
590
|
+
}
|
|
591
|
+
getActiveItem() {
|
|
592
|
+
var _a;
|
|
593
|
+
const activeElement = this.getItems().find((i) => i === document.activeElement);
|
|
594
|
+
if (activeElement) {
|
|
595
|
+
return activeElement;
|
|
596
|
+
}
|
|
597
|
+
return (_a = this.extractItemsFromDOM()) === null || _a === void 0 ? void 0 : _a.find(isFocusedMenuItem);
|
|
598
|
+
}
|
|
599
|
+
extractItemsFromDOM() {
|
|
600
|
+
var _a, _b;
|
|
601
|
+
return Array.from((_b = (_a = this.host) === null || _a === void 0 ? void 0 : _a.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelectorAll('six-menu-item'));
|
|
602
|
+
}
|
|
603
|
+
setActiveItem(item) {
|
|
604
|
+
item.setFocus();
|
|
605
|
+
}
|
|
606
|
+
handleClick(event) {
|
|
607
|
+
const target = event.target;
|
|
608
|
+
const clickedItem = target.closest('six-menu-item');
|
|
609
|
+
if (clickedItem && !clickedItem.disabled) {
|
|
610
|
+
this.sixMenuItemSelected.emit({ name: clickedItem.value, item: clickedItem });
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
handleKeyDown(event) {
|
|
614
|
+
// Make a selection when pressing enter
|
|
615
|
+
if (event.key === 'Enter') {
|
|
616
|
+
const activeItem = this.getActiveItem();
|
|
617
|
+
event.preventDefault();
|
|
618
|
+
if (activeItem) {
|
|
619
|
+
this.sixMenuItemSelected.emit({ name: activeItem.value, item: activeItem });
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
// Prevent scrolling when space is pressed
|
|
623
|
+
if (event.key === ' ') {
|
|
624
|
+
event.preventDefault();
|
|
625
|
+
}
|
|
626
|
+
// Move the selection when pressing down or up
|
|
627
|
+
if (['ArrowDown', 'ArrowUp', 'Home', 'End'].includes(event.key)) {
|
|
628
|
+
const items = this.items === null ? this.getItems() : this.extractItemsFromDOM();
|
|
629
|
+
let indexOfActiveItem = this.getActiveItemIndex();
|
|
630
|
+
if (items.length) {
|
|
631
|
+
event.preventDefault();
|
|
632
|
+
if (event.key === 'ArrowDown') {
|
|
633
|
+
indexOfActiveItem++;
|
|
634
|
+
}
|
|
635
|
+
else if (event.key === 'ArrowUp') {
|
|
636
|
+
indexOfActiveItem--;
|
|
637
|
+
}
|
|
638
|
+
else if (event.key === 'Home') {
|
|
639
|
+
indexOfActiveItem = 0;
|
|
640
|
+
}
|
|
641
|
+
else if (event.key === 'End') {
|
|
642
|
+
indexOfActiveItem = items.length - 1;
|
|
643
|
+
}
|
|
644
|
+
if (indexOfActiveItem < 0)
|
|
645
|
+
indexOfActiveItem = 0;
|
|
646
|
+
if (indexOfActiveItem > items.length - 1)
|
|
647
|
+
indexOfActiveItem = items.length - 1;
|
|
648
|
+
this.setActiveItem(items[indexOfActiveItem]);
|
|
649
|
+
return;
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
void this.typeToSelect(event.key);
|
|
653
|
+
}
|
|
654
|
+
getMenuWrapperStyle() {
|
|
655
|
+
const styles = {};
|
|
656
|
+
if (this.getItemsShown() > 0) {
|
|
657
|
+
// calculate the proper height to show the correct number of items
|
|
658
|
+
styles.height = `${this.getItemsShown() * this.sixMenuItemHeight}px`;
|
|
659
|
+
}
|
|
660
|
+
return Object.assign({}, styles);
|
|
661
|
+
}
|
|
662
|
+
getMenuContainerStyle() {
|
|
663
|
+
const styles = {};
|
|
664
|
+
if (this.virtualScroll) {
|
|
665
|
+
// calculate height of content are if all items would be rendered so the scrollbar has the proper size
|
|
666
|
+
styles.transform = `translateY(${this.sixMenuItemHeight * this.scrollingIndex}px)`;
|
|
667
|
+
}
|
|
668
|
+
return Object.assign({}, styles);
|
|
669
|
+
}
|
|
670
|
+
getScrollbarGhostStyle() {
|
|
671
|
+
const styles = {};
|
|
672
|
+
if (this.virtualScroll && this.items !== null) {
|
|
673
|
+
styles.height = `${this.items.length * this.sixMenuItemHeight - this.itemSize * this.sixMenuItemHeight}px`;
|
|
674
|
+
}
|
|
675
|
+
return Object.assign({}, styles);
|
|
676
|
+
}
|
|
677
|
+
renderItems() {
|
|
678
|
+
if (this.items === undefined || this.items === null) {
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
681
|
+
if (!this.virtualScroll) {
|
|
682
|
+
return this.items.map(mapToMenuItem);
|
|
683
|
+
}
|
|
684
|
+
return this.items
|
|
685
|
+
.slice(this.scrollingIndex, Math.min(this.items.length, this.itemSize + this.scrollingIndex))
|
|
686
|
+
.map(mapToMenuItem);
|
|
687
|
+
}
|
|
688
|
+
render() {
|
|
689
|
+
return (index.h("div", { ref: (el) => (this.menuWrapper = el), style: this.getMenuWrapperStyle(), part: "wrapper", class: {
|
|
690
|
+
menu: true,
|
|
691
|
+
'menu--noshadow': this.removeBoxShadow,
|
|
692
|
+
'menu__wrapper--scrollable': this.getItemsShown() > 0,
|
|
693
|
+
} }, index.h("div", { ref: (el) => (this.menu = el), part: "base", role: "menu", onClick: this.handleClick, onKeyDown: this.handleKeyDown, tabIndex: 0, style: this.getMenuContainerStyle() }, index.h("slot", null), this.renderItems()), this.virtualScroll && index.h("div", { style: this.getScrollbarGhostStyle() })));
|
|
694
|
+
}
|
|
695
|
+
get host() { return index.getElement(this); }
|
|
696
|
+
};
|
|
697
697
|
SixMenu.style = sixMenuCss;
|
|
698
698
|
|
|
699
699
|
const sixMenuItemCss = ":host{position:relative;box-sizing:border-box}:host *,:host *:before,:host *:after{box-sizing:inherit}:host{display:block}.menu-item{position:relative;display:flex;align-items:stretch;font-family:var(--six-font-sans);font-size:var(--six-font-size-small);font-weight:var(--six-font-weight-normal);line-height:var(--six-line-height-normal);letter-spacing:var(--six-letter-spacing-normal);text-align:left;color:var(--six-input-color);border-radius:var(--six-border-radius-medium);padding:var(--six-spacing-medium) var(--six-spacing-medium);transition:var(--six-transition-fast) fill;user-select:none;white-space:nowrap;cursor:pointer}.menu-item.menu-item--focused:not(.menu-item--disabled){outline:none;background-color:var(--six-menu-item-background-color)}.menu-item.menu-item--disabled{outline:none;color:var(--six-input-color-disabled);cursor:not-allowed}.menu-item .menu-item__label{flex:1 1 auto;align-self:center}.menu-item .menu-item__prefix{flex:0 0 auto;display:flex;align-items:center}.menu-item .menu-item__prefix ::slotted(:last-child){margin-right:0.5em}.menu-item .menu-item__suffix{flex:0 0 auto;display:flex;align-items:center}.menu-item .menu-item__suffix ::slotted(:first-child){margin-left:0.5em}.menu-item .menu-item__check{flex:0 0 auto;display:flex;align-items:center;margin-left:var(--six-spacing-small);visibility:hidden;font-size:inherit}.menu-item--checked .menu-item__check{visibility:visible}";
|
|
700
700
|
|
|
701
|
-
let SixMenuItem = class {
|
|
702
|
-
constructor(hostRef) {
|
|
703
|
-
index.registerInstance(this, hostRef);
|
|
704
|
-
this.hasFocus = false;
|
|
705
|
-
/** Set to true to draw the item in a checked state. */
|
|
706
|
-
this.checked = false;
|
|
707
|
-
/** A unique value to store in the menu item. This can be used as a way to identify menu items when selected. */
|
|
708
|
-
this.value = '';
|
|
709
|
-
/** Set to true to draw the menu item in a disabled state. */
|
|
710
|
-
this.disabled = false;
|
|
711
|
-
}
|
|
712
|
-
connectedCallback() {
|
|
713
|
-
this.handleBlur = this.handleBlur.bind(this);
|
|
714
|
-
this.handleFocus = this.handleFocus.bind(this);
|
|
715
|
-
this.handleMouseEnter = this.handleMouseEnter.bind(this);
|
|
716
|
-
this.handleMouseLeave = this.handleMouseLeave.bind(this);
|
|
717
|
-
}
|
|
718
|
-
/** Sets focus on the button. */
|
|
719
|
-
async setFocus(options) {
|
|
720
|
-
this.menuItem.focus(options);
|
|
721
|
-
}
|
|
722
|
-
/** Removes focus from the button. */
|
|
723
|
-
async removeFocus() {
|
|
724
|
-
this.menuItem.blur();
|
|
725
|
-
}
|
|
726
|
-
handleBlur() {
|
|
727
|
-
this.hasFocus = false;
|
|
728
|
-
}
|
|
729
|
-
handleFocus() {
|
|
730
|
-
this.hasFocus = true;
|
|
731
|
-
}
|
|
732
|
-
handleMouseEnter() {
|
|
733
|
-
this.setFocus();
|
|
734
|
-
}
|
|
735
|
-
handleMouseLeave() {
|
|
736
|
-
this.removeFocus();
|
|
737
|
-
}
|
|
738
|
-
render() {
|
|
739
|
-
return (index.h("div", { ref: (el) => (this.menuItem = el), part: "base", class: {
|
|
740
|
-
'menu-item': true,
|
|
741
|
-
'menu-item--checked': this.checked,
|
|
742
|
-
'menu-item--disabled': this.disabled,
|
|
743
|
-
'menu-item--focused': this.hasFocus,
|
|
744
|
-
}, role: "menuitem", "aria-disabled": this.disabled ? 'true' : 'false', "aria-checked": this.checked ? 'true' : 'false', tabIndex: !this.disabled ? 0 : null, onFocus: this.handleFocus, onBlur: this.handleBlur, onMouseEnter: this.handleMouseEnter, onMouseLeave: this.handleMouseLeave }, index.h("span", { part: "prefix", class: "menu-item__prefix" }, index.h("slot", { name: "prefix" })), index.h("span", { part: "label", class: "menu-item__label" }, index.h("slot", null)), index.h("span", { part: "suffix", class: "menu-item__suffix" }, index.h("slot", { name: "suffix" })), index.h("span", { part: "checked-icon", class: "menu-item__check" }, index.h("six-icon", { size: "small", "aria-hidden": "true" }, "check"))));
|
|
745
|
-
}
|
|
746
|
-
};
|
|
701
|
+
let SixMenuItem = class {
|
|
702
|
+
constructor(hostRef) {
|
|
703
|
+
index.registerInstance(this, hostRef);
|
|
704
|
+
this.hasFocus = false;
|
|
705
|
+
/** Set to true to draw the item in a checked state. */
|
|
706
|
+
this.checked = false;
|
|
707
|
+
/** A unique value to store in the menu item. This can be used as a way to identify menu items when selected. */
|
|
708
|
+
this.value = '';
|
|
709
|
+
/** Set to true to draw the menu item in a disabled state. */
|
|
710
|
+
this.disabled = false;
|
|
711
|
+
}
|
|
712
|
+
connectedCallback() {
|
|
713
|
+
this.handleBlur = this.handleBlur.bind(this);
|
|
714
|
+
this.handleFocus = this.handleFocus.bind(this);
|
|
715
|
+
this.handleMouseEnter = this.handleMouseEnter.bind(this);
|
|
716
|
+
this.handleMouseLeave = this.handleMouseLeave.bind(this);
|
|
717
|
+
}
|
|
718
|
+
/** Sets focus on the button. */
|
|
719
|
+
async setFocus(options) {
|
|
720
|
+
this.menuItem.focus(options);
|
|
721
|
+
}
|
|
722
|
+
/** Removes focus from the button. */
|
|
723
|
+
async removeFocus() {
|
|
724
|
+
this.menuItem.blur();
|
|
725
|
+
}
|
|
726
|
+
handleBlur() {
|
|
727
|
+
this.hasFocus = false;
|
|
728
|
+
}
|
|
729
|
+
handleFocus() {
|
|
730
|
+
this.hasFocus = true;
|
|
731
|
+
}
|
|
732
|
+
handleMouseEnter() {
|
|
733
|
+
this.setFocus();
|
|
734
|
+
}
|
|
735
|
+
handleMouseLeave() {
|
|
736
|
+
this.removeFocus();
|
|
737
|
+
}
|
|
738
|
+
render() {
|
|
739
|
+
return (index.h("div", { ref: (el) => (this.menuItem = el), part: "base", class: {
|
|
740
|
+
'menu-item': true,
|
|
741
|
+
'menu-item--checked': this.checked,
|
|
742
|
+
'menu-item--disabled': this.disabled,
|
|
743
|
+
'menu-item--focused': this.hasFocus,
|
|
744
|
+
}, role: "menuitem", "aria-disabled": this.disabled ? 'true' : 'false', "aria-checked": this.checked ? 'true' : 'false', tabIndex: !this.disabled ? 0 : null, onFocus: this.handleFocus, onBlur: this.handleBlur, onMouseEnter: this.handleMouseEnter, onMouseLeave: this.handleMouseLeave }, index.h("span", { part: "prefix", class: "menu-item__prefix" }, index.h("slot", { name: "prefix" })), index.h("span", { part: "label", class: "menu-item__label" }, index.h("slot", null)), index.h("span", { part: "suffix", class: "menu-item__suffix" }, index.h("slot", { name: "suffix" })), index.h("span", { part: "checked-icon", class: "menu-item__check" }, index.h("six-icon", { size: "small", "aria-hidden": "true" }, "check"))));
|
|
745
|
+
}
|
|
746
|
+
};
|
|
747
747
|
SixMenuItem.style = sixMenuItemCss;
|
|
748
748
|
|
|
749
749
|
exports.six_dropdown = SixDropdown;
|