UNPKG

@sikka/hawa

Version:

Modern UI Kit made with Tailwind

1,377 lines (1,356 loc) • 60.4 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/appLayout/index.ts var appLayout_exports = {}; __export(appLayout_exports, { AppLayout: () => AppLayout }); module.exports = __toCommonJS(appLayout_exports); // layout/appLayout/AppLayout.tsx var import_react10 = __toESM(require("react")); // hooks/useClickOutside.ts var import_react = require("react"); var DEFAULT_EVENTS = ["mousedown", "touchstart"]; function useClickOutside(handler, events, nodes) { const ref = (0, import_react.useRef)(); (0, import_react.useEffect)(() => { const listener = (event) => { const { target } = event != null ? event : {}; if (Array.isArray(nodes)) { const shouldIgnore = (target == null ? void 0 : target.hasAttribute("data-ignore-outside-clicks")) || !document.body.contains(target) && target.tagName !== "HTML"; const shouldTrigger = nodes.every( (node) => !!node && !event.composedPath().includes(node) ); shouldTrigger && !shouldIgnore && handler(); } else if (ref.current && !ref.current.contains(target)) { handler(); } }; (events || DEFAULT_EVENTS).forEach( (fn) => document.addEventListener(fn, listener) ); return () => { (events || DEFAULT_EVENTS).forEach( (fn) => document.removeEventListener(fn, listener) ); }; }, [ref, handler, nodes]); return ref; } // layout/appLayout/AppLayout.tsx var Dialog = __toESM(require("@radix-ui/react-dialog")); // 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/button/Button.tsx var React5 = __toESM(require("react")); var import_class_variance_authority = require("class-variance-authority"); // elements/helperText/HelperText.tsx var import_react2 = __toESM(require("react")); var HelperText = ({ helperText }) => /* @__PURE__ */ import_react2.default.createElement( "p", { className: cn( "hawa-my-0 hawa-text-start hawa-text-xs hawa-text-helper-color hawa-transition-all", helperText ? "hawa-h-4 hawa-opacity-100" : "hawa-h-0 hawa-opacity-0" ) }, helperText ); // elements/label/Label.tsx var React3 = __toESM(require("react")); // elements/tooltip/Tooltip.tsx var import_react3 = __toESM(require("react")); var TooltipPrimitive = __toESM(require("@radix-ui/react-tooltip")); var TooltipContent = import_react3.default.forwardRef(({ className, sideOffset = 4, size = "default", ...props }, ref) => /* @__PURE__ */ import_react3.default.createElement( TooltipPrimitive.Content, { ref, sideOffset, className: cn( "hawa-z-50 hawa-overflow-hidden hawa-rounded-md hawa-border hawa-bg-popover hawa-px-3 hawa-py-1.5 hawa-text-sm hawa-text-popover-foreground hawa-shadow-md hawa-animate-in hawa-fade-in-0 hawa-zoom-in-95 data-[state=closed]:hawa-animate-out data-[state=closed]:hawa-fade-out-0 data-[state=closed]:hawa-zoom-out-95 data-[side=bottom]:hawa-slide-in-from-top-2 data-[side=left]:hawa-slide-in-from-right-2 data-[side=right]:hawa-slide-in-from-left-2 data-[side=top]:hawa-slide-in-from-bottom-2", { "hawa-text-xs": size === "small", "hawa-text-xl": size === "large" }, className ), ...props } )); TooltipContent.displayName = TooltipPrimitive.Content.displayName; var TooltipArrow = import_react3.default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ import_react3.default.createElement(TooltipPrimitive.Arrow, { ref, className: cn(className), ...props })); TooltipArrow.displayName = TooltipPrimitive.Arrow.displayName; var Tooltip = ({ side, size, open, content, children, disabled, defaultOpen, onOpenChange, triggerProps, contentProps, providerProps, delayDuration = 300, ...props }) => { return /* @__PURE__ */ import_react3.default.createElement( TooltipPrimitive.TooltipProvider, { delayDuration, ...providerProps }, /* @__PURE__ */ import_react3.default.createElement( TooltipPrimitive.Root, { open: !disabled && open, defaultOpen, onOpenChange, ...props }, /* @__PURE__ */ import_react3.default.createElement(TooltipPrimitive.Trigger, { ...triggerProps }, children), /* @__PURE__ */ import_react3.default.createElement( TooltipContent, { size, side, align: "center", ...contentProps, style: { ...contentProps == null ? void 0 : contentProps.style, maxWidth: "var(--radix-tooltip-content-available-width)", maxHeight: "var(--radix-tooltip-content-available-height)" } }, content ) ) ); }; // elements/label/Label.tsx var Label = React3.forwardRef(({ className, hint, hintSide, required, children, ...props }, ref) => /* @__PURE__ */ React3.createElement("div", { className: "hawa-flex hawa-flex-row hawa-items-center hawa-gap-1 hawa-transition-all" }, /* @__PURE__ */ React3.createElement( "label", { ref, className: cn( "hawa-text-sm hawa-font-medium hawa-leading-none peer-disabled:hawa-cursor-not-allowed peer-disabled:hawa-opacity-70", className ), ...props }, children, required && /* @__PURE__ */ React3.createElement("span", { className: "hawa-mx-0.5 hawa-text-red-500" }, "*") ), hint && /* @__PURE__ */ React3.createElement( Tooltip, { content: hint, side: hintSide, triggerProps: { tabIndex: -1, onClick: (event) => event.preventDefault() } }, /* @__PURE__ */ React3.createElement("div", null, /* @__PURE__ */ React3.createElement( "svg", { xmlns: "http://www.w3.org/2000/svg", className: "hawa-h-[14px] hawa-w-[14px] hawa-cursor-help", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, /* @__PURE__ */ React3.createElement("circle", { cx: "12", cy: "12", r: "10" }), /* @__PURE__ */ React3.createElement("path", { d: "M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3" }), /* @__PURE__ */ React3.createElement("path", { d: "M12 17h.01" }) )) ))); Label.displayName = "Label"; // elements/loading/Loading.tsx var import_react4 = __toESM(require("react")); var Loading = ({ design = "spinner", size = "normal", themeMode = "light", classNames, color, ...props }) => { let sizeStyles = { button: "hawa-h-4 hawa-w-4", xs: "hawa-h-1 hawa-w-1", sm: "hawa-h-6 hawa-w-6", normal: "hawa-h-8 hawa-w-8", lg: "hawa-h-14 hawa-w-14", xl: "hawa-h-24 hawa-w-24" }; let progressSizes = { button: "hawa-h-1", xs: "hawa-h-1 hawa-w-1", sm: "hawa-h-6 hawa-w-6", normal: "", lg: "hawa-h-6", xl: "hawa-h-10 hawa-w-64" }; let animationStyles = { pulse: "hawa-animate-in hawa-fade-in hawa-duration-1000", bounce: "hawa-animate-bounce" }; switch (design.split("-")[0]) { case "dots": return /* @__PURE__ */ import_react4.default.createElement( "div", { className: cn( "hawa-flex hawa-flex-row hawa-gap-2", classNames == null ? void 0 : classNames.container ) }, /* @__PURE__ */ import_react4.default.createElement( "div", { className: cn( "hawa-animate-bounce hawa-rounded-full hawa-delay-100 hawa-repeat-infinite", size === "button" ? "hawa-h-2 hawa-w-2" : sizeStyles[size], animationStyles[design.split("-")[1]], color ? color : "hawa-bg-primary" ) } ), /* @__PURE__ */ import_react4.default.createElement( "div", { className: cn( "hawa-animate-bounce hawa-rounded-full hawa-delay-200 hawa-repeat-infinite", size === "button" ? "hawa-h-2 hawa-w-2" : sizeStyles[size], animationStyles[design.split("-")[1]], color ? color : "hawa-bg-primary" ) } ), /* @__PURE__ */ import_react4.default.createElement( "div", { className: cn( "hawa-animate-bounce hawa-rounded-full hawa-delay-300 hawa-repeat-infinite", size === "button" ? "hawa-h-2 hawa-w-2" : sizeStyles[size], animationStyles[design.split("-")[1]], color ? color : "hawa-bg-primary" ) } ) ); case "square": return /* @__PURE__ */ import_react4.default.createElement( "svg", { className: cn( "squircle-container", sizeStyles[size], classNames == null ? void 0 : classNames.container ), viewBox: "0 0 35 35", height: "35", width: "35" }, /* @__PURE__ */ import_react4.default.createElement( "rect", { className: "squircle-track", x: "2.5", y: "2.5", fill: "none", strokeWidth: "5px", width: "32.5", height: "32.5" } ), /* @__PURE__ */ import_react4.default.createElement( "rect", { className: "square-car", x: "2.5", y: "2.5", fill: "none", strokeWidth: "5px", width: "32.5", height: "32.5", pathLength: "100" } ) ); case "squircle": return /* @__PURE__ */ import_react4.default.createElement( "svg", { x: "0px", y: "0px", viewBox: "0 0 37 37", height: "37", width: "37", preserveAspectRatio: "xMidYMid meet", className: cn( "squircle-container", sizeStyles[size], classNames == null ? void 0 : classNames.container ) }, /* @__PURE__ */ import_react4.default.createElement( "path", { className: cn("squircle-track", classNames == null ? void 0 : classNames.track), fill: "none", strokeWidth: "5", pathLength: "100", d: "M0.37 18.5 C0.37 5.772 5.772 0.37 18.5 0.37 S36.63 5.772 36.63 18.5 S31.228 36.63 18.5 36.63 S0.37 31.228 0.37 18.5" } ), /* @__PURE__ */ import_react4.default.createElement( "path", { className: cn("squircle-car", classNames == null ? void 0 : classNames.car), fill: "none", strokeWidth: "5", pathLength: "100", d: "M0.37 18.5 C0.37 5.772 5.772 0.37 18.5 0.37 S36.63 5.772 36.63 18.5 S31.228 36.63 18.5 36.63 S0.37 31.228 0.37 18.5" } ) ); case "progress": return /* @__PURE__ */ import_react4.default.createElement( "div", { className: cn( "progress-loading after:hawa-rounded hawa-rounded", progressSizes[size], classNames == null ? void 0 : classNames.container ) } ); case "orbit": return /* @__PURE__ */ import_react4.default.createElement("div", { className: cn("orbit-container", classNames == null ? void 0 : classNames.container) }); default: return /* @__PURE__ */ import_react4.default.createElement( "svg", { viewBox: "0 0 40 40", height: "40", width: "40", className: cn( "circle-container", sizeStyles[size], classNames == null ? void 0 : classNames.container ) }, /* @__PURE__ */ import_react4.default.createElement( "circle", { className: cn( "circle-track", { "hawa-stroke-primary-foreground": themeMode === "dark", "hawa-stroke-primary": themeMode === "light" }, classNames == null ? void 0 : classNames.track ), cx: "20", cy: "20", r: "17.5", fill: "none", strokeWidth: "5px", pathLength: "100" } ), /* @__PURE__ */ import_react4.default.createElement( "circle", { className: cn( "circle-car", { "hawa-stroke-primary-foreground": themeMode === "dark", "hawa-stroke-primary": themeMode === "light" }, classNames == null ? void 0 : classNames.car ), cx: "20", cy: "20", r: "17.5", fill: "none", pathLength: "100", strokeWidth: "5px" } ) ); } }; // elements/button/Button.tsx var buttonVariants = (0, import_class_variance_authority.cva)( "hawa-inline-flex hawa-items-center hawa-select-none hawa-rounded-md hawa-text-sm hawa-font-medium hawa-ring-offset-background hawa-transition-colors focus-visible:hawa-outline-none focus-visible:hawa-ring-2 focus-visible:hawa-ring-ring focus-visible:hawa-ring-offset-2 disabled:hawa-pointer-events-none disabled:hawa-opacity-50", { variants: { variant: { default: "hawa-bg-primary hawa-text-primary-foreground hover:hawa-bg-primary/90", light: "hawa-bg-primary/20 hawa-text-primary hover:hawa-bg-primary/40", destructive: "hawa-bg-destructive hawa-text-destructive-foreground hover:hawa-bg-destructive/90", outline: "hawa-border hawa-border-input hawa-bg-transparent hover:hawa-bg-accent hover:hawa-text-accent-foreground", secondary: "hawa-bg-secondary hawa-text-secondary-foreground hover:hawa-bg-secondary/80", ghost: "hover:hawa-bg-accent hover:hawa-text-accent-foreground", link: "hawa-text-primary hawa-underline-offset-4 hover:hawa-underline", combobox: "hawa-bg-background hawa-border", neoBrutalism: "neo-brutalism" // "hawa-cursor-pointer 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] active:hawa-translate-x-0.5 active:hawa-translate-y-0.5 active:hawa-shadow-color-primary-active shadow-color-primary active:shadow-color-primary-active", }, size: { default: "hawa-h-10 hawa-px-4 hawa-py-2", heightless: "hawa-px-4 hawa-py-4", xs: "hawa-h-fit hawa-min-h-[25px] hawa-py-1 hawa-text-[10px] hawa-px-2 ", sm: "hawa-h-9 hawa-text-[11px] hawa-rounded-md hawa-px-3", lg: "hawa-h-11 hawa-rounded-md hawa-px-8", xl: "hawa-h-14 hawa-rounded-md hawa-px-10", icon: "hawa-h-10 hawa-w-10", smallIcon: "hawa-h-7 hawa-w-7" } }, defaultVariants: { variant: "default", size: "default" } } ); var Button = React5.forwardRef( ({ className, label, variant, size, asChild = false, centered = true, isLoading, children, labelProps, showHelperText = false, asInput = false, ...props }, ref) => { const Comp = "button"; const loadingColor = variant === "outline" || variant === "ghost" || variant === "neoBrutalism" ? "hawa-bg-primary" : "hawa-bg-primary-foreground"; if (asInput) { return /* @__PURE__ */ React5.createElement("div", { className: "hawa-flex hawa-flex-col hawa-gap-2" }, label && /* @__PURE__ */ React5.createElement(Label, { ...labelProps }, label), /* @__PURE__ */ React5.createElement( Comp, { className: cn( buttonVariants({ variant, size, className }), centered && "hawa-justify-center" ), ref, ...props }, isLoading ? /* @__PURE__ */ React5.createElement( Loading, { design: size === "icon" || size === "smallIcon" ? "spinner" : "dots-pulse", themeMode: variant === "outline" ? "light" : "dark", color: loadingColor, size: size === "sm" || size === "xs" ? "xs" : "button" } ) : children ), showHelperText && /* @__PURE__ */ React5.createElement(HelperText, { helperText: props.helperText })); } else { return /* @__PURE__ */ React5.createElement( Comp, { className: cn( buttonVariants({ variant, size, className }), centered && "hawa-justify-center" ), ref, ...props }, isLoading ? /* @__PURE__ */ React5.createElement( Loading, { design: size === "icon" || size === "smallIcon" ? "spinner" : "dots-pulse", themeMode: variant === "outline" ? "light" : "dark", color: loadingColor, size: size === "sm" || size === "xs" ? "xs" : "button" } ) : children ); } } ); Button.displayName = "Button"; // elements/dropdownMenu/DropdownMenu.tsx var React6 = __toESM(require("react")); var import_react5 = require("@headlessui/react"); var DropdownMenuPrimitive = __toESM(require("@radix-ui/react-dropdown-menu")); var DropdownMenuRoot = DropdownMenuPrimitive.Root; var DropdownMenuTrigger = DropdownMenuPrimitive.Trigger; var DropdownMenuSub = DropdownMenuPrimitive.Sub; var DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup; var DropdownMenuSubTrigger = React6.forwardRef(({ className, inset, children, ...props }, ref) => /* @__PURE__ */ React6.createElement( DropdownMenuPrimitive.SubTrigger, { ref, className: cn( "hawa-flex hawa-cursor-default hawa-select-none hawa-items-center hawa-justify-between hawa-rounded-sm hawa-text-sm hawa-outline-none focus:hawa-bg-accent data-[state=open]:hawa-bg-accent", inset && "hawa-pl-8", className ), ...props }, /* @__PURE__ */ React6.createElement("div", { className: "hawa-flex hawa-flex-row hawa-items-center hawa-gap-2" }, children), " ", /* @__PURE__ */ React6.createElement( "svg", { "aria-label": "Chevron Right Icon", stroke: "currentColor", fill: "currentColor", strokeWidth: "0", viewBox: "0 0 16 16", height: "1em", width: "1em", className: cn(props.dir === "rtl" ? "hawa-rotate-180" : "") }, /* @__PURE__ */ React6.createElement( "path", { fillRule: "evenodd", d: "M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z" } ) ) )); DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName; var DropdownMenuSubContent = React6.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React6.createElement( DropdownMenuPrimitive.SubContent, { ref, className: cn( "hawa-z-50 hawa-min-w-[8rem] hawa-gap-1 hawa-overflow-hidden hawa-rounded-md hawa-border hawa-bg-popover hawa-p-1 hawa-text-popover-foreground hawa-shadow-lg data-[state=open]:hawa-animate-in data-[state=closed]:hawa-animate-out data-[state=closed]:hawa-fade-out-0 data-[state=open]:hawa-fade-in-0 data-[state=closed]:hawa-zoom-out-95 data-[state=open]:hawa-zoom-in-95 data-[side=bottom]:hawa-slide-in-from-top-2 data-[side=left]:hawa-slide-in-from-right-2 data-[side=right]:hawa-slide-in-from-left-2 data-[side=top]:hawa-slide-in-from-bottom-2", className ), ...props } )); DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName; var DropdownMenuContent = React6.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ React6.createElement(import_react5.Portal, null, /* @__PURE__ */ React6.createElement( DropdownMenuPrimitive.Content, { ref, sideOffset, className: cn( "hawa-z-50 hawa-overflow-hidden hawa-rounded-md hawa-border hawa-bg-popover hawa-p-1 hawa-text-popover-foreground hawa-shadow-md data-[state=open]:hawa-animate-in data-[state=closed]:hawa-animate-out data-[state=closed]:hawa-fade-out-0 data-[state=open]:hawa-fade-in-0 data-[state=closed]:hawa-zoom-out-95 data-[state=open]:hawa-zoom-in-95 data-[side=bottom]:hawa-slide-in-from-top-2 data-[side=left]:hawa-slide-in-from-right-2 data-[side=right]:hawa-slide-in-from-left-2 data-[side=top]:hawa-slide-in-from-bottom-2", className ), ...props } ))); DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName; var DropdownMenuItem = React6.forwardRef(({ className, inset, badged, slug, LinkComponent = "a", ...props }, ref) => { return /* @__PURE__ */ React6.createElement(LinkComponent, { href: slug }, /* @__PURE__ */ React6.createElement( DropdownMenuPrimitive.Item, { disabled: props.disabled, ref, className: cn( "hawa-relative hawa-flex hawa-cursor-pointer hawa-select-none hawa-items-center hawa-justify-between hawa-rounded-sm hawa-text-sm hawa-outline-none hawa-transition-colors focus:hawa-text-accent-foreground data-[disabled]:hawa-pointer-events-none data-[disabled]:hawa-opacity-50", inset && "hawa-pl-8", props.end && Array.isArray(props.children) && props.children[1] && "hawa-gap-6", className ), ...props }, /* @__PURE__ */ React6.createElement("div", { className: "hawa-flex hawa-flex-row hawa-items-center hawa-gap-2" }, props.children), props.end && props.end, !props.end && props.shortcut && /* @__PURE__ */ React6.createElement(DropdownMenuShortcut, null, props.shortcut), !props.end && badged && /* @__PURE__ */ React6.createElement("div", { className: "hawa-h-3 hawa-w-3 hawa-rounded-full hawa-bg-red-500" }) )); }); DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName; var DropdownMenuCheckboxItem = React6.forwardRef(({ className, children, checked, ...props }, ref) => /* @__PURE__ */ React6.createElement( DropdownMenuPrimitive.CheckboxItem, { ref, className: cn( "hawa-relative hawa-flex hawa-cursor-default hawa-select-none hawa-items-center hawa-rounded-sm hawa-py-1.5 hawa-pl-8 hawa-pr-2 hawa-text-sm hawa-outline-none hawa-transition-colors focus:hawa-bg-accent focus:hawa-text-accent-foreground data-[disabled]:hawa-pointer-events-none data-[disabled]:hawa-opacity-50", className ), checked, ...props }, /* @__PURE__ */ React6.createElement("span", { className: "hawa-absolute hawa-left-2 hawa-flex hawa-h-3.5 hawa-w-3.5 hawa-items-center hawa-justify-center" }, /* @__PURE__ */ React6.createElement(DropdownMenuPrimitive.ItemIndicator, null, /* @__PURE__ */ React6.createElement( "svg", { "aria-label": "Check Mark", stroke: "currentColor", fill: "currentColor", strokeWidth: "0", viewBox: "0 0 512 512", height: "0.60em", width: "0.60em" }, /* @__PURE__ */ React6.createElement("path", { d: "M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z" }) ), " ")), children )); DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName; var DropdownMenuRadioItem = React6.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ React6.createElement( DropdownMenuPrimitive.RadioItem, { ref, className: cn( "hawa-relative hawa-flex hawa-cursor-pointer hawa-select-none hawa-items-center hawa-rounded-sm hawa-py-1.5 hawa-pl-8 hawa-pr-2 hawa-text-sm hawa-outline-none hawa-transition-colors focus:hawa-bg-accent focus:hawa-text-accent-foreground data-[disabled]:hawa-pointer-events-none data-[disabled]:hawa-opacity-50", className ), ...props }, /* @__PURE__ */ React6.createElement("span", { className: "hawa-absolute hawa-left-2 hawa-flex hawa-h-3.5 hawa-w-3.5 hawa-items-center hawa-justify-center" }, /* @__PURE__ */ React6.createElement(DropdownMenuPrimitive.ItemIndicator, null, /* @__PURE__ */ React6.createElement( "svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", "aria-label": "Circle", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "hawa-h-2 hawa-w-2 hawa-fill-current" }, /* @__PURE__ */ React6.createElement("circle", { cx: "12", cy: "12", r: "10" }) ))), children )); DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName; var DropdownMenuLabel = React6.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ React6.createElement( DropdownMenuPrimitive.Label, { ref, className: cn( "hawa-px-2 hawa-py-1.5 hawa-text-sm hawa-font-semibold", inset && "hawa-pl-8", className ), ...props } )); DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName; var DropdownMenuSeparator = React6.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React6.createElement( DropdownMenuPrimitive.Separator, { ref, className: cn("hawa--mx-1 hawa-my-1 hawa-h-px hawa-bg-muted", className), ...props } )); DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName; var DropdownMenuShortcut = ({ className, ...props }) => { return /* @__PURE__ */ React6.createElement( "span", { className: cn( "hawa-text-xs hawa-tracking-widest hawa-opacity-60", className ), ...props } ); }; DropdownMenuShortcut.displayName = "DropdownMenuShortcut"; var DropdownMenu = ({ trigger, items, direction, sideOffset, side, className, classNames, contentProps, triggerClassname, triggerProps, align, alignOffset, onItemSelect, size = "default", width = "default", header, onOpenChange, open, LinkComponent }) => { const widthStyles = { default: "hawa-min-w-[8rem]", sm: "hawa-w-fit", lg: "hawa-w-[200px]", parent: "ddm-w-parent" }; const sizeStyles = { default: "hawa-px-2 hawa-py-3 ", sm: "hawa-text-xs hawa-px-1.5 hawa-py-1.5 " }; let [values, setValues] = React6.useState( items.map((item) => item.currentOption) ); return /* @__PURE__ */ React6.createElement( DropdownMenuRoot, { onOpenChange, open, modal: false, dir: direction }, /* @__PURE__ */ React6.createElement( DropdownMenuTrigger, { asChild: true, className: cn(classNames == null ? void 0 : classNames.trigger, triggerClassname), ...triggerProps }, trigger ), /* @__PURE__ */ React6.createElement(import_react5.Portal, null, /* @__PURE__ */ React6.createElement( DropdownMenuContent, { side, sideOffset, align, alignOffset, className: cn( className, classNames == null ? void 0 : classNames.content, widthStyles[width], "hawa-flex hawa-flex-col hawa-gap-1 hawa-overflow-y-auto" ), style: { maxHeight: "var(--radix-dropdown-menu-content-available-height)" }, ...contentProps }, header && header, items && items.map((item, index) => { var _a; const ItemLinkComponent = item.slug ? LinkComponent : "a"; if (item.itemType === "separator") { return /* @__PURE__ */ React6.createElement( DropdownMenuSeparator, { key: index, className: classNames == null ? void 0 : classNames.separator } ); } else if (item.itemType === "label") { return /* @__PURE__ */ React6.createElement(DropdownMenuLabel, { key: index }, item.label); } else if (item.itemType === "radio") { let dd = item.currentOption; return /* @__PURE__ */ React6.createElement(DropdownMenuSub, { key: index }, /* @__PURE__ */ React6.createElement( DropdownMenuSubTrigger, { dir: direction, className: cn(sizeStyles[size]) }, item.icon && item.icon, item.label && item.label ), /* @__PURE__ */ React6.createElement(DropdownMenuSubContent, null, /* @__PURE__ */ React6.createElement( DropdownMenuRadioGroup, { value: values[index], onValueChange: (e) => { let newValues = [...values]; newValues[index] = e; setValues(newValues); console.log("changing to ", e); if (item.onOptionChange) { item.onOptionChange(e); } } }, (_a = item.options) == null ? void 0 : _a.map((opt, i) => /* @__PURE__ */ React6.createElement(DropdownMenuRadioItem, { key: i, value: opt.value }, opt.label)) ))); } else if (item.itemType === "custom") { return /* @__PURE__ */ React6.createElement("div", { key: index }, item.content); } else { return item.subitems ? /* @__PURE__ */ React6.createElement(DropdownMenuSub, { key: index }, /* @__PURE__ */ React6.createElement( DropdownMenuSubTrigger, { dir: direction, className: cn(sizeStyles[size]) }, item.icon && item.icon, item.label && item.label ), /* @__PURE__ */ React6.createElement(import_react5.Portal, null, /* @__PURE__ */ React6.createElement(DropdownMenuSubContent, null, item.subitems.map((subitem, subIndex) => { const SubitemLinkComponent = subitem.slug ? LinkComponent : "a"; return /* @__PURE__ */ React6.createElement( DropdownMenuItem, { key: subIndex, LinkComponent: SubitemLinkComponent, slug: subitem.slug, disabled: subitem.disabled, className: cn( sizeStyles[size], !item.icon && !item.label ? "hawa-px-0 hawa-py-0 focus:hawa-bg-transparent" : "focus:hawa-bg-accent" ), onMouseDown: (event) => { if (event.button === 1 || event.button === 0 && event.ctrlKey) { event.preventDefault(); if (subitem.onMiddleClick) { subitem.onMiddleClick(item.value); } } }, onSelect: () => { subitem.action && subitem.action(); if (onItemSelect) { onItemSelect(subitem.value); } } }, subitem.icon && subitem.icon, subitem.label && subitem.label ); })))) : /* @__PURE__ */ React6.createElement( DropdownMenuItem, { LinkComponent: ItemLinkComponent, slug: item.slug, key: index, disabled: item.disabled, onMouseDown: (event) => { if (event.button === 1 || event.button === 0 && event.ctrlKey) { event.preventDefault(); if (item.onMiddleClick) { item.onMiddleClick(item.value); } } }, onClick: (event) => { if (item.onClick) { item.onClick(item.value); } }, onSelect: (e) => { if (item.presist) { e.preventDefault(); } if (item.action) { item.action(); if (onItemSelect) { onItemSelect(item.value); } } else { if (onItemSelect) { onItemSelect(item.value); } } }, end: item.end, shortcut: item.shortcut, badged: item.badged, className: cn( sizeStyles[size], !item.icon && !item.label ? "hawa-px-0 hawa-py-0 focus:hawa-bg-transparent" : "focus:hawa-bg-accent", item.presist && "focus:hawa-bg-transparent", classNames == null ? void 0 : classNames.item ) }, item.icon && item.icon, item.label && item.label ); } }) )) ); }; // icons/Emojis.tsx var import_react6 = __toESM(require("react")); // icons/InputIcons.tsx var import_react7 = __toESM(require("react")); // icons/CommonIcons.tsx var import_react8 = __toESM(require("react")); var MenuIcon = () => /* @__PURE__ */ import_react8.default.createElement( "svg", { "aria-label": "Menu Button", stroke: "currentColor", fill: "currentColor", strokeWidth: 0, viewBox: "0 0 20 20", "aria-hidden": "true", height: "1.6em", width: "1.6em" }, /* @__PURE__ */ import_react8.default.createElement( "path", { fillRule: "evenodd", clipRule: "evenodd", d: "M3 5a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 10a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 15a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1z" } ) ); // layout/sidebar/Sidebar.tsx var React11 = __toESM(require("react")); var AccordionPrimitive = __toESM(require("@radix-ui/react-accordion")); // elements/chip/Chip.tsx var import_react9 = __toESM(require("react")); var Chip = import_react9.default.forwardRef( ({ label, size = "normal", icon, color, radius = "inherit", dot, dotStatus = "none", ...rest }, ref) => { let defaultStyles = "hawa-flex hawa-flex-row hawa-w-fit hawa-gap-1 hawa-items-center hawa-px-2.5 hawa-py-1 hawa-font-bold "; let radiusStyles = { inherit: " hawa-rounded", full: "hawa-rounded-full", none: "hawa-rounded-none" }; let sizeStyles = { small: "hawa-h-[15px] hawa-leading-4 hawa-px-0 hawa-py-0 hawa-text-[9px] hawa-gap-0.5 ", normal: "hawa-h-fit hawa-text-xs", large: "hawa-text-base" }; let dotStyles = { small: "hawa-flex hawa-h-1 hawa-w-1 hawa-rounded-full", normal: "hawa-flex hawa-h-2 hawa-w-2 hawa-rounded-full", large: "hawa-flex hawa-h-3 hawa-w-3 hawa-rounded-full" }; let dotStatusStyles = { none: "hawa-bg-gray-500 dark:hawa-bg-gray-800", available: "hawa-bg-green-500", unavailable: "hawa-bg-red-500" }; let colorStyles = { green: "hawa-bg-green-200 hawa-text-green-700 dark:hawa-bg-green-700 dark:hawa-text-green-200", blue: "hawa-bg-blue-200 hawa-text-blue-700 dark:hawa-bg-blue-700 dark:hawa-text-blue-100", red: "hawa-bg-red-200 hawa-text-red-700 dark:hawa-bg-red-700 dark:hawa-text-red-100", yellow: "hawa-bg-yellow-200 hawa-text-yellow-700 dark:hawa-bg-yellow-600 dark:hawa-text-black", orange: "hawa-bg-orange-200 hawa-text-orange-700 dark:hawa-bg-orange-700 dark:hawa-text-orange-100", purple: "hawa-bg-purple-200 hawa-text-purple-700 dark:hawa-bg-purple-700 dark:hawa-text-purple-100", cyan: "hawa-bg-cyan-200 hawa-text-cyan-700 dark:hawa-bg-cyan-700 dark:hawa-text-cyan-100", hyper: "hawa-text-white dark:hawa-text-black hawa-bg-gradient-to-tl hawa-from-pink-500 hawa-via-red-500 hawa-to-yellow-500 ", oceanic: "hawa-text-white dark:hawa-text-black hawa-bg-gradient-to-bl hawa-from-green-300 hawa-via-blue-500 hawa-to-purple-600" }; if (label) { return /* @__PURE__ */ import_react9.default.createElement( "span", { ...rest, ref, className: cn( defaultStyles, sizeStyles[size], radiusStyles[radius], color ? colorStyles[color] : "hawa-border hawa-bg-none", rest.className ) }, dot && /* @__PURE__ */ import_react9.default.createElement( "span", { className: cn(dotStyles[size], dotStatusStyles[dotStatus]) } ), icon && icon, label ); } else { return /* @__PURE__ */ import_react9.default.createElement( "span", { ...rest, ref, className: cn( "hawa-h-2 hawa-w-2 hawa-rounded-full", color ? colorStyles[color] : "hawa-border hawa-bg-none" ) } ); } } ); // layout/sidebar/Sidebar.tsx var Accordion = AccordionPrimitive.Root; var triggerStyles = "hawa-flex hawa-flex-1 hawa-items-center hawa-duration-75 hawa-select-none hawa-cursor-pointer hawa-rounded hawa-justify-between hawa-p-2 hawa-px-3 hawa-font-medium hawa-transition-all [&[data-state=open]>svg]:hawa--rotate-90"; var AccordionItem = React11.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React11.createElement(AccordionPrimitive.Item, { ref, className: cn(className), ...props })); AccordionItem.displayName = "AccordionItem"; var AccordionTrigger = React11.forwardRef(({ className, showArrow, children, ...props }, ref) => /* @__PURE__ */ React11.createElement(AccordionPrimitive.Header, { className: "flex" }, /* @__PURE__ */ React11.createElement( AccordionPrimitive.Trigger, { ref, className: cn(triggerStyles, className), ...props }, children, showArrow && /* @__PURE__ */ React11.createElement( "svg", { "aria-label": "Chevron Right Icon", stroke: "currentColor", fill: "currentColor", viewBox: "0 0 16 16", height: "1em", width: "1em", className: "hawa-icon hawa-shrink-0 hawa-rotate-90 hawa-transition-transform hawa-duration-200" }, /* @__PURE__ */ React11.createElement("path", { d: "M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z" }) ) ))); AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName; var AccordionContent = React11.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ React11.createElement( AccordionPrimitive.Content, { ref, className: cn( "hawa-overflow-hidden hawa-text-sm hawa-transition-all data-[state=closed]:hawa-animate-accordion-up data-[state=open]:hawa-animate-accordion-down", className ), ...props }, /* @__PURE__ */ React11.createElement("div", null, children) )); AccordionContent.displayName = AccordionPrimitive.Content.displayName; var SidebarGroup = ({ title, items, selectedItem, openedItem, setOpenedItem, onItemClick, onSubItemClick, direction, isOpen, ...props }) => { const LinkComponent = props.LinkComponent || "a"; return /* @__PURE__ */ React11.createElement("div", { className: "hawa-m-2" }, title && /* @__PURE__ */ React11.createElement("h3", { className: "hawa-mb-1 hawa-font-bold" }, title), /* @__PURE__ */ React11.createElement("ul", { className: "hawa-flex hawa-flex-col hawa-gap-2" }, /* @__PURE__ */ React11.createElement( Accordion, { value: openedItem, type: "single", onValueChange: (e) => { setOpenedItem(e); }, collapsible: true, className: "hawa-flex hawa-flex-col hawa-gap-1" }, items.map((item, idx) => /* @__PURE__ */ React11.createElement( SidebarItem, { isOpen, selectedItem, key: idx, direction, item, onItemClick, onSubItemClick, LinkComponent } )) ))); }; var SidebarItem = ({ item, onItemClick, onSubItemClick, direction, isOpen = true, LinkComponent, ...props }) => { const getSelectedStyle = (value) => { return props.selectedItem === value ? "hawa-bg-primary/90 hawa-text-primary-foreground hawa-cursor-default" : "hover:hawa-bg-primary/10"; }; if (item.subitems) { return /* @__PURE__ */ React11.createElement( AccordionItem, { value: item.value, className: "hawa-overflow-x-clip", dir: direction }, /* @__PURE__ */ React11.createElement( AccordionTrigger, { className: cn( "hawa-w-full hawa-overflow-x-clip", props.selectedItem === item.value ? "hawa-cursor-default hawa-bg-primary hawa-text-primary-foreground" : "hawa-h-10 hover:hawa-bg-primary/10", item.subitems && item.subitems.some( (subitem) => props.selectedItem === subitem.value ) ? "hawa-bg-primary/80 hawa-text-primary-foreground hover:hawa-bg-primary/80" : "" ), showArrow: isOpen }, /* @__PURE__ */ React11.createElement( "div", { className: cn( "hawa-flex hawa-h-fit hawa-w-fit hawa-flex-row hawa-items-center hawa-gap-2" ) }, item.icon && item.icon, /* @__PURE__ */ React11.createElement( "span", { className: cn( "hawa-transition-all hawa-flex hawa-flex-row hawa-items-center hawa-gap-2 hawa-whitespace-nowrap", isOpen ? "hawa-opacity-100" : "hawa-opacity-0" ) }, item.label, item.badge && /* @__PURE__ */ React11.createElement( Chip, { label: item.badge.label, color: item.badge.color, size: "small" } ) ) ) ), item.subitems && /* @__PURE__ */ React11.createElement(AccordionContent, { className: "hawa-mt-1 hawa-h-full hawa-rounded" }, /* @__PURE__ */ React11.createElement( "div", { className: cn( "hawa-flex hawa-h-full hawa-flex-col hawa-gap-2 hawa-bg-foreground/5 hawa-p-1" ) }, item.subitems.map((subitem, idx) => /* @__PURE__ */ React11.createElement( LinkComponent, { href: subitem.slug, key: idx, onMouseDown: (e) => { if (subitem.onMouseDown) { subitem.onMouseDown(e); } }, onClick: (e) => { e.stopPropagation(); if (subitem.onClick) { subitem.onClick(e); } if (onSubItemClick) { onSubItemClick([item.value, subitem.value]); } }, className: cn( "hawa-flex hawa-h-full hawa-cursor-pointer hawa-flex-row hawa-items-center hawa-gap-2 hawa-overflow-x-clip hawa-whitespace-nowrap hawa-rounded hawa-p-2 hawa-transition-all", // bg-foreground/10 getSelectedStyle(subitem.value) ) }, subitem.icon && subitem.icon, subitem.label, subitem.badge && /* @__PURE__ */ React11.createElement( Chip, { label: subitem.badge.label, color: subitem.badge.color, size: "small" } ) )) )) ); } else { return /* @__PURE__ */ React11.createElement( LinkComponent, { href: item.slug, dir: direction, onMouseDown: (e) => { if (item.onMouseDown) { item.onMouseDown(e); } }, onClick: (e) => { if (item.onClick) { item.onClick(e); } if (onItemClick) { onItemClick([item.value]); } }, className: cn( triggerStyles, getSelectedStyle(item.value), "hawa-overflow-x-clip" ) }, /* @__PURE__ */ React11.createElement("div", { className: "hawa-flex hawa-flex-row hawa-items-center hawa-gap-2" }, item.icon && item.icon, /* @__PURE__ */ React11.createElement( "span", { className: cn( "hawa-flex hawa-flex-row hawa-items-center hawa-gap-2 hawa-whitespace-nowrap hawa-transition-all", isOpen ? "hawa-opacity-100" : "hawa-opacity-0" ) }, item.label, " ", item.badge && /* @__PURE__ */ React11.createElement( Chip, { label: item.badge.label, color: item.badge.color, size: "small" } ) )) ); } }; // layout/appLayout/AppLayout.tsx var LOCAL_STORAGE_KEY = "@sikka/hawa/keep-drawer-open"; var AppLayout = ({ profileMenuWidth = "default", DrawerFooterActions, classNames, bordered = true, design = "default", direction = "ltr", drawerSize = "md", currentPage, clickedItem, DrawerLinkComponent, MenuLinkComponent, onDrawerExpanded, onAvatarClick, ...props }) => { var _a, _b; (0, import_react10.useEffect)(() => { let isDrawerOpen = localStorage.getItem(LOCAL_STORAGE_KEY); if (isDrawerOpen === null) { localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(false)); } }, []); let closeDrawerWidth = 56; let openDrawerWidth = 200; let drawerSizeStyle = { opened: { sm: "100", md: openDrawerWidth, lg: "250" }, closed: { sm: closeDrawerWidth, md: closeDrawerWidth, lg: closeDrawerWidth } }; const isRTL = direction === "rtl"; const [openedSidebarItem, setOpenedSidebarItem] = (0, import_react10.useState)(""); const [size, setSize] = (0, import_react10.useState)( typeof window !== "undefined" && window.innerWidth || 1200 ); const [openSideMenu, setOpenSideMenu] = (0, import_react10.useState)(() => { const savedState = localStorage.getItem(LOCAL_STORAGE_KEY); return savedState ? JSON.parse(savedState) : false; }); const [container, setContainer] = import_react10.default.useState(null); const [keepDrawerOpen, setKeepDrawerOpen] = (0, import_react10.useState)(() => { const savedState = localStorage.getItem(LOCAL_STORAGE_KEY); return savedState ? JSON.parse(savedState) : false; }); const handleClickOutside = () => { if (typeof window !== "undefined") { if (window.innerWidth < 600) { setKeepDrawerOpen(false); setOpenSideMenu(false); onDrawerExpanded && onDrawerExpanded(false); } } }; const ref = useClickOutside(handleClickOutside); (0, import_react10.useEffect)(() => { if (typeof window !== "undefined") { const resize = () => { setSize(window.innerWidth); if (window.innerWidth > 600) { setKeepDrawerOpen(false); } else { localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(false)); } onDrawerExpanded && onDrawerExpanded(keepDrawerOpen); }; resize(); window.addEventListener("resize", resize); return () => { window.removeEventListener("resize", resize); }; } }, []); (0, import_react10.useEffect)(() => { setKeepDrawerOpen(() => { const savedState = localStorage.getItem(LOCAL_STORAGE_KEY); return savedState ? JSON.parse(savedState) : true; }); }, [setKeepDrawerOpen]); (0, import_react10.useEffect)(() => { if (size > 600) { setOpenSideMenu(keepDrawerOpen); onDrawerExpanded && onDrawerExpanded(keepDrawerOpen); } else { setKeepDrawerOpen(false); setOpenSideMenu(false); onDrawerExpanded && onDrawerExpanded(false); } }, [size, keepDrawerOpen]); const drawerSizeCondition = size > 600 ? drawerSizeStyle[keepDrawerOpen ? "opened" : "closed"][drawerSize] : 0; return /* @__PURE__ */ import_react10.default.createElement("div", { className: "hawa-fixed hawa-start-0" }, props.topBar && /* @__PURE__ */ import_react10.default.createElement( "div", { dir: direction, className: cn( "hawa-fixed hawa-end-0 hawa-start-0 hawa-top-0 hawa-z-10 hawa-flex hawa-h-14 hawa-w-full hawa-items-center hawa-justify-between hawa-bg-primary-foreground hawa-p-2", bordered && "hawa-border-b-[1px]" ) }, size > 600 ? /* @__PURE__ */ import_react10.default.createElement( "div", { className: cn( "dark:hawa-text-white", size > 600 ? "hawa-ms-14" : "hawa-ms-2" ),