@windmorph/react 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/NOTICE +23 -0
- package/README.md +149 -2
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +112 -0
- package/dist/cli.js.map +1 -0
- package/dist/components/app-bar/AppBarItems.js +23 -0
- package/dist/components/app-bar/AppBarItems.js.map +1 -0
- package/dist/components/app-bar/TopAppBar.d.ts +89 -0
- package/dist/components/app-bar/TopAppBar.js +103 -0
- package/dist/components/app-bar/TopAppBar.js.map +1 -0
- package/dist/components/app-bar/app-bar-styles.d.ts +280 -0
- package/dist/components/app-bar/app-bar-styles.js +142 -0
- package/dist/components/app-bar/app-bar-styles.js.map +1 -0
- package/dist/components/app-bar/app-bar-tokens.d.ts +7 -0
- package/dist/components/app-bar/app-bar-tokens.js +64 -0
- package/dist/components/app-bar/app-bar-tokens.js.map +1 -0
- package/dist/components/app-bar/use-app-bar-scroll.d.ts +6 -0
- package/dist/components/app-bar/use-app-bar-scroll.js +139 -0
- package/dist/components/app-bar/use-app-bar-scroll.js.map +1 -0
- package/dist/components/autocomplete/Autocomplete.d.ts +142 -0
- package/dist/components/autocomplete/Autocomplete.js +284 -0
- package/dist/components/autocomplete/Autocomplete.js.map +1 -0
- package/dist/components/badge/Badge.d.ts +71 -0
- package/dist/components/badge/Badge.js +72 -0
- package/dist/components/badge/Badge.js.map +1 -0
- package/dist/components/badge/badge-styles.d.ts +100 -0
- package/dist/components/badge/badge-styles.js +43 -0
- package/dist/components/badge/badge-styles.js.map +1 -0
- package/dist/components/badge/badge-tokens.d.ts +7 -0
- package/dist/components/badge/badge-tokens.js +40 -0
- package/dist/components/badge/badge-tokens.js.map +1 -0
- package/dist/components/button/Button.d.ts +91 -0
- package/dist/components/button/Button.js +96 -0
- package/dist/components/button/Button.js.map +1 -0
- package/dist/components/button/ButtonContext.d.ts +30 -0
- package/dist/components/button/ButtonContext.js +18 -0
- package/dist/components/button/ButtonContext.js.map +1 -0
- package/dist/components/button/DensityZeroButtons.js +25 -0
- package/dist/components/button/DensityZeroButtons.js.map +1 -0
- package/dist/components/button/button-pending.d.ts +10 -0
- package/dist/components/button/button-pending.js +166 -0
- package/dist/components/button/button-pending.js.map +1 -0
- package/dist/components/button/button-styles.d.ts +216 -0
- package/dist/components/button/button-styles.js +199 -0
- package/dist/components/button/button-styles.js.map +1 -0
- package/dist/components/button/button-tokens.d.ts +10 -0
- package/dist/components/button/button-tokens.js +257 -0
- package/dist/components/button/button-tokens.js.map +1 -0
- package/dist/components/button/connected-shapes.js +152 -0
- package/dist/components/button/connected-shapes.js.map +1 -0
- package/dist/components/card/Card.d.ts +60 -0
- package/dist/components/card/Card.js +69 -0
- package/dist/components/card/Card.js.map +1 -0
- package/dist/components/card/card-styles.d.ts +42 -0
- package/dist/components/card/card-styles.js +64 -0
- package/dist/components/card/card-styles.js.map +1 -0
- package/dist/components/card/card-tokens.d.ts +7 -0
- package/dist/components/card/card-tokens.js +84 -0
- package/dist/components/card/card-tokens.js.map +1 -0
- package/dist/components/carousel/Carousel.d.ts +124 -0
- package/dist/components/carousel/Carousel.js +387 -0
- package/dist/components/carousel/Carousel.js.map +1 -0
- package/dist/components/carousel/carousel-keylines.js +486 -0
- package/dist/components/carousel/carousel-keylines.js.map +1 -0
- package/dist/components/carousel/carousel-press-area.js +35 -0
- package/dist/components/carousel/carousel-press-area.js.map +1 -0
- package/dist/components/carousel/carousel-styles.d.ts +188 -0
- package/dist/components/carousel/carousel-styles.js +116 -0
- package/dist/components/carousel/carousel-styles.js.map +1 -0
- package/dist/components/carousel/carousel-tokens.d.ts +7 -0
- package/dist/components/carousel/carousel-tokens.js +18 -0
- package/dist/components/carousel/carousel-tokens.js.map +1 -0
- package/dist/components/checkbox/Checkbox.d.ts +78 -0
- package/dist/components/checkbox/Checkbox.js +77 -0
- package/dist/components/checkbox/Checkbox.js.map +1 -0
- package/dist/components/checkbox/checkbox-box.js +34 -0
- package/dist/components/checkbox/checkbox-box.js.map +1 -0
- package/dist/components/checkbox/checkbox-styles.d.ts +100 -0
- package/dist/components/checkbox/checkbox-styles.js +54 -0
- package/dist/components/checkbox/checkbox-styles.js.map +1 -0
- package/dist/components/checkbox/checkbox-tokens.d.ts +7 -0
- package/dist/components/checkbox/checkbox-tokens.js +41 -0
- package/dist/components/checkbox/checkbox-tokens.js.map +1 -0
- package/dist/components/chip/Chip.d.ts +171 -0
- package/dist/components/chip/Chip.js +348 -0
- package/dist/components/chip/Chip.js.map +1 -0
- package/dist/components/chip/ChipSet.d.ts +70 -0
- package/dist/components/chip/ChipSet.js +198 -0
- package/dist/components/chip/ChipSet.js.map +1 -0
- package/dist/components/chip/chip-styles.d.ts +263 -0
- package/dist/components/chip/chip-styles.js +360 -0
- package/dist/components/chip/chip-styles.js.map +1 -0
- package/dist/components/chip/chip-tokens.d.ts +13 -0
- package/dist/components/chip/chip-tokens.js +185 -0
- package/dist/components/chip/chip-tokens.js.map +1 -0
- package/dist/components/date-picker/CalendarGrid.js +94 -0
- package/dist/components/date-picker/CalendarGrid.js.map +1 -0
- package/dist/components/date-picker/CompactDateDialog.js +63 -0
- package/dist/components/date-picker/CompactDateDialog.js.map +1 -0
- package/dist/components/date-picker/DateField.d.ts +161 -0
- package/dist/components/date-picker/DateField.js +393 -0
- package/dist/components/date-picker/DateField.js.map +1 -0
- package/dist/components/date-picker/DateInput.d.ts +20 -0
- package/dist/components/date-picker/DateInput.js +99 -0
- package/dist/components/date-picker/DateInput.js.map +1 -0
- package/dist/components/date-picker/DatePicker.d.ts +165 -0
- package/dist/components/date-picker/DatePicker.js +492 -0
- package/dist/components/date-picker/DatePicker.js.map +1 -0
- package/dist/components/date-picker/PickerDialog.d.ts +121 -0
- package/dist/components/date-picker/PickerDialog.js +161 -0
- package/dist/components/date-picker/PickerDialog.js.map +1 -0
- package/dist/components/date-picker/calendar-parts.js +141 -0
- package/dist/components/date-picker/calendar-parts.js.map +1 -0
- package/dist/components/date-picker/date-format.js +72 -0
- package/dist/components/date-picker/date-format.js.map +1 -0
- package/dist/components/date-picker/date-picker-styles.d.ts +247 -0
- package/dist/components/date-picker/date-picker-styles.js +163 -0
- package/dist/components/date-picker/date-picker-styles.js.map +1 -0
- package/dist/components/date-picker/date-picker-tokens.d.ts +7 -0
- package/dist/components/date-picker/date-picker-tokens.js +104 -0
- package/dist/components/date-picker/date-picker-tokens.js.map +1 -0
- package/dist/components/date-picker/picker-dialog-context.js +8 -0
- package/dist/components/date-picker/picker-dialog-context.js.map +1 -0
- package/dist/components/date-picker/picker-dialog-styles.d.ts +95 -0
- package/dist/components/date-picker/picker-dialog-styles.js +57 -0
- package/dist/components/date-picker/picker-dialog-styles.js.map +1 -0
- package/dist/components/date-picker/picker-icons.js +24 -0
- package/dist/components/date-picker/picker-icons.js.map +1 -0
- package/dist/components/date-picker/use-media-query.js +21 -0
- package/dist/components/date-picker/use-media-query.js.map +1 -0
- package/dist/components/date-picker/use-size-transform.js +62 -0
- package/dist/components/date-picker/use-size-transform.js.map +1 -0
- package/dist/components/date-picker/use-view-exit.js +68 -0
- package/dist/components/date-picker/use-view-exit.js.map +1 -0
- package/dist/components/dialog/Dialog.d.ts +267 -0
- package/dist/components/dialog/Dialog.js +521 -0
- package/dist/components/dialog/Dialog.js.map +1 -0
- package/dist/components/dialog/dialog-styles.d.ts +335 -0
- package/dist/components/dialog/dialog-styles.js +377 -0
- package/dist/components/dialog/dialog-styles.js.map +1 -0
- package/dist/components/dialog/dialog-tokens.d.ts +7 -0
- package/dist/components/dialog/dialog-tokens.js +57 -0
- package/dist/components/dialog/dialog-tokens.js.map +1 -0
- package/dist/components/divider/Divider.d.ts +59 -0
- package/dist/components/divider/Divider.js +53 -0
- package/dist/components/divider/Divider.js.map +1 -0
- package/dist/components/divider/divider-styles.d.ts +90 -0
- package/dist/components/divider/divider-styles.js +66 -0
- package/dist/components/divider/divider-styles.js.map +1 -0
- package/dist/components/divider/divider-tokens.d.ts +7 -0
- package/dist/components/divider/divider-tokens.js +16 -0
- package/dist/components/divider/divider-tokens.js.map +1 -0
- package/dist/components/fab/Fab.d.ts +130 -0
- package/dist/components/fab/Fab.js +137 -0
- package/dist/components/fab/Fab.js.map +1 -0
- package/dist/components/fab/FabTooltip.js +36 -0
- package/dist/components/fab/FabTooltip.js.map +1 -0
- package/dist/components/fab/fab-styles.d.ts +286 -0
- package/dist/components/fab/fab-styles.js +131 -0
- package/dist/components/fab/fab-styles.js.map +1 -0
- package/dist/components/fab/fab-tokens.d.ts +12 -0
- package/dist/components/fab/fab-tokens.js +105 -0
- package/dist/components/fab/fab-tokens.js.map +1 -0
- package/dist/components/fab-menu/FabMenu.d.ts +156 -0
- package/dist/components/fab-menu/FabMenu.js +291 -0
- package/dist/components/fab-menu/FabMenu.js.map +1 -0
- package/dist/components/fab-menu/fab-menu-stagger.js +51 -0
- package/dist/components/fab-menu/fab-menu-stagger.js.map +1 -0
- package/dist/components/fab-menu/fab-menu-styles.d.ts +166 -0
- package/dist/components/fab-menu/fab-menu-styles.js +107 -0
- package/dist/components/fab-menu/fab-menu-styles.js.map +1 -0
- package/dist/components/fab-menu/fab-menu-tokens.d.ts +7 -0
- package/dist/components/fab-menu/fab-menu-tokens.js +120 -0
- package/dist/components/fab-menu/fab-menu-tokens.js.map +1 -0
- package/dist/components/icon-button/IconButton.d.ts +125 -0
- package/dist/components/icon-button/IconButton.js +112 -0
- package/dist/components/icon-button/IconButton.js.map +1 -0
- package/dist/components/icon-button/icon-button-styles.d.ts +217 -0
- package/dist/components/icon-button/icon-button-styles.js +244 -0
- package/dist/components/icon-button/icon-button-styles.js.map +1 -0
- package/dist/components/icon-button/icon-button-tokens.d.ts +11 -0
- package/dist/components/icon-button/icon-button-tokens.js +215 -0
- package/dist/components/icon-button/icon-button-tokens.js.map +1 -0
- package/dist/components/list/List.d.ts +265 -0
- package/dist/components/list/List.js +1386 -0
- package/dist/components/list/List.js.map +1 -0
- package/dist/components/list/ListMedia.d.ts +88 -0
- package/dist/components/list/ListMedia.js +132 -0
- package/dist/components/list/ListMedia.js.map +1 -0
- package/dist/components/list/list-styles.d.ts +375 -0
- package/dist/components/list/list-styles.js +220 -0
- package/dist/components/list/list-styles.js.map +1 -0
- package/dist/components/list/list-tokens.d.ts +7 -0
- package/dist/components/list/list-tokens.js +92 -0
- package/dist/components/list/list-tokens.js.map +1 -0
- package/dist/components/loading-indicator/LoadingIndicator.d.ts +65 -0
- package/dist/components/loading-indicator/LoadingIndicator.js +92 -0
- package/dist/components/loading-indicator/LoadingIndicator.js.map +1 -0
- package/dist/components/loading-indicator/lazy-loading-indicator.js +25 -0
- package/dist/components/loading-indicator/lazy-loading-indicator.js.map +1 -0
- package/dist/components/loading-indicator/loading-indicator-frames.js +149 -0
- package/dist/components/loading-indicator/loading-indicator-frames.js.map +1 -0
- package/dist/components/loading-indicator/loading-indicator-styles.d.ts +36 -0
- package/dist/components/loading-indicator/loading-indicator-styles.js +22 -0
- package/dist/components/loading-indicator/loading-indicator-styles.js.map +1 -0
- package/dist/components/loading-indicator/loading-indicator-tokens.d.ts +7 -0
- package/dist/components/loading-indicator/loading-indicator-tokens.js +44 -0
- package/dist/components/loading-indicator/loading-indicator-tokens.js.map +1 -0
- package/dist/components/menu/Menu.d.ts +215 -0
- package/dist/components/menu/Menu.js +715 -0
- package/dist/components/menu/Menu.js.map +1 -0
- package/dist/components/menu/menu-styles.d.ts +354 -0
- package/dist/components/menu/menu-styles.js +219 -0
- package/dist/components/menu/menu-styles.js.map +1 -0
- package/dist/components/menu/menu-tokens.d.ts +7 -0
- package/dist/components/menu/menu-tokens.js +93 -0
- package/dist/components/menu/menu-tokens.js.map +1 -0
- package/dist/components/menu/menu-trigger.d.ts +51 -0
- package/dist/components/menu/menu-trigger.js +100 -0
- package/dist/components/menu/menu-trigger.js.map +1 -0
- package/dist/components/menu/use-reveal-entering.js +42 -0
- package/dist/components/menu/use-reveal-entering.js.map +1 -0
- package/dist/components/navigation/NavItem.d.ts +54 -0
- package/dist/components/navigation/NavItem.js +182 -0
- package/dist/components/navigation/NavItem.js.map +1 -0
- package/dist/components/navigation/NavigationBar.d.ts +64 -0
- package/dist/components/navigation/NavigationBar.js +121 -0
- package/dist/components/navigation/NavigationBar.js.map +1 -0
- package/dist/components/navigation/NavigationRail.d.ts +91 -0
- package/dist/components/navigation/NavigationRail.js +285 -0
- package/dist/components/navigation/NavigationRail.js.map +1 -0
- package/dist/components/navigation/nav-item-styles.d.ts +190 -0
- package/dist/components/navigation/nav-item-styles.js +123 -0
- package/dist/components/navigation/nav-item-styles.js.map +1 -0
- package/dist/components/navigation/navigation-styles.d.ts +239 -0
- package/dist/components/navigation/navigation-styles.js +134 -0
- package/dist/components/navigation/navigation-styles.js.map +1 -0
- package/dist/components/navigation/navigation-tokens.d.ts +9 -0
- package/dist/components/navigation/navigation-tokens.js +114 -0
- package/dist/components/navigation/navigation-tokens.js.map +1 -0
- package/dist/components/navigation/use-hide-on-scroll.js +115 -0
- package/dist/components/navigation/use-hide-on-scroll.js.map +1 -0
- package/dist/components/navigation/use-item-arrow-keys.js +37 -0
- package/dist/components/navigation/use-item-arrow-keys.js.map +1 -0
- package/dist/components/navigation/use-rail-item-morph.js +61 -0
- package/dist/components/navigation/use-rail-item-morph.js.map +1 -0
- package/dist/components/progress/ProgressIndicator.d.ts +95 -0
- package/dist/components/progress/ProgressIndicator.js +426 -0
- package/dist/components/progress/ProgressIndicator.js.map +1 -0
- package/dist/components/progress/progress-geometry.js +285 -0
- package/dist/components/progress/progress-geometry.js.map +1 -0
- package/dist/components/progress/progress-styles.d.ts +81 -0
- package/dist/components/progress/progress-styles.js +43 -0
- package/dist/components/progress/progress-styles.js.map +1 -0
- package/dist/components/progress/progress-tokens.d.ts +7 -0
- package/dist/components/progress/progress-tokens.js +39 -0
- package/dist/components/progress/progress-tokens.js.map +1 -0
- package/dist/components/pull-to-refresh/PullToRefresh.d.ts +94 -0
- package/dist/components/pull-to-refresh/PullToRefresh.js +395 -0
- package/dist/components/pull-to-refresh/PullToRefresh.js.map +1 -0
- package/dist/components/pull-to-refresh/pull-to-refresh-math.js +37 -0
- package/dist/components/pull-to-refresh/pull-to-refresh-math.js.map +1 -0
- package/dist/components/pull-to-refresh/pull-to-refresh-styles.d.ts +53 -0
- package/dist/components/pull-to-refresh/pull-to-refresh-styles.js +14 -0
- package/dist/components/pull-to-refresh/pull-to-refresh-styles.js.map +1 -0
- package/dist/components/radio/RadioGroup.d.ts +121 -0
- package/dist/components/radio/RadioGroup.js +163 -0
- package/dist/components/radio/RadioGroup.js.map +1 -0
- package/dist/components/radio/radio-ring.js +21 -0
- package/dist/components/radio/radio-ring.js.map +1 -0
- package/dist/components/radio/radio-styles.d.ts +155 -0
- package/dist/components/radio/radio-styles.js +60 -0
- package/dist/components/radio/radio-styles.js.map +1 -0
- package/dist/components/radio/radio-tokens.d.ts +7 -0
- package/dist/components/radio/radio-tokens.js +31 -0
- package/dist/components/radio/radio-tokens.js.map +1 -0
- package/dist/components/search/SearchAppBar.d.ts +45 -0
- package/dist/components/search/SearchAppBar.js +61 -0
- package/dist/components/search/SearchAppBar.js.map +1 -0
- package/dist/components/search/SearchBar.d.ts +147 -0
- package/dist/components/search/SearchBar.js +412 -0
- package/dist/components/search/SearchBar.js.map +1 -0
- package/dist/components/search/search-styles.d.ts +243 -0
- package/dist/components/search/search-styles.js +143 -0
- package/dist/components/search/search-styles.js.map +1 -0
- package/dist/components/search/search-tokens.d.ts +9 -0
- package/dist/components/search/search-tokens.js +70 -0
- package/dist/components/search/search-tokens.js.map +1 -0
- package/dist/components/select/Select.d.ts +187 -0
- package/dist/components/select/Select.js +319 -0
- package/dist/components/select/Select.js.map +1 -0
- package/dist/components/select/field-shell.d.ts +29 -0
- package/dist/components/select/field-shell.js +135 -0
- package/dist/components/select/field-shell.js.map +1 -0
- package/dist/components/select/option-list.d.ts +81 -0
- package/dist/components/select/option-list.js +291 -0
- package/dist/components/select/option-list.js.map +1 -0
- package/dist/components/select/search-list.js +135 -0
- package/dist/components/select/search-list.js.map +1 -0
- package/dist/components/select/selection-cap.js +30 -0
- package/dist/components/select/selection-cap.js.map +1 -0
- package/dist/components/sheet/BottomSheet.d.ts +154 -0
- package/dist/components/sheet/BottomSheet.js +442 -0
- package/dist/components/sheet/BottomSheet.js.map +1 -0
- package/dist/components/sheet/SheetTrigger.d.ts +25 -0
- package/dist/components/sheet/SheetTrigger.js +46 -0
- package/dist/components/sheet/SheetTrigger.js.map +1 -0
- package/dist/components/sheet/SideSheet.d.ts +139 -0
- package/dist/components/sheet/SideSheet.js +289 -0
- package/dist/components/sheet/SideSheet.js.map +1 -0
- package/dist/components/sheet/bottom-sheet-gesture.js +30 -0
- package/dist/components/sheet/bottom-sheet-gesture.js.map +1 -0
- package/dist/components/sheet/lazy-bottom-sheet.js +33 -0
- package/dist/components/sheet/lazy-bottom-sheet.js.map +1 -0
- package/dist/components/sheet/sheet-gesture.js +48 -0
- package/dist/components/sheet/sheet-gesture.js.map +1 -0
- package/dist/components/sheet/sheet-icons.js +31 -0
- package/dist/components/sheet/sheet-icons.js.map +1 -0
- package/dist/components/sheet/sheet-settle.js +58 -0
- package/dist/components/sheet/sheet-settle.js.map +1 -0
- package/dist/components/sheet/sheet-styles.d.ts +312 -0
- package/dist/components/sheet/sheet-styles.js +229 -0
- package/dist/components/sheet/sheet-styles.js.map +1 -0
- package/dist/components/sheet/sheet-tokens.d.ts +12 -0
- package/dist/components/sheet/sheet-tokens.js +115 -0
- package/dist/components/sheet/sheet-tokens.js.map +1 -0
- package/dist/components/sheet/side-swipe-gesture.js +22 -0
- package/dist/components/sheet/side-swipe-gesture.js.map +1 -0
- package/dist/components/sheet/use-peek-inert.js +32 -0
- package/dist/components/sheet/use-peek-inert.js.map +1 -0
- package/dist/components/sheet/use-side-swipe.js +174 -0
- package/dist/components/sheet/use-side-swipe.js.map +1 -0
- package/dist/components/slider/Slider.d.ts +129 -0
- package/dist/components/slider/Slider.js +295 -0
- package/dist/components/slider/Slider.js.map +1 -0
- package/dist/components/slider/slider-geometry.js +138 -0
- package/dist/components/slider/slider-geometry.js.map +1 -0
- package/dist/components/slider/slider-styles.d.ts +133 -0
- package/dist/components/slider/slider-styles.js +97 -0
- package/dist/components/slider/slider-styles.js.map +1 -0
- package/dist/components/slider/slider-tokens.d.ts +7 -0
- package/dist/components/slider/slider-tokens.js +66 -0
- package/dist/components/slider/slider-tokens.js.map +1 -0
- package/dist/components/slider/use-touch-track.js +138 -0
- package/dist/components/slider/use-touch-track.js.map +1 -0
- package/dist/components/snackbar/Snackbar.d.ts +96 -0
- package/dist/components/snackbar/Snackbar.js +253 -0
- package/dist/components/snackbar/Snackbar.js.map +1 -0
- package/dist/components/snackbar/snackbar-state.d.ts +58 -0
- package/dist/components/snackbar/snackbar-state.js +73 -0
- package/dist/components/snackbar/snackbar-state.js.map +1 -0
- package/dist/components/snackbar/snackbar-styles.d.ts +109 -0
- package/dist/components/snackbar/snackbar-styles.js +67 -0
- package/dist/components/snackbar/snackbar-styles.js.map +1 -0
- package/dist/components/snackbar/snackbar-tokens.d.ts +7 -0
- package/dist/components/snackbar/snackbar-tokens.js +54 -0
- package/dist/components/snackbar/snackbar-tokens.js.map +1 -0
- package/dist/components/split-button/SplitButton.d.ts +109 -0
- package/dist/components/split-button/SplitButton.js +195 -0
- package/dist/components/split-button/SplitButton.js.map +1 -0
- package/dist/components/split-button/split-button-styles.d.ts +214 -0
- package/dist/components/split-button/split-button-styles.js +164 -0
- package/dist/components/split-button/split-button-styles.js.map +1 -0
- package/dist/components/split-button/split-button-tokens.d.ts +7 -0
- package/dist/components/split-button/split-button-tokens.js +36 -0
- package/dist/components/split-button/split-button-tokens.js.map +1 -0
- package/dist/components/switch/Switch.d.ts +82 -0
- package/dist/components/switch/Switch.js +165 -0
- package/dist/components/switch/Switch.js.map +1 -0
- package/dist/components/switch/switch-styles.d.ts +96 -0
- package/dist/components/switch/switch-styles.js +68 -0
- package/dist/components/switch/switch-styles.js.map +1 -0
- package/dist/components/switch/switch-thumb.js +41 -0
- package/dist/components/switch/switch-thumb.js.map +1 -0
- package/dist/components/switch/switch-tokens.d.ts +7 -0
- package/dist/components/switch/switch-tokens.js +78 -0
- package/dist/components/switch/switch-tokens.js.map +1 -0
- package/dist/components/tabs/Tabs.d.ts +120 -0
- package/dist/components/tabs/Tabs.js +346 -0
- package/dist/components/tabs/Tabs.js.map +1 -0
- package/dist/components/tabs/tabs-styles.d.ts +198 -0
- package/dist/components/tabs/tabs-styles.js +99 -0
- package/dist/components/tabs/tabs-styles.js.map +1 -0
- package/dist/components/tabs/tabs-tokens.d.ts +7 -0
- package/dist/components/tabs/tabs-tokens.js +121 -0
- package/dist/components/tabs/tabs-tokens.js.map +1 -0
- package/dist/components/text-field/TextField.d.ts +175 -0
- package/dist/components/text-field/TextField.js +250 -0
- package/dist/components/text-field/TextField.js.map +1 -0
- package/dist/components/text-field/text-field-styles.d.ts +252 -0
- package/dist/components/text-field/text-field-styles.js +209 -0
- package/dist/components/text-field/text-field-styles.js.map +1 -0
- package/dist/components/text-field/text-field-tokens.d.ts +7 -0
- package/dist/components/text-field/text-field-tokens.js +177 -0
- package/dist/components/text-field/text-field-tokens.js.map +1 -0
- package/dist/components/time-picker/TimePicker.d.ts +142 -0
- package/dist/components/time-picker/TimePicker.js +700 -0
- package/dist/components/time-picker/TimePicker.js.map +1 -0
- package/dist/components/time-picker/time-picker-styles.d.ts +175 -0
- package/dist/components/time-picker/time-picker-styles.js +112 -0
- package/dist/components/time-picker/time-picker-styles.js.map +1 -0
- package/dist/components/time-picker/time-picker-tokens.d.ts +7 -0
- package/dist/components/time-picker/time-picker-tokens.js +86 -0
- package/dist/components/time-picker/time-picker-tokens.js.map +1 -0
- package/dist/components/toolbar/Toolbar.d.ts +209 -0
- package/dist/components/toolbar/Toolbar.js +282 -0
- package/dist/components/toolbar/Toolbar.js.map +1 -0
- package/dist/components/toolbar/toolbar-styles.d.ts +403 -0
- package/dist/components/toolbar/toolbar-styles.js +253 -0
- package/dist/components/toolbar/toolbar-styles.js.map +1 -0
- package/dist/components/toolbar/toolbar-tokens.d.ts +27 -0
- package/dist/components/toolbar/toolbar-tokens.js +117 -0
- package/dist/components/toolbar/toolbar-tokens.js.map +1 -0
- package/dist/components/toolbar/use-toolbar-scroll-expansion.d.ts +56 -0
- package/dist/components/toolbar/use-toolbar-scroll-expansion.js +86 -0
- package/dist/components/toolbar/use-toolbar-scroll-expansion.js.map +1 -0
- package/dist/components/tooltip/Tooltip.d.ts +131 -0
- package/dist/components/tooltip/Tooltip.js +388 -0
- package/dist/components/tooltip/Tooltip.js.map +1 -0
- package/dist/components/tooltip/lazy-tooltip.js +35 -0
- package/dist/components/tooltip/lazy-tooltip.js.map +1 -0
- package/dist/components/tooltip/tooltip-placement.d.ts +16 -0
- package/dist/components/tooltip/tooltip-placement.js +14 -0
- package/dist/components/tooltip/tooltip-placement.js.map +1 -0
- package/dist/components/tooltip/tooltip-styles.d.ts +142 -0
- package/dist/components/tooltip/tooltip-styles.js +81 -0
- package/dist/components/tooltip/tooltip-styles.js.map +1 -0
- package/dist/components/tooltip/tooltip-tokens.d.ts +9 -0
- package/dist/components/tooltip/tooltip-tokens.js +72 -0
- package/dist/components/tooltip/tooltip-tokens.js.map +1 -0
- package/dist/components/tooltip/tooltip-trigger.d.ts +42 -0
- package/dist/components/tooltip/tooltip-trigger.js +115 -0
- package/dist/components/tooltip/tooltip-trigger.js.map +1 -0
- package/dist/composites/button-group/ButtonGroup.d.ts +116 -0
- package/dist/composites/button-group/ButtonGroup.js +270 -0
- package/dist/composites/button-group/ButtonGroup.js.map +1 -0
- package/dist/composites/button-group/button-group-styles.d.ts +73 -0
- package/dist/composites/button-group/button-group-styles.js +87 -0
- package/dist/composites/button-group/button-group-styles.js.map +1 -0
- package/dist/composites/button-group/lazy-overflow-menu.js +43 -0
- package/dist/composites/button-group/lazy-overflow-menu.js.map +1 -0
- package/dist/composites/button-group/overflow-menu-list.js +26 -0
- package/dist/composites/button-group/overflow-menu-list.js.map +1 -0
- package/dist/composites/button-group/use-overflow.js +75 -0
- package/dist/composites/button-group/use-overflow.js.map +1 -0
- package/dist/composites/button-group/use-press-expansion.js +155 -0
- package/dist/composites/button-group/use-press-expansion.js.map +1 -0
- package/dist/index.d.ts +142 -0
- package/dist/index.js +136 -0
- package/dist/motion/get-m3-spring.d.ts +6 -0
- package/dist/motion/get-m3-spring.js +10 -0
- package/dist/motion/get-m3-spring.js.map +1 -0
- package/dist/motion/reduced-motion.js +19 -0
- package/dist/motion/reduced-motion.js.map +1 -0
- package/dist/motion/use-m3-spring.d.ts +13 -0
- package/dist/motion/use-m3-spring.js +22 -0
- package/dist/motion/use-m3-spring.js.map +1 -0
- package/dist/next/NextRouterProvider.d.ts +13 -0
- package/dist/next/NextRouterProvider.js +26 -0
- package/dist/next/NextRouterProvider.js.map +1 -0
- package/dist/next/get-theme-from-cookies.d.ts +32 -0
- package/dist/next/get-theme-from-cookies.js +27 -0
- package/dist/next/get-theme-from-cookies.js.map +1 -0
- package/dist/next/navigation-guard.d.ts +30 -0
- package/dist/next/navigation-guard.js +68 -0
- package/dist/next/navigation-guard.js.map +1 -0
- package/dist/next.d.ts +5 -0
- package/dist/next.js +5 -0
- package/dist/primitives/ButtonBase.d.ts +115 -0
- package/dist/primitives/ButtonBase.js +231 -0
- package/dist/primitives/ButtonBase.js.map +1 -0
- package/dist/primitives/DomDirectionLocale.d.ts +18 -0
- package/dist/primitives/DomDirectionLocale.js +28 -0
- package/dist/primitives/DomDirectionLocale.js.map +1 -0
- package/dist/primitives/Field.d.ts +50 -0
- package/dist/primitives/Field.js +74 -0
- package/dist/primitives/Field.js.map +1 -0
- package/dist/primitives/IconFaces.js +23 -0
- package/dist/primitives/IconFaces.js.map +1 -0
- package/dist/primitives/Overlay.d.ts +39 -0
- package/dist/primitives/Overlay.js +86 -0
- package/dist/primitives/Overlay.js.map +1 -0
- package/dist/primitives/SelectionControl.d.ts +55 -0
- package/dist/primitives/SelectionControl.js +58 -0
- package/dist/primitives/SelectionControl.js.map +1 -0
- package/dist/primitives/Surface.d.ts +123 -0
- package/dist/primitives/Surface.js +68 -0
- package/dist/primitives/Surface.js.map +1 -0
- package/dist/primitives/ToolbarContext.js +12 -0
- package/dist/primitives/ToolbarContext.js.map +1 -0
- package/dist/primitives/TouchTarget.d.ts +14 -0
- package/dist/primitives/TouchTarget.js +20 -0
- package/dist/primitives/TouchTarget.js.map +1 -0
- package/dist/primitives/TriggerContext.d.ts +34 -0
- package/dist/primitives/TriggerContext.js +24 -0
- package/dist/primitives/TriggerContext.js.map +1 -0
- package/dist/primitives/hidden-input-focus.js +27 -0
- package/dist/primitives/hidden-input-focus.js.map +1 -0
- package/dist/primitives/icon-faces-styles.d.ts +9 -0
- package/dist/primitives/icon-faces-styles.js +45 -0
- package/dist/primitives/icon-faces-styles.js.map +1 -0
- package/dist/primitives/locale-with-direction.d.ts +9 -0
- package/dist/primitives/locale-with-direction.js +17 -0
- package/dist/primitives/locale-with-direction.js.map +1 -0
- package/dist/primitives/morph-path.d.ts +25 -0
- package/dist/primitives/morph-path.js +38 -0
- package/dist/primitives/morph-path.js.map +1 -0
- package/dist/primitives/selection-control-styles.d.ts +54 -0
- package/dist/primitives/selection-control-styles.js +44 -0
- package/dist/primitives/selection-control-styles.js.map +1 -0
- package/dist/primitives/use-m3-interaction.d.ts +51 -0
- package/dist/primitives/use-m3-interaction.js +149 -0
- package/dist/primitives/use-m3-interaction.js.map +1 -0
- package/dist/primitives/use-m3-morph.d.ts +18 -0
- package/dist/primitives/use-m3-morph.js +36 -0
- package/dist/primitives/use-m3-morph.js.map +1 -0
- package/dist/primitives/use-presence.d.ts +19 -0
- package/dist/primitives/use-presence.js +37 -0
- package/dist/primitives/use-presence.js.map +1 -0
- package/dist/primitives.d.ts +36 -0
- package/dist/primitives.js +34 -0
- package/dist/shapes/corner-rounding.d.ts +13 -0
- package/dist/shapes/corner-rounding.js +18 -0
- package/dist/shapes/corner-rounding.js.map +1 -0
- package/dist/shapes/cubic.d.ts +52 -0
- package/dist/shapes/cubic.js +189 -0
- package/dist/shapes/cubic.js.map +1 -0
- package/dist/shapes/feature-mapping.js +80 -0
- package/dist/shapes/feature-mapping.js.map +1 -0
- package/dist/shapes/features.d.ts +23 -0
- package/dist/shapes/features.js +82 -0
- package/dist/shapes/features.js.map +1 -0
- package/dist/shapes/float-mapping.js +65 -0
- package/dist/shapes/float-mapping.js.map +1 -0
- package/dist/shapes/generated/material-shape-path-record.d.ts +11 -0
- package/dist/shapes/generated/material-shape-path-record.js +48 -0
- package/dist/shapes/generated/material-shape-path-record.js.map +1 -0
- package/dist/shapes/generated/material-shape-paths.d.ts +78 -0
- package/dist/shapes/generated/material-shape-paths.js +218 -0
- package/dist/shapes/generated/material-shape-paths.js.map +1 -0
- package/dist/shapes/mask.d.ts +14 -0
- package/dist/shapes/mask.js +24 -0
- package/dist/shapes/mask.js.map +1 -0
- package/dist/shapes/material-shapes.d.ts +11 -0
- package/dist/shapes/material-shapes.js +250 -0
- package/dist/shapes/material-shapes.js.map +1 -0
- package/dist/shapes/morph.d.ts +25 -0
- package/dist/shapes/morph.js +97 -0
- package/dist/shapes/morph.js.map +1 -0
- package/dist/shapes/path.d.ts +33 -0
- package/dist/shapes/path.js +47 -0
- package/dist/shapes/path.js.map +1 -0
- package/dist/shapes/point.d.ts +28 -0
- package/dist/shapes/point.js +103 -0
- package/dist/shapes/point.js.map +1 -0
- package/dist/shapes/polygon-measure.js +140 -0
- package/dist/shapes/polygon-measure.js.map +1 -0
- package/dist/shapes/rounded-polygon.d.ts +44 -0
- package/dist/shapes/rounded-polygon.js +278 -0
- package/dist/shapes/rounded-polygon.js.map +1 -0
- package/dist/shapes/shape-path.d.ts +15 -0
- package/dist/shapes/shapes.d.ts +53 -0
- package/dist/shapes/shapes.js +171 -0
- package/dist/shapes/shapes.js.map +1 -0
- package/dist/styles/generated/components.css +710 -0
- package/dist/styles/generated/theme.css +247 -0
- package/dist/styles/generated/themes.css +3361 -0
- package/dist/styles/generated/tokens.css +284 -0
- package/dist/styles/styles.css +15 -0
- package/dist/styles/utilities.css +283 -0
- package/dist/styles.compiled.css +2 -0
- package/dist/theme/ThemeProvider.d.ts +72 -0
- package/dist/theme/ThemeProvider.js +144 -0
- package/dist/theme/ThemeProvider.js.map +1 -0
- package/dist/theme/ThemeScope.d.ts +32 -0
- package/dist/theme/ThemeScope.js +67 -0
- package/dist/theme/ThemeScope.js.map +1 -0
- package/dist/theme/ThemeScript.d.ts +26 -0
- package/dist/theme/ThemeScript.js +44 -0
- package/dist/theme/ThemeScript.js.map +1 -0
- package/dist/theme/context.d.ts +32 -0
- package/dist/theme/context.js +47 -0
- package/dist/theme/context.js.map +1 -0
- package/dist/theme/create-theme.d.ts +60 -0
- package/dist/theme/create-theme.js +47 -0
- package/dist/theme/create-theme.js.map +1 -0
- package/dist/theme/css.js +54 -0
- package/dist/theme/css.js.map +1 -0
- package/dist/theme/parse-palettes.js +40 -0
- package/dist/theme/parse-palettes.js.map +1 -0
- package/dist/theme/scheme.d.ts +6 -0
- package/dist/theme/scheme.js +118 -0
- package/dist/theme/scheme.js.map +1 -0
- package/dist/theme/state.d.ts +38 -0
- package/dist/theme/state.js +93 -0
- package/dist/theme/state.js.map +1 -0
- package/dist/theme/storage.js +21 -0
- package/dist/theme/storage.js.map +1 -0
- package/dist/tokens/breakpoints.d.ts +15 -0
- package/dist/tokens/breakpoints.js +16 -0
- package/dist/tokens/breakpoints.js.map +1 -0
- package/dist/tokens/color.d.ts +104 -0
- package/dist/tokens/color.js +147 -0
- package/dist/tokens/color.js.map +1 -0
- package/dist/tokens/component.d.ts +110 -0
- package/dist/tokens/component.js +67 -0
- package/dist/tokens/component.js.map +1 -0
- package/dist/tokens/density.d.ts +20 -0
- package/dist/tokens/density.js +27 -0
- package/dist/tokens/density.js.map +1 -0
- package/dist/tokens/elevation.d.ts +44 -0
- package/dist/tokens/elevation.js +45 -0
- package/dist/tokens/elevation.js.map +1 -0
- package/dist/tokens/motion.d.ts +79 -0
- package/dist/tokens/motion.js +126 -0
- package/dist/tokens/motion.js.map +1 -0
- package/dist/tokens/shape.d.ts +22 -0
- package/dist/tokens/shape.js +22 -0
- package/dist/tokens/shape.js.map +1 -0
- package/dist/tokens/spring-velocity.d.ts +19 -0
- package/dist/tokens/spring-velocity.js +44 -0
- package/dist/tokens/spring-velocity.js.map +1 -0
- package/dist/tokens/state.d.ts +18 -0
- package/dist/tokens/state.js +19 -0
- package/dist/tokens/state.js.map +1 -0
- package/dist/tokens/typography.d.ts +64 -0
- package/dist/tokens/typography.js +60 -0
- package/dist/tokens/typography.js.map +1 -0
- package/dist/tokens/z-index.d.ts +17 -0
- package/dist/tokens/z-index.js +18 -0
- package/dist/tokens/z-index.js.map +1 -0
- package/dist/utils/announce.js +51 -0
- package/dist/utils/announce.js.map +1 -0
- package/dist/utils/assert-collection-children.js +26 -0
- package/dist/utils/assert-collection-children.js.map +1 -0
- package/dist/utils/closed-by.d.ts +9 -0
- package/dist/utils/closed-by.js +12 -0
- package/dist/utils/closed-by.js.map +1 -0
- package/dist/utils/cn.d.ts +31 -0
- package/dist/utils/cn.js +37 -0
- package/dist/utils/cn.js.map +1 -0
- package/dist/utils/composite-keys.js +32 -0
- package/dist/utils/composite-keys.js.map +1 -0
- package/dist/utils/focus-visible.js +14 -0
- package/dist/utils/focus-visible.js.map +1 -0
- package/dist/utils/focus.js +51 -0
- package/dist/utils/focus.js.map +1 -0
- package/dist/utils/focusable-disabled.js +12 -0
- package/dist/utils/focusable-disabled.js.map +1 -0
- package/dist/utils/keep-pressed-in-place.d.ts +60 -0
- package/dist/utils/keep-pressed-in-place.js +127 -0
- package/dist/utils/keep-pressed-in-place.js.map +1 -0
- package/dist/utils/load-on-demand.js +111 -0
- package/dist/utils/load-on-demand.js.map +1 -0
- package/dist/utils/merge-data-tokens.d.ts +9 -0
- package/dist/utils/merge-data-tokens.js +15 -0
- package/dist/utils/merge-data-tokens.js.map +1 -0
- package/dist/utils/natural-size.js +53 -0
- package/dist/utils/natural-size.js.map +1 -0
- package/dist/utils/nearest-reveal.js +28 -0
- package/dist/utils/nearest-reveal.js.map +1 -0
- package/dist/utils/placement.js +14 -0
- package/dist/utils/placement.js.map +1 -0
- package/dist/utils/radio-group-keys.js +74 -0
- package/dist/utils/radio-group-keys.js.map +1 -0
- package/dist/utils/rendered-description.js +17 -0
- package/dist/utils/rendered-description.js.map +1 -0
- package/dist/utils/root-props.d.ts +103 -0
- package/dist/utils/root-props.js +51 -0
- package/dist/utils/root-props.js.map +1 -0
- package/dist/utils/search.d.ts +11 -0
- package/dist/utils/search.js +18 -0
- package/dist/utils/search.js.map +1 -0
- package/dist/utils/shortcut.js +20 -0
- package/dist/utils/shortcut.js.map +1 -0
- package/dist/utils/split-data-attributes.d.ts +12 -0
- package/dist/utils/split-data-attributes.js +20 -0
- package/dist/utils/split-data-attributes.js.map +1 -0
- package/dist/utils/toolbar-keys.js +28 -0
- package/dist/utils/toolbar-keys.js.map +1 -0
- package/dist/utils/tv.d.ts +7 -0
- package/dist/utils/tv.js +9 -0
- package/dist/utils/tv.js.map +1 -0
- package/dist/utils/typeahead.js +64 -0
- package/dist/utils/typeahead.js.map +1 -0
- package/dist/utils/warn-once.js +30 -0
- package/dist/utils/warn-once.js.map +1 -0
- package/dist/vendor/material-color-utilities/blend/blend.js +88 -0
- package/dist/vendor/material-color-utilities/blend/blend.js.map +1 -0
- package/dist/vendor/material-color-utilities/contrast/contrast.js +131 -0
- package/dist/vendor/material-color-utilities/contrast/contrast.js.map +1 -0
- package/dist/vendor/material-color-utilities/dislike/dislike_analyzer.js +58 -0
- package/dist/vendor/material-color-utilities/dislike/dislike_analyzer.js.map +1 -0
- package/dist/vendor/material-color-utilities/dynamiccolor/color_spec_2021.js +620 -0
- package/dist/vendor/material-color-utilities/dynamiccolor/color_spec_2021.js.map +1 -0
- package/dist/vendor/material-color-utilities/dynamiccolor/color_spec_2025.js +786 -0
- package/dist/vendor/material-color-utilities/dynamiccolor/color_spec_2025.js.map +1 -0
- package/dist/vendor/material-color-utilities/dynamiccolor/contrast_curve.js +59 -0
- package/dist/vendor/material-color-utilities/dynamiccolor/contrast_curve.js.map +1 -0
- package/dist/vendor/material-color-utilities/dynamiccolor/dynamic_color.js +420 -0
- package/dist/vendor/material-color-utilities/dynamiccolor/dynamic_color.js.map +1 -0
- package/dist/vendor/material-color-utilities/dynamiccolor/dynamic_scheme.js +701 -0
- package/dist/vendor/material-color-utilities/dynamiccolor/dynamic_scheme.js.map +1 -0
- package/dist/vendor/material-color-utilities/dynamiccolor/material_dynamic_colors.js +374 -0
- package/dist/vendor/material-color-utilities/dynamiccolor/material_dynamic_colors.js.map +1 -0
- package/dist/vendor/material-color-utilities/dynamiccolor/tone_delta_pair.js +65 -0
- package/dist/vendor/material-color-utilities/dynamiccolor/tone_delta_pair.js.map +1 -0
- package/dist/vendor/material-color-utilities/dynamiccolor/variant.js +38 -0
- package/dist/vendor/material-color-utilities/dynamiccolor/variant.js.map +1 -0
- package/dist/vendor/material-color-utilities/hct/cam16.js +309 -0
- package/dist/vendor/material-color-utilities/hct/cam16.js.map +1 -0
- package/dist/vendor/material-color-utilities/hct/hct.js +148 -0
- package/dist/vendor/material-color-utilities/hct/hct.js.map +1 -0
- package/dist/vendor/material-color-utilities/hct/hct_solver.js +660 -0
- package/dist/vendor/material-color-utilities/hct/hct_solver.js.map +1 -0
- package/dist/vendor/material-color-utilities/hct/viewing_conditions.js +117 -0
- package/dist/vendor/material-color-utilities/hct/viewing_conditions.js.map +1 -0
- package/dist/vendor/material-color-utilities/index.js +51 -0
- package/dist/vendor/material-color-utilities/index.js.map +1 -0
- package/dist/vendor/material-color-utilities/palettes/core_palette.js +22 -0
- package/dist/vendor/material-color-utilities/palettes/core_palette.js.map +1 -0
- package/dist/vendor/material-color-utilities/palettes/tonal_palette.js +134 -0
- package/dist/vendor/material-color-utilities/palettes/tonal_palette.js.map +1 -0
- package/dist/vendor/material-color-utilities/scheme/scheme.js +21 -0
- package/dist/vendor/material-color-utilities/scheme/scheme.js.map +1 -0
- package/dist/vendor/material-color-utilities/scheme/scheme_android.js +21 -0
- package/dist/vendor/material-color-utilities/scheme/scheme_android.js.map +1 -0
- package/dist/vendor/material-color-utilities/scheme/scheme_content.js +22 -0
- package/dist/vendor/material-color-utilities/scheme/scheme_content.js.map +1 -0
- package/dist/vendor/material-color-utilities/scheme/scheme_expressive.js +38 -0
- package/dist/vendor/material-color-utilities/scheme/scheme_expressive.js.map +1 -0
- package/dist/vendor/material-color-utilities/scheme/scheme_fidelity.js +22 -0
- package/dist/vendor/material-color-utilities/scheme/scheme_fidelity.js.map +1 -0
- package/dist/vendor/material-color-utilities/scheme/scheme_fruit_salad.js +22 -0
- package/dist/vendor/material-color-utilities/scheme/scheme_fruit_salad.js.map +1 -0
- package/dist/vendor/material-color-utilities/scheme/scheme_monochrome.js +22 -0
- package/dist/vendor/material-color-utilities/scheme/scheme_monochrome.js.map +1 -0
- package/dist/vendor/material-color-utilities/scheme/scheme_neutral.js +36 -0
- package/dist/vendor/material-color-utilities/scheme/scheme_neutral.js.map +1 -0
- package/dist/vendor/material-color-utilities/scheme/scheme_rainbow.js +22 -0
- package/dist/vendor/material-color-utilities/scheme/scheme_rainbow.js.map +1 -0
- package/dist/vendor/material-color-utilities/scheme/scheme_tonal_spot.js +41 -0
- package/dist/vendor/material-color-utilities/scheme/scheme_tonal_spot.js.map +1 -0
- package/dist/vendor/material-color-utilities/scheme/scheme_vibrant.js +39 -0
- package/dist/vendor/material-color-utilities/scheme/scheme_vibrant.js.map +1 -0
- package/dist/vendor/material-color-utilities/score/score.js +115 -0
- package/dist/vendor/material-color-utilities/score/score.js.map +1 -0
- package/dist/vendor/material-color-utilities/temperature/temperature_cache.js +227 -0
- package/dist/vendor/material-color-utilities/temperature/temperature_cache.js.map +1 -0
- package/dist/vendor/material-color-utilities/utils/color_utils.js +246 -0
- package/dist/vendor/material-color-utilities/utils/color_utils.js.map +1 -0
- package/dist/vendor/material-color-utilities/utils/image_utils.js +21 -0
- package/dist/vendor/material-color-utilities/utils/image_utils.js.map +1 -0
- package/dist/vendor/material-color-utilities/utils/math_utils.js +119 -0
- package/dist/vendor/material-color-utilities/utils/math_utils.js.map +1 -0
- package/dist/vendor/material-color-utilities/utils/string_utils.js +74 -0
- package/dist/vendor/material-color-utilities/utils/string_utils.js.map +1 -0
- package/dist/vendor/material-color-utilities/utils/theme_utils.js +24 -0
- package/dist/vendor/material-color-utilities/utils/theme_utils.js.map +1 -0
- package/package.json +114 -3
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Point, PointTransformer } from "./point.js";
|
|
2
|
+
//#region src/shapes/cubic.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* A cubic Bézier curve: two anchor points and two control points, stored as
|
|
5
|
+
* `[anchor0X, anchor0Y, control0X, control0Y, control1X, control1Y, anchor1X, anchor1Y]`.
|
|
6
|
+
*/
|
|
7
|
+
export declare class Cubic {
|
|
8
|
+
readonly points: number[];
|
|
9
|
+
constructor(points?: readonly number[]);
|
|
10
|
+
static of(anchor0X: number, anchor0Y: number, control0X: number, control0Y: number, control1X: number, control1Y: number, anchor1X: number, anchor1Y: number): Cubic;
|
|
11
|
+
static fromPoints(anchor0: Point, control0: Point, control1: Point, anchor1: Point): Cubic;
|
|
12
|
+
get anchor0X(): number;
|
|
13
|
+
get anchor0Y(): number;
|
|
14
|
+
get control0X(): number;
|
|
15
|
+
get control0Y(): number;
|
|
16
|
+
get control1X(): number;
|
|
17
|
+
get control1Y(): number;
|
|
18
|
+
get anchor1X(): number;
|
|
19
|
+
get anchor1Y(): number;
|
|
20
|
+
/** The point on the curve at parameter `t` (0..1). */
|
|
21
|
+
pointOnCurve(t: number): Point;
|
|
22
|
+
zeroLength(): boolean;
|
|
23
|
+
convexTo(next: Cubic): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Bounds as `[minX, minY, maxX, maxY]`. `approximate` uses the hull of anchors and controls,
|
|
26
|
+
* which is cheaper and never smaller than the true bounds.
|
|
27
|
+
*/
|
|
28
|
+
calculateBounds(bounds?: number[], approximate?: boolean): number[];
|
|
29
|
+
/** Splits the curve at `t` into two curves. */
|
|
30
|
+
split(t: number): [Cubic, Cubic];
|
|
31
|
+
/** The same curve drawn in the opposite direction. */
|
|
32
|
+
reverse(): Cubic;
|
|
33
|
+
plus(o: Cubic): Cubic;
|
|
34
|
+
times(x: number): Cubic;
|
|
35
|
+
div(x: number): Cubic;
|
|
36
|
+
equals(other: Cubic): boolean;
|
|
37
|
+
transformed(f: PointTransformer): Cubic;
|
|
38
|
+
toString(): string;
|
|
39
|
+
/** A straight line, as a cubic with controls one and two thirds along it. */
|
|
40
|
+
static straightLine(x0: number, y0: number, x1: number, y1: number): Cubic;
|
|
41
|
+
/** A circular arc of up to 180° around (centerX, centerY) from (x0, y0) to (x1, y1). */
|
|
42
|
+
static circularArc(centerX: number, centerY: number, x0: number, y0: number, x1: number, y1: number): Cubic;
|
|
43
|
+
/** A zero-length cubic at (x0, y0). */
|
|
44
|
+
static empty(x0: number, y0: number): Cubic;
|
|
45
|
+
}
|
|
46
|
+
/** A cubic whose points can be rewritten in place (used per animation frame by Morph). */
|
|
47
|
+
export declare class MutableCubic extends Cubic {
|
|
48
|
+
transform(f: PointTransformer): void;
|
|
49
|
+
interpolate(c1: Cubic, c2: Cubic, progress: number): void;
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
//# sourceMappingURL=cubic.d.ts.map
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { Point, convex, directionVector, distance, interpolate } from "./point.js";
|
|
2
|
+
//#region src/shapes/cubic.ts
|
|
3
|
+
const inUnit = (t) => t >= 0 && t <= 1;
|
|
4
|
+
/**
|
|
5
|
+
* A cubic Bézier curve: two anchor points and two control points, stored as
|
|
6
|
+
* `[anchor0X, anchor0Y, control0X, control0Y, control1X, control1Y, anchor1X, anchor1Y]`.
|
|
7
|
+
*/
|
|
8
|
+
var Cubic = class Cubic {
|
|
9
|
+
points;
|
|
10
|
+
constructor(points = new Array(8).fill(0)) {
|
|
11
|
+
if (points.length !== 8) throw new Error("Points array size should be 8");
|
|
12
|
+
this.points = [...points];
|
|
13
|
+
}
|
|
14
|
+
static of(anchor0X, anchor0Y, control0X, control0Y, control1X, control1Y, anchor1X, anchor1Y) {
|
|
15
|
+
return new Cubic([
|
|
16
|
+
anchor0X,
|
|
17
|
+
anchor0Y,
|
|
18
|
+
control0X,
|
|
19
|
+
control0Y,
|
|
20
|
+
control1X,
|
|
21
|
+
control1Y,
|
|
22
|
+
anchor1X,
|
|
23
|
+
anchor1Y
|
|
24
|
+
]);
|
|
25
|
+
}
|
|
26
|
+
static fromPoints(anchor0, control0, control1, anchor1) {
|
|
27
|
+
return Cubic.of(anchor0.x, anchor0.y, control0.x, control0.y, control1.x, control1.y, anchor1.x, anchor1.y);
|
|
28
|
+
}
|
|
29
|
+
get anchor0X() {
|
|
30
|
+
return this.points[0];
|
|
31
|
+
}
|
|
32
|
+
get anchor0Y() {
|
|
33
|
+
return this.points[1];
|
|
34
|
+
}
|
|
35
|
+
get control0X() {
|
|
36
|
+
return this.points[2];
|
|
37
|
+
}
|
|
38
|
+
get control0Y() {
|
|
39
|
+
return this.points[3];
|
|
40
|
+
}
|
|
41
|
+
get control1X() {
|
|
42
|
+
return this.points[4];
|
|
43
|
+
}
|
|
44
|
+
get control1Y() {
|
|
45
|
+
return this.points[5];
|
|
46
|
+
}
|
|
47
|
+
get anchor1X() {
|
|
48
|
+
return this.points[6];
|
|
49
|
+
}
|
|
50
|
+
get anchor1Y() {
|
|
51
|
+
return this.points[7];
|
|
52
|
+
}
|
|
53
|
+
/** The point on the curve at parameter `t` (0..1). */
|
|
54
|
+
pointOnCurve(t) {
|
|
55
|
+
const u = 1 - t;
|
|
56
|
+
return new Point(this.anchor0X * (u * u * u) + this.control0X * (3 * t * u * u) + this.control1X * (3 * t * t * u) + this.anchor1X * (t * t * t), this.anchor0Y * (u * u * u) + this.control0Y * (3 * t * u * u) + this.control1Y * (3 * t * t * u) + this.anchor1Y * (t * t * t));
|
|
57
|
+
}
|
|
58
|
+
zeroLength() {
|
|
59
|
+
return Math.abs(this.anchor0X - this.anchor1X) < 1e-4 && Math.abs(this.anchor0Y - this.anchor1Y) < 1e-4;
|
|
60
|
+
}
|
|
61
|
+
convexTo(next) {
|
|
62
|
+
return convex(new Point(this.anchor0X, this.anchor0Y), new Point(this.anchor1X, this.anchor1Y), new Point(next.anchor1X, next.anchor1Y));
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Bounds as `[minX, minY, maxX, maxY]`. `approximate` uses the hull of anchors and controls,
|
|
66
|
+
* which is cheaper and never smaller than the true bounds.
|
|
67
|
+
*/
|
|
68
|
+
calculateBounds(bounds = new Array(4).fill(0), approximate = false) {
|
|
69
|
+
if (this.zeroLength()) {
|
|
70
|
+
bounds[0] = this.anchor0X;
|
|
71
|
+
bounds[1] = this.anchor0Y;
|
|
72
|
+
bounds[2] = this.anchor0X;
|
|
73
|
+
bounds[3] = this.anchor0Y;
|
|
74
|
+
return bounds;
|
|
75
|
+
}
|
|
76
|
+
let minX = Math.min(this.anchor0X, this.anchor1X);
|
|
77
|
+
let minY = Math.min(this.anchor0Y, this.anchor1Y);
|
|
78
|
+
let maxX = Math.max(this.anchor0X, this.anchor1X);
|
|
79
|
+
let maxY = Math.max(this.anchor0Y, this.anchor1Y);
|
|
80
|
+
if (approximate) {
|
|
81
|
+
bounds[0] = Math.min(minX, Math.min(this.control0X, this.control1X));
|
|
82
|
+
bounds[1] = Math.min(minY, Math.min(this.control0Y, this.control1Y));
|
|
83
|
+
bounds[2] = Math.max(maxX, Math.max(this.control0X, this.control1X));
|
|
84
|
+
bounds[3] = Math.max(maxY, Math.max(this.control0Y, this.control1Y));
|
|
85
|
+
return bounds;
|
|
86
|
+
}
|
|
87
|
+
const extremaTs = (p0, c0, c1, p1) => {
|
|
88
|
+
const a = -p0 + 3 * c0 - 3 * c1 + p1;
|
|
89
|
+
const b = 2 * p0 - 4 * c0 + 2 * c1;
|
|
90
|
+
const c = -p0 + c0;
|
|
91
|
+
if (Math.abs(a) < 1e-4) {
|
|
92
|
+
if (b !== 0) {
|
|
93
|
+
const t = 2 * c / (-2 * b);
|
|
94
|
+
return inUnit(t) ? [t] : [];
|
|
95
|
+
}
|
|
96
|
+
return [];
|
|
97
|
+
}
|
|
98
|
+
const s = b * b - 4 * a * c;
|
|
99
|
+
if (s < 0) return [];
|
|
100
|
+
return [(-b + Math.sqrt(s)) / (2 * a), (-b - Math.sqrt(s)) / (2 * a)].filter(inUnit);
|
|
101
|
+
};
|
|
102
|
+
for (const t of extremaTs(this.anchor0X, this.control0X, this.control1X, this.anchor1X)) {
|
|
103
|
+
const x = this.pointOnCurve(t).x;
|
|
104
|
+
if (x < minX) minX = x;
|
|
105
|
+
if (x > maxX) maxX = x;
|
|
106
|
+
}
|
|
107
|
+
for (const t of extremaTs(this.anchor0Y, this.control0Y, this.control1Y, this.anchor1Y)) {
|
|
108
|
+
const y = this.pointOnCurve(t).y;
|
|
109
|
+
if (y < minY) minY = y;
|
|
110
|
+
if (y > maxY) maxY = y;
|
|
111
|
+
}
|
|
112
|
+
bounds[0] = minX;
|
|
113
|
+
bounds[1] = minY;
|
|
114
|
+
bounds[2] = maxX;
|
|
115
|
+
bounds[3] = maxY;
|
|
116
|
+
return bounds;
|
|
117
|
+
}
|
|
118
|
+
/** Splits the curve at `t` into two curves. */
|
|
119
|
+
split(t) {
|
|
120
|
+
const u = 1 - t;
|
|
121
|
+
const p = this.pointOnCurve(t);
|
|
122
|
+
return [Cubic.of(this.anchor0X, this.anchor0Y, this.anchor0X * u + this.control0X * t, this.anchor0Y * u + this.control0Y * t, this.anchor0X * (u * u) + this.control0X * (2 * u * t) + this.control1X * (t * t), this.anchor0Y * (u * u) + this.control0Y * (2 * u * t) + this.control1Y * (t * t), p.x, p.y), Cubic.of(p.x, p.y, this.control0X * (u * u) + this.control1X * (2 * u * t) + this.anchor1X * (t * t), this.control0Y * (u * u) + this.control1Y * (2 * u * t) + this.anchor1Y * (t * t), this.control1X * u + this.anchor1X * t, this.control1Y * u + this.anchor1Y * t, this.anchor1X, this.anchor1Y)];
|
|
123
|
+
}
|
|
124
|
+
/** The same curve drawn in the opposite direction. */
|
|
125
|
+
reverse() {
|
|
126
|
+
return Cubic.of(this.anchor1X, this.anchor1Y, this.control1X, this.control1Y, this.control0X, this.control0Y, this.anchor0X, this.anchor0Y);
|
|
127
|
+
}
|
|
128
|
+
plus(o) {
|
|
129
|
+
return new Cubic(this.points.map((v, i) => v + o.points[i]));
|
|
130
|
+
}
|
|
131
|
+
times(x) {
|
|
132
|
+
return new Cubic(this.points.map((v) => v * x));
|
|
133
|
+
}
|
|
134
|
+
div(x) {
|
|
135
|
+
return this.times(1 / x);
|
|
136
|
+
}
|
|
137
|
+
equals(other) {
|
|
138
|
+
return this.points.every((v, i) => v === other.points[i]);
|
|
139
|
+
}
|
|
140
|
+
transformed(f) {
|
|
141
|
+
const points = [...this.points];
|
|
142
|
+
for (let i = 0; i < 8; i += 2) {
|
|
143
|
+
const [x, y] = f(points[i], points[i + 1]);
|
|
144
|
+
points[i] = x;
|
|
145
|
+
points[i + 1] = y;
|
|
146
|
+
}
|
|
147
|
+
return new Cubic(points);
|
|
148
|
+
}
|
|
149
|
+
toString() {
|
|
150
|
+
return `anchor0: (${this.anchor0X}, ${this.anchor0Y}) control0: (${this.control0X}, ${this.control0Y}), control1: (${this.control1X}, ${this.control1Y}), anchor1: (${this.anchor1X}, ${this.anchor1Y})`;
|
|
151
|
+
}
|
|
152
|
+
/** A straight line, as a cubic with controls one and two thirds along it. */
|
|
153
|
+
static straightLine(x0, y0, x1, y1) {
|
|
154
|
+
return Cubic.of(x0, y0, interpolate(x0, x1, 1 / 3), interpolate(y0, y1, 1 / 3), interpolate(x0, x1, 2 / 3), interpolate(y0, y1, 2 / 3), x1, y1);
|
|
155
|
+
}
|
|
156
|
+
/** A circular arc of up to 180° around (centerX, centerY) from (x0, y0) to (x1, y1). */
|
|
157
|
+
static circularArc(centerX, centerY, x0, y0, x1, y1) {
|
|
158
|
+
const p0d = directionVector(x0 - centerX, y0 - centerY);
|
|
159
|
+
const p1d = directionVector(x1 - centerX, y1 - centerY);
|
|
160
|
+
const rotatedP0 = p0d.rotate90();
|
|
161
|
+
const rotatedP1 = p1d.rotate90();
|
|
162
|
+
const clockwise = rotatedP0.dotProductXY(x1 - centerX, y1 - centerY) >= 0;
|
|
163
|
+
const cosa = p0d.dotProduct(p1d);
|
|
164
|
+
if (cosa > .999) return Cubic.straightLine(x0, y0, x1, y1);
|
|
165
|
+
const k = distance(x0 - centerX, y0 - centerY) * 4 / 3 * (Math.sqrt(2 * (1 - cosa)) - Math.sqrt(1 - cosa * cosa)) / (1 - cosa) * (clockwise ? 1 : -1);
|
|
166
|
+
return Cubic.of(x0, y0, x0 + rotatedP0.x * k, y0 + rotatedP0.y * k, x1 - rotatedP1.x * k, y1 - rotatedP1.y * k, x1, y1);
|
|
167
|
+
}
|
|
168
|
+
/** A zero-length cubic at (x0, y0). */
|
|
169
|
+
static empty(x0, y0) {
|
|
170
|
+
return Cubic.of(x0, y0, x0, y0, x0, y0, x0, y0);
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
/** A cubic whose points can be rewritten in place (used per animation frame by Morph). */
|
|
174
|
+
var MutableCubic = class extends Cubic {
|
|
175
|
+
transform(f) {
|
|
176
|
+
for (let i = 0; i < 8; i += 2) {
|
|
177
|
+
const [x, y] = f(this.points[i], this.points[i + 1]);
|
|
178
|
+
this.points[i] = x;
|
|
179
|
+
this.points[i + 1] = y;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
interpolate(c1, c2, progress) {
|
|
183
|
+
for (let i = 0; i < 8; i++) this.points[i] = interpolate(c1.points[i], c2.points[i], progress);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
//#endregion
|
|
187
|
+
export { Cubic, MutableCubic };
|
|
188
|
+
|
|
189
|
+
//# sourceMappingURL=cubic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cubic.js","names":[],"sources":["../../src/shapes/cubic.ts"],"sourcesContent":["/*\n * Port of androidx.graphics.shapes Cubic.kt (Apache-2.0, see LICENSE-androidx.md).\n */\nimport {\n DistanceEpsilon,\n Point,\n convex,\n directionVector,\n distance,\n interpolate,\n type PointTransformer,\n} from './point';\n\nconst inUnit = (t: number) => t >= 0 && t <= 1;\n\n/**\n * A cubic Bézier curve: two anchor points and two control points, stored as\n * `[anchor0X, anchor0Y, control0X, control0Y, control1X, control1Y, anchor1X, anchor1Y]`.\n */\nexport class Cubic {\n readonly points: number[];\n\n constructor(points: readonly number[] = new Array(8).fill(0)) {\n if (points.length !== 8) throw new Error('Points array size should be 8');\n this.points = [...points];\n }\n\n static of(\n anchor0X: number,\n anchor0Y: number,\n control0X: number,\n control0Y: number,\n control1X: number,\n control1Y: number,\n anchor1X: number,\n anchor1Y: number,\n ): Cubic {\n return new Cubic([\n anchor0X,\n anchor0Y,\n control0X,\n control0Y,\n control1X,\n control1Y,\n anchor1X,\n anchor1Y,\n ]);\n }\n\n static fromPoints(anchor0: Point, control0: Point, control1: Point, anchor1: Point): Cubic {\n return Cubic.of(\n anchor0.x,\n anchor0.y,\n control0.x,\n control0.y,\n control1.x,\n control1.y,\n anchor1.x,\n anchor1.y,\n );\n }\n\n get anchor0X() {\n return this.points[0]!;\n }\n get anchor0Y() {\n return this.points[1]!;\n }\n get control0X() {\n return this.points[2]!;\n }\n get control0Y() {\n return this.points[3]!;\n }\n get control1X() {\n return this.points[4]!;\n }\n get control1Y() {\n return this.points[5]!;\n }\n get anchor1X() {\n return this.points[6]!;\n }\n get anchor1Y() {\n return this.points[7]!;\n }\n\n /** The point on the curve at parameter `t` (0..1). */\n pointOnCurve(t: number): Point {\n const u = 1 - t;\n return new Point(\n this.anchor0X * (u * u * u) +\n this.control0X * (3 * t * u * u) +\n this.control1X * (3 * t * t * u) +\n this.anchor1X * (t * t * t),\n this.anchor0Y * (u * u * u) +\n this.control0Y * (3 * t * u * u) +\n this.control1Y * (3 * t * t * u) +\n this.anchor1Y * (t * t * t),\n );\n }\n\n zeroLength(): boolean {\n return (\n Math.abs(this.anchor0X - this.anchor1X) < DistanceEpsilon &&\n Math.abs(this.anchor0Y - this.anchor1Y) < DistanceEpsilon\n );\n }\n\n convexTo(next: Cubic): boolean {\n return convex(\n new Point(this.anchor0X, this.anchor0Y),\n new Point(this.anchor1X, this.anchor1Y),\n new Point(next.anchor1X, next.anchor1Y),\n );\n }\n\n /**\n * Bounds as `[minX, minY, maxX, maxY]`. `approximate` uses the hull of anchors and controls,\n * which is cheaper and never smaller than the true bounds.\n */\n calculateBounds(bounds: number[] = new Array(4).fill(0), approximate = false): number[] {\n // A curve might be of zero-length, with both anchors co-located: return the point itself.\n if (this.zeroLength()) {\n bounds[0] = this.anchor0X;\n bounds[1] = this.anchor0Y;\n bounds[2] = this.anchor0X;\n bounds[3] = this.anchor0Y;\n return bounds;\n }\n let minX = Math.min(this.anchor0X, this.anchor1X);\n let minY = Math.min(this.anchor0Y, this.anchor1Y);\n let maxX = Math.max(this.anchor0X, this.anchor1X);\n let maxY = Math.max(this.anchor0Y, this.anchor1Y);\n if (approximate) {\n bounds[0] = Math.min(minX, Math.min(this.control0X, this.control1X));\n bounds[1] = Math.min(minY, Math.min(this.control0Y, this.control1Y));\n bounds[2] = Math.max(maxX, Math.max(this.control0X, this.control1X));\n bounds[3] = Math.max(maxY, Math.max(this.control0Y, this.control1Y));\n return bounds;\n }\n\n // The derivative is a quadratic Bézier; solve for t with the quadratic formula.\n const extremaTs = (p0: number, c0: number, c1: number, p1: number): number[] => {\n const a = -p0 + 3 * c0 - 3 * c1 + p1;\n const b = 2 * p0 - 4 * c0 + 2 * c1;\n const c = -p0 + c0;\n if (Math.abs(a) < DistanceEpsilon) {\n // A single root when a is 0.\n if (b !== 0) {\n const t = (2 * c) / (-2 * b);\n return inUnit(t) ? [t] : [];\n }\n return [];\n }\n const s = b * b - 4 * a * c;\n if (s < 0) return [];\n return [(-b + Math.sqrt(s)) / (2 * a), (-b - Math.sqrt(s)) / (2 * a)].filter(inUnit);\n };\n\n for (const t of extremaTs(this.anchor0X, this.control0X, this.control1X, this.anchor1X)) {\n const x = this.pointOnCurve(t).x;\n if (x < minX) minX = x;\n if (x > maxX) maxX = x;\n }\n for (const t of extremaTs(this.anchor0Y, this.control0Y, this.control1Y, this.anchor1Y)) {\n const y = this.pointOnCurve(t).y;\n if (y < minY) minY = y;\n if (y > maxY) maxY = y;\n }\n bounds[0] = minX;\n bounds[1] = minY;\n bounds[2] = maxX;\n bounds[3] = maxY;\n return bounds;\n }\n\n /** Splits the curve at `t` into two curves. */\n split(t: number): [Cubic, Cubic] {\n const u = 1 - t;\n const p = this.pointOnCurve(t);\n return [\n Cubic.of(\n this.anchor0X,\n this.anchor0Y,\n this.anchor0X * u + this.control0X * t,\n this.anchor0Y * u + this.control0Y * t,\n this.anchor0X * (u * u) + this.control0X * (2 * u * t) + this.control1X * (t * t),\n this.anchor0Y * (u * u) + this.control0Y * (2 * u * t) + this.control1Y * (t * t),\n p.x,\n p.y,\n ),\n Cubic.of(\n p.x,\n p.y,\n this.control0X * (u * u) + this.control1X * (2 * u * t) + this.anchor1X * (t * t),\n this.control0Y * (u * u) + this.control1Y * (2 * u * t) + this.anchor1Y * (t * t),\n this.control1X * u + this.anchor1X * t,\n this.control1Y * u + this.anchor1Y * t,\n this.anchor1X,\n this.anchor1Y,\n ),\n ];\n }\n\n /** The same curve drawn in the opposite direction. */\n reverse(): Cubic {\n return Cubic.of(\n this.anchor1X,\n this.anchor1Y,\n this.control1X,\n this.control1Y,\n this.control0X,\n this.control0Y,\n this.anchor0X,\n this.anchor0Y,\n );\n }\n\n plus(o: Cubic): Cubic {\n return new Cubic(this.points.map((v, i) => v + o.points[i]!));\n }\n\n times(x: number): Cubic {\n return new Cubic(this.points.map((v) => v * x));\n }\n\n div(x: number): Cubic {\n return this.times(1 / x);\n }\n\n equals(other: Cubic): boolean {\n return this.points.every((v, i) => v === other.points[i]);\n }\n\n transformed(f: PointTransformer): Cubic {\n const points = [...this.points];\n for (let i = 0; i < 8; i += 2) {\n const [x, y] = f(points[i]!, points[i + 1]!);\n points[i] = x;\n points[i + 1] = y;\n }\n return new Cubic(points);\n }\n\n toString(): string {\n return `anchor0: (${this.anchor0X}, ${this.anchor0Y}) control0: (${this.control0X}, ${this.control0Y}), control1: (${this.control1X}, ${this.control1Y}), anchor1: (${this.anchor1X}, ${this.anchor1Y})`;\n }\n\n /** A straight line, as a cubic with controls one and two thirds along it. */\n static straightLine(x0: number, y0: number, x1: number, y1: number): Cubic {\n return Cubic.of(\n x0,\n y0,\n interpolate(x0, x1, 1 / 3),\n interpolate(y0, y1, 1 / 3),\n interpolate(x0, x1, 2 / 3),\n interpolate(y0, y1, 2 / 3),\n x1,\n y1,\n );\n }\n\n /** A circular arc of up to 180° around (centerX, centerY) from (x0, y0) to (x1, y1). */\n static circularArc(\n centerX: number,\n centerY: number,\n x0: number,\n y0: number,\n x1: number,\n y1: number,\n ): Cubic {\n const p0d = directionVector(x0 - centerX, y0 - centerY);\n const p1d = directionVector(x1 - centerX, y1 - centerY);\n const rotatedP0 = p0d.rotate90();\n const rotatedP1 = p1d.rotate90();\n const clockwise = rotatedP0.dotProductXY(x1 - centerX, y1 - centerY) >= 0;\n const cosa = p0d.dotProduct(p1d);\n if (cosa > 0.999) return Cubic.straightLine(x0, y0, x1, y1); // p0 ~= p1\n const k =\n ((((distance(x0 - centerX, y0 - centerY) * 4) / 3) *\n (Math.sqrt(2 * (1 - cosa)) - Math.sqrt(1 - cosa * cosa))) /\n (1 - cosa)) *\n (clockwise ? 1 : -1);\n return Cubic.of(\n x0,\n y0,\n x0 + rotatedP0.x * k,\n y0 + rotatedP0.y * k,\n x1 - rotatedP1.x * k,\n y1 - rotatedP1.y * k,\n x1,\n y1,\n );\n }\n\n /** A zero-length cubic at (x0, y0). */\n static empty(x0: number, y0: number): Cubic {\n return Cubic.of(x0, y0, x0, y0, x0, y0, x0, y0);\n }\n}\n\n/** A cubic whose points can be rewritten in place (used per animation frame by Morph). */\nexport class MutableCubic extends Cubic {\n transform(f: PointTransformer): void {\n for (let i = 0; i < 8; i += 2) {\n const [x, y] = f(this.points[i]!, this.points[i + 1]!);\n this.points[i] = x;\n this.points[i + 1] = y;\n }\n }\n\n interpolate(c1: Cubic, c2: Cubic, progress: number): void {\n for (let i = 0; i < 8; i++) {\n this.points[i] = interpolate(c1.points[i]!, c2.points[i]!, progress);\n }\n }\n}\n"],"mappings":";;AAaA,MAAM,UAAU,MAAc,KAAK,KAAK,KAAK;;;;;AAM7C,IAAa,QAAb,MAAa,MAAM;CACjB;CAEA,YAAY,SAA4B,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG;EAC5D,IAAI,OAAO,WAAW,GAAG,MAAM,IAAI,MAAM,+BAA+B;EACxE,KAAK,SAAS,CAAC,GAAG,MAAM;CAC1B;CAEA,OAAO,GACL,UACA,UACA,WACA,WACA,WACA,WACA,UACA,UACO;EACP,OAAO,IAAI,MAAM;GACf;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,CAAC;CACH;CAEA,OAAO,WAAW,SAAgB,UAAiB,UAAiB,SAAuB;EACzF,OAAO,MAAM,GACX,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,QAAQ,GACR,QAAQ,CACV;CACF;CAEA,IAAI,WAAW;EACb,OAAO,KAAK,OAAO;CACrB;CACA,IAAI,WAAW;EACb,OAAO,KAAK,OAAO;CACrB;CACA,IAAI,YAAY;EACd,OAAO,KAAK,OAAO;CACrB;CACA,IAAI,YAAY;EACd,OAAO,KAAK,OAAO;CACrB;CACA,IAAI,YAAY;EACd,OAAO,KAAK,OAAO;CACrB;CACA,IAAI,YAAY;EACd,OAAO,KAAK,OAAO;CACrB;CACA,IAAI,WAAW;EACb,OAAO,KAAK,OAAO;CACrB;CACA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,SACN,YAAY,IAAI;EACnB,OAAO,MAAM,GACX,IACA,IACA,KAAK,UAAU,IAAI,GACnB,KAAK,UAAU,IAAI,GACnB,KAAK,UAAU,IAAI,GACnB,KAAK,UAAU,IAAI,GACnB,IACA,EACF;CACF;;CAGA,OAAO,MAAM,IAAY,IAAmB;EAC1C,OAAO,MAAM,GAAG,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,EAAE;CAChD;AACF;;AAGA,IAAa,eAAb,cAAkC,MAAM;CACtC,UAAU,GAA2B;EACnC,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG;GAC7B,MAAM,CAAC,GAAG,KAAK,EAAE,KAAK,OAAO,IAAK,KAAK,OAAO,IAAI,EAAG;GACrD,KAAK,OAAO,KAAK;GACjB,KAAK,OAAO,IAAI,KAAK;EACvB;CACF;CAEA,YAAY,IAAW,IAAW,UAAwB;EACxD,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,KACrB,KAAK,OAAO,KAAK,YAAY,GAAG,OAAO,IAAK,GAAG,OAAO,IAAK,QAAQ;CAEvE;AACF"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Point } from "./point.js";
|
|
2
|
+
import { Corner } from "./features.js";
|
|
3
|
+
import { DoubleMapper, progressDistance, progressInRange } from "./float-mapping.js";
|
|
4
|
+
//#region src/shapes/feature-mapping.ts
|
|
5
|
+
/** Maps outline progress between two shapes by pairing their closest corners. */
|
|
6
|
+
function featureMapper(features1, features2) {
|
|
7
|
+
const corners1 = features1.filter((f) => f.feature instanceof Corner);
|
|
8
|
+
const corners2 = features2.filter((f) => f.feature instanceof Corner);
|
|
9
|
+
return new DoubleMapper(...doMapping(corners1, corners2));
|
|
10
|
+
}
|
|
11
|
+
const IdentityMapping = [[0, 0], [.5, .5]];
|
|
12
|
+
function doMapping(features1, features2) {
|
|
13
|
+
const candidates = [];
|
|
14
|
+
for (const f1 of features1) for (const f2 of features2) {
|
|
15
|
+
const d = featureDistSquared(f1.feature, f2.feature);
|
|
16
|
+
if (d !== Infinity) candidates.push({
|
|
17
|
+
distance: d,
|
|
18
|
+
f1,
|
|
19
|
+
f2
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
candidates.sort((a, b) => a.distance - b.distance);
|
|
23
|
+
if (candidates.length === 0) return IdentityMapping;
|
|
24
|
+
if (candidates.length === 1) {
|
|
25
|
+
const p1 = candidates[0].f1.progress;
|
|
26
|
+
const p2 = candidates[0].f2.progress;
|
|
27
|
+
return [[p1, p2], [(p1 + .5) % 1, (p2 + .5) % 1]];
|
|
28
|
+
}
|
|
29
|
+
const helper = new MappingHelper();
|
|
30
|
+
for (const { f1, f2 } of candidates) helper.addMapping(f1, f2);
|
|
31
|
+
return helper.mapping;
|
|
32
|
+
}
|
|
33
|
+
var MappingHelper = class {
|
|
34
|
+
/** Start-shape to end-shape progress pairs, sorted by start progress. */
|
|
35
|
+
mapping = [];
|
|
36
|
+
usedF1 = /* @__PURE__ */ new Set();
|
|
37
|
+
usedF2 = /* @__PURE__ */ new Set();
|
|
38
|
+
addMapping(f1, f2) {
|
|
39
|
+
if (this.usedF1.has(f1) || this.usedF2.has(f2)) return;
|
|
40
|
+
const index = binarySearchBy(this.mapping, f1.progress);
|
|
41
|
+
if (index >= 0) throw new Error("There can't be two features with the same progress");
|
|
42
|
+
const insertionIndex = -index - 1;
|
|
43
|
+
const n = this.mapping.length;
|
|
44
|
+
if (n >= 1) {
|
|
45
|
+
const [before1, before2] = this.mapping[(insertionIndex + n - 1) % n];
|
|
46
|
+
const [after1, after2] = this.mapping[insertionIndex % n];
|
|
47
|
+
if (progressDistance(f1.progress, before1) < 1e-4 || progressDistance(f1.progress, after1) < 1e-4 || progressDistance(f2.progress, before2) < 1e-4 || progressDistance(f2.progress, after2) < 1e-4) return;
|
|
48
|
+
if (n > 1 && !progressInRange(f2.progress, before2, after2)) return;
|
|
49
|
+
}
|
|
50
|
+
this.mapping.splice(insertionIndex, 0, [f1.progress, f2.progress]);
|
|
51
|
+
this.usedF1.add(f1);
|
|
52
|
+
this.usedF2.add(f2);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
/** Kotlin's `binarySearchBy` on the first element: the index, or `-(insertion point) - 1`. */
|
|
56
|
+
function binarySearchBy(list, key) {
|
|
57
|
+
let low = 0;
|
|
58
|
+
let high = list.length - 1;
|
|
59
|
+
while (low <= high) {
|
|
60
|
+
const mid = low + high >>> 1;
|
|
61
|
+
const value = list[mid][0];
|
|
62
|
+
if (value < key) low = mid + 1;
|
|
63
|
+
else if (value > key) high = mid - 1;
|
|
64
|
+
else return mid;
|
|
65
|
+
}
|
|
66
|
+
return -(low + 1);
|
|
67
|
+
}
|
|
68
|
+
function featureDistSquared(f1, f2) {
|
|
69
|
+
if (f1 instanceof Corner && f2 instanceof Corner && f1.convex !== f2.convex) return Infinity;
|
|
70
|
+
return featureRepresentativePoint(f1).minus(featureRepresentativePoint(f2)).getDistanceSquared();
|
|
71
|
+
}
|
|
72
|
+
function featureRepresentativePoint(feature) {
|
|
73
|
+
const first = feature.cubics[0];
|
|
74
|
+
const last = feature.cubics[feature.cubics.length - 1];
|
|
75
|
+
return new Point((first.anchor0X + last.anchor1X) / 2, (first.anchor0Y + last.anchor1Y) / 2);
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
export { doMapping, featureDistSquared, featureMapper, featureRepresentativePoint };
|
|
79
|
+
|
|
80
|
+
//# sourceMappingURL=feature-mapping.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feature-mapping.js","names":[],"sources":["../../src/shapes/feature-mapping.ts"],"sourcesContent":["/*\n * Port of androidx.graphics.shapes FeatureMapping.kt (Apache-2.0, see LICENSE-androidx.md).\n */\nimport { DoubleMapper, progressDistance, progressInRange } from './float-mapping';\nimport { Corner, type Feature } from './features';\nimport { DistanceEpsilon, Point } from './point';\nimport type { ProgressableFeature } from './polygon-measure';\n\ntype Mapping = readonly [number, number];\n\n/** Maps outline progress between two shapes by pairing their closest corners. */\nexport function featureMapper(\n features1: readonly ProgressableFeature[],\n features2: readonly ProgressableFeature[],\n): DoubleMapper {\n // Only corners take part in the mapping.\n const corners1 = features1.filter((f) => f.feature instanceof Corner);\n const corners2 = features2.filter((f) => f.feature instanceof Corner);\n return new DoubleMapper(...doMapping(corners1, corners2));\n}\n\nconst IdentityMapping: readonly Mapping[] = [\n [0, 0],\n [0.5, 0.5],\n];\n\nexport function doMapping(\n features1: readonly ProgressableFeature[],\n features2: readonly ProgressableFeature[],\n): readonly Mapping[] {\n const candidates: { distance: number; f1: ProgressableFeature; f2: ProgressableFeature }[] = [];\n for (const f1 of features1) {\n for (const f2 of features2) {\n const d = featureDistSquared(f1.feature, f2.feature);\n if (d !== Infinity) candidates.push({ distance: d, f1, f2 });\n }\n }\n // Array.prototype.sort is stable, matching Kotlin's sortedBy.\n candidates.sort((a, b) => a.distance - b.distance);\n\n if (candidates.length === 0) return IdentityMapping;\n if (candidates.length === 1) {\n const p1 = candidates[0]!.f1.progress;\n const p2 = candidates[0]!.f2.progress;\n return [\n [p1, p2],\n [(p1 + 0.5) % 1, (p2 + 0.5) % 1],\n ];\n }\n const helper = new MappingHelper();\n for (const { f1, f2 } of candidates) helper.addMapping(f1, f2);\n return helper.mapping;\n}\n\nclass MappingHelper {\n /** Start-shape to end-shape progress pairs, sorted by start progress. */\n readonly mapping: Mapping[] = [];\n private readonly usedF1 = new Set<ProgressableFeature>();\n private readonly usedF2 = new Set<ProgressableFeature>();\n\n addMapping(f1: ProgressableFeature, f2: ProgressableFeature): void {\n // Map each feature at most once.\n if (this.usedF1.has(f1) || this.usedF2.has(f2)) return;\n\n const index = binarySearchBy(this.mapping, f1.progress);\n if (index >= 0) throw new Error(\"There can't be two features with the same progress\");\n const insertionIndex = -index - 1;\n const n = this.mapping.length;\n if (n >= 1) {\n const [before1, before2] = this.mapping[(insertionIndex + n - 1) % n]!;\n const [after1, after2] = this.mapping[insertionIndex % n]!;\n // Features too close to their neighbours would make the DoubleMapper unstable.\n if (\n progressDistance(f1.progress, before1) < DistanceEpsilon ||\n progressDistance(f1.progress, after1) < DistanceEpsilon ||\n progressDistance(f2.progress, before2) < DistanceEpsilon ||\n progressDistance(f2.progress, after2) < DistanceEpsilon\n ) {\n return;\n }\n // With two or more mappings, don't add crossings.\n if (n > 1 && !progressInRange(f2.progress, before2, after2)) return;\n }\n this.mapping.splice(insertionIndex, 0, [f1.progress, f2.progress]);\n this.usedF1.add(f1);\n this.usedF2.add(f2);\n }\n}\n\n/** Kotlin's `binarySearchBy` on the first element: the index, or `-(insertion point) - 1`. */\nfunction binarySearchBy(list: readonly Mapping[], key: number): number {\n let low = 0;\n let high = list.length - 1;\n while (low <= high) {\n const mid = (low + high) >>> 1;\n const value = list[mid]![0];\n if (value < key) low = mid + 1;\n else if (value > key) high = mid - 1;\n else return mid;\n }\n return -(low + 1);\n}\n\nexport function featureDistSquared(f1: Feature, f2: Feature): number {\n // Corners only map to corners of the same concavity.\n if (f1 instanceof Corner && f2 instanceof Corner && f1.convex !== f2.convex) return Infinity;\n return featureRepresentativePoint(f1).minus(featureRepresentativePoint(f2)).getDistanceSquared();\n}\n\nexport function featureRepresentativePoint(feature: Feature): Point {\n const first = feature.cubics[0]!;\n const last = feature.cubics[feature.cubics.length - 1]!;\n return new Point((first.anchor0X + last.anchor1X) / 2, (first.anchor0Y + last.anchor1Y) / 2);\n}\n"],"mappings":";;;;;AAWA,SAAgB,cACd,WACA,WACc;CAEd,MAAM,WAAW,UAAU,QAAQ,MAAM,EAAE,mBAAmB,MAAM;CACpE,MAAM,WAAW,UAAU,QAAQ,MAAM,EAAE,mBAAmB,MAAM;CACpE,OAAO,IAAI,aAAa,GAAG,UAAU,UAAU,QAAQ,CAAC;AAC1D;AAEA,MAAM,kBAAsC,CAC1C,CAAC,GAAG,CAAC,GACL,CAAC,IAAK,EAAG,CACX;AAEA,SAAgB,UACd,WACA,WACoB;CACpB,MAAM,aAAuF,CAAC;CAC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IAAA,QACrC,iBAAiB,GAAG,UAAU,MAAM,IAAA,MAEpC;GAGF,IAAI,IAAI,KAAK,CAAC,gBAAgB,GAAG,UAAU,SAAS,MAAM,GAAG;EAC/D;EACA,KAAK,QAAQ,OAAO,gBAAgB,GAAG,CAAC,GAAG,UAAU,GAAG,QAAQ,CAAC;EACjE,KAAK,OAAO,IAAI,EAAE;EAClB,KAAK,OAAO,IAAI,EAAE;CACpB;AACF;;AAGA,SAAS,eAAe,MAA0B,KAAqB;CACrE,IAAI,MAAM;CACV,IAAI,OAAO,KAAK,SAAS;CACzB,OAAO,OAAO,MAAM;EAClB,MAAM,MAAO,MAAM,SAAU;EAC7B,MAAM,QAAQ,KAAK,IAAI,CAAE;EACzB,IAAI,QAAQ,KAAK,MAAM,MAAM;OACxB,IAAI,QAAQ,KAAK,OAAO,MAAM;OAC9B,OAAO;CACd;CACA,OAAO,EAAE,MAAM;AACjB;AAEA,SAAgB,mBAAmB,IAAa,IAAqB;CAEnE,IAAI,cAAc,UAAU,cAAc,UAAU,GAAG,WAAW,GAAG,QAAQ,OAAO;CACpF,OAAO,2BAA2B,EAAE,CAAC,CAAC,MAAM,2BAA2B,EAAE,CAAC,CAAC,CAAC,mBAAmB;AACjG;AAEA,SAAgB,2BAA2B,SAAyB;CAClE,MAAM,QAAQ,QAAQ,OAAO;CAC7B,MAAM,OAAO,QAAQ,OAAO,QAAQ,OAAO,SAAS;CACpD,OAAO,IAAI,OAAO,MAAM,WAAW,KAAK,YAAY,IAAI,MAAM,WAAW,KAAK,YAAY,CAAC;AAC7F"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PointTransformer } from "./point.js";
|
|
2
|
+
import { Cubic } from "./cubic.js";
|
|
3
|
+
//#region src/shapes/features.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* A part of a polygon outline: an edge, or a convex or concave corner. Morphing matches
|
|
6
|
+
* corresponding features (corners) between two shapes.
|
|
7
|
+
*/
|
|
8
|
+
export declare abstract class Feature {
|
|
9
|
+
readonly cubics: readonly Cubic[];
|
|
10
|
+
constructor(cubics: readonly Cubic[]);
|
|
11
|
+
abstract transformed(f: PointTransformer): Feature;
|
|
12
|
+
abstract reversed(): Feature;
|
|
13
|
+
abstract readonly isIgnorableFeature: boolean;
|
|
14
|
+
abstract readonly isEdge: boolean;
|
|
15
|
+
abstract readonly isConvexCorner: boolean;
|
|
16
|
+
abstract readonly isConcaveCorner: boolean;
|
|
17
|
+
static buildIgnorableFeature(cubics: readonly Cubic[]): Feature;
|
|
18
|
+
static buildEdge(cubic: Cubic): Feature;
|
|
19
|
+
static buildConvexCorner(cubics: readonly Cubic[]): Feature;
|
|
20
|
+
static buildConcaveCorner(cubics: readonly Cubic[]): Feature;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
//# sourceMappingURL=features.d.ts.map
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import "./point.js";
|
|
2
|
+
//#region src/shapes/features.ts
|
|
3
|
+
/**
|
|
4
|
+
* A part of a polygon outline: an edge, or a convex or concave corner. Morphing matches
|
|
5
|
+
* corresponding features (corners) between two shapes.
|
|
6
|
+
*/
|
|
7
|
+
var Feature = class {
|
|
8
|
+
cubics;
|
|
9
|
+
constructor(cubics) {
|
|
10
|
+
this.cubics = cubics;
|
|
11
|
+
}
|
|
12
|
+
static buildIgnorableFeature(cubics) {
|
|
13
|
+
return validated(new Edge(cubics));
|
|
14
|
+
}
|
|
15
|
+
static buildEdge(cubic) {
|
|
16
|
+
return new Edge([cubic]);
|
|
17
|
+
}
|
|
18
|
+
static buildConvexCorner(cubics) {
|
|
19
|
+
return validated(new Corner(cubics, true));
|
|
20
|
+
}
|
|
21
|
+
static buildConcaveCorner(cubics) {
|
|
22
|
+
return validated(new Corner(cubics, false));
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
function isContinuous(feature) {
|
|
26
|
+
let prev = feature.cubics[0];
|
|
27
|
+
for (let i = 1; i < feature.cubics.length; i++) {
|
|
28
|
+
const cubic = feature.cubics[i];
|
|
29
|
+
if (Math.abs(cubic.anchor0X - prev.anchor1X) > 1e-4 || Math.abs(cubic.anchor0Y - prev.anchor1Y) > 1e-4) return false;
|
|
30
|
+
prev = cubic;
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
function validated(feature) {
|
|
35
|
+
if (feature.cubics.length === 0) throw new Error("Features need at least one cubic.");
|
|
36
|
+
if (!isContinuous(feature)) throw new Error("Feature must be continuous, with the anchor points of all cubics matching the anchor points of the preceding and succeeding cubics");
|
|
37
|
+
return feature;
|
|
38
|
+
}
|
|
39
|
+
const reverseCubics = (cubics) => [...cubics].reverse().map((cubic) => cubic.reverse());
|
|
40
|
+
var Edge = class Edge extends Feature {
|
|
41
|
+
isIgnorableFeature = true;
|
|
42
|
+
isEdge = true;
|
|
43
|
+
isConvexCorner = false;
|
|
44
|
+
isConcaveCorner = false;
|
|
45
|
+
transformed(f) {
|
|
46
|
+
return new Edge(this.cubics.map((cubic) => cubic.transformed(f)));
|
|
47
|
+
}
|
|
48
|
+
reversed() {
|
|
49
|
+
return new Edge(reverseCubics(this.cubics));
|
|
50
|
+
}
|
|
51
|
+
toString() {
|
|
52
|
+
return "Edge";
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
var Corner = class Corner extends Feature {
|
|
56
|
+
convex;
|
|
57
|
+
isIgnorableFeature = false;
|
|
58
|
+
isEdge = false;
|
|
59
|
+
constructor(cubics, convex = true) {
|
|
60
|
+
super(cubics);
|
|
61
|
+
this.convex = convex;
|
|
62
|
+
}
|
|
63
|
+
get isConvexCorner() {
|
|
64
|
+
return this.convex;
|
|
65
|
+
}
|
|
66
|
+
get isConcaveCorner() {
|
|
67
|
+
return !this.convex;
|
|
68
|
+
}
|
|
69
|
+
transformed(f) {
|
|
70
|
+
return new Corner(this.cubics.map((cubic) => cubic.transformed(f)), this.convex);
|
|
71
|
+
}
|
|
72
|
+
reversed() {
|
|
73
|
+
return new Corner(reverseCubics(this.cubics), !this.convex);
|
|
74
|
+
}
|
|
75
|
+
toString() {
|
|
76
|
+
return `Corner: cubics=${this.cubics.map((c) => `[${c}]`).join(", ")} convex=${this.convex}`;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
//#endregion
|
|
80
|
+
export { Corner, Edge, Feature };
|
|
81
|
+
|
|
82
|
+
//# sourceMappingURL=features.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features.js","names":[],"sources":["../../src/shapes/features.ts"],"sourcesContent":["/*\n * Port of androidx.graphics.shapes Features.kt (Apache-2.0, see LICENSE-androidx.md).\n */\nimport type { Cubic } from './cubic';\nimport { DistanceEpsilon, type PointTransformer } from './point';\n\n/**\n * A part of a polygon outline: an edge, or a convex or concave corner. Morphing matches\n * corresponding features (corners) between two shapes.\n */\nexport abstract class Feature {\n constructor(readonly cubics: readonly Cubic[]) {}\n\n abstract transformed(f: PointTransformer): Feature;\n abstract reversed(): Feature;\n abstract readonly isIgnorableFeature: boolean;\n abstract readonly isEdge: boolean;\n abstract readonly isConvexCorner: boolean;\n abstract readonly isConcaveCorner: boolean;\n\n static buildIgnorableFeature(cubics: readonly Cubic[]): Feature {\n return validated(new Edge(cubics));\n }\n\n static buildEdge(cubic: Cubic): Feature {\n return new Edge([cubic]);\n }\n\n static buildConvexCorner(cubics: readonly Cubic[]): Feature {\n return validated(new Corner(cubics, true));\n }\n\n static buildConcaveCorner(cubics: readonly Cubic[]): Feature {\n return validated(new Corner(cubics, false));\n }\n}\n\nfunction isContinuous(feature: Feature): boolean {\n let prev = feature.cubics[0]!;\n for (let i = 1; i < feature.cubics.length; i++) {\n const cubic = feature.cubics[i]!;\n if (\n Math.abs(cubic.anchor0X - prev.anchor1X) > DistanceEpsilon ||\n Math.abs(cubic.anchor0Y - prev.anchor1Y) > DistanceEpsilon\n ) {\n return false;\n }\n prev = cubic;\n }\n return true;\n}\n\nfunction validated(feature: Feature): Feature {\n if (feature.cubics.length === 0) throw new Error('Features need at least one cubic.');\n if (!isContinuous(feature)) {\n throw new Error(\n 'Feature must be continuous, with the anchor points of all cubics matching the anchor points of the preceding and succeeding cubics',\n );\n }\n return feature;\n}\n\nconst reverseCubics = (cubics: readonly Cubic[]) =>\n [...cubics].reverse().map((cubic) => cubic.reverse());\n\nexport class Edge extends Feature {\n readonly isIgnorableFeature = true;\n readonly isEdge = true;\n readonly isConvexCorner = false;\n readonly isConcaveCorner = false;\n\n transformed(f: PointTransformer): Edge {\n return new Edge(this.cubics.map((cubic) => cubic.transformed(f)));\n }\n\n reversed(): Edge {\n return new Edge(reverseCubics(this.cubics));\n }\n\n override toString(): string {\n return 'Edge';\n }\n}\n\nexport class Corner extends Feature {\n readonly isIgnorableFeature = false;\n readonly isEdge = false;\n\n constructor(\n cubics: readonly Cubic[],\n readonly convex = true,\n ) {\n super(cubics);\n }\n\n get isConvexCorner(): boolean {\n return this.convex;\n }\n\n get isConcaveCorner(): boolean {\n return !this.convex;\n }\n\n transformed(f: PointTransformer): Corner {\n return new Corner(\n this.cubics.map((cubic) => cubic.transformed(f)),\n this.convex,\n );\n }\n\n reversed(): Corner {\n // androidx b/369320447: the flag is negated until RoundedPolygon ignores orientation.\n return new Corner(reverseCubics(this.cubics), !this.convex);\n }\n\n override toString(): string {\n return `Corner: cubics=${this.cubics.map((c) => `[${c}]`).join(', ')} convex=${this.convex}`;\n }\n}\n"],"mappings":";;;;;;AAUA,IAAsB,UAAtB,MAA8B;CACP;CAArB,YAAY,QAAmC;EAA1B,KAAA,SAAA;CAA2B;CAShD,OAAO,sBAAsB,QAAmC;EAC9D,OAAO,UAAU,IAAI,KAAK,MAAM,CAAC;CACnC;CAEA,OAAO,UAAU,OAAuB;EACtC,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC;CACzB;CAEA,OAAO,kBAAkB,QAAmC;EAC1D,OAAO,UAAU,IAAI,OAAO,QAAQ,IAAI,CAAC;CAC3C;CAEA,OAAO,mBAAmB,QA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AK,OAAO,KAAK,UAAU,MAAM,YAAY,CAAC,CAAC,GAC/C,KAAK,MACP;CACF;CAEA,WAAmB;EAEjB,OAAO,IAAI,OAAO,cAAc,KAAK,MAAM,GAAG,CAAC,KAAK,MAAM;CAC5D;CAEA,WAA4B;EAC1B,OAAO,kBAAkB,KAAK,OAAO,KAAK,MAAM,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,EAAE,UAAU,KAAK;CACtF;AACF"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { positiveModulo } from "./point.js";
|
|
2
|
+
//#region src/shapes/float-mapping.ts
|
|
3
|
+
/** Whether `progress` lies in `[from, to]`, where the range may wrap around 1. */
|
|
4
|
+
function progressInRange(progress, from, to) {
|
|
5
|
+
return to >= from ? progress >= from && progress <= to : progress >= from || progress <= to;
|
|
6
|
+
}
|
|
7
|
+
/** Maps `x` through the piecewise-linear, wrapping function given by the two value lists. */
|
|
8
|
+
function linearMap(xValues, yValues, x) {
|
|
9
|
+
if (!(x >= 0 && x <= 1)) throw new Error(`Invalid progress: ${x}`);
|
|
10
|
+
const n = xValues.length;
|
|
11
|
+
const segmentStartIndex = xValues.findIndex((_, i) => progressInRange(x, xValues[i], xValues[(i + 1) % n]));
|
|
12
|
+
const segmentEndIndex = (segmentStartIndex + 1) % n;
|
|
13
|
+
const segmentSizeX = positiveModulo(xValues[segmentEndIndex] - xValues[segmentStartIndex], 1);
|
|
14
|
+
const segmentSizeY = positiveModulo(yValues[segmentEndIndex] - yValues[segmentStartIndex], 1);
|
|
15
|
+
const positionInSegment = segmentSizeX < .001 ? .5 : positiveModulo(x - xValues[segmentStartIndex], 1) / segmentSizeX;
|
|
16
|
+
return positiveModulo(yValues[segmentStartIndex] + segmentSizeY * positionInSegment, 1);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A bidirectional mapping between two progress spaces, both `[0, 1)` and wrapping. Each
|
|
20
|
+
* mapping pair anchors one source progress to one target progress.
|
|
21
|
+
*/
|
|
22
|
+
var DoubleMapper = class DoubleMapper {
|
|
23
|
+
static Identity = new DoubleMapper([0, 0], [.5, .5]);
|
|
24
|
+
sourceValues;
|
|
25
|
+
targetValues;
|
|
26
|
+
constructor(...mappings) {
|
|
27
|
+
this.sourceValues = mappings.map(([source]) => source);
|
|
28
|
+
this.targetValues = mappings.map(([, target]) => target);
|
|
29
|
+
validateProgress(this.sourceValues);
|
|
30
|
+
validateProgress(this.targetValues);
|
|
31
|
+
}
|
|
32
|
+
map(x) {
|
|
33
|
+
return linearMap(this.sourceValues, this.targetValues, x);
|
|
34
|
+
}
|
|
35
|
+
mapBack(x) {
|
|
36
|
+
return linearMap(this.targetValues, this.sourceValues, x);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Checks that every progress value is in `[0, 1)` and that the list (including the last to
|
|
41
|
+
* first pair) increases monotonically, wrapping at most once. `(0.3, 0.6, 0)` is valid;
|
|
42
|
+
* `(0.5, 0, 0.7)` is not.
|
|
43
|
+
*/
|
|
44
|
+
function validateProgress(p) {
|
|
45
|
+
let prev = p[p.length - 1];
|
|
46
|
+
let wraps = 0;
|
|
47
|
+
for (const curr of p) {
|
|
48
|
+
if (!(curr >= 0 && curr < 1)) throw new Error(`FloatMapping - Progress outside of range: ${p.join(", ")}`);
|
|
49
|
+
if (!(progressDistance(curr, prev) > 1e-4)) throw new Error(`FloatMapping - Progress repeats a value: ${p.join(", ")}`);
|
|
50
|
+
if (curr < prev) {
|
|
51
|
+
wraps++;
|
|
52
|
+
if (wraps > 1) throw new Error(`FloatMapping - Progress wraps more than once: ${p.join(", ")}`);
|
|
53
|
+
}
|
|
54
|
+
prev = curr;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/** Distance between two wrapping progress values: 0.99 and 0 are 0.01 apart. */
|
|
58
|
+
function progressDistance(p1, p2) {
|
|
59
|
+
const d = Math.abs(p1 - p2);
|
|
60
|
+
return Math.min(d, 1 - d);
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
export { DoubleMapper, linearMap, progressDistance, progressInRange, validateProgress };
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=float-mapping.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"float-mapping.js","names":[],"sources":["../../src/shapes/float-mapping.ts"],"sourcesContent":["/*\n * Port of androidx.graphics.shapes FloatMapping.kt (Apache-2.0, see LICENSE-androidx.md).\n */\nimport { DistanceEpsilon, positiveModulo } from './point';\n\n/** Whether `progress` lies in `[from, to]`, where the range may wrap around 1. */\nexport function progressInRange(progress: number, from: number, to: number): boolean {\n return to >= from ? progress >= from && progress <= to : progress >= from || progress <= to;\n}\n\n/** Maps `x` through the piecewise-linear, wrapping function given by the two value lists. */\nexport function linearMap(\n xValues: readonly number[],\n yValues: readonly number[],\n x: number,\n): number {\n if (!(x >= 0 && x <= 1)) throw new Error(`Invalid progress: ${x}`);\n const n = xValues.length;\n const segmentStartIndex = xValues.findIndex((_, i) =>\n progressInRange(x, xValues[i]!, xValues[(i + 1) % n]!),\n );\n const segmentEndIndex = (segmentStartIndex + 1) % n;\n const segmentSizeX = positiveModulo(xValues[segmentEndIndex]! - xValues[segmentStartIndex]!, 1);\n const segmentSizeY = positiveModulo(yValues[segmentEndIndex]! - yValues[segmentStartIndex]!, 1);\n const positionInSegment =\n segmentSizeX < 0.001 ? 0.5 : positiveModulo(x - xValues[segmentStartIndex]!, 1) / segmentSizeX;\n return positiveModulo(yValues[segmentStartIndex]! + segmentSizeY * positionInSegment, 1);\n}\n\n/**\n * A bidirectional mapping between two progress spaces, both `[0, 1)` and wrapping. Each\n * mapping pair anchors one source progress to one target progress.\n */\nexport class DoubleMapper {\n static readonly Identity = new DoubleMapper([0, 0], [0.5, 0.5]);\n\n private readonly sourceValues: number[];\n private readonly targetValues: number[];\n\n constructor(...mappings: readonly (readonly [number, number])[]) {\n this.sourceValues = mappings.map(([source]) => source);\n this.targetValues = mappings.map(([, target]) => target);\n // Both lists must increase monotonically, except for at most one wrap-around.\n validateProgress(this.sourceValues);\n validateProgress(this.targetValues);\n }\n\n map(x: number): number {\n return linearMap(this.sourceValues, this.targetValues, x);\n }\n\n mapBack(x: number): number {\n return linearMap(this.targetValues, this.sourceValues, x);\n }\n}\n\n/**\n * Checks that every progress value is in `[0, 1)` and that the list (including the last to\n * first pair) increases monotonically, wrapping at most once. `(0.3, 0.6, 0)` is valid;\n * `(0.5, 0, 0.7)` is not.\n */\nexport function validateProgress(p: readonly number[]): void {\n let prev = p[p.length - 1]!;\n let wraps = 0;\n for (const curr of p) {\n if (!(curr >= 0 && curr < 1)) {\n throw new Error(`FloatMapping - Progress outside of range: ${p.join(', ')}`);\n }\n if (!(progressDistance(curr, prev) > DistanceEpsilon)) {\n throw new Error(`FloatMapping - Progress repeats a value: ${p.join(', ')}`);\n }\n if (curr < prev) {\n wraps++;\n if (wraps > 1) {\n throw new Error(`FloatMapping - Progress wraps more than once: ${p.join(', ')}`);\n }\n }\n prev = curr;\n }\n}\n\n/** Distance between two wrapping progress values: 0.99 and 0 are 0.01 apart. */\nexport function progressDistance(p1: number, p2: number): number {\n const d = Math.abs(p1 - p2);\n return Math.min(d, 1 - d);\n}\n"],"mappings":";;;AAMA,SAAgB,gBAAgB,UAAkB,MAAc,IAAqB;CACnF,OAAO,MAAM,OAAO,YAAY,QAAQ,YAAY,KAAK,YAAY,QAAQ,YAAY;AAC3F;;AAGA,SAAgB,UACd,SACA,SACA,GACQ;CACR,IAAI,EAAE,KAAK,KAAK,KAAK,IAAI,MAAM,IAAI,MAAM,qBAAqB,GAAG;CACjE,MAAM,IAAI,QAAQ;CAClB,MAAM,oBAAoB,QAAQ,WAAW,GAAG,MAC9C,gBAAgB,GAAG,QAAQ,IAAK,SAAS,IAAI,KAAK,EAAG,CACvD;CACA,MAAM,mBAAmB,oBAAoB,KAAK;CAClD,MAAM,eAAe,eAAe,QAAQ,mBAAoB,QAAQ,oBAAqB,CAAC;CAC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AAC;AAC1B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MaterialShapePath } from "../shape-path.js";
|
|
2
|
+
import { MaterialShapeName } from "./material-shape-paths.js";
|
|
3
|
+
//#region src/shapes/generated/material-shape-path-record.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Every M3 Expressive shape's precomputed outline by name, for a shape gallery or picker.
|
|
6
|
+
* Importing it costs all 35 outlines (about 11 kB gzipped once minified); to draw one shape, import its
|
|
7
|
+
* constant (`cookie12SidedShape`) instead.
|
|
8
|
+
*/
|
|
9
|
+
export declare const materialShapePaths: Readonly<Record<MaterialShapeName, MaterialShapePath>>;
|
|
10
|
+
//#endregion
|
|
11
|
+
//# sourceMappingURL=material-shape-path-record.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { archShape, arrowShape, boomShape, bunShape, burstShape, circleShape, clamShellShape, clover4LeafShape, clover8LeafShape, cookie12SidedShape, cookie4SidedShape, cookie6SidedShape, cookie7SidedShape, cookie9SidedShape, diamondShape, fanShape, flowerShape, gemShape, ghostishShape, heartShape, ovalShape, pentagonShape, pillShape, pixelCircleShape, pixelTriangleShape, puffyDiamondShape, puffyShape, semiCircleShape, slantedShape, softBoomShape, softBurstShape, squareShape, sunnyShape, triangleShape, verySunnyShape } from "./material-shape-paths.js";
|
|
2
|
+
//#region src/shapes/generated/material-shape-path-record.ts
|
|
3
|
+
/**
|
|
4
|
+
* Every M3 Expressive shape's precomputed outline by name, for a shape gallery or picker.
|
|
5
|
+
* Importing it costs all 35 outlines (about 11 kB gzipped once minified); to draw one shape, import its
|
|
6
|
+
* constant (`cookie12SidedShape`) instead.
|
|
7
|
+
*/
|
|
8
|
+
const materialShapePaths = {
|
|
9
|
+
Circle: circleShape,
|
|
10
|
+
Square: squareShape,
|
|
11
|
+
Slanted: slantedShape,
|
|
12
|
+
Arch: archShape,
|
|
13
|
+
Fan: fanShape,
|
|
14
|
+
Arrow: arrowShape,
|
|
15
|
+
SemiCircle: semiCircleShape,
|
|
16
|
+
Oval: ovalShape,
|
|
17
|
+
Pill: pillShape,
|
|
18
|
+
Triangle: triangleShape,
|
|
19
|
+
Diamond: diamondShape,
|
|
20
|
+
ClamShell: clamShellShape,
|
|
21
|
+
Pentagon: pentagonShape,
|
|
22
|
+
Gem: gemShape,
|
|
23
|
+
Sunny: sunnyShape,
|
|
24
|
+
VerySunny: verySunnyShape,
|
|
25
|
+
Cookie4Sided: cookie4SidedShape,
|
|
26
|
+
Cookie6Sided: cookie6SidedShape,
|
|
27
|
+
Cookie7Sided: cookie7SidedShape,
|
|
28
|
+
Cookie9Sided: cookie9SidedShape,
|
|
29
|
+
Cookie12Sided: cookie12SidedShape,
|
|
30
|
+
Ghostish: ghostishShape,
|
|
31
|
+
Clover4Leaf: clover4LeafShape,
|
|
32
|
+
Clover8Leaf: clover8LeafShape,
|
|
33
|
+
Burst: burstShape,
|
|
34
|
+
SoftBurst: softBurstShape,
|
|
35
|
+
Boom: boomShape,
|
|
36
|
+
SoftBoom: softBoomShape,
|
|
37
|
+
Flower: flowerShape,
|
|
38
|
+
Puffy: puffyShape,
|
|
39
|
+
PuffyDiamond: puffyDiamondShape,
|
|
40
|
+
PixelCircle: pixelCircleShape,
|
|
41
|
+
PixelTriangle: pixelTriangleShape,
|
|
42
|
+
Bun: bunShape,
|
|
43
|
+
Heart: heartShape
|
|
44
|
+
};
|
|
45
|
+
//#endregion
|
|
46
|
+
export { materialShapePaths };
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=material-shape-path-record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"material-shape-path-record.js","names":[],"sources":["../../../src/shapes/generated/material-shape-path-record.ts"],"sourcesContent":["/* Generated by @windmorph/react from src/shapes/material-shapes.ts (pnpm generate). Do not edit by hand. */\nimport type { MaterialShapePath } from '../shape-path';\nimport {\n circleShape,\n squareShape,\n slantedShape,\n archShape,\n fanShape,\n arrowShape,\n semiCircleShape,\n ovalShape,\n pillShape,\n triangleShape,\n diamondShape,\n clamShellShape,\n pentagonShape,\n gemShape,\n sunnyShape,\n verySunnyShape,\n cookie4SidedShape,\n cookie6SidedShape,\n cookie7SidedShape,\n cookie9SidedShape,\n cookie12SidedShape,\n ghostishShape,\n clover4LeafShape,\n clover8LeafShape,\n burstShape,\n softBurstShape,\n boomShape,\n softBoomShape,\n flowerShape,\n puffyShape,\n puffyDiamondShape,\n pixelCircleShape,\n pixelTriangleShape,\n bunShape,\n heartShape,\n type MaterialShapeName,\n} from './material-shape-paths';\n\n/**\n * Every M3 Expressive shape's precomputed outline by name, for a shape gallery or picker.\n * Importing it costs all 35 outlines (about 11 kB gzipped once minified); to draw one shape, import its\n * constant (`cookie12SidedShape`) instead.\n */\nexport const materialShapePaths: Readonly<Record<MaterialShapeName, MaterialShapePath>> = {\n Circle: circleShape,\n Square: squareShape,\n Slanted: slantedShape,\n Arch: archShape,\n Fan: fanShape,\n Arrow: arrowShape,\n SemiCircle: semiCircleShape,\n Oval: ovalShape,\n Pill: pillShape,\n Triangle: triangleShape,\n Diamond: diamondShape,\n ClamShell: clamShellShape,\n Pentagon: pentagonShape,\n Gem: gemShape,\n Sunny: sunnyShape,\n VerySunny: verySunnyShape,\n Cookie4Sided: cookie4SidedShape,\n Cookie6Sided: cookie6SidedShape,\n Cookie7Sided: cookie7SidedShape,\n Cookie9Sided: cookie9SidedShape,\n Cookie12Sided: cookie12SidedShape,\n Ghostish: ghostishShape,\n Clover4Leaf: clover4LeafShape,\n Clover8Leaf: clover8LeafShape,\n Burst: burstShape,\n SoftBurst: softBurstShape,\n Boom: boomShape,\n SoftBoom: softBoomShape,\n Flower: flowerShape,\n Puffy: puffyShape,\n PuffyDiamond: puffyDiamondShape,\n PixelCircle: pixelCircleShape,\n PixelTriangle: pixelTriangleShape,\n Bun: bunShape,\n Heart: heartShape,\n};\n"],"mappings":";;;;;;;AA8CA,MAAa,qBAA6E;CACxF,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,MAAM;CACN,KAAK;CACL,OAAO;CACP,YAAY;CACZ,MAAM;CACN,MAAM;CACN,UAAU;CACV,SAAS;CACT,WAAW;CACX,UAAU;CACV,KAAK;CACL,OAAO;CACP,WAAW;CACX,cAAc;CACd,cAAc;CACd,cAAc;CACd,cAAc;CACd,eAAe;CACf,UAAU;CACV,aAAa;CACb,aAAa;CACb,OAAO;CACP,WAAW;CACX,MAAM;CACN,UAAU;CACV,QAAQ;CACR,OAAO;CACP,cAAc;CACd,aAAa;CACb,eAAe;CACf,KAAK;CACL,OAAO;AACT"}
|