{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "inline-alert",
  "type": "registry:ui",
  "title": "InlineAlert",
  "description": "InlineAlert presents persistent, in-context feedback inside the current layout.",
  "dependencies": [
    "@remixicon/react@^4.9.0",
    "class-variance-authority@^0.7.1"
  ],
  "registryDependencies": [
    "https://wideset.co/r/button.json",
    "https://wideset.co/r/icon-button.json",
    "https://wideset.co/r/logic.json",
    "https://wideset.co/r/styles.json",
    "https://wideset.co/r/utils.json"
  ],
  "files": [
    {
      "path": "src/components/inline-alert/InlineAlert.hooks.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/inline-alert/InlineAlert.hooks.ts",
      "content": "'use client';\n\nimport { useCallback, useRef } from 'react';\n\nimport type { InlineAlertOutletHandle, InlineAlertShowConfig } from './InlineAlert.types';\n\nexport const useInlineAlert = () => {\n  const ref = useRef<InlineAlertOutletHandle>(null);\n\n  const showInlineAlert = useCallback(\n    (config: InlineAlertShowConfig) => ref.current?.show(config) ?? '',\n    [],\n  );\n\n  const dismissInlineAlert = useCallback((id: string) => ref.current?.dismiss(id), []);\n\n  const dismissAllInlineAlerts = useCallback(() => ref.current?.dismissAll(), []);\n\n  return { ref, showInlineAlert, dismissInlineAlert, dismissAllInlineAlerts };\n};\n"
    },
    {
      "path": "src/components/inline-alert/InlineAlert.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/inline-alert/InlineAlert.tsx",
      "content": "'use client';\n\nimport type { RemixiconComponentType } from '@remixicon/react';\nimport {\n  RiCheckboxCircleFill,\n  RiCloseLine,\n  RiErrorWarningFill,\n  RiInformationFill,\n} from '@remixicon/react';\nimport React, { forwardRef, isValidElement, useEffect, useState } from 'react';\nimport { cn } from '@/lib/wideset/utils';\n\nimport { IconButton } from '../button/IconButton';\nimport type {\n  InlineAlertMessageProps,\n  InlineAlertProps,\n  InlineAlertStatus,\n  InlineAlertTitleProps,\n  InlineAlertWithSubComponents,\n} from './InlineAlert.types';\nimport { inlineAlertIconVariants, inlineAlertVariants } from './InlineAlert.variants';\nimport { InlineAlertAction } from './InlineAlertAction';\nimport { InlineAlertMessage } from './InlineAlertMessage';\nimport { InlineAlertOutlet } from './InlineAlertOutlet';\nimport { InlineAlertTitle } from './InlineAlertTitle';\n\nconst iconsMap: Record<InlineAlertStatus, RemixiconComponentType> = {\n  error: RiErrorWarningFill,\n  warning: RiErrorWarningFill,\n  success: RiCheckboxCircleFill,\n  info: RiInformationFill,\n};\n\nconst isSlot = (child: React.ReactNode, slot: React.ElementType) =>\n  isValidElement(child) && child.type === slot;\n\nconst InlineAlert = forwardRef<HTMLDivElement, InlineAlertProps>(\n  (\n    {\n      className,\n      status = 'info',\n      orientation = 'horizontal',\n      alertId,\n      messageId,\n      dismissed,\n      title,\n      message,\n      onDismiss,\n      persistent = false,\n      dismissAriaLabel = 'Dismiss',\n      children,\n      ...props\n    },\n    ref,\n  ) => {\n    const IconComponent = iconsMap[status as InlineAlertStatus];\n    const childrenArray = React.Children.toArray(children);\n    const [isDismissed, setIsDismissed] = useState(false);\n\n    const isControlled = dismissed !== undefined;\n    const isVisible = isControlled ? !dismissed : !isDismissed;\n\n    useEffect(() => {\n      if (isControlled || (!alertId && !messageId)) return;\n      setIsDismissed(false);\n    }, [alertId, messageId, isControlled]);\n\n    const dismiss = () => {\n      if (!isControlled) {\n        setIsDismissed(true);\n      }\n\n      onDismiss?.();\n    };\n\n    const titleSlot = childrenArray.find((child) => isSlot(child, InlineAlertTitle)) as\n      React.ReactElement<InlineAlertTitleProps> | undefined;\n\n    const messageSlot = childrenArray.find((child) => isSlot(child, InlineAlertMessage)) as\n      React.ReactElement<InlineAlertMessageProps> | undefined;\n\n    const actions = childrenArray.filter(\n      (child) => !isSlot(child, InlineAlertTitle) && !isSlot(child, InlineAlertMessage),\n    );\n\n    const resolvedTitle = titleSlot ? titleSlot.props.children : title;\n    const resolvedMessage = messageSlot ? messageSlot.props.children : message;\n\n    const icon = (\n      <IconComponent\n        aria-hidden=\"true\"\n        focusable=\"false\"\n        className={inlineAlertIconVariants({ status })}\n      />\n    );\n\n    const textContent = (\n      <div className=\"gap-ws-2 flex flex-1 flex-col\">\n        {resolvedTitle && (\n          <span data-slot=\"inline-alert-title\" className=\"typography-label-strong-sm\">\n            {resolvedTitle}\n          </span>\n        )}\n        {resolvedMessage && (\n          <span data-slot=\"inline-alert-message\" className=\"typography-body-md\">\n            {resolvedMessage}\n          </span>\n        )}\n      </div>\n    );\n\n    const actionsContent = actions.length > 0 && (\n      <div className=\"gap-ws-5 flex shrink-0 items-center\">{actions}</div>\n    );\n\n    const closeButton = persistent ? null : (\n      <IconButton\n        icon={RiCloseLine}\n        preset=\"ghost\"\n        variant=\"secondary\"\n        size=\"sm\"\n        aria-label={dismissAriaLabel}\n        onClick={dismiss}\n        className={cn('text-inherit', orientation === 'horizontal' && 'self-center')}\n      />\n    );\n\n    if (!isVisible) return null;\n\n    // Figma anchors the icon to the first text line whenever the content block is\n    // taller than one line; otherwise everything centres on the tallest child.\n    const alignStart = Boolean(resolvedTitle) || (orientation === 'vertical' && actions.length > 0);\n\n    return (\n      <div\n        ref={ref}\n        data-slot=\"inline-alert\"\n        className={cn(\n          inlineAlertVariants({ status, orientation }),\n          alignStart ? 'items-start' : 'items-center',\n          className,\n        )}\n        role={status === 'error' ? 'alert' : 'status'}\n        {...props}\n      >\n        {icon}\n        {/*\n         * The orientation axis is exactly this: the text block and the actions\n         * sit side by side in `horizontal` and stacked in `vertical`. Both gaps\n         * are 12px in Figma — the frame's Gap/7 in one case, the Content\n         * column's Gap/7 in the other.\n         */}\n        <div\n          className={cn(\n            'gap-ws-7 flex flex-1',\n            orientation === 'horizontal' ? 'items-center' : 'flex-col',\n          )}\n        >\n          {textContent}\n          {actionsContent}\n        </div>\n        {closeButton}\n      </div>\n    );\n  },\n) as InlineAlertWithSubComponents;\n\nInlineAlert.displayName = 'InlineAlert';\nInlineAlert.Title = InlineAlertTitle;\nInlineAlert.Message = InlineAlertMessage;\nInlineAlert.Action = InlineAlertAction;\nInlineAlert.Outlet = InlineAlertOutlet;\n\nexport { InlineAlert };\n"
    },
    {
      "path": "src/components/inline-alert/InlineAlert.types.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/inline-alert/InlineAlert.types.ts",
      "content": "import type { VariantProps } from 'class-variance-authority';\nimport type {\n  ComponentType,\n  ForwardRefExoticComponent,\n  HTMLAttributes,\n  PropsWithoutRef,\n  ReactNode,\n  RefAttributes,\n} from 'react';\n\nimport type { ButtonProps } from '../button/Button.types';\nimport type { inlineAlertVariants } from './InlineAlert.variants';\n\n/** Semantic tone of the alert visuals and iconography. */\nexport type InlineAlertStatus = NonNullable<VariantProps<typeof inlineAlertVariants>['status']>;\n\n/** Layout direction of the alert content and action area. */\nexport type InlineAlertOrientation = NonNullable<\n  VariantProps<typeof inlineAlertVariants>['orientation']\n>;\n\n/** Persistent feedback within a page section. */\nexport type InlineAlertProps = Omit<\n  HTMLAttributes<HTMLDivElement>,\n  'children' | 'className' | 'title'\n> &\n  VariantProps<typeof inlineAlertVariants> & {\n    /** Additional CSS classes merged with the alert root element. */\n    className?: string;\n    /**\n     * Alert content, typically composed with `InlineAlert.Title`, `InlineAlert.Message`, and\n     * `InlineAlert.Action`. Slot content overrides the `title` and `message` props.\n     */\n    children?: ReactNode;\n    /** Optional identifier used to reset uncontrolled dismissed state when the alert instance changes. */\n    alertId?: string;\n    /** Optional identifier used to reset uncontrolled dismissed state when the message content changes. */\n    messageId?: string;\n    /** Controlled visibility state. When `true`, the alert is hidden. */\n    dismissed?: boolean;\n    /** Optional short title rendered above or before the main message. */\n    title?: string;\n    /** Main alert message when not using `InlineAlert.Message`. */\n    message?: ReactNode;\n    /** Called when the user presses the dismiss button. */\n    onDismiss?: () => void;\n    /** When `true`, the dismiss button is not rendered. */\n    persistent?: boolean;\n    /** Accessible label for the dismiss button. Defaults to `'Dismiss'`. */\n    dismissAriaLabel?: string;\n  };\n\n/** The primary title text. */\nexport type InlineAlertTitleProps = {\n  /** Short heading content rendered above or before the alert message. */\n  children: ReactNode;\n};\n\n/** The message displayed inside the feedback surface. */\nexport type InlineAlertMessageProps = {\n  /** Main inline message content. */\n  children: ReactNode;\n};\n\n/**\n * Props forwarded to `InlineAlert.Action`.\n * Inherits the full `Button` API and defaults to `preset=\"border\"`, `variant=\"secondary\"`,\n * and `size=\"sm\"` when those props are not provided.\n */\nexport interface InlineAlertActionProps extends ButtonProps {}\n\nexport type InlineAlertWithSubComponents = ForwardRefExoticComponent<\n  PropsWithoutRef<InlineAlertProps> & RefAttributes<HTMLDivElement>\n> & {\n  Title: ComponentType<InlineAlertTitleProps>;\n  Message: ComponentType<InlineAlertMessageProps>;\n  Action: ComponentType<InlineAlertActionProps>;\n  Outlet: ForwardRefExoticComponent<\n    PropsWithoutRef<InlineAlertOutletProps> & RefAttributes<InlineAlertOutletHandle>\n  >;\n};\n\nexport type InlineAlertShowConfig = {\n  /** Semantic alert tone used for the rendered inline alert. */\n  status?: InlineAlertStatus;\n  /** Layout direction of the rendered inline alert. */\n  orientation?: InlineAlertOrientation;\n  /** Optional short title rendered above or before the alert message. */\n  title?: string;\n  /** Main inline alert message content. */\n  message: ReactNode;\n  /** Optional action content rendered inside the alert. */\n  action?: ReactNode | ReactNode[];\n};\n\nexport type InlineAlertItem = InlineAlertShowConfig & {\n  /** Stable identifier for a rendered inline alert instance. */\n  id: string;\n};\n\n/** Container for alerts shown through its ref (`show`, `dismiss`, `dismissAll`). */\nexport type InlineAlertOutletProps = Omit<\n  HTMLAttributes<HTMLDivElement>,\n  'children' | 'className'\n> & {\n  /** Additional CSS classes merged with the outlet container. */\n  className?: string;\n  /** Additional CSS classes merged with each rendered inline alert root. */\n  inlineAlertClassName?: string;\n  /** Additional CSS classes merged with each rendered inline alert message. */\n  messageClassName?: string;\n};\n\nexport type InlineAlertOutletHandle = {\n  /** Adds a new inline alert and returns its generated id. */\n  show: (config: InlineAlertShowConfig) => string;\n  /** Dismisses a rendered inline alert by id. */\n  dismiss: (id: string) => void;\n  /** Dismisses all rendered inline alerts. */\n  dismissAll: () => void;\n};\n"
    },
    {
      "path": "src/components/inline-alert/InlineAlert.variants.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/inline-alert/InlineAlert.variants.ts",
      "content": "import { cva } from 'class-variance-authority';\n\n// The root is always a row — icon | content | dismiss — in both orientations, as\n// in Figma. The orientation axis only carries vertical padding: the horizontal\n// frame is padded Gap/7 (12px) top and bottom, the vertical one Space/400 (16px).\n// Horizontal padding is Space/400 (16px) in both. What actually flips with the\n// axis is the content group, handled in InlineAlert.tsx.\nexport const inlineAlertVariants = cva('rounded-ws-container-md gap-ws-7 px-ws-9 flex', {\n  variants: {\n    status: {\n      error: 'bg-ws-semantic-negative text-ws-semantic-on-subtle-negative',\n      warning: 'bg-ws-semantic-notice text-ws-semantic-on-subtle-notice',\n      success: 'bg-ws-semantic-positive text-ws-semantic-on-subtle-positive',\n      info: 'bg-ws-semantic-info text-ws-semantic-on-subtle-info',\n    },\n    orientation: {\n      horizontal: 'py-ws-7',\n      vertical: 'py-ws-9',\n    },\n  },\n  defaultVariants: {\n    status: 'info',\n    orientation: 'horizontal',\n  },\n});\n\nexport const inlineAlertIconVariants = cva('size-ws-11 shrink-0', {\n  variants: {\n    status: {\n      error: 'text-ws-semantic-negative',\n      warning: 'text-ws-semantic-notice',\n      success: 'text-ws-semantic-positive',\n      info: 'text-ws-semantic-info',\n    },\n  },\n});\n"
    },
    {
      "path": "src/components/inline-alert/InlineAlertAction.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/inline-alert/InlineAlertAction.tsx",
      "content": "'use client';\n\nimport { cn } from '@/lib/wideset/utils';\n\nimport { Button } from '../button/Button';\nimport type { InlineAlertActionProps } from './InlineAlert.types';\n\nconst InlineAlertAction = ({\n  preset = 'border',\n  variant = 'secondary',\n  size = 'sm',\n  children,\n  className,\n  ...props\n}: InlineAlertActionProps) => (\n  <Button\n    data-slot=\"inline-alert-action\"\n    preset={preset}\n    variant={variant}\n    size={size}\n    // Figma tints the action label with the alert's on-subtle status colour, which\n    // the root already sets — inherit it over the Button's own secondary text token.\n    className={cn('text-inherit', className)}\n    {...props}\n  >\n    {children}\n  </Button>\n);\n\nInlineAlertAction.displayName = 'InlineAlert.Action';\n\nexport { InlineAlertAction };\n"
    },
    {
      "path": "src/components/inline-alert/InlineAlertMessage.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/inline-alert/InlineAlertMessage.tsx",
      "content": "'use client';\n\nimport type { InlineAlertMessageProps } from './InlineAlert.types';\n\nconst InlineAlertMessage = ({ children }: InlineAlertMessageProps) => <>{children}</>;\n\nInlineAlertMessage.displayName = 'InlineAlert.Message';\n\nexport { InlineAlertMessage };\n"
    },
    {
      "path": "src/components/inline-alert/InlineAlertOutlet.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/inline-alert/InlineAlertOutlet.tsx",
      "content": "'use client';\n\nimport { forwardRef, Fragment, type ReactNode, useImperativeHandle, useState } from 'react';\nimport { cn } from '@/lib/wideset/utils';\nimport { generateId } from '@/lib/wideset/helpers';\n\nimport { InlineAlert } from './InlineAlert';\nimport type {\n  InlineAlertItem,\n  InlineAlertOutletHandle,\n  InlineAlertOutletProps,\n  InlineAlertShowConfig,\n} from './InlineAlert.types';\n\nconst InlineAlertOutlet = forwardRef<InlineAlertOutletHandle, InlineAlertOutletProps>(\n  ({ className, inlineAlertClassName, messageClassName, ...props }, ref) => {\n    const [alerts, setAlerts] = useState<InlineAlertItem[]>([]);\n\n    useImperativeHandle(ref, () => ({\n      show: (config: InlineAlertShowConfig) => {\n        const id = generateId();\n        setAlerts((prev) => [...prev, { ...config, id }]);\n        return id;\n      },\n      dismiss: (id: string) => {\n        setAlerts((prev) => prev.filter((alert) => alert.id !== id));\n      },\n      dismissAll: () => {\n        setAlerts([]);\n      },\n    }));\n\n    const renderActions = (action: ReactNode | ReactNode[]) =>\n      Array.isArray(action)\n        ? action.map((actionNode, index) => <Fragment key={index}>{actionNode}</Fragment>)\n        : action;\n\n    if (alerts.length === 0) return null;\n\n    return (\n      <div\n        data-slot=\"inline-alert-outlet\"\n        className={cn('gap-ws-7 flex flex-col', className)}\n        {...props}\n      >\n        {alerts.map(({ id, status, orientation, title, message, action }) => (\n          <InlineAlert\n            key={id}\n            className={inlineAlertClassName}\n            status={status}\n            orientation={orientation}\n            title={title}\n            message={\n              messageClassName ? <span className={messageClassName}>{message}</span> : message\n            }\n            onDismiss={() => setAlerts((prev) => prev.filter((alert) => alert.id !== id))}\n          >\n            {action && renderActions(action)}\n          </InlineAlert>\n        ))}\n      </div>\n    );\n  },\n);\n\nInlineAlertOutlet.displayName = 'InlineAlert.Outlet';\n\nexport { InlineAlertOutlet };\n"
    },
    {
      "path": "src/components/inline-alert/InlineAlertTitle.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/inline-alert/InlineAlertTitle.tsx",
      "content": "'use client';\n\nimport type { InlineAlertTitleProps } from './InlineAlert.types';\n\nconst InlineAlertTitle = ({ children }: InlineAlertTitleProps) => <>{children}</>;\n\nInlineAlertTitle.displayName = 'InlineAlert.Title';\n\nexport { InlineAlertTitle };\n"
    }
  ],
  "meta": {
    "version": "1.0.0",
    "commit": "8bb3627"
  }
}
