UNPKG

@sikka/hawa

Version:

Modern UI Kit made with Tailwind

211 lines (205 loc) • 8.13 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); // layout/stats/index.ts var stats_exports = {}; __export(stats_exports, { Stats: () => Stats }); module.exports = __toCommonJS(stats_exports); // layout/stats/Stats.tsx var import_react2 = __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/skeleton/Skeleton.tsx var import_react = __toESM(require("react")); function Skeleton({ className, content, animation = "pulse", fade, ...props }) { const animationStyles = { none: "hawa-rounded hawa-bg-muted", pulse: "hawa-animate-pulse hawa-rounded hawa-bg-muted", shimmer: "hawa-space-y-5 hawa-rounded hawa-bg-muted hawa-p-4 hawa-relative before:hawa-absolute before:hawa-inset-0 before:hawa--translate-x-full before:hawa-animate-[shimmer_2s_infinite] before:hawa-bg-gradient-to-r before:hawa-from-transparent before:hawa-via-gray-300/40 dark:before:hawa-via-white/10 before:hawa-to-transparent hawa-isolate hawa-overflow-hidden before:hawa-border-t before:hawa-border-rose-100/10" }; const fadeStyle = { bottom: "hawa-mask-fade-bottom", top: "hawa-mask-fade-top", right: "hawa-mask-fade-right", left: "hawa-mask-fade-left " }; return /* @__PURE__ */ import_react.default.createElement( "div", { className: cn( animationStyles[animation], content && "hawa-flex hawa-flex-col hawa-items-center hawa-justify-center", fade && fadeStyle[fade], className ), ...props }, content && content ); } // layout/stats/Stats.tsx var Stats = ({ label, icon, isLoading, number, helperText, helperTextColor = "default", chart, clickable, variant = "default", ...props }) => { let helperTextColorStyles = { default: "", positive: "hawa-text-green-600 dark:hawa-text-green-500", negative: "hawa-text-red-600 dark:hawa-text-red-500", muted: "hawa-text-muted-foreground" }; return /* @__PURE__ */ import_react2.default.createElement(Card, { ...props, clickable }, /* @__PURE__ */ import_react2.default.createElement("div", { className: "hawa-flex hawa-flex-row hawa-items-center hawa-justify-between hawa-p-4 hawa-px-6" }, /* @__PURE__ */ import_react2.default.createElement(CardTitle, { className: "hawa-text-sm hawa-font-medium" }, label), icon && /* @__PURE__ */ import_react2.default.createElement("span", null, icon)), /* @__PURE__ */ import_react2.default.createElement(CardContent, { className: "hawa-transition-all" }, isLoading ? /* @__PURE__ */ import_react2.default.createElement(Skeleton, { className: "hawa-h-8 hawa-w-3/4" }) : /* @__PURE__ */ import_react2.default.createElement("div", { className: "hawa-text-2xl hawa-font-bold" }, number), helperText && /* @__PURE__ */ import_react2.default.createElement( "div", { className: cn( "hawa-my-0 hawa-text-start hawa-text-xs hawa-transition-all", helperTextColorStyles[helperTextColor], helperText ? "hawa-h-4 hawa-opacity-100" : "hawa-h-0 hawa-opacity-0" ) }, isLoading ? /* @__PURE__ */ import_react2.default.createElement(Skeleton, { className: "hawa-mt-2 hawa-h-4 hawa-w-1/2" }) : helperText ), chart && (isLoading ? /* @__PURE__ */ import_react2.default.createElement(Skeleton, { className: "hawa-mt-2 hawa-h-4 hawa-w-1/2" }) : chart))); }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { Stats }); //# sourceMappingURL=index.js.map