UNPKG

@yamada-ui/motion

Version:

Yamada UI motion components

416 lines (410 loc) • 13.6 kB
"use client" "use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/index.ts var index_exports = {}; __export(index_exports, { AnimatePresence: () => import_react4.AnimatePresence, AnimateSharedLayout: () => import_react4.AnimateSharedLayout, DeprecatedLayoutGroupContext: () => import_react4.DeprecatedLayoutGroupContext, DragControls: () => import_react4.DragControls, FlatTree: () => import_react4.FlatTree, LayoutGroup: () => import_react4.LayoutGroup, LayoutGroupContext: () => import_react4.LayoutGroupContext, LazyMotion: () => import_react4.LazyMotion, MOTION_TRANSITION_DEFAULTS: () => MOTION_TRANSITION_DEFAULTS, MOTION_TRANSITION_EASINGS: () => MOTION_TRANSITION_EASINGS, MOTION_TRANSITION_VARIANTS: () => MOTION_TRANSITION_VARIANTS, Motion: () => Motion, MotionConfig: () => import_react4.MotionConfig, MotionConfigContext: () => import_react4.MotionConfigContext, MotionContext: () => import_react4.MotionContext, MotionGlobalConfig: () => import_react4.MotionGlobalConfig, MotionReorder: () => import_react4.Reorder, PresenceContext: () => import_react4.PresenceContext, SwitchLayoutGroupContext: () => import_react4.SwitchLayoutGroupContext, VisualElement: () => import_react4.VisualElement, addPointerInfo: () => import_react4.addPointerInfo, addScaleCorrector: () => import_react4.addScaleCorrector, animate: () => import_react4.animate, animateValue: () => import_react4.animateValue, animateVisualElement: () => import_react4.animateVisualElement, animationControls: () => import_react4.animationControls, animations: () => import_react4.animations, anticipate: () => import_react4.anticipate, backIn: () => import_react4.backIn, backInOut: () => import_react4.backInOut, backOut: () => import_react4.backOut, buildTransform: () => import_react4.buildTransform, calcLength: () => import_react4.calcLength, cancelFrame: () => import_react4.cancelFrame, circIn: () => import_react4.circIn, circInOut: () => import_react4.circInOut, circOut: () => import_react4.circOut, clamp: () => import_react4.clamp, color: () => import_react4.color, complex: () => import_react4.complex, createBox: () => import_react4.createBox, createScopedAnimate: () => import_react4.createScopedAnimate, cubicBezier: () => import_react4.cubicBezier, delay: () => import_react4.delay, disableInstantTransitions: () => import_react4.disableInstantTransitions, distance: () => import_react4.distance, distance2D: () => import_react4.distance2D, domAnimation: () => import_react4.domAnimation, domMax: () => import_react4.domMax, easeIn: () => import_react4.easeIn, easeInOut: () => import_react4.easeInOut, easeOut: () => import_react4.easeOut, filterProps: () => import_react4.filterProps, frame: () => import_react4.frame, frameData: () => import_react4.frameData, inView: () => import_react4.inView, interpolate: () => import_react4.interpolate, invariant: () => import_react4.invariant, isBrowser: () => import_react4.isBrowser, isDragActive: () => import_react4.isDragActive, isMotionComponent: () => import_react4.isMotionComponent, isMotionValue: () => import_react4.isMotionValue, isValidMotionProp: () => import_react4.isValidMotionProp, m: () => import_react4.m, makeUseVisualState: () => import_react4.makeUseVisualState, mirrorEasing: () => import_react4.mirrorEasing, mix: () => import_react4.mix, motion: () => motion, motionForwardRef: () => motionForwardRef, motionValue: () => import_react4.motionValue, optimizedAppearDataAttribute: () => import_react4.optimizedAppearDataAttribute, pipe: () => import_react4.pipe, progress: () => import_react4.progress, px: () => import_react4.px, resolveMotionValue: () => import_react4.resolveMotionValue, reverseEasing: () => import_react4.reverseEasing, scroll: () => import_react4.scroll, scrollInfo: () => import_react4.scrollInfo, spring: () => import_react4.spring, stagger: () => import_react4.stagger, startOptimizedAppearAnimation: () => import_react4.startOptimizedAppearAnimation, steps: () => import_react4.steps, transform: () => import_react4.transform, transitionEnter: () => transitionEnter, transitionExit: () => transitionExit, unwrapMotionComponent: () => import_react4.unwrapMotionComponent, useAnimate: () => import_react4.useAnimate, useAnimationControls: () => import_react4.useAnimationControls, useAnimationFrame: () => import_react4.useAnimationFrame, useCycle: () => import_react4.useCycle, useDeprecatedAnimatedState: () => import_react4.useDeprecatedAnimatedState, useDeprecatedInvertedScale: () => import_react4.useDeprecatedInvertedScale, useDomEvent: () => import_react4.useDomEvent, useDragControls: () => import_react4.useDragControls, useElementScroll: () => import_react4.useElementScroll, useForceUpdate: () => import_react4.useForceUpdate, useInView: () => import_react4.useInView, useInstantLayoutTransition: () => import_react4.useInstantLayoutTransition, useInstantTransition: () => import_react4.useInstantTransition, useIsPresent: () => import_react4.useIsPresent, useIsomorphicLayoutEffect: () => import_react4.useIsomorphicLayoutEffect, useMotionAnimation: () => import_react4.useAnimation, useMotionTemplate: () => import_react4.useMotionTemplate, useMotionValue: () => import_react4.useMotionValue, useMotionValueEvent: () => import_react4.useMotionValueEvent, usePresence: () => import_react4.usePresence, useReducedMotion: () => import_react4.useReducedMotion, useReducedMotionConfig: () => import_react4.useReducedMotionConfig, useResetProjection: () => import_react4.useResetProjection, useScroll: () => import_react4.useScroll, useSpring: () => import_react4.useSpring, useTime: () => import_react4.useTime, useTransform: () => import_react4.useTransform, useVelocity: () => import_react4.useVelocity, useViewportScroll: () => import_react4.useViewportScroll, useWillChange: () => import_react4.useWillChange, visualElementStore: () => import_react4.visualElementStore, wrap: () => import_react4.wrap }); module.exports = __toCommonJS(index_exports); // src/factory.ts var import_core = require("@yamada-ui/core"); var import_react = require("motion/react"); function factory() { const cache = /* @__PURE__ */ new Map(); return new Proxy(import_core.styled, { apply: (_target, _thisArg, [el, options]) => { const component = (0, import_core.styled)(el, options); return import_react.motion.create(component); }, get: (_target, el) => { if (!cache.has(el)) { const component = (0, import_core.styled)(el); cache.set(el, import_react.motion.create(component)); } return cache.get(el); } }); } var motion = factory(); // src/forward-ref.tsx var React = __toESM(require("react")); function motionForwardRef(render) { return React.forwardRef( render ); } // src/motion.tsx var import_core2 = require("@yamada-ui/core"); var import_utils = require("@yamada-ui/utils"); var import_react2 = require("motion/react"); var import_react3 = require("react"); var import_jsx_runtime = require("react/jsx-runtime"); var disableStyleProps = ["transition"]; var disableStyleProp = (prop) => disableStyleProps.includes(prop); var Component = (0, import_core2.ui)("div", { disableStyleProp }); var Motion = motionForwardRef( ({ as: asProp = "div", className, ...rest }, ref) => { const as = (0, import_react3.useMemo)(() => import_react2.motion.create(asProp), [asProp]); return /* @__PURE__ */ (0, import_jsx_runtime.jsx)( Component, { ref, as, className: (0, import_utils.cx)("ui-motion", className), ...rest } ); } ); Motion.displayName = "Motion"; Motion.__ui__ = "Motion"; // src/utils.ts var import_utils2 = require("@yamada-ui/utils"); var MOTION_TRANSITION_EASINGS = { ease: [0.25, 0.1, 0.25, 1], easeIn: [0.4, 0, 1, 1], easeInOut: [0.4, 0, 0.2, 1], easeOut: [0, 0, 0.2, 1] }; var MOTION_TRANSITION_VARIANTS = { fade: { enter: { opacity: 1 }, exit: { opacity: 0 } }, pushDown: { enter: { y: "-100%" }, exit: { y: "30%" } }, pushLeft: { enter: { x: "100%" }, exit: { x: "-30%" } }, pushRight: { enter: { x: "-100%" }, exit: { x: "30%" } }, pushUp: { enter: { y: "100%" }, exit: { y: "-30%" } }, scale: { enter: { scale: 1 }, exit: { scale: 0.95 } }, slideDown: { enter: { x: 0, y: 0 }, exit: { x: 0, y: "100%" }, position: { bottom: 0, left: 0, maxWidth: "100vw", right: 0 } }, slideLeft: { enter: { x: 0, y: 0 }, exit: { x: "-100%", y: 0 }, position: { bottom: 0, left: 0, top: 0, width: "100%" } }, slideRight: { enter: { x: 0, y: 0 }, exit: { x: "100%", y: 0 }, position: { bottom: 0, right: 0, top: 0, width: "100%" } }, slideUp: { enter: { x: 0, y: 0 }, exit: { x: 0, y: "-100%" }, position: { left: 0, maxWidth: "100vw", right: 0, top: 0 } } }; var MOTION_TRANSITION_DEFAULTS = { enter: { duration: 0.25, ease: MOTION_TRANSITION_EASINGS.easeOut }, exit: { duration: 0.2, ease: MOTION_TRANSITION_EASINGS.easeIn } }; function transitionEnter(transition) { return function(delay2, duration) { return { ...transition != null ? transition : MOTION_TRANSITION_DEFAULTS.enter, ...duration ? { duration: (0, import_utils2.isNumber)(duration) ? duration : duration.enter } : {}, delay: (0, import_utils2.isNumber)(delay2) ? delay2 : delay2 == null ? void 0 : delay2.enter }; }; } function transitionExit(transition) { return function(delay2, duration) { return { ...transition != null ? transition : MOTION_TRANSITION_DEFAULTS.exit, ...duration ? { duration: (0, import_utils2.isNumber)(duration) ? duration : duration.exit } : {}, delay: (0, import_utils2.isNumber)(delay2) ? delay2 : delay2 == null ? void 0 : delay2.exit }; }; } // src/index.ts var import_react4 = require("motion/react"); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { AnimatePresence, AnimateSharedLayout, DeprecatedLayoutGroupContext, DragControls, FlatTree, LayoutGroup, LayoutGroupContext, LazyMotion, MOTION_TRANSITION_DEFAULTS, MOTION_TRANSITION_EASINGS, MOTION_TRANSITION_VARIANTS, Motion, MotionConfig, MotionConfigContext, MotionContext, MotionGlobalConfig, MotionReorder, PresenceContext, SwitchLayoutGroupContext, VisualElement, addPointerInfo, addScaleCorrector, animate, animateValue, animateVisualElement, animationControls, animations, anticipate, backIn, backInOut, backOut, buildTransform, calcLength, cancelFrame, circIn, circInOut, circOut, clamp, color, complex, createBox, createScopedAnimate, cubicBezier, delay, disableInstantTransitions, distance, distance2D, domAnimation, domMax, easeIn, easeInOut, easeOut, filterProps, frame, frameData, inView, interpolate, invariant, isBrowser, isDragActive, isMotionComponent, isMotionValue, isValidMotionProp, m, makeUseVisualState, mirrorEasing, mix, motion, motionForwardRef, motionValue, optimizedAppearDataAttribute, pipe, progress, px, resolveMotionValue, reverseEasing, scroll, scrollInfo, spring, stagger, startOptimizedAppearAnimation, steps, transform, transitionEnter, transitionExit, unwrapMotionComponent, useAnimate, useAnimationControls, useAnimationFrame, useCycle, useDeprecatedAnimatedState, useDeprecatedInvertedScale, useDomEvent, useDragControls, useElementScroll, useForceUpdate, useInView, useInstantLayoutTransition, useInstantTransition, useIsPresent, useIsomorphicLayoutEffect, useMotionAnimation, useMotionTemplate, useMotionValue, useMotionValueEvent, usePresence, useReducedMotion, useReducedMotionConfig, useResetProjection, useScroll, useSpring, useTime, useTransform, useVelocity, useViewportScroll, useWillChange, visualElementStore, wrap }); //# sourceMappingURL=index.js.map