UNPKG

@yamada-ui/transitions

Version:

Yamada UI transitions components

126 lines (125 loc) 3.9 kB
"use client" "use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; 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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/slide.tsx var slide_exports = {}; __export(slide_exports, { Slide: () => Slide, getSlideProps: () => getSlideProps, slideProps: () => slideProps }); module.exports = __toCommonJS(slide_exports); var import_core = require("@yamada-ui/core"); var import_motion = require("@yamada-ui/motion"); var import_use_value = require("@yamada-ui/use-value"); var import_utils = require("@yamada-ui/utils"); var import_jsx_runtime = require("react/jsx-runtime"); var getSlideProps = (placement = "right") => { switch (placement) { case "right": return import_motion.MOTION_TRANSITION_VARIANTS.slideRight; case "left": return import_motion.MOTION_TRANSITION_VARIANTS.slideLeft; case "bottom": return import_motion.MOTION_TRANSITION_VARIANTS.slideDown; case "top": return import_motion.MOTION_TRANSITION_VARIANTS.slideUp; } }; var variants = { enter: ({ delay, duration, enter, placement, transition, transitionEnd } = {}) => ({ ...getSlideProps(placement).enter, transition: (0, import_motion.transitionEnter)(transition == null ? void 0 : transition.enter)(delay, duration), transitionEnd: transitionEnd == null ? void 0 : transitionEnd.enter, ...enter }), exit: ({ delay, duration, exit, placement, transition, transitionEnd } = {}) => ({ ...getSlideProps(placement).exit, transition: (0, import_motion.transitionExit)(transition == null ? void 0 : transition.exit)(delay, duration), transitionEnd: transitionEnd == null ? void 0 : transitionEnd.exit, ...exit }) }; var slideProps = { animate: "enter", exit: "exit", initial: "exit", variants }; var Slide = (0, import_motion.motionForwardRef)((props, ref) => { const [style, mergedProps] = (0, import_core.useComponentStyle)("Slide", props); const { className, delay, duration = { enter: 0.4, exit: 0.3 }, isOpen, open = isOpen, placement: _placement, transition, transitionEnd, unmountOnExit, __css, ...rest } = (0, import_core.omitThemeProps)(mergedProps); const animate = open || unmountOnExit ? "enter" : "exit"; const placement = (0, import_use_value.useValue)(_placement); const custom = { delay, duration, placement, transition, transitionEnd }; const { position } = getSlideProps(placement); const resolvedOpen = unmountOnExit ? open && unmountOnExit : true; const css = { ...style, ...__css, ...position }; return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_motion.AnimatePresence, { custom, children: resolvedOpen ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)( import_motion.motion.div, { ref, className: (0, import_utils.cx)("ui-slide", className), custom, ...slideProps, animate, __css: css, ...rest } ) : null }); }); Slide.displayName = "Slide"; Slide.__ui__ = "Slide"; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { Slide, getSlideProps, slideProps }); //# sourceMappingURL=slide.js.map