UNPKG

@sikka/hawa

Version:

Modern UI Kit made with Tailwind

165 lines (160 loc) 5.25 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/avatar/index.ts var avatar_exports = {}; __export(avatar_exports, { Avatar: () => Avatar }); module.exports = __toCommonJS(avatar_exports); // elements/avatar/Avatar.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/fileUploader/FileUploader.tsx var import_react = __toESM(require("react")); var FileUploader = ({ handleFile, className }) => { const hiddenFileInput = (0, import_react.useRef)(null); const handleClick = () => { var _a; (_a = hiddenFileInput.current) == null ? void 0 : _a.click(); }; const handleChange = (event) => { const fileUploaded = event.target.files[0]; handleFile(fileUploaded); }; return /* @__PURE__ */ import_react.default.createElement("div", { className }, /* @__PURE__ */ import_react.default.createElement("div", { className: "hawa-h-full hawa-w-full", onClick: handleClick }), /* @__PURE__ */ import_react.default.createElement( "input", { type: "file", onChange: handleChange, ref: hiddenFileInput, style: { display: "none" } } )); }; // elements/avatar/Avatar.tsx var Avatar = ({ isUploadable, hideIcon, src, alt, size = "default", radius = "inherit", icon, className, ...props }) => { let sizeStyles = { "2xs": "hawa-h-4 hawa-w-4", xs: "hawa-h-6 hawa-w-6", sm: "hawa-h-8 hawa-w-8", default: "hawa-h-10 hawa-w-10", lg: "hawa-h-12 hawa-w-12", xl: "hawa-h-14 hawa-w-14", "2xl": "hawa-h-16 hawa-w-16", "3xl": "hawa-h-[72px] hawa-w-[72px]", "4xl": "hawa-h-20 hawa-w-20", "5xl": "hawa-h-[88px] hawa-w-[88px]", "6xl": "hawa-h-24 hawa-w-24" }; let radiusStyles = { full: "hawa-rounded-full", inherit: "hawa-rounded", none: "hawa-rounded-none" }; return /* @__PURE__ */ import_react2.default.createElement( "div", { className: cn( "hawa-relative hawa-bg-card hawa-p-0", sizeStyles[size], radiusStyles[radius], className ) }, /* @__PURE__ */ import_react2.default.createElement( FileUploader, { className: cn( "hawa-absolute hawa-left-0 hawa-top-0 hawa-w-full hawa-cursor-pointer hawa-bg-red-400 hawa-opacity-0", sizeStyles[size], radiusStyles[radius], (!isUploadable || !!src) && "hawa-hidden" ) } ), /* @__PURE__ */ import_react2.default.createElement( "img", { className: cn( "hawa-blue-400 hawa-object-cover", sizeStyles[size], radiusStyles[radius], !src && "hawa-hidden" ), src, alt } ), !src && !hideIcon && /* @__PURE__ */ import_react2.default.createElement( "div", { className: cn( sizeStyles[size], "hawa-flex hawa-flex-col hawa-items-center hawa-justify-center" ) }, icon ? icon : /* @__PURE__ */ import_react2.default.createElement( "svg", { xmlns: "http://www.w3.org/2000/svg", style: { width: "50%", opacity: 0.35 }, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, /* @__PURE__ */ import_react2.default.createElement("circle", { cx: "12", cy: "8", r: "5" }), /* @__PURE__ */ import_react2.default.createElement("path", { d: "M20 21a8 8 0 1 0-16 0" }) ) ) ); }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { Avatar }); //# sourceMappingURL=index.js.map