UNPKG

@vela-ui/react

Version:

Vela UI React components

237 lines (231 loc) 8.07 kB
"use strict"; "use client"; 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/components/drawer.tsx var drawer_exports = {}; __export(drawer_exports, { Drawer: () => Drawer, DrawerCloseIcon: () => DrawerCloseIcon, DrawerContent: () => DrawerContent, DrawerDescription: () => DrawerDescription, DrawerFooter: () => DrawerFooter, DrawerHeader: () => DrawerHeader, DrawerTitle: () => DrawerTitle, DrawerTrigger: () => DrawerTrigger }); module.exports = __toCommonJS(drawer_exports); var import_react_aria_components3 = require("react-aria-components"); var import_tailwind_variants = require("tailwind-variants"); // src/icons/close.tsx var import_jsx_runtime = require("react/jsx-runtime"); var CloseIcon = (props) => { return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)( "svg", { fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", width: "1em", height: "1em", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", ...props, children: [ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M18 6 6 18" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m6 6 12 12" }) ] } ); }; // src/lib/utils.ts var import_clsx = require("clsx"); var import_react_aria_components = require("react-aria-components"); var import_tailwind_merge = require("tailwind-merge"); var cn = (...inputs) => (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(...inputs)); function composeTailwindRenderProps(className, tailwind) { return (0, import_react_aria_components.composeRenderProps)(className, (className2) => (0, import_tailwind_merge.twMerge)(tailwind, className2)); } // src/components/dialog.tsx var import_react_aria_components2 = require("react-aria-components"); var import_jsx_runtime2 = require("react/jsx-runtime"); var DialogTrigger = import_react_aria_components2.DialogTrigger; var DialogContent = ({ role = "dialog", className, children, showCloseButton = true, ...props }) => { return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( import_react_aria_components2.Dialog, { role, "data-slot": "dialog-content", className: cn("relative flex h-full w-full flex-col p-6 outline-hidden", className), ...props, children: (0, import_react_aria_components2.composeRenderProps)(children, (children2) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [ children2, showCloseButton && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DialogCloseIcon, {}) ] })) } ); }; var DialogHeader = ({ className, ...props }) => { return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( "div", { "data-slot": "dialog-header", className: cn("mb-4 flex flex-col gap-2 text-center sm:text-left", className), ...props } ); }; var DialogFooter = ({ className, ...props }) => { return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( "div", { "data-slot": "dialog-footer", className: cn("mt-4 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", className), ...props } ); }; var DialogTitle = ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( import_react_aria_components2.Heading, { slot: "title", "data-slot": "dialog-title", className: cn("text-lg leading-none font-semibold", className), ...props } ); var DialogDescription = ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( import_react_aria_components2.Text, { slot: "description", "data-slot": "dialog-description", className: cn("text-muted-foreground text-sm", className), ...props } ); var DialogCloseIcon = ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)( import_react_aria_components2.Button, { "aria-label": "Close", slot: "close", "data-slot": "dialog-close", className: composeTailwindRenderProps( className, "ring-offset-background focus:ring-ring absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4" ), ...props, children: [ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CloseIcon, {}), /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "sr-only", children: "Close" }) ] } ); // src/components/drawer.tsx var import_jsx_runtime3 = require("react/jsx-runtime"); var drawerOverlayVariants = (0, import_tailwind_variants.tv)({ base: "fixed top-0 left-0 isolate z-50 flex w-full items-center justify-center bg-black/50", variants: { isEntering: { true: "animate-in fade-in-0 duration-300" }, isExiting: { true: "animate-out fade-out-0 duration-200" } } }); var drawerVariants = (0, import_tailwind_variants.tv)({ base: "bg-background fixed z-50 flex h-auto flex-col shadow-lg transition", variants: { placement: { top: "data-[entering]:slide-in-from-top data-[exiting]:slide-out-to-top inset-x-0 top-0 border-b", bottom: "data-[entering]:slide-in-from-bottom data-[exiting]:slide-out-to-bottom inset-x-0 bottom-0 border-t", left: "data-[entering]:slide-in-from-left data-[exiting]:slide-out-to-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm", right: "data-[entering]:slide-in-from-right data-[exiting]:slide-out-to-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm" }, isEntering: { true: "animate-in duration-300" }, isExiting: { true: "animate-out duration-200" } }, defaultVariants: { placement: "right" } }); var Drawer = ({ className, overlayClassName, isDismissable = true, placement, ...props }) => { return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)( import_react_aria_components3.ModalOverlay, { "data-slot": "drawer-overlay", style: { height: "var(--visual-viewport-height)" }, isDismissable, className: (0, import_react_aria_components3.composeRenderProps)( overlayClassName, (className2, renderProps) => drawerOverlayVariants({ ...renderProps, className: className2 }) ), ...props, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)( import_react_aria_components3.Modal, { "data-slot": "drawer", isDismissable, className: (0, import_react_aria_components3.composeRenderProps)( className, (className2, renderProps) => drawerVariants({ ...renderProps, placement, className: className2 }) ), ...props } ) } ); }; var DrawerTrigger = DialogTrigger; var DrawerContent = DialogContent; var DrawerHeader = DialogHeader; var DrawerFooter = DialogFooter; var DrawerTitle = DialogTitle; var DrawerDescription = DialogDescription; var DrawerCloseIcon = DialogCloseIcon; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { Drawer, DrawerCloseIcon, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger });