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
|
@@ -7,232 +7,232 @@ const length = (a) => distance(a[0], a[1]);
|
|
|
7
7
|
const unit = (a) => direction(a[0], a[1]);
|
|
8
8
|
const mix = (a, b, t) => [lerp(a[0], b[0], t), lerp(a[1], b[1], t)];
|
|
9
9
|
const lineIntersection = (p0, d0, p1, d1) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
const rotatedD1 = rotate90(d1);
|
|
11
|
+
const den = dot(d0, rotatedD1);
|
|
12
|
+
if (Math.abs(den) < DISTANCE_EPSILON)
|
|
13
|
+
return null;
|
|
14
|
+
const num = dot(sub(p1, p0), rotatedD1);
|
|
15
|
+
if (Math.abs(den) < DISTANCE_EPSILON * Math.abs(num))
|
|
16
|
+
return null;
|
|
17
|
+
return add(p0, mul(d0, num / den));
|
|
18
18
|
};
|
|
19
19
|
const roundedCorner = (p0, p1, p2, rounding) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
20
|
+
const v01 = sub(p0, p1);
|
|
21
|
+
const v21 = sub(p2, p1);
|
|
22
|
+
const d01 = length(v01);
|
|
23
|
+
const d21 = length(v21);
|
|
24
|
+
if (d01 > 0 && d21 > 0) {
|
|
25
|
+
const d1 = mul(v01, 1 / d01);
|
|
26
|
+
const d2 = mul(v21, 1 / d21);
|
|
27
|
+
const cornerRadius = rounding.radius;
|
|
28
|
+
const smoothing = rounding.smoothing ?? 0;
|
|
29
|
+
const cosAngle = dot(d1, d2);
|
|
30
|
+
const sinAngle = Math.sqrt(1 - cosAngle * cosAngle);
|
|
31
|
+
const expectedRoundCut = sinAngle > 1e-3 ? (cornerRadius * (cosAngle + 1)) / sinAngle : 0;
|
|
32
|
+
return {
|
|
33
|
+
p0, p1, p2, d1, d2, cornerRadius, smoothing, expectedRoundCut,
|
|
34
|
+
expectedCut: (1 + smoothing) * expectedRoundCut,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return { p0, p1, p2, d1: [0, 0], d2: [0, 0], cornerRadius: 0, smoothing: 0, expectedRoundCut: 0, expectedCut: 0 };
|
|
38
38
|
};
|
|
39
39
|
const actualSmoothing = (corner, allowedCut) => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
if (allowedCut > corner.expectedCut)
|
|
41
|
+
return corner.smoothing;
|
|
42
|
+
if (allowedCut > corner.expectedRoundCut) {
|
|
43
|
+
return (corner.smoothing * (allowedCut - corner.expectedRoundCut)) / (corner.expectedCut - corner.expectedRoundCut);
|
|
44
|
+
}
|
|
45
|
+
return 0;
|
|
46
46
|
};
|
|
47
47
|
const flankingCurve = (actualRoundCut, smoothing, corner, sideStart, circleSegmentIntersection, otherCircleSegmentIntersection, circleCenter, actualR) => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
48
|
+
const sideDirection = unit(sub(sideStart, corner));
|
|
49
|
+
const curveStart = add(corner, mul(sideDirection, actualRoundCut * (1 + smoothing)));
|
|
50
|
+
const p = mix(circleSegmentIntersection, mul(add(circleSegmentIntersection, otherCircleSegmentIntersection), 0.5), smoothing);
|
|
51
|
+
const curveEnd = add(circleCenter, mul(direction(p[0] - circleCenter[0], p[1] - circleCenter[1]), actualR));
|
|
52
|
+
const circleTangent = rotate90(sub(curveEnd, circleCenter));
|
|
53
|
+
const anchorEnd = lineIntersection(sideStart, sideDirection, curveEnd, circleTangent) ?? circleSegmentIntersection;
|
|
54
|
+
const anchorStart = mul(add(curveStart, mul(anchorEnd, 2)), 1 / 3);
|
|
55
|
+
return [curveStart[0], curveStart[1], anchorStart[0], anchorStart[1], anchorEnd[0], anchorEnd[1], curveEnd[0], curveEnd[1]];
|
|
56
56
|
};
|
|
57
57
|
const cornerCubics = (corner, allowedCut0, allowedCut1) => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
58
|
+
const allowedCut = Math.min(allowedCut0, allowedCut1);
|
|
59
|
+
const { p0, p1, p2, d1, d2, cornerRadius, expectedRoundCut } = corner;
|
|
60
|
+
if (expectedRoundCut < DISTANCE_EPSILON || allowedCut < DISTANCE_EPSILON || cornerRadius < DISTANCE_EPSILON) {
|
|
61
|
+
return [straightLine(p1[0], p1[1], p1[0], p1[1])];
|
|
62
|
+
}
|
|
63
|
+
const actualRoundCut = Math.min(allowedCut, expectedRoundCut);
|
|
64
|
+
const smoothing0 = actualSmoothing(corner, allowedCut0);
|
|
65
|
+
const smoothing1 = actualSmoothing(corner, allowedCut1);
|
|
66
|
+
const actualR = (cornerRadius * actualRoundCut) / expectedRoundCut;
|
|
67
|
+
const centerDistance = Math.sqrt(actualR * actualR + actualRoundCut * actualRoundCut);
|
|
68
|
+
const center = add(p1, mul(unit(mul(add(d1, d2), 0.5)), centerDistance));
|
|
69
|
+
const circleIntersection0 = add(p1, mul(d1, actualRoundCut));
|
|
70
|
+
const circleIntersection2 = add(p1, mul(d2, actualRoundCut));
|
|
71
|
+
const flanking0 = flankingCurve(actualRoundCut, smoothing0, p1, p0, circleIntersection0, circleIntersection2, center, actualR);
|
|
72
|
+
const flanking2 = reverseCubic(flankingCurve(actualRoundCut, smoothing1, p1, p2, circleIntersection2, circleIntersection0, center, actualR));
|
|
73
|
+
return [
|
|
74
|
+
flanking0,
|
|
75
|
+
circularArc(center[0], center[1], flanking0[6], flanking0[7], flanking2[0], flanking2[1]),
|
|
76
|
+
flanking2,
|
|
77
|
+
];
|
|
78
78
|
};
|
|
79
79
|
export const roundedPolygon = (vertices, rounding = UNROUNDED, perVertexRounding, centerX, centerY) => {
|
|
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
|
-
|
|
80
|
+
if (vertices.length < 6)
|
|
81
|
+
throw new Error('Polygons must have at least 3 vertices');
|
|
82
|
+
if (vertices.length % 2 === 1)
|
|
83
|
+
throw new Error('The vertices array should have even size');
|
|
84
|
+
const n = vertices.length / 2;
|
|
85
|
+
if (perVertexRounding && perVertexRounding.length !== n) {
|
|
86
|
+
throw new Error('perVertexRounding should have one entry per vertex');
|
|
87
|
+
}
|
|
88
|
+
const vertex = (i) => [vertices[(i % n) * 2], vertices[(i % n) * 2 + 1]];
|
|
89
|
+
const corners = [];
|
|
90
|
+
for (let i = 0; i < n; i++) {
|
|
91
|
+
corners.push(roundedCorner(vertex(i + n - 1), vertex(i), vertex(i + 1), perVertexRounding?.[i] ?? rounding));
|
|
92
|
+
}
|
|
93
|
+
const cutAdjusts = [];
|
|
94
|
+
for (let i = 0; i < n; i++) {
|
|
95
|
+
const next = corners[(i + 1) % n];
|
|
96
|
+
const expectedRoundCut = corners[i].expectedRoundCut + next.expectedRoundCut;
|
|
97
|
+
const expectedCut = corners[i].expectedCut + next.expectedCut;
|
|
98
|
+
const a = vertex(i);
|
|
99
|
+
const b = vertex(i + 1);
|
|
100
|
+
const sideSize = distance(a[0] - b[0], a[1] - b[1]);
|
|
101
|
+
if (expectedRoundCut > sideSize) {
|
|
102
|
+
cutAdjusts.push([sideSize / expectedRoundCut, 0]);
|
|
103
|
+
}
|
|
104
|
+
else if (expectedCut > sideSize) {
|
|
105
|
+
cutAdjusts.push([1, (sideSize - expectedRoundCut) / (expectedCut - expectedRoundCut)]);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
cutAdjusts.push([1, 1]);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const cornerRuns = [];
|
|
112
|
+
for (let i = 0; i < n; i++) {
|
|
113
|
+
const corner = corners[i];
|
|
114
|
+
const allowed = [];
|
|
115
|
+
for (let delta = 0; delta <= 1; delta++) {
|
|
116
|
+
const [roundCutRatio, cutRatio] = cutAdjusts[(i + n - 1 + delta) % n];
|
|
117
|
+
allowed.push(corner.expectedRoundCut * roundCutRatio + (corner.expectedCut - corner.expectedRoundCut) * cutRatio);
|
|
118
|
+
}
|
|
119
|
+
cornerRuns.push(cornerCubics(corner, allowed[0], allowed[1]));
|
|
120
|
+
}
|
|
121
|
+
const features = [];
|
|
122
|
+
for (let i = 0; i < n; i++) {
|
|
123
|
+
const run = cornerRuns[i];
|
|
124
|
+
const last = run[run.length - 1];
|
|
125
|
+
const first = cornerRuns[(i + 1) % n][0];
|
|
126
|
+
features.push(run, [straightLine(last[6], last[7], first[0], first[1])]);
|
|
127
|
+
}
|
|
128
|
+
const first = features[0];
|
|
129
|
+
const split = first.length === 3 ? splitCubic(first[1], 0.5) : null;
|
|
130
|
+
const all = split ? [split[1], first[2], ...features.slice(1).flat(), first[0], split[0]] : features.flat();
|
|
131
|
+
const cubics = [];
|
|
132
|
+
for (const c of all) {
|
|
133
|
+
const last = cubics.length - 1;
|
|
134
|
+
if (!zeroLength(c))
|
|
135
|
+
cubics.push(c);
|
|
136
|
+
else if (last >= 0)
|
|
137
|
+
cubics[last] = [...cubics[last].slice(0, 6), c[6], c[7]];
|
|
138
|
+
}
|
|
139
|
+
let cx = centerX;
|
|
140
|
+
let cy = centerY;
|
|
141
|
+
if (cx === undefined || cy === undefined) {
|
|
142
|
+
let sx = 0;
|
|
143
|
+
let sy = 0;
|
|
144
|
+
for (let i = 0; i < n; i++) {
|
|
145
|
+
sx += vertices[i * 2];
|
|
146
|
+
sy += vertices[i * 2 + 1];
|
|
147
|
+
}
|
|
148
|
+
cx = sx / n;
|
|
149
|
+
cy = sy / n;
|
|
150
|
+
}
|
|
151
|
+
const last = cubics.length - 1;
|
|
152
|
+
if (last >= 0)
|
|
153
|
+
cubics[last] = [...cubics[last].slice(0, 6), cubics[0][0], cubics[0][1]];
|
|
154
|
+
else
|
|
155
|
+
cubics.push([cx, cy, cx, cy, cx, cy, cx, cy]);
|
|
156
|
+
return { cubics, centerX: cx, centerY: cy };
|
|
157
157
|
};
|
|
158
158
|
const radial = (radius, angle, cx, cy) => [cx + Math.cos(angle) * radius, cy + Math.sin(angle) * radius];
|
|
159
159
|
export const regularPolygon = (numVertices, radius = 1, centerX = 0, centerY = 0, rounding = UNROUNDED, perVertexRounding) => {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
160
|
+
const vertices = [];
|
|
161
|
+
for (let i = 0; i < numVertices; i++) {
|
|
162
|
+
vertices.push(...radial(radius, (Math.PI / numVertices) * 2 * i, centerX, centerY));
|
|
163
|
+
}
|
|
164
|
+
return roundedPolygon(vertices, rounding, perVertexRounding, centerX, centerY);
|
|
165
165
|
};
|
|
166
166
|
export const circle = (numVertices = 8, radius = 1, centerX = 0, centerY = 0) => {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
167
|
+
if (numVertices < 3)
|
|
168
|
+
throw new Error('Circle must have at least three vertices');
|
|
169
|
+
const theta = Math.PI / numVertices;
|
|
170
|
+
return regularPolygon(numVertices, radius / Math.cos(theta), centerX, centerY, { radius });
|
|
171
171
|
};
|
|
172
172
|
export const star = (numVerticesPerRadius, radius = 1, innerRadius = 0.5, rounding = UNROUNDED, innerRounding, perVertexRounding, centerX = 0, centerY = 0) => {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
173
|
+
if (radius <= 0 || innerRadius <= 0)
|
|
174
|
+
throw new Error('Star radii must both be greater than 0');
|
|
175
|
+
if (innerRadius >= radius)
|
|
176
|
+
throw new Error('innerRadius must be less than radius');
|
|
177
|
+
let pvRounding = perVertexRounding;
|
|
178
|
+
if (!pvRounding && innerRounding) {
|
|
179
|
+
pvRounding = [];
|
|
180
|
+
for (let i = 0; i < numVerticesPerRadius; i++)
|
|
181
|
+
pvRounding.push(rounding, innerRounding);
|
|
182
|
+
}
|
|
183
|
+
const vertices = [];
|
|
184
|
+
for (let i = 0; i < numVerticesPerRadius; i++) {
|
|
185
|
+
vertices.push(...radial(radius, (Math.PI / numVerticesPerRadius) * 2 * i, centerX, centerY));
|
|
186
|
+
vertices.push(...radial(innerRadius, (Math.PI / numVerticesPerRadius) * (2 * i + 1), centerX, centerY));
|
|
187
|
+
}
|
|
188
|
+
return roundedPolygon(vertices, rounding, pvRounding, centerX, centerY);
|
|
189
189
|
};
|
|
190
190
|
export const rectangle = (width = 2, height = 2, rounding = UNROUNDED, perVertexRounding, centerX = 0, centerY = 0) => {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
191
|
+
const left = centerX - width / 2;
|
|
192
|
+
const top = centerY - height / 2;
|
|
193
|
+
const right = centerX + width / 2;
|
|
194
|
+
const bottom = centerY + height / 2;
|
|
195
|
+
return roundedPolygon([right, bottom, left, bottom, left, top, right, top], rounding, perVertexRounding, centerX, centerY);
|
|
196
196
|
};
|
|
197
197
|
export const transformPolygon = (polygon, f) => {
|
|
198
|
-
|
|
199
|
-
|
|
198
|
+
const center = f(polygon.centerX, polygon.centerY);
|
|
199
|
+
return { cubics: polygon.cubics.map((c) => transformCubic(c, f)), centerX: center[0], centerY: center[1] };
|
|
200
200
|
};
|
|
201
201
|
export const rotatePolygon = (polygon, degrees) => {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
202
|
+
const a = (degrees * Math.PI) / 180;
|
|
203
|
+
const cos = Math.cos(a);
|
|
204
|
+
const sin = Math.sin(a);
|
|
205
|
+
return transformPolygon(polygon, (x, y) => [x * cos - y * sin, x * sin + y * cos]);
|
|
206
206
|
};
|
|
207
207
|
export const scalePolygon = (polygon, sx, sy = sx) => transformPolygon(polygon, (x, y) => [x * sx, y * sy]);
|
|
208
208
|
export const polygonBounds = (polygon) => {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
209
|
+
let minX = Infinity;
|
|
210
|
+
let minY = Infinity;
|
|
211
|
+
let maxX = -Infinity;
|
|
212
|
+
let maxY = -Infinity;
|
|
213
|
+
for (const c of polygon.cubics) {
|
|
214
|
+
const b = cubicBounds(c);
|
|
215
|
+
minX = Math.min(minX, b[0]);
|
|
216
|
+
minY = Math.min(minY, b[1]);
|
|
217
|
+
maxX = Math.max(maxX, b[2]);
|
|
218
|
+
maxY = Math.max(maxY, b[3]);
|
|
219
|
+
}
|
|
220
|
+
return [minX, minY, maxX, maxY];
|
|
221
221
|
};
|
|
222
222
|
export const polygonMaxRadius = (polygon) => {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
223
|
+
let max = 0;
|
|
224
|
+
for (const c of polygon.cubics) {
|
|
225
|
+
const mid = pointOnCurve(c, 0.5);
|
|
226
|
+
max = Math.max(max, distance(c[0] - polygon.centerX, c[1] - polygon.centerY), distance(mid[0] - polygon.centerX, mid[1] - polygon.centerY));
|
|
227
|
+
}
|
|
228
|
+
return max;
|
|
229
229
|
};
|
|
230
230
|
export const normalizePolygon = (polygon) => {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
231
|
+
const bounds = polygonBounds(polygon);
|
|
232
|
+
const width = bounds[2] - bounds[0];
|
|
233
|
+
const height = bounds[3] - bounds[1];
|
|
234
|
+
const side = Math.max(width, height);
|
|
235
|
+
const offsetX = (side - width) / 2 - bounds[0];
|
|
236
|
+
const offsetY = (side - height) / 2 - bounds[1];
|
|
237
|
+
return transformPolygon(polygon, (x, y) => [(x + offsetX) / side, (y + offsetY) / side]);
|
|
238
238
|
};
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
export const createEmitter = () => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
2
|
+
const events = new Map();
|
|
3
|
+
return {
|
|
4
|
+
on: (event, callback) => {
|
|
5
|
+
const callbacks = events.get(event) || [];
|
|
6
|
+
events.set(event, [...callbacks, callback]);
|
|
7
|
+
return () => {
|
|
8
|
+
const callbacks = events.get(event) || [];
|
|
9
|
+
events.set(event, callbacks.filter(cb => cb !== callback));
|
|
10
|
+
};
|
|
11
|
+
},
|
|
12
|
+
off(event, callback) {
|
|
13
|
+
const callbacks = events.get(event) || [];
|
|
14
|
+
events.set(event, callbacks.filter(cb => cb !== callback));
|
|
15
|
+
},
|
|
16
|
+
emit: (event, ...args) => {
|
|
17
|
+
const callbacks = events.get(event) || [];
|
|
18
|
+
callbacks.forEach(cb => {
|
|
19
|
+
try {
|
|
20
|
+
cb(...args);
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
console.error(`A listener for "${event}" threw:`, error);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
clear: () => {
|
|
28
|
+
events.clear();
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
31
|
};
|
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
export const createEventManager = (element) => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
2
|
+
const handlers = new Map();
|
|
3
|
+
return {
|
|
4
|
+
on(event, handler) {
|
|
5
|
+
element.addEventListener(event, handler);
|
|
6
|
+
let callbacks = handlers.get(event);
|
|
7
|
+
if (!callbacks)
|
|
8
|
+
handlers.set(event, callbacks = new Set());
|
|
9
|
+
callbacks.add(handler);
|
|
10
|
+
return this;
|
|
11
|
+
},
|
|
12
|
+
off(event, handler) {
|
|
13
|
+
element.removeEventListener(event, handler);
|
|
14
|
+
const callbacks = handlers.get(event);
|
|
15
|
+
callbacks?.delete(handler);
|
|
16
|
+
if (!callbacks?.size)
|
|
17
|
+
handlers.delete(event);
|
|
18
|
+
return this;
|
|
19
|
+
},
|
|
20
|
+
destroy() {
|
|
21
|
+
handlers.forEach((callbacks, event) => {
|
|
22
|
+
callbacks.forEach(handler => element.removeEventListener(event, handler));
|
|
23
|
+
});
|
|
24
|
+
handlers.clear();
|
|
25
|
+
},
|
|
26
|
+
getHandlers() {
|
|
27
|
+
const snapshot = new Map();
|
|
28
|
+
handlers.forEach((callbacks, event) => callbacks.forEach(handler => snapshot.set(handler, event)));
|
|
29
|
+
return snapshot;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
32
|
};
|