Files
wdi-dashboard/node_modules/@chakra-ui/transition/dist/slide.js
2024-08-16 15:06:52 +05:30

197 lines
5.4 KiB
JavaScript

'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
});
module.exports = __toCommonJS(slide_exports);
var import_shared_utils = require("@chakra-ui/shared-utils");
var import_framer_motion = require("framer-motion");
var import_react = require("react");
// src/transition-utils.ts
var TRANSITION_EASINGS = {
ease: [0.25, 0.1, 0.25, 1],
easeIn: [0.4, 0, 1, 1],
easeOut: [0, 0, 0.2, 1],
easeInOut: [0.4, 0, 0.2, 1]
};
var TRANSITION_VARIANTS = {
scale: {
enter: { scale: 1 },
exit: { scale: 0.95 }
},
fade: {
enter: { opacity: 1 },
exit: { opacity: 0 }
},
pushLeft: {
enter: { x: "100%" },
exit: { x: "-30%" }
},
pushRight: {
enter: { x: "-100%" },
exit: { x: "30%" }
},
pushUp: {
enter: { y: "100%" },
exit: { y: "-30%" }
},
pushDown: {
enter: { y: "-100%" },
exit: { y: "30%" }
},
slideLeft: {
position: { left: 0, top: 0, bottom: 0, width: "100%" },
enter: { x: 0, y: 0 },
exit: { x: "-100%", y: 0 }
},
slideRight: {
position: { right: 0, top: 0, bottom: 0, width: "100%" },
enter: { x: 0, y: 0 },
exit: { x: "100%", y: 0 }
},
slideUp: {
position: { top: 0, left: 0, right: 0, maxWidth: "100vw" },
enter: { x: 0, y: 0 },
exit: { x: 0, y: "-100%" }
},
slideDown: {
position: { bottom: 0, left: 0, right: 0, maxWidth: "100vw" },
enter: { x: 0, y: 0 },
exit: { x: 0, y: "100%" }
}
};
function getSlideTransition(options) {
var _a;
const side = (_a = options == null ? void 0 : options.direction) != null ? _a : "right";
switch (side) {
case "right":
return TRANSITION_VARIANTS.slideRight;
case "left":
return TRANSITION_VARIANTS.slideLeft;
case "bottom":
return TRANSITION_VARIANTS.slideDown;
case "top":
return TRANSITION_VARIANTS.slideUp;
default:
return TRANSITION_VARIANTS.slideRight;
}
}
var TRANSITION_DEFAULTS = {
enter: {
duration: 0.2,
ease: TRANSITION_EASINGS.easeOut
},
exit: {
duration: 0.1,
ease: TRANSITION_EASINGS.easeIn
}
};
var withDelay = {
enter: (transition, delay) => ({
...transition,
delay: typeof delay === "number" ? delay : delay == null ? void 0 : delay["enter"]
}),
exit: (transition, delay) => ({
...transition,
delay: typeof delay === "number" ? delay : delay == null ? void 0 : delay["exit"]
})
};
// src/slide.tsx
var import_jsx_runtime = require("react/jsx-runtime");
var defaultTransition = {
exit: {
duration: 0.15,
ease: TRANSITION_EASINGS.easeInOut
},
enter: {
type: "spring",
damping: 25,
stiffness: 180
}
};
var variants = {
exit: ({ direction, transition, transitionEnd, delay }) => {
var _a;
const { exit: exitStyles } = getSlideTransition({ direction });
return {
...exitStyles,
transition: (_a = transition == null ? void 0 : transition.exit) != null ? _a : withDelay.exit(defaultTransition.exit, delay),
transitionEnd: transitionEnd == null ? void 0 : transitionEnd.exit
};
},
enter: ({ direction, transitionEnd, transition, delay }) => {
var _a;
const { enter: enterStyles } = getSlideTransition({ direction });
return {
...enterStyles,
transition: (_a = transition == null ? void 0 : transition.enter) != null ? _a : withDelay.enter(defaultTransition.enter, delay),
transitionEnd: transitionEnd == null ? void 0 : transitionEnd.enter
};
}
};
var Slide = (0, import_react.forwardRef)(function Slide2(props, ref) {
const {
direction = "right",
style,
unmountOnExit,
in: isOpen,
className,
transition,
transitionEnd,
delay,
motionProps,
...rest
} = props;
const transitionStyles = getSlideTransition({ direction });
const computedStyle = Object.assign(
{ position: "fixed" },
transitionStyles.position,
style
);
const show = unmountOnExit ? isOpen && unmountOnExit : true;
const animate = isOpen || unmountOnExit ? "enter" : "exit";
const custom = { transitionEnd, transition, direction, delay };
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_framer_motion.AnimatePresence, { custom, children: show && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
import_framer_motion.motion.div,
{
...rest,
ref,
initial: "exit",
className: (0, import_shared_utils.cx)("chakra-slide", className),
animate,
exit: "exit",
custom,
variants,
style: computedStyle,
...motionProps
}
) });
});
Slide.displayName = "Slide";
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
Slide
});
//# sourceMappingURL=slide.js.map