UNPKG

@sikka/hawa

Version:

Modern UI Kit made with Tailwind

217 lines (212 loc) • 7.83 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); // elements/destroyableCard/index.ts var destroyableCard_exports = {}; __export(destroyableCard_exports, { DestroyableCard: () => DestroyableCard }); module.exports = __toCommonJS(destroyableCard_exports); // elements/destroyableCard/DestroyableCard.tsx var import_react = __toESM(require("react")); // util/index.ts var import_clsx = require("clsx"); var import_tailwind_merge = require("tailwind-merge"); function cn(...inputs) { return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs)); } // elements/card/Card.tsx var React = __toESM(require("react")); var Card = React.forwardRef( ({ className, variant = "default", clickable = false, asContainer = false, ...props }, ref) => { let variantStyles = { default: cn( "hawa-rounded-lg hawa-border hawa-bg-card hawa-text-card-foreground hawa-shadow-sm", clickable && "hawa-cursor-pointer hawa-transition-all hover:hawa-drop-shadow-md dark:hover:dark-shadow" ), neoBrutalism: cn( "neo-brutalism", // "hawa-transition-all hawa-uppercase hawa-font-mono dark:hawa-bg-black hawa-font-bold hawa-py-2 hawa-px-4 hawa-rounded hawa-border-2 hawa-border-primary hawa-shadow-color-primary hawa-transition-[hawa-transform_50ms, hawa-box-shadow_50ms] transition-all uppercase font-mono dark:bg-black font-bold py-2 px-4 rounded border-2 border-primary shadow-color-primary transition-[transform_50ms, box-shadow_50ms]", clickable && "hawa-cursor-pointer active:hawa-translate-x-0.5 active:hawa-translate-y-0.5 active:hawa-shadow-color-primary-active active:translate-x-0.5 active:translate-y-0.5 active:shadow-color-primary-active" ) }; return /* @__PURE__ */ React.createElement( "div", { ref, className: cn(className, !asContainer && variantStyles[variant]), ...props } ); } ); var CardHeader = React.forwardRef( ({ className, ...props }, ref) => /* @__PURE__ */ React.createElement("div", { className: "hawa-flex hawa-flex-row hawa-justify-between" }, /* @__PURE__ */ React.createElement( "div", { ref, className: cn( "hawa-flex hawa-flex-col hawa-space-y-1.5 hawa-p-6", className ), ...props } ), props.actions && /* @__PURE__ */ React.createElement("div", { className: "hawa-p-6" }, props.actions)) ); var CardTitle = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement( "h3", { ref, className: cn("hawa-text-2xl hawa-font-semibold", className), ...props } )); var CardDescription = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement( "p", { ref, className: cn("hawa-text-sm hawa-text-muted-foreground", className), ...props } )); var CardContent = React.forwardRef( ({ headless, noPadding, className, ...props }, ref) => /* @__PURE__ */ React.createElement( "div", { ref, className: cn( noPadding ? "hawa-p-0" : "hawa-p-6", headless ? "hawa-pt-6" : "hawa-pt-0", className ), ...props } ) ); var CardFooter = React.forwardRef(({ className, noPadding, ...props }, ref) => /* @__PURE__ */ React.createElement( "div", { ref, className: cn( noPadding ? "hawa-p-0" : "hawa-p-6", "hawa-flex hawa-items-center hawa-pt-0", className ), ...props } )); CardDescription.displayName = "CardDescription"; CardContent.displayName = "CardContent"; CardHeader.displayName = "CardHeader"; CardFooter.displayName = "CardFooter"; CardTitle.displayName = "CardTitle"; Card.displayName = "Card"; // elements/destroyableCard/DestroyableCard.tsx var DestroyableCard = ({ position = "bottom-right", fixed, direction, ...props }) => { const [closed, setClosed] = (0, import_react.useState)(false); const popUpRef = (0, import_react.useRef)(null); const boxPosition = { "bottom-right": "hawa-right-4 hawa-bottom-4", "bottom-left": "hawa-left-4 hawa-bottom-4" }; return /* @__PURE__ */ import_react.default.createElement( "div", { className: cn( "hawa-transition-all", closed ? "hawa-opacity-0" : "hawa-opacity-100" ), ref: popUpRef }, /* @__PURE__ */ import_react.default.createElement( Card, { className: cn( fixed ? "hawa-fixed" : "hawa-relative", fixed && position && boxPosition[position] ), dir: direction }, /* @__PURE__ */ import_react.default.createElement( "button", { type: "button", className: cn( direction === "rtl" ? "hawa-left-2" : "hawa-right-2", "hawa-absolute hawa-top-2 hawa-inline-flex hawa-h-8 hawa-w-8 hawa-rounded hawa-p-1.5 hawa-text-gray-400 hawa-transition-all hover:hawa-bg-gray-100 hover:hawa-text-gray-900 focus:hawa-ring-2 focus:hawa-ring-gray-300 dark:hawa-bg-gray-800 dark:hawa-text-gray-500 dark:hover:hawa-bg-gray-700 dark:hover:hawa-text-white" ), "data-dismiss-target": "#destroyable-card", "aria-label": "Close", onClick: () => { setClosed(true); setTimeout(() => { if (popUpRef == null ? void 0 : popUpRef.current) { popUpRef == null ? void 0 : popUpRef.current.removeChild(popUpRef == null ? void 0 : popUpRef.current.children[0]); } }, 200); } }, /* @__PURE__ */ import_react.default.createElement( "svg", { "aria-hidden": "true", className: "hawa-h-5 hawa-w-5", fill: "currentColor", viewBox: "0 0 20 20" }, /* @__PURE__ */ import_react.default.createElement( "path", { fillRule: "evenodd", d: "M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z", clipRule: "evenodd" } ) ) ), /* @__PURE__ */ import_react.default.createElement(CardContent, { headless: true }, props.children) ) ); }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { DestroyableCard }); //# sourceMappingURL=index.js.map