UNPKG

@ducor/react

Version:

admin template ui interface

67 lines (66 loc) 4.49 kB
var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { Dialog, DialogPanel, Transition, TransitionChild, } from "@headlessui/react"; import { forwardRef, createElement } from "react"; import { twMerge } from "tailwind-merge"; import Flex from "./flex"; import { BtnClose } from "./button"; import Box from "./box"; var Drawer = forwardRef(function (_a, ref) { var _b = _a.isOpen, isOpen = _b === void 0 ? false : _b, _c = _a.size, size = _c === void 0 ? "sm" : _c, _d = _a.placement, placement = _d === void 0 ? "left" : _d, _e = _a.onClose, onClose = _e === void 0 ? function () { } : _e, children = _a.children; return (_jsx(Transition, { show: isOpen, children: _jsxs(Dialog, { className: 'fixed inset-0 z-50 overflow-hidden', onClose: onClose, ref: ref, children: [_jsx(TransitionChild, { enter: 'transition-opacity ease-linear duration-300', enterFrom: 'opacity-0', enterTo: 'opacity-100', leave: 'transition-opacity ease-linear duration-300', leaveFrom: 'opacity-100', leaveTo: 'opacity-0', children: _jsx("div", { className: 'fixed inset-0 bg-gray-500 bg-opacity-75 opacity-50 transition-opacity dark:bg-black dark:bg-opacity-50' }) }), _jsx("div", { className: 'fixed inset-0 overflow-hidden', children: _jsx("div", { className: 'absolute inset-0 overflow-hidden', children: _jsx("div", { className: 'pointer-events-none fixed inset-y-0 right-0 flex max-w-full pl-10', children: _jsx(TransitionChild, { enter: 'transform transition ease-in-out duration-300 sm:duration-500', enterFrom: 'translate-x-full', enterTo: 'translate-x-0', leave: 'transform transition ease-in-out duration-300 sm:duration-500', leaveFrom: 'translate-x-0', leaveTo: 'translate-x-full', children: _jsx(DialogPanel, { className: 'pointer-events-auto w-screen max-w-md', children: _jsxs(Box, { className: 'relative h-screen', children: [_jsx("div", { className: 'absolute top-5 right-3 size-5', children: _jsx(BtnClose, { onClose: onClose }) }), _jsx(Flex, { justify: 'between', direction: 'col', className: 'h-screen flex-col bg-white shadow-xl dark:bg-gray-800', children: children })] }) }) }) }) }) })] }) })); }); var DrawerHeader = function (_a) { var children = _a.children, className = _a.className, res = __rest(_a, ["children", "className"]); return createElement("div", __assign({ className: twMerge("block flex-none p-4 border-b border-gray-200 dark:border-gray-700", className) }, res), children); }; var DrawerTitle = function (_a) { var children = _a.children, className = _a.className; return createElement("h3", { className: twMerge("text-lg font-medium leading-6 text-gray-900 dark:text-white", className), }, children); }; var DrawerSubTitle = function (_a) { var children = _a.children, className = _a.className; return children ? createElement("p", { className: twMerge("font-medium text-gray-900 dark:text-gray-300", className), }, children) : null; }; var DrawerBody = function (_a) { var children = _a.children, className = _a.className; return (_jsx("div", { className: twMerge("flex-1 p-4 h-full overflow-y-auto dark:text-gray-300", className), children: children })); }; var DrawerFooter = function (_a) { var children = _a.children, className = _a.className; return (_jsx(Flex, { justify: 'end', className: twMerge("block flex-none p-4 border-b border-gray-200 dark:border-gray-700", className), children: children })); }; export default Object.assign(Drawer, { Header: DrawerHeader, Title: DrawerTitle, SubTitle: DrawerSubTitle, Body: DrawerBody, Footer: DrawerFooter, });