material 3.5.2 → 3.5.4
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/components/badge/api.js +156 -156
- package/dist/components/badge/badge.js +9 -9
- package/dist/components/badge/config.js +43 -43
- package/dist/components/badge/constants.js +13 -13
- package/dist/components/badge/features.js +75 -75
- package/dist/components/bottom-app-bar/bottom-app-bar.js +98 -98
- package/dist/components/bottom-app-bar/config.js +5 -5
- package/dist/components/bottom-app-bar/constants.js +8 -8
- package/dist/components/bottom-sheet/api.js +52 -52
- package/dist/components/bottom-sheet/bottom-sheet.js +9 -9
- package/dist/components/bottom-sheet/config.js +17 -17
- package/dist/components/bottom-sheet/constants.js +24 -24
- package/dist/components/bottom-sheet/features/drag.js +91 -91
- package/dist/components/bottom-sheet/features/state.js +148 -148
- package/dist/components/bottom-sheet/features/structure.js +85 -85
- package/dist/components/button/api.js +265 -265
- package/dist/components/button/button.js +15 -15
- package/dist/components/button/config.js +39 -39
- package/dist/components/button/constants.js +21 -21
- package/dist/components/button/features/progress.js +167 -167
- package/dist/components/button/features/toggle.js +31 -31
- package/dist/components/button-group/button-group.js +389 -389
- package/dist/components/button-group/config.js +106 -106
- package/dist/components/button-group/constants.js +62 -62
- package/dist/components/card/api.js +88 -88
- package/dist/components/card/card.js +11 -11
- package/dist/components/card/config.js +131 -131
- package/dist/components/card/constants.js +39 -39
- package/dist/components/card/content.js +175 -175
- package/dist/components/carousel/api.js +49 -49
- package/dist/components/carousel/arrangement.js +51 -51
- package/dist/components/carousel/carousel.js +2 -2
- package/dist/components/carousel/config.js +31 -31
- package/dist/components/carousel/constants.js +17 -17
- package/dist/components/carousel/features/scroll.js +469 -469
- package/dist/components/carousel/features/slides.js +125 -125
- package/dist/components/carousel/keylines.js +244 -244
- package/dist/components/carousel/strategy.js +185 -185
- package/dist/components/checkbox/api.js +87 -87
- package/dist/components/checkbox/checkbox.js +55 -55
- package/dist/components/checkbox/config.js +44 -44
- package/dist/components/checkbox/constants.js +10 -10
- package/dist/components/chips/api.js +157 -157
- package/dist/components/chips/chip/chip.js +275 -275
- package/dist/components/chips/chips.js +25 -25
- package/dist/components/chips/config.js +73 -73
- package/dist/components/chips/constants.js +2 -2
- package/dist/components/chips/features/chip-items.js +15 -15
- package/dist/components/chips/features/container.js +39 -39
- package/dist/components/chips/features/controller.js +317 -317
- package/dist/components/chips/features/dom.js +52 -52
- package/dist/components/datepicker/api.js +6 -6
- package/dist/components/datepicker/config.js +3 -3
- package/dist/components/datepicker/constants.js +39 -39
- package/dist/components/datepicker/datepicker.js +675 -675
- package/dist/components/datepicker/render.js +153 -153
- package/dist/components/datepicker/types.js +6 -6
- package/dist/components/datepicker/utils.js +157 -157
- package/dist/components/dialog/api.js +109 -109
- package/dist/components/dialog/config.js +29 -29
- package/dist/components/dialog/constants.js +35 -35
- package/dist/components/dialog/dialog.js +16 -16
- package/dist/components/dialog/features.js +739 -739
- package/dist/components/divider/config.js +4 -4
- package/dist/components/divider/constants.js +10 -10
- package/dist/components/divider/divider.js +6 -6
- package/dist/components/divider/features.js +72 -72
- package/dist/components/drawer/api.js +73 -73
- package/dist/components/drawer/config.js +61 -61
- package/dist/components/drawer/constants.js +32 -32
- package/dist/components/drawer/drawer.js +38 -38
- package/dist/components/drawer/features/headline.js +34 -34
- package/dist/components/drawer/features/items.js +203 -203
- package/dist/components/drawer/features/state.js +206 -206
- package/dist/components/extended-fab/api.js +92 -92
- package/dist/components/extended-fab/config.js +65 -65
- package/dist/components/extended-fab/constants.js +30 -30
- package/dist/components/extended-fab/extended-fab.js +51 -51
- package/dist/components/fab/api.js +65 -65
- package/dist/components/fab/config.js +46 -46
- package/dist/components/fab/constants.js +25 -25
- package/dist/components/fab/fab.js +9 -9
- package/dist/components/fab-menu/config.js +9 -9
- package/dist/components/fab-menu/constants.js +15 -15
- package/dist/components/fab-menu/fab-menu.js +310 -310
- package/dist/components/fab-menu/stagger.js +18 -18
- package/dist/components/icon-button/api.js +195 -195
- package/dist/components/icon-button/config.js +79 -79
- package/dist/components/icon-button/constants.js +43 -43
- package/dist/components/icon-button/features/toggle.js +116 -116
- package/dist/components/icon-button/icon-button.js +15 -15
- package/dist/components/list/api.js +55 -55
- package/dist/components/list/config.js +56 -56
- package/dist/components/list/constants.js +25 -25
- package/dist/components/list/features/anatomy.js +41 -41
- package/dist/components/list/features/renderer.js +136 -136
- package/dist/components/list/features/selection.js +118 -118
- package/dist/components/list/list.js +9 -9
- package/dist/components/loading-indicator/api.js +117 -117
- package/dist/components/loading-indicator/config.js +13 -13
- package/dist/components/loading-indicator/constants.js +23 -23
- package/dist/components/loading-indicator/features/motion.js +33 -33
- package/dist/components/loading-indicator/features/renderer.js +121 -121
- package/dist/components/loading-indicator/loading-indicator.js +8 -8
- package/dist/components/menu/api.js +76 -76
- package/dist/components/menu/config.js +73 -73
- package/dist/components/menu/constants.js +45 -45
- package/dist/components/menu/features/controller.js +507 -507
- package/dist/components/menu/features/keyboard.js +292 -292
- package/dist/components/menu/features/layer.js +13 -13
- package/dist/components/menu/features/loader.js +61 -61
- package/dist/components/menu/features/opener.js +288 -288
- package/dist/components/menu/features/position.js +279 -279
- package/dist/components/menu/features/registry.js +7 -7
- package/dist/components/menu/features/submenu.js +386 -386
- package/dist/components/menu/features/tasks.js +45 -45
- package/dist/components/menu/menu.js +16 -16
- package/dist/components/menu/on-demand.js +138 -138
- package/dist/components/navigation-bar/navigation-bar.js +144 -144
- package/dist/components/navigation-rail/config.js +11 -11
- package/dist/components/navigation-rail/constants.js +8 -8
- package/dist/components/navigation-rail/navigation-rail.js +237 -237
- package/dist/components/progress/api.js +207 -207
- package/dist/components/progress/config.js +137 -137
- package/dist/components/progress/constants.js +88 -88
- package/dist/components/progress/features/canvas.js +291 -291
- package/dist/components/progress/features/circular.js +69 -69
- package/dist/components/progress/features/colors.js +41 -41
- package/dist/components/progress/features/linear.js +96 -96
- package/dist/components/progress/features/motion.js +87 -87
- package/dist/components/progress/features/state.js +35 -35
- package/dist/components/progress/progress.js +11 -11
- package/dist/components/radios/api.js +54 -54
- package/dist/components/radios/config.js +19 -19
- package/dist/components/radios/constants.js +10 -10
- package/dist/components/radios/radio.js +161 -161
- package/dist/components/radios/radios.js +12 -12
- package/dist/components/search/api.js +116 -116
- package/dist/components/search/config.js +66 -66
- package/dist/components/search/constants.js +75 -75
- package/dist/components/search/features/input.js +238 -238
- package/dist/components/search/features/states.js +279 -279
- package/dist/components/search/features/structure.js +212 -212
- package/dist/components/search/features/suggestions.js +234 -234
- package/dist/components/search/search.js +30 -30
- package/dist/components/select/api.js +92 -92
- package/dist/components/select/config.js +46 -46
- package/dist/components/select/constants.js +39 -39
- package/dist/components/select/features.js +485 -485
- package/dist/components/select/select.js +17 -17
- package/dist/components/side-sheet/api.js +46 -46
- package/dist/components/side-sheet/config.js +19 -19
- package/dist/components/side-sheet/constants.js +22 -22
- package/dist/components/side-sheet/features/state.js +132 -132
- package/dist/components/side-sheet/features/structure.js +89 -89
- package/dist/components/side-sheet/side-sheet.js +8 -8
- package/dist/components/slider/config.js +54 -54
- package/dist/components/slider/constants.js +54 -54
- package/dist/components/slider/features/axis.js +14 -14
- package/dist/components/slider/features/controller.js +944 -944
- package/dist/components/slider/features/dom.js +104 -104
- package/dist/components/slider/features/states.js +83 -83
- package/dist/components/slider/slider.js +16 -16
- package/dist/components/snackbar/api.js +199 -199
- package/dist/components/snackbar/config.js +24 -24
- package/dist/components/snackbar/constants.js +41 -41
- package/dist/components/snackbar/features.js +115 -115
- package/dist/components/snackbar/layer.js +72 -72
- package/dist/components/snackbar/position.js +20 -20
- package/dist/components/snackbar/queue.js +89 -89
- package/dist/components/snackbar/snackbar.js +12 -12
- package/dist/components/split-button/api.js +137 -137
- package/dist/components/split-button/config.js +11 -11
- package/dist/components/split-button/constants.js +24 -24
- package/dist/components/split-button/features/buttons.js +35 -35
- package/dist/components/split-button/features/menu.js +12 -12
- package/dist/components/split-button/split-button.js +11 -11
- package/dist/components/switch/api.js +101 -101
- package/dist/components/switch/config.js +20 -20
- package/dist/components/switch/constants.js +29 -29
- package/dist/components/switch/features.js +123 -123
- package/dist/components/switch/switch.js +13 -13
- package/dist/components/tabs/api.js +104 -104
- package/dist/components/tabs/config.js +20 -20
- package/dist/components/tabs/constants.js +40 -40
- package/dist/components/tabs/features.js +159 -159
- package/dist/components/tabs/indicator.js +151 -151
- package/dist/components/tabs/responsive.js +59 -59
- package/dist/components/tabs/tab.js +218 -218
- package/dist/components/tabs/tabs.js +27 -27
- package/dist/components/tabs/utils.js +121 -121
- package/dist/components/text-field/api.js +212 -212
- package/dist/components/text-field/config.js +30 -30
- package/dist/components/text-field/constants.js +54 -54
- package/dist/components/text-field/features/counter.js +51 -51
- package/dist/components/text-field/features/density.js +36 -36
- package/dist/components/text-field/features/error.js +55 -55
- package/dist/components/text-field/features/field.js +30 -30
- package/dist/components/text-field/features/leading-icon.js +52 -52
- package/dist/components/text-field/features/placement.js +146 -146
- package/dist/components/text-field/features/prefix-text.js +48 -48
- package/dist/components/text-field/features/required.js +48 -48
- package/dist/components/text-field/features/suffix-text.js +48 -48
- package/dist/components/text-field/features/supporting-text.js +85 -85
- package/dist/components/text-field/features/trailing-icon.js +88 -88
- package/dist/components/text-field/text-field.js +11 -11
- package/dist/components/timepicker/api.js +275 -275
- package/dist/components/timepicker/config.js +31 -31
- package/dist/components/timepicker/constants.js +52 -52
- package/dist/components/timepicker/dial.js +164 -164
- package/dist/components/timepicker/render.js +400 -400
- package/dist/components/timepicker/timepicker.js +40 -40
- package/dist/components/timepicker/types.js +8 -8
- package/dist/components/timepicker/utils.js +67 -67
- package/dist/components/toolbar/config.js +35 -35
- package/dist/components/toolbar/constants.js +17 -17
- package/dist/components/toolbar/toolbar.js +188 -188
- package/dist/components/tooltip/api.js +309 -309
- package/dist/components/tooltip/config.js +32 -32
- package/dist/components/tooltip/constants.js +38 -38
- package/dist/components/tooltip/tooltip.js +20 -20
- package/dist/components/tooltip/types.js +15 -15
- package/dist/components/top-app-bar/config.js +5 -5
- package/dist/components/top-app-bar/constants.js +25 -25
- package/dist/components/top-app-bar/top-app-bar.js +158 -158
- package/dist/core/canvas/animation.js +30 -30
- package/dist/core/canvas/drawing.js +52 -52
- package/dist/core/canvas/resize.js +47 -47
- package/dist/core/canvas/utils.js +101 -101
- package/dist/core/compose/base.js +5 -5
- package/dist/core/compose/cleanup.js +47 -47
- package/dist/core/compose/component.js +132 -132
- package/dist/core/compose/features/badge.js +56 -56
- package/dist/core/compose/features/checkable.js +37 -37
- package/dist/core/compose/features/constants.js +1 -1
- package/dist/core/compose/features/debounce.js +39 -39
- package/dist/core/compose/features/disabled.js +61 -61
- package/dist/core/compose/features/events.js +19 -19
- package/dist/core/compose/features/icon.js +66 -66
- package/dist/core/compose/features/input.js +63 -63
- package/dist/core/compose/features/lifecycle.js +71 -71
- package/dist/core/compose/features/position.js +31 -31
- package/dist/core/compose/features/ripple.js +76 -76
- package/dist/core/compose/features/size.js +5 -5
- package/dist/core/compose/features/style.js +7 -7
- package/dist/core/compose/features/text.js +49 -49
- package/dist/core/compose/features/textinput.js +164 -164
- package/dist/core/compose/features/textlabel.js +47 -47
- package/dist/core/compose/features/throttle.js +39 -39
- package/dist/core/compose/features/track.js +24 -24
- package/dist/core/compose/features/variant.js +5 -5
- package/dist/core/compose/features/withEvents.js +48 -48
- package/dist/core/compose/pipe.js +4 -4
- package/dist/core/compose/utils/type-guards.js +6 -6
- package/dist/core/config/component.js +54 -54
- package/dist/core/config/global.js +6 -6
- package/dist/core/config.js +9 -9
- package/dist/core/dom/attributes.js +38 -38
- package/dist/core/dom/classes.js +74 -74
- package/dist/core/dom/create.js +133 -133
- package/dist/core/dom/direction.js +28 -28
- package/dist/core/dom/events.js +80 -80
- package/dist/core/dom/focus.js +38 -38
- package/dist/core/dom/form-value.js +10 -10
- package/dist/core/dom/html.js +7 -7
- package/dist/core/dom/layer.js +134 -134
- package/dist/core/dom/roving.js +69 -69
- package/dist/core/dom/utils.js +38 -38
- package/dist/core/navigation/destinations.js +103 -103
- package/dist/core/navigation/ripple.js +39 -39
- package/dist/core/shapes/cubic.js +55 -55
- package/dist/core/shapes/material.js +164 -164
- package/dist/core/shapes/polygon.js +198 -198
- package/dist/core/state/emitter.js +29 -29
- package/dist/core/state/events.js +30 -30
- package/dist/core/state/store.js +55 -55
- package/dist/core/theme/tokens.js +28 -28
- package/dist/core/utils/attributes.js +8 -8
- package/dist/core/utils/background.js +29 -29
- package/dist/core/utils/color.js +21 -21
- package/dist/core/utils/mobile.js +28 -28
- package/dist/core/utils/object.js +17 -17
- package/dist/core/utils/performance.js +111 -111
- package/dist/core/utils/theme.js +49 -49
- package/dist/core/utils/url.js +0 -0
- package/dist/core/utils/warn.js +14 -14
- package/dist/elements/adapter.js +51 -51
- package/dist/elements/badge.js +23 -23
- package/dist/elements/bottom-app-bar.js +32 -32
- package/dist/elements/bottom-sheet.js +81 -81
- package/dist/elements/button-group.js +151 -151
- package/dist/elements/button.js +40 -40
- package/dist/elements/card.js +89 -89
- package/dist/elements/carousel.js +101 -101
- package/dist/elements/checkbox.js +44 -44
- package/dist/elements/chips.js +185 -185
- package/dist/elements/datepicker.js +101 -101
- package/dist/elements/define.js +571 -571
- package/dist/elements/dialog.js +134 -134
- package/dist/elements/divider.js +16 -16
- package/dist/elements/drawer.js +118 -118
- package/dist/elements/extended-fab.js +29 -29
- package/dist/elements/fab-menu.js +58 -58
- package/dist/elements/fab.js +18 -18
- package/dist/elements/form-button.js +14 -14
- package/dist/elements/icon-button.js +42 -42
- package/dist/elements/index.js +87 -87
- package/dist/elements/lifecycle.js +8 -8
- package/dist/elements/list.js +162 -162
- package/dist/elements/loading-indicator.js +19 -19
- package/dist/elements/menu.js +169 -169
- package/dist/elements/navigation-bar.js +58 -58
- package/dist/elements/navigation-rail.js +110 -110
- package/dist/elements/preupgrade/badge.css +1 -1
- package/dist/elements/preupgrade/bottom-app-bar.css +1 -1
- package/dist/elements/preupgrade/bottom-sheet.css +1 -1
- package/dist/elements/preupgrade/button-group.css +1 -1
- package/dist/elements/preupgrade/button.css +1 -1
- package/dist/elements/preupgrade/card.css +1 -1
- package/dist/elements/preupgrade/carousel.css +1 -1
- package/dist/elements/preupgrade/checkbox.css +1 -1
- package/dist/elements/preupgrade/chips.css +1 -1
- package/dist/elements/preupgrade/datepicker.css +1 -1
- package/dist/elements/preupgrade/dialog.css +1 -1
- package/dist/elements/preupgrade/divider.css +1 -1
- package/dist/elements/preupgrade/drawer.css +1 -1
- package/dist/elements/preupgrade/extended-fab.css +1 -1
- package/dist/elements/preupgrade/fab-menu.css +1 -1
- package/dist/elements/preupgrade/fab.css +1 -1
- package/dist/elements/preupgrade/icon-button.css +1 -1
- package/dist/elements/preupgrade/list.css +1 -1
- package/dist/elements/preupgrade/loading-indicator.css +1 -1
- package/dist/elements/preupgrade/menu.css +1 -1
- package/dist/elements/preupgrade/navigation-bar.css +1 -1
- package/dist/elements/preupgrade/navigation-rail.css +1 -1
- package/dist/elements/preupgrade/progress.css +1 -1
- package/dist/elements/preupgrade/radios.css +1 -1
- package/dist/elements/preupgrade/search.css +1 -1
- package/dist/elements/preupgrade/select.css +1 -1
- package/dist/elements/preupgrade/side-sheet.css +1 -1
- package/dist/elements/preupgrade/slider.css +1 -1
- package/dist/elements/preupgrade/snackbar.css +1 -1
- package/dist/elements/preupgrade/split-button.css +1 -1
- package/dist/elements/preupgrade/switch.css +1 -1
- package/dist/elements/preupgrade/tabs.css +1 -1
- package/dist/elements/preupgrade/text-field.css +1 -1
- package/dist/elements/preupgrade/timepicker.css +1 -1
- package/dist/elements/preupgrade/toolbar.css +1 -1
- package/dist/elements/preupgrade/tooltip.css +1 -1
- package/dist/elements/preupgrade/top-app-bar.css +1 -1
- package/dist/elements/preupgrade.css +1 -1
- package/dist/elements/preupgrade.js +0 -1
- package/dist/elements/progress.js +32 -32
- package/dist/elements/radios.js +105 -105
- package/dist/elements/search.js +189 -189
- package/dist/elements/select.js +124 -124
- package/dist/elements/sheet.js +49 -49
- package/dist/elements/side-sheet.js +53 -53
- package/dist/elements/slider.js +117 -117
- package/dist/elements/snackbar.js +45 -45
- package/dist/elements/split-button.js +82 -82
- package/dist/elements/styles.js +27 -27
- package/dist/elements/switch.js +43 -43
- package/dist/elements/tabs.js +96 -96
- package/dist/elements/text-field.js +117 -117
- package/dist/elements/timepicker.js +142 -142
- package/dist/elements/toolbar.js +63 -63
- package/dist/elements/tooltip.js +111 -111
- package/dist/elements/top-app-bar.js +75 -75
- package/dist/package.json +1 -1
- package/dist/react/create.js +113 -113
- package/dist/react/shadow.js +8 -8
- package/dist/solid/create.js +122 -122
- package/dist/solid/shadow.js +6 -6
- package/dist/ssr/index.js +17 -17
- package/dist/ssr/react.js +2 -310
- package/dist/ssr/solid.js +1 -16
- package/dist/ssr/svelte.js +1 -73
- package/dist/ssr/vue.js +1 -71
- package/dist/styles/badge.css +1 -1
- package/dist/styles/base.css +1 -1
- package/dist/styles/bottom-app-bar.css +1 -1
- package/dist/styles/bottom-sheet.css +1 -1
- package/dist/styles/button-group.css +1 -1
- package/dist/styles/button.css +1 -1
- package/dist/styles/card.css +1 -1
- package/dist/styles/carousel.css +1 -1
- package/dist/styles/checkbox.css +1 -1
- package/dist/styles/chips.css +1 -1
- package/dist/styles/contrast.css +1 -1
- package/dist/styles/datepicker.css +1 -1
- package/dist/styles/dialog.css +1 -1
- package/dist/styles/divider.css +1 -1
- package/dist/styles/drawer.css +1 -1
- package/dist/styles/extended-fab.css +1 -1
- package/dist/styles/fab-menu.css +1 -1
- package/dist/styles/fab.css +1 -1
- package/dist/styles/icon-button.css +1 -1
- package/dist/styles/list.css +1 -1
- package/dist/styles/loading-indicator.css +1 -1
- package/dist/styles/menu.css +1 -1
- package/dist/styles/navigation-bar.css +1 -1
- package/dist/styles/navigation-rail.css +1 -1
- package/dist/styles/progress.css +1 -1
- package/dist/styles/radios.css +1 -1
- package/dist/styles/search.css +1 -1
- package/dist/styles/select.css +1 -1
- package/dist/styles/side-sheet.css +1 -1
- package/dist/styles/slider.css +1 -1
- package/dist/styles/snackbar.css +1 -1
- package/dist/styles/split-button.css +1 -1
- package/dist/styles/switch.css +1 -1
- package/dist/styles/tabs.css +1 -1
- package/dist/styles/text-field.css +1 -1
- package/dist/styles/timepicker.css +1 -1
- package/dist/styles/toolbar.css +1 -1
- package/dist/styles/tooltip.css +1 -1
- package/dist/styles/top-app-bar.css +1 -1
- package/dist/styles/typography.css +1 -1
- package/dist/styles/utilities.css +1 -1
- package/dist/styles.css +1 -1
- package/dist/themes/autumn-contrast.css +1 -1
- package/dist/themes/autumn.css +1 -1
- package/dist/themes/baseline-contrast.css +1 -1
- package/dist/themes/baseline.css +1 -1
- package/dist/themes/brownbeige-contrast.css +1 -1
- package/dist/themes/brownbeige.css +1 -1
- package/dist/themes/content-contrast.css +1 -1
- package/dist/themes/content.css +1 -1
- package/dist/themes/desert-contrast.css +1 -1
- package/dist/themes/desert.css +1 -1
- package/dist/themes/expressive-contrast.css +1 -1
- package/dist/themes/expressive.css +1 -1
- package/dist/themes/fidelity-contrast.css +1 -1
- package/dist/themes/fidelity.css +1 -1
- package/dist/themes/forest-contrast.css +1 -1
- package/dist/themes/forest.css +1 -1
- package/dist/themes/fruit-salad-contrast.css +1 -1
- package/dist/themes/fruit-salad.css +1 -1
- package/dist/themes/highcontrast-contrast.css +1 -1
- package/dist/themes/highcontrast.css +1 -1
- package/dist/themes/monochrome-contrast.css +1 -1
- package/dist/themes/monochrome.css +1 -1
- package/dist/themes/neutral-contrast.css +1 -1
- package/dist/themes/neutral.css +1 -1
- package/dist/themes/ocean-contrast.css +1 -1
- package/dist/themes/ocean.css +1 -1
- package/dist/themes/rainbow-contrast.css +1 -1
- package/dist/themes/rainbow.css +1 -1
- package/dist/themes/sageivory-contrast.css +1 -1
- package/dist/themes/sageivory.css +1 -1
- package/dist/themes/spring-contrast.css +1 -1
- package/dist/themes/spring.css +1 -1
- package/dist/themes/summer-contrast.css +1 -1
- package/dist/themes/summer.css +1 -1
- package/dist/themes/sunset-contrast.css +1 -1
- package/dist/themes/sunset.css +1 -1
- package/dist/themes/tealcaramel-contrast.css +1 -1
- package/dist/themes/tealcaramel.css +1 -1
- package/dist/themes/vibrant-contrast.css +1 -1
- package/dist/themes/vibrant.css +1 -1
- package/dist/vue/create.js +123 -123
- package/dist/vue/shadow.js +6 -6
- package/package.json +1 -1
|
@@ -4,765 +4,765 @@ import { setHTML } from "../../core/dom/html.js";
|
|
|
4
4
|
import { deepActiveElement, tabStops, wrapTab } from "../../core/dom/focus.js";
|
|
5
5
|
import { hideFromTopLayer, onModalEscape, onTopLayerClose, showInTopLayer } from "../../core/dom/layer.js";
|
|
6
6
|
const DIALOG_EVENTS = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
OPEN: "open",
|
|
8
|
+
CLOSE: "close",
|
|
9
|
+
BEFORE_OPEN: "beforeopen",
|
|
10
|
+
BEFORE_CLOSE: "beforeclose",
|
|
11
|
+
AFTER_OPEN: "afteropen",
|
|
12
|
+
AFTER_CLOSE: "afterclose",
|
|
13
13
|
};
|
|
14
14
|
let dialogCount = 0;
|
|
15
15
|
export const withStructure = (config, getComponent) => (component) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
16
|
+
const uid = `${component.getClass("dialog")}-${++dialogCount}`;
|
|
17
|
+
const titleId = `${uid}-title`;
|
|
18
|
+
const contentId = `${uid}-content`;
|
|
19
|
+
const overlay = document.createElement("div");
|
|
20
|
+
overlay.classList.add(component.getClass("dialog__overlay"));
|
|
21
|
+
if (config.zIndex) {
|
|
22
|
+
overlay.style.zIndex = String(config.zIndex);
|
|
23
|
+
}
|
|
24
|
+
const showCloseButton = config.closeButton ?? config.size === "fullscreen";
|
|
25
|
+
const createHeader = () => {
|
|
26
|
+
const header = document.createElement("div");
|
|
27
|
+
header.classList.add(component.getClass("dialog__header"));
|
|
28
|
+
const headerContent = document.createElement("div");
|
|
29
|
+
headerContent.classList.add(component.getClass("dialog__header-content"));
|
|
30
|
+
header.appendChild(headerContent);
|
|
31
|
+
if (config.title) {
|
|
32
|
+
const title = document.createElement("h2");
|
|
33
|
+
title.classList.add(component.getClass("dialog__header-title"));
|
|
34
|
+
title.id = titleId;
|
|
35
|
+
title.textContent = config.title;
|
|
36
|
+
headerContent.appendChild(title);
|
|
37
|
+
}
|
|
38
|
+
if (config.subtitle) {
|
|
39
|
+
const subtitle = document.createElement("p");
|
|
40
|
+
subtitle.classList.add(component.getClass("dialog__header-subtitle"));
|
|
41
|
+
subtitle.textContent = config.subtitle;
|
|
42
|
+
headerContent.appendChild(subtitle);
|
|
43
|
+
}
|
|
44
|
+
if (showCloseButton) {
|
|
45
|
+
const closeButton = document.createElement("button");
|
|
46
|
+
closeButton.classList.add(component.getClass("dialog__header-close"));
|
|
47
|
+
closeButton.setAttribute("aria-label", "Close dialog");
|
|
48
|
+
setHTML(closeButton, `
|
|
49
49
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
50
50
|
<line x1="18" y1="6" x2="6" y2="18"></line>
|
|
51
51
|
<line x1="6" y1="6" x2="18" y2="18"></line>
|
|
52
52
|
</svg>
|
|
53
53
|
`);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
54
|
+
closeButton.addEventListener("click", (e) => {
|
|
55
|
+
e.preventDefault();
|
|
56
|
+
e.stopPropagation();
|
|
57
|
+
if (component && component.emit) {
|
|
58
|
+
component.emit("dialog:close", { source: "closeButton" });
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
header.appendChild(closeButton);
|
|
62
|
+
}
|
|
63
|
+
return header;
|
|
64
|
+
};
|
|
65
|
+
const createContent = () => {
|
|
66
|
+
const content = document.createElement("div");
|
|
67
|
+
content.classList.add(component.getClass("dialog__content"));
|
|
68
|
+
content.id = contentId;
|
|
69
|
+
if (config.content) {
|
|
70
|
+
setHTML(content, config.content);
|
|
71
|
+
}
|
|
72
|
+
return content;
|
|
73
|
+
};
|
|
74
|
+
const createFooter = () => {
|
|
75
|
+
const footer = document.createElement("div");
|
|
76
|
+
footer.classList.add(component.getClass("dialog__footer"));
|
|
77
|
+
const alignment = config.footerAlignment || "right";
|
|
78
|
+
if (alignment !== "right") {
|
|
79
|
+
addClass(footer, `${component.getClass("dialog__footer")}--${alignment}`);
|
|
80
|
+
}
|
|
81
|
+
if (Array.isArray(config.buttons) && config.buttons.length > 0) {
|
|
82
|
+
config.buttons.forEach((buttonConfig) => addButton(footer, buttonConfig, component, getComponent));
|
|
83
|
+
}
|
|
84
|
+
return footer;
|
|
85
|
+
};
|
|
86
|
+
const createDividerElement = () => {
|
|
87
|
+
const divider = document.createElement("hr");
|
|
88
|
+
divider.classList.add(component.getClass("dialog__divider"));
|
|
89
|
+
return divider;
|
|
90
|
+
};
|
|
91
|
+
const header = createHeader();
|
|
92
|
+
const content = createContent();
|
|
93
|
+
const footer = Array.isArray(config.buttons) && config.buttons.length > 0
|
|
94
|
+
? createFooter()
|
|
95
|
+
: null;
|
|
96
|
+
addClass(component.element, component.getClass("dialog"));
|
|
97
|
+
if (config.title) {
|
|
98
|
+
component.element.setAttribute("aria-labelledby", titleId);
|
|
99
|
+
}
|
|
100
|
+
else if (config.ariaLabel) {
|
|
101
|
+
component.element.setAttribute("aria-label", config.ariaLabel);
|
|
102
|
+
}
|
|
103
|
+
if (config.content) {
|
|
104
|
+
component.element.setAttribute("aria-describedby", contentId);
|
|
105
|
+
}
|
|
106
|
+
const size = config.size || "medium";
|
|
107
|
+
if (size !== "medium") {
|
|
108
|
+
addClass(component.element, `${component.getClass("dialog")}--${size}`);
|
|
109
|
+
}
|
|
110
|
+
const animation = config.animation || "scale";
|
|
111
|
+
if (animation !== "scale") {
|
|
112
|
+
addClass(component.element, `${component.getClass("dialog")}--${animation}`);
|
|
113
|
+
}
|
|
114
|
+
component.element.appendChild(header);
|
|
115
|
+
let headerDivider = null;
|
|
116
|
+
let footerDivider = null;
|
|
117
|
+
if (config.divider) {
|
|
118
|
+
headerDivider = createDividerElement();
|
|
119
|
+
headerDivider.classList.add(component.getClass("dialog__header-divider"));
|
|
120
|
+
component.element.appendChild(headerDivider);
|
|
121
|
+
if (footer) {
|
|
122
|
+
footerDivider = createDividerElement();
|
|
123
|
+
footerDivider.classList.add(component.getClass("dialog__footer-divider"));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
component.element.appendChild(content);
|
|
127
|
+
if (footerDivider) {
|
|
128
|
+
component.element.appendChild(footerDivider);
|
|
129
|
+
}
|
|
130
|
+
if (footer) {
|
|
131
|
+
component.element.appendChild(footer);
|
|
132
|
+
}
|
|
133
|
+
const container = config.container || document.body;
|
|
134
|
+
if (config.layer === "top") {
|
|
135
|
+
container.appendChild(component.element);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
overlay.appendChild(component.element);
|
|
139
|
+
container.appendChild(overlay);
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
...component,
|
|
143
|
+
overlay,
|
|
144
|
+
structure: {
|
|
145
|
+
header,
|
|
146
|
+
content,
|
|
147
|
+
footer,
|
|
148
|
+
headerDivider,
|
|
149
|
+
footerDivider,
|
|
150
|
+
container,
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
153
|
};
|
|
154
154
|
export const withDivider = () => (component) => {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
155
|
+
return {
|
|
156
|
+
...component,
|
|
157
|
+
divider: {
|
|
158
|
+
toggleDivider(show) {
|
|
159
|
+
if (show && !component.structure.headerDivider) {
|
|
160
|
+
const headerDivider = document.createElement("hr");
|
|
161
|
+
headerDivider.classList.add(component.getClass("dialog__divider"), component.getClass("dialog__header-divider"));
|
|
162
|
+
component.element.insertBefore(headerDivider, component.structure.content);
|
|
163
|
+
component.structure.headerDivider = headerDivider;
|
|
164
|
+
if (component.structure.footer &&
|
|
165
|
+
!component.structure.footerDivider) {
|
|
166
|
+
const footerDivider = document.createElement("hr");
|
|
167
|
+
footerDivider.classList.add(component.getClass("dialog__divider"), component.getClass("dialog__footer-divider"));
|
|
168
|
+
component.element.insertBefore(footerDivider, component.structure.footer);
|
|
169
|
+
component.structure.footerDivider = footerDivider;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
else if (!show) {
|
|
173
|
+
if (component.structure.headerDivider) {
|
|
174
|
+
component.structure.headerDivider.remove();
|
|
175
|
+
component.structure.headerDivider = null;
|
|
176
|
+
}
|
|
177
|
+
if (component.structure.footerDivider) {
|
|
178
|
+
component.structure.footerDivider.remove();
|
|
179
|
+
component.structure.footerDivider = null;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return component;
|
|
183
|
+
},
|
|
184
|
+
hasDivider() {
|
|
185
|
+
return component.structure.headerDivider !== null;
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
189
|
};
|
|
190
190
|
const addButton = (footer, buttonConfig, component, getComponent) => {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
191
|
+
const { text, variant = "text", onClick, closeDialog = true, autofocus = false, attributes = {}, size, } = buttonConfig;
|
|
192
|
+
const button = createButton({
|
|
193
|
+
text,
|
|
194
|
+
variant,
|
|
195
|
+
...(size ? { size } : {}),
|
|
196
|
+
...attributes,
|
|
197
|
+
});
|
|
198
|
+
button.on("click", ({ originalEvent: event }) => {
|
|
199
|
+
let shouldClose = closeDialog;
|
|
200
|
+
if (typeof onClick === "function") {
|
|
201
|
+
try {
|
|
202
|
+
const result = onClick(event, getComponent());
|
|
203
|
+
if (result === false) {
|
|
204
|
+
shouldClose = false;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
catch (err) {
|
|
208
|
+
console.error("Error in onClick handler:", err);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
if (shouldClose) {
|
|
212
|
+
if (component && component.emit) {
|
|
213
|
+
component.emit("dialog:close", { source: "button", text });
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
if (autofocus) {
|
|
218
|
+
button.element.setAttribute("autofocus", "true");
|
|
219
|
+
}
|
|
220
|
+
footer.appendChild(button.element);
|
|
221
|
+
if (!component._buttons) {
|
|
222
|
+
component._buttons = [];
|
|
223
|
+
}
|
|
224
|
+
component._buttons.push({
|
|
225
|
+
config: buttonConfig,
|
|
226
|
+
instance: button,
|
|
227
|
+
});
|
|
228
228
|
};
|
|
229
229
|
export const withVisibility = (getComponent) => (component) => {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
230
|
+
const isOpen = component.config.open === true;
|
|
231
|
+
let opened = isOpen;
|
|
232
|
+
let escape;
|
|
233
|
+
let asking = false;
|
|
234
|
+
let showTimer;
|
|
235
|
+
let afterOpenTimer;
|
|
236
|
+
let afterCloseTimer;
|
|
237
|
+
let afterOpenWaiting = false;
|
|
238
|
+
const openDuration = component.config.animationDuration ?? 500;
|
|
239
|
+
const closeDuration = component.config.animationDuration ?? 150;
|
|
240
|
+
const top = component.config.layer === "top";
|
|
241
|
+
const scrim = top ? component.element : component.overlay;
|
|
242
|
+
let previouslyFocusedElement = null;
|
|
243
|
+
let mouseDownOnOverlay = false;
|
|
244
|
+
const inerted = [];
|
|
245
|
+
let scrollLock = null;
|
|
246
|
+
let focusFrame;
|
|
247
|
+
let focusView;
|
|
248
|
+
let focusRequest = 0;
|
|
249
|
+
let focusPending = false;
|
|
250
|
+
const cancelFocusFrame = () => {
|
|
251
|
+
focusRequest += 1;
|
|
252
|
+
focusPending = false;
|
|
253
|
+
if (focusFrame !== undefined) {
|
|
254
|
+
focusView?.cancelAnimationFrame(focusFrame);
|
|
255
|
+
focusFrame = undefined;
|
|
256
|
+
focusView = undefined;
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
const emitAfterOpen = () => {
|
|
260
|
+
afterOpenWaiting = false;
|
|
261
|
+
if (!opened || typeof component.emit !== "function")
|
|
262
|
+
return;
|
|
263
|
+
component.emit(DIALOG_EVENTS.AFTER_OPEN, { dialog: getComponent() });
|
|
264
|
+
};
|
|
265
|
+
const afterOpenDue = () => {
|
|
266
|
+
afterOpenTimer = undefined;
|
|
267
|
+
if (focusPending) {
|
|
268
|
+
afterOpenWaiting = true;
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
emitAfterOpen();
|
|
272
|
+
};
|
|
273
|
+
const inertBackground = () => {
|
|
274
|
+
if (component.config.modal === false)
|
|
275
|
+
return;
|
|
276
|
+
const parent = top ? null : component.overlay.parentElement;
|
|
277
|
+
if (parent) {
|
|
278
|
+
Array.from(parent.children).forEach((sibling) => {
|
|
279
|
+
if (sibling === component.overlay)
|
|
280
|
+
return;
|
|
281
|
+
if (sibling.hasAttribute("inert"))
|
|
282
|
+
return;
|
|
283
|
+
sibling.setAttribute("inert", "");
|
|
284
|
+
inerted.push(sibling);
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
const body = component.element.ownerDocument.body;
|
|
288
|
+
if (body && scrollLock === null) {
|
|
289
|
+
scrollLock = body.style.overflow;
|
|
290
|
+
body.style.overflow = "hidden";
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
const releaseBackground = () => {
|
|
294
|
+
inerted.forEach((el) => el.removeAttribute("inert"));
|
|
295
|
+
inerted.length = 0;
|
|
296
|
+
const body = component.element.ownerDocument.body;
|
|
297
|
+
if (body && scrollLock !== null) {
|
|
298
|
+
body.style.overflow = scrollLock;
|
|
299
|
+
scrollLock = null;
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
let containerPosition = null;
|
|
303
|
+
const unscopeScrim = () => {
|
|
304
|
+
removeClass(component.overlay, `${component.getClass("dialog__overlay")}--contained`);
|
|
305
|
+
if (containerPosition === null)
|
|
306
|
+
return;
|
|
307
|
+
component.structure.container.style.position = containerPosition;
|
|
308
|
+
containerPosition = null;
|
|
309
|
+
};
|
|
310
|
+
const scopeScrim = () => {
|
|
311
|
+
const container = component.structure.container;
|
|
312
|
+
if (top || container === document.body)
|
|
313
|
+
return;
|
|
314
|
+
if (getComputedStyle(container).position === "static") {
|
|
315
|
+
containerPosition ?? (containerPosition = container.style.position);
|
|
316
|
+
container.style.position = "relative";
|
|
317
|
+
}
|
|
318
|
+
addClass(component.overlay, `${component.getClass("dialog__overlay")}--contained`);
|
|
319
|
+
if (!container.clientHeight ||
|
|
320
|
+
container.clientWidth < component.element.offsetWidth ||
|
|
321
|
+
container.clientHeight < component.element.offsetHeight) {
|
|
322
|
+
unscopeScrim();
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
const handleWrap = (e) => wrapTab(component.element, e);
|
|
326
|
+
const focusWhenVisible = (target) => {
|
|
327
|
+
const view = target.ownerDocument.defaultView;
|
|
328
|
+
if (!view || typeof view.requestAnimationFrame !== "function") {
|
|
329
|
+
target.focus();
|
|
330
|
+
focusPending = false;
|
|
331
|
+
if (afterOpenWaiting)
|
|
332
|
+
emitAfterOpen();
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
cancelFocusFrame();
|
|
336
|
+
const request = focusRequest;
|
|
337
|
+
const settle = () => {
|
|
338
|
+
focusFrame = undefined;
|
|
339
|
+
if (request !== focusRequest)
|
|
340
|
+
return;
|
|
341
|
+
if (!opened || !target.isConnected) {
|
|
342
|
+
focusPending = false;
|
|
343
|
+
if (afterOpenWaiting)
|
|
344
|
+
emitAfterOpen();
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
if (view.getComputedStyle(target).visibility !== "hidden") {
|
|
348
|
+
target.focus();
|
|
349
|
+
focusPending = false;
|
|
350
|
+
if (afterOpenWaiting)
|
|
351
|
+
emitAfterOpen();
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
focusPending = true;
|
|
355
|
+
focusFrame = view.requestAnimationFrame(settle);
|
|
356
|
+
focusView = view;
|
|
357
|
+
};
|
|
358
|
+
settle();
|
|
359
|
+
};
|
|
360
|
+
const trapFocus = () => {
|
|
361
|
+
inertBackground();
|
|
362
|
+
if (component.config.autofocus !== false) {
|
|
363
|
+
const requested = component.element.querySelector("[autofocus]");
|
|
364
|
+
const target = requested || tabStops(component.element)[0] || component.element;
|
|
365
|
+
focusWhenVisible(target);
|
|
366
|
+
}
|
|
367
|
+
if (component.config.trapFocus !== false) {
|
|
368
|
+
component.element.addEventListener("keydown", handleWrap);
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
const releaseFocus = () => {
|
|
372
|
+
component.element.removeEventListener("keydown", handleWrap);
|
|
373
|
+
releaseBackground();
|
|
374
|
+
if (previouslyFocusedElement) {
|
|
375
|
+
if (previouslyFocusedElement.isConnected)
|
|
376
|
+
previouslyFocusedElement.focus();
|
|
377
|
+
previouslyFocusedElement = null;
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
const setupEvents = () => {
|
|
381
|
+
if (component.config.closeOnOverlayClick !== false) {
|
|
382
|
+
scrim.addEventListener("mousedown", handleOverlayMouseDown);
|
|
383
|
+
document.addEventListener("mouseup", handleOverlayMouseUp);
|
|
384
|
+
}
|
|
385
|
+
escape?.stop();
|
|
386
|
+
escape = onModalEscape(component.element, () => {
|
|
387
|
+
if (top) {
|
|
388
|
+
asking = true;
|
|
389
|
+
component.element.dispatchEvent(new Event("cancel", { cancelable: true }));
|
|
390
|
+
asking = false;
|
|
391
|
+
}
|
|
392
|
+
else if (component.config.closeOnEscape !== false)
|
|
393
|
+
visibility.close();
|
|
394
|
+
});
|
|
395
|
+
if (top)
|
|
396
|
+
component.element.addEventListener("cancel", handleCancel);
|
|
397
|
+
};
|
|
398
|
+
const cleanupEvents = () => {
|
|
399
|
+
scrim.removeEventListener("mousedown", handleOverlayMouseDown);
|
|
400
|
+
document.removeEventListener("mouseup", handleOverlayMouseUp);
|
|
401
|
+
escape?.stop();
|
|
402
|
+
component.element.removeEventListener("cancel", handleCancel);
|
|
403
|
+
};
|
|
404
|
+
const onScrim = (e) => {
|
|
405
|
+
if (!top)
|
|
406
|
+
return e.target === component.overlay;
|
|
407
|
+
if (e.composedPath()[0] !== scrim)
|
|
408
|
+
return false;
|
|
409
|
+
const box = scrim.getBoundingClientRect();
|
|
410
|
+
return e.clientX < box.left || e.clientX > box.right || e.clientY < box.top || e.clientY > box.bottom;
|
|
411
|
+
};
|
|
412
|
+
function handleOverlayMouseDown(e) {
|
|
413
|
+
mouseDownOnOverlay = onScrim(e);
|
|
414
|
+
}
|
|
415
|
+
function handleOverlayMouseUp(e) {
|
|
416
|
+
if (mouseDownOnOverlay && onScrim(e)) {
|
|
417
|
+
visibility.close();
|
|
418
|
+
}
|
|
419
|
+
mouseDownOnOverlay = false;
|
|
420
|
+
}
|
|
421
|
+
function handleCancel(e) {
|
|
422
|
+
e.preventDefault();
|
|
423
|
+
if ((asking || !escape?.opening) && component.config.closeOnEscape !== false && visibility.isOpen()) {
|
|
424
|
+
visibility.close();
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
const showModal = () => {
|
|
428
|
+
if (!component.element.isConnected) {
|
|
429
|
+
component.structure.container.appendChild(component.element);
|
|
430
|
+
}
|
|
431
|
+
if (!component.element.isConnected || !showInTopLayer(component.element, { kind: "modal" })) {
|
|
432
|
+
component.element.setAttribute("open", "");
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
scopeScrim();
|
|
436
|
+
if (isOpen) {
|
|
437
|
+
if (top)
|
|
438
|
+
showModal();
|
|
439
|
+
addClass(component.overlay, `${component.getClass("dialog__overlay")}--visible`);
|
|
440
|
+
addClass(component.element, `${component.getClass("dialog")}--visible`);
|
|
441
|
+
trapFocus();
|
|
442
|
+
setupEvents();
|
|
443
|
+
}
|
|
444
|
+
const visibility = {
|
|
445
|
+
open() {
|
|
446
|
+
if (opened)
|
|
447
|
+
return;
|
|
448
|
+
previouslyFocusedElement = deepActiveElement();
|
|
449
|
+
const beforeOpenEvent = {
|
|
450
|
+
dialog: getComponent(),
|
|
451
|
+
defaultPrevented: false,
|
|
452
|
+
preventDefault: () => {
|
|
453
|
+
beforeOpenEvent.defaultPrevented = true;
|
|
454
|
+
},
|
|
455
|
+
};
|
|
456
|
+
if (typeof component.emit === "function") {
|
|
457
|
+
component.emit(DIALOG_EVENTS.BEFORE_OPEN, beforeOpenEvent);
|
|
458
|
+
}
|
|
459
|
+
if (beforeOpenEvent.defaultPrevented)
|
|
460
|
+
return;
|
|
461
|
+
opened = true;
|
|
462
|
+
clearTimeout(afterCloseTimer);
|
|
463
|
+
afterOpenWaiting = false;
|
|
464
|
+
focusPending = false;
|
|
465
|
+
if (top) {
|
|
466
|
+
showModal();
|
|
467
|
+
void component.element.offsetWidth;
|
|
468
|
+
addClass(component.element, `${component.getClass("dialog")}--visible`);
|
|
469
|
+
trapFocus();
|
|
470
|
+
setupEvents();
|
|
471
|
+
component.emit(DIALOG_EVENTS.OPEN, { dialog: getComponent() });
|
|
472
|
+
if (!opened)
|
|
473
|
+
return;
|
|
474
|
+
afterOpenTimer = setTimeout(afterOpenDue, openDuration);
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
if (component.element.parentNode !== component.overlay) {
|
|
478
|
+
component.overlay.appendChild(component.element);
|
|
479
|
+
}
|
|
480
|
+
if (component.overlay && !component.overlay.parentNode) {
|
|
481
|
+
const container = component.structure.container || document.body;
|
|
482
|
+
container.appendChild(component.overlay);
|
|
483
|
+
}
|
|
484
|
+
scopeScrim();
|
|
485
|
+
setupEvents();
|
|
486
|
+
if (typeof component.emit === "function") {
|
|
487
|
+
component.emit(DIALOG_EVENTS.OPEN, { dialog: getComponent() });
|
|
488
|
+
}
|
|
489
|
+
if (!opened)
|
|
490
|
+
return;
|
|
491
|
+
showTimer = setTimeout(() => {
|
|
492
|
+
addClass(component.overlay, `${component.getClass("dialog__overlay")}--visible`);
|
|
493
|
+
addClass(component.element, `${component.getClass("dialog")}--visible`);
|
|
494
|
+
trapFocus();
|
|
495
|
+
if (typeof component.emit === "function") {
|
|
496
|
+
afterOpenTimer = setTimeout(afterOpenDue, openDuration);
|
|
497
|
+
}
|
|
498
|
+
}, 10);
|
|
499
|
+
},
|
|
500
|
+
close(forced) {
|
|
501
|
+
if (!opened)
|
|
502
|
+
return;
|
|
503
|
+
const beforeCloseEvent = {
|
|
504
|
+
dialog: getComponent(),
|
|
505
|
+
defaultPrevented: false,
|
|
506
|
+
preventDefault: () => {
|
|
507
|
+
beforeCloseEvent.defaultPrevented = true;
|
|
508
|
+
},
|
|
509
|
+
};
|
|
510
|
+
if (!forced && typeof component.emit === "function") {
|
|
511
|
+
component.emit(DIALOG_EVENTS.BEFORE_CLOSE, beforeCloseEvent);
|
|
512
|
+
}
|
|
513
|
+
if (beforeCloseEvent.defaultPrevented) {
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
opened = false;
|
|
517
|
+
clearTimeout(showTimer);
|
|
518
|
+
clearTimeout(afterOpenTimer);
|
|
519
|
+
afterOpenWaiting = false;
|
|
520
|
+
cancelFocusFrame();
|
|
521
|
+
const dialogVisibleClass = `${component.getClass("dialog")}--visible`;
|
|
522
|
+
const overlayVisibleClass = `${component.getClass("dialog__overlay")}--visible`;
|
|
523
|
+
removeClass(component.element, dialogVisibleClass);
|
|
524
|
+
removeClass(component.overlay, overlayVisibleClass);
|
|
525
|
+
if (top)
|
|
526
|
+
hideFromTopLayer(component.element);
|
|
527
|
+
releaseFocus();
|
|
528
|
+
cleanupEvents();
|
|
529
|
+
if (typeof component.emit === "function") {
|
|
530
|
+
component.emit(DIALOG_EVENTS.CLOSE, { dialog: getComponent() });
|
|
531
|
+
}
|
|
532
|
+
if (opened)
|
|
533
|
+
return;
|
|
534
|
+
afterCloseTimer = setTimeout(() => {
|
|
535
|
+
if (!top && component.overlay && component.overlay.parentNode) {
|
|
536
|
+
component.overlay.parentNode.removeChild(component.overlay);
|
|
537
|
+
}
|
|
538
|
+
unscopeScrim();
|
|
539
|
+
if (typeof component.emit === "function") {
|
|
540
|
+
component.emit(DIALOG_EVENTS.AFTER_CLOSE, { dialog: getComponent() });
|
|
541
|
+
}
|
|
542
|
+
}, closeDuration);
|
|
543
|
+
},
|
|
544
|
+
toggle(open) {
|
|
545
|
+
if (open === undefined) {
|
|
546
|
+
this.isOpen() ? this.close() : this.open();
|
|
547
|
+
}
|
|
548
|
+
else if (open) {
|
|
549
|
+
this.open();
|
|
550
|
+
}
|
|
551
|
+
else {
|
|
552
|
+
this.close();
|
|
553
|
+
}
|
|
554
|
+
},
|
|
555
|
+
isOpen() {
|
|
556
|
+
return opened;
|
|
557
|
+
},
|
|
558
|
+
cancel() {
|
|
559
|
+
opened = false;
|
|
560
|
+
clearTimeout(showTimer);
|
|
561
|
+
clearTimeout(afterOpenTimer);
|
|
562
|
+
clearTimeout(afterCloseTimer);
|
|
563
|
+
afterOpenWaiting = false;
|
|
564
|
+
cancelFocusFrame();
|
|
565
|
+
cleanupEvents();
|
|
566
|
+
unscopeScrim();
|
|
567
|
+
},
|
|
568
|
+
};
|
|
569
|
+
if (component && component.on) {
|
|
570
|
+
component.on("dialog:close", () => {
|
|
571
|
+
visibility.close();
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
if (top) {
|
|
575
|
+
onTopLayerClose(component.element, () => visibility.close(true));
|
|
576
|
+
}
|
|
577
|
+
return {
|
|
578
|
+
...component,
|
|
579
|
+
visibility,
|
|
580
|
+
focus: {
|
|
581
|
+
trapFocus,
|
|
582
|
+
releaseFocus,
|
|
583
|
+
},
|
|
584
|
+
};
|
|
585
585
|
};
|
|
586
586
|
export const withContent = () => (component) => {
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
587
|
+
const headerElement = component.structure.header;
|
|
588
|
+
const contentElement = component.structure.content;
|
|
589
|
+
const footerElement = component.structure.footer;
|
|
590
|
+
return {
|
|
591
|
+
...component,
|
|
592
|
+
content: {
|
|
593
|
+
setTitle(title) {
|
|
594
|
+
let titleElement = headerElement.querySelector(`.${component.getClass("dialog__header-title")}`);
|
|
595
|
+
if (!titleElement && title) {
|
|
596
|
+
titleElement = document.createElement("h2");
|
|
597
|
+
titleElement.classList.add(component.getClass("dialog__header-title"));
|
|
598
|
+
headerElement
|
|
599
|
+
.querySelector(`.${component.getClass("dialog__header-content")}`)
|
|
600
|
+
?.appendChild(titleElement);
|
|
601
|
+
}
|
|
602
|
+
if (titleElement) {
|
|
603
|
+
titleElement.textContent = title;
|
|
604
|
+
}
|
|
605
|
+
},
|
|
606
|
+
getTitle() {
|
|
607
|
+
const titleElement = headerElement.querySelector(`.${component.getClass("dialog__header-title")}`);
|
|
608
|
+
return titleElement ? titleElement.textContent || "" : "";
|
|
609
|
+
},
|
|
610
|
+
setSubtitle(subtitle) {
|
|
611
|
+
let subtitleElement = headerElement.querySelector(`.${component.getClass("dialog__header-subtitle")}`);
|
|
612
|
+
if (!subtitleElement && subtitle) {
|
|
613
|
+
subtitleElement = document.createElement("p");
|
|
614
|
+
subtitleElement.classList.add(component.getClass("dialog__header-subtitle"));
|
|
615
|
+
headerElement
|
|
616
|
+
.querySelector(`.${component.getClass("dialog__header-content")}`)
|
|
617
|
+
?.appendChild(subtitleElement);
|
|
618
|
+
}
|
|
619
|
+
if (subtitleElement) {
|
|
620
|
+
subtitleElement.textContent = subtitle;
|
|
621
|
+
}
|
|
622
|
+
},
|
|
623
|
+
getSubtitle() {
|
|
624
|
+
const subtitleElement = headerElement.querySelector(`.${component.getClass("dialog__header-subtitle")}`);
|
|
625
|
+
return subtitleElement ? subtitleElement.textContent || "" : "";
|
|
626
|
+
},
|
|
627
|
+
setContent(content) {
|
|
628
|
+
setHTML(contentElement, content);
|
|
629
|
+
},
|
|
630
|
+
getContent() {
|
|
631
|
+
return contentElement.innerHTML;
|
|
632
|
+
},
|
|
633
|
+
getHeaderElement() {
|
|
634
|
+
return headerElement;
|
|
635
|
+
},
|
|
636
|
+
getContentElement() {
|
|
637
|
+
return contentElement;
|
|
638
|
+
},
|
|
639
|
+
getFooterElement() {
|
|
640
|
+
return footerElement;
|
|
641
|
+
},
|
|
642
|
+
},
|
|
643
|
+
};
|
|
644
644
|
};
|
|
645
645
|
export const withButtons = (getComponent) => (component) => {
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
646
|
+
if (!component._buttons) {
|
|
647
|
+
component._buttons = [];
|
|
648
|
+
}
|
|
649
|
+
const buttonRecords = component._buttons;
|
|
650
|
+
return {
|
|
651
|
+
...component,
|
|
652
|
+
_buttons: buttonRecords,
|
|
653
|
+
buttons: {
|
|
654
|
+
addButton(button) {
|
|
655
|
+
let footer = component.structure.footer;
|
|
656
|
+
if (!footer) {
|
|
657
|
+
footer = document.createElement("div");
|
|
658
|
+
footer.classList.add(component.getClass("dialog__footer"));
|
|
659
|
+
const alignment = component.config.footerAlignment || "right";
|
|
660
|
+
if (alignment !== "right") {
|
|
661
|
+
addClass(footer, `${component.getClass("dialog__footer")}--${alignment}`);
|
|
662
|
+
}
|
|
663
|
+
component.element.appendChild(footer);
|
|
664
|
+
component.structure.footer = footer;
|
|
665
|
+
}
|
|
666
|
+
addButton(footer, button, component, getComponent);
|
|
667
|
+
},
|
|
668
|
+
removeButton(indexOrText) {
|
|
669
|
+
if (typeof indexOrText === "number") {
|
|
670
|
+
if (indexOrText >= 0 && indexOrText < buttonRecords.length) {
|
|
671
|
+
const button = buttonRecords[indexOrText];
|
|
672
|
+
button.instance.destroy();
|
|
673
|
+
buttonRecords.splice(indexOrText, 1);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
else {
|
|
677
|
+
const index = buttonRecords.findIndex((button) => button.config.text === indexOrText);
|
|
678
|
+
if (index !== -1) {
|
|
679
|
+
const button = buttonRecords[index];
|
|
680
|
+
button.instance.destroy();
|
|
681
|
+
buttonRecords.splice(index, 1);
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
if (buttonRecords.length === 0 && component.structure.footer) {
|
|
685
|
+
component.element.removeChild(component.structure.footer);
|
|
686
|
+
component.structure.footer = null;
|
|
687
|
+
}
|
|
688
|
+
},
|
|
689
|
+
getButtons() {
|
|
690
|
+
return buttonRecords.map((button) => button.config);
|
|
691
|
+
},
|
|
692
|
+
setFooterAlignment(alignment) {
|
|
693
|
+
const footer = component.structure.footer;
|
|
694
|
+
if (!footer)
|
|
695
|
+
return;
|
|
696
|
+
const ALL_ALIGNMENTS = ["right", "left", "center", "space-between"];
|
|
697
|
+
ALL_ALIGNMENTS.forEach((align) => {
|
|
698
|
+
if (align !== "right") {
|
|
699
|
+
removeClass(footer, `${component.getClass("dialog__footer")}--${align}`);
|
|
700
|
+
}
|
|
701
|
+
});
|
|
702
|
+
if (alignment !== "right") {
|
|
703
|
+
addClass(footer, `${component.getClass("dialog__footer")}--${alignment}`);
|
|
704
|
+
}
|
|
705
|
+
},
|
|
706
|
+
},
|
|
707
|
+
};
|
|
708
708
|
};
|
|
709
709
|
export const withSize = () => (component) => {
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
710
|
+
return {
|
|
711
|
+
...component,
|
|
712
|
+
size: {
|
|
713
|
+
setSize(size) {
|
|
714
|
+
const ALL_SIZES = [
|
|
715
|
+
"small",
|
|
716
|
+
"medium",
|
|
717
|
+
"large",
|
|
718
|
+
"fullwidth",
|
|
719
|
+
"fullscreen",
|
|
720
|
+
];
|
|
721
|
+
ALL_SIZES.forEach((sizeValue) => {
|
|
722
|
+
removeClass(component.element, `${component.getClass("dialog")}--${sizeValue}`);
|
|
723
|
+
});
|
|
724
|
+
if (size !== "medium") {
|
|
725
|
+
addClass(component.element, `${component.getClass("dialog")}--${size}`);
|
|
726
|
+
}
|
|
727
|
+
},
|
|
728
|
+
},
|
|
729
|
+
};
|
|
730
730
|
};
|
|
731
731
|
export const withConfirm = () => (component) => {
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
732
|
+
return {
|
|
733
|
+
...component,
|
|
734
|
+
confirm(options) {
|
|
735
|
+
return new Promise((resolve) => {
|
|
736
|
+
const { title = "Confirm", message, confirmText = "Yes", cancelText = "No", confirmVariant = "filled", cancelVariant = "text", size = "small", } = options;
|
|
737
|
+
component.content.setTitle(title);
|
|
738
|
+
const text = document.createElement("p");
|
|
739
|
+
text.textContent = message;
|
|
740
|
+
component.content.setContent(text.outerHTML);
|
|
741
|
+
component.size.setSize(size);
|
|
742
|
+
component._buttons.forEach((button) => button.instance.destroy());
|
|
743
|
+
component._buttons = [];
|
|
744
|
+
let settled = false;
|
|
745
|
+
const settle = (answer) => {
|
|
746
|
+
if (settled)
|
|
747
|
+
return;
|
|
748
|
+
settled = true;
|
|
749
|
+
component.off("close", onClose);
|
|
750
|
+
resolve(answer);
|
|
751
|
+
};
|
|
752
|
+
const onClose = () => settle(false);
|
|
753
|
+
component.on("close", onClose);
|
|
754
|
+
component.buttons.addButton({
|
|
755
|
+
text: cancelText,
|
|
756
|
+
variant: cancelVariant,
|
|
757
|
+
onClick: () => settle(false),
|
|
758
|
+
});
|
|
759
|
+
component.buttons.addButton({
|
|
760
|
+
text: confirmText,
|
|
761
|
+
variant: confirmVariant,
|
|
762
|
+
onClick: () => settle(true),
|
|
763
|
+
});
|
|
764
|
+
component.visibility.open();
|
|
765
|
+
});
|
|
766
|
+
},
|
|
767
|
+
};
|
|
768
768
|
};
|