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
|
@@ -8,473 +8,473 @@ const DRAG_THRESHOLD = 4;
|
|
|
8
8
|
const WHEEL_QUIET = 120;
|
|
9
9
|
const WHEEL_SNAP_REACH = 1;
|
|
10
10
|
export const withScroll = (config) => (component) => {
|
|
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
|
-
|
|
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
|
-
|
|
11
|
+
const { variant, gap, padding, snap } = resolveLayoutDefaults(config);
|
|
12
|
+
const vertical = variant === CAROUSEL_VARIANTS.FULL_SCREEN;
|
|
13
|
+
const rules = {
|
|
14
|
+
minSmallSize: config.minSmallItemWidth ?? CAROUSEL_DEFAULTS.MIN_SMALL_ITEM_WIDTH,
|
|
15
|
+
maxSmallSize: config.maxSmallItemWidth ?? CAROUSEL_DEFAULTS.MAX_SMALL_ITEM_WIDTH,
|
|
16
|
+
anchorSize: CAROUSEL_DEFAULTS.ANCHOR_SIZE,
|
|
17
|
+
mediumLargeThreshold: CAROUSEL_DEFAULTS.MEDIUM_LARGE_THRESHOLD,
|
|
18
|
+
};
|
|
19
|
+
const cornerRadius = config.cornerRadius ?? CAROUSEL_DEFAULTS.CORNER_RADIUS;
|
|
20
|
+
const corner = cornerRadius === CAROUSEL_DEFAULTS.CORNER_RADIUS
|
|
21
|
+
? cornerToken("extra-large", cornerRadius, config.prefix)
|
|
22
|
+
: `${cornerRadius}px`;
|
|
23
|
+
const reduceMotion = typeof window !== "undefined" && typeof window.matchMedia === "function"
|
|
24
|
+
? window.matchMedia("(prefers-reduced-motion: reduce)")
|
|
25
|
+
: null;
|
|
26
|
+
const { element, scroller, track, slideElements } = component;
|
|
27
|
+
const prefix = component.getClass("carousel");
|
|
28
|
+
const snapClass = `${prefix}__snap`;
|
|
29
|
+
element.classList.toggle(`${prefix}--snap`, snap);
|
|
30
|
+
const readRtl = () => !vertical && window.getComputedStyle?.(scroller).direction === "rtl";
|
|
31
|
+
let rtl = readRtl();
|
|
32
|
+
let sign = rtl ? -1 : 1;
|
|
33
|
+
let lastWheel = -Infinity;
|
|
34
|
+
let strategy = null;
|
|
35
|
+
let count = 0;
|
|
36
|
+
let containerSize = 0;
|
|
37
|
+
let scrollOffsetAtStart = 0;
|
|
38
|
+
let snapPositions = [];
|
|
39
|
+
let currentIndex = Math.max(0, config.initialSlide ?? CAROUSEL_DEFAULTS.INITIAL_SLIDE);
|
|
40
|
+
let lastStyles = new WeakMap();
|
|
41
|
+
let pending = null;
|
|
42
|
+
let pendingTimer = 0;
|
|
43
|
+
const clearPending = () => {
|
|
44
|
+
pending = null;
|
|
45
|
+
window.clearTimeout(pendingTimer);
|
|
46
|
+
};
|
|
47
|
+
const expect = (index) => {
|
|
48
|
+
pending = index;
|
|
49
|
+
window.clearTimeout(pendingTimer);
|
|
50
|
+
pendingTimer = window.setTimeout(clearPending, 1000);
|
|
51
|
+
};
|
|
52
|
+
const scrollPosition = () => {
|
|
53
|
+
if (readRtl() !== rtl)
|
|
54
|
+
rebuild();
|
|
55
|
+
return vertical ? scroller.scrollTop : scroller.scrollLeft * sign;
|
|
56
|
+
};
|
|
57
|
+
const setScrollPosition = (value, smooth) => {
|
|
58
|
+
const behavior = smooth && !reduceMotion?.matches ? "smooth" : "auto";
|
|
59
|
+
const physical = value * sign;
|
|
60
|
+
if (typeof scroller.scrollTo === "function")
|
|
61
|
+
scroller.scrollTo(vertical ? { top: value, behavior } : { left: physical, behavior });
|
|
62
|
+
else if (vertical)
|
|
63
|
+
scroller.scrollTop = value;
|
|
64
|
+
else
|
|
65
|
+
scroller.scrollLeft = physical;
|
|
66
|
+
};
|
|
67
|
+
const emitChange = () => {
|
|
68
|
+
component.emit?.(CAROUSEL_EVENTS.CHANGE, { value: currentIndex });
|
|
69
|
+
};
|
|
70
|
+
const nearestIndex = (position) => {
|
|
71
|
+
let best = 0;
|
|
72
|
+
let bestDistance = Number.MAX_VALUE;
|
|
73
|
+
snapPositions.forEach((snapPosition, i) => {
|
|
74
|
+
const distance = Math.abs(position - snapPosition);
|
|
75
|
+
if (distance < bestDistance) {
|
|
76
|
+
bestDistance = distance;
|
|
77
|
+
best = i;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
return best;
|
|
81
|
+
};
|
|
82
|
+
const buildKeylines = (size) => {
|
|
83
|
+
const preferred = config.itemWidth ?? CAROUSEL_DEFAULTS.ITEM_WIDTH;
|
|
84
|
+
if (variant === CAROUSEL_VARIANTS.FULL_SCREEN)
|
|
85
|
+
return fullScreenKeylines(size, gap, rules);
|
|
86
|
+
if (reduceMotion?.matches === true) {
|
|
87
|
+
const itemSize = variant.startsWith("hero") ? Math.min(config.itemWidth ?? size, size) : preferred;
|
|
88
|
+
return cappedKeylines(size, itemSize, gap, rules);
|
|
89
|
+
}
|
|
90
|
+
return variant.startsWith("hero")
|
|
91
|
+
? heroKeylines(size, config.itemWidth ?? null, gap, count, variant === CAROUSEL_VARIANTS.HERO_CENTER, rules)
|
|
92
|
+
: multiBrowseKeylines(size, preferred, gap, count, rules);
|
|
93
|
+
};
|
|
94
|
+
const build = () => {
|
|
95
|
+
rtl = readRtl();
|
|
96
|
+
sign = rtl ? -1 : 1;
|
|
97
|
+
lastStyles = new WeakMap();
|
|
98
|
+
count = slideElements.length;
|
|
99
|
+
containerSize = vertical ? scroller.clientHeight : scroller.clientWidth;
|
|
100
|
+
currentIndex = count ? Math.min(currentIndex, count - 1) : 0;
|
|
101
|
+
if (containerSize <= 0 || count === 0) {
|
|
102
|
+
strategy = null;
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const isUncontained = variant === CAROUSEL_VARIANTS.UNCONTAINED;
|
|
106
|
+
strategy = isUncontained
|
|
107
|
+
? { itemSize: config.itemWidth ?? CAROUSEL_DEFAULTS.ITEM_WIDTH, gap, valid: true }
|
|
108
|
+
: createStrategy(buildKeylines(containerSize), containerSize, gap, padding, padding);
|
|
109
|
+
if (!strategy.valid) {
|
|
110
|
+
strategy = null;
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const unit = strategy.itemSize + strategy.gap;
|
|
114
|
+
scrollOffsetAtStart = isUncontained ? 0 : -snapPositionOffset(strategy, 0, count);
|
|
115
|
+
snapPositions = slideElements.map((_, i) => isUncontained ? i * unit : i * unit - snapPositionOffset(strategy, i, count) - scrollOffsetAtStart);
|
|
116
|
+
const scrollRange = Math.max(0, snapPositions[count - 1] ?? 0);
|
|
117
|
+
track.style[vertical ? "height" : "width"] = `${containerSize + scrollRange}px`;
|
|
118
|
+
track.style[vertical ? "width" : "height"] = "";
|
|
119
|
+
track.querySelectorAll(`.${snapClass}`).forEach((el) => el.remove());
|
|
120
|
+
const fragment = document.createDocumentFragment();
|
|
121
|
+
snapPositions.forEach((snapPosition) => {
|
|
122
|
+
const point = document.createElement("div");
|
|
123
|
+
point.className = snapClass;
|
|
124
|
+
point.style[vertical ? "top" : rtl ? "right" : "left"] = `${snapPosition}px`;
|
|
125
|
+
if (rtl)
|
|
126
|
+
point.style.left = "auto";
|
|
127
|
+
fragment.appendChild(point);
|
|
128
|
+
});
|
|
129
|
+
track.appendChild(fragment);
|
|
130
|
+
slideElements.forEach((el) => {
|
|
131
|
+
el.style[vertical ? "height" : "width"] = `${strategy.itemSize}px`;
|
|
132
|
+
el.style[vertical ? "width" : "height"] = "";
|
|
133
|
+
el.style.left = rtl ? "auto" : "";
|
|
134
|
+
el.style.right = rtl ? "0" : "";
|
|
135
|
+
});
|
|
136
|
+
element.style.setProperty(`--${config.prefix}-carousel-corner`, corner);
|
|
137
|
+
};
|
|
138
|
+
const layout = () => {
|
|
139
|
+
if (!strategy)
|
|
140
|
+
return;
|
|
141
|
+
const position = scrollPosition();
|
|
142
|
+
const isUncontained = variant === CAROUSEL_VARIANTS.UNCONTAINED;
|
|
143
|
+
const itemSize = strategy.itemSize;
|
|
144
|
+
const unit = itemSize + strategy.gap;
|
|
145
|
+
const scrollOffset = position + scrollOffsetAtStart;
|
|
146
|
+
const keylines = isUncontained ? null : keylinesForScrollOffset(strategy, scrollOffset, maxScrollOffset(strategy, count));
|
|
147
|
+
const fadeRange = strategy.maxItemSize - strategy.minItemSize;
|
|
148
|
+
for (let i = 0; i < count; i++) {
|
|
149
|
+
const el = slideElements[i];
|
|
150
|
+
let start = padding + i * unit;
|
|
151
|
+
let inset = 0;
|
|
152
|
+
let fade = 1;
|
|
153
|
+
let offscreen = false;
|
|
154
|
+
if (!isUncontained) {
|
|
155
|
+
const placement = placeItem(strategy, keylines, i, scrollOffset);
|
|
156
|
+
const visible = Math.max(0, Math.min(itemSize, placement.size));
|
|
157
|
+
start = placement.center - itemSize / 2 + position;
|
|
158
|
+
offscreen = placement.center + visible / 2 < -itemSize || placement.center - visible / 2 > containerSize + itemSize;
|
|
159
|
+
inset = Math.max(0, (itemSize - visible) / 2);
|
|
160
|
+
if (fadeRange > 0)
|
|
161
|
+
fade = Math.min(1, Math.max(0, (visible - strategy.minItemSize) / fadeRange));
|
|
162
|
+
}
|
|
163
|
+
const style = offscreen
|
|
164
|
+
? "hidden"
|
|
165
|
+
: `${Math.round(start * 100) / 100}|${Math.round(inset * 100) / 100}|${fade.toFixed(3)}`;
|
|
166
|
+
if (lastStyles.get(el) === style)
|
|
167
|
+
continue;
|
|
168
|
+
lastStyles.set(el, style);
|
|
169
|
+
if (offscreen) {
|
|
170
|
+
el.style.visibility = "hidden";
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
el.style.visibility = "";
|
|
174
|
+
el.style.transform = vertical ? `translate3d(0, ${start}px, 0)` : `translate3d(${start * sign}px, 0, 0)`;
|
|
175
|
+
el.style.clipPath = inset > 0 ? (vertical ? `inset(${inset}px 0 round ${corner})` : `inset(0 ${inset}px round ${corner})`) : "";
|
|
176
|
+
el.style.setProperty(`--${config.prefix}-carousel-fade`, fade.toFixed(3));
|
|
177
|
+
}
|
|
178
|
+
if (pending !== null) {
|
|
179
|
+
if (Math.abs(scrollPosition() - (snapPositions[pending] ?? 0)) < 1)
|
|
180
|
+
clearPending();
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
const index = nearestIndex(scrollPosition());
|
|
184
|
+
if (index !== currentIndex) {
|
|
185
|
+
currentIndex = index;
|
|
186
|
+
emitChange();
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
const rebuild = () => {
|
|
190
|
+
stopWheel();
|
|
191
|
+
build();
|
|
192
|
+
if (strategy) {
|
|
193
|
+
expect(currentIndex);
|
|
194
|
+
setScrollPosition(snapPositions[currentIndex] ?? 0, false);
|
|
195
|
+
}
|
|
196
|
+
layout();
|
|
197
|
+
};
|
|
198
|
+
const goTo = (index) => {
|
|
199
|
+
stopWheel();
|
|
200
|
+
if (!count)
|
|
201
|
+
return;
|
|
202
|
+
scrollPosition();
|
|
203
|
+
const target = Math.min(Math.max(index, 0), count - 1);
|
|
204
|
+
if (strategy) {
|
|
205
|
+
expect(target);
|
|
206
|
+
setScrollPosition(snapPositions[target] ?? 0, true);
|
|
207
|
+
}
|
|
208
|
+
if (target !== currentIndex) {
|
|
209
|
+
currentIndex = target;
|
|
210
|
+
emitChange();
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
const next = () => goTo(currentIndex + 1);
|
|
214
|
+
const prev = () => goTo(currentIndex - 1);
|
|
215
|
+
const indexOf = (target) => {
|
|
216
|
+
const item = target?.closest?.(`.${prefix}__item`);
|
|
217
|
+
return item ? slideElements.indexOf(item) : -1;
|
|
218
|
+
};
|
|
219
|
+
const handleKeyDown = (e) => {
|
|
220
|
+
stopWheel();
|
|
221
|
+
const from = indexOf(e.target);
|
|
222
|
+
if (from < 0)
|
|
223
|
+
return;
|
|
224
|
+
const forward = vertical ? "ArrowDown" : rtl ? "ArrowLeft" : "ArrowRight";
|
|
225
|
+
const backward = vertical ? "ArrowUp" : rtl ? "ArrowRight" : "ArrowLeft";
|
|
226
|
+
let target = -1;
|
|
227
|
+
if (e.key === forward)
|
|
228
|
+
target = from + 1;
|
|
229
|
+
else if (e.key === backward)
|
|
230
|
+
target = from - 1;
|
|
231
|
+
else if (e.key === "Home")
|
|
232
|
+
target = 0;
|
|
233
|
+
else if (e.key === "End")
|
|
234
|
+
target = count - 1;
|
|
235
|
+
if (target < 0 || target >= count)
|
|
236
|
+
return;
|
|
237
|
+
e.preventDefault();
|
|
238
|
+
slideElements[target].focus({ preventScroll: true });
|
|
239
|
+
goTo(target);
|
|
240
|
+
};
|
|
241
|
+
const handleFocusIn = (e) => {
|
|
242
|
+
const index = indexOf(e.target);
|
|
243
|
+
if (index >= 0 && index !== currentIndex)
|
|
244
|
+
goTo(index);
|
|
245
|
+
};
|
|
246
|
+
let dragging = false;
|
|
247
|
+
let dragged = false;
|
|
248
|
+
let dragStart = 0;
|
|
249
|
+
let dragScrollStart = 0;
|
|
250
|
+
let dragLast = 0;
|
|
251
|
+
let dragLastTime = 0;
|
|
252
|
+
let dragVelocity = 0;
|
|
253
|
+
let settleTimer = 0;
|
|
254
|
+
const restoreSnap = () => {
|
|
255
|
+
window.clearTimeout(settleTimer);
|
|
256
|
+
scroller.removeEventListener("scrollend", restoreSnap);
|
|
257
|
+
delete element.dataset.settling;
|
|
258
|
+
};
|
|
259
|
+
const handlePointerDown = (e) => {
|
|
260
|
+
stopWheel();
|
|
261
|
+
clearPending();
|
|
262
|
+
if (e.pointerType !== "mouse" || e.button !== 0 || !strategy)
|
|
263
|
+
return;
|
|
264
|
+
dragging = true;
|
|
265
|
+
lastWheel = -Infinity;
|
|
266
|
+
dragged = false;
|
|
267
|
+
dragStart = vertical ? e.clientY : e.clientX;
|
|
268
|
+
dragLast = dragStart;
|
|
269
|
+
dragLastTime = e.timeStamp;
|
|
270
|
+
dragVelocity = 0;
|
|
271
|
+
dragScrollStart = scroller[vertical ? "scrollTop" : "scrollLeft"];
|
|
272
|
+
restoreSnap();
|
|
273
|
+
element.dataset.settling = "true";
|
|
274
|
+
scroller.setPointerCapture(e.pointerId);
|
|
275
|
+
};
|
|
276
|
+
const handlePointerMove = (e) => {
|
|
277
|
+
if (!dragging)
|
|
278
|
+
return;
|
|
279
|
+
const position = vertical ? e.clientY : e.clientX;
|
|
280
|
+
const delta = position - dragStart;
|
|
281
|
+
if (!dragged && Math.abs(delta) < DRAG_THRESHOLD)
|
|
282
|
+
return;
|
|
283
|
+
dragged = true;
|
|
284
|
+
element.dataset.dragging = "true";
|
|
285
|
+
const dt = e.timeStamp - dragLastTime;
|
|
286
|
+
if (dt > 0)
|
|
287
|
+
dragVelocity = ((position - dragLast) / dt) * sign;
|
|
288
|
+
dragLast = position;
|
|
289
|
+
dragLastTime = e.timeStamp;
|
|
290
|
+
scroller[vertical ? "scrollTop" : "scrollLeft"] = dragScrollStart - delta;
|
|
291
|
+
e.preventDefault();
|
|
292
|
+
};
|
|
293
|
+
const handlePointerUp = (e) => {
|
|
294
|
+
if (!dragging)
|
|
295
|
+
return;
|
|
296
|
+
dragging = false;
|
|
297
|
+
if (scroller.hasPointerCapture(e.pointerId))
|
|
298
|
+
scroller.releasePointerCapture(e.pointerId);
|
|
299
|
+
delete element.dataset.dragging;
|
|
300
|
+
if (!dragged) {
|
|
301
|
+
restoreSnap();
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
if (snap) {
|
|
305
|
+
let target = nearestIndex(scrollPosition());
|
|
306
|
+
if (dragVelocity < -FLING_VELOCITY)
|
|
307
|
+
target = Math.min(count - 1, target + 1);
|
|
308
|
+
else if (dragVelocity > FLING_VELOCITY)
|
|
309
|
+
target = Math.max(0, target - 1);
|
|
310
|
+
goTo(target);
|
|
311
|
+
scroller.addEventListener("scrollend", restoreSnap, { once: true });
|
|
312
|
+
settleTimer = window.setTimeout(restoreSnap, 600);
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
restoreSnap();
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
const handleClick = (e) => {
|
|
319
|
+
if (dragged) {
|
|
320
|
+
dragged = false;
|
|
321
|
+
e.preventDefault();
|
|
322
|
+
e.stopPropagation();
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
let wheelDirection = 0;
|
|
326
|
+
let wheelStart = 0;
|
|
327
|
+
let wheelDelta = 0;
|
|
328
|
+
let wheelTarget = 0;
|
|
329
|
+
let wheelFrame = 0;
|
|
330
|
+
let wheelPosition = 0;
|
|
331
|
+
let wheelVelocity = 0;
|
|
332
|
+
let wheelTime = 0;
|
|
333
|
+
let wheelSnap = null;
|
|
334
|
+
let wheelSnapPriority = "";
|
|
335
|
+
const stopWheel = (resetGesture = true) => {
|
|
336
|
+
if (wheelFrame)
|
|
337
|
+
window.cancelAnimationFrame(wheelFrame);
|
|
338
|
+
wheelFrame = 0;
|
|
339
|
+
wheelVelocity = 0;
|
|
340
|
+
if (resetGesture)
|
|
341
|
+
lastWheel = -Infinity;
|
|
342
|
+
if (wheelSnap !== null) {
|
|
343
|
+
scroller.style.setProperty("scroll-snap-type", wheelSnap, wheelSnapPriority);
|
|
344
|
+
wheelSnap = null;
|
|
345
|
+
clearPending();
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
const glide = (now) => {
|
|
349
|
+
const dt = (now - wheelTime) / 1000;
|
|
350
|
+
wheelTime = now;
|
|
351
|
+
const offset = wheelPosition - wheelTarget;
|
|
352
|
+
const decay = Math.exp(-12 * dt);
|
|
353
|
+
const carry = wheelVelocity + 12 * offset;
|
|
354
|
+
wheelPosition = wheelTarget + (offset + carry * dt) * decay;
|
|
355
|
+
wheelVelocity = (wheelVelocity - 12 * carry * dt) * decay;
|
|
356
|
+
const resting = wheelDirection * (wheelPosition - wheelTarget) >= 0 ||
|
|
357
|
+
(Math.abs(wheelPosition - wheelTarget) < 0.5 && Math.abs(wheelVelocity) < 5);
|
|
358
|
+
scroller.scrollLeft = (resting ? wheelTarget : wheelPosition) * sign;
|
|
359
|
+
if (resting)
|
|
360
|
+
stopWheel(false);
|
|
361
|
+
else
|
|
362
|
+
wheelFrame = window.requestAnimationFrame(glide);
|
|
363
|
+
};
|
|
364
|
+
const handleTouchStart = () => {
|
|
365
|
+
stopWheel();
|
|
366
|
+
clearPending();
|
|
367
|
+
};
|
|
368
|
+
const handleWheel = (e) => {
|
|
369
|
+
if (e.ctrlKey || dragging || Math.abs(e.deltaX) >= Math.abs(e.deltaY) || !strategy)
|
|
370
|
+
return;
|
|
371
|
+
const position = scrollPosition();
|
|
372
|
+
const end = snapPositions[count - 1] ?? 0;
|
|
373
|
+
const direction = Math.sign(e.deltaY);
|
|
374
|
+
if (direction < 0 ? position <= 1 : position >= end - 1)
|
|
375
|
+
return;
|
|
376
|
+
e.preventDefault();
|
|
377
|
+
if (direction !== wheelDirection)
|
|
378
|
+
stopWheel();
|
|
379
|
+
const fresh = e.timeStamp - lastWheel >= WHEEL_QUIET || direction !== wheelDirection;
|
|
380
|
+
if (fresh) {
|
|
381
|
+
wheelStart = position;
|
|
382
|
+
wheelDelta = 0;
|
|
383
|
+
wheelTarget = position;
|
|
384
|
+
}
|
|
385
|
+
lastWheel = e.timeStamp;
|
|
386
|
+
wheelDirection = direction;
|
|
387
|
+
const unit = e.deltaMode === 1
|
|
388
|
+
? parseFloat(window.getComputedStyle(scroller).lineHeight) || 16
|
|
389
|
+
: e.deltaMode === 2 ? containerSize : 1;
|
|
390
|
+
wheelDelta += e.deltaY * unit;
|
|
391
|
+
const destination = Math.max(0, Math.min(end, wheelStart + wheelDelta));
|
|
392
|
+
let index = direction > 0 ? count - 1 : 0;
|
|
393
|
+
const reach = fresh ? WHEEL_SNAP_REACH : 0;
|
|
394
|
+
for (let i = direction > 0 ? 0 : count - 1; i >= 0 && i < count; i += direction) {
|
|
395
|
+
if (direction * (snapPositions[i] - destination) >= -reach &&
|
|
396
|
+
direction * (snapPositions[i] - wheelStart) > 0) {
|
|
397
|
+
index = i;
|
|
398
|
+
break;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
const target = snapPositions[index];
|
|
402
|
+
if (direction * (target - wheelTarget) > 0) {
|
|
403
|
+
wheelTarget = target;
|
|
404
|
+
expect(index);
|
|
405
|
+
if (reduceMotion?.matches) {
|
|
406
|
+
setScrollPosition(target, false);
|
|
407
|
+
}
|
|
408
|
+
else if (!wheelFrame) {
|
|
409
|
+
wheelSnap = scroller.style.getPropertyValue("scroll-snap-type");
|
|
410
|
+
wheelSnapPriority = scroller.style.getPropertyPriority("scroll-snap-type");
|
|
411
|
+
scroller.style.setProperty("scroll-snap-type", "none");
|
|
412
|
+
scroller.scrollLeft = position * sign;
|
|
413
|
+
wheelPosition = position;
|
|
414
|
+
wheelTime = performance.now();
|
|
415
|
+
wheelFrame = window.requestAnimationFrame(glide);
|
|
416
|
+
}
|
|
417
|
+
if (index !== currentIndex) {
|
|
418
|
+
currentIndex = index;
|
|
419
|
+
emitChange();
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
expect(currentIndex);
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
const setWheel = (on) => {
|
|
427
|
+
scroller.removeEventListener("wheel", handleWheel);
|
|
428
|
+
stopWheel();
|
|
429
|
+
if (on && !vertical)
|
|
430
|
+
scroller.addEventListener("wheel", handleWheel, { passive: false });
|
|
431
|
+
};
|
|
432
|
+
scroller.addEventListener("scroll", layout, { passive: true });
|
|
433
|
+
scroller.addEventListener("wheel", clearPending, { passive: true });
|
|
434
|
+
setWheel(!!config.wheel);
|
|
435
|
+
scroller.addEventListener("touchstart", handleTouchStart, { passive: true });
|
|
436
|
+
scroller.addEventListener("keydown", handleKeyDown);
|
|
437
|
+
scroller.addEventListener("focusin", handleFocusIn);
|
|
438
|
+
scroller.addEventListener("pointerdown", handlePointerDown);
|
|
439
|
+
scroller.addEventListener("pointermove", handlePointerMove);
|
|
440
|
+
scroller.addEventListener("pointerup", handlePointerUp);
|
|
441
|
+
scroller.addEventListener("pointercancel", handlePointerUp);
|
|
442
|
+
scroller.addEventListener("click", handleClick, true);
|
|
443
|
+
reduceMotion?.addEventListener?.("change", rebuild);
|
|
444
|
+
const resizeObserver = typeof ResizeObserver === "function" ? new ResizeObserver(rebuild) : null;
|
|
445
|
+
resizeObserver?.observe(scroller);
|
|
446
|
+
const directionObserver = typeof MutationObserver === "function" ? new MutationObserver(rebuild) : null;
|
|
447
|
+
directionObserver?.observe(document.documentElement, { attributeFilter: ["dir"], subtree: true });
|
|
448
|
+
component.onSlidesChanged(rebuild);
|
|
449
|
+
rebuild();
|
|
450
|
+
const destroy = component.lifecycle?.destroy;
|
|
451
|
+
const enhanced = component;
|
|
452
|
+
enhanced.getCurrentSlide = () => currentIndex;
|
|
453
|
+
enhanced.getVariant = () => variant;
|
|
454
|
+
enhanced.next = next;
|
|
455
|
+
enhanced.prev = prev;
|
|
456
|
+
enhanced.goTo = goTo;
|
|
457
|
+
enhanced.setWheel = setWheel;
|
|
458
|
+
enhanced.lifecycle = {
|
|
459
|
+
destroy: () => {
|
|
460
|
+
setWheel(false);
|
|
461
|
+
restoreSnap();
|
|
462
|
+
resizeObserver?.disconnect();
|
|
463
|
+
directionObserver?.disconnect();
|
|
464
|
+
reduceMotion?.removeEventListener?.("change", rebuild);
|
|
465
|
+
clearPending();
|
|
466
|
+
scroller.removeEventListener("scroll", layout);
|
|
467
|
+
scroller.removeEventListener("wheel", clearPending);
|
|
468
|
+
scroller.removeEventListener("touchstart", handleTouchStart);
|
|
469
|
+
scroller.removeEventListener("keydown", handleKeyDown);
|
|
470
|
+
scroller.removeEventListener("focusin", handleFocusIn);
|
|
471
|
+
scroller.removeEventListener("pointerdown", handlePointerDown);
|
|
472
|
+
scroller.removeEventListener("pointermove", handlePointerMove);
|
|
473
|
+
scroller.removeEventListener("pointerup", handlePointerUp);
|
|
474
|
+
scroller.removeEventListener("pointercancel", handlePointerUp);
|
|
475
|
+
scroller.removeEventListener("click", handleClick, true);
|
|
476
|
+
destroy?.();
|
|
477
|
+
},
|
|
478
|
+
};
|
|
479
|
+
return enhanced;
|
|
480
480
|
};
|