{"version":3,"sources":["../src/components/dialog.tsx"],"sourcesContent":["import * as DialogPrimitive from \"@radix-ui/react-dialog\";\nimport {\n  ForwardRefExoticComponent,\n  ComponentProps,\n  forwardRef,\n  ReactElement,\n  JSXElementConstructor,\n  ReactNode,\n  createContext,\n  useContext,\n  LegacyRef,\n} from \"react\";\nimport { CrossIcon } from \"../icons/cross\";\nimport { clx } from \"../utils\";\nimport { Button } from \"./button\";\nimport { cva } from \"class-variance-authority\";\nimport { Slot } from \"@radix-ui/react-slot\";\n\nconst Dialog = DialogPrimitive.Root;\n\n/*========================================================================================================================*/\n\nconst DialogTrigger: ForwardRefExoticComponent<\n  ComponentProps<typeof DialogPrimitive.Trigger>\n> = forwardRef((props, ref) => {\n  return <DialogPrimitive.Trigger ref={ref} {...props} asChild />;\n});\n\n/*========================================================================================================================*/\n\nconst DialogClose: ForwardRefExoticComponent<\n  ComponentProps<typeof DialogPrimitive.Close>\n> = forwardRef((props, ref) => {\n  const { onDismiss } = useContext(DialogBodyContext);\n\n  return (\n    <DialogPrimitive.Close\n      ref={ref}\n      {...props}\n      asChild\n      onClick={onDismiss && onDismiss}\n    />\n  );\n});\n\n/*========================================================================================================================*/\n\ninterface DialogBodyContextProps {\n  dismissible?: boolean;\n  onDismiss?: () => void;\n}\ninterface DialogBodyProps\n  extends ComponentProps<typeof DialogPrimitive.Content>,\n    DialogBodyContextProps {\n  hideClose?: boolean;\n}\n\nconst DialogBodyContext = createContext<DialogBodyContextProps>({\n  dismissible: true,\n  onDismiss: () => {},\n});\n\nconst DialogBody: ForwardRefExoticComponent<DialogBodyProps> = forwardRef(\n  (\n    {\n      className,\n      children,\n      hideClose = false,\n      dismissible = true,\n      onDismiss,\n      ...props\n    },\n    ref,\n  ) => {\n    return (\n      <DialogPrimitive.Portal>\n        <DialogPrimitive.Overlay\n          className={clx(\n            \"fixed inset-0 z-[900]\",\n            \"h-full w-full\",\n            \"bg-gray-700/60\",\n            \"data-[state=open]:animate-in data-[state=open]:fade-in-0\",\n            \"data-[state=closed]:animate-out data-[state=closed]:fade-out-0\",\n          )}\n        />\n        <DialogPrimitive.Content\n          ref={ref}\n          className={clx(\n            \"fixed left-[50%] top-[50%] z-[1000] box-border translate-x-[-50%] translate-y-[-50%]\",\n            \"w-full min-w-[300px] max-w-[calc(100dvw-36px)] sm:max-w-lg\",\n            \"flex flex-col items-start\",\n            \"rounded-lg shadow-lg\",\n            \"border-otl-gray-200 border\",\n            \"bg-bg-white\",\n            \"data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]\",\n            \"data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%]\",\n            \"duration-200\",\n            className,\n          )}\n          onInteractOutside={\n            !dismissible\n              ? (e) => e.preventDefault()\n              : () => onDismiss && onDismiss()\n          }\n          {...props}\n        >\n          <DialogBodyContext.Provider value={{ dismissible, onDismiss }}>\n            {children}\n            {!hideClose && (\n              <DialogClose\n                className={clx(\n                  \"absolute right-4 top-4\",\n                  \"grid place-content-center\",\n                  \"text-txt-black-900\",\n                  \"disabled:pointer-events-none\",\n                )}\n              >\n                <Button variant=\"default-outline\" size={\"small\"} iconOnly>\n                  <CrossIcon className=\"size-5 stroke-current\" />\n                  <span className=\"sr-only\">Close</span>\n                </Button>\n              </DialogClose>\n            )}\n          </DialogBodyContext.Provider>\n        </DialogPrimitive.Content>\n      </DialogPrimitive.Portal>\n    );\n  },\n);\n\n/*========================================================================================================================*/\n\ninterface DialogHeaderProps extends ComponentProps<\"div\"> {\n  border?: boolean;\n}\n\nconst dialog_header_cva = cva(\"flex w-full flex-col text-left px-6 pt-6\", {\n  variants: {\n    border: {\n      true: \"border-otl-gray-200 border-b pb-4.5 mb-6\",\n      false: \"pb-2\",\n    },\n  },\n  defaultVariants: {\n    border: false,\n  },\n});\n\nconst DialogHeader: ForwardRefExoticComponent<DialogHeaderProps> = forwardRef(\n  ({ className, border, ...props }, ref) => {\n    return (\n      <div\n        ref={ref}\n        className={clx(dialog_header_cva({ border }), className)}\n        {...props}\n      />\n    );\n  },\n);\n/*========================================================================================================================*/\n\ninterface DialogContentProps extends ComponentProps<\"div\"> {}\n\nconst DialogContent: ForwardRefExoticComponent<DialogContentProps> = forwardRef(\n  ({ className, ...props }, ref) => {\n    return (\n      <div ref={ref} className={clx(\"w-full px-6\", className)} {...props} />\n    );\n  },\n);\n\n/*========================================================================================================================*/\n\ninterface DialogFooterProps extends ComponentProps<\"div\"> {\n  border?: boolean;\n  align?: \"start\" | \"full\" | \"end\";\n  action?: ReactNode;\n}\n\nconst dialog_footer_cva = cva(\n  [\n    \"flex w-full justify-between items-end p-6 gap-3\",\n    \"[&>*]:w-full sm:[&>*]:w-auto\",\n    \"[&>button]:place-content-center\",\n  ],\n  {\n    variants: {\n      align: {\n        start: \"sm:flex-row-reverse flex-col-reverse\",\n        full: \"sm:flex-row flex-col\",\n        end: \"sm:flex-row flex-col\",\n      },\n      border: {\n        true: \"border-otl-gray-200 border-t\",\n        false: \"\",\n      },\n    },\n    defaultVariants: {\n      align: \"end\",\n      border: false,\n    },\n  },\n);\nconst dialog_action_cva = cva(\n  [\n    \"flex gap-3 grow\",\n    \"[&>*]:w-full sm:[&>*]:w-auto\",\n    \"[&>*]:place-content-center\",\n  ],\n  {\n    variants: {\n      align: {\n        start: \"justify-end sm:flex-row-reverse flex-col-reverse\",\n        full: \"justify-center grow [&>*]:flex-1 [&>*]:place-content-center sm:flex-row flex-col\",\n        end: \"justify-end sm:flex-row flex-col\",\n      },\n    },\n    defaultVariants: {\n      align: \"end\",\n    },\n  },\n);\n\nconst DialogFooter: ForwardRefExoticComponent<DialogFooterProps> = forwardRef(\n  ({ action, border, className, align = \"end\", ...props }, ref) => {\n    return (\n      <div className={clx(dialog_footer_cva({ border, align }), className)}>\n        {action}\n        <div\n          ref={ref}\n          className={clx(dialog_action_cva({ align }), className)}\n          {...props}\n        />\n      </div>\n    );\n  },\n);\n\n/*========================================================================================================================*/\n\ninterface DialogTitleProps\n  extends ComponentProps<typeof DialogPrimitive.Title> {}\n\nconst DialogTitle: ForwardRefExoticComponent<DialogTitleProps> = forwardRef(\n  ({ className, ...props }, ref) => (\n    <DialogPrimitive.Title\n      ref={ref}\n      className={clx(\n        \"text-body-lg text-txt-black-900 font-body font-semibold\",\n        className,\n      )}\n      {...props}\n    />\n  ),\n);\n\n/*========================================================================================================================*/\ninterface DialogDescriptionProps\n  extends ComponentProps<typeof DialogPrimitive.Description> {}\n\nconst DialogDescription: ForwardRefExoticComponent<DialogDescriptionProps> =\n  forwardRef(({ className, ...props }, ref) => (\n    <DialogPrimitive.Description\n      ref={ref}\n      className={clx(\"text-txt-black-700 text-body-sm font-normal\", className)}\n      {...props}\n    />\n  ));\n\n/*========================================================================================================================*/\n\n/**\n * `DialogIcon` forwards a ref to its child and applies a class based on the button size.\n *\n * @component\n * @param {DialogIconProps} props - The properties for the DialogIcon component.\n * @param {ReactNode} props.children - The child element to which the ref will be forwarded.\n * @param {Ref} ref - The ref to be forwarded to the child element.\n * @returns {ReactElement} The cloned child element with the forwarded ref and applied class name.\n */\n\nconst dialog_icon_cva = cva(\"block stroke-[1.5px] size-10.5 shrink-0\", {\n  variants: {\n    variant: {\n      default: \"\",\n      primary: \"text-txt-primary stroke-txt-primary\",\n      success: \"text-txt-success stroke-txt-success\",\n      warning: \"text-txt-warning stroke-txt-warning\",\n      danger: \"text-txt-danger stroke-txt-danger\",\n    },\n  },\n  defaultVariants: {\n    variant: \"primary\",\n  },\n});\n\ninterface DialogIconProps {\n  variant: \"default\" | \"primary\" | \"success\" | \"warning\" | \"danger\";\n  children: ReactElement<any, string | JSXElementConstructor<any>>;\n  className?: string;\n  ref?: LegacyRef<HTMLElement>;\n}\n\nconst DialogIcon: ForwardRefExoticComponent<DialogIconProps> = forwardRef(\n  ({ variant, children, className }, ref) => {\n    return (\n      <Slot ref={ref} className={clx(dialog_icon_cva({ variant }), className)}>\n        {children}\n      </Slot>\n    );\n  },\n);\n\n/*========================================================================================================================*/\n\nDialogBody.displayName = \"DialogBody\";\nDialogHeader.displayName = \"DialogHeader\";\nDialogFooter.displayName = \"DialogFooter\";\nDialogTitle.displayName = DialogPrimitive.Title.displayName;\nDialogDescription.displayName = DialogPrimitive.Description.displayName;\nDialogIcon.displayName = \"DialogIcon\";\nDialogClose.displayName = DialogPrimitive.Close.displayName;\nDialogContent.displayName = DialogPrimitive.Content.displayName;\nDialogTrigger.displayName = DialogPrimitive.Trigger.displayName;\n\n/*========================================================================================================================*/\n\nexport {\n  Dialog,\n  DialogIcon,\n  DialogClose,\n  DialogBody,\n  DialogContent,\n  DialogDescription,\n  DialogFooter,\n  DialogHeader,\n  DialogTitle,\n  DialogTrigger,\n};\n"],"mappings":"6KAAA,UAAYA,MAAqB,yBACjC,OAGE,cAAAC,EAIA,iBAAAC,EACA,cAAAC,MAEK,QAIP,OAAS,OAAAC,MAAW,2BACpB,OAAS,QAAAC,MAAY,uBASZ,cAAAC,EA4FO,QAAAC,MA5FP,oBAPT,IAAMC,EAAyB,OAIzBC,EAEFC,EAAW,CAACC,EAAOC,IACdN,EAAiB,UAAhBO,EAAAC,EAAA,CAAwB,IAAKF,GAASD,GAAtC,CAA6C,QAAO,IAAC,CAC9D,EAIKI,EAEFL,EAAW,CAACC,EAAOC,IAAQ,CAC7B,GAAM,CAAE,UAAAI,CAAU,EAAIC,EAAWC,CAAiB,EAElD,OACEZ,EAAiB,QAAhBO,EAAAC,EAAA,CACC,IAAKF,GACDD,GAFL,CAGC,QAAO,GACP,QAASK,GAAaA,GACxB,CAEJ,CAAC,EAcKE,EAAoBC,EAAsC,CAC9D,YAAa,GACb,UAAW,IAAM,CAAC,CACpB,CAAC,EAEKC,EAAyDV,EAC7D,CACEW,EAQAT,IACG,CATH,IAAAU,EAAAD,EACE,WAAAE,EACA,SAAAC,EACA,UAAAC,EA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,0DACAL,CACF,GACIZ,EACN,EAEJ,EAMMgC,EACJjC,EAAW,CAACW,EAAyBT,IAAK,CAA9B,IAAAU,EAAAD,EAAE,WAAAE,CArQhB,EAqQcD,EAAgBX,EAAAgB,EAAhBL,EAAgB,CAAd,cACZ,OAAAhB,EAAiB,cAAhBQ,EAAA,CACC,IAAKF,EACL,UAAWgB,EAAI,8CAA+CL,CAAS,GACnEZ,EACN,EACD,EAcGiC,EAAkBX,EAAI,0CAA2C,CACrE,SAAU,CACR,QAAS,CACP,QAAS,GACT,QAAS,sCACT,QAAS,sCACT,QAAS,sCACT,OAAQ,mCACV,CACF,EACA,gBAAiB,CACf,QAAS,SACX,CACF,CAAC,EASKY,EAAyDnC,EAC7D,CAAC,CAAE,QAAAoC,EAAS,SAAAtB,EAAU,UAAAD,CAAU,EAAGX,IAE/BN,EAACyC,EAAA,CAAK,IAAKnC,EAAK,UAAWgB,EAAIgB,EAAgB,CAAE,QAAAE,CAAQ,CAAC,EAAGvB,CAAS,EACnE,SAAAC,EACH,CAGN,EAIAJ,EAAW,YAAc,aACzBc,EAAa,YAAc,eAC3BK,EAAa,YAAc,eAC3BG,EAAY,YAA8B,QAAM,YAChDC,EAAkB,YAA8B,cAAY,YAC5DE,EAAW,YAAc,aACzB9B,EAAY,YAA8B,QAAM,YAChDqB,EAAc,YAA8B,UAAQ,YACpD3B,EAAc,YAA8B,UAAQ","names":["DialogPrimitive","forwardRef","createContext","useContext","cva","Slot","jsx","jsxs","Dialog","DialogTrigger","forwardRef","props","ref","__spreadProps","__spreadValues","DialogClose","onDismiss","useContext","DialogBodyContext","createContext","DialogBody","_a","_b","className","children","hideClose","dismissible","__objRest","clx","e","Button","CrossIcon","dialog_header_cva","cva","DialogHeader","border","DialogContent","dialog_footer_cva","dialog_action_cva","DialogFooter","action","align","DialogTitle","DialogDescription","dialog_icon_cva","DialogIcon","variant","Slot"]}