mtrl 0.8.0-next.8 → 0.8.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 +112 -283
- package/dist/README.md +112 -283
- package/dist/components/badge/api.d.ts +1 -1
- package/dist/components/badge/api.js +162 -0
- package/dist/components/badge/badge.d.ts +1 -1
- package/dist/components/badge/badge.js +18 -0
- package/dist/components/badge/config.d.ts +1 -1
- package/dist/components/badge/config.js +63 -0
- package/dist/components/badge/constants.js +20 -0
- package/dist/components/badge/features.d.ts +1 -1
- package/dist/components/badge/features.js +95 -0
- package/dist/components/badge/index.d.ts +2 -2
- package/dist/components/badge/index.js +1 -0
- package/dist/components/badge/types.js +1 -0
- package/dist/components/bottom-app-bar/bottom-app-bar.d.ts +1 -1
- package/dist/components/bottom-app-bar/bottom-app-bar.js +91 -0
- package/dist/components/bottom-app-bar/config.d.ts +1 -1
- package/dist/components/bottom-app-bar/config.js +10 -0
- package/dist/components/bottom-app-bar/constants.js +13 -0
- package/dist/components/bottom-app-bar/index.d.ts +2 -2
- package/dist/components/bottom-app-bar/index.js +3 -0
- package/dist/components/bottom-app-bar/types.d.ts +1 -1
- package/dist/components/bottom-app-bar/types.js +1 -0
- package/dist/components/bottom-sheet/api.d.ts +43 -0
- package/dist/components/bottom-sheet/api.js +56 -0
- package/dist/components/bottom-sheet/bottom-sheet.d.ts +24 -0
- package/dist/components/bottom-sheet/bottom-sheet.js +18 -0
- package/dist/components/bottom-sheet/config.d.ts +34 -0
- package/dist/components/bottom-sheet/config.js +19 -0
- package/dist/components/bottom-sheet/constants.d.ts +65 -0
- package/dist/components/bottom-sheet/constants.js +35 -0
- package/dist/components/bottom-sheet/features/drag.d.ts +32 -0
- package/dist/components/bottom-sheet/features/drag.js +71 -0
- package/dist/components/bottom-sheet/features/index.d.ts +3 -0
- package/dist/components/bottom-sheet/features/index.js +3 -0
- package/dist/components/bottom-sheet/features/state.d.ts +31 -0
- package/dist/components/bottom-sheet/features/state.js +82 -0
- package/dist/components/bottom-sheet/features/structure.d.ts +26 -0
- package/dist/components/bottom-sheet/features/structure.js +88 -0
- package/dist/components/bottom-sheet/index.d.ts +2 -0
- package/dist/components/bottom-sheet/index.js +1 -0
- package/dist/components/bottom-sheet/types.d.ts +116 -0
- package/dist/components/bottom-sheet/types.js +1 -0
- package/dist/components/button/api.d.ts +2 -2
- package/dist/components/button/api.js +265 -0
- package/dist/components/button/button.d.ts +1 -1
- package/dist/components/button/button.js +25 -0
- package/dist/components/button/config.d.ts +1 -1
- package/dist/components/button/config.js +51 -0
- package/dist/components/button/constants.js +35 -0
- package/dist/components/button/features/progress.d.ts +2 -2
- package/dist/components/button/features/progress.js +163 -0
- package/dist/components/button/features/toggle.d.ts +1 -1
- package/dist/components/button/features/toggle.js +33 -0
- package/dist/components/button/index.d.ts +3 -3
- package/dist/components/button/index.js +1 -0
- package/dist/components/button/types.d.ts +3 -3
- package/dist/components/button/types.js +1 -0
- package/dist/components/button-group/button-group.d.ts +1 -1
- package/dist/components/button-group/button-group.js +358 -0
- package/dist/components/button-group/config.d.ts +10 -10
- package/dist/components/button-group/config.js +123 -0
- package/dist/components/button-group/constants.d.ts +8 -0
- package/dist/components/button-group/constants.js +94 -0
- package/dist/components/button-group/index.d.ts +4 -4
- package/dist/components/button-group/index.js +3 -0
- package/dist/components/button-group/types.d.ts +1 -1
- package/dist/components/button-group/types.js +1 -0
- package/dist/components/card/api.d.ts +1 -1
- package/dist/components/card/api.js +74 -0
- package/dist/components/card/card.d.ts +1 -1
- package/dist/components/card/card.js +20 -0
- package/dist/components/card/config.d.ts +1 -1
- package/dist/components/card/config.js +161 -0
- package/dist/components/card/constants.js +55 -0
- package/dist/components/card/content.d.ts +1 -1
- package/dist/components/card/content.js +195 -0
- package/dist/components/card/features.d.ts +1 -1
- package/dist/components/card/features.js +225 -0
- package/dist/components/card/index.d.ts +5 -5
- package/dist/components/card/index.js +4 -0
- package/dist/components/card/types.js +1 -0
- package/dist/components/carousel/api.d.ts +1 -1
- package/dist/components/carousel/api.js +46 -0
- package/dist/components/carousel/arrangement.js +61 -0
- package/dist/components/carousel/carousel.d.ts +1 -1
- package/dist/components/carousel/carousel.js +11 -0
- package/dist/components/carousel/config.d.ts +1 -1
- package/dist/components/carousel/config.js +40 -0
- package/dist/components/carousel/constants.js +23 -0
- package/dist/components/carousel/features/index.d.ts +2 -2
- package/dist/components/carousel/features/index.js +2 -0
- package/dist/components/carousel/features/scroll.d.ts +2 -2
- package/dist/components/carousel/features/scroll.js +345 -0
- package/dist/components/carousel/features/slides.d.ts +1 -1
- package/dist/components/carousel/features/slides.js +127 -0
- package/dist/components/carousel/index.d.ts +3 -3
- package/dist/components/carousel/index.js +2 -0
- package/dist/components/carousel/keylines.js +292 -0
- package/dist/components/carousel/strategy.d.ts +1 -1
- package/dist/components/carousel/strategy.js +207 -0
- package/dist/components/carousel/types.js +1 -0
- package/dist/components/checkbox/api.d.ts +1 -1
- package/dist/components/checkbox/api.js +82 -0
- package/dist/components/checkbox/checkbox.d.ts +1 -1
- package/dist/components/checkbox/checkbox.js +29 -0
- package/dist/components/checkbox/config.d.ts +1 -1
- package/dist/components/checkbox/config.js +44 -0
- package/dist/components/checkbox/constants.js +20 -0
- package/dist/components/checkbox/index.d.ts +3 -3
- package/dist/components/checkbox/index.js +2 -0
- package/dist/components/checkbox/types.js +1 -0
- package/dist/components/chips/api.d.ts +1 -1
- package/dist/components/chips/api.js +153 -0
- package/dist/components/chips/chip/api.d.ts +1 -1
- package/dist/components/chips/chip/api.js +186 -0
- package/dist/components/chips/chip/chip.d.ts +1 -1
- package/dist/components/chips/chip/chip.js +78 -0
- package/dist/components/chips/chip/config.d.ts +1 -1
- package/dist/components/chips/chip/config.js +53 -0
- package/dist/components/chips/chip/constants.js +18 -0
- package/dist/components/chips/chip/index.d.ts +2 -2
- package/dist/components/chips/chip/index.js +2 -0
- package/dist/components/chips/chip/types.d.ts +1 -1
- package/dist/components/chips/chip/types.js +1 -0
- package/dist/components/chips/chips.d.ts +1 -1
- package/dist/components/chips/chips.js +32 -0
- package/dist/components/chips/config.d.ts +1 -1
- package/dist/components/chips/config.js +82 -0
- package/dist/components/chips/constants.js +20 -0
- package/dist/components/chips/features/chip-items.d.ts +1 -1
- package/dist/components/chips/features/chip-items.js +17 -0
- package/dist/components/chips/features/container.d.ts +1 -1
- package/dist/components/chips/features/container.js +41 -0
- package/dist/components/chips/features/controller.d.ts +1 -1
- package/dist/components/chips/features/controller.js +309 -0
- package/dist/components/chips/features/dom.d.ts +2 -2
- package/dist/components/chips/features/dom.js +27 -0
- package/dist/components/chips/features/index.d.ts +5 -5
- package/dist/components/chips/features/index.js +5 -0
- package/dist/components/chips/features/label.d.ts +1 -1
- package/dist/components/chips/features/label.js +63 -0
- package/dist/components/chips/index.d.ts +3 -3
- package/dist/components/chips/index.js +2 -0
- package/dist/components/chips/schema.d.ts +1 -1
- package/dist/components/chips/schema.js +46 -0
- package/dist/components/chips/types.js +11 -0
- package/dist/components/datepicker/api.d.ts +1 -1
- package/dist/components/datepicker/api.js +180 -0
- package/dist/components/datepicker/config.d.ts +1 -1
- package/dist/components/datepicker/config.js +89 -0
- package/dist/components/datepicker/constants.js +50 -0
- package/dist/components/datepicker/datepicker.d.ts +1 -1
- package/dist/components/datepicker/datepicker.js +238 -0
- package/dist/components/datepicker/index.d.ts +3 -3
- package/dist/components/datepicker/index.js +2 -0
- package/dist/components/datepicker/render.js +290 -0
- package/dist/components/datepicker/types.js +18 -0
- package/dist/components/datepicker/utils.d.ts +1 -1
- package/dist/components/datepicker/utils.js +156 -0
- package/dist/components/dialog/api.d.ts +1 -1
- package/dist/components/dialog/api.js +106 -0
- package/dist/components/dialog/config.d.ts +2 -6
- package/dist/components/dialog/config.js +84 -0
- package/dist/components/dialog/constants.js +51 -0
- package/dist/components/dialog/dialog.d.ts +1 -1
- package/dist/components/dialog/dialog.js +25 -0
- package/dist/components/dialog/features.d.ts +1 -6
- package/dist/components/dialog/features.js +619 -0
- package/dist/components/dialog/index.d.ts +2 -2
- package/dist/components/dialog/index.js +1 -0
- package/dist/components/dialog/types.d.ts +14 -3
- package/dist/components/dialog/types.js +1 -0
- package/dist/components/divider/config.js +9 -0
- package/dist/components/divider/constants.js +18 -0
- package/dist/components/divider/divider.d.ts +3 -3
- package/dist/components/divider/divider.js +11 -0
- package/dist/components/divider/features.d.ts +3 -3
- package/dist/components/divider/features.js +141 -0
- package/dist/components/divider/index.d.ts +3 -3
- package/dist/components/divider/index.js +2 -0
- package/dist/components/divider/types.d.ts +1 -1
- package/dist/components/divider/types.js +1 -0
- package/dist/components/drawer/api.d.ts +1 -1
- package/dist/components/drawer/api.js +73 -0
- package/dist/components/drawer/config.d.ts +3 -2
- package/dist/components/drawer/config.js +66 -0
- package/dist/components/drawer/constants.d.ts +2 -0
- package/dist/components/drawer/constants.js +46 -0
- package/dist/components/drawer/drawer.d.ts +1 -1
- package/dist/components/drawer/drawer.js +42 -0
- package/dist/components/drawer/features/headline.d.ts +1 -1
- package/dist/components/drawer/features/headline.js +36 -0
- package/dist/components/drawer/features/index.d.ts +3 -3
- package/dist/components/drawer/features/index.js +3 -0
- package/dist/components/drawer/features/items.d.ts +1 -1
- package/dist/components/drawer/features/items.js +215 -0
- package/dist/components/drawer/features/state.d.ts +2 -10
- package/dist/components/drawer/features/state.js +170 -0
- package/dist/components/drawer/index.d.ts +2 -2
- package/dist/components/drawer/index.js +1 -0
- package/dist/components/drawer/types.d.ts +8 -2
- package/dist/components/drawer/types.js +1 -0
- package/dist/components/extended-fab/api.d.ts +1 -1
- package/dist/components/extended-fab/api.js +77 -0
- package/dist/components/extended-fab/config.d.ts +1 -1
- package/dist/components/extended-fab/config.js +73 -0
- package/dist/components/extended-fab/constants.d.ts +16 -4
- package/dist/components/extended-fab/constants.js +47 -0
- package/dist/components/extended-fab/extended-fab.d.ts +1 -1
- package/dist/components/extended-fab/extended-fab.js +59 -0
- package/dist/components/extended-fab/index.d.ts +2 -2
- package/dist/components/extended-fab/index.js +1 -0
- package/dist/components/extended-fab/types.d.ts +13 -6
- package/dist/components/extended-fab/types.js +1 -0
- package/dist/components/fab/api.d.ts +1 -1
- package/dist/components/fab/api.js +52 -0
- package/dist/components/fab/config.d.ts +1 -1
- package/dist/components/fab/config.js +53 -0
- package/dist/components/fab/constants.d.ts +18 -7
- package/dist/components/fab/constants.js +43 -0
- package/dist/components/fab/fab.d.ts +1 -1
- package/dist/components/fab/fab.js +17 -0
- package/dist/components/fab/index.d.ts +3 -3
- package/dist/components/fab/index.js +1 -0
- package/dist/components/fab/types.d.ts +10 -9
- package/dist/components/fab/types.js +1 -0
- package/dist/components/icon-button/api.d.ts +1 -1
- package/dist/components/icon-button/api.js +204 -0
- package/dist/components/icon-button/config.d.ts +1 -1
- package/dist/components/icon-button/config.js +91 -0
- package/dist/components/icon-button/constants.d.ts +21 -21
- package/dist/components/icon-button/constants.js +67 -0
- package/dist/components/icon-button/features/toggle.d.ts +1 -1
- package/dist/components/icon-button/features/toggle.js +122 -0
- package/dist/components/icon-button/icon-button.d.ts +1 -1
- package/dist/components/icon-button/icon-button.js +24 -0
- package/dist/components/icon-button/index.d.ts +4 -4
- package/dist/components/icon-button/index.js +2 -0
- package/dist/components/icon-button/types.d.ts +2 -2
- package/dist/components/icon-button/types.js +1 -0
- package/dist/components/index.d.ts +83 -69
- package/dist/components/index.js +41 -0
- package/dist/components/list/api.js +53 -0
- package/dist/components/list/config.d.ts +2 -2
- package/dist/components/list/config.js +80 -0
- package/dist/components/list/constants.js +35 -0
- package/dist/components/list/features/index.d.ts +2 -2
- package/dist/components/list/features/index.js +2 -0
- package/dist/components/list/features/renderer.js +120 -0
- package/dist/components/list/features/selection.js +160 -0
- package/dist/components/list/index.d.ts +3 -3
- package/dist/components/list/index.js +2 -0
- package/dist/components/list/list.js +19 -0
- package/dist/components/list/types.js +1 -0
- package/dist/components/loading-indicator/api.d.ts +14 -0
- package/dist/components/loading-indicator/api.js +122 -0
- package/dist/components/loading-indicator/config.d.ts +44 -0
- package/dist/components/loading-indicator/config.js +25 -0
- package/dist/components/loading-indicator/constants.d.ts +60 -0
- package/dist/components/loading-indicator/constants.js +32 -0
- package/dist/components/loading-indicator/features/motion.d.ts +22 -0
- package/dist/components/loading-indicator/features/motion.js +47 -0
- package/dist/components/loading-indicator/features/renderer.d.ts +29 -0
- package/dist/components/loading-indicator/features/renderer.js +115 -0
- package/dist/components/loading-indicator/index.d.ts +3 -0
- package/dist/components/loading-indicator/index.js +2 -0
- package/dist/components/loading-indicator/loading-indicator.d.ts +9 -0
- package/dist/components/loading-indicator/loading-indicator.js +17 -0
- package/dist/components/loading-indicator/types.d.ts +65 -0
- package/dist/components/loading-indicator/types.js +1 -0
- package/dist/components/menu/api.d.ts +1 -1
- package/dist/components/menu/api.js +79 -0
- package/dist/components/menu/config.d.ts +1 -1
- package/dist/components/menu/config.js +82 -0
- package/dist/components/menu/constants.d.ts +32 -0
- package/dist/components/menu/constants.js +61 -0
- package/dist/components/menu/features/controller.d.ts +1 -1
- package/dist/components/menu/features/controller.js +542 -0
- package/dist/components/menu/features/index.d.ts +5 -5
- package/dist/components/menu/features/index.js +6 -0
- package/dist/components/menu/features/keyboard.d.ts +3 -1
- package/dist/components/menu/features/keyboard.js +296 -0
- package/dist/components/menu/features/opener.d.ts +1 -1
- package/dist/components/menu/features/opener.js +300 -0
- package/dist/components/menu/features/position.d.ts +1 -1
- package/dist/components/menu/features/position.js +276 -0
- package/dist/components/menu/features/registry.d.ts +37 -0
- package/dist/components/menu/features/registry.js +13 -0
- package/dist/components/menu/features/submenu.d.ts +1 -1
- package/dist/components/menu/features/submenu.js +386 -0
- package/dist/components/menu/features/tasks.d.ts +9 -0
- package/dist/components/menu/features/tasks.js +47 -0
- package/dist/components/menu/index.d.ts +3 -3
- package/dist/components/menu/index.js +2 -0
- package/dist/components/menu/menu.d.ts +1 -1
- package/dist/components/menu/menu.js +25 -0
- package/dist/components/menu/types.d.ts +46 -3
- package/dist/components/menu/types.js +14 -0
- package/dist/components/navigation/api.d.ts +1 -1
- package/dist/components/navigation/api.js +117 -0
- package/dist/components/navigation/config.d.ts +1 -1
- package/dist/components/navigation/config.js +39 -0
- package/dist/components/navigation/constants.js +65 -0
- package/dist/components/navigation/features/controller.d.ts +1 -1
- package/dist/components/navigation/features/controller.js +173 -0
- package/dist/components/navigation/features/items.d.ts +2 -2
- package/dist/components/navigation/features/items.js +236 -0
- package/dist/components/navigation/index.d.ts +3 -3
- package/dist/components/navigation/index.js +2 -0
- package/dist/components/navigation/nav-item.d.ts +1 -1
- package/dist/components/navigation/nav-item.js +118 -0
- package/dist/components/navigation/navigation.d.ts +1 -1
- package/dist/components/navigation/navigation.js +52 -0
- package/dist/components/navigation/system/core.d.ts +1 -1
- package/dist/components/navigation/system/core.js +148 -0
- package/dist/components/navigation/system/events.d.ts +1 -1
- package/dist/components/navigation/system/events.js +126 -0
- package/dist/components/navigation/system/index.d.ts +2 -2
- package/dist/components/navigation/system/index.js +92 -0
- package/dist/components/navigation/system/mobile.d.ts +1 -1
- package/dist/components/navigation/system/mobile.js +139 -0
- package/dist/components/navigation/system/state.d.ts +1 -1
- package/dist/components/navigation/system/state.js +44 -0
- package/dist/components/navigation/system/types.js +1 -0
- package/dist/components/navigation/types.js +33 -0
- package/dist/components/navigation-rail/config.d.ts +2 -0
- package/dist/components/navigation-rail/config.js +15 -0
- package/dist/components/navigation-rail/constants.d.ts +14 -0
- package/dist/components/navigation-rail/constants.js +12 -0
- package/dist/components/navigation-rail/index.d.ts +2 -0
- package/dist/components/navigation-rail/index.js +1 -0
- package/dist/components/navigation-rail/navigation-rail.d.ts +7 -0
- package/dist/components/navigation-rail/navigation-rail.js +341 -0
- package/dist/components/navigation-rail/ripple.d.ts +2 -0
- package/dist/components/navigation-rail/ripple.js +41 -0
- package/dist/components/navigation-rail/types.d.ts +72 -0
- package/dist/components/navigation-rail/types.js +1 -0
- package/dist/components/progress/api.d.ts +3 -3
- package/dist/components/progress/api.js +205 -0
- package/dist/components/progress/config.d.ts +1 -1
- package/dist/components/progress/config.js +162 -0
- package/dist/components/progress/constants.d.ts +103 -84
- package/dist/components/progress/constants.js +110 -0
- package/dist/components/progress/features/canvas.d.ts +18 -29
- package/dist/components/progress/features/canvas.js +300 -0
- package/dist/components/progress/features/circular.d.ts +17 -7
- package/dist/components/progress/features/circular.js +71 -0
- package/dist/components/progress/features/colors.d.ts +16 -0
- package/dist/components/progress/features/colors.js +40 -0
- package/dist/components/progress/features/index.d.ts +4 -4
- package/dist/components/progress/features/index.js +4 -0
- package/dist/components/progress/features/linear.d.ts +23 -7
- package/dist/components/progress/features/linear.js +104 -0
- package/dist/components/progress/features/motion.d.ts +43 -0
- package/dist/components/progress/features/motion.js +105 -0
- package/dist/components/progress/features/resize-observer.js +40 -0
- package/dist/components/progress/features/state.d.ts +1 -1
- package/dist/components/progress/features/state.js +37 -0
- package/dist/components/progress/index.d.ts +2 -2
- package/dist/components/progress/index.js +1 -0
- package/dist/components/progress/progress.d.ts +1 -1
- package/dist/components/progress/progress.js +21 -0
- package/dist/components/progress/types.d.ts +19 -2
- package/dist/components/progress/types.js +1 -0
- package/dist/components/radios/api.d.ts +1 -1
- package/dist/components/radios/api.js +73 -0
- package/dist/components/radios/config.d.ts +1 -1
- package/dist/components/radios/config.js +28 -0
- package/dist/components/radios/constants.js +53 -0
- package/dist/components/radios/index.d.ts +3 -3
- package/dist/components/radios/index.js +2 -0
- package/dist/components/radios/radio.d.ts +1 -1
- package/dist/components/radios/radio.js +186 -0
- package/dist/components/radios/radios.d.ts +1 -1
- package/dist/components/radios/radios.js +21 -0
- package/dist/components/radios/types.js +1 -0
- package/dist/components/search/api.d.ts +1 -1
- package/dist/components/search/api.js +110 -0
- package/dist/components/search/config.d.ts +1 -1
- package/dist/components/search/config.js +66 -0
- package/dist/components/search/constants.js +84 -0
- package/dist/components/search/features/index.d.ts +4 -4
- package/dist/components/search/features/index.js +4 -0
- package/dist/components/search/features/input.d.ts +1 -1
- package/dist/components/search/features/input.js +245 -0
- package/dist/components/search/features/states.d.ts +1 -1
- package/dist/components/search/features/states.js +182 -0
- package/dist/components/search/features/structure.d.ts +1 -1
- package/dist/components/search/features/structure.js +165 -0
- package/dist/components/search/features/suggestions.d.ts +1 -1
- package/dist/components/search/features/suggestions.js +223 -0
- package/dist/components/search/index.d.ts +2 -2
- package/dist/components/search/index.js +1 -0
- package/dist/components/search/search.d.ts +1 -1
- package/dist/components/search/search.js +27 -0
- package/dist/components/search/types.js +1 -0
- package/dist/components/segmented-button/config.d.ts +1 -8
- package/dist/components/segmented-button/config.js +54 -0
- package/dist/components/segmented-button/constants.js +40 -0
- package/dist/components/segmented-button/index.d.ts +3 -3
- package/dist/components/segmented-button/index.js +2 -0
- package/dist/components/segmented-button/segment.d.ts +2 -1
- package/dist/components/segmented-button/segment.js +94 -0
- package/dist/components/segmented-button/segmented-button.d.ts +12 -1
- package/dist/components/segmented-button/segmented-button.js +195 -0
- package/dist/components/segmented-button/types.d.ts +11 -11
- package/dist/components/segmented-button/types.js +11 -0
- package/dist/components/select/api.d.ts +1 -1
- package/dist/components/select/api.js +89 -0
- package/dist/components/select/config.d.ts +1 -1
- package/dist/components/select/config.js +54 -0
- package/dist/components/select/constants.js +53 -0
- package/dist/components/select/features.d.ts +1 -1
- package/dist/components/select/features.js +246 -0
- package/dist/components/select/index.d.ts +3 -3
- package/dist/components/select/index.js +2 -0
- package/dist/components/select/select.d.ts +1 -1
- package/dist/components/select/select.js +26 -0
- package/dist/components/select/types.d.ts +21 -0
- package/dist/components/select/types.js +4 -0
- package/dist/components/side-sheet/api.d.ts +33 -0
- package/dist/components/side-sheet/api.js +50 -0
- package/dist/components/side-sheet/config.d.ts +34 -0
- package/dist/components/side-sheet/config.js +20 -0
- package/dist/components/side-sheet/constants.d.ts +60 -0
- package/dist/components/side-sheet/constants.js +32 -0
- package/dist/components/side-sheet/features/index.d.ts +2 -0
- package/dist/components/side-sheet/features/index.js +2 -0
- package/dist/components/side-sheet/features/state.d.ts +28 -0
- package/dist/components/side-sheet/features/state.js +67 -0
- package/dist/components/side-sheet/features/structure.d.ts +21 -0
- package/dist/components/side-sheet/features/structure.js +97 -0
- package/dist/components/side-sheet/index.d.ts +2 -0
- package/dist/components/side-sheet/index.js +1 -0
- package/dist/components/side-sheet/side-sheet.d.ts +24 -0
- package/dist/components/side-sheet/side-sheet.js +17 -0
- package/dist/components/side-sheet/types.d.ts +102 -0
- package/dist/components/side-sheet/types.js +1 -0
- package/dist/components/slider/api.d.ts +2 -2
- package/dist/components/slider/api.js +104 -0
- package/dist/components/slider/config.d.ts +1 -1
- package/dist/components/slider/config.js +106 -0
- package/dist/components/slider/constants.js +74 -0
- package/dist/components/slider/features/controller.d.ts +1 -1
- package/dist/components/slider/features/controller.js +291 -0
- package/dist/components/slider/features/dom.d.ts +2 -2
- package/dist/components/slider/features/dom.js +113 -0
- package/dist/components/slider/features/handlers.d.ts +1 -1
- package/dist/components/slider/features/handlers.js +389 -0
- package/dist/components/slider/features/index.d.ts +5 -5
- package/dist/components/slider/features/index.js +5 -0
- package/dist/components/slider/features/range.d.ts +1 -1
- package/dist/components/slider/features/range.js +70 -0
- package/dist/components/slider/features/states.d.ts +1 -1
- package/dist/components/slider/features/states.js +119 -0
- package/dist/components/slider/features/tracks.d.ts +13 -0
- package/dist/components/slider/features/tracks.js +174 -0
- package/dist/components/slider/index.d.ts +2 -2
- package/dist/components/slider/index.js +1 -0
- package/dist/components/slider/slider.d.ts +2 -2
- package/dist/components/slider/slider.js +27 -0
- package/dist/components/slider/types.d.ts +4 -3
- package/dist/components/slider/types.js +2 -0
- package/dist/components/snackbar/api.d.ts +2 -2
- package/dist/components/snackbar/api.js +173 -0
- package/dist/components/snackbar/config.d.ts +26 -11
- package/dist/components/snackbar/config.js +33 -0
- package/dist/components/snackbar/constants.d.ts +73 -47
- package/dist/components/snackbar/constants.js +60 -0
- package/dist/components/snackbar/features.d.ts +17 -4
- package/dist/components/snackbar/features.js +125 -0
- package/dist/components/snackbar/index.d.ts +4 -4
- package/dist/components/snackbar/index.js +3 -0
- package/dist/components/snackbar/position.d.ts +3 -2
- package/dist/components/snackbar/position.js +24 -0
- package/dist/components/snackbar/queue.d.ts +1 -1
- package/dist/components/snackbar/queue.js +79 -0
- package/dist/components/snackbar/snackbar.d.ts +1 -1
- package/dist/components/snackbar/snackbar.js +25 -0
- package/dist/components/snackbar/types.d.ts +56 -57
- package/dist/components/snackbar/types.js +1 -0
- package/dist/components/split-button/api.d.ts +14 -0
- package/dist/components/split-button/api.js +122 -0
- package/dist/components/split-button/config.d.ts +40 -0
- package/dist/components/split-button/config.js +19 -0
- package/dist/components/split-button/constants.d.ts +67 -0
- package/dist/components/split-button/constants.js +35 -0
- package/dist/components/split-button/features/buttons.d.ts +7 -0
- package/dist/components/split-button/features/buttons.js +39 -0
- package/dist/components/split-button/features/menu.d.ts +7 -0
- package/dist/components/split-button/features/menu.js +19 -0
- package/dist/components/split-button/index.d.ts +3 -0
- package/dist/components/split-button/index.js +2 -0
- package/dist/components/split-button/split-button.d.ts +24 -0
- package/dist/components/split-button/split-button.js +21 -0
- package/dist/components/split-button/types.d.ts +116 -0
- package/dist/components/split-button/types.js +1 -0
- package/dist/components/switch/api.d.ts +1 -1
- package/dist/components/switch/api.js +91 -0
- package/dist/components/switch/config.d.ts +1 -1
- package/dist/components/switch/config.js +27 -0
- package/dist/components/switch/constants.js +39 -0
- package/dist/components/switch/features.d.ts +3 -3
- package/dist/components/switch/features.js +101 -0
- package/dist/components/switch/index.d.ts +5 -4
- package/dist/components/switch/index.js +3 -0
- package/dist/components/switch/switch.d.ts +1 -1
- package/dist/components/switch/switch.js +18 -0
- package/dist/components/switch/types.js +4 -0
- package/dist/components/tabs/api.d.ts +1 -1
- package/dist/components/tabs/api.js +98 -0
- package/dist/components/tabs/config.d.ts +2 -2
- package/dist/components/tabs/config.js +42 -0
- package/dist/components/tabs/constants.js +62 -0
- package/dist/components/tabs/features.d.ts +2 -2
- package/dist/components/tabs/features.js +179 -0
- package/dist/components/tabs/index.d.ts +10 -9
- package/dist/components/tabs/index.js +10 -0
- package/dist/components/tabs/indicator.d.ts +1 -1
- package/dist/components/tabs/indicator.js +134 -0
- package/dist/components/tabs/responsive.d.ts +1 -1
- package/dist/components/tabs/responsive.js +72 -0
- package/dist/components/tabs/scroll-indicators.d.ts +1 -1
- package/dist/components/tabs/scroll-indicators.js +83 -0
- package/dist/components/tabs/state.d.ts +2 -2
- package/dist/components/tabs/state.js +84 -0
- package/dist/components/tabs/tab-api.d.ts +2 -2
- package/dist/components/tabs/tab-api.js +139 -0
- package/dist/components/tabs/tab.d.ts +1 -1
- package/dist/components/tabs/tab.js +185 -0
- package/dist/components/tabs/tabs.d.ts +1 -1
- package/dist/components/tabs/tabs.js +22 -0
- package/dist/components/tabs/types.d.ts +2 -2
- package/dist/components/tabs/types.js +1 -0
- package/dist/components/tabs/utils.d.ts +1 -1
- package/dist/components/tabs/utils.js +67 -0
- package/dist/components/textfield/api.d.ts +2 -1
- package/dist/components/textfield/api.js +190 -0
- package/dist/components/textfield/config.d.ts +1 -1
- package/dist/components/textfield/config.js +21 -0
- package/dist/components/textfield/constants.js +63 -0
- package/dist/components/textfield/features/density.d.ts +1 -1
- package/dist/components/textfield/features/density.js +38 -0
- package/dist/components/textfield/features/error.d.ts +1 -1
- package/dist/components/textfield/features/error.js +35 -0
- package/dist/components/textfield/features/index.d.ts +14 -14
- package/dist/components/textfield/features/index.js +8 -0
- package/dist/components/textfield/features/leading-icon.d.ts +1 -1
- package/dist/components/textfield/features/leading-icon.js +55 -0
- package/dist/components/textfield/features/placement.d.ts +3 -1
- package/dist/components/textfield/features/placement.js +184 -0
- package/dist/components/textfield/features/prefix-text.d.ts +1 -1
- package/dist/components/textfield/features/prefix-text.js +38 -0
- package/dist/components/textfield/features/suffix-text.d.ts +1 -1
- package/dist/components/textfield/features/suffix-text.js +34 -0
- package/dist/components/textfield/features/supporting-text.d.ts +1 -1
- package/dist/components/textfield/features/supporting-text.js +58 -0
- package/dist/components/textfield/features/trailing-icon.d.ts +1 -1
- package/dist/components/textfield/features/trailing-icon.js +40 -0
- package/dist/components/textfield/index.d.ts +2 -2
- package/dist/components/textfield/index.js +1 -0
- package/dist/components/textfield/textfield.d.ts +1 -1
- package/dist/components/textfield/textfield.js +18 -0
- package/dist/components/textfield/types.js +18 -0
- package/dist/components/timepicker/api.d.ts +1 -1
- package/dist/components/timepicker/api.js +426 -0
- package/dist/components/timepicker/clockdial.d.ts +1 -1
- package/dist/components/timepicker/clockdial.js +277 -0
- package/dist/components/timepicker/config.d.ts +1 -1
- package/dist/components/timepicker/config.js +81 -0
- package/dist/components/timepicker/constants.js +135 -0
- package/dist/components/timepicker/index.d.ts +4 -4
- package/dist/components/timepicker/index.js +3 -0
- package/dist/components/timepicker/render.d.ts +1 -1
- package/dist/components/timepicker/render.js +476 -0
- package/dist/components/timepicker/timepicker.d.ts +1 -1
- package/dist/components/timepicker/timepicker.js +68 -0
- package/dist/components/timepicker/types.js +20 -0
- package/dist/components/timepicker/utils.d.ts +1 -1
- package/dist/components/timepicker/utils.js +131 -0
- package/dist/components/tooltip/api.d.ts +1 -1
- package/dist/components/tooltip/api.js +293 -0
- package/dist/components/tooltip/config.d.ts +1 -1
- package/dist/components/tooltip/config.js +38 -0
- package/dist/components/tooltip/constants.js +49 -0
- package/dist/components/tooltip/index.d.ts +3 -3
- package/dist/components/tooltip/index.js +2 -0
- package/dist/components/tooltip/tooltip.d.ts +1 -1
- package/dist/components/tooltip/tooltip.js +31 -0
- package/dist/components/tooltip/types.js +23 -0
- package/dist/components/top-app-bar/config.d.ts +1 -1
- package/dist/components/top-app-bar/config.js +10 -0
- package/dist/components/top-app-bar/constants.js +33 -0
- package/dist/components/top-app-bar/index.d.ts +3 -3
- package/dist/components/top-app-bar/index.js +4 -0
- package/dist/components/top-app-bar/top-app-bar.d.ts +2 -2
- package/dist/components/top-app-bar/top-app-bar.js +155 -0
- package/dist/components/top-app-bar/types.d.ts +1 -1
- package/dist/components/top-app-bar/types.js +1 -0
- package/dist/core/canvas/animation.js +36 -0
- package/dist/core/canvas/drawing.js +62 -0
- package/dist/core/canvas/index.d.ts +4 -4
- package/dist/core/canvas/index.js +4 -0
- package/dist/core/canvas/resize.js +35 -0
- package/dist/core/canvas/utils.d.ts +5 -4
- package/dist/core/canvas/utils.js +116 -0
- package/dist/core/compose/base.js +7 -0
- package/dist/core/compose/cleanup.d.ts +14 -0
- package/dist/core/compose/cleanup.js +51 -0
- package/dist/core/compose/component.d.ts +2 -0
- package/dist/core/compose/component.js +144 -0
- package/dist/core/compose/features/badge.d.ts +1 -1
- package/dist/core/compose/features/badge.js +20 -0
- package/dist/core/compose/features/checkable.d.ts +1 -1
- package/dist/core/compose/features/checkable.js +55 -0
- package/dist/core/compose/features/constants.js +36 -0
- package/dist/core/compose/features/debounce.d.ts +1 -1
- package/dist/core/compose/features/debounce.js +44 -0
- package/dist/core/compose/features/disabled.d.ts +1 -1
- package/dist/core/compose/features/disabled.js +63 -0
- package/dist/core/compose/features/events.d.ts +1 -1
- package/dist/core/compose/features/events.js +23 -0
- package/dist/core/compose/features/icon.d.ts +1 -1
- package/dist/core/compose/features/icon.js +70 -0
- package/dist/core/compose/features/index.d.ts +34 -34
- package/dist/core/compose/features/index.js +19 -0
- package/dist/core/compose/features/input.d.ts +1 -1
- package/dist/core/compose/features/input.js +67 -0
- package/dist/core/compose/features/lifecycle.d.ts +1 -1
- package/dist/core/compose/features/lifecycle.js +82 -0
- package/dist/core/compose/features/position.d.ts +1 -1
- package/dist/core/compose/features/position.js +36 -0
- package/dist/core/compose/features/ripple.d.ts +8 -8
- package/dist/core/compose/features/ripple.js +87 -0
- package/dist/core/compose/features/size.d.ts +1 -1
- package/dist/core/compose/features/size.js +7 -0
- package/dist/core/compose/features/style.d.ts +1 -1
- package/dist/core/compose/features/style.js +9 -0
- package/dist/core/compose/features/text.d.ts +1 -1
- package/dist/core/compose/features/text.js +47 -0
- package/dist/core/compose/features/textinput.d.ts +1 -1
- package/dist/core/compose/features/textinput.js +162 -0
- package/dist/core/compose/features/textlabel.d.ts +1 -1
- package/dist/core/compose/features/textlabel.js +44 -0
- package/dist/core/compose/features/throttle.d.ts +1 -1
- package/dist/core/compose/features/throttle.js +44 -0
- package/dist/core/compose/features/track.d.ts +1 -1
- package/dist/core/compose/features/track.js +23 -0
- package/dist/core/compose/features/variant.d.ts +1 -1
- package/dist/core/compose/features/variant.js +7 -0
- package/dist/core/compose/features/withEvents.d.ts +1 -1
- package/dist/core/compose/features/withEvents.js +46 -0
- package/dist/core/compose/index.d.ts +9 -9
- package/dist/core/compose/index.js +5 -0
- package/dist/core/compose/pipe.js +6 -0
- package/dist/core/compose/utils/type-guards.d.ts +1 -1
- package/dist/core/compose/utils/type-guards.js +10 -0
- package/dist/core/config/component.js +71 -0
- package/dist/core/config/global.d.ts +4 -2
- package/dist/core/config/global.js +15 -0
- package/dist/core/config.js +72 -0
- package/dist/core/dom/attributes.js +39 -0
- package/dist/core/dom/classes.js +207 -0
- package/dist/core/dom/create.js +250 -0
- package/dist/core/dom/events.js +82 -0
- package/dist/core/dom/index.d.ts +6 -6
- package/dist/core/dom/index.js +4 -0
- package/dist/core/dom/utils.d.ts +1 -1
- package/dist/core/dom/utils.js +45 -0
- package/dist/core/index.d.ts +20 -20
- package/dist/core/index.js +13 -0
- package/dist/core/shapes/cubic.d.ts +30 -0
- package/dist/core/shapes/cubic.js +62 -0
- package/dist/core/shapes/index.d.ts +6 -0
- package/dist/core/shapes/index.js +3 -0
- package/dist/core/shapes/material.d.ts +24 -0
- package/dist/core/shapes/material.js +119 -0
- package/dist/core/shapes/polygon.d.ts +35 -0
- package/dist/core/shapes/polygon.js +221 -0
- package/dist/core/state/disabled.js +26 -0
- package/dist/core/state/emitter.js +24 -0
- package/dist/core/state/events.js +32 -0
- package/dist/core/state/index.d.ts +10 -10
- package/dist/core/state/index.js +5 -0
- package/dist/core/state/lifecycle.js +51 -0
- package/dist/core/state/store.js +61 -0
- package/dist/core/utils/background.js +35 -0
- package/dist/core/utils/color.js +23 -0
- package/dist/core/utils/index.d.ts +6 -6
- package/dist/core/utils/index.js +8 -0
- package/dist/core/utils/mobile.js +63 -0
- package/dist/core/utils/object.js +21 -0
- package/dist/core/utils/performance.d.ts +5 -2
- package/dist/core/utils/performance.js +117 -0
- package/dist/core/utils/theme.js +78 -0
- package/dist/core/utils/validate.js +113 -0
- package/dist/index.cjs +12 -18
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -57
- package/dist/package.json +40 -11
- package/dist/styles/badge.css +2 -0
- package/dist/styles/badge.d.ts +1 -0
- package/dist/styles/badge.js +2 -0
- package/dist/styles/base.css +2 -0
- package/dist/styles/base.d.ts +1 -0
- package/dist/styles/base.js +2 -0
- package/dist/styles/bottom-app-bar.css +2 -0
- package/dist/styles/bottom-app-bar.d.ts +1 -0
- package/dist/styles/bottom-app-bar.js +2 -0
- package/dist/styles/bottom-sheet.css +2 -0
- package/dist/styles/bottom-sheet.d.ts +1 -0
- package/dist/styles/bottom-sheet.js +2 -0
- package/dist/styles/button-group.css +2 -0
- package/dist/styles/button-group.d.ts +1 -0
- package/dist/styles/button-group.js +3 -0
- package/dist/styles/button.css +2 -0
- package/dist/styles/button.d.ts +1 -0
- package/dist/styles/button.js +2 -0
- package/dist/styles/card.css +2 -0
- package/dist/styles/card.d.ts +1 -0
- package/dist/styles/card.js +2 -0
- package/dist/styles/carousel.css +2 -0
- package/dist/styles/carousel.d.ts +1 -0
- package/dist/styles/carousel.js +2 -0
- package/dist/styles/checkbox.css +2 -0
- package/dist/styles/checkbox.d.ts +1 -0
- package/dist/styles/checkbox.js +2 -0
- package/dist/styles/chips.css +2 -0
- package/dist/styles/chips.d.ts +1 -0
- package/dist/styles/chips.js +2 -0
- package/dist/styles/dialog.css +2 -0
- package/dist/styles/dialog.d.ts +1 -0
- package/dist/styles/dialog.js +3 -0
- package/dist/styles/divider.css +2 -0
- package/dist/styles/divider.d.ts +1 -0
- package/dist/styles/divider.js +2 -0
- package/dist/styles/drawer.css +2 -0
- package/dist/styles/drawer.d.ts +1 -0
- package/dist/styles/drawer.js +2 -0
- package/dist/styles/extended-fab.css +2 -0
- package/dist/styles/extended-fab.d.ts +1 -0
- package/dist/styles/extended-fab.js +2 -0
- package/dist/styles/fab.css +2 -0
- package/dist/styles/fab.d.ts +1 -0
- package/dist/styles/fab.js +2 -0
- package/dist/styles/icon-button.css +2 -0
- package/dist/styles/icon-button.d.ts +1 -0
- package/dist/styles/icon-button.js +2 -0
- package/dist/styles/list.css +2 -0
- package/dist/styles/list.d.ts +1 -0
- package/dist/styles/list.js +2 -0
- package/dist/styles/loading-indicator.css +2 -0
- package/dist/styles/loading-indicator.d.ts +1 -0
- package/dist/styles/loading-indicator.js +2 -0
- package/dist/styles/menu.css +2 -0
- package/dist/styles/menu.d.ts +1 -0
- package/dist/styles/menu.js +2 -0
- package/dist/styles/navigation-rail.css +2 -0
- package/dist/styles/navigation-rail.d.ts +1 -0
- package/dist/styles/navigation-rail.js +2 -0
- package/dist/styles/navigation.css +2 -0
- package/dist/styles/navigation.d.ts +1 -0
- package/dist/styles/navigation.js +2 -0
- package/dist/styles/progress.css +2 -0
- package/dist/styles/progress.d.ts +1 -0
- package/dist/styles/progress.js +2 -0
- package/dist/styles/radios.css +2 -0
- package/dist/styles/radios.d.ts +1 -0
- package/dist/styles/radios.js +2 -0
- package/dist/styles/search.css +2 -0
- package/dist/styles/search.d.ts +1 -0
- package/dist/styles/search.js +2 -0
- package/dist/styles/segmented-button.css +2 -0
- package/dist/styles/segmented-button.d.ts +1 -0
- package/dist/styles/segmented-button.js +2 -0
- package/dist/styles/select.css +2 -0
- package/dist/styles/select.d.ts +1 -0
- package/dist/styles/select.js +3 -0
- package/dist/styles/side-sheet.css +2 -0
- package/dist/styles/side-sheet.d.ts +1 -0
- package/dist/styles/side-sheet.js +2 -0
- package/dist/styles/slider.css +2 -0
- package/dist/styles/slider.d.ts +1 -0
- package/dist/styles/slider.js +2 -0
- package/dist/styles/snackbar.css +2 -0
- package/dist/styles/snackbar.d.ts +1 -0
- package/dist/styles/snackbar.js +3 -0
- package/dist/styles/split-button.css +2 -0
- package/dist/styles/split-button.d.ts +1 -0
- package/dist/styles/split-button.js +3 -0
- package/dist/styles/switch.css +2 -0
- package/dist/styles/switch.d.ts +1 -0
- package/dist/styles/switch.js +2 -0
- package/dist/styles/tabs.css +2 -0
- package/dist/styles/tabs.d.ts +1 -0
- package/dist/styles/tabs.js +3 -0
- package/dist/styles/textfield.css +2 -0
- package/dist/styles/textfield.d.ts +1 -0
- package/dist/styles/textfield.js +2 -0
- package/dist/styles/timepicker.css +2 -0
- package/dist/styles/timepicker.d.ts +1 -0
- package/dist/styles/timepicker.js +2 -0
- package/dist/styles/top-app-bar.css +2 -0
- package/dist/styles/top-app-bar.d.ts +1 -0
- package/dist/styles/top-app-bar.js +2 -0
- package/dist/styles/utilities.css +2 -0
- package/dist/styles/utilities.d.ts +1 -0
- package/dist/styles/utilities.js +2 -0
- package/dist/styles.css +2 -7
- package/dist/themes/autumn.css +2 -0
- package/dist/themes/baseline.css +2 -0
- package/dist/themes/brownbeige.css +2 -0
- package/dist/themes/browngreen.css +2 -0
- package/dist/themes/desert.css +2 -0
- package/dist/themes/forest.css +2 -0
- package/dist/themes/highcontrast.css +2 -0
- package/dist/themes/legacy.css +2 -0
- package/dist/themes/material.css +2 -0
- package/dist/themes/ocean.css +2 -0
- package/dist/themes/sageivory.css +2 -0
- package/dist/themes/spring.css +2 -0
- package/dist/themes/summer.css +2 -0
- package/dist/themes/sunset.css +2 -0
- package/dist/themes/tealcaramel.css +2 -0
- package/dist/themes/winter.css +2 -0
- package/package.json +44 -7
- package/src/styles/abstract/_variables.scss +18 -2
- package/src/styles/base/_document.scss +54 -0
- package/src/styles/components/_bottom-sheet.scss +167 -0
- package/src/styles/components/_button-group.scss +58 -38
- package/src/styles/components/_button.scss +9 -3
- package/src/styles/components/_card.scss +79 -20
- package/src/styles/components/_carousel.scss +3 -3
- package/src/styles/components/_chips.scss +2 -2
- package/src/styles/components/_dialog.scss +86 -22
- package/src/styles/components/_drawer.scss +85 -95
- package/src/styles/components/_extended-fab.scss +95 -111
- package/src/styles/components/_fab.scss +70 -87
- package/src/styles/components/_icon-button.scss +115 -104
- package/src/styles/components/_list.scss +2 -2
- package/src/styles/components/_loading-indicator.scss +41 -0
- package/src/styles/components/_menu.scss +324 -16
- package/src/styles/components/_navigation-rail.scss +307 -0
- package/src/styles/components/_navigation-system.scss +3 -1
- package/src/styles/components/_progress.scss +46 -53
- package/src/styles/components/_segmented-button.scss +71 -113
- package/src/styles/components/_side-sheet.scss +175 -0
- package/src/styles/components/_slider.scss +50 -20
- package/src/styles/components/_snackbar.scss +153 -167
- package/src/styles/components/_split-button.scss +229 -0
- package/src/styles/components/_textfield.scss +4 -1
- package/src/styles/main.scss +6 -51
- package/src/styles/themes/_baseline.scss +8 -0
- package/src/styles/utilities/_ripple.scss +12 -3
- package/dist/components/sheet/api.d.ts +0 -37
- package/dist/components/sheet/config.d.ts +0 -53
- package/dist/components/sheet/constants.d.ts +0 -136
- package/dist/components/sheet/features/content.d.ts +0 -6
- package/dist/components/sheet/features/gestures.d.ts +0 -6
- package/dist/components/sheet/features/index.d.ts +0 -5
- package/dist/components/sheet/features/position.d.ts +0 -7
- package/dist/components/sheet/features/state.d.ts +0 -6
- package/dist/components/sheet/features/title.d.ts +0 -6
- package/dist/components/sheet/index.d.ts +0 -3
- package/dist/components/sheet/sheet.d.ts +0 -8
- package/dist/components/sheet/types.d.ts +0 -250
- package/dist/components/slider/features/canvas.d.ts +0 -47
- package/dist/index.cjs.map +0 -269
- package/dist/index.js.map +0 -269
- package/src/styles/components/_sheet.scss +0 -236
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import { PROGRESS_CLASSES, PROGRESS_VARIANTS, PROGRESS_SHAPES, PROGRESS_MEASUREMENTS, PROGRESS_MOTION, PROGRESS_THICKNESS, PROGRESS_WAVE, } from "../constants.js";
|
|
2
|
+
import { observeCanvasResize } from "../../../core/canvas/resize.js";
|
|
3
|
+
import { createColors } from "./colors.js";
|
|
4
|
+
import { drawCircularProgress } from "./circular.js";
|
|
5
|
+
import { drawLinearProgress } from "./linear.js";
|
|
6
|
+
import { waveAmplitudeAt, waveAmplitudeTarget } from "./motion.js";
|
|
7
|
+
export const getStrokeWidth = (thickness = "thin") => {
|
|
8
|
+
if (typeof thickness === "number")
|
|
9
|
+
return thickness;
|
|
10
|
+
return thickness === "thick" ? PROGRESS_THICKNESS.THICK : PROGRESS_THICKNESS.THIN;
|
|
11
|
+
};
|
|
12
|
+
export const getWaveAmplitude = (isCircular, strokeWidth, size) => isCircular
|
|
13
|
+
? PROGRESS_WAVE.CIRCULAR.AMPLITUDE * (size / PROGRESS_MEASUREMENTS.CIRCULAR.SIZE)
|
|
14
|
+
: PROGRESS_WAVE.LINEAR.AMPLITUDE * (strokeWidth / PROGRESS_THICKNESS.THIN);
|
|
15
|
+
export const getCircularSize = (config) => {
|
|
16
|
+
const fallback = config.shape === PROGRESS_SHAPES.WAVY
|
|
17
|
+
? PROGRESS_MEASUREMENTS.CIRCULAR.WAVE_SIZE
|
|
18
|
+
: PROGRESS_MEASUREMENTS.CIRCULAR.SIZE;
|
|
19
|
+
return Math.max(PROGRESS_MEASUREMENTS.CIRCULAR.MIN_SIZE, Math.min(config.size ?? fallback, PROGRESS_MEASUREMENTS.CIRCULAR.MAX_SIZE));
|
|
20
|
+
};
|
|
21
|
+
export const getLinearHeight = (strokeWidth, isWavy) => isWavy ? strokeWidth + 2 * getWaveAmplitude(false, strokeWidth, 0) : strokeWidth;
|
|
22
|
+
export const withCanvas = (config) => (component) => {
|
|
23
|
+
const isCircular = config.variant === PROGRESS_VARIANTS.CIRCULAR;
|
|
24
|
+
const view = component.element.ownerDocument?.defaultView ?? null;
|
|
25
|
+
const canvas = document.createElement("canvas");
|
|
26
|
+
canvas.className = `${component.getClass(PROGRESS_CLASSES.CONTAINER)}-canvas`;
|
|
27
|
+
canvas.setAttribute("aria-hidden", "true");
|
|
28
|
+
component.element.appendChild(canvas);
|
|
29
|
+
let context = null;
|
|
30
|
+
let currentThickness = config.thickness ?? "thin";
|
|
31
|
+
let currentShape = config.shape ?? PROGRESS_SHAPES.FLAT;
|
|
32
|
+
let currentSize = getCircularSize(config);
|
|
33
|
+
let animatedValue = config.value ?? 0;
|
|
34
|
+
let targetValue = animatedValue;
|
|
35
|
+
let valueAnimationId = null;
|
|
36
|
+
let lastSetValueTime = 0;
|
|
37
|
+
let amplitudeFrom = 0;
|
|
38
|
+
let amplitudeTarget = 0;
|
|
39
|
+
let amplitudeStarted = 0;
|
|
40
|
+
let animationId = null;
|
|
41
|
+
let animationTime = 0;
|
|
42
|
+
let animationStart = 0;
|
|
43
|
+
const reducedMotion = view?.matchMedia?.("(prefers-reduced-motion: reduce)") ?? null;
|
|
44
|
+
const isWavy = () => currentShape === PROGRESS_SHAPES.WAVY;
|
|
45
|
+
const strokeWidth = () => getStrokeWidth(currentThickness);
|
|
46
|
+
const max = () => component.state?.max ?? config.max ?? 100;
|
|
47
|
+
const isIndeterminate = () => component.state?.indeterminate ?? config.indeterminate ?? false;
|
|
48
|
+
const colors = createColors(() => draw(animationTime));
|
|
49
|
+
const measure = () => {
|
|
50
|
+
if (!context)
|
|
51
|
+
return;
|
|
52
|
+
const ratio = view?.devicePixelRatio || 1;
|
|
53
|
+
let width;
|
|
54
|
+
let height;
|
|
55
|
+
if (isCircular) {
|
|
56
|
+
width = height = currentSize;
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
const rect = component.element.getBoundingClientRect?.();
|
|
60
|
+
width = Math.max(rect?.width || component.element.offsetWidth || 0, 0);
|
|
61
|
+
height = getLinearHeight(strokeWidth(), isWavy());
|
|
62
|
+
}
|
|
63
|
+
canvas.style.width = `${width}px`;
|
|
64
|
+
canvas.style.height = `${height}px`;
|
|
65
|
+
canvas.width = Math.round(width * ratio);
|
|
66
|
+
canvas.height = Math.round(height * ratio);
|
|
67
|
+
context.width = width;
|
|
68
|
+
context.height = height;
|
|
69
|
+
context.pixelRatio = ratio;
|
|
70
|
+
context.ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
71
|
+
context.ctx.scale(ratio, ratio);
|
|
72
|
+
};
|
|
73
|
+
const initialize = () => {
|
|
74
|
+
if (typeof canvas.getContext !== "function")
|
|
75
|
+
return false;
|
|
76
|
+
const ctx = canvas.getContext("2d");
|
|
77
|
+
if (!ctx)
|
|
78
|
+
return false;
|
|
79
|
+
context = { canvas, ctx, width: 0, height: 0, pixelRatio: view?.devicePixelRatio || 1 };
|
|
80
|
+
measure();
|
|
81
|
+
component.ctx = ctx;
|
|
82
|
+
return true;
|
|
83
|
+
};
|
|
84
|
+
const currentAmplitude = () => {
|
|
85
|
+
if (!isWavy())
|
|
86
|
+
return 0;
|
|
87
|
+
const full = getWaveAmplitude(isCircular, strokeWidth(), currentSize);
|
|
88
|
+
if (isIndeterminate())
|
|
89
|
+
return full;
|
|
90
|
+
const fraction = waveAmplitudeAt(amplitudeFrom, amplitudeTarget, (view?.performance ?? performance).now() - amplitudeStarted);
|
|
91
|
+
return full * fraction;
|
|
92
|
+
};
|
|
93
|
+
const draw = (time = animationTime) => {
|
|
94
|
+
if (!context || context.width <= 0 || context.height <= 0)
|
|
95
|
+
return;
|
|
96
|
+
const indeterminate = isIndeterminate();
|
|
97
|
+
const value = indeterminate ? 0 : animatedValue / max();
|
|
98
|
+
if (isCircular) {
|
|
99
|
+
drawCircularProgress(context, {
|
|
100
|
+
progress: value,
|
|
101
|
+
indeterminate,
|
|
102
|
+
strokeWidth: strokeWidth(),
|
|
103
|
+
time,
|
|
104
|
+
waveAmplitude: currentAmplitude(),
|
|
105
|
+
colors: colors.get(),
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
const rtl = view?.getComputedStyle?.(component.element)?.direction === "rtl";
|
|
110
|
+
drawLinearProgress(context, {
|
|
111
|
+
progress: value,
|
|
112
|
+
buffer: (component.state?.buffer ?? config.buffer ?? 0) / max(),
|
|
113
|
+
indeterminate,
|
|
114
|
+
strokeWidth: strokeWidth(),
|
|
115
|
+
time,
|
|
116
|
+
waveAmplitude: currentAmplitude(),
|
|
117
|
+
rtl,
|
|
118
|
+
colors: colors.get(),
|
|
119
|
+
showStopIndicator: !indeterminate && config.showStopIndicator !== false,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
const needsAnimation = () => !reducedMotion?.matches && (isIndeterminate() || isWavy());
|
|
124
|
+
const startAnimation = (offset = 0) => {
|
|
125
|
+
stopAnimation();
|
|
126
|
+
if (!needsAnimation()) {
|
|
127
|
+
draw(0);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
animationStart = 0;
|
|
131
|
+
const step = (timestamp) => {
|
|
132
|
+
if (animationStart === 0)
|
|
133
|
+
animationStart = timestamp - offset;
|
|
134
|
+
animationTime = timestamp - animationStart;
|
|
135
|
+
draw(animationTime);
|
|
136
|
+
animationId = needsAnimation() ? requestAnimationFrame(step) : null;
|
|
137
|
+
};
|
|
138
|
+
animationId = requestAnimationFrame(step);
|
|
139
|
+
};
|
|
140
|
+
const stopAnimation = () => {
|
|
141
|
+
if (animationId !== null) {
|
|
142
|
+
cancelAnimationFrame(animationId);
|
|
143
|
+
animationId = null;
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
const stopValueAnimation = () => {
|
|
147
|
+
if (valueAnimationId !== null) {
|
|
148
|
+
cancelAnimationFrame(valueAnimationId);
|
|
149
|
+
valueAnimationId = null;
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
const retargetAmplitude = (progress) => {
|
|
153
|
+
const next = waveAmplitudeTarget(progress);
|
|
154
|
+
if (next === amplitudeTarget)
|
|
155
|
+
return;
|
|
156
|
+
amplitudeFrom = waveAmplitudeAt(amplitudeFrom, amplitudeTarget, (view?.performance ?? performance).now() - amplitudeStarted);
|
|
157
|
+
amplitudeTarget = next;
|
|
158
|
+
amplitudeStarted = (view?.performance ?? performance).now();
|
|
159
|
+
};
|
|
160
|
+
const complete = (value) => {
|
|
161
|
+
component.element.dispatchEvent(new CustomEvent("complete", { detail: { value, max: max() } }));
|
|
162
|
+
};
|
|
163
|
+
component.setValue = (value, animate = true) => {
|
|
164
|
+
targetValue = Math.max(0, Math.min(max(), value));
|
|
165
|
+
retargetAmplitude(targetValue / max());
|
|
166
|
+
if (valueAnimationId !== null && animate)
|
|
167
|
+
return;
|
|
168
|
+
stopValueAnimation();
|
|
169
|
+
if (!animate || reducedMotion?.matches) {
|
|
170
|
+
animatedValue = targetValue;
|
|
171
|
+
draw();
|
|
172
|
+
if (targetValue >= max())
|
|
173
|
+
complete(targetValue);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
const startValue = animatedValue;
|
|
177
|
+
const startTime = (view?.performance ?? performance).now();
|
|
178
|
+
const sinceLast = startTime - lastSetValueTime;
|
|
179
|
+
const duration = lastSetValueTime > 0 && sinceLast < PROGRESS_MOTION.VALUE_DURATION
|
|
180
|
+
? Math.max(100, sinceLast * 0.9)
|
|
181
|
+
: PROGRESS_MOTION.VALUE_DURATION;
|
|
182
|
+
lastSetValueTime = startTime;
|
|
183
|
+
const step = (now) => {
|
|
184
|
+
const fraction = Math.min((now - startTime) / duration, 1);
|
|
185
|
+
animatedValue = startValue + (targetValue - startValue) * fraction;
|
|
186
|
+
if (animationId === null)
|
|
187
|
+
draw();
|
|
188
|
+
if (fraction < 1) {
|
|
189
|
+
valueAnimationId = requestAnimationFrame(step);
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
valueAnimationId = null;
|
|
193
|
+
animatedValue = targetValue;
|
|
194
|
+
if (animationId === null)
|
|
195
|
+
draw();
|
|
196
|
+
if (targetValue >= max())
|
|
197
|
+
complete(targetValue);
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
valueAnimationId = requestAnimationFrame(step);
|
|
201
|
+
};
|
|
202
|
+
component.setIndeterminate = (indeterminate) => {
|
|
203
|
+
if (component.state)
|
|
204
|
+
component.state.indeterminate = indeterminate;
|
|
205
|
+
stopValueAnimation();
|
|
206
|
+
animatedValue = component.state?.value ?? animatedValue;
|
|
207
|
+
if (!indeterminate)
|
|
208
|
+
retargetAmplitude(animatedValue / max());
|
|
209
|
+
startAnimation();
|
|
210
|
+
if (!needsAnimation())
|
|
211
|
+
draw(0);
|
|
212
|
+
};
|
|
213
|
+
component.setThickness = (thickness) => {
|
|
214
|
+
currentThickness = thickness;
|
|
215
|
+
measure();
|
|
216
|
+
draw();
|
|
217
|
+
};
|
|
218
|
+
component.setShape = (shape) => {
|
|
219
|
+
if (currentShape === shape)
|
|
220
|
+
return;
|
|
221
|
+
currentShape = shape;
|
|
222
|
+
component.currentShape = shape;
|
|
223
|
+
if (component.state)
|
|
224
|
+
component.state.shape = shape;
|
|
225
|
+
if (isCircular && config.size === undefined)
|
|
226
|
+
currentSize = getCircularSize({ ...config, shape });
|
|
227
|
+
if (shape === PROGRESS_SHAPES.WAVY) {
|
|
228
|
+
amplitudeFrom = 0;
|
|
229
|
+
amplitudeTarget = 0;
|
|
230
|
+
amplitudeStarted = (view?.performance ?? performance).now();
|
|
231
|
+
retargetAmplitude(animatedValue / max());
|
|
232
|
+
}
|
|
233
|
+
measure();
|
|
234
|
+
startAnimation(animationTime);
|
|
235
|
+
if (!needsAnimation())
|
|
236
|
+
draw(0);
|
|
237
|
+
};
|
|
238
|
+
component.setSize = (size) => {
|
|
239
|
+
if (!isCircular)
|
|
240
|
+
return;
|
|
241
|
+
currentSize = Math.max(PROGRESS_MEASUREMENTS.CIRCULAR.MIN_SIZE, Math.min(size, PROGRESS_MEASUREMENTS.CIRCULAR.MAX_SIZE));
|
|
242
|
+
measure();
|
|
243
|
+
draw();
|
|
244
|
+
};
|
|
245
|
+
component.getSize = () => (isCircular ? currentSize : undefined);
|
|
246
|
+
component.hide = () => {
|
|
247
|
+
component.element.classList.add(component.getClass(PROGRESS_CLASSES.TRANSITION));
|
|
248
|
+
component.element.setAttribute("hidden", "");
|
|
249
|
+
stopAnimation();
|
|
250
|
+
stopValueAnimation();
|
|
251
|
+
return component;
|
|
252
|
+
};
|
|
253
|
+
component.show = () => {
|
|
254
|
+
component.element.classList.add(component.getClass(PROGRESS_CLASSES.TRANSITION));
|
|
255
|
+
component.element.removeAttribute("hidden");
|
|
256
|
+
measure();
|
|
257
|
+
startAnimation(animationTime);
|
|
258
|
+
if (!needsAnimation())
|
|
259
|
+
draw(0);
|
|
260
|
+
return component;
|
|
261
|
+
};
|
|
262
|
+
component.isVisible = () => !component.element.hasAttribute("hidden");
|
|
263
|
+
const resize = () => {
|
|
264
|
+
measure();
|
|
265
|
+
draw();
|
|
266
|
+
};
|
|
267
|
+
if (!initialize()) {
|
|
268
|
+
requestAnimationFrame(() => {
|
|
269
|
+
if (initialize()) {
|
|
270
|
+
startAnimation();
|
|
271
|
+
draw();
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
const resizeCleanup = observeCanvasResize(component.element, canvas, resize);
|
|
276
|
+
if (isWavy() && !isIndeterminate()) {
|
|
277
|
+
amplitudeStarted = (view?.performance ?? performance).now();
|
|
278
|
+
retargetAmplitude(animatedValue / max());
|
|
279
|
+
}
|
|
280
|
+
draw();
|
|
281
|
+
startAnimation();
|
|
282
|
+
const originalDestroy = component.lifecycle?.destroy;
|
|
283
|
+
component.lifecycle = {
|
|
284
|
+
...(component.lifecycle ?? {}),
|
|
285
|
+
destroy: () => {
|
|
286
|
+
resizeCleanup();
|
|
287
|
+
colors.destroy();
|
|
288
|
+
stopAnimation();
|
|
289
|
+
stopValueAnimation();
|
|
290
|
+
originalDestroy?.();
|
|
291
|
+
},
|
|
292
|
+
};
|
|
293
|
+
return {
|
|
294
|
+
...component,
|
|
295
|
+
canvas,
|
|
296
|
+
ctx: context?.ctx,
|
|
297
|
+
draw,
|
|
298
|
+
resize,
|
|
299
|
+
};
|
|
300
|
+
};
|
|
@@ -1,9 +1,19 @@
|
|
|
1
|
+
import { CanvasContext } from "./canvas.js";
|
|
2
|
+
import { ProgressColors } from "./colors.js";
|
|
3
|
+
/** What a frame of the circular indicator needs */
|
|
4
|
+
export interface CircularFrame {
|
|
5
|
+
/** Progress from 0 to 1; ignored when indeterminate */
|
|
6
|
+
progress: number;
|
|
7
|
+
indeterminate: boolean;
|
|
8
|
+
/** Arc thickness in pixels */
|
|
9
|
+
strokeWidth: number;
|
|
10
|
+
/** Milliseconds since the animation started */
|
|
11
|
+
time: number;
|
|
12
|
+
/** Wave height in pixels; 0 draws a flat arc */
|
|
13
|
+
waveAmplitude: number;
|
|
14
|
+
colors: ProgressColors;
|
|
15
|
+
}
|
|
1
16
|
/**
|
|
2
|
-
*
|
|
17
|
+
* Draws one frame of the circular indicator.
|
|
3
18
|
*/
|
|
4
|
-
|
|
5
|
-
import { CanvasContext } from "./canvas";
|
|
6
|
-
/**
|
|
7
|
-
* Draws circular progress on canvas
|
|
8
|
-
*/
|
|
9
|
-
export declare const drawCircularProgress: (context: CanvasContext, config: ProgressConfig, value: number, max: number, isIndeterminate: boolean, animationTime?: number, currentShape?: ProgressShape) => void;
|
|
19
|
+
export declare const drawCircularProgress: (context: CanvasContext, frame: CircularFrame) => void;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { circularIndeterminateFrame } from "./motion.js";
|
|
2
|
+
import { PROGRESS_MEASUREMENTS, PROGRESS_WAVE } from "../constants.js";
|
|
3
|
+
const TWO_PI = Math.PI * 2;
|
|
4
|
+
const START_ANGLE = -Math.PI / 2;
|
|
5
|
+
const drawArc = (ctx, centerX, centerY, radius, from, sweep, color, strokeWidth, wave) => {
|
|
6
|
+
if (sweep <= 0 || radius <= 0)
|
|
7
|
+
return;
|
|
8
|
+
ctx.strokeStyle = color;
|
|
9
|
+
ctx.lineWidth = strokeWidth;
|
|
10
|
+
ctx.lineCap = "round";
|
|
11
|
+
ctx.lineJoin = "round";
|
|
12
|
+
ctx.beginPath();
|
|
13
|
+
if (!wave || wave.amplitude <= 0) {
|
|
14
|
+
ctx.arc(centerX, centerY, radius, from, from + sweep);
|
|
15
|
+
ctx.stroke();
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const arcLength = sweep * radius;
|
|
19
|
+
const steps = Math.max(8, Math.ceil(arcLength / Math.max(1, wave.wavelength / 24)));
|
|
20
|
+
for (let i = 0; i <= steps; i++) {
|
|
21
|
+
const t = i / steps;
|
|
22
|
+
const angle = from + sweep * t;
|
|
23
|
+
const along = t * arcLength;
|
|
24
|
+
const r = radius + wave.amplitude * Math.sin((TWO_PI * (along - wave.phase)) / wave.wavelength);
|
|
25
|
+
const x = centerX + Math.cos(angle) * r;
|
|
26
|
+
const y = centerY + Math.sin(angle) * r;
|
|
27
|
+
if (i === 0)
|
|
28
|
+
ctx.moveTo(x, y);
|
|
29
|
+
else
|
|
30
|
+
ctx.lineTo(x, y);
|
|
31
|
+
}
|
|
32
|
+
ctx.stroke();
|
|
33
|
+
};
|
|
34
|
+
export const drawCircularProgress = (context, frame) => {
|
|
35
|
+
const { ctx, width, height } = context;
|
|
36
|
+
const { strokeWidth, colors, indeterminate, waveAmplitude } = frame;
|
|
37
|
+
if (width <= 0 || height <= 0)
|
|
38
|
+
return;
|
|
39
|
+
const size = Math.min(width, height);
|
|
40
|
+
const centerX = width / 2;
|
|
41
|
+
const centerY = height / 2;
|
|
42
|
+
const radius = size / 2 - strokeWidth / 2 - waveAmplitude;
|
|
43
|
+
if (radius <= 0)
|
|
44
|
+
return;
|
|
45
|
+
ctx.clearRect(0, 0, width, height);
|
|
46
|
+
const scale = size / PROGRESS_MEASUREMENTS.CIRCULAR.SIZE;
|
|
47
|
+
const wavelength = PROGRESS_WAVE.CIRCULAR.WAVELENGTH * scale;
|
|
48
|
+
const wave = waveAmplitude > 0
|
|
49
|
+
? {
|
|
50
|
+
amplitude: waveAmplitude,
|
|
51
|
+
wavelength,
|
|
52
|
+
phase: ((frame.time / 1000) * PROGRESS_WAVE.SPEED * wavelength) % wavelength,
|
|
53
|
+
}
|
|
54
|
+
: undefined;
|
|
55
|
+
const gapPx = PROGRESS_MEASUREMENTS.CIRCULAR.GAP + strokeWidth;
|
|
56
|
+
const gapSweep = size > 0 ? (gapPx / (Math.PI * size)) * TWO_PI : 0;
|
|
57
|
+
if (indeterminate) {
|
|
58
|
+
const { rotation, sweep } = circularIndeterminateFrame(frame.time);
|
|
59
|
+
const start = (rotation * Math.PI) / 180;
|
|
60
|
+
drawArc(ctx, centerX, centerY, radius, start, sweep * TWO_PI, colors.indicator, strokeWidth, wave);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const progress = Math.min(1, Math.max(0, frame.progress));
|
|
64
|
+
const sweep = progress * TWO_PI;
|
|
65
|
+
const gap = Math.min(sweep, gapSweep);
|
|
66
|
+
const trackSweep = TWO_PI - sweep - gap * 2;
|
|
67
|
+
if (trackSweep > 0) {
|
|
68
|
+
drawArc(ctx, centerX, centerY, radius, START_ANGLE + sweep + gap, trackSweep, colors.track, strokeWidth);
|
|
69
|
+
}
|
|
70
|
+
drawArc(ctx, centerX, centerY, radius, START_ANGLE, sweep, colors.indicator, strokeWidth, wave);
|
|
71
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface ProgressColors {
|
|
2
|
+
indicator: string;
|
|
3
|
+
track: string;
|
|
4
|
+
stop: string;
|
|
5
|
+
buffer: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Keeps the palette for one indicator, refreshed when the theme changes.
|
|
9
|
+
* @param onChange - called after the colours change, to redraw
|
|
10
|
+
* @returns the palette getter and a cleanup function
|
|
11
|
+
*/
|
|
12
|
+
export declare const createColors: (onChange: () => void) => {
|
|
13
|
+
get: () => ProgressColors;
|
|
14
|
+
refresh: () => void;
|
|
15
|
+
destroy: () => void;
|
|
16
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { getThemeColor } from "../../../core/utils/index.js";
|
|
2
|
+
import { onThemeChange } from "../../../core/utils/theme.js";
|
|
3
|
+
import { PROGRESS_COLORS } from "../constants.js";
|
|
4
|
+
const FALLBACKS = {
|
|
5
|
+
indicator: "#6750A4",
|
|
6
|
+
track: "#E8DEF8",
|
|
7
|
+
stop: "#6750A4",
|
|
8
|
+
buffer: "#EADDFF",
|
|
9
|
+
};
|
|
10
|
+
const read = () => ({
|
|
11
|
+
indicator: getThemeColor(PROGRESS_COLORS.INDICATOR, { fallback: FALLBACKS.indicator }),
|
|
12
|
+
track: getThemeColor(PROGRESS_COLORS.TRACK, { fallback: FALLBACKS.track }),
|
|
13
|
+
stop: getThemeColor(PROGRESS_COLORS.STOP, { fallback: FALLBACKS.stop }),
|
|
14
|
+
buffer: getThemeColor(PROGRESS_COLORS.BUFFER, { fallback: FALLBACKS.buffer }),
|
|
15
|
+
});
|
|
16
|
+
export const createColors = (onChange) => {
|
|
17
|
+
let colors = FALLBACKS;
|
|
18
|
+
let read_ = false;
|
|
19
|
+
const refresh = () => {
|
|
20
|
+
try {
|
|
21
|
+
colors = read();
|
|
22
|
+
read_ = true;
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const offThemeChange = onThemeChange(() => {
|
|
28
|
+
refresh();
|
|
29
|
+
onChange();
|
|
30
|
+
});
|
|
31
|
+
return {
|
|
32
|
+
get: () => {
|
|
33
|
+
if (!read_)
|
|
34
|
+
refresh();
|
|
35
|
+
return colors;
|
|
36
|
+
},
|
|
37
|
+
refresh,
|
|
38
|
+
destroy: offThemeChange,
|
|
39
|
+
};
|
|
40
|
+
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Progress component features
|
|
3
3
|
* Exports all features used by the progress component
|
|
4
4
|
*/
|
|
5
|
-
export { withCanvas } from
|
|
6
|
-
export { withState } from
|
|
7
|
-
export { drawCircularProgress } from
|
|
8
|
-
export { drawLinearProgress } from
|
|
5
|
+
export { withCanvas } from "./canvas.js";
|
|
6
|
+
export { withState } from "./state.js";
|
|
7
|
+
export { drawCircularProgress } from "./circular.js";
|
|
8
|
+
export { drawLinearProgress } from "./linear.js";
|
|
@@ -1,9 +1,25 @@
|
|
|
1
|
+
import { CanvasContext } from "./canvas.js";
|
|
2
|
+
import { ProgressColors } from "./colors.js";
|
|
3
|
+
/** What a frame of the linear indicator needs */
|
|
4
|
+
export interface LinearFrame {
|
|
5
|
+
/** Progress from 0 to 1; ignored when indeterminate */
|
|
6
|
+
progress: number;
|
|
7
|
+
/** Buffer from 0 to 1, this library's own extension; 0 for none */
|
|
8
|
+
buffer: number;
|
|
9
|
+
indeterminate: boolean;
|
|
10
|
+
/** Track and indicator thickness in pixels */
|
|
11
|
+
strokeWidth: number;
|
|
12
|
+
/** Milliseconds since the animation started */
|
|
13
|
+
time: number;
|
|
14
|
+
/** Wave height in pixels; 0 draws a flat indicator */
|
|
15
|
+
waveAmplitude: number;
|
|
16
|
+
/** Right to left, in which case the indicator runs from the right */
|
|
17
|
+
rtl: boolean;
|
|
18
|
+
colors: ProgressColors;
|
|
19
|
+
/** Whether to mark the end of the track with a dot */
|
|
20
|
+
showStopIndicator: boolean;
|
|
21
|
+
}
|
|
1
22
|
/**
|
|
2
|
-
*
|
|
23
|
+
* Draws one frame of the linear indicator.
|
|
3
24
|
*/
|
|
4
|
-
|
|
5
|
-
import { CanvasContext } from "./canvas";
|
|
6
|
-
/**
|
|
7
|
-
* Draws linear progress on canvas with shape support
|
|
8
|
-
*/
|
|
9
|
-
export declare const drawLinearProgress: (context: CanvasContext, config: ProgressConfig, value: number, max: number, buffer: number, isIndeterminate: boolean, animationTime?: number, showStopIndicator?: boolean, currentShape?: ProgressShape) => void;
|
|
25
|
+
export declare const drawLinearProgress: (context: CanvasContext, frame: LinearFrame) => void;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { linearIndeterminateFrame } from "./motion.js";
|
|
2
|
+
import { PROGRESS_MEASUREMENTS, PROGRESS_WAVE } from "../constants.js";
|
|
3
|
+
const drawBar = (ctx, width, centerY, strokeWidth, from, to, color, rtl, wave) => {
|
|
4
|
+
const start = Math.min(from, to);
|
|
5
|
+
const end = Math.max(from, to);
|
|
6
|
+
if (end - start <= 0)
|
|
7
|
+
return;
|
|
8
|
+
const cap = strokeWidth / 2;
|
|
9
|
+
const toX = (fraction) => {
|
|
10
|
+
const f = rtl ? 1 - fraction : fraction;
|
|
11
|
+
return Math.min(Math.max(f * width, cap), width - cap);
|
|
12
|
+
};
|
|
13
|
+
const x0 = toX(start);
|
|
14
|
+
const x1 = toX(end);
|
|
15
|
+
if (Math.abs(x1 - x0) < 1e-6 && start !== end)
|
|
16
|
+
return;
|
|
17
|
+
ctx.strokeStyle = color;
|
|
18
|
+
ctx.lineWidth = strokeWidth;
|
|
19
|
+
ctx.lineCap = "round";
|
|
20
|
+
ctx.lineJoin = "round";
|
|
21
|
+
ctx.beginPath();
|
|
22
|
+
if (!wave || wave.amplitude <= 0) {
|
|
23
|
+
ctx.moveTo(Math.min(x0, x1), centerY);
|
|
24
|
+
ctx.lineTo(Math.max(x0, x1), centerY);
|
|
25
|
+
ctx.stroke();
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const left = Math.min(x0, x1);
|
|
29
|
+
const right = Math.max(x0, x1);
|
|
30
|
+
const step = Math.max(1, wave.wavelength / 24);
|
|
31
|
+
for (let x = left; x <= right; x += step) {
|
|
32
|
+
const y = centerY + wave.amplitude * Math.sin((2 * Math.PI * (x - wave.phase)) / wave.wavelength);
|
|
33
|
+
if (x === left)
|
|
34
|
+
ctx.moveTo(x, y);
|
|
35
|
+
else
|
|
36
|
+
ctx.lineTo(x, y);
|
|
37
|
+
}
|
|
38
|
+
const endY = centerY + wave.amplitude * Math.sin((2 * Math.PI * (right - wave.phase)) / wave.wavelength);
|
|
39
|
+
ctx.lineTo(right, endY);
|
|
40
|
+
ctx.stroke();
|
|
41
|
+
};
|
|
42
|
+
const drawStopIndicator = (ctx, width, height, color, rtl) => {
|
|
43
|
+
const size = Math.min(PROGRESS_MEASUREMENTS.LINEAR.STOP_INDICATOR, height);
|
|
44
|
+
const offset = Math.min((height - size) / 2, PROGRESS_MEASUREMENTS.LINEAR.STOP_TRAILING_SPACE);
|
|
45
|
+
const x = rtl ? size / 2 + offset : width - size / 2 - offset;
|
|
46
|
+
ctx.fillStyle = color;
|
|
47
|
+
ctx.beginPath();
|
|
48
|
+
ctx.arc(x, height / 2, size / 2, 0, 2 * Math.PI);
|
|
49
|
+
ctx.fill();
|
|
50
|
+
};
|
|
51
|
+
export const drawLinearProgress = (context, frame) => {
|
|
52
|
+
const { ctx, width, height } = context;
|
|
53
|
+
const { strokeWidth, colors, rtl, indeterminate, waveAmplitude } = frame;
|
|
54
|
+
if (width <= 0 || height <= 0)
|
|
55
|
+
return;
|
|
56
|
+
const centerY = height / 2;
|
|
57
|
+
ctx.clearRect(0, 0, width, height);
|
|
58
|
+
const gapPx = PROGRESS_MEASUREMENTS.LINEAR.GAP + strokeWidth;
|
|
59
|
+
const gap = width > 0 ? gapPx / width : 0;
|
|
60
|
+
const wavelength = indeterminate
|
|
61
|
+
? PROGRESS_WAVE.LINEAR.INDETERMINATE_WAVELENGTH
|
|
62
|
+
: PROGRESS_WAVE.LINEAR.WAVELENGTH;
|
|
63
|
+
const wave = waveAmplitude > 0
|
|
64
|
+
? {
|
|
65
|
+
amplitude: waveAmplitude,
|
|
66
|
+
wavelength,
|
|
67
|
+
phase: ((frame.time / 1000) * PROGRESS_WAVE.SPEED * wavelength) % wavelength,
|
|
68
|
+
}
|
|
69
|
+
: undefined;
|
|
70
|
+
const bar = (from, to, color, wavy = false) => drawBar(ctx, width, centerY, strokeWidth, from, to, color, rtl, wavy ? wave : undefined);
|
|
71
|
+
if (indeterminate) {
|
|
72
|
+
const { firstHead, firstTail, secondHead, secondTail } = linearIndeterminateFrame(frame.time);
|
|
73
|
+
if (firstHead < 1 - gap) {
|
|
74
|
+
bar(firstHead > 0 ? firstHead + gap : 0, 1, colors.track);
|
|
75
|
+
}
|
|
76
|
+
if (firstHead - firstTail > 0) {
|
|
77
|
+
bar(firstTail, firstHead, colors.indicator, true);
|
|
78
|
+
}
|
|
79
|
+
if (firstTail > gap) {
|
|
80
|
+
bar(secondHead > 0 ? secondHead + gap : 0, firstTail < 1 ? firstTail - gap : 1, colors.track);
|
|
81
|
+
}
|
|
82
|
+
if (secondHead - secondTail > 0) {
|
|
83
|
+
bar(secondTail, secondHead, colors.indicator, true);
|
|
84
|
+
}
|
|
85
|
+
if (secondTail > gap) {
|
|
86
|
+
bar(0, secondTail - gap, colors.track);
|
|
87
|
+
}
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const progress = Math.min(1, Math.max(0, frame.progress));
|
|
91
|
+
const trackStart = progress + Math.min(progress, gap);
|
|
92
|
+
if (trackStart <= 1) {
|
|
93
|
+
bar(trackStart, 1, colors.track);
|
|
94
|
+
}
|
|
95
|
+
if (frame.buffer > progress) {
|
|
96
|
+
const bufferEnd = Math.min(1, frame.buffer);
|
|
97
|
+
if (bufferEnd > trackStart)
|
|
98
|
+
bar(trackStart, bufferEnd, colors.buffer);
|
|
99
|
+
}
|
|
100
|
+
bar(0, progress, colors.indicator, true);
|
|
101
|
+
if (frame.showStopIndicator) {
|
|
102
|
+
drawStopIndicator(ctx, width, height, colors.stop, rtl);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A cubic Bézier easing, as CSS and Compose define it: the curve through
|
|
3
|
+
* (0,0), (x1,y1), (x2,y2), (1,1), solved for y at a given x.
|
|
4
|
+
*/
|
|
5
|
+
export declare const cubicBezier: (x1: number, y1: number, x2: number, y2: number) => ((t: number) => number);
|
|
6
|
+
export declare const emphasizedAccelerate: (t: number) => number;
|
|
7
|
+
export declare const emphasizedDecelerate: (t: number) => number;
|
|
8
|
+
export declare const standardEasing: (t: number) => number;
|
|
9
|
+
/** Where the two indeterminate bars are, as fractions of the track */
|
|
10
|
+
export interface LinearIndeterminateFrame {
|
|
11
|
+
firstHead: number;
|
|
12
|
+
firstTail: number;
|
|
13
|
+
secondHead: number;
|
|
14
|
+
secondTail: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The linear indeterminate frame at `elapsed` milliseconds: two bars, each
|
|
18
|
+
* from its tail to its head, on the Compose keyframes over a 1750ms cycle.
|
|
19
|
+
*/
|
|
20
|
+
export declare const linearIndeterminateFrame: (elapsed: number) => LinearIndeterminateFrame;
|
|
21
|
+
/** How far round the arc has turned, and how much of the circle it covers */
|
|
22
|
+
export interface CircularIndeterminateFrame {
|
|
23
|
+
/** Rotation of the arc's start, in degrees clockwise from 3 o'clock */
|
|
24
|
+
rotation: number;
|
|
25
|
+
/** Length of the arc as a fraction of the circle */
|
|
26
|
+
sweep: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The circular indeterminate frame at `elapsed` milliseconds: a 1080 degree
|
|
30
|
+
* linear turn over the 6 second cycle, four 90 degree kicks on top of it, and
|
|
31
|
+
* an arc that grows to 87% by half way and shrinks back to 10%.
|
|
32
|
+
*/
|
|
33
|
+
export declare const circularIndeterminateFrame: (elapsed: number) => CircularIndeterminateFrame;
|
|
34
|
+
/**
|
|
35
|
+
* How tall the wave is for a determinate value: flat at both ends of the
|
|
36
|
+
* range, full in between (WavyProgressIndicatorDefaults.indicatorAmplitude).
|
|
37
|
+
*/
|
|
38
|
+
export declare const waveAmplitudeTarget: (progress: number) => number;
|
|
39
|
+
/**
|
|
40
|
+
* The wave's height part way through a change: standard easing on the way in,
|
|
41
|
+
* emphasized accelerate on the way out, over 500ms either way.
|
|
42
|
+
*/
|
|
43
|
+
export declare const waveAmplitudeAt: (from: number, target: number, elapsed: number) => number;
|