{"version":3,"sources":["../src/alert/alert.tsx"],"sourcesContent":["import React, { forwardRef, type HTMLAttributes } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { Box, type BoxProps } from \"../box/box\";\n\nexport interface AlertTitleProps extends HTMLAttributes<HTMLParagraphElement> {\n  /**\n   * Change the default rendered element for the one passed as a child, merging their props and behavior.\n   *\n   * @default false\n   */\n  asChild?: boolean;\n}\nexport const AlertTitle = forwardRef<HTMLParagraphElement, AlertTitleProps>(\n  ({ asChild, className, ...rest }, ref) => {\n    const Component = asChild ? Slot : \"div\";\n    return (\n      <Component className={clsx(\"hds-alert__title\", className as undefined)} ref={ref} {...rest} />\n    );\n  },\n);\nAlertTitle.displayName = \"Alert.Title\";\n\nexport interface AlertDescriptionProps extends HTMLAttributes<HTMLParagraphElement> {\n  /**\n   * Change the default rendered element for the one passed as a child, merging their props and behavior.\n   *\n   * @default false\n   */\n  asChild?: boolean;\n}\nexport const AlertDescription = forwardRef<HTMLParagraphElement, AlertDescriptionProps>(\n  ({ asChild, className, ...rest }, ref) => {\n    const Component = asChild ? Slot : \"div\";\n    return (\n      <Component\n        className={clsx(\"hds-alert__description\", className as undefined)}\n        ref={ref}\n        {...rest}\n      />\n    );\n  },\n);\nAlertDescription.displayName = \"Alert.Description\";\n\nexport type AlertProps = (\n  | {\n      /**\n       * @deprecated use data-color instead\n       */\n      variant?: \"info\" | \"success\" | \"warning\" | \"error\";\n      icon?: never;\n      iconClassName?: never;\n    }\n  | {\n      /**\n       * @deprecated use data-color instead\n       */\n      variant: \"neutral\";\n      icon?: React.ReactNode;\n      iconClassName?: string;\n    }\n  | {\n      \"data-color\"?: \"info\" | \"success\" | \"warning\" | \"error\";\n      icon?: never;\n      iconClassName?: never;\n    }\n  | {\n      \"data-color\": \"neutral\";\n      icon?: React.ReactNode;\n      iconClassName?: string;\n    }\n) &\n  Omit<BoxProps, \"variant\" | \"asChild\">;\n\nconst allowedColors = [\"neutral\", \"info\", \"success\", \"warning\", \"error\", undefined] as const;\ntype DataColor = (typeof allowedColors)[number];\n\nfunction isValidDataColor(value: string | undefined): value is DataColor {\n  return allowedColors.includes(value as DataColor);\n}\n\nexport const Alert = forwardRef<HTMLDivElement, AlertProps>(\n  ({ children, className, \"data-color\": color = undefined, icon, iconClassName, ...rest }, ref) => {\n    const { variant, ...boxProps } = rest as { variant?: string };\n\n    // Support deprecated 'variant' prop for backward compatibility\n    const resolvedColor = color ?? variant;\n    const validColor: DataColor | undefined = isValidDataColor(resolvedColor)\n      ? resolvedColor\n      : undefined;\n\n    return (\n      <Box\n        data-color={validColor}\n        className={clsx(`hds-alert`, className as undefined)}\n        ref={ref}\n        {...boxProps}\n      >\n        {validColor === \"neutral\" && (\n          <div className={clsx(\"hds-alert--neutral__icon\", iconClassName as undefined)}>{icon}</div>\n        )}\n        {children}\n      </Box>\n    );\n  },\n) as AlertType;\nAlert.displayName = \"Alert\";\n\ntype AlertType = ReturnType<typeof forwardRef<HTMLDivElement, AlertProps>> & {\n  Title: typeof AlertTitle;\n  Description: typeof AlertDescription;\n};\nAlert.Title = AlertTitle;\nAlert.Description = AlertDescription;\n"],"mappings":";;;;;;;;;;AAAA,SAAgB,kBAAuC;AACvD,SAAS,YAAY;AACrB,SAAS,YAAY;AAef,cA4EA,YA5EA;AAJC,IAAM,aAAa;AAAA,EACxB,CAAC,IAAiC,QAAQ;AAAzC,iBAAE,WAAS,UAdd,IAcG,IAAyB,iBAAzB,IAAyB,CAAvB,WAAS;AACV,UAAM,YAAY,UAAU,OAAO;AACnC,WACE,oBAAC,4BAAU,WAAW,KAAK,oBAAoB,SAAsB,GAAG,OAAc,KAAM;AAAA,EAEhG;AACF;AACA,WAAW,cAAc;AAUlB,IAAM,mBAAmB;AAAA,EAC9B,CAAC,IAAiC,QAAQ;AAAzC,iBAAE,WAAS,UAhCd,IAgCG,IAAyB,iBAAzB,IAAyB,CAAvB,WAAS;AACV,UAAM,YAAY,UA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