@quan-erp/shared-ui 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +90 -0
- package/dist/common/common.d.ts +2 -0
- package/dist/components/blocks/editor-00/editor.d.ts +8 -0
- package/dist/components/blocks/editor-00/nodes.d.ts +3 -0
- package/dist/components/blocks/editor-00/plugins.d.ts +2 -0
- package/dist/components/custom/confirm-dialog.d.ts +15 -0
- package/dist/components/custom/dashboard.d.ts +22 -0
- package/dist/components/custom/data-table/cursor-based-pagination.d.ts +9 -0
- package/dist/components/custom/data-table/data-table-bulk-action-menu.d.ts +9 -0
- package/dist/components/custom/data-table/data-table-bulk-export.d.ts +8 -0
- package/dist/components/custom/data-table/data-table-column-header.d.ts +9 -0
- package/dist/components/custom/data-table/data-table-grid.d.ts +21 -0
- package/dist/components/custom/data-table/data-table-group-by.types.d.ts +11 -0
- package/dist/components/custom/data-table/data-table-helper.d.ts +2 -0
- package/dist/components/custom/data-table/data-table-list-view.d.ts +13 -0
- package/dist/components/custom/data-table/data-table-page-size.d.ts +11 -0
- package/dist/components/custom/data-table/data-table-pagination.d.ts +9 -0
- package/dist/components/custom/data-table/data-table-toolbar.d.ts +26 -0
- package/dist/components/custom/data-table/data-table-util.d.ts +7 -0
- package/dist/components/custom/data-table/data-table-view-fallback.d.ts +2 -0
- package/dist/components/custom/data-table/data-table-view-options.d.ts +17 -0
- package/dist/components/custom/data-table/data-table-view-preferences.d.ts +22 -0
- package/dist/components/custom/data-table/data-table-view-preferences.storage.d.ts +15 -0
- package/dist/components/custom/data-table/data-table-wrapper.d.ts +51 -0
- package/dist/components/custom/data-table/data-table.d.ts +47 -0
- package/dist/components/custom/data-table/export.d.ts +22 -0
- package/dist/components/custom/data-table/group-table-rows.d.ts +3 -0
- package/dist/components/custom/data-table/types.d.ts +17 -0
- package/dist/components/custom/data-table/use-data-table-page-size.d.ts +41 -0
- package/dist/components/custom/document-title.d.ts +4 -0
- package/dist/components/custom/empty-screen.d.ts +8 -0
- package/dist/components/custom/error-screen.d.ts +9 -0
- package/dist/components/custom/floating-action-btn.d.ts +39 -0
- package/dist/components/custom/index.d.ts +20 -0
- package/dist/components/custom/loading-screen.d.ts +7 -0
- package/dist/components/custom/menu-tab.d.ts +17 -0
- package/dist/components/custom/page.d.ts +35 -0
- package/dist/components/custom/plugin-theme.d.ts +8 -0
- package/dist/components/custom/portal.d.ts +4 -0
- package/dist/components/custom/protected-page.d.ts +26 -0
- package/dist/components/custom/pull-to-refresh.d.ts +16 -0
- package/dist/components/custom/render-in-view.d.ts +12 -0
- package/dist/components/custom/responsive-dialog.d.ts +47 -0
- package/dist/components/custom/safearea.d.ts +5 -0
- package/dist/components/custom/scrollable.d.ts +17 -0
- package/dist/components/custom/search-and-filter-suite.d.ts +16 -0
- package/dist/components/custom/setting.d.ts +30 -0
- package/dist/components/custom/submenu-hub.d.ts +17 -0
- package/dist/components/editor/editor-ui/content-editable.d.ts +9 -0
- package/dist/components/editor/themes/editor-theme.d.ts +3 -0
- package/dist/components/ui/accordion.d.ts +8 -0
- package/dist/components/ui/alert-dialog.d.ts +19 -0
- package/dist/components/ui/alert.d.ts +9 -0
- package/dist/components/ui/avatar.d.ts +7 -0
- package/dist/components/ui/badge.d.ts +10 -0
- package/dist/components/ui/breadcrumb.d.ts +20 -0
- package/dist/components/ui/button-group.d.ts +12 -0
- package/dist/components/ui/button.d.ts +11 -0
- package/dist/components/ui/calendar.d.ts +12 -0
- package/dist/components/ui/card.d.ts +10 -0
- package/dist/components/ui/carousel.d.ts +29 -0
- package/dist/components/ui/chart.d.ts +63 -0
- package/dist/components/ui/checkbox.d.ts +5 -0
- package/dist/components/ui/collapsible.d.ts +6 -0
- package/dist/components/ui/command.d.ts +81 -0
- package/dist/components/ui/context-menu.d.ts +28 -0
- package/dist/components/ui/dialog.d.ts +16 -0
- package/dist/components/ui/drawer.d.ts +23 -0
- package/dist/components/ui/dropdown-menu.d.ts +28 -0
- package/dist/components/ui/field.d.ts +25 -0
- package/dist/components/ui/form.d.ts +26 -0
- package/dist/components/ui/hover-card.d.ts +7 -0
- package/dist/components/ui/index.d.ts +54 -0
- package/dist/components/ui/input-group.d.ts +17 -0
- package/dist/components/ui/input-otp.d.ts +35 -0
- package/dist/components/ui/input.d.ts +10 -0
- package/dist/components/ui/item.d.ts +24 -0
- package/dist/components/ui/kbd.d.ts +4 -0
- package/dist/components/ui/label.d.ts +5 -0
- package/dist/components/ui/menubar.d.ts +29 -0
- package/dist/components/ui/navigation-menu.d.ts +13 -0
- package/dist/components/ui/pagination.d.ts +28 -0
- package/dist/components/ui/popover.d.ts +8 -0
- package/dist/components/ui/progress.d.ts +5 -0
- package/dist/components/ui/radio-group.d.ts +6 -0
- package/dist/components/ui/resizable.d.ts +24 -0
- package/dist/components/ui/scroll-area.d.ts +6 -0
- package/dist/components/ui/select.d.ts +14 -0
- package/dist/components/ui/separator.d.ts +5 -0
- package/dist/components/ui/sheet.d.ts +16 -0
- package/dist/components/ui/sidebar.d.ts +71 -0
- package/dist/components/ui/skeleton.d.ts +3 -0
- package/dist/components/ui/slider.d.ts +12 -0
- package/dist/components/ui/sonner.d.ts +6 -0
- package/dist/components/ui/spinner.d.ts +9 -0
- package/dist/components/ui/switch.d.ts +11 -0
- package/dist/components/ui/table.d.ts +14 -0
- package/dist/components/ui/tabs.d.ts +16 -0
- package/dist/components/ui/textarea.d.ts +10 -0
- package/dist/components/ui/time-picker.d.ts +13 -0
- package/dist/components/ui/toggle-group.d.ts +13 -0
- package/dist/components/ui/toggle.d.ts +10 -0
- package/dist/components/ui/tooltip.d.ts +8 -0
- package/dist/es/common/common.js +4 -0
- package/dist/es/components/blocks/editor-00/editor.js +49 -0
- package/dist/es/components/blocks/editor-00/nodes.js +6 -0
- package/dist/es/components/blocks/editor-00/plugins.js +23 -0
- package/dist/es/components/custom/confirm-dialog.js +34 -0
- package/dist/es/components/custom/dashboard.js +86 -0
- package/dist/es/components/custom/data-table/cursor-based-pagination.js +123 -0
- package/dist/es/components/custom/data-table/data-table-bulk-action-menu.js +112 -0
- package/dist/es/components/custom/data-table/data-table-bulk-export.js +76 -0
- package/dist/es/components/custom/data-table/data-table-column-header.js +102 -0
- package/dist/es/components/custom/data-table/data-table-grid.js +234 -0
- package/dist/es/components/custom/data-table/data-table-helper.js +8 -0
- package/dist/es/components/custom/data-table/data-table-list-view.js +121 -0
- package/dist/es/components/custom/data-table/data-table-page-size.js +49 -0
- package/dist/es/components/custom/data-table/data-table-pagination.js +156 -0
- package/dist/es/components/custom/data-table/data-table-toolbar.js +149 -0
- package/dist/es/components/custom/data-table/data-table-util.js +31 -0
- package/dist/es/components/custom/data-table/data-table-view-fallback.js +7 -0
- package/dist/es/components/custom/data-table/data-table-view-options.js +311 -0
- package/dist/es/components/custom/data-table/data-table-view-preferences.js +71 -0
- package/dist/es/components/custom/data-table/data-table-view-preferences.storage.js +115 -0
- package/dist/es/components/custom/data-table/data-table.js +425 -0
- package/dist/es/components/custom/data-table/group-table-rows.js +16 -0
- package/dist/es/components/custom/data-table/use-data-table-page-size.js +155 -0
- package/dist/es/components/custom/empty-screen.js +28 -0
- package/dist/es/components/custom/error-screen.js +84 -0
- package/dist/es/components/custom/floating-action-btn.js +200 -0
- package/dist/es/components/custom/loading-screen.js +26 -0
- package/dist/es/components/custom/menu-tab.js +45 -0
- package/dist/es/components/custom/page.js +105 -0
- package/dist/es/components/custom/plugin-theme.js +13 -0
- package/dist/es/components/custom/portal.js +13 -0
- package/dist/es/components/custom/protected-page.js +74 -0
- package/dist/es/components/custom/pull-to-refresh.js +378 -0
- package/dist/es/components/custom/render-in-view.js +35 -0
- package/dist/es/components/custom/responsive-dialog.js +163 -0
- package/dist/es/components/custom/safearea.js +8 -0
- package/dist/es/components/custom/scrollable.js +96 -0
- package/dist/es/components/custom/setting.js +39 -0
- package/dist/es/components/editor/editor-ui/content-editable.js +26 -0
- package/dist/es/components/editor/themes/editor-theme.js +119 -0
- package/dist/es/components/ui/accordion.js +47 -0
- package/dist/es/components/ui/alert-dialog.js +178 -0
- package/dist/es/components/ui/alert.js +51 -0
- package/dist/es/components/ui/avatar.js +42 -0
- package/dist/es/components/ui/badge.js +27 -0
- package/dist/es/components/ui/breadcrumb.js +93 -0
- package/dist/es/components/ui/button-group.js +76 -0
- package/dist/es/components/ui/button.js +57 -0
- package/dist/es/components/ui/calendar.js +402 -0
- package/dist/es/components/ui/card.js +91 -0
- package/dist/es/components/ui/carousel.js +194 -0
- package/dist/es/components/ui/chart.js +239 -0
- package/dist/es/components/ui/checkbox.js +27 -0
- package/dist/es/components/ui/collapsible.js +9 -0
- package/dist/es/components/ui/command.js +115 -0
- package/dist/es/components/ui/context-menu.js +153 -0
- package/dist/es/components/ui/dialog.js +137 -0
- package/dist/es/components/ui/drawer.js +107 -0
- package/dist/es/components/ui/dropdown-menu.js +152 -0
- package/dist/es/components/ui/field.js +226 -0
- package/dist/es/components/ui/form.js +109 -0
- package/dist/es/components/ui/hover-card.js +25 -0
- package/dist/es/components/ui/input-group.js +155 -0
- package/dist/es/components/ui/input-otp.js +49 -0
- package/dist/es/components/ui/input.js +37 -0
- package/dist/es/components/ui/item.js +188 -0
- package/dist/es/components/ui/kbd.js +31 -0
- package/dist/es/components/ui/label.js +23 -0
- package/dist/es/components/ui/menubar.js +202 -0
- package/dist/es/components/ui/navigation-menu.js +107 -0
- package/dist/es/components/ui/pagination.js +101 -0
- package/dist/es/components/ui/popover.js +27 -0
- package/dist/es/components/ui/progress.js +26 -0
- package/dist/es/components/ui/radio-group.js +35 -0
- package/dist/es/components/ui/resizable.js +38 -0
- package/dist/es/components/ui/scroll-area.js +38 -0
- package/dist/es/components/ui/select.js +124 -0
- package/dist/es/components/ui/separator.js +27 -0
- package/dist/es/components/ui/sheet.js +129 -0
- package/dist/es/components/ui/sidebar.js +604 -0
- package/dist/es/components/ui/skeleton.js +17 -0
- package/dist/es/components/ui/slider.js +62 -0
- package/dist/es/components/ui/sonner.js +26 -0
- package/dist/es/components/ui/spinner.js +34 -0
- package/dist/es/components/ui/switch.js +54 -0
- package/dist/es/components/ui/table.js +90 -0
- package/dist/es/components/ui/tabs.js +84 -0
- package/dist/es/components/ui/textarea.js +32 -0
- package/dist/es/components/ui/time-picker.js +199 -0
- package/dist/es/components/ui/toggle-group.js +43 -0
- package/dist/es/components/ui/toggle.js +44 -0
- package/dist/es/components/ui/tooltip.js +56 -0
- package/dist/es/hooks/use-debounce-value.js +16 -0
- package/dist/es/hooks/use-is-inview.js +25 -0
- package/dist/es/hooks/use-mobile-back-dialog.js +34 -0
- package/dist/es/hooks/use-mobile.js +43 -0
- package/dist/es/hooks/use-mounted.js +14 -0
- package/dist/es/hooks/use-scroll-direction.js +26 -0
- package/dist/es/hooks/use-user-hand-behavior.js +20 -0
- package/dist/es/index.d.ts +2 -0
- package/dist/es/index.js +487 -0
- package/dist/es/lib/utils.js +8 -0
- package/dist/es/locale/locale.js +87 -0
- package/dist/es/node_modules/@tanstack/react-table/build/lib/index.js +93 -0
- package/dist/es/node_modules/@tanstack/table-core/build/lib/index.js +2737 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/components/AnimatePresence/PopChild.js +85 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/components/AnimatePresence/PresenceChild.js +49 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/components/AnimatePresence/index.js +86 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/components/AnimatePresence/use-presence.js +19 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/components/AnimatePresence/utils.js +14 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/context/LayoutGroupContext.js +5 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/context/LazyContext.js +5 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/context/MotionConfigContext.js +9 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/context/MotionContext/create.js +13 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/context/MotionContext/index.js +5 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/context/MotionContext/utils.js +15 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/context/PresenceContext.js +5 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/context/SwitchLayoutGroupContext.js +5 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/events/add-pointer-event.js +8 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/events/event-info.js +14 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/gestures/drag/VisualElementDragControls.js +432 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/gestures/drag/index.js +38 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/gestures/drag/utils/constraints.js +93 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/gestures/focus.js +35 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/gestures/hover.js +31 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/gestures/pan/PanSession.js +215 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/gestures/pan/index.js +50 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/gestures/press.js +38 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/motion/features/animation/exit.js +60 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/motion/features/animation/index.js +40 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/motion/features/animations.js +13 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/motion/features/definitions.js +42 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/motion/features/drag.js +17 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/motion/features/gestures.js +21 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/motion/features/layout/MeasureLayout.js +111 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/motion/features/layout.js +11 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/motion/features/load-features.js +15 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/motion/features/viewport/index.js +64 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/motion/features/viewport/observers.js +33 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/motion/index.js +69 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/motion/utils/symbol.js +4 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/motion/utils/use-motion-ref.js +35 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/motion/utils/use-visual-element.js +106 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/motion/utils/use-visual-state.js +66 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/motion/utils/valid-prop.js +39 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/render/components/create-proxy.js +35 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/render/components/motion/feature-bundle.js +13 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/render/components/motion/proxy.js +7 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/render/dom/create-visual-element.js +13 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/render/dom/use-render.js +21 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/render/dom/utils/filter-props.js +31 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/render/dom/utils/is-svg-component.js +29 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/render/html/use-html-visual-state.js +10 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/render/html/use-props.js +44 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/render/html/utils/create-render-state.js +9 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/render/svg/lowercase-elements.js +30 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/render/svg/use-props.js +24 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/render/svg/use-svg-visual-state.js +10 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/render/svg/utils/create-render-state.js +8 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/utils/distance.js +10 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/utils/get-context-window.js +6 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/utils/is-browser.js +4 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/utils/is-ref-object.js +6 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/utils/use-composed-ref.js +38 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/utils/use-constant.js +11 -0
- package/dist/es/shared-ui/node_modules/framer-motion/dist/es/utils/use-isomorphic-effect.js +6 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/AsyncMotionValueAnimation.js +153 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/JSAnimation.js +294 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/NativeAnimation.js +160 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/NativeAnimationExtended.js +51 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/animate/single-value.js +11 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/drivers/frame.js +17 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/generators/inertia.js +67 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/generators/keyframes.js +37 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/generators/spring.js +246 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/generators/utils/calc-duration.js +15 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/generators/utils/create-generator-easing.js +16 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/generators/utils/is-generator.js +6 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/generators/utils/velocity.js +9 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/interfaces/motion-value.js +69 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/interfaces/visual-element-target.js +78 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/interfaces/visual-element-variant.js +36 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/interfaces/visual-element.js +22 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/keyframes/DOMKeyframesResolver.js +107 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/keyframes/KeyframesResolver.js +131 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/keyframes/get-final.js +10 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/keyframes/offsets/default.js +9 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/keyframes/offsets/fill.js +12 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/keyframes/offsets/time.js +6 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/keyframes/utils/fill-wildcards.js +8 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/keyframes/utils/is-none.js +13 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/keyframes/utils/make-none-animatable.js +22 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/keyframes/utils/unit-conversion.js +43 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/optimized-appear/data-id.js +7 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/optimized-appear/get-appear-id.js +7 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/utils/WithPromise.js +27 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/utils/calc-child-stagger.js +10 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/utils/can-animate.js +31 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/utils/css-variables-conversion.js +31 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/utils/default-transitions.js +33 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/utils/get-value-transition.js +11 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/utils/is-animatable.js +16 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/utils/is-css-variable.js +20 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/utils/is-transition-defined.js +22 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/utils/make-animation-instant.js +7 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/utils/replace-transition-type.js +18 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/utils/resolve-transition.js +10 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/waapi/easing/cubic-bezier.js +4 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/waapi/easing/map-easing.js +21 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/waapi/easing/supported.js +15 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/waapi/start-waapi-animation.js +26 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/waapi/supports/waapi.js +36 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/waapi/utils/accelerated-values.js +12 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/waapi/utils/apply-generator.js +14 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/waapi/utils/is-browser-color.js +12 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/waapi/utils/linear.js +11 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/waapi/utils/unsupported-easing.js +19 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/events/add-dom-event.js +7 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/frameloop/batcher.js +67 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/frameloop/frame.js +9 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/frameloop/microtask.js +5 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/frameloop/order.js +21 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/frameloop/render-step.js +64 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/frameloop/sync-time.js +21 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/gestures/drag/state/is-active.js +11 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/gestures/drag/state/set-active.js +25 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/gestures/hover.js +62 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/gestures/press/index.js +62 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/gestures/press/utils/is-keyboard-accessible.js +18 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/gestures/press/utils/keyboard.js +32 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/gestures/press/utils/state.js +4 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/gestures/utils/is-node-or-child.js +12 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/gestures/utils/is-primary-pointer.js +10 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/gestures/utils/setup.js +15 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/projection/animation/mix-values.js +60 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/projection/geometry/conversion.js +26 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/projection/geometry/copy.js +19 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/projection/geometry/delta-apply.js +86 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/projection/geometry/delta-calc.js +57 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/projection/geometry/delta-remove.js +40 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/projection/geometry/models.js +21 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/projection/geometry/utils.js +34 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/projection/node/DocumentProjectionNode.js +13 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/projection/node/HTMLProjectionNode.js +28 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/projection/node/create-projection-node.js +1124 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/projection/node/state.js +15 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/projection/shared/stack.js +83 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/projection/styles/scale-border-radius.js +26 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/projection/styles/scale-box-shadow.js +25 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/projection/styles/scale-correction.js +21 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/projection/styles/transform.js +38 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/projection/utils/compare-by-depth.js +4 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/projection/utils/each-axis.js +6 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/projection/utils/flat-tree.js +24 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/projection/utils/has-transform.js +20 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/projection/utils/measure.js +18 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/Feature.js +11 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/VisualElement.js +426 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/dom/DOMVisualElement.js +37 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/dom/is-css-var.js +4 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/dom/parse-transform.js +83 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/dom/style-set.js +7 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/dom/utils/camel-to-dash.js +6 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/html/HTMLVisualElement.js +40 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/html/utils/build-styles.js +42 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/html/utils/build-transform.js +53 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/html/utils/render.js +14 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/html/utils/scrape-motion-values.js +18 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/store.js +4 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/svg/SVGVisualElement.js +45 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/svg/utils/build-attrs.js +59 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/svg/utils/camel-case-attrs.js +28 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/svg/utils/is-svg-tag.js +4 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/svg/utils/path.js +17 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/svg/utils/render.js +12 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/svg/utils/scrape-motion-values.js +16 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/utils/animation-state.js +223 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/utils/get-variant-context.js +26 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/utils/is-animation-controls.js +6 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/utils/is-controlling-variants.js +13 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/utils/is-forced-motion-value.js +9 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/utils/is-keyframes-target.js +6 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/utils/is-variant-label.js +6 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/utils/keys-position.js +13 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/utils/keys-transform.js +24 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/utils/motion-values.js +33 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/utils/reduced-motion/index.js +20 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/utils/reduced-motion/state.js +6 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/utils/resolve-dynamic-variants.js +8 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/utils/resolve-variants.js +25 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/utils/setters.js +25 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/utils/shallow-compare.js +15 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/render/utils/variant-props.js +14 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/resize/handle-element.js +61 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/resize/handle-window.js +31 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/resize/index.js +8 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/utils/delay.js +17 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/utils/interpolate.js +53 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/utils/is-html-element.js +7 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/utils/is-svg-element.js +7 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/utils/is-svg-svg-element.js +7 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/utils/mix/color.js +44 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/utils/mix/complex.js +83 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/utils/mix/immediate.js +6 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/utils/mix/index.js +12 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/utils/mix/number.js +6 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/utils/mix/visibility.js +12 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/utils/resolve-elements.js +16 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/utils/supports/flags.js +4 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/utils/supports/linear-easing.js +12 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/utils/supports/memo.js +9 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/utils/supports/scroll-timeline.js +5 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/value/index.js +286 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/value/types/auto.js +7 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/value/types/color/hex.js +37 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/value/types/color/hsla-to-rgba.js +39 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/value/types/color/hsla.js +14 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/value/types/color/index.js +26 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/value/types/color/rgba.js +18 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/value/types/color/utils.js +21 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/value/types/complex/filter.js +27 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/value/types/complex/index.js +91 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/value/types/complex/mask.js +12 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/value/types/dimensions.js +10 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/value/types/int.js +8 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/value/types/maps/defaults.js +28 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/value/types/maps/number.js +70 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/value/types/maps/transform.js +37 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/value/types/numbers/index.js +19 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/value/types/numbers/units.js +23 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/value/types/test.js +4 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/value/types/utils/animatable-none.js +14 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/value/types/utils/color-regex.js +4 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/value/types/utils/find.js +9 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/value/types/utils/float-regex.js +4 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/value/types/utils/get-as-type.js +6 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/value/types/utils/is-nullish.js +6 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/value/types/utils/sanitize.js +4 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/value/types/utils/single-color-regex.js +4 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/value/utils/is-motion-value.js +4 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/value/utils/resolve-motion-value.js +7 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/value/will-change/add-will-change.js +15 -0
- package/dist/es/shared-ui/node_modules/motion-dom/dist/es/value/will-change/is.js +7 -0
- package/dist/es/shared-ui/node_modules/motion-utils/dist/es/array.js +13 -0
- package/dist/es/shared-ui/node_modules/motion-utils/dist/es/clamp.js +10 -0
- package/dist/es/shared-ui/node_modules/motion-utils/dist/es/easing/anticipate.js +5 -0
- package/dist/es/shared-ui/node_modules/motion-utils/dist/es/easing/back.js +11 -0
- package/dist/es/shared-ui/node_modules/motion-utils/dist/es/easing/circ.js +10 -0
- package/dist/es/shared-ui/node_modules/motion-utils/dist/es/easing/cubic-bezier.js +29 -0
- package/dist/es/shared-ui/node_modules/motion-utils/dist/es/easing/ease.js +9 -0
- package/dist/es/shared-ui/node_modules/motion-utils/dist/es/easing/modifiers/mirror.js +4 -0
- package/dist/es/shared-ui/node_modules/motion-utils/dist/es/easing/modifiers/reverse.js +4 -0
- package/dist/es/shared-ui/node_modules/motion-utils/dist/es/easing/utils/is-bezier-definition.js +4 -0
- package/dist/es/shared-ui/node_modules/motion-utils/dist/es/easing/utils/is-easing-array.js +6 -0
- package/dist/es/shared-ui/node_modules/motion-utils/dist/es/easing/utils/map.js +38 -0
- package/dist/es/shared-ui/node_modules/motion-utils/dist/es/errors.js +21 -0
- package/dist/es/shared-ui/node_modules/motion-utils/dist/es/format-error-message.js +6 -0
- package/dist/es/shared-ui/node_modules/motion-utils/dist/es/global-config.js +4 -0
- package/dist/es/shared-ui/node_modules/motion-utils/dist/es/is-numerical-string.js +4 -0
- package/dist/es/shared-ui/node_modules/motion-utils/dist/es/is-object.js +4 -0
- package/dist/es/shared-ui/node_modules/motion-utils/dist/es/is-zero-value-string.js +4 -0
- package/dist/es/shared-ui/node_modules/motion-utils/dist/es/memo.js +12 -0
- package/dist/es/shared-ui/node_modules/motion-utils/dist/es/noop.js +4 -0
- package/dist/es/shared-ui/node_modules/motion-utils/dist/es/pipe.js +4 -0
- package/dist/es/shared-ui/node_modules/motion-utils/dist/es/progress.js +7 -0
- package/dist/es/shared-ui/node_modules/motion-utils/dist/es/subscription-manager.js +32 -0
- package/dist/es/shared-ui/node_modules/motion-utils/dist/es/time-conversion.js +6 -0
- package/dist/es/shared-ui/node_modules/motion-utils/dist/es/velocity-per-second.js +4 -0
- package/dist/es/shared-ui/node_modules/motion-utils/dist/es/warn-once.js +11 -0
- package/dist/es/shared-ui.css +95 -0
- package/dist/hooks/index.d.ts +8 -0
- package/dist/hooks/use-debounce-value.d.ts +2 -0
- package/dist/hooks/use-inview.d.ts +7 -0
- package/dist/hooks/use-is-inview.d.ts +7 -0
- package/dist/hooks/use-mobile-back-dialog.d.ts +6 -0
- package/dist/hooks/use-mobile.d.ts +9 -0
- package/dist/hooks/use-mounted.d.ts +2 -0
- package/dist/hooks/use-scroll-direction.d.ts +3 -0
- package/dist/hooks/use-user-hand-behavior.d.ts +7 -0
- package/dist/index.d.ts +13 -0
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/locale/index.d.ts +2 -0
- package/dist/locale/locale.d.ts +26 -0
- package/package.json +118 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { setStyle } from "../render/dom/style-set.js";
|
|
2
|
+
import { supportsScrollTimeline } from "../utils/supports/scroll-timeline.js";
|
|
3
|
+
import { getFinalKeyframe } from "./keyframes/get-final.js";
|
|
4
|
+
import { WithPromise } from "./utils/WithPromise.js";
|
|
5
|
+
import { startWaapiAnimation } from "./waapi/start-waapi-animation.js";
|
|
6
|
+
import { applyGeneratorOptions } from "./waapi/utils/apply-generator.js";
|
|
7
|
+
import { invariant } from "../../../../motion-utils/dist/es/errors.js";
|
|
8
|
+
import { millisecondsToSeconds, secondsToMilliseconds } from "../../../../motion-utils/dist/es/time-conversion.js";
|
|
9
|
+
import { noop } from "../../../../motion-utils/dist/es/noop.js";
|
|
10
|
+
class NativeAnimation extends WithPromise {
|
|
11
|
+
constructor(options) {
|
|
12
|
+
super();
|
|
13
|
+
this.finishedTime = null;
|
|
14
|
+
this.isStopped = false;
|
|
15
|
+
this.manualStartTime = null;
|
|
16
|
+
if (!options)
|
|
17
|
+
return;
|
|
18
|
+
const { element, name, keyframes, pseudoElement, allowFlatten = false, finalKeyframe, onComplete } = options;
|
|
19
|
+
this.isPseudoElement = Boolean(pseudoElement);
|
|
20
|
+
this.allowFlatten = allowFlatten;
|
|
21
|
+
this.options = options;
|
|
22
|
+
invariant(typeof options.type !== "string", `Mini animate() doesn't support "type" as a string.`, "mini-spring");
|
|
23
|
+
const transition = applyGeneratorOptions(options);
|
|
24
|
+
this.animation = startWaapiAnimation(element, name, keyframes, transition, pseudoElement);
|
|
25
|
+
if (transition.autoplay === false) {
|
|
26
|
+
this.animation.pause();
|
|
27
|
+
}
|
|
28
|
+
this.animation.onfinish = () => {
|
|
29
|
+
this.finishedTime = this.time;
|
|
30
|
+
if (!pseudoElement) {
|
|
31
|
+
const keyframe = getFinalKeyframe(keyframes, this.options, finalKeyframe, this.speed);
|
|
32
|
+
if (this.updateMotionValue) {
|
|
33
|
+
this.updateMotionValue(keyframe);
|
|
34
|
+
}
|
|
35
|
+
setStyle(element, name, keyframe);
|
|
36
|
+
this.animation.cancel();
|
|
37
|
+
}
|
|
38
|
+
onComplete?.();
|
|
39
|
+
this.notifyFinished();
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
play() {
|
|
43
|
+
if (this.isStopped)
|
|
44
|
+
return;
|
|
45
|
+
this.manualStartTime = null;
|
|
46
|
+
this.animation.play();
|
|
47
|
+
if (this.state === "finished") {
|
|
48
|
+
this.updateFinished();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
pause() {
|
|
52
|
+
this.animation.pause();
|
|
53
|
+
}
|
|
54
|
+
complete() {
|
|
55
|
+
this.animation.finish?.();
|
|
56
|
+
}
|
|
57
|
+
cancel() {
|
|
58
|
+
try {
|
|
59
|
+
this.animation.cancel();
|
|
60
|
+
} catch (e) {
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
stop() {
|
|
64
|
+
if (this.isStopped)
|
|
65
|
+
return;
|
|
66
|
+
this.isStopped = true;
|
|
67
|
+
const { state } = this;
|
|
68
|
+
if (state === "idle" || state === "finished") {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (this.updateMotionValue) {
|
|
72
|
+
this.updateMotionValue();
|
|
73
|
+
} else {
|
|
74
|
+
this.commitStyles();
|
|
75
|
+
}
|
|
76
|
+
if (!this.isPseudoElement)
|
|
77
|
+
this.cancel();
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* WAAPI doesn't natively have any interruption capabilities.
|
|
81
|
+
*
|
|
82
|
+
* In this method, we commit styles back to the DOM before cancelling
|
|
83
|
+
* the animation.
|
|
84
|
+
*
|
|
85
|
+
* This is designed to be overridden by NativeAnimationExtended, which
|
|
86
|
+
* will create a renderless JS animation and sample it twice to calculate
|
|
87
|
+
* its current value, "previous" value, and therefore allow
|
|
88
|
+
* Motion to also correctly calculate velocity for any subsequent animation
|
|
89
|
+
* while deferring the commit until the next animation frame.
|
|
90
|
+
*/
|
|
91
|
+
commitStyles() {
|
|
92
|
+
const element = this.options?.element;
|
|
93
|
+
if (!this.isPseudoElement && element?.isConnected) {
|
|
94
|
+
this.animation.commitStyles?.();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
get duration() {
|
|
98
|
+
const duration = this.animation.effect?.getComputedTiming?.().duration || 0;
|
|
99
|
+
return millisecondsToSeconds(Number(duration));
|
|
100
|
+
}
|
|
101
|
+
get iterationDuration() {
|
|
102
|
+
const { delay = 0 } = this.options || {};
|
|
103
|
+
return this.duration + millisecondsToSeconds(delay);
|
|
104
|
+
}
|
|
105
|
+
get time() {
|
|
106
|
+
return millisecondsToSeconds(Number(this.animation.currentTime) || 0);
|
|
107
|
+
}
|
|
108
|
+
set time(newTime) {
|
|
109
|
+
const wasFinished = this.finishedTime !== null;
|
|
110
|
+
this.manualStartTime = null;
|
|
111
|
+
this.finishedTime = null;
|
|
112
|
+
this.animation.currentTime = secondsToMilliseconds(newTime);
|
|
113
|
+
if (wasFinished) {
|
|
114
|
+
this.animation.pause();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* The playback speed of the animation.
|
|
119
|
+
* 1 = normal speed, 2 = double speed, 0.5 = half speed.
|
|
120
|
+
*/
|
|
121
|
+
get speed() {
|
|
122
|
+
return this.animation.playbackRate;
|
|
123
|
+
}
|
|
124
|
+
set speed(newSpeed) {
|
|
125
|
+
if (newSpeed < 0)
|
|
126
|
+
this.finishedTime = null;
|
|
127
|
+
this.animation.playbackRate = newSpeed;
|
|
128
|
+
}
|
|
129
|
+
get state() {
|
|
130
|
+
return this.finishedTime !== null ? "finished" : this.animation.playState;
|
|
131
|
+
}
|
|
132
|
+
get startTime() {
|
|
133
|
+
return this.manualStartTime ?? Number(this.animation.startTime);
|
|
134
|
+
}
|
|
135
|
+
set startTime(newStartTime) {
|
|
136
|
+
this.manualStartTime = this.animation.startTime = newStartTime;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Attaches a timeline to the animation, for instance the `ScrollTimeline`.
|
|
140
|
+
*/
|
|
141
|
+
attachTimeline({ timeline, rangeStart, rangeEnd, observe }) {
|
|
142
|
+
if (this.allowFlatten) {
|
|
143
|
+
this.animation.effect?.updateTiming({ easing: "linear" });
|
|
144
|
+
}
|
|
145
|
+
this.animation.onfinish = null;
|
|
146
|
+
if (timeline && supportsScrollTimeline()) {
|
|
147
|
+
this.animation.timeline = timeline;
|
|
148
|
+
if (rangeStart)
|
|
149
|
+
this.animation.rangeStart = rangeStart;
|
|
150
|
+
if (rangeEnd)
|
|
151
|
+
this.animation.rangeEnd = rangeEnd;
|
|
152
|
+
return noop;
|
|
153
|
+
} else {
|
|
154
|
+
return observe(this);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
export {
|
|
159
|
+
NativeAnimation
|
|
160
|
+
};
|
package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/NativeAnimationExtended.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { time } from "../frameloop/sync-time.js";
|
|
2
|
+
import { setStyle } from "../render/dom/style-set.js";
|
|
3
|
+
import { JSAnimation } from "./JSAnimation.js";
|
|
4
|
+
import { NativeAnimation } from "./NativeAnimation.js";
|
|
5
|
+
import { replaceTransitionType } from "./utils/replace-transition-type.js";
|
|
6
|
+
import { replaceStringEasing } from "./waapi/utils/unsupported-easing.js";
|
|
7
|
+
import { clamp } from "../../../../motion-utils/dist/es/clamp.js";
|
|
8
|
+
const sampleDelta = 10;
|
|
9
|
+
class NativeAnimationExtended extends NativeAnimation {
|
|
10
|
+
constructor(options) {
|
|
11
|
+
replaceStringEasing(options);
|
|
12
|
+
replaceTransitionType(options);
|
|
13
|
+
super(options);
|
|
14
|
+
if (options.startTime !== void 0 && options.autoplay !== false) {
|
|
15
|
+
this.startTime = options.startTime;
|
|
16
|
+
}
|
|
17
|
+
this.options = options;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* WAAPI doesn't natively have any interruption capabilities.
|
|
21
|
+
*
|
|
22
|
+
* Rather than read committed styles back out of the DOM, we can
|
|
23
|
+
* create a renderless JS animation and sample it twice to calculate
|
|
24
|
+
* its current value, "previous" value, and therefore allow
|
|
25
|
+
* Motion to calculate velocity for any subsequent animation.
|
|
26
|
+
*/
|
|
27
|
+
updateMotionValue(value) {
|
|
28
|
+
const { motionValue, onUpdate, onComplete, element, ...options } = this.options;
|
|
29
|
+
if (!motionValue)
|
|
30
|
+
return;
|
|
31
|
+
if (value !== void 0) {
|
|
32
|
+
motionValue.set(value);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const sampleAnimation = new JSAnimation({
|
|
36
|
+
...options,
|
|
37
|
+
autoplay: false
|
|
38
|
+
});
|
|
39
|
+
const sampleTime = Math.max(sampleDelta, time.now() - this.startTime);
|
|
40
|
+
const delta = clamp(0, sampleDelta, sampleTime - sampleDelta);
|
|
41
|
+
const current = sampleAnimation.sample(sampleTime).value;
|
|
42
|
+
const { name } = this.options;
|
|
43
|
+
if (element && name)
|
|
44
|
+
setStyle(element, name, current);
|
|
45
|
+
motionValue.setWithVelocity(sampleAnimation.sample(Math.max(0, sampleTime - delta)).value, current, delta);
|
|
46
|
+
sampleAnimation.stop();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
NativeAnimationExtended
|
|
51
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { animateMotionValue } from "../interfaces/motion-value.js";
|
|
2
|
+
import { motionValue } from "../../value/index.js";
|
|
3
|
+
import { isMotionValue } from "../../value/utils/is-motion-value.js";
|
|
4
|
+
function animateSingleValue(value, keyframes, options) {
|
|
5
|
+
const motionValue$1 = isMotionValue(value) ? value : motionValue(value);
|
|
6
|
+
motionValue$1.start(animateMotionValue("", motionValue$1, keyframes, options));
|
|
7
|
+
return motionValue$1.animation;
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
animateSingleValue
|
|
11
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { time } from "../../frameloop/sync-time.js";
|
|
2
|
+
import { frameData, cancelFrame, frame } from "../../frameloop/frame.js";
|
|
3
|
+
const frameloopDriver = (update) => {
|
|
4
|
+
const passTimestamp = ({ timestamp }) => update(timestamp);
|
|
5
|
+
return {
|
|
6
|
+
start: (keepAlive = true) => frame.update(passTimestamp, keepAlive),
|
|
7
|
+
stop: () => cancelFrame(passTimestamp),
|
|
8
|
+
/**
|
|
9
|
+
* If we're processing this frame we can use the
|
|
10
|
+
* framelocked timestamp to keep things in sync.
|
|
11
|
+
*/
|
|
12
|
+
now: () => frameData.isProcessing ? frameData.timestamp : time.now()
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
frameloopDriver
|
|
17
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { spring } from "./spring.js";
|
|
2
|
+
import { getGeneratorVelocity } from "./utils/velocity.js";
|
|
3
|
+
function inertia({ keyframes, velocity = 0, power = 0.8, timeConstant = 325, bounceDamping = 10, bounceStiffness = 500, modifyTarget, min, max, restDelta = 0.5, restSpeed }) {
|
|
4
|
+
const origin = keyframes[0];
|
|
5
|
+
const state = {
|
|
6
|
+
done: false,
|
|
7
|
+
value: origin
|
|
8
|
+
};
|
|
9
|
+
const isOutOfBounds = (v) => min !== void 0 && v < min || max !== void 0 && v > max;
|
|
10
|
+
const nearestBoundary = (v) => {
|
|
11
|
+
if (min === void 0)
|
|
12
|
+
return max;
|
|
13
|
+
if (max === void 0)
|
|
14
|
+
return min;
|
|
15
|
+
return Math.abs(min - v) < Math.abs(max - v) ? min : max;
|
|
16
|
+
};
|
|
17
|
+
let amplitude = power * velocity;
|
|
18
|
+
const ideal = origin + amplitude;
|
|
19
|
+
const target = modifyTarget === void 0 ? ideal : modifyTarget(ideal);
|
|
20
|
+
if (target !== ideal)
|
|
21
|
+
amplitude = target - origin;
|
|
22
|
+
const calcDelta = (t) => -amplitude * Math.exp(-t / timeConstant);
|
|
23
|
+
const calcLatest = (t) => target + calcDelta(t);
|
|
24
|
+
const applyFriction = (t) => {
|
|
25
|
+
const delta = calcDelta(t);
|
|
26
|
+
const latest = calcLatest(t);
|
|
27
|
+
state.done = Math.abs(delta) <= restDelta;
|
|
28
|
+
state.value = state.done ? target : latest;
|
|
29
|
+
};
|
|
30
|
+
let timeReachedBoundary;
|
|
31
|
+
let spring$1;
|
|
32
|
+
const checkCatchBoundary = (t) => {
|
|
33
|
+
if (!isOutOfBounds(state.value))
|
|
34
|
+
return;
|
|
35
|
+
timeReachedBoundary = t;
|
|
36
|
+
spring$1 = spring({
|
|
37
|
+
keyframes: [state.value, nearestBoundary(state.value)],
|
|
38
|
+
velocity: getGeneratorVelocity(calcLatest, t, state.value),
|
|
39
|
+
// TODO: This should be passing * 1000
|
|
40
|
+
damping: bounceDamping,
|
|
41
|
+
stiffness: bounceStiffness,
|
|
42
|
+
restDelta,
|
|
43
|
+
restSpeed
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
checkCatchBoundary(0);
|
|
47
|
+
return {
|
|
48
|
+
calculatedDuration: null,
|
|
49
|
+
next: (t) => {
|
|
50
|
+
let hasUpdatedFrame = false;
|
|
51
|
+
if (!spring$1 && timeReachedBoundary === void 0) {
|
|
52
|
+
hasUpdatedFrame = true;
|
|
53
|
+
applyFriction(t);
|
|
54
|
+
checkCatchBoundary(t);
|
|
55
|
+
}
|
|
56
|
+
if (timeReachedBoundary !== void 0 && t >= timeReachedBoundary) {
|
|
57
|
+
return spring$1.next(t - timeReachedBoundary);
|
|
58
|
+
} else {
|
|
59
|
+
!hasUpdatedFrame && applyFriction(t);
|
|
60
|
+
return state;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
inertia
|
|
67
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { interpolate } from "../../utils/interpolate.js";
|
|
2
|
+
import { defaultOffset } from "../keyframes/offsets/default.js";
|
|
3
|
+
import { convertOffsetToTimes } from "../keyframes/offsets/time.js";
|
|
4
|
+
import { isEasingArray } from "../../../../../motion-utils/dist/es/easing/utils/is-easing-array.js";
|
|
5
|
+
import { easingDefinitionToFunction } from "../../../../../motion-utils/dist/es/easing/utils/map.js";
|
|
6
|
+
import { easeInOut } from "../../../../../motion-utils/dist/es/easing/ease.js";
|
|
7
|
+
function defaultEasing(values, easing) {
|
|
8
|
+
return values.map(() => easing || easeInOut).splice(0, values.length - 1);
|
|
9
|
+
}
|
|
10
|
+
function keyframes({ duration = 300, keyframes: keyframeValues, times, ease = "easeInOut" }) {
|
|
11
|
+
const easingFunctions = isEasingArray(ease) ? ease.map(easingDefinitionToFunction) : easingDefinitionToFunction(ease);
|
|
12
|
+
const state = {
|
|
13
|
+
done: false,
|
|
14
|
+
value: keyframeValues[0]
|
|
15
|
+
};
|
|
16
|
+
const absoluteTimes = convertOffsetToTimes(
|
|
17
|
+
// Only use the provided offsets if they're the correct length
|
|
18
|
+
// TODO Maybe we should warn here if there's a length mismatch
|
|
19
|
+
times && times.length === keyframeValues.length ? times : defaultOffset(keyframeValues),
|
|
20
|
+
duration
|
|
21
|
+
);
|
|
22
|
+
const mapTimeToKeyframe = interpolate(absoluteTimes, keyframeValues, {
|
|
23
|
+
ease: Array.isArray(easingFunctions) ? easingFunctions : defaultEasing(keyframeValues, easingFunctions)
|
|
24
|
+
});
|
|
25
|
+
return {
|
|
26
|
+
calculatedDuration: duration,
|
|
27
|
+
next: (t) => {
|
|
28
|
+
state.value = mapTimeToKeyframe(t);
|
|
29
|
+
state.done = t >= duration;
|
|
30
|
+
return state;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
defaultEasing,
|
|
36
|
+
keyframes
|
|
37
|
+
};
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { generateLinearEasing } from "../waapi/utils/linear.js";
|
|
2
|
+
import { calcGeneratorDuration, maxGeneratorDuration } from "./utils/calc-duration.js";
|
|
3
|
+
import { createGeneratorEasing } from "./utils/create-generator-easing.js";
|
|
4
|
+
import { millisecondsToSeconds, secondsToMilliseconds } from "../../../../../motion-utils/dist/es/time-conversion.js";
|
|
5
|
+
import { clamp } from "../../../../../motion-utils/dist/es/clamp.js";
|
|
6
|
+
import { warning } from "../../../../../motion-utils/dist/es/errors.js";
|
|
7
|
+
const springDefaults = {
|
|
8
|
+
// Default spring physics
|
|
9
|
+
stiffness: 100,
|
|
10
|
+
damping: 10,
|
|
11
|
+
mass: 1,
|
|
12
|
+
velocity: 0,
|
|
13
|
+
// Default duration/bounce-based options
|
|
14
|
+
duration: 800,
|
|
15
|
+
// in ms
|
|
16
|
+
bounce: 0.3,
|
|
17
|
+
visualDuration: 0.3,
|
|
18
|
+
// in seconds
|
|
19
|
+
// Rest thresholds
|
|
20
|
+
restSpeed: {
|
|
21
|
+
granular: 0.01,
|
|
22
|
+
default: 2
|
|
23
|
+
},
|
|
24
|
+
restDelta: {
|
|
25
|
+
granular: 5e-3,
|
|
26
|
+
default: 0.5
|
|
27
|
+
},
|
|
28
|
+
// Limits
|
|
29
|
+
minDuration: 0.01,
|
|
30
|
+
// in seconds
|
|
31
|
+
maxDuration: 10,
|
|
32
|
+
// in seconds
|
|
33
|
+
minDamping: 0.05,
|
|
34
|
+
maxDamping: 1
|
|
35
|
+
};
|
|
36
|
+
function calcAngularFreq(undampedFreq, dampingRatio) {
|
|
37
|
+
return undampedFreq * Math.sqrt(1 - dampingRatio * dampingRatio);
|
|
38
|
+
}
|
|
39
|
+
const rootIterations = 12;
|
|
40
|
+
function approximateRoot(envelope, derivative, initialGuess) {
|
|
41
|
+
let result = initialGuess;
|
|
42
|
+
for (let i = 1; i < rootIterations; i++) {
|
|
43
|
+
result = result - envelope(result) / derivative(result);
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
const safeMin = 1e-3;
|
|
48
|
+
function findSpring({ duration = springDefaults.duration, bounce = springDefaults.bounce, velocity = springDefaults.velocity, mass = springDefaults.mass }) {
|
|
49
|
+
let envelope;
|
|
50
|
+
let derivative;
|
|
51
|
+
warning(duration <= secondsToMilliseconds(springDefaults.maxDuration), "Spring duration must be 10 seconds or less", "spring-duration-limit");
|
|
52
|
+
let dampingRatio = 1 - bounce;
|
|
53
|
+
dampingRatio = clamp(springDefaults.minDamping, springDefaults.maxDamping, dampingRatio);
|
|
54
|
+
duration = clamp(springDefaults.minDuration, springDefaults.maxDuration, millisecondsToSeconds(duration));
|
|
55
|
+
if (dampingRatio < 1) {
|
|
56
|
+
envelope = (undampedFreq2) => {
|
|
57
|
+
const exponentialDecay = undampedFreq2 * dampingRatio;
|
|
58
|
+
const delta = exponentialDecay * duration;
|
|
59
|
+
const a = exponentialDecay - velocity;
|
|
60
|
+
const b = calcAngularFreq(undampedFreq2, dampingRatio);
|
|
61
|
+
const c = Math.exp(-delta);
|
|
62
|
+
return safeMin - a / b * c;
|
|
63
|
+
};
|
|
64
|
+
derivative = (undampedFreq2) => {
|
|
65
|
+
const exponentialDecay = undampedFreq2 * dampingRatio;
|
|
66
|
+
const delta = exponentialDecay * duration;
|
|
67
|
+
const d = delta * velocity + velocity;
|
|
68
|
+
const e = Math.pow(dampingRatio, 2) * Math.pow(undampedFreq2, 2) * duration;
|
|
69
|
+
const f = Math.exp(-delta);
|
|
70
|
+
const g = calcAngularFreq(Math.pow(undampedFreq2, 2), dampingRatio);
|
|
71
|
+
const factor = -envelope(undampedFreq2) + safeMin > 0 ? -1 : 1;
|
|
72
|
+
return factor * ((d - e) * f) / g;
|
|
73
|
+
};
|
|
74
|
+
} else {
|
|
75
|
+
envelope = (undampedFreq2) => {
|
|
76
|
+
const a = Math.exp(-undampedFreq2 * duration);
|
|
77
|
+
const b = (undampedFreq2 - velocity) * duration + 1;
|
|
78
|
+
return -safeMin + a * b;
|
|
79
|
+
};
|
|
80
|
+
derivative = (undampedFreq2) => {
|
|
81
|
+
const a = Math.exp(-undampedFreq2 * duration);
|
|
82
|
+
const b = (velocity - undampedFreq2) * (duration * duration);
|
|
83
|
+
return a * b;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
const initialGuess = 5 / duration;
|
|
87
|
+
const undampedFreq = approximateRoot(envelope, derivative, initialGuess);
|
|
88
|
+
duration = secondsToMilliseconds(duration);
|
|
89
|
+
if (isNaN(undampedFreq)) {
|
|
90
|
+
return {
|
|
91
|
+
stiffness: springDefaults.stiffness,
|
|
92
|
+
damping: springDefaults.damping,
|
|
93
|
+
duration
|
|
94
|
+
};
|
|
95
|
+
} else {
|
|
96
|
+
const stiffness = Math.pow(undampedFreq, 2) * mass;
|
|
97
|
+
return {
|
|
98
|
+
stiffness,
|
|
99
|
+
damping: dampingRatio * 2 * Math.sqrt(mass * stiffness),
|
|
100
|
+
duration
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const durationKeys = ["duration", "bounce"];
|
|
105
|
+
const physicsKeys = ["stiffness", "damping", "mass"];
|
|
106
|
+
function isSpringType(options, keys) {
|
|
107
|
+
return keys.some((key) => options[key] !== void 0);
|
|
108
|
+
}
|
|
109
|
+
function getSpringOptions(options) {
|
|
110
|
+
let springOptions = {
|
|
111
|
+
velocity: springDefaults.velocity,
|
|
112
|
+
stiffness: springDefaults.stiffness,
|
|
113
|
+
damping: springDefaults.damping,
|
|
114
|
+
mass: springDefaults.mass,
|
|
115
|
+
isResolvedFromDuration: false,
|
|
116
|
+
...options
|
|
117
|
+
};
|
|
118
|
+
if (!isSpringType(options, physicsKeys) && isSpringType(options, durationKeys)) {
|
|
119
|
+
springOptions.velocity = 0;
|
|
120
|
+
if (options.visualDuration) {
|
|
121
|
+
const visualDuration = options.visualDuration;
|
|
122
|
+
const root = 2 * Math.PI / (visualDuration * 1.2);
|
|
123
|
+
const stiffness = root * root;
|
|
124
|
+
const damping = 2 * clamp(0.05, 1, 1 - (options.bounce || 0)) * Math.sqrt(stiffness);
|
|
125
|
+
springOptions = {
|
|
126
|
+
...springOptions,
|
|
127
|
+
mass: springDefaults.mass,
|
|
128
|
+
stiffness,
|
|
129
|
+
damping
|
|
130
|
+
};
|
|
131
|
+
} else {
|
|
132
|
+
const derived = findSpring({ ...options, velocity: 0 });
|
|
133
|
+
springOptions = {
|
|
134
|
+
...springOptions,
|
|
135
|
+
...derived,
|
|
136
|
+
mass: springDefaults.mass
|
|
137
|
+
};
|
|
138
|
+
springOptions.isResolvedFromDuration = true;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return springOptions;
|
|
142
|
+
}
|
|
143
|
+
function spring(optionsOrVisualDuration = springDefaults.visualDuration, bounce = springDefaults.bounce) {
|
|
144
|
+
const options = typeof optionsOrVisualDuration !== "object" ? {
|
|
145
|
+
visualDuration: optionsOrVisualDuration,
|
|
146
|
+
keyframes: [0, 1],
|
|
147
|
+
bounce
|
|
148
|
+
} : optionsOrVisualDuration;
|
|
149
|
+
let { restSpeed, restDelta } = options;
|
|
150
|
+
const origin = options.keyframes[0];
|
|
151
|
+
const target = options.keyframes[options.keyframes.length - 1];
|
|
152
|
+
const state = { done: false, value: origin };
|
|
153
|
+
const { stiffness, damping, mass, duration, velocity, isResolvedFromDuration } = getSpringOptions({
|
|
154
|
+
...options,
|
|
155
|
+
velocity: -millisecondsToSeconds(options.velocity || 0)
|
|
156
|
+
});
|
|
157
|
+
const initialVelocity = velocity || 0;
|
|
158
|
+
const dampingRatio = damping / (2 * Math.sqrt(stiffness * mass));
|
|
159
|
+
const initialDelta = target - origin;
|
|
160
|
+
const undampedAngularFreq = millisecondsToSeconds(Math.sqrt(stiffness / mass));
|
|
161
|
+
const isGranularScale = Math.abs(initialDelta) < 5;
|
|
162
|
+
restSpeed || (restSpeed = isGranularScale ? springDefaults.restSpeed.granular : springDefaults.restSpeed.default);
|
|
163
|
+
restDelta || (restDelta = isGranularScale ? springDefaults.restDelta.granular : springDefaults.restDelta.default);
|
|
164
|
+
let resolveSpring;
|
|
165
|
+
let resolveVelocity;
|
|
166
|
+
let angularFreq;
|
|
167
|
+
let A;
|
|
168
|
+
let sinCoeff;
|
|
169
|
+
let cosCoeff;
|
|
170
|
+
if (dampingRatio < 1) {
|
|
171
|
+
angularFreq = calcAngularFreq(undampedAngularFreq, dampingRatio);
|
|
172
|
+
A = (initialVelocity + dampingRatio * undampedAngularFreq * initialDelta) / angularFreq;
|
|
173
|
+
resolveSpring = (t) => {
|
|
174
|
+
const envelope = Math.exp(-dampingRatio * undampedAngularFreq * t);
|
|
175
|
+
return target - envelope * (A * Math.sin(angularFreq * t) + initialDelta * Math.cos(angularFreq * t));
|
|
176
|
+
};
|
|
177
|
+
sinCoeff = dampingRatio * undampedAngularFreq * A + initialDelta * angularFreq;
|
|
178
|
+
cosCoeff = dampingRatio * undampedAngularFreq * initialDelta - A * angularFreq;
|
|
179
|
+
resolveVelocity = (t) => {
|
|
180
|
+
const envelope = Math.exp(-dampingRatio * undampedAngularFreq * t);
|
|
181
|
+
return envelope * (sinCoeff * Math.sin(angularFreq * t) + cosCoeff * Math.cos(angularFreq * t));
|
|
182
|
+
};
|
|
183
|
+
} else if (dampingRatio === 1) {
|
|
184
|
+
resolveSpring = (t) => target - Math.exp(-undampedAngularFreq * t) * (initialDelta + (initialVelocity + undampedAngularFreq * initialDelta) * t);
|
|
185
|
+
const C = initialVelocity + undampedAngularFreq * initialDelta;
|
|
186
|
+
resolveVelocity = (t) => Math.exp(-undampedAngularFreq * t) * (undampedAngularFreq * C * t - initialVelocity);
|
|
187
|
+
} else {
|
|
188
|
+
const dampedAngularFreq = undampedAngularFreq * Math.sqrt(dampingRatio * dampingRatio - 1);
|
|
189
|
+
resolveSpring = (t) => {
|
|
190
|
+
const envelope = Math.exp(-dampingRatio * undampedAngularFreq * t);
|
|
191
|
+
const freqForT = Math.min(dampedAngularFreq * t, 300);
|
|
192
|
+
return target - envelope * ((initialVelocity + dampingRatio * undampedAngularFreq * initialDelta) * Math.sinh(freqForT) + dampedAngularFreq * initialDelta * Math.cosh(freqForT)) / dampedAngularFreq;
|
|
193
|
+
};
|
|
194
|
+
const P = (initialVelocity + dampingRatio * undampedAngularFreq * initialDelta) / dampedAngularFreq;
|
|
195
|
+
const sinhCoeff = dampingRatio * undampedAngularFreq * P - initialDelta * dampedAngularFreq;
|
|
196
|
+
const coshCoeff = dampingRatio * undampedAngularFreq * initialDelta - P * dampedAngularFreq;
|
|
197
|
+
resolveVelocity = (t) => {
|
|
198
|
+
const envelope = Math.exp(-dampingRatio * undampedAngularFreq * t);
|
|
199
|
+
const freqForT = Math.min(dampedAngularFreq * t, 300);
|
|
200
|
+
return envelope * (sinhCoeff * Math.sinh(freqForT) + coshCoeff * Math.cosh(freqForT));
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
const generator = {
|
|
204
|
+
calculatedDuration: isResolvedFromDuration ? duration || null : null,
|
|
205
|
+
velocity: (t) => secondsToMilliseconds(resolveVelocity(t)),
|
|
206
|
+
next: (t) => {
|
|
207
|
+
if (!isResolvedFromDuration && dampingRatio < 1) {
|
|
208
|
+
const envelope = Math.exp(-dampingRatio * undampedAngularFreq * t);
|
|
209
|
+
const sin = Math.sin(angularFreq * t);
|
|
210
|
+
const cos = Math.cos(angularFreq * t);
|
|
211
|
+
const current2 = target - envelope * (A * sin + initialDelta * cos);
|
|
212
|
+
const currentVelocity = secondsToMilliseconds(envelope * (sinCoeff * sin + cosCoeff * cos));
|
|
213
|
+
state.done = Math.abs(currentVelocity) <= restSpeed && Math.abs(target - current2) <= restDelta;
|
|
214
|
+
state.value = state.done ? target : current2;
|
|
215
|
+
return state;
|
|
216
|
+
}
|
|
217
|
+
const current = resolveSpring(t);
|
|
218
|
+
if (!isResolvedFromDuration) {
|
|
219
|
+
const currentVelocity = secondsToMilliseconds(resolveVelocity(t));
|
|
220
|
+
state.done = Math.abs(currentVelocity) <= restSpeed && Math.abs(target - current) <= restDelta;
|
|
221
|
+
} else {
|
|
222
|
+
state.done = t >= duration;
|
|
223
|
+
}
|
|
224
|
+
state.value = state.done ? target : current;
|
|
225
|
+
return state;
|
|
226
|
+
},
|
|
227
|
+
toString: () => {
|
|
228
|
+
const calculatedDuration = Math.min(calcGeneratorDuration(generator), maxGeneratorDuration);
|
|
229
|
+
const easing = generateLinearEasing((progress) => generator.next(calculatedDuration * progress).value, calculatedDuration, 30);
|
|
230
|
+
return calculatedDuration + "ms " + easing;
|
|
231
|
+
},
|
|
232
|
+
toTransition: () => {
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
return generator;
|
|
236
|
+
}
|
|
237
|
+
spring.applyToOptions = (options) => {
|
|
238
|
+
const generatorOptions = createGeneratorEasing(options, 100, spring);
|
|
239
|
+
options.ease = generatorOptions.ease;
|
|
240
|
+
options.duration = secondsToMilliseconds(generatorOptions.duration);
|
|
241
|
+
options.type = "keyframes";
|
|
242
|
+
return options;
|
|
243
|
+
};
|
|
244
|
+
export {
|
|
245
|
+
spring
|
|
246
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const maxGeneratorDuration = 2e4;
|
|
2
|
+
function calcGeneratorDuration(generator) {
|
|
3
|
+
let duration = 0;
|
|
4
|
+
const timeStep = 50;
|
|
5
|
+
let state = generator.next(duration);
|
|
6
|
+
while (!state.done && duration < maxGeneratorDuration) {
|
|
7
|
+
duration += timeStep;
|
|
8
|
+
state = generator.next(duration);
|
|
9
|
+
}
|
|
10
|
+
return duration >= maxGeneratorDuration ? Infinity : duration;
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
calcGeneratorDuration,
|
|
14
|
+
maxGeneratorDuration
|
|
15
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { calcGeneratorDuration, maxGeneratorDuration } from "./calc-duration.js";
|
|
2
|
+
import { millisecondsToSeconds } from "../../../../../../motion-utils/dist/es/time-conversion.js";
|
|
3
|
+
function createGeneratorEasing(options, scale = 100, createGenerator) {
|
|
4
|
+
const generator = createGenerator({ ...options, keyframes: [0, scale] });
|
|
5
|
+
const duration = Math.min(calcGeneratorDuration(generator), maxGeneratorDuration);
|
|
6
|
+
return {
|
|
7
|
+
type: "keyframes",
|
|
8
|
+
ease: (progress) => {
|
|
9
|
+
return generator.next(duration * progress).value / scale;
|
|
10
|
+
},
|
|
11
|
+
duration: millisecondsToSeconds(duration)
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
createGeneratorEasing
|
|
16
|
+
};
|
package/dist/es/shared-ui/node_modules/motion-dom/dist/es/animation/generators/utils/velocity.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { velocityPerSecond } from "../../../../../../motion-utils/dist/es/velocity-per-second.js";
|
|
2
|
+
const velocitySampleDuration = 5;
|
|
3
|
+
function getGeneratorVelocity(resolveValue, t, current) {
|
|
4
|
+
const prevT = Math.max(t - velocitySampleDuration, 0);
|
|
5
|
+
return velocityPerSecond(current - resolveValue(prevT), t - prevT);
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
getGeneratorVelocity
|
|
9
|
+
};
|