material 3.5.3 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- 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/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-lite.css +2 -0
- package/dist/styles/base-lite.d.ts +1 -0
- package/dist/styles/base-lite.js +2 -0
- 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 +2 -1
- package/src/styles/abstract/_mixins.scss +21 -0
- package/src/styles/base/_body-theme.scss +22 -0
- package/src/styles/base/_document.scss +4 -14
- package/src/styles/base/_reset.scss +3 -14
|
@@ -15,682 +15,682 @@ const isRangeObject = (value) => typeof value === "object" && value !== null &&
|
|
|
15
15
|
let nextId = 0;
|
|
16
16
|
const scrollLocks = new WeakMap();
|
|
17
17
|
function lockScroll(doc) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
const lock = scrollLocks.get(doc) ?? { count: 0, overflow: doc.body.style.overflow };
|
|
19
|
+
lock.count++;
|
|
20
|
+
scrollLocks.set(doc, lock);
|
|
21
|
+
doc.body.style.overflow = "hidden";
|
|
22
|
+
return () => {
|
|
23
|
+
if (--lock.count === 0) {
|
|
24
|
+
doc.body.style.overflow = lock.overflow;
|
|
25
|
+
scrollLocks.delete(doc);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
28
|
}
|
|
29
29
|
const createDatePicker = (config = {}) => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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
|
-
|
|
189
|
-
|
|
190
|
-
|
|
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
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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
|
-
|
|
585
|
-
|
|
586
|
-
|
|
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
|
-
|
|
644
|
-
|
|
645
|
-
|
|
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
|
-
|
|
30
|
+
const settings = createBaseConfig(config);
|
|
31
|
+
const base = pipe(createBase, withEvents(), withElement(getContainerConfig(settings)), withDisabled(settings), withLifecycle())(settings);
|
|
32
|
+
const doc = base.element.ownerDocument;
|
|
33
|
+
const view = doc.defaultView ?? window;
|
|
34
|
+
const id = `${PREFIX}-datepicker-${++nextId}`;
|
|
35
|
+
const cls = (name) => base.getClass(`datepicker__${name}`);
|
|
36
|
+
const today = parseDate(new Date());
|
|
37
|
+
const state = {
|
|
38
|
+
id, prefix: PREFIX, label: settings.label || "Select date", selectedDate: null, rangeEndDate: null,
|
|
39
|
+
currentView: settings.variant !== "fullscreen" && ["month", "year"].includes(settings.initialView ?? "") ? settings.initialView : "day",
|
|
40
|
+
currentMonth: today.getMonth(), currentYear: today.getFullYear(), focusedDate: today,
|
|
41
|
+
minDate: parseDate(settings.minDate ?? null), maxDate: parseDate(settings.maxDate ?? null),
|
|
42
|
+
dateFormat: settings.dateFormat || "MM/DD/YYYY", variant: settings.variant === "modal" || settings.variant === "modal-input" || settings.variant === "fullscreen" ? settings.variant : "docked",
|
|
43
|
+
selectionMode: settings.selectionMode === "range" ? "range" : "single", inputMode: settings.variant === "modal-input",
|
|
44
|
+
specialDates: (settings.specialDates ?? []).map(item => ({ ...item })),
|
|
45
|
+
isAllowed: date => (!state.minDate || date >= state.minDate) && (!state.maxDate || date <= state.maxDate) && !state.specialDates.some(item => { const special = parseDate(item.date); return item.disabled && special && isSameDay(date, special); }),
|
|
46
|
+
};
|
|
47
|
+
const modal = state.variant !== "docked";
|
|
48
|
+
let opened = false, destroyed = false, navigationRequested = false, readOnly = false;
|
|
49
|
+
let escape, from;
|
|
50
|
+
const release = () => { escape?.stop(); from?.stop(); escape = from = undefined; };
|
|
51
|
+
let committed = null, committedEnd = null;
|
|
52
|
+
let returnFocus = null;
|
|
53
|
+
let unlock;
|
|
54
|
+
const label = createElement({ tag: "label", className: cls("label"), text: state.label, attributes: { for: `${id}-input` } });
|
|
55
|
+
const field = createElement({ tag: "div", className: cls("anchor") });
|
|
56
|
+
const input = doc.createElement("input");
|
|
57
|
+
input.className = cls("input");
|
|
58
|
+
input.id = `${id}-input`;
|
|
59
|
+
input.type = "text";
|
|
60
|
+
input.readOnly = modal;
|
|
61
|
+
if (settings.name)
|
|
62
|
+
input.name = settings.name;
|
|
63
|
+
input.placeholder = settings.placeholder || state.dateFormat;
|
|
64
|
+
input.autocomplete = "off";
|
|
65
|
+
input.setAttribute("aria-describedby", `${id}-help ${id}-error`);
|
|
66
|
+
const trigger = doc.createElement("button");
|
|
67
|
+
trigger.type = "button";
|
|
68
|
+
trigger.className = cls("trigger");
|
|
69
|
+
setHTML(trigger, DATEPICKER_ICONS.calendar);
|
|
70
|
+
trigger.dataset.action = "open";
|
|
71
|
+
trigger.setAttribute("aria-label", "Choose date");
|
|
72
|
+
trigger.setAttribute("aria-haspopup", "dialog");
|
|
73
|
+
trigger.setAttribute("aria-controls", `${id}-dialog`);
|
|
74
|
+
trigger.setAttribute("aria-expanded", "false");
|
|
75
|
+
const help = createElement({ tag: "div", className: cls("help"), text: settings.supportingText || state.dateFormat, attributes: { id: `${id}-help` } });
|
|
76
|
+
const error = createElement({ tag: "div", className: cls("error"), attributes: { id: `${id}-error`, "aria-live": "polite" } });
|
|
77
|
+
const dialog = doc.createElement("dialog");
|
|
78
|
+
dialog.id = `${id}-dialog`;
|
|
79
|
+
dialog.className = cls("calendar");
|
|
80
|
+
dialog.classList.add(base.getClass(`datepicker--${modal ? "modal" : "docked"}`));
|
|
81
|
+
if (state.variant === "fullscreen")
|
|
82
|
+
dialog.classList.add(base.getClass("datepicker--fullscreen"));
|
|
83
|
+
dialog.setAttribute("aria-modal", String(modal));
|
|
84
|
+
if (settings.animate)
|
|
85
|
+
dialog.classList.add(base.getClass("datepicker--animate"));
|
|
86
|
+
if (state.selectionMode === "range")
|
|
87
|
+
dialog.classList.add(base.getClass("datepicker--range"));
|
|
88
|
+
if (modal)
|
|
89
|
+
dialog.setAttribute("aria-labelledby", `${id}-title`);
|
|
90
|
+
else
|
|
91
|
+
dialog.setAttribute("aria-label", state.label);
|
|
92
|
+
const announcement = createElement({ tag: "div", className: cls("sr-only"), attributes: { "aria-live": "polite", "aria-atomic": "true" } });
|
|
93
|
+
field.append(input, trigger);
|
|
94
|
+
base.element.append(label, field, help, error, dialog);
|
|
95
|
+
const formatted = (date, end) => formatDate(date, state.dateFormat) + (date && end ? ` - ${formatDate(end, state.dateFormat)}` : "");
|
|
96
|
+
const getValue = () => committed ? committedEnd ? [new Date(committed), new Date(committedEnd)] : new Date(committed) : null;
|
|
97
|
+
const syncInput = () => {
|
|
98
|
+
input.value = formatted(committed, committedEnd);
|
|
99
|
+
input.removeAttribute("aria-invalid");
|
|
100
|
+
error.textContent = "";
|
|
101
|
+
trigger.setAttribute("aria-label", committed ? `Change date, ${input.value}` : "Choose date");
|
|
102
|
+
};
|
|
103
|
+
const resetDraft = () => { state.selectedDate = committed && new Date(committed); state.rangeEndDate = committedEnd && new Date(committedEnd); };
|
|
104
|
+
const setDisplayDate = (date) => { state.focusedDate = new Date(date); state.currentMonth = date.getMonth(); state.currentYear = date.getFullYear(); };
|
|
105
|
+
const focusCurrent = () => {
|
|
106
|
+
const selector = state.inputMode ? '[data-entry="start"]' : '[data-date][tabindex="0"], [data-month][tabindex="0"], [data-year][tabindex="0"]';
|
|
107
|
+
(dialog.querySelector(selector) ?? dialog.querySelector('button:not(:disabled)'))?.focus();
|
|
108
|
+
};
|
|
109
|
+
const track = () => dialog.querySelector(`.${cls("track")}`);
|
|
110
|
+
const rtl = (element) => view.getComputedStyle(element).direction === "rtl";
|
|
111
|
+
const centre = () => {
|
|
112
|
+
const element = track();
|
|
113
|
+
if (element?.clientWidth)
|
|
114
|
+
element.scrollLeft = (rtl(element) ? -1 : 1) * element.clientWidth;
|
|
115
|
+
const years = dialog.querySelector(`.${cls("years")}`);
|
|
116
|
+
const year = years?.querySelector('[aria-pressed="true"]');
|
|
117
|
+
if (years && year)
|
|
118
|
+
years.scrollTop = year.offsetTop - (years.clientHeight - year.offsetHeight) / 2;
|
|
119
|
+
};
|
|
120
|
+
const monthIndex = (date) => date.getFullYear() * 12 + date.getMonth();
|
|
121
|
+
const fromIndex = (index) => new Date(Math.floor(index / 12), index % 12, 1);
|
|
122
|
+
const list = () => dialog.querySelector(`.${cls("list")}`);
|
|
123
|
+
const limits = () => [state.minDate ? monthIndex(state.minDate) : -Infinity, state.maxDate ? monthIndex(state.maxDate) : Infinity];
|
|
124
|
+
let shiftBy = null;
|
|
125
|
+
const ensureWindow = () => {
|
|
126
|
+
if (state.variant !== "fullscreen")
|
|
127
|
+
return;
|
|
128
|
+
const focus = state.currentYear * 12 + state.currentMonth;
|
|
129
|
+
const start = state.listStart ? monthIndex(state.listStart) : NaN;
|
|
130
|
+
if (start <= focus && focus < start + (state.listLength ?? 0))
|
|
131
|
+
return;
|
|
132
|
+
const [min, max] = limits();
|
|
133
|
+
const first = Math.max(min, focus - 12), last = Math.min(max, focus + 12);
|
|
134
|
+
state.listStart = fromIndex(first);
|
|
135
|
+
state.listLength = last - first + 1;
|
|
136
|
+
};
|
|
137
|
+
const extend = (element) => {
|
|
138
|
+
const [min, max] = limits();
|
|
139
|
+
const start = monthIndex(state.listStart), end = start + state.listLength - 1;
|
|
140
|
+
const margin = element.clientHeight;
|
|
141
|
+
if (element.scrollTop < margin && start > min) {
|
|
142
|
+
const first = Math.max(min, start - 12);
|
|
143
|
+
state.listStart = fromIndex(first);
|
|
144
|
+
state.listLength = end - first + 1;
|
|
145
|
+
shiftBy = element.scrollHeight;
|
|
146
|
+
}
|
|
147
|
+
else if (element.scrollHeight - element.scrollTop - element.clientHeight < margin && end < max) {
|
|
148
|
+
state.listLength = Math.min(max, end + 12) - start + 1;
|
|
149
|
+
}
|
|
150
|
+
else
|
|
151
|
+
return;
|
|
152
|
+
const focused = activeElementOf(dialog);
|
|
153
|
+
const active = focused instanceof HTMLElement ? focused.dataset.date : undefined;
|
|
154
|
+
render();
|
|
155
|
+
if (active)
|
|
156
|
+
dialog.querySelector(`[data-date="${active}"]`)?.focus({ preventScroll: true });
|
|
157
|
+
};
|
|
158
|
+
const reveal = () => {
|
|
159
|
+
const element = list();
|
|
160
|
+
const section = element?.querySelector(`[data-month-key="${state.currentYear}-${state.currentMonth}"]`);
|
|
161
|
+
if (element && section)
|
|
162
|
+
element.scrollTop = section.offsetTop;
|
|
163
|
+
};
|
|
164
|
+
const render = (focus = false, action) => {
|
|
165
|
+
if (!opened || destroyed)
|
|
166
|
+
return;
|
|
167
|
+
ensureWindow();
|
|
168
|
+
const previous = list();
|
|
169
|
+
const kept = previous && { top: previous.scrollTop, height: previous.scrollHeight };
|
|
170
|
+
dialog.replaceChildren(renderCalendar(state), announcement);
|
|
171
|
+
const current = list();
|
|
172
|
+
if (current && kept)
|
|
173
|
+
current.scrollTop = kept.top + (shiftBy === null ? 0 : current.scrollHeight - kept.height);
|
|
174
|
+
shiftBy = null;
|
|
175
|
+
centre();
|
|
176
|
+
announcement.textContent = new Date(state.currentYear, state.currentMonth, 1).toLocaleDateString("en-US", { month: "long", year: "numeric" });
|
|
177
|
+
if (action)
|
|
178
|
+
dialog.querySelector(`[data-action="${action}"]`)?.focus();
|
|
179
|
+
else if (focus)
|
|
180
|
+
focusCurrent();
|
|
181
|
+
};
|
|
182
|
+
const emitChange = () => {
|
|
183
|
+
const rangeEndDate = committedEnd && new Date(committedEnd);
|
|
184
|
+
base.emit("change", { value: getValue(), rangeEndDate, formattedValue: formatted(committed, committedEnd), iso: toIsoValue(getValue(), rangeEndDate) });
|
|
185
|
+
};
|
|
186
|
+
const commitDraft = () => {
|
|
187
|
+
committed = state.selectedDate && new Date(state.selectedDate);
|
|
188
|
+
committedEnd = state.rangeEndDate && new Date(state.rangeEndDate);
|
|
189
|
+
syncInput();
|
|
190
|
+
emitChange();
|
|
191
|
+
};
|
|
192
|
+
const close = (restoreFocus = true) => {
|
|
193
|
+
if (!opened)
|
|
194
|
+
return;
|
|
195
|
+
opened = false;
|
|
196
|
+
release();
|
|
197
|
+
if (typeof dialog.close === "function")
|
|
198
|
+
dialog.close();
|
|
199
|
+
else
|
|
200
|
+
dialog.removeAttribute("open");
|
|
201
|
+
unlock?.();
|
|
202
|
+
unlock = undefined;
|
|
203
|
+
resetDraft();
|
|
204
|
+
trigger.setAttribute("aria-expanded", "false");
|
|
205
|
+
if (restoreFocus && returnFocus?.isConnected)
|
|
206
|
+
returnFocus.focus();
|
|
207
|
+
if (!destroyed)
|
|
208
|
+
base.emit("close", { value: getValue() });
|
|
209
|
+
};
|
|
210
|
+
const open = () => {
|
|
211
|
+
if (destroyed || opened || base.disabled.isDisabled() || readOnly)
|
|
212
|
+
return;
|
|
213
|
+
opened = true;
|
|
214
|
+
release();
|
|
215
|
+
if (modal)
|
|
216
|
+
escape = onModalEscape(dialog, () => close());
|
|
217
|
+
else
|
|
218
|
+
from = eventsFrom(dialog);
|
|
219
|
+
resetDraft();
|
|
220
|
+
state.inputMode = state.variant === "modal-input";
|
|
221
|
+
state.listStart = undefined;
|
|
222
|
+
let initial = committed ?? today;
|
|
223
|
+
if (state.minDate && initial < state.minDate)
|
|
224
|
+
initial = state.minDate;
|
|
225
|
+
if (state.maxDate && initial > state.maxDate)
|
|
226
|
+
initial = state.maxDate;
|
|
227
|
+
if (!navigationRequested)
|
|
228
|
+
setDisplayDate(initial);
|
|
229
|
+
navigationRequested = false;
|
|
230
|
+
const opener = deepActiveElement();
|
|
231
|
+
returnFocus = opener instanceof HTMLElement && opener !== doc.body ? opener : trigger;
|
|
232
|
+
render();
|
|
233
|
+
if (modal && typeof dialog.showModal === "function" && dialog.isConnected)
|
|
234
|
+
dialog.showModal();
|
|
235
|
+
else if (!modal && typeof dialog.show === "function")
|
|
236
|
+
dialog.show();
|
|
237
|
+
else
|
|
238
|
+
dialog.setAttribute("open", "");
|
|
239
|
+
if (modal)
|
|
240
|
+
unlock = lockScroll(doc);
|
|
241
|
+
centre();
|
|
242
|
+
reveal();
|
|
243
|
+
trigger.setAttribute("aria-expanded", "true");
|
|
244
|
+
focusCurrent();
|
|
245
|
+
base.emit("open", { value: getValue() });
|
|
246
|
+
};
|
|
247
|
+
const assignValue = (input, emit) => {
|
|
248
|
+
const given = isRangeObject(input) ? [input.start, input.end] : input;
|
|
249
|
+
const value = state.selectionMode === "range" && !Array.isArray(given) ? [given, given] : given;
|
|
250
|
+
if (destroyed || Array.isArray(value) && state.selectionMode !== "range")
|
|
251
|
+
return;
|
|
252
|
+
const start = parseDate(Array.isArray(value) ? value[0] : value);
|
|
253
|
+
const end = Array.isArray(value) ? parseDate(value[1]) : null;
|
|
254
|
+
if (!start || !state.isAllowed(start) || Array.isArray(value) && (!end || !state.isAllowed(end)))
|
|
255
|
+
return;
|
|
256
|
+
committed = end && end < start ? end : start;
|
|
257
|
+
committedEnd = end && end < start ? start : end;
|
|
258
|
+
resetDraft();
|
|
259
|
+
setDisplayDate(committed);
|
|
260
|
+
syncInput();
|
|
261
|
+
render();
|
|
262
|
+
if (emit)
|
|
263
|
+
emitChange();
|
|
264
|
+
};
|
|
265
|
+
const clearValue = (emit) => {
|
|
266
|
+
if (destroyed)
|
|
267
|
+
return;
|
|
268
|
+
committed = null;
|
|
269
|
+
committedEnd = null;
|
|
270
|
+
resetDraft();
|
|
271
|
+
syncInput();
|
|
272
|
+
render();
|
|
273
|
+
if (emit)
|
|
274
|
+
emitChange();
|
|
275
|
+
};
|
|
276
|
+
const validateEntries = () => {
|
|
277
|
+
const fields = Array.from(dialog.querySelectorAll('[data-entry]'));
|
|
278
|
+
if (!fields.length)
|
|
279
|
+
return !!state.selectedDate && state.isAllowed(state.selectedDate) && (state.selectionMode !== "range" || !!state.rangeEndDate && state.isAllowed(state.rangeEndDate));
|
|
280
|
+
const values = fields.map(field => parseInputDate(field.value, state.dateFormat));
|
|
281
|
+
let valid = true;
|
|
282
|
+
fields.forEach((field, index) => {
|
|
283
|
+
const date = values[index];
|
|
284
|
+
const message = !date ? `Enter a valid date (${state.dateFormat}).` : !state.isAllowed(date) ? "Date is not selectable." : index === 1 && values[0] && date < values[0] ? "End date must be on or after start date." : "";
|
|
285
|
+
if (message) {
|
|
286
|
+
field.setAttribute("aria-invalid", "true");
|
|
287
|
+
valid = false;
|
|
288
|
+
}
|
|
289
|
+
else
|
|
290
|
+
field.removeAttribute("aria-invalid");
|
|
291
|
+
dialog.querySelector(`#${field.id}-error`).textContent = message;
|
|
292
|
+
});
|
|
293
|
+
const confirm = dialog.querySelector('[data-action="confirm"]');
|
|
294
|
+
if (confirm)
|
|
295
|
+
confirm.disabled = !valid;
|
|
296
|
+
if (valid) {
|
|
297
|
+
state.selectedDate = values[0];
|
|
298
|
+
state.rangeEndDate = values[1] ?? null;
|
|
299
|
+
setDisplayDate(values[0]);
|
|
300
|
+
const headline = dialog.querySelector(`.${cls("headline")}`);
|
|
301
|
+
if (headline)
|
|
302
|
+
headline.textContent = formatDate(state.selectedDate, "MMM D, YYYY") + (state.rangeEndDate ? ` – ${formatDate(state.rangeEndDate, "MMM D, YYYY")}` : "");
|
|
303
|
+
}
|
|
304
|
+
return valid;
|
|
305
|
+
};
|
|
306
|
+
const onEntry = () => { validateEntries(); };
|
|
307
|
+
const onInputChange = () => {
|
|
308
|
+
if (modal || destroyed || base.disabled.isDisabled())
|
|
309
|
+
return;
|
|
310
|
+
if (!input.value.trim()) {
|
|
311
|
+
clearValue(true);
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
const pieces = state.selectionMode === "range" ? input.value.split(' - ') : [input.value];
|
|
315
|
+
const dates = pieces.map(value => parseInputDate(value, state.dateFormat));
|
|
316
|
+
if (dates.length !== (state.selectionMode === 'range' ? 2 : 1) || dates.some(date => !date || !state.isAllowed(date)) || dates[1] && dates[0] && dates[1] < dates[0]) {
|
|
317
|
+
input.setAttribute("aria-invalid", "true");
|
|
318
|
+
error.textContent = `Enter a selectable ${state.selectionMode === "range" ? "date range" : "date"} (${state.dateFormat}).`;
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
assignValue(dates.length === 2 ? [dates[0], dates[1]] : dates[0], true);
|
|
322
|
+
};
|
|
323
|
+
const select = (date, accept = settings.closeOnSelect) => {
|
|
324
|
+
if (!state.isAllowed(date))
|
|
325
|
+
return;
|
|
326
|
+
if (state.selectionMode === "range" && state.selectedDate && !state.rangeEndDate) {
|
|
327
|
+
state.rangeEndDate = date < state.selectedDate ? state.selectedDate : date;
|
|
328
|
+
state.selectedDate = date < state.selectedDate ? date : state.selectedDate;
|
|
329
|
+
}
|
|
330
|
+
else {
|
|
331
|
+
state.selectedDate = date;
|
|
332
|
+
state.rangeEndDate = null;
|
|
333
|
+
}
|
|
334
|
+
setDisplayDate(date);
|
|
335
|
+
const whole = state.selectionMode !== "range" || !!state.rangeEndDate;
|
|
336
|
+
if ((!modal || accept) && whole)
|
|
337
|
+
commitDraft();
|
|
338
|
+
if (accept && whole)
|
|
339
|
+
close();
|
|
340
|
+
else
|
|
341
|
+
render(true);
|
|
342
|
+
};
|
|
343
|
+
const navigate = (amount) => {
|
|
344
|
+
const count = state.currentView === "day" ? amount : amount * 12;
|
|
345
|
+
const anchor = new Date(state.currentYear, state.currentMonth, 1);
|
|
346
|
+
anchor.setDate(Math.min(state.focusedDate.getDate(), new Date(state.currentYear, state.currentMonth + 1, 0).getDate()));
|
|
347
|
+
setDisplayDate(addMonths(anchor, count));
|
|
348
|
+
};
|
|
349
|
+
const onClick = (event) => {
|
|
350
|
+
if (destroyed || base.disabled.isDisabled())
|
|
351
|
+
return;
|
|
352
|
+
const target = event.target instanceof Element ? event.target.closest('button') : null;
|
|
353
|
+
if (!target || !base.element.contains(target) || target.hasAttribute('disabled'))
|
|
354
|
+
return;
|
|
355
|
+
const action = target.dataset.action;
|
|
356
|
+
if (action === "open") {
|
|
357
|
+
opened ? close() : open();
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
if (!opened)
|
|
361
|
+
return;
|
|
362
|
+
if (target.dataset.date) {
|
|
363
|
+
select(parseDate(target.dataset.date));
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
if (target.dataset.month) {
|
|
367
|
+
setDisplayDate(new Date(state.currentYear, Number(target.dataset.month), 1));
|
|
368
|
+
state.currentView = "day";
|
|
369
|
+
render(true);
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
if (target.dataset.year) {
|
|
373
|
+
state.currentYear = Number(target.dataset.year);
|
|
374
|
+
state.currentView = "month";
|
|
375
|
+
render(true);
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
if (action === "cancel")
|
|
379
|
+
close();
|
|
380
|
+
else if (action === "confirm") {
|
|
381
|
+
if (validateEntries()) {
|
|
382
|
+
commitDraft();
|
|
383
|
+
close();
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
else if (action === "toggle-mode") {
|
|
387
|
+
if (state.inputMode && !validateEntries())
|
|
388
|
+
return;
|
|
389
|
+
state.inputMode = !state.inputMode;
|
|
390
|
+
render(true);
|
|
391
|
+
}
|
|
392
|
+
else if (action === "month" || action === "year") {
|
|
393
|
+
state.currentView = action;
|
|
394
|
+
render(true);
|
|
395
|
+
}
|
|
396
|
+
else if (action === "prev" || action === "next") {
|
|
397
|
+
const element = state.currentView === "day" ? track() : null;
|
|
398
|
+
if (element?.clientWidth && !view.matchMedia?.("(prefers-reduced-motion: reduce)").matches) {
|
|
399
|
+
element.scrollBy({ left: (action === "prev" ? -1 : 1) * (rtl(element) ? -1 : 1) * element.clientWidth, behavior: "smooth" });
|
|
400
|
+
}
|
|
401
|
+
else {
|
|
402
|
+
navigate(action === "prev" ? -1 : 1);
|
|
403
|
+
render(false, action);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
const onKey = (event) => {
|
|
408
|
+
if (event.key === "Enter" && event.target === input && !modal) {
|
|
409
|
+
event.preventDefault();
|
|
410
|
+
onInputChange();
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
if (event.key === "Enter" && opened && state.inputMode && event.target instanceof HTMLElement && event.target.hasAttribute("data-entry")) {
|
|
414
|
+
event.preventDefault();
|
|
415
|
+
if (validateEntries()) {
|
|
416
|
+
commitDraft();
|
|
417
|
+
close();
|
|
418
|
+
}
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
if (!opened) {
|
|
422
|
+
if (event.key === "ArrowDown" && event.target === input) {
|
|
423
|
+
event.preventDefault();
|
|
424
|
+
open();
|
|
425
|
+
}
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
if (event.key === "Escape") {
|
|
429
|
+
event.preventDefault();
|
|
430
|
+
event.stopPropagation();
|
|
431
|
+
close();
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
if (event.key === "Tab" && modal) {
|
|
435
|
+
const elements = Array.from(dialog.querySelectorAll('button:not(:disabled):not([tabindex="-1"]), input:not(:disabled)'));
|
|
436
|
+
const first = elements[0], last = elements.at(-1);
|
|
437
|
+
const focused = activeElementOf(dialog);
|
|
438
|
+
if (event.shiftKey && focused === first) {
|
|
439
|
+
event.preventDefault();
|
|
440
|
+
last?.focus();
|
|
441
|
+
}
|
|
442
|
+
else if (!event.shiftKey && focused === last) {
|
|
443
|
+
event.preventDefault();
|
|
444
|
+
first?.focus();
|
|
445
|
+
}
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
const target = event.target instanceof HTMLElement ? event.target : null;
|
|
449
|
+
if (target?.dataset.date) {
|
|
450
|
+
const date = parseDate(target.dataset.date);
|
|
451
|
+
if (event.key === "Enter" && state.selectionMode === "single") {
|
|
452
|
+
event.preventDefault();
|
|
453
|
+
select(date, true);
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
let next;
|
|
457
|
+
const ahead = rtl(dialog) ? -1 : 1;
|
|
458
|
+
if (event.key === "ArrowLeft")
|
|
459
|
+
next = addDays(date, -ahead);
|
|
460
|
+
else if (event.key === "ArrowRight")
|
|
461
|
+
next = addDays(date, ahead);
|
|
462
|
+
else if (event.key === "ArrowUp")
|
|
463
|
+
next = addDays(date, -7);
|
|
464
|
+
else if (event.key === "ArrowDown")
|
|
465
|
+
next = addDays(date, 7);
|
|
466
|
+
else if (event.key === "Home")
|
|
467
|
+
next = addDays(date, -date.getDay());
|
|
468
|
+
else if (event.key === "End")
|
|
469
|
+
next = addDays(date, 6 - date.getDay());
|
|
470
|
+
else if (event.key === "PageUp" || event.key === "PageDown")
|
|
471
|
+
next = addMonths(date, (event.key === "PageUp" ? -1 : 1) * (event.shiftKey ? 12 : 1));
|
|
472
|
+
else
|
|
473
|
+
return;
|
|
474
|
+
event.preventDefault();
|
|
475
|
+
if (state.minDate && next < state.minDate)
|
|
476
|
+
next = new Date(state.minDate);
|
|
477
|
+
if (state.maxDate && next > state.maxDate)
|
|
478
|
+
next = new Date(state.maxDate);
|
|
479
|
+
const direction = next < date ? -1 : 1;
|
|
480
|
+
for (let n = 0; !state.isAllowed(next) && n <= state.specialDates.length; n++)
|
|
481
|
+
next = addDays(next, direction);
|
|
482
|
+
if (state.isAllowed(next)) {
|
|
483
|
+
setDisplayDate(next);
|
|
484
|
+
render(true);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
else if (target?.hasAttribute('data-month') || target?.hasAttribute('data-year')) {
|
|
488
|
+
const buttons = Array.from(dialog.querySelectorAll('[data-month], [data-year]'));
|
|
489
|
+
let index = buttons.indexOf(target);
|
|
490
|
+
const ahead = rtl(dialog) ? -1 : 1;
|
|
491
|
+
const delta = { ArrowLeft: -ahead, ArrowRight: ahead, ArrowUp: -3, ArrowDown: 3 }[event.key];
|
|
492
|
+
if (event.key === "Home")
|
|
493
|
+
index = 0;
|
|
494
|
+
else if (event.key === "End")
|
|
495
|
+
index = buttons.length - 1;
|
|
496
|
+
else if (delta)
|
|
497
|
+
index = Math.min(buttons.length - 1, Math.max(0, index + delta));
|
|
498
|
+
else
|
|
499
|
+
return;
|
|
500
|
+
event.preventDefault();
|
|
501
|
+
buttons.forEach(button => button.tabIndex = -1);
|
|
502
|
+
buttons[index].tabIndex = 0;
|
|
503
|
+
buttons[index].focus();
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
const onFocus = (event) => {
|
|
507
|
+
const target = event.target instanceof HTMLElement ? event.target : null;
|
|
508
|
+
if (target?.dataset.date) {
|
|
509
|
+
state.focusedDate = parseDate(target.dataset.date);
|
|
510
|
+
dialog.querySelectorAll('[data-date]').forEach(el => el.tabIndex = el === target ? 0 : -1);
|
|
511
|
+
}
|
|
512
|
+
};
|
|
513
|
+
let quiet;
|
|
514
|
+
const settle = () => {
|
|
515
|
+
const element = track();
|
|
516
|
+
if (!opened || !element?.clientWidth)
|
|
517
|
+
return;
|
|
518
|
+
const page = Math.round(Math.abs(element.scrollLeft) / element.clientWidth) - 1;
|
|
519
|
+
if (!page)
|
|
520
|
+
return;
|
|
521
|
+
const focused = activeElementOf(dialog);
|
|
522
|
+
const active = focused instanceof HTMLElement && dialog.contains(focused) ? focused : null;
|
|
523
|
+
navigate(page);
|
|
524
|
+
render(!!active?.dataset.date, active?.dataset.action);
|
|
525
|
+
};
|
|
526
|
+
const onScroll = (event) => {
|
|
527
|
+
if (event.type === "scroll" && event.target instanceof HTMLElement && event.target === list()) {
|
|
528
|
+
extend(event.target);
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
if (!(event.target instanceof HTMLElement) || event.target !== track())
|
|
532
|
+
return;
|
|
533
|
+
if (event.type === "scrollend") {
|
|
534
|
+
settle();
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
if ("onscrollend" in view)
|
|
538
|
+
return;
|
|
539
|
+
clearTimeout(quiet);
|
|
540
|
+
quiet = setTimeout(settle, 150);
|
|
541
|
+
};
|
|
542
|
+
const onCancel = (event) => {
|
|
543
|
+
event.preventDefault();
|
|
544
|
+
if (!escape?.opening)
|
|
545
|
+
close();
|
|
546
|
+
};
|
|
547
|
+
const onOutside = (event) => {
|
|
548
|
+
if (!opened || (from && !from.after(event)))
|
|
549
|
+
return;
|
|
550
|
+
if (!modal && event.target instanceof Node && !event.composedPath().includes(base.element))
|
|
551
|
+
close(false);
|
|
552
|
+
if (modal && event.target === dialog) {
|
|
553
|
+
const bounds = dialog.getBoundingClientRect();
|
|
554
|
+
if (event.clientX < bounds.left || event.clientX > bounds.right || event.clientY < bounds.top || event.clientY > bounds.bottom)
|
|
555
|
+
close();
|
|
556
|
+
}
|
|
557
|
+
};
|
|
558
|
+
const onDialogClick = (event) => { onClick(event); onOutside(event); event.stopPropagation(); };
|
|
559
|
+
const onInputClick = () => {
|
|
560
|
+
if (modal)
|
|
561
|
+
open();
|
|
562
|
+
};
|
|
563
|
+
const onFocusOut = (event) => {
|
|
564
|
+
if (!destroyed && opened && !modal && event.relatedTarget instanceof Node && !base.element.contains(event.relatedTarget))
|
|
565
|
+
close(false);
|
|
566
|
+
};
|
|
567
|
+
base.element.addEventListener("click", onClick);
|
|
568
|
+
base.element.addEventListener("keydown", onKey);
|
|
569
|
+
base.element.addEventListener("focusout", onFocusOut);
|
|
570
|
+
dialog.addEventListener("focusin", onFocus);
|
|
571
|
+
dialog.addEventListener("click", onDialogClick);
|
|
572
|
+
dialog.addEventListener("input", onEntry);
|
|
573
|
+
dialog.addEventListener("cancel", onCancel);
|
|
574
|
+
dialog.addEventListener("scroll", onScroll, true);
|
|
575
|
+
dialog.addEventListener("scrollend", onScroll, true);
|
|
576
|
+
input.addEventListener("change", onInputChange);
|
|
577
|
+
input.addEventListener("click", onInputClick);
|
|
578
|
+
doc.addEventListener("click", onOutside);
|
|
579
|
+
const setDisabled = (disabled) => {
|
|
580
|
+
if (destroyed)
|
|
581
|
+
return;
|
|
582
|
+
if (disabled) {
|
|
583
|
+
close();
|
|
584
|
+
base.disabled.disable();
|
|
585
|
+
}
|
|
586
|
+
else
|
|
587
|
+
base.disabled.enable();
|
|
588
|
+
input.disabled = disabled;
|
|
589
|
+
trigger.disabled = disabled || readOnly;
|
|
590
|
+
};
|
|
591
|
+
const setReadOnly = (value) => {
|
|
592
|
+
if (destroyed)
|
|
593
|
+
return;
|
|
594
|
+
readOnly = value;
|
|
595
|
+
if (value)
|
|
596
|
+
close();
|
|
597
|
+
input.readOnly = value || modal;
|
|
598
|
+
trigger.disabled = value || base.disabled.isDisabled();
|
|
599
|
+
base.element.classList.toggle(base.getClass("datepicker--readonly"), value);
|
|
600
|
+
};
|
|
601
|
+
const checkValidity = () => !(input.required && !committed);
|
|
602
|
+
const reportValidity = () => {
|
|
603
|
+
const valid = checkValidity();
|
|
604
|
+
if (!valid) {
|
|
605
|
+
input.setAttribute("aria-invalid", "true");
|
|
606
|
+
error.textContent = `Select a ${state.selectionMode === "range" ? "date range" : "date"}.`;
|
|
607
|
+
}
|
|
608
|
+
return valid;
|
|
609
|
+
};
|
|
610
|
+
const destroy = () => {
|
|
611
|
+
if (destroyed)
|
|
612
|
+
return;
|
|
613
|
+
destroyed = true;
|
|
614
|
+
close();
|
|
615
|
+
doc.removeEventListener("click", onOutside);
|
|
616
|
+
input.removeEventListener("change", onInputChange);
|
|
617
|
+
input.removeEventListener("click", onInputClick);
|
|
618
|
+
base.element.removeEventListener("click", onClick);
|
|
619
|
+
base.element.removeEventListener("keydown", onKey);
|
|
620
|
+
base.element.removeEventListener("focusout", onFocusOut);
|
|
621
|
+
dialog.removeEventListener("focusin", onFocus);
|
|
622
|
+
dialog.removeEventListener("click", onDialogClick);
|
|
623
|
+
dialog.removeEventListener("input", onEntry);
|
|
624
|
+
dialog.removeEventListener("cancel", onCancel);
|
|
625
|
+
dialog.removeEventListener("scroll", onScroll, true);
|
|
626
|
+
dialog.removeEventListener("scrollend", onScroll, true);
|
|
627
|
+
clearTimeout(quiet);
|
|
628
|
+
base.lifecycle.destroy();
|
|
629
|
+
};
|
|
630
|
+
const api = withAPI({
|
|
631
|
+
element: base.element, input, getClass: base.getClass,
|
|
632
|
+
disabled: { enable: () => setDisabled(false), disable: () => setDisabled(true), isDisabled: () => base.disabled.isDisabled() }, lifecycle: { destroy }, destroy,
|
|
633
|
+
open() { open(); return api; }, close() { close(); return api; }, isOpen: () => opened, getValue,
|
|
634
|
+
getFormattedValue: () => formatted(committed, committedEnd),
|
|
635
|
+
setValue(value) { assignValue(value, false); return api; },
|
|
636
|
+
setReadOnly(value) { setReadOnly(value); return api; }, isReadOnly: () => readOnly,
|
|
637
|
+
setRequired(value) {
|
|
638
|
+
input.required = value;
|
|
639
|
+
if (!value)
|
|
640
|
+
syncInput();
|
|
641
|
+
return api;
|
|
642
|
+
}, checkValidity, reportValidity,
|
|
643
|
+
setSupportingText(text) { help.textContent = text || state.dateFormat; return api; },
|
|
644
|
+
clear() { clearValue(false); return api; },
|
|
645
|
+
enable() { setDisabled(false); return api; }, disable() { setDisabled(true); return api; },
|
|
646
|
+
setMinDate(value) {
|
|
647
|
+
const date = parseDate(value);
|
|
648
|
+
if (date && !destroyed) {
|
|
649
|
+
state.minDate = date;
|
|
650
|
+
render();
|
|
651
|
+
if (state.inputMode)
|
|
652
|
+
validateEntries();
|
|
653
|
+
}
|
|
654
|
+
return api;
|
|
655
|
+
},
|
|
656
|
+
setMaxDate(value) {
|
|
657
|
+
const date = parseDate(value);
|
|
658
|
+
if (date && !destroyed) {
|
|
659
|
+
state.maxDate = date;
|
|
660
|
+
render();
|
|
661
|
+
if (state.inputMode)
|
|
662
|
+
validateEntries();
|
|
663
|
+
}
|
|
664
|
+
return api;
|
|
665
|
+
},
|
|
666
|
+
calendar: {
|
|
667
|
+
goToDate(value) {
|
|
668
|
+
const date = parseDate(value);
|
|
669
|
+
if (date) {
|
|
670
|
+
navigationRequested = !opened;
|
|
671
|
+
setDisplayDate(date);
|
|
672
|
+
render();
|
|
673
|
+
}
|
|
674
|
+
},
|
|
675
|
+
nextMonth() { navigationRequested = !opened; setDisplayDate(addMonths(new Date(state.currentYear, state.currentMonth, 1), 1)); render(); },
|
|
676
|
+
prevMonth() { navigationRequested = !opened; setDisplayDate(addMonths(new Date(state.currentYear, state.currentMonth, 1), -1)); render(); },
|
|
677
|
+
nextYear() { navigationRequested = !opened; state.currentYear++; render(); }, prevYear() { navigationRequested = !opened; state.currentYear--; render(); },
|
|
678
|
+
showDayView() { state.currentView = "day"; state.inputMode = false; render(); },
|
|
679
|
+
showMonthView() { state.currentView = "month"; state.inputMode = false; render(); },
|
|
680
|
+
showYearView() { state.currentView = "year"; state.inputMode = false; render(); },
|
|
681
|
+
getCurrentView: () => state.currentView,
|
|
682
|
+
},
|
|
683
|
+
}, base);
|
|
684
|
+
if (settings.value)
|
|
685
|
+
assignValue(settings.value, false);
|
|
686
|
+
else
|
|
687
|
+
syncInput();
|
|
688
|
+
dialog.append(renderCalendar(state), announcement);
|
|
689
|
+
setDisabled(!!settings.disabled);
|
|
690
|
+
if (settings.required)
|
|
691
|
+
input.required = true;
|
|
692
|
+
if (settings.readOnly)
|
|
693
|
+
setReadOnly(true);
|
|
694
|
+
return api;
|
|
695
695
|
};
|
|
696
696
|
export default createDatePicker;
|