material 3.5.3 → 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/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
|
@@ -5,404 +5,404 @@ import { createDial, nameFor } from "./dial.js";
|
|
|
5
5
|
let fieldIds = 0;
|
|
6
6
|
import { setHTML } from "../../core/dom/html.js";
|
|
7
7
|
export const renderTimePicker = (container, timeValue, config, onTimeChange) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
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
|
-
|
|
8
|
+
container.replaceChildren();
|
|
9
|
+
if (config.title) {
|
|
10
|
+
const title = document.createElement("div");
|
|
11
|
+
title.className = `${config.prefix}-time-picker__title`;
|
|
12
|
+
title.textContent = config.title;
|
|
13
|
+
title.id = config.titleId ?? `${config.prefix}-time-picker__title`;
|
|
14
|
+
container.appendChild(title);
|
|
15
|
+
}
|
|
16
|
+
const content = document.createElement("div");
|
|
17
|
+
content.className = `${config.prefix}-time-picker__content`;
|
|
18
|
+
container.appendChild(content);
|
|
19
|
+
const inputContainer = document.createElement("div");
|
|
20
|
+
inputContainer.className = `${config.prefix}-time-picker__input-container`;
|
|
21
|
+
content.appendChild(inputContainer);
|
|
22
|
+
const { hours: displayHours } = config.format === TIME_FORMAT.MILITARY
|
|
23
|
+
? { hours: timeValue.hours }
|
|
24
|
+
: convertTo12Hour(timeValue.hours);
|
|
25
|
+
const dialMode = config.type === TIME_PICKER_TYPE.DIAL;
|
|
26
|
+
const selectors = document.createElement("div");
|
|
27
|
+
selectors.className = `${config.prefix}-time-picker__selectors`;
|
|
28
|
+
if (dialMode) {
|
|
29
|
+
selectors.setAttribute("role", "radiogroup");
|
|
30
|
+
selectors.setAttribute("aria-label", "Time");
|
|
31
|
+
}
|
|
32
|
+
inputContainer.appendChild(selectors);
|
|
33
|
+
const SELECT = { hour: "Select hour", minute: "Select minutes", second: "Select seconds" };
|
|
34
|
+
const NAME = { hour: "Hour", minute: "Minute", second: "Second" };
|
|
35
|
+
const CLASS = { hour: "hours", minute: "minutes", second: "seconds" };
|
|
36
|
+
const show = (field, value) => {
|
|
37
|
+
if (!field)
|
|
38
|
+
return;
|
|
39
|
+
const unit = field.getAttribute("data-type");
|
|
40
|
+
if (dialMode) {
|
|
41
|
+
field.textContent = padZero(value);
|
|
42
|
+
field.setAttribute("aria-label", `${SELECT[unit]}: ${nameFor(unit, config.format, value)}`);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
field.value = padZero(value);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const createField = (unit, min, max, value) => {
|
|
49
|
+
const wrapper = document.createElement("div");
|
|
50
|
+
wrapper.className = `${config.prefix}-time-picker__time-input-field`;
|
|
51
|
+
let field;
|
|
52
|
+
if (dialMode) {
|
|
53
|
+
field = document.createElement("button");
|
|
54
|
+
field.type = "button";
|
|
55
|
+
field.setAttribute("role", "radio");
|
|
56
|
+
const active = unit === "hour";
|
|
57
|
+
field.setAttribute("aria-checked", String(active));
|
|
58
|
+
field.setAttribute("data-active", String(active));
|
|
59
|
+
field.tabIndex = active ? 0 : -1;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
const input = document.createElement("input");
|
|
63
|
+
input.type = "number";
|
|
64
|
+
input.min = String(min);
|
|
65
|
+
input.max = String(max);
|
|
66
|
+
input.setAttribute("aria-label", NAME[unit]);
|
|
67
|
+
input.setAttribute("inputmode", "numeric");
|
|
68
|
+
input.setAttribute("pattern", "[0-9]*");
|
|
69
|
+
field = input;
|
|
70
|
+
}
|
|
71
|
+
field.className = `${config.prefix}-time-picker__${CLASS[unit]}`;
|
|
72
|
+
field.setAttribute("data-type", unit);
|
|
73
|
+
show(field, value);
|
|
74
|
+
wrapper.appendChild(field);
|
|
75
|
+
if (!dialMode) {
|
|
76
|
+
field.id = `${config.prefix}-time-picker-${unit}-${++fieldIds}`;
|
|
77
|
+
const label = document.createElement("label");
|
|
78
|
+
label.className = `${config.prefix}-time-picker__input-label`;
|
|
79
|
+
label.htmlFor = field.id;
|
|
80
|
+
label.textContent = NAME[unit];
|
|
81
|
+
wrapper.appendChild(label);
|
|
82
|
+
}
|
|
83
|
+
selectors.appendChild(wrapper);
|
|
84
|
+
return field;
|
|
85
|
+
};
|
|
86
|
+
const createSeparator = () => {
|
|
87
|
+
const separator = document.createElement("div");
|
|
88
|
+
separator.className = `${config.prefix}-time-picker__separator`;
|
|
89
|
+
separator.textContent = ":";
|
|
90
|
+
selectors.appendChild(separator);
|
|
91
|
+
};
|
|
92
|
+
const military = config.format === TIME_FORMAT.MILITARY;
|
|
93
|
+
const hoursInput = createField("hour", military ? 0 : 1, military ? 23 : 12, displayHours);
|
|
94
|
+
createSeparator();
|
|
95
|
+
const minutesInput = createField("minute", 0, 59, timeValue.minutes);
|
|
96
|
+
let secondsInput;
|
|
97
|
+
if (config.showSeconds) {
|
|
98
|
+
createSeparator();
|
|
99
|
+
secondsInput = createField("second", 0, 59, timeValue.seconds || 0);
|
|
100
|
+
}
|
|
101
|
+
if (config.format === TIME_FORMAT.AMPM) {
|
|
102
|
+
const periodContainer = document.createElement("div");
|
|
103
|
+
periodContainer.className = `${config.prefix}-time-picker__period`;
|
|
104
|
+
periodContainer.setAttribute("role", "radiogroup");
|
|
105
|
+
periodContainer.setAttribute("aria-label", "AM or PM");
|
|
106
|
+
const createPeriodOption = (period) => {
|
|
107
|
+
const selected = timeValue.period === period;
|
|
108
|
+
const option = document.createElement("div");
|
|
109
|
+
option.className = `${config.prefix}-time-picker__period-${period.toLowerCase()} ${selected ? `${config.prefix}-time-picker__period--selected` : ""}`;
|
|
110
|
+
option.textContent = period;
|
|
111
|
+
option.setAttribute("role", "radio");
|
|
112
|
+
option.setAttribute("aria-checked", selected ? "true" : "false");
|
|
113
|
+
option.setAttribute("tabindex", selected ? "0" : "-1");
|
|
114
|
+
return option;
|
|
115
|
+
};
|
|
116
|
+
const amPeriod = createPeriodOption(TIME_PERIOD.AM);
|
|
117
|
+
const pmPeriod = createPeriodOption(TIME_PERIOD.PM);
|
|
118
|
+
periodContainer.appendChild(amPeriod);
|
|
119
|
+
periodContainer.appendChild(pmPeriod);
|
|
120
|
+
inputContainer.appendChild(periodContainer);
|
|
121
|
+
}
|
|
122
|
+
const dialContainer = document.createElement("div");
|
|
123
|
+
dialContainer.className = `${config.prefix}-time-picker__dial`;
|
|
124
|
+
dialContainer.style.display =
|
|
125
|
+
config.type === TIME_PICKER_TYPE.DIAL ? "block" : "none";
|
|
126
|
+
content.appendChild(dialContainer);
|
|
127
|
+
const dial = createDial({
|
|
128
|
+
prefix: config.prefix,
|
|
129
|
+
format: config.format,
|
|
130
|
+
onSelect: (value, final, pointer) => selectFromDial(value, final, pointer),
|
|
131
|
+
allowed: (unit, value) => allowed(unit, value),
|
|
132
|
+
});
|
|
133
|
+
dialContainer.appendChild(dial.element);
|
|
134
|
+
const actions = document.createElement("div");
|
|
135
|
+
actions.className = `${config.prefix}-time-picker__actions`;
|
|
136
|
+
container.appendChild(actions);
|
|
137
|
+
const toggleTypeButton = document.createElement("button");
|
|
138
|
+
toggleTypeButton.className = `${config.prefix}-time-picker__toggle-type`;
|
|
139
|
+
toggleTypeButton.setAttribute("type", "button");
|
|
140
|
+
toggleTypeButton.setAttribute("aria-label", config.type === TIME_PICKER_TYPE.DIAL
|
|
141
|
+
? "Toggle input picker"
|
|
142
|
+
: "Toggle dial picker");
|
|
143
|
+
setHTML(toggleTypeButton, config.type === TIME_PICKER_TYPE.DIAL
|
|
144
|
+
? config.keyboardIcon || TIMEPICKER_ICONS.KEYBOARD
|
|
145
|
+
: config.clockIcon || TIMEPICKER_ICONS.CLOCK);
|
|
146
|
+
actions.appendChild(toggleTypeButton);
|
|
147
|
+
const actionButtons = document.createElement("div");
|
|
148
|
+
actionButtons.className = `${config.prefix}-time-picker__action-buttons`;
|
|
149
|
+
actions.appendChild(actionButtons);
|
|
150
|
+
const cancelButton = document.createElement("button");
|
|
151
|
+
cancelButton.className = `${config.prefix}-time-picker__cancel`;
|
|
152
|
+
cancelButton.textContent = config.cancelText || "Cancel";
|
|
153
|
+
cancelButton.setAttribute("type", "button");
|
|
154
|
+
actionButtons.appendChild(cancelButton);
|
|
155
|
+
const confirmButton = document.createElement("button");
|
|
156
|
+
confirmButton.className = `${config.prefix}-time-picker__confirm`;
|
|
157
|
+
confirmButton.textContent = config.confirmText || "OK";
|
|
158
|
+
confirmButton.setAttribute("type", "button");
|
|
159
|
+
actionButtons.appendChild(confirmButton);
|
|
160
|
+
let activeSelector = "hour";
|
|
161
|
+
const fields = () => [["hour", hoursInput], ["minute", minutesInput], ["second", secondsInput]]
|
|
162
|
+
.filter((entry) => entry[1] !== undefined);
|
|
163
|
+
const setActive = (unit) => {
|
|
164
|
+
activeSelector = unit;
|
|
165
|
+
for (const [type, field] of fields()) {
|
|
166
|
+
field.setAttribute("data-active", String(type === unit));
|
|
167
|
+
if (dialMode) {
|
|
168
|
+
field.setAttribute("aria-checked", String(type === unit));
|
|
169
|
+
field.tabIndex = type === unit ? 0 : -1;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
dial.update(timeValue, activeSelector);
|
|
173
|
+
};
|
|
174
|
+
const limits = limitsOf(config.minTime, config.maxTime);
|
|
175
|
+
const minuteStep = Math.max(1, Math.floor(config.minuteStep) || 1);
|
|
176
|
+
const secondStep = Math.max(1, Math.floor(config.secondStep) || 1);
|
|
177
|
+
const HALF_DAY = 12 * 3600;
|
|
178
|
+
const roundToStep = (value, step) => Math.min(Math.round(value / step) * step, 59 - (59 % step));
|
|
179
|
+
const to24 = (hour) => config.format === TIME_FORMAT.MILITARY ? hour : (hour % 12) + (timeValue.period === TIME_PERIOD.PM ? 12 : 0);
|
|
180
|
+
const periodAllowed = (period) => period === TIME_PERIOD.AM ? reachable(limits, 0, HALF_DAY - 1) : reachable(limits, HALF_DAY, 2 * HALF_DAY - 1);
|
|
181
|
+
function allowed(unit, value) {
|
|
182
|
+
if (unit === "hour") {
|
|
183
|
+
const start = to24(value) * 3600;
|
|
184
|
+
return reachable(limits, start, start + 3599);
|
|
185
|
+
}
|
|
186
|
+
const hour = timeValue.hours * 3600;
|
|
187
|
+
if (unit === "minute")
|
|
188
|
+
return value % minuteStep === 0 && reachable(limits, hour + value * 60, hour + value * 60 + 59);
|
|
189
|
+
return value % secondStep === 0 && reachable(limits, hour + timeValue.minutes * 60 + value);
|
|
190
|
+
}
|
|
191
|
+
const refresh = () => {
|
|
192
|
+
show(hoursInput, config.format === TIME_FORMAT.MILITARY ? timeValue.hours : timeValue.hours % 12 || 12);
|
|
193
|
+
show(minutesInput, timeValue.minutes);
|
|
194
|
+
show(secondsInput, timeValue.seconds ?? 0);
|
|
195
|
+
markPeriod();
|
|
196
|
+
dial.update(timeValue, activeSelector);
|
|
197
|
+
};
|
|
198
|
+
const settle = () => {
|
|
199
|
+
Object.assign(timeValue, constrainTime(timeValue, limits, minuteStep, secondStep));
|
|
200
|
+
refresh();
|
|
201
|
+
};
|
|
202
|
+
const notify = (before) => {
|
|
203
|
+
if (secondsOfTime(before) !== secondsOfTime(timeValue))
|
|
204
|
+
onTimeChange?.("hours", timeValue.hours);
|
|
205
|
+
};
|
|
206
|
+
function markPeriod() {
|
|
207
|
+
for (const period of [TIME_PERIOD.AM, TIME_PERIOD.PM]) {
|
|
208
|
+
const element = container.querySelector(`.${config.prefix}-time-picker__period-${period.toLowerCase()}`);
|
|
209
|
+
if (!element)
|
|
210
|
+
continue;
|
|
211
|
+
const selected = timeValue.period === period;
|
|
212
|
+
element.classList.toggle(`${config.prefix}-time-picker__period--selected`, selected);
|
|
213
|
+
element.setAttribute("aria-checked", String(selected));
|
|
214
|
+
element.setAttribute("tabindex", selected ? "0" : "-1");
|
|
215
|
+
if (periodAllowed(period))
|
|
216
|
+
element.removeAttribute("aria-disabled");
|
|
217
|
+
else
|
|
218
|
+
element.setAttribute("aria-disabled", "true");
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
dial.update(timeValue, activeSelector);
|
|
222
|
+
const handleInputChange = (e) => {
|
|
223
|
+
const target = e.target;
|
|
224
|
+
const type = target.getAttribute("data-type");
|
|
225
|
+
const value = target.value;
|
|
226
|
+
const commit = e.type !== "input";
|
|
227
|
+
const numValue = parseInt(value, 10);
|
|
228
|
+
if (isNaN(numValue)) {
|
|
229
|
+
if (commit)
|
|
230
|
+
refresh();
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
const previousValue = { ...timeValue };
|
|
234
|
+
if (type === "hour") {
|
|
235
|
+
let newHours = numValue;
|
|
236
|
+
if (config.format === TIME_FORMAT.AMPM) {
|
|
237
|
+
if (numValue < 1)
|
|
238
|
+
newHours = 12;
|
|
239
|
+
if (numValue > 12)
|
|
240
|
+
newHours = 1;
|
|
241
|
+
if (timeValue.period === TIME_PERIOD.PM && newHours !== 12) {
|
|
242
|
+
newHours += 12;
|
|
243
|
+
}
|
|
244
|
+
else if (timeValue.period === TIME_PERIOD.AM && newHours === 12) {
|
|
245
|
+
newHours = 0;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
if (numValue < 0)
|
|
250
|
+
newHours = 0;
|
|
251
|
+
if (numValue > 23)
|
|
252
|
+
newHours = 23;
|
|
253
|
+
}
|
|
254
|
+
timeValue.hours = newHours;
|
|
255
|
+
timeValue.period = newHours >= 12 ? TIME_PERIOD.PM : TIME_PERIOD.AM;
|
|
256
|
+
setActive("hour");
|
|
257
|
+
}
|
|
258
|
+
else if (type === "minute") {
|
|
259
|
+
let newMinutes = numValue;
|
|
260
|
+
if (numValue < 0)
|
|
261
|
+
newMinutes = 0;
|
|
262
|
+
if (numValue > 59)
|
|
263
|
+
newMinutes = 59;
|
|
264
|
+
timeValue.minutes = commit ? roundToStep(newMinutes, minuteStep) : newMinutes;
|
|
265
|
+
setActive("minute");
|
|
266
|
+
}
|
|
267
|
+
else if (type === "second") {
|
|
268
|
+
let newSeconds = numValue;
|
|
269
|
+
if (numValue < 0)
|
|
270
|
+
newSeconds = 0;
|
|
271
|
+
if (numValue > 59)
|
|
272
|
+
newSeconds = 59;
|
|
273
|
+
timeValue.seconds = commit ? roundToStep(newSeconds, secondStep) : newSeconds;
|
|
274
|
+
setActive("second");
|
|
275
|
+
}
|
|
276
|
+
if (commit)
|
|
277
|
+
settle();
|
|
278
|
+
notify(previousValue);
|
|
279
|
+
};
|
|
280
|
+
const isInput = (field) => field?.tagName === "INPUT";
|
|
281
|
+
for (const input of [hoursInput, minutesInput, secondsInput]) {
|
|
282
|
+
if (!isInput(input))
|
|
283
|
+
continue;
|
|
284
|
+
input.addEventListener("input", handleInputChange);
|
|
285
|
+
input.addEventListener("change", handleInputChange);
|
|
286
|
+
input.addEventListener("keyup", event => {
|
|
287
|
+
if (event.key === "Enter")
|
|
288
|
+
handleInputChange(event);
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
if (isInput(hoursInput) && isInput(minutesInput)) {
|
|
292
|
+
const hours = hoursInput, minutes = minutesInput;
|
|
293
|
+
hours.addEventListener("keyup", (e) => {
|
|
294
|
+
if (e.key === "Enter") {
|
|
295
|
+
minutes.focus();
|
|
296
|
+
minutes.select();
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
minutes.addEventListener("keyup", (e) => {
|
|
300
|
+
if (e.key === "Enter") {
|
|
301
|
+
if (config.showSeconds && isInput(secondsInput)) {
|
|
302
|
+
secondsInput.focus();
|
|
303
|
+
secondsInput.select();
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
confirmButton.focus();
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
if (isInput(secondsInput)) {
|
|
311
|
+
secondsInput.addEventListener("keyup", (e) => {
|
|
312
|
+
if (e.key === "Enter") {
|
|
313
|
+
confirmButton.focus();
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
const handlePeriodChange = (period) => {
|
|
319
|
+
if (timeValue.period === period || !periodAllowed(period))
|
|
320
|
+
return;
|
|
321
|
+
const previousValue = { ...timeValue };
|
|
322
|
+
timeValue.period = period;
|
|
323
|
+
timeValue.hours = (timeValue.hours % 12) + (period === TIME_PERIOD.PM ? 12 : 0);
|
|
324
|
+
settle();
|
|
325
|
+
notify(previousValue);
|
|
326
|
+
};
|
|
327
|
+
if (config.format === TIME_FORMAT.AMPM) {
|
|
328
|
+
const amPeriodElement = container.querySelector(`.${config.prefix}-time-picker__period-am`);
|
|
329
|
+
const pmPeriodElement = container.querySelector(`.${config.prefix}-time-picker__period-pm`);
|
|
330
|
+
const wirePeriod = (element, period, other) => {
|
|
331
|
+
if (!element)
|
|
332
|
+
return;
|
|
333
|
+
element.addEventListener("click", () => handlePeriodChange(period));
|
|
334
|
+
element.addEventListener("keydown", (event) => {
|
|
335
|
+
const key = event.key;
|
|
336
|
+
if (key === "Enter" || key === " " || key === "Spacebar") {
|
|
337
|
+
event.preventDefault();
|
|
338
|
+
handlePeriodChange(period);
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
if (key === "ArrowLeft" ||
|
|
342
|
+
key === "ArrowRight" ||
|
|
343
|
+
key === "ArrowUp" ||
|
|
344
|
+
key === "ArrowDown") {
|
|
345
|
+
event.preventDefault();
|
|
346
|
+
if (!periodAllowed(other))
|
|
347
|
+
return;
|
|
348
|
+
handlePeriodChange(other);
|
|
349
|
+
const moved = container.querySelector(`.${config.prefix}-time-picker__period-${other.toLowerCase()}`);
|
|
350
|
+
if (moved instanceof HTMLElement)
|
|
351
|
+
moved.focus();
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
};
|
|
355
|
+
wirePeriod(amPeriodElement, TIME_PERIOD.AM, TIME_PERIOD.PM);
|
|
356
|
+
wirePeriod(pmPeriodElement, TIME_PERIOD.PM, TIME_PERIOD.AM);
|
|
357
|
+
}
|
|
358
|
+
let started = null;
|
|
359
|
+
function selectFromDial(value, final, pointer) {
|
|
360
|
+
if (!final && !started)
|
|
361
|
+
started = { ...timeValue };
|
|
362
|
+
const previousValue = started ?? { ...timeValue };
|
|
363
|
+
if (activeSelector !== "hour")
|
|
364
|
+
value = roundToStep(value, activeSelector === "minute" ? minuteStep : secondStep);
|
|
365
|
+
const picked = allowed(activeSelector, value);
|
|
366
|
+
if (picked) {
|
|
367
|
+
if (activeSelector === "hour") {
|
|
368
|
+
timeValue.hours = to24(value);
|
|
369
|
+
timeValue.period = timeValue.hours >= 12 ? TIME_PERIOD.PM : TIME_PERIOD.AM;
|
|
370
|
+
}
|
|
371
|
+
else if (activeSelector === "minute") {
|
|
372
|
+
timeValue.minutes = value;
|
|
373
|
+
}
|
|
374
|
+
else if (secondsInput) {
|
|
375
|
+
timeValue.seconds = value;
|
|
376
|
+
}
|
|
377
|
+
settle();
|
|
378
|
+
}
|
|
379
|
+
if (!final)
|
|
380
|
+
return;
|
|
381
|
+
started = null;
|
|
382
|
+
notify(previousValue);
|
|
383
|
+
if (picked && pointer && activeSelector === "hour") {
|
|
384
|
+
setTimeout(() => {
|
|
385
|
+
if (dial.element.isConnected && activeSelector === "hour")
|
|
386
|
+
minutesInput.click();
|
|
387
|
+
}, 200);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
markPeriod();
|
|
391
|
+
if (dialMode) {
|
|
392
|
+
for (const [unit, field] of fields()) {
|
|
393
|
+
field.addEventListener("click", () => setActive(unit));
|
|
394
|
+
field.addEventListener("keydown", event => {
|
|
395
|
+
const key = event.key;
|
|
396
|
+
const step = key === "ArrowRight" || key === "ArrowDown" ? 1
|
|
397
|
+
: key === "ArrowLeft" || key === "ArrowUp" ? -1 : 0;
|
|
398
|
+
if (!step)
|
|
399
|
+
return;
|
|
400
|
+
event.preventDefault();
|
|
401
|
+
const all = fields();
|
|
402
|
+
const [next, target] = all[(all.findIndex(([type]) => type === unit) + step + all.length) % all.length];
|
|
403
|
+
setActive(next);
|
|
404
|
+
target.focus();
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
408
|
};
|