UNPKG

@sikka/hawa

Version:

Modern UI Kit made with Tailwind

801 lines (789 loc) • 29.1 kB
"use client"; // elements/combobox/Combobox.tsx import * as React8 from "react"; import * as PopoverPrimitive2 from "@radix-ui/react-popover"; // util/index.ts import { clsx } from "clsx"; import { twMerge } from "tailwind-merge"; function cn(...inputs) { return twMerge(clsx(inputs)); } // elements/command/Command.tsx import * as React2 from "react"; import { Dialog } from "@radix-ui/react-dialog"; import { Command as CommandPrimitive } from "cmdk"; // elements/dialog/Dialog.tsx import * as React from "react"; import * as DialogPrimitive from "@radix-ui/react-dialog"; var DialogPortal = ({ ...props }) => /* @__PURE__ */ React.createElement(DialogPrimitive.Portal, { ...props }); var DialogOverlay = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement( DialogPrimitive.Overlay, { ref, className: cn( "hawa-fixed hawa-inset-0 hawa-z-50 hawa-bg-background/80 hawa-backdrop-blur-sm 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", className ), ...props } )); var DialogContent = React.forwardRef( ({ ids, className, classNames, children, persist, hideCloseButton, overlayProps, ...props }, ref) => /* @__PURE__ */ React.createElement(DialogPortal, { container: props.container }, /* @__PURE__ */ React.createElement( DialogOverlay, { className: classNames == null ? void 0 : classNames.overlay, id: ids == null ? void 0 : ids.overlay, ...overlayProps } ), /* @__PURE__ */ React.createElement( DialogPrimitive.Content, { onPointerDownOutside: (e) => { if (persist) { e.preventDefault(); } }, ref, className: cn( "hawa-fixed hawa-left-[50%] hawa-top-[50%] hawa-z-50 hawa-grid hawa-w-[90%] hawa-max-w-lg hawa-translate-x-[-50%] hawa-translate-y-[-50%] hawa-gap-4 hawa-border hawa-bg-background hawa-p-6 hawa-shadow-lg hawa-transition-all hawa-duration-200 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-[state=closed]:hawa-slide-out-to-left-1/2 data-[state=closed]:hawa-slide-out-to-top-[48%] data-[state=open]:hawa-slide-in-from-left-1/2 data-[state=open]:hawa-slide-in-from-top-[48%] hawa-rounded md:hawa-w-full", className ), ...props }, children, !hideCloseButton && /* @__PURE__ */ React.createElement( DialogPrimitive.Close, { className: cn( "hawa-absolute hawa-top-4 hawa-rounded hawa-opacity-70 hawa-ring-offset-background hawa-transition-opacity hover:hawa-opacity-100 focus:hawa-outline-none focus:hawa-ring-2 focus:hawa-ring-ring focus:hawa-ring-offset-2 disabled:hawa-pointer-events-none data-[state=open]:hawa-bg-accent data-[state=open]:hawa-text-muted-foreground", props.dir === "rtl" ? "hawa-left-4" : "hawa-right-4", classNames == null ? void 0 : classNames.closeButton ), id: ids == null ? void 0 : ids.closeButton }, /* @__PURE__ */ React.createElement( "svg", { id: ids == null ? void 0 : ids.closeIcon, "aria-label": "Close Icon", "aria-hidden": "true", className: "hawa-h-5 hawa-w-5", fill: "currentColor", viewBox: "0 0 20 20" }, /* @__PURE__ */ React.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__ */ React.createElement("span", { className: "hawa-sr-only" }, "Close") ) )) ); var DialogCarouselContent = React.forwardRef( ({ className, children, onPrev, persist, hideCloseButton, hidePrevButton, ...props }, ref) => /* @__PURE__ */ React.createElement(DialogPortal, null, /* @__PURE__ */ React.createElement(DialogOverlay, null), /* @__PURE__ */ React.createElement( DialogPrimitive.Content, { onPointerDownOutside: (e) => { if (persist) { e.preventDefault(); } }, ref, className: cn( "hawa-fixed hawa-left-[50%] hawa-top-[50%] hawa-z-50 hawa-grid hawa-w-full hawa-max-w-lg hawa-translate-x-[-50%] hawa-translate-y-[-50%] hawa-gap-4 hawa-border hawa-bg-background hawa-p-6 hawa-pt-14 hawa-shadow-lg hawa-transition-all hawa-duration-200 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-[state=closed]:hawa-slide-out-to-left-1/2 data-[state=closed]:hawa-slide-out-to-top-[48%] data-[state=open]:hawa-slide-in-from-left-1/2 data-[state=open]:hawa-slide-in-from-top-[48%] sm:hawa-rounded md:hawa-w-full", className ), ...props }, children, /* @__PURE__ */ React.createElement( "div", { className: cn( "hawa-absolute hawa-top-0 hawa-flex hawa-w-full hawa-flex-row hawa-p-4", onPrev ? "hawa-justify-between" : "hawa-justify-end" ) }, hidePrevButton ? /* @__PURE__ */ React.createElement("div", null) : /* @__PURE__ */ React.createElement( "div", { onClick: onPrev, className: cn( "hawa-end-0 hawa-cursor-pointer hawa-rounded hawa-opacity-70 hawa-ring-offset-background hawa-transition-opacity hover:hawa-opacity-100 focus:hawa-outline-none focus:hawa-ring-2 focus:hawa-ring-ring focus:hawa-ring-offset-2 disabled:hawa-pointer-events-none data-[state=open]:hawa-bg-accent data-[state=open]:hawa-text-muted-foreground", props.dir === "rtl" && "hawa-rotate-180" ) }, /* @__PURE__ */ React.createElement( "svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", className: "hawa-h-6 hawa-w-6", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, /* @__PURE__ */ React.createElement("path", { d: "m15 18-6-6 6-6" }) ) ), !hideCloseButton && /* @__PURE__ */ React.createElement( DialogPrimitive.Close, { className: cn( "hawa-end-0 hawa-rounded hawa-opacity-70 hawa-ring-offset-background hawa-transition-opacity hover:hawa-opacity-100 focus:hawa-outline-none focus:hawa-ring-2 focus:hawa-ring-ring focus:hawa-ring-offset-2 disabled:hawa-pointer-events-none data-[state=open]:hawa-bg-accent data-[state=open]:hawa-text-muted-foreground", props.dir === "rtl" ? "hawa-left-4" : "hawa-right-4" ) }, /* @__PURE__ */ React.createElement( "svg", { "aria-label": "Close Icon", "aria-hidden": "true", className: "hawa-h-6 hawa-w-6", fill: "currentColor", viewBox: "0 0 20 20" }, /* @__PURE__ */ React.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__ */ React.createElement("span", { className: "hawa-sr-only" }, "Close") ) ) )) ); var DialogHeader = ({ className, ...props }) => /* @__PURE__ */ React.createElement( "div", { className: cn( "hawa-flex hawa-flex-col hawa-space-y-1.5 hawa-text-center sm:hawa-text-left", className ), ...props } ); var DialogTitle = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement( DialogPrimitive.Title, { ref, className: cn( "hawa-text-start hawa-text-lg hawa-font-semibold hawa-leading-none hawa-tracking-tight", className ), ...props } )); var DialogDescription = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement( DialogPrimitive.Description, { ref, className: cn( "hawa-text-start hawa-text-sm hawa-text-muted-foreground", className ), ...props } )); var DialogFooter = ({ className, ...props }) => /* @__PURE__ */ React.createElement( "div", { className: cn( "hawa-flex hawa-flex-col xs:hawa-flex-row sm:hawa-justify-end hawa-gap-2", className ), ...props } ); var DialogCarousel = ({ stepsApi, stepsRef, children, direction }) => { React.useEffect(() => { if (stepsApi) { stepsApi.reInit(); } }, [stepsApi, children]); return /* @__PURE__ */ React.createElement("div", { className: "hawa-overflow-hidden" }, /* @__PURE__ */ React.createElement("div", { ref: stepsRef, dir: direction }, /* @__PURE__ */ React.createElement( "div", { className: "hawa-flex", style: { transition: "height 0.2s" } }, React.Children.map(children, (child, index) => /* @__PURE__ */ React.createElement( "div", { className: cn( "hawa-flex hawa-h-fit hawa-flex-[0_0_100%] hawa-items-center hawa-justify-center" ), key: index }, child )) ))); }; var DialogSteps = ({ currentStep, visibleStepRef, children }) => { const [dialogHeight, setDialogHeight] = React.useState(null); React.useEffect(() => { if (visibleStepRef.current) { setDialogHeight(visibleStepRef.current.offsetHeight); console.log("height is ", visibleStepRef.current.offsetHeight); } }, [currentStep, visibleStepRef]); return /* @__PURE__ */ React.createElement( "div", { className: "hawa-relative hawa-overflow-clip", style: { height: dialogHeight || "fit-content", transition: "height 0.2s" } }, React.Children.map(children, (child, index) => /* @__PURE__ */ React.createElement( "div", { ref: currentStep === `step-${index + 1}` ? visibleStepRef : null, className: cn( currentStep === `step-${index + 1}` ? "hawa-visible hawa-block" : "hawa-invisible hawa-hidden" ) }, child )) ); }; var DialogStep = ({ id, children, className, stepRef }) => { return /* @__PURE__ */ React.createElement( "div", { id, ref: stepRef, className: cn("hawa-w-full hawa-px-1", className) }, children ); }; var DialogBody = ({ children, className }) => { return /* @__PURE__ */ React.createElement("div", { className: cn("hawa-py-6", className) }, children); }; DialogBody.displayName = "DialogBody"; DialogStep.displayName = "DialogStep"; DialogSteps.displayName = "DialogSteps"; DialogCarousel.displayName = "DialogCarousel"; DialogCarouselContent.displayName = "DialogCarouselContent"; DialogHeader.displayName = "DialogHeader"; DialogFooter.displayName = "DialogFooter"; DialogTitle.displayName = DialogPrimitive.Title.displayName; DialogPortal.displayName = DialogPrimitive.Portal.displayName; DialogOverlay.displayName = DialogPrimitive.Overlay.displayName; DialogContent.displayName = DialogPrimitive.Content.displayName; DialogDescription.displayName = DialogPrimitive.Description.displayName; // elements/command/Command.tsx var Command = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React2.createElement( CommandPrimitive, { ref, className: cn( "hawa-flex hawa-h-full hawa-w-full hawa-flex-col hawa-overflow-hidden hawa-rounded-md hawa-bg-popover hawa-text-popover-foreground", className ), ...props } )); var CommandInput = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React2.createElement( "div", { className: "hawa-flex hawa-items-center hawa-border-b hawa-px-3", "cmdk-input-wrapper": "" }, /* @__PURE__ */ React2.createElement( "svg", { "aria-label": "Search Icon", xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "hawa-icon hawa-me-2 hawa-shrink-0 hawa-opacity-50" }, /* @__PURE__ */ React2.createElement("circle", { cx: "11", cy: "11", r: "8" }), /* @__PURE__ */ React2.createElement("path", { d: "m21 21-4.3-4.3" }) ), /* @__PURE__ */ React2.createElement( CommandPrimitive.Input, { ref, className: cn( "hawa-flex hawa-h-11 hawa-w-full hawa-rounded-md hawa-bg-transparent hawa-py-3 hawa-text-sm hawa-outline-none placeholder:hawa-text-muted-foreground disabled:hawa-cursor-not-allowed disabled:hawa-opacity-50", className ), ...props } ) )); var CommandList = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React2.createElement( CommandPrimitive.List, { ref, className: cn( "hawa-max-h-[300px] hawa-overflow-y-auto hawa-overflow-x-hidden", className ), ...props } )); var CommandEmpty = React2.forwardRef((props, ref) => /* @__PURE__ */ React2.createElement( CommandPrimitive.Empty, { ref, className: "hawa-py-6 hawa-text-center hawa-text-sm", ...props } )); var CommandGroup = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React2.createElement( CommandPrimitive.Group, { ref, className: cn( "hawa-overflow-hidden hawa-p-1 hawa-text-foreground [&_[cmdk-group-heading]]:hawa-px-2 [&_[cmdk-group-heading]]:hawa-py-1.5 [&_[cmdk-group-heading]]:hawa-text-xs [&_[cmdk-group-heading]]:hawa-font-medium [&_[cmdk-group-heading]]:hawa-text-muted-foreground", className ), ...props } )); var CommandSeparator = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React2.createElement( CommandPrimitive.Separator, { ref, className: cn("hawa--mx-1 hawa-h-px hawa-bg-border", className), ...props } )); var CommandItem = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React2.createElement( CommandPrimitive.Item, { ref, className: cn( "hawa-relative hawa-flex hawa-cursor-default hawa-select-none hawa-items-center hawa-rounded-sm hawa-px-2 hawa-py-1.5 hawa-text-sm hawa-outline-none aria-selected:hawa-bg-accent aria-selected:hawa-text-accent-foreground data-[disabled='true']:hawa-pointer-events-none data-[disabled='true']:hawa-opacity-50", className ), ...props } )); var CommandShortcut = ({ className, ...props }) => { return /* @__PURE__ */ React2.createElement( "span", { className: cn( "hawa-ms-auto hawa-text-xs hawa-tracking-widest hawa-text-muted-foreground", className ), ...props } ); }; CommandShortcut.displayName = "CommandShortcut"; CommandItem.displayName = CommandPrimitive.Item.displayName; CommandSeparator.displayName = CommandPrimitive.Separator.displayName; CommandGroup.displayName = CommandPrimitive.Group.displayName; CommandEmpty.displayName = CommandPrimitive.Empty.displayName; CommandList.displayName = CommandPrimitive.List.displayName; Command.displayName = CommandPrimitive.displayName; CommandInput.displayName = CommandPrimitive.Input.displayName; // elements/helperText/HelperText.tsx import React3 from "react"; var HelperText = ({ helperText }) => /* @__PURE__ */ React3.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 import * as React5 from "react"; // elements/tooltip/Tooltip.tsx import React4 from "react"; import * as TooltipPrimitive from "@radix-ui/react-tooltip"; var TooltipContent = React4.forwardRef(({ className, sideOffset = 4, size = "default", ...props }, ref) => /* @__PURE__ */ React4.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 = React4.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React4.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__ */ React4.createElement( TooltipPrimitive.TooltipProvider, { delayDuration, ...providerProps }, /* @__PURE__ */ React4.createElement( TooltipPrimitive.Root, { open: !disabled && open, defaultOpen, onOpenChange, ...props }, /* @__PURE__ */ React4.createElement(TooltipPrimitive.Trigger, { ...triggerProps }, children), /* @__PURE__ */ React4.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 = React5.forwardRef(({ className, hint, hintSide, required, children, ...props }, ref) => /* @__PURE__ */ React5.createElement("div", { className: "hawa-flex hawa-flex-row hawa-items-center hawa-gap-1 hawa-transition-all" }, /* @__PURE__ */ React5.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__ */ React5.createElement("span", { className: "hawa-mx-0.5 hawa-text-red-500" }, "*") ), hint && /* @__PURE__ */ React5.createElement( Tooltip, { content: hint, side: hintSide, triggerProps: { tabIndex: -1, onClick: (event) => event.preventDefault() } }, /* @__PURE__ */ React5.createElement("div", null, /* @__PURE__ */ React5.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__ */ React5.createElement("circle", { cx: "12", cy: "12", r: "10" }), /* @__PURE__ */ React5.createElement("path", { d: "M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3" }), /* @__PURE__ */ React5.createElement("path", { d: "M12 17h.01" }) )) ))); Label.displayName = "Label"; // elements/popover/Popover.tsx import * as React6 from "react"; import * as PopoverPrimitive from "@radix-ui/react-popover"; var PopoverContent = React6.forwardRef( ({ className, align = "center", sideOffset = 4, container, ...props }, ref) => /* @__PURE__ */ React6.createElement(PopoverPrimitive.Portal, { container }, /* @__PURE__ */ React6.createElement( PopoverPrimitive.Content, { ref, align, sideOffset, className: cn( "dark:dark-shadow hawa-z-50 hawa-rounded hawa-border hawa-bg-popover hawa-text-popover-foreground hawa-shadow-md hawa-outline-none 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 } )) ); PopoverContent.displayName = PopoverPrimitive.Content.displayName; var PopoverTrigger = PopoverPrimitive.Trigger; // elements/skeleton/Skeleton.tsx import React7 from "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__ */ React7.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 ); } // elements/combobox/Combobox.tsx var Combobox = React8.forwardRef( ({ labelKey = "label", valueKey = "value", defaultValue = "", popoverClassName, direction, labelProps, inputProps, data, renderOption, renderSelected, ...props }, ref) => { var _a, _b, _c; const [open, setOpen] = React8.useState(false); const [value, setValue] = React8.useState(defaultValue); const containerRef = React8.useRef(null); function getProperty(obj, key) { return key.split(".").reduce((o, k) => (o || {})[k], obj); } const handleOpenChange = (open2) => { if (!(props.isLoading || props.preview)) { setOpen(open2); } }; const selectedItem = data.find( (item) => getProperty(item, valueKey) === value ); return /* @__PURE__ */ React8.createElement( "div", { className: cn( "hawa-relative hawa-flex hawa-h-fit hawa-flex-col hawa-gap-2", props.width === "fit" ? "hawa-w-fit" : "hawa-w-full" ), ref: containerRef }, props.label && /* @__PURE__ */ React8.createElement(Label, { ...labelProps }, props.label), /* @__PURE__ */ React8.createElement(PopoverPrimitive2.Root, { open, onOpenChange: handleOpenChange }, /* @__PURE__ */ React8.createElement(PopoverTrigger, { asChild: true }, props.isLoading ? /* @__PURE__ */ React8.createElement("div", { className: "hawa-pb-2" }, /* @__PURE__ */ React8.createElement(Skeleton, { className: "hawa-h-[40px] hawa-w-full" })) : /* @__PURE__ */ React8.createElement("div", { className: "hawa-flex hawa-flex-col hawa-items-start hawa-gap-2" }, /* @__PURE__ */ React8.createElement( "div", { className: cn( "hawa-absolute hawa-top-[22px] hawa-h-[0.8px] hawa-w-full hawa-bg-gray-200 hawa-transition-all dark:hawa-bg-gray-800", props.preview ? "hawa-opacity-100" : "hawa-opacity-0" ) } ), /* @__PURE__ */ React8.createElement( "button", { role: "combobox", type: "button", "aria-expanded": open, className: cn( "hawa-inline-flex hawa-h-10 hawa-w-full hawa-select-none hawa-items-center hawa-justify-between hawa-rounded-md hawa-border hawa-py-2 hawa-text-sm hawa-font-normal hawa-ring-offset-background hawa-transition-all 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", props.preview ? "hawa-cursor-default hawa-rounded-none hawa-border-transparent hawa-px-0" : "hawa-bg-background hawa-px-3" ) }, selectedItem ? renderSelected ? renderSelected(selectedItem) : getProperty(selectedItem, labelKey) : ((_a = props.texts) == null ? void 0 : _a.placeholder) || ". . .", /* @__PURE__ */ React8.createElement( "svg", { xmlns: "http://www.w3.org/2000/svg", className: cn( "hawa-icon hawa-transition-all", !props.preview ? "hawa-visible hawa-opacity-100" : "hawa-invisible hawa-opacity-0" ), "aria-label": "Chevron down icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, /* @__PURE__ */ React8.createElement("path", { d: "m6 9 6 6 6-6" }) ) ), /* @__PURE__ */ React8.createElement(HelperText, { helperText: props.helperText }))), /* @__PURE__ */ React8.createElement( PopoverContent, { sideOffset: 0, className: cn("popover-w-parent", props.helperText && "-hawa-mt-4"), dir: direction, container: containerRef.current }, /* @__PURE__ */ React8.createElement( Command, { filter: (value2, search) => { if (value2.toLowerCase().includes(search.toLowerCase())) return 1; return 0; } }, !props.hideInput && /* @__PURE__ */ React8.createElement( CommandInput, { ...inputProps, dir: direction, placeholder: ((_b = props.texts) == null ? void 0 : _b.searchPlaceholder) || "Search" } ), /* @__PURE__ */ React8.createElement(CommandEmpty, null, ((_c = props.texts) == null ? void 0 : _c.noItems) || "No items found."), /* @__PURE__ */ React8.createElement(CommandList, null, /* @__PURE__ */ React8.createElement( CommandGroup, { className: cn( "hawa-max-h-[200px]", data.length > 0 && "hawa-overflow-y-auto" ) }, data.map((item, i) => /* @__PURE__ */ React8.createElement( CommandItem, { key: i, onSelect: () => { const newValue = getProperty(item, valueKey); setValue( newValue === value ? "" : newValue ); if (props.onChange) { props.onChange( newValue === value ? "" : newValue ); } setOpen(false); } }, /* @__PURE__ */ React8.createElement( "svg", { "aria-label": "Check Icon", xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: cn( "hawa-icon", value === getProperty(item, valueKey) ? "hawa-opacity-100" : "hawa-opacity-0" ), style: { marginInlineEnd: "0.5rem" } }, /* @__PURE__ */ React8.createElement("polyline", { points: "20 6 9 17 4 12" }) ), renderOption ? renderOption(item) : getProperty(item, labelKey) )) )) ) )) ); } ); export { Combobox }; //# sourceMappingURL=index.mjs.map