@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,432 @@
|
|
|
1
|
+
import { addPointerEvent } from "../../events/add-pointer-event.js";
|
|
2
|
+
import { extractEventInfo } from "../../events/event-info.js";
|
|
3
|
+
import { getContextWindow } from "../../utils/get-context-window.js";
|
|
4
|
+
import { isRefObject } from "../../utils/is-ref-object.js";
|
|
5
|
+
import { PanSession } from "../pan/PanSession.js";
|
|
6
|
+
import { applyConstraints, calcRelativeConstraints, resolveDragElastic, calcViewportConstraints, defaultElastic, rebaseAxisConstraints, calcOrigin } from "./utils/constraints.js";
|
|
7
|
+
import { createBox } from "../../../../../motion-dom/dist/es/projection/geometry/models.js";
|
|
8
|
+
import { frame } from "../../../../../motion-dom/dist/es/frameloop/frame.js";
|
|
9
|
+
import { eachAxis } from "../../../../../motion-dom/dist/es/projection/utils/each-axis.js";
|
|
10
|
+
import { invariant } from "../../../../../motion-utils/dist/es/errors.js";
|
|
11
|
+
import { measurePageBox } from "../../../../../motion-dom/dist/es/projection/utils/measure.js";
|
|
12
|
+
import { convertBoxToBoundingBox, convertBoundingBoxToBox } from "../../../../../motion-dom/dist/es/projection/geometry/conversion.js";
|
|
13
|
+
import { addValueToWillChange } from "../../../../../motion-dom/dist/es/value/will-change/add-will-change.js";
|
|
14
|
+
import { animateMotionValue } from "../../../../../motion-dom/dist/es/animation/interfaces/motion-value.js";
|
|
15
|
+
import { addDomEvent } from "../../../../../motion-dom/dist/es/events/add-dom-event.js";
|
|
16
|
+
import { setDragLock } from "../../../../../motion-dom/dist/es/gestures/drag/state/set-active.js";
|
|
17
|
+
import { resize } from "../../../../../motion-dom/dist/es/resize/index.js";
|
|
18
|
+
import { percent } from "../../../../../motion-dom/dist/es/value/types/numbers/units.js";
|
|
19
|
+
import { calcLength } from "../../../../../motion-dom/dist/es/projection/geometry/delta-calc.js";
|
|
20
|
+
import { mixNumber } from "../../../../../motion-dom/dist/es/utils/mix/number.js";
|
|
21
|
+
import { isElementTextInput } from "../../../../../motion-dom/dist/es/gestures/press/utils/is-keyboard-accessible.js";
|
|
22
|
+
const elementDragControls = /* @__PURE__ */ new WeakMap();
|
|
23
|
+
class VisualElementDragControls {
|
|
24
|
+
constructor(visualElement) {
|
|
25
|
+
this.openDragLock = null;
|
|
26
|
+
this.isDragging = false;
|
|
27
|
+
this.currentDirection = null;
|
|
28
|
+
this.originPoint = { x: 0, y: 0 };
|
|
29
|
+
this.constraints = false;
|
|
30
|
+
this.hasMutatedConstraints = false;
|
|
31
|
+
this.elastic = createBox();
|
|
32
|
+
this.latestPointerEvent = null;
|
|
33
|
+
this.latestPanInfo = null;
|
|
34
|
+
this.visualElement = visualElement;
|
|
35
|
+
}
|
|
36
|
+
start(originEvent, { snapToCursor = false, distanceThreshold } = {}) {
|
|
37
|
+
const { presenceContext } = this.visualElement;
|
|
38
|
+
if (presenceContext && presenceContext.isPresent === false)
|
|
39
|
+
return;
|
|
40
|
+
const onSessionStart = (event) => {
|
|
41
|
+
if (snapToCursor) {
|
|
42
|
+
this.snapToCursor(extractEventInfo(event).point);
|
|
43
|
+
}
|
|
44
|
+
this.stopAnimation();
|
|
45
|
+
};
|
|
46
|
+
const onStart = (event, info) => {
|
|
47
|
+
const { drag, dragPropagation, onDragStart } = this.getProps();
|
|
48
|
+
if (drag && !dragPropagation) {
|
|
49
|
+
if (this.openDragLock)
|
|
50
|
+
this.openDragLock();
|
|
51
|
+
this.openDragLock = setDragLock(drag);
|
|
52
|
+
if (!this.openDragLock)
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
this.latestPointerEvent = event;
|
|
56
|
+
this.latestPanInfo = info;
|
|
57
|
+
this.isDragging = true;
|
|
58
|
+
this.currentDirection = null;
|
|
59
|
+
this.resolveConstraints();
|
|
60
|
+
if (this.visualElement.projection) {
|
|
61
|
+
this.visualElement.projection.isAnimationBlocked = true;
|
|
62
|
+
this.visualElement.projection.target = void 0;
|
|
63
|
+
}
|
|
64
|
+
eachAxis((axis) => {
|
|
65
|
+
let current = this.getAxisMotionValue(axis).get() || 0;
|
|
66
|
+
if (percent.test(current)) {
|
|
67
|
+
const { projection } = this.visualElement;
|
|
68
|
+
if (projection && projection.layout) {
|
|
69
|
+
const measuredAxis = projection.layout.layoutBox[axis];
|
|
70
|
+
if (measuredAxis) {
|
|
71
|
+
const length = calcLength(measuredAxis);
|
|
72
|
+
current = length * (parseFloat(current) / 100);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
this.originPoint[axis] = current;
|
|
77
|
+
});
|
|
78
|
+
if (onDragStart) {
|
|
79
|
+
frame.update(() => onDragStart(event, info), false, true);
|
|
80
|
+
}
|
|
81
|
+
addValueToWillChange(this.visualElement, "transform");
|
|
82
|
+
const { animationState } = this.visualElement;
|
|
83
|
+
animationState && animationState.setActive("whileDrag", true);
|
|
84
|
+
};
|
|
85
|
+
const onMove = (event, info) => {
|
|
86
|
+
this.latestPointerEvent = event;
|
|
87
|
+
this.latestPanInfo = info;
|
|
88
|
+
const { dragPropagation, dragDirectionLock, onDirectionLock, onDrag } = this.getProps();
|
|
89
|
+
if (!dragPropagation && !this.openDragLock)
|
|
90
|
+
return;
|
|
91
|
+
const { offset } = info;
|
|
92
|
+
if (dragDirectionLock && this.currentDirection === null) {
|
|
93
|
+
this.currentDirection = getCurrentDirection(offset);
|
|
94
|
+
if (this.currentDirection !== null) {
|
|
95
|
+
onDirectionLock && onDirectionLock(this.currentDirection);
|
|
96
|
+
}
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
this.updateAxis("x", info.point, offset);
|
|
100
|
+
this.updateAxis("y", info.point, offset);
|
|
101
|
+
this.visualElement.render();
|
|
102
|
+
if (onDrag) {
|
|
103
|
+
frame.update(() => onDrag(event, info), false, true);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
const onSessionEnd = (event, info) => {
|
|
107
|
+
this.latestPointerEvent = event;
|
|
108
|
+
this.latestPanInfo = info;
|
|
109
|
+
this.stop(event, info);
|
|
110
|
+
this.latestPointerEvent = null;
|
|
111
|
+
this.latestPanInfo = null;
|
|
112
|
+
};
|
|
113
|
+
const resumeAnimation = () => {
|
|
114
|
+
const { dragSnapToOrigin: snap } = this.getProps();
|
|
115
|
+
if (snap || this.constraints) {
|
|
116
|
+
this.startAnimation({ x: 0, y: 0 });
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
const { dragSnapToOrigin } = this.getProps();
|
|
120
|
+
this.panSession = new PanSession(originEvent, {
|
|
121
|
+
onSessionStart,
|
|
122
|
+
onStart,
|
|
123
|
+
onMove,
|
|
124
|
+
onSessionEnd,
|
|
125
|
+
resumeAnimation
|
|
126
|
+
}, {
|
|
127
|
+
transformPagePoint: this.visualElement.getTransformPagePoint(),
|
|
128
|
+
dragSnapToOrigin,
|
|
129
|
+
distanceThreshold,
|
|
130
|
+
contextWindow: getContextWindow(this.visualElement),
|
|
131
|
+
element: this.visualElement.current
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* @internal
|
|
136
|
+
*/
|
|
137
|
+
stop(event, panInfo) {
|
|
138
|
+
const finalEvent = event || this.latestPointerEvent;
|
|
139
|
+
const finalPanInfo = panInfo || this.latestPanInfo;
|
|
140
|
+
const isDragging = this.isDragging;
|
|
141
|
+
this.cancel();
|
|
142
|
+
if (!isDragging || !finalPanInfo || !finalEvent)
|
|
143
|
+
return;
|
|
144
|
+
const { velocity } = finalPanInfo;
|
|
145
|
+
this.startAnimation(velocity);
|
|
146
|
+
const { onDragEnd } = this.getProps();
|
|
147
|
+
if (onDragEnd) {
|
|
148
|
+
frame.postRender(() => onDragEnd(finalEvent, finalPanInfo));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* @internal
|
|
153
|
+
*/
|
|
154
|
+
cancel() {
|
|
155
|
+
this.isDragging = false;
|
|
156
|
+
const { projection, animationState } = this.visualElement;
|
|
157
|
+
if (projection) {
|
|
158
|
+
projection.isAnimationBlocked = false;
|
|
159
|
+
}
|
|
160
|
+
this.endPanSession();
|
|
161
|
+
const { dragPropagation } = this.getProps();
|
|
162
|
+
if (!dragPropagation && this.openDragLock) {
|
|
163
|
+
this.openDragLock();
|
|
164
|
+
this.openDragLock = null;
|
|
165
|
+
}
|
|
166
|
+
animationState && animationState.setActive("whileDrag", false);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Clean up the pan session without modifying other drag state.
|
|
170
|
+
* This is used during unmount to ensure event listeners are removed
|
|
171
|
+
* without affecting projection animations or drag locks.
|
|
172
|
+
* @internal
|
|
173
|
+
*/
|
|
174
|
+
endPanSession() {
|
|
175
|
+
this.panSession && this.panSession.end();
|
|
176
|
+
this.panSession = void 0;
|
|
177
|
+
}
|
|
178
|
+
updateAxis(axis, _point, offset) {
|
|
179
|
+
const { drag } = this.getProps();
|
|
180
|
+
if (!offset || !shouldDrag(axis, drag, this.currentDirection))
|
|
181
|
+
return;
|
|
182
|
+
const axisValue = this.getAxisMotionValue(axis);
|
|
183
|
+
let next = this.originPoint[axis] + offset[axis];
|
|
184
|
+
if (this.constraints && this.constraints[axis]) {
|
|
185
|
+
next = applyConstraints(next, this.constraints[axis], this.elastic[axis]);
|
|
186
|
+
}
|
|
187
|
+
axisValue.set(next);
|
|
188
|
+
}
|
|
189
|
+
resolveConstraints() {
|
|
190
|
+
const { dragConstraints, dragElastic } = this.getProps();
|
|
191
|
+
const layout = this.visualElement.projection && !this.visualElement.projection.layout ? this.visualElement.projection.measure(false) : this.visualElement.projection?.layout;
|
|
192
|
+
const prevConstraints = this.constraints;
|
|
193
|
+
if (dragConstraints && isRefObject(dragConstraints)) {
|
|
194
|
+
if (!this.constraints) {
|
|
195
|
+
this.constraints = this.resolveRefConstraints();
|
|
196
|
+
}
|
|
197
|
+
} else {
|
|
198
|
+
if (dragConstraints && layout) {
|
|
199
|
+
this.constraints = calcRelativeConstraints(layout.layoutBox, dragConstraints);
|
|
200
|
+
} else {
|
|
201
|
+
this.constraints = false;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
this.elastic = resolveDragElastic(dragElastic);
|
|
205
|
+
if (prevConstraints !== this.constraints && !isRefObject(dragConstraints) && layout && this.constraints && !this.hasMutatedConstraints) {
|
|
206
|
+
eachAxis((axis) => {
|
|
207
|
+
if (this.constraints !== false && this.getAxisMotionValue(axis)) {
|
|
208
|
+
this.constraints[axis] = rebaseAxisConstraints(layout.layoutBox[axis], this.constraints[axis]);
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
resolveRefConstraints() {
|
|
214
|
+
const { dragConstraints: constraints, onMeasureDragConstraints } = this.getProps();
|
|
215
|
+
if (!constraints || !isRefObject(constraints))
|
|
216
|
+
return false;
|
|
217
|
+
const constraintsElement = constraints.current;
|
|
218
|
+
invariant(constraintsElement !== null, "If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.", "drag-constraints-ref");
|
|
219
|
+
const { projection } = this.visualElement;
|
|
220
|
+
if (!projection || !projection.layout)
|
|
221
|
+
return false;
|
|
222
|
+
if (projection.root) {
|
|
223
|
+
projection.root.scroll = void 0;
|
|
224
|
+
projection.root.updateScroll();
|
|
225
|
+
}
|
|
226
|
+
const constraintsBox = measurePageBox(constraintsElement, projection.root, this.visualElement.getTransformPagePoint());
|
|
227
|
+
let measuredConstraints = calcViewportConstraints(projection.layout.layoutBox, constraintsBox);
|
|
228
|
+
if (onMeasureDragConstraints) {
|
|
229
|
+
const userConstraints = onMeasureDragConstraints(convertBoxToBoundingBox(measuredConstraints));
|
|
230
|
+
this.hasMutatedConstraints = !!userConstraints;
|
|
231
|
+
if (userConstraints) {
|
|
232
|
+
measuredConstraints = convertBoundingBoxToBox(userConstraints);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return measuredConstraints;
|
|
236
|
+
}
|
|
237
|
+
startAnimation(velocity) {
|
|
238
|
+
const { drag, dragMomentum, dragElastic, dragTransition, dragSnapToOrigin, onDragTransitionEnd } = this.getProps();
|
|
239
|
+
const constraints = this.constraints || {};
|
|
240
|
+
const momentumAnimations = eachAxis((axis) => {
|
|
241
|
+
if (!shouldDrag(axis, drag, this.currentDirection)) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
let transition = constraints && constraints[axis] || {};
|
|
245
|
+
if (dragSnapToOrigin === true || dragSnapToOrigin === axis)
|
|
246
|
+
transition = { min: 0, max: 0 };
|
|
247
|
+
const bounceStiffness = dragElastic ? 200 : 1e6;
|
|
248
|
+
const bounceDamping = dragElastic ? 40 : 1e7;
|
|
249
|
+
const inertia = {
|
|
250
|
+
type: "inertia",
|
|
251
|
+
velocity: dragMomentum ? velocity[axis] : 0,
|
|
252
|
+
bounceStiffness,
|
|
253
|
+
bounceDamping,
|
|
254
|
+
timeConstant: 750,
|
|
255
|
+
restDelta: 1,
|
|
256
|
+
restSpeed: 10,
|
|
257
|
+
...dragTransition,
|
|
258
|
+
...transition
|
|
259
|
+
};
|
|
260
|
+
return this.startAxisValueAnimation(axis, inertia);
|
|
261
|
+
});
|
|
262
|
+
return Promise.all(momentumAnimations).then(onDragTransitionEnd);
|
|
263
|
+
}
|
|
264
|
+
startAxisValueAnimation(axis, transition) {
|
|
265
|
+
const axisValue = this.getAxisMotionValue(axis);
|
|
266
|
+
addValueToWillChange(this.visualElement, axis);
|
|
267
|
+
return axisValue.start(animateMotionValue(axis, axisValue, 0, transition, this.visualElement, false));
|
|
268
|
+
}
|
|
269
|
+
stopAnimation() {
|
|
270
|
+
eachAxis((axis) => this.getAxisMotionValue(axis).stop());
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Drag works differently depending on which props are provided.
|
|
274
|
+
*
|
|
275
|
+
* - If _dragX and _dragY are provided, we output the gesture delta directly to those motion values.
|
|
276
|
+
* - Otherwise, we apply the delta to the x/y motion values.
|
|
277
|
+
*/
|
|
278
|
+
getAxisMotionValue(axis) {
|
|
279
|
+
const dragKey = `_drag${axis.toUpperCase()}`;
|
|
280
|
+
const props = this.visualElement.getProps();
|
|
281
|
+
const externalMotionValue = props[dragKey];
|
|
282
|
+
return externalMotionValue ? externalMotionValue : this.visualElement.getValue(axis, this.visualElement.latestValues[axis] ?? 0);
|
|
283
|
+
}
|
|
284
|
+
snapToCursor(point) {
|
|
285
|
+
eachAxis((axis) => {
|
|
286
|
+
const { drag } = this.getProps();
|
|
287
|
+
if (!shouldDrag(axis, drag, this.currentDirection))
|
|
288
|
+
return;
|
|
289
|
+
const { projection } = this.visualElement;
|
|
290
|
+
const axisValue = this.getAxisMotionValue(axis);
|
|
291
|
+
if (projection && projection.layout) {
|
|
292
|
+
const { min, max } = projection.layout.layoutBox[axis];
|
|
293
|
+
const current = axisValue.get() || 0;
|
|
294
|
+
axisValue.set(point[axis] - mixNumber(min, max, 0.5) + current);
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* When the viewport resizes we want to check if the measured constraints
|
|
300
|
+
* have changed and, if so, reposition the element within those new constraints
|
|
301
|
+
* relative to where it was before the resize.
|
|
302
|
+
*/
|
|
303
|
+
scalePositionWithinConstraints() {
|
|
304
|
+
if (!this.visualElement.current)
|
|
305
|
+
return;
|
|
306
|
+
const { drag, dragConstraints } = this.getProps();
|
|
307
|
+
const { projection } = this.visualElement;
|
|
308
|
+
if (!isRefObject(dragConstraints) || !projection || !this.constraints)
|
|
309
|
+
return;
|
|
310
|
+
this.stopAnimation();
|
|
311
|
+
const boxProgress = { x: 0, y: 0 };
|
|
312
|
+
eachAxis((axis) => {
|
|
313
|
+
const axisValue = this.getAxisMotionValue(axis);
|
|
314
|
+
if (axisValue && this.constraints !== false) {
|
|
315
|
+
const latest = axisValue.get();
|
|
316
|
+
boxProgress[axis] = calcOrigin({ min: latest, max: latest }, this.constraints[axis]);
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
const { transformTemplate } = this.visualElement.getProps();
|
|
320
|
+
this.visualElement.current.style.transform = transformTemplate ? transformTemplate({}, "") : "none";
|
|
321
|
+
projection.root && projection.root.updateScroll();
|
|
322
|
+
projection.updateLayout();
|
|
323
|
+
this.constraints = false;
|
|
324
|
+
this.resolveConstraints();
|
|
325
|
+
eachAxis((axis) => {
|
|
326
|
+
if (!shouldDrag(axis, drag, null))
|
|
327
|
+
return;
|
|
328
|
+
const axisValue = this.getAxisMotionValue(axis);
|
|
329
|
+
const { min, max } = this.constraints[axis];
|
|
330
|
+
axisValue.set(mixNumber(min, max, boxProgress[axis]));
|
|
331
|
+
});
|
|
332
|
+
this.visualElement.render();
|
|
333
|
+
}
|
|
334
|
+
addListeners() {
|
|
335
|
+
if (!this.visualElement.current)
|
|
336
|
+
return;
|
|
337
|
+
elementDragControls.set(this.visualElement, this);
|
|
338
|
+
const element = this.visualElement.current;
|
|
339
|
+
const stopPointerListener = addPointerEvent(element, "pointerdown", (event) => {
|
|
340
|
+
const { drag, dragListener = true } = this.getProps();
|
|
341
|
+
const target = event.target;
|
|
342
|
+
const isClickingTextInputChild = target !== element && isElementTextInput(target);
|
|
343
|
+
if (drag && dragListener && !isClickingTextInputChild) {
|
|
344
|
+
this.start(event);
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
let stopResizeObservers;
|
|
348
|
+
const measureDragConstraints = () => {
|
|
349
|
+
const { dragConstraints } = this.getProps();
|
|
350
|
+
if (isRefObject(dragConstraints) && dragConstraints.current) {
|
|
351
|
+
this.constraints = this.resolveRefConstraints();
|
|
352
|
+
if (!stopResizeObservers) {
|
|
353
|
+
stopResizeObservers = startResizeObservers(element, dragConstraints.current, () => this.scalePositionWithinConstraints());
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
const { projection } = this.visualElement;
|
|
358
|
+
const stopMeasureLayoutListener = projection.addEventListener("measure", measureDragConstraints);
|
|
359
|
+
if (projection && !projection.layout) {
|
|
360
|
+
projection.root && projection.root.updateScroll();
|
|
361
|
+
projection.updateLayout();
|
|
362
|
+
}
|
|
363
|
+
frame.read(measureDragConstraints);
|
|
364
|
+
const stopResizeListener = addDomEvent(window, "resize", () => this.scalePositionWithinConstraints());
|
|
365
|
+
const stopLayoutUpdateListener = projection.addEventListener("didUpdate", (({ delta, hasLayoutChanged }) => {
|
|
366
|
+
if (this.isDragging && hasLayoutChanged) {
|
|
367
|
+
eachAxis((axis) => {
|
|
368
|
+
const motionValue = this.getAxisMotionValue(axis);
|
|
369
|
+
if (!motionValue)
|
|
370
|
+
return;
|
|
371
|
+
this.originPoint[axis] += delta[axis].translate;
|
|
372
|
+
motionValue.set(motionValue.get() + delta[axis].translate);
|
|
373
|
+
});
|
|
374
|
+
this.visualElement.render();
|
|
375
|
+
}
|
|
376
|
+
}));
|
|
377
|
+
return () => {
|
|
378
|
+
stopResizeListener();
|
|
379
|
+
stopPointerListener();
|
|
380
|
+
stopMeasureLayoutListener();
|
|
381
|
+
stopLayoutUpdateListener && stopLayoutUpdateListener();
|
|
382
|
+
stopResizeObservers && stopResizeObservers();
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
getProps() {
|
|
386
|
+
const props = this.visualElement.getProps();
|
|
387
|
+
const { drag = false, dragDirectionLock = false, dragPropagation = false, dragConstraints = false, dragElastic = defaultElastic, dragMomentum = true } = props;
|
|
388
|
+
return {
|
|
389
|
+
...props,
|
|
390
|
+
drag,
|
|
391
|
+
dragDirectionLock,
|
|
392
|
+
dragPropagation,
|
|
393
|
+
dragConstraints,
|
|
394
|
+
dragElastic,
|
|
395
|
+
dragMomentum
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
function skipFirstCall(callback) {
|
|
400
|
+
let isFirst = true;
|
|
401
|
+
return () => {
|
|
402
|
+
if (isFirst) {
|
|
403
|
+
isFirst = false;
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
callback();
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
function startResizeObservers(element, constraintsElement, onResize) {
|
|
410
|
+
const stopElement = resize(element, skipFirstCall(onResize));
|
|
411
|
+
const stopContainer = resize(constraintsElement, skipFirstCall(onResize));
|
|
412
|
+
return () => {
|
|
413
|
+
stopElement();
|
|
414
|
+
stopContainer();
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
function shouldDrag(direction, drag, currentDirection) {
|
|
418
|
+
return (drag === true || drag === direction) && (currentDirection === null || currentDirection === direction);
|
|
419
|
+
}
|
|
420
|
+
function getCurrentDirection(offset, lockThreshold = 10) {
|
|
421
|
+
let direction = null;
|
|
422
|
+
if (Math.abs(offset.y) > lockThreshold) {
|
|
423
|
+
direction = "y";
|
|
424
|
+
} else if (Math.abs(offset.x) > lockThreshold) {
|
|
425
|
+
direction = "x";
|
|
426
|
+
}
|
|
427
|
+
return direction;
|
|
428
|
+
}
|
|
429
|
+
export {
|
|
430
|
+
VisualElementDragControls,
|
|
431
|
+
elementDragControls
|
|
432
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { VisualElementDragControls } from "./VisualElementDragControls.js";
|
|
2
|
+
import { Feature } from "../../../../../motion-dom/dist/es/render/Feature.js";
|
|
3
|
+
import { noop } from "../../../../../motion-utils/dist/es/noop.js";
|
|
4
|
+
class DragGesture extends Feature {
|
|
5
|
+
constructor(node) {
|
|
6
|
+
super(node);
|
|
7
|
+
this.removeGroupControls = noop;
|
|
8
|
+
this.removeListeners = noop;
|
|
9
|
+
this.controls = new VisualElementDragControls(node);
|
|
10
|
+
}
|
|
11
|
+
mount() {
|
|
12
|
+
const { dragControls } = this.node.getProps();
|
|
13
|
+
if (dragControls) {
|
|
14
|
+
this.removeGroupControls = dragControls.subscribe(this.controls);
|
|
15
|
+
}
|
|
16
|
+
this.removeListeners = this.controls.addListeners() || noop;
|
|
17
|
+
}
|
|
18
|
+
update() {
|
|
19
|
+
const { dragControls } = this.node.getProps();
|
|
20
|
+
const { dragControls: prevDragControls } = this.node.prevProps || {};
|
|
21
|
+
if (dragControls !== prevDragControls) {
|
|
22
|
+
this.removeGroupControls();
|
|
23
|
+
if (dragControls) {
|
|
24
|
+
this.removeGroupControls = dragControls.subscribe(this.controls);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
unmount() {
|
|
29
|
+
this.removeGroupControls();
|
|
30
|
+
this.removeListeners();
|
|
31
|
+
if (!this.controls.isDragging) {
|
|
32
|
+
this.controls.endPanSession();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
DragGesture
|
|
38
|
+
};
|
package/dist/es/shared-ui/node_modules/framer-motion/dist/es/gestures/drag/utils/constraints.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { mixNumber } from "../../../../../../motion-dom/dist/es/utils/mix/number.js";
|
|
2
|
+
import { calcLength } from "../../../../../../motion-dom/dist/es/projection/geometry/delta-calc.js";
|
|
3
|
+
import { progress } from "../../../../../../motion-utils/dist/es/progress.js";
|
|
4
|
+
import { clamp } from "../../../../../../motion-utils/dist/es/clamp.js";
|
|
5
|
+
function applyConstraints(point, { min, max }, elastic) {
|
|
6
|
+
if (min !== void 0 && point < min) {
|
|
7
|
+
point = elastic ? mixNumber(min, point, elastic.min) : Math.max(point, min);
|
|
8
|
+
} else if (max !== void 0 && point > max) {
|
|
9
|
+
point = elastic ? mixNumber(max, point, elastic.max) : Math.min(point, max);
|
|
10
|
+
}
|
|
11
|
+
return point;
|
|
12
|
+
}
|
|
13
|
+
function calcRelativeAxisConstraints(axis, min, max) {
|
|
14
|
+
return {
|
|
15
|
+
min: min !== void 0 ? axis.min + min : void 0,
|
|
16
|
+
max: max !== void 0 ? axis.max + max - (axis.max - axis.min) : void 0
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function calcRelativeConstraints(layoutBox, { top, left, bottom, right }) {
|
|
20
|
+
return {
|
|
21
|
+
x: calcRelativeAxisConstraints(layoutBox.x, left, right),
|
|
22
|
+
y: calcRelativeAxisConstraints(layoutBox.y, top, bottom)
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function calcViewportAxisConstraints(layoutAxis, constraintsAxis) {
|
|
26
|
+
let min = constraintsAxis.min - layoutAxis.min;
|
|
27
|
+
let max = constraintsAxis.max - layoutAxis.max;
|
|
28
|
+
if (constraintsAxis.max - constraintsAxis.min < layoutAxis.max - layoutAxis.min) {
|
|
29
|
+
[min, max] = [max, min];
|
|
30
|
+
}
|
|
31
|
+
return { min, max };
|
|
32
|
+
}
|
|
33
|
+
function calcViewportConstraints(layoutBox, constraintsBox) {
|
|
34
|
+
return {
|
|
35
|
+
x: calcViewportAxisConstraints(layoutBox.x, constraintsBox.x),
|
|
36
|
+
y: calcViewportAxisConstraints(layoutBox.y, constraintsBox.y)
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function calcOrigin(source, target) {
|
|
40
|
+
let origin = 0.5;
|
|
41
|
+
const sourceLength = calcLength(source);
|
|
42
|
+
const targetLength = calcLength(target);
|
|
43
|
+
if (targetLength > sourceLength) {
|
|
44
|
+
origin = progress(target.min, target.max - sourceLength, source.min);
|
|
45
|
+
} else if (sourceLength > targetLength) {
|
|
46
|
+
origin = progress(source.min, source.max - targetLength, target.min);
|
|
47
|
+
}
|
|
48
|
+
return clamp(0, 1, origin);
|
|
49
|
+
}
|
|
50
|
+
function rebaseAxisConstraints(layout, constraints) {
|
|
51
|
+
const relativeConstraints = {};
|
|
52
|
+
if (constraints.min !== void 0) {
|
|
53
|
+
relativeConstraints.min = constraints.min - layout.min;
|
|
54
|
+
}
|
|
55
|
+
if (constraints.max !== void 0) {
|
|
56
|
+
relativeConstraints.max = constraints.max - layout.min;
|
|
57
|
+
}
|
|
58
|
+
return relativeConstraints;
|
|
59
|
+
}
|
|
60
|
+
const defaultElastic = 0.35;
|
|
61
|
+
function resolveDragElastic(dragElastic = defaultElastic) {
|
|
62
|
+
if (dragElastic === false) {
|
|
63
|
+
dragElastic = 0;
|
|
64
|
+
} else if (dragElastic === true) {
|
|
65
|
+
dragElastic = defaultElastic;
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
x: resolveAxisElastic(dragElastic, "left", "right"),
|
|
69
|
+
y: resolveAxisElastic(dragElastic, "top", "bottom")
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function resolveAxisElastic(dragElastic, minLabel, maxLabel) {
|
|
73
|
+
return {
|
|
74
|
+
min: resolvePointElastic(dragElastic, minLabel),
|
|
75
|
+
max: resolvePointElastic(dragElastic, maxLabel)
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function resolvePointElastic(dragElastic, label) {
|
|
79
|
+
return typeof dragElastic === "number" ? dragElastic : dragElastic[label] || 0;
|
|
80
|
+
}
|
|
81
|
+
export {
|
|
82
|
+
applyConstraints,
|
|
83
|
+
calcOrigin,
|
|
84
|
+
calcRelativeAxisConstraints,
|
|
85
|
+
calcRelativeConstraints,
|
|
86
|
+
calcViewportAxisConstraints,
|
|
87
|
+
calcViewportConstraints,
|
|
88
|
+
defaultElastic,
|
|
89
|
+
rebaseAxisConstraints,
|
|
90
|
+
resolveAxisElastic,
|
|
91
|
+
resolveDragElastic,
|
|
92
|
+
resolvePointElastic
|
|
93
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Feature } from "../../../../motion-dom/dist/es/render/Feature.js";
|
|
2
|
+
import { pipe } from "../../../../motion-utils/dist/es/pipe.js";
|
|
3
|
+
import { addDomEvent } from "../../../../motion-dom/dist/es/events/add-dom-event.js";
|
|
4
|
+
class FocusGesture extends Feature {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.isActive = false;
|
|
8
|
+
}
|
|
9
|
+
onFocus() {
|
|
10
|
+
let isFocusVisible = false;
|
|
11
|
+
try {
|
|
12
|
+
isFocusVisible = this.node.current.matches(":focus-visible");
|
|
13
|
+
} catch (e) {
|
|
14
|
+
isFocusVisible = true;
|
|
15
|
+
}
|
|
16
|
+
if (!isFocusVisible || !this.node.animationState)
|
|
17
|
+
return;
|
|
18
|
+
this.node.animationState.setActive("whileFocus", true);
|
|
19
|
+
this.isActive = true;
|
|
20
|
+
}
|
|
21
|
+
onBlur() {
|
|
22
|
+
if (!this.isActive || !this.node.animationState)
|
|
23
|
+
return;
|
|
24
|
+
this.node.animationState.setActive("whileFocus", false);
|
|
25
|
+
this.isActive = false;
|
|
26
|
+
}
|
|
27
|
+
mount() {
|
|
28
|
+
this.unmount = pipe(addDomEvent(this.node.current, "focus", () => this.onFocus()), addDomEvent(this.node.current, "blur", () => this.onBlur()));
|
|
29
|
+
}
|
|
30
|
+
unmount() {
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
FocusGesture
|
|
35
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { extractEventInfo } from "../events/event-info.js";
|
|
2
|
+
import { Feature } from "../../../../motion-dom/dist/es/render/Feature.js";
|
|
3
|
+
import { hover } from "../../../../motion-dom/dist/es/gestures/hover.js";
|
|
4
|
+
import { frame } from "../../../../motion-dom/dist/es/frameloop/frame.js";
|
|
5
|
+
function handleHoverEvent(node, event, lifecycle) {
|
|
6
|
+
const { props } = node;
|
|
7
|
+
if (node.animationState && props.whileHover) {
|
|
8
|
+
node.animationState.setActive("whileHover", lifecycle === "Start");
|
|
9
|
+
}
|
|
10
|
+
const eventName = "onHover" + lifecycle;
|
|
11
|
+
const callback = props[eventName];
|
|
12
|
+
if (callback) {
|
|
13
|
+
frame.postRender(() => callback(event, extractEventInfo(event)));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
class HoverGesture extends Feature {
|
|
17
|
+
mount() {
|
|
18
|
+
const { current } = this.node;
|
|
19
|
+
if (!current)
|
|
20
|
+
return;
|
|
21
|
+
this.unmount = hover(current, (_element, startEvent) => {
|
|
22
|
+
handleHoverEvent(this.node, startEvent, "Start");
|
|
23
|
+
return (endEvent) => handleHoverEvent(this.node, endEvent, "End");
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
unmount() {
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
HoverGesture
|
|
31
|
+
};
|