{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "system-alert",
  "type": "registry:ui",
  "title": "SystemAlert",
  "description": "SystemAlert is a full-width banner for app-level messages.",
  "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/styles.json",
    "https://wideset.co/r/utils.json"
  ],
  "files": [
    {
      "path": "src/components/system-alert/SystemAlert.context.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/system-alert/SystemAlert.context.ts",
      "content": "'use client';\n\nimport { createContext, useContext } from 'react';\n\nimport type { SystemAlertContextValue } from './SystemAlert.types';\n\nexport const SystemAlertContext = createContext<SystemAlertContextValue | undefined>(undefined);\n\nexport const useSystemAlertContext = () => {\n  const context = useContext(SystemAlertContext);\n\n  if (context === undefined) {\n    throw new Error('useSystemAlertContext must be used within a SystemAlert');\n  }\n\n  return context;\n};\n"
    },
    {
      "path": "src/components/system-alert/SystemAlert.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/system-alert/SystemAlert.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, useState } from 'react';\nimport { cn } from '@/lib/wideset/utils';\n\nimport { IconButton } from '../button/IconButton';\nimport { SystemAlertContext } from './SystemAlert.context';\nimport type {\n  SystemAlertMessageProps,\n  SystemAlertProps,\n  SystemAlertStatus,\n  SystemAlertWithSubComponents,\n} from './SystemAlert.types';\nimport {\n  systemAlertIconVariants,\n  systemAlertOnColorActionClassName,\n  systemAlertVariants,\n} from './SystemAlert.variants';\nimport { SystemAlertAction } from './SystemAlertAction';\nimport { SystemAlertMessage } from './SystemAlertMessage';\n\nconst iconsMap: Record<SystemAlertStatus, RemixiconComponentType | null> = {\n  negative: RiErrorWarningFill,\n  notice: RiErrorWarningFill,\n  positive: RiCheckboxCircleFill,\n  info: RiInformationFill,\n  neutral: null,\n};\n\nconst isSlot = (child: React.ReactNode, slot: React.ElementType) =>\n  isValidElement(child) && child.type === slot;\n\nconst SystemAlert = forwardRef<HTMLDivElement, SystemAlertProps>(\n  (\n    {\n      className,\n      status = 'positive',\n      emphasis = 'low',\n      dismissed,\n      message,\n      onDismiss,\n      dismissible = true,\n      dismissAriaLabel = 'Dismiss',\n      children,\n      ...props\n    },\n    ref,\n  ) => {\n    const [isDismissed, setIsDismissed] = useState(false);\n\n    const isControlled = dismissed !== undefined;\n    const isVisible = isControlled ? !dismissed : !isDismissed;\n\n    const childrenArray = React.Children.toArray(children);\n    const messageSlot = childrenArray.find((child) => isSlot(child, SystemAlertMessage)) as\n      React.ReactElement<SystemAlertMessageProps> | undefined;\n    const actions = childrenArray.filter((child) => !isSlot(child, SystemAlertMessage));\n\n    const content = messageSlot?.props.children ?? message;\n    const IconComponent = iconsMap[status];\n    const actionVariant = emphasis === 'high' && status !== 'notice' ? 'inverse' : 'secondary';\n    const hasActionsBlock = actions.length > 0 || dismissible;\n\n    const dismiss = () => {\n      if (!isControlled) {\n        setIsDismissed(true);\n      }\n\n      onDismiss?.();\n    };\n\n    if (!isVisible) return null;\n\n    return (\n      <SystemAlertContext.Provider value={{ emphasis, status }}>\n        <div\n          ref={ref}\n          data-slot=\"system-alert\"\n          className={cn(systemAlertVariants({ status, emphasis }), className)}\n          role={status === 'negative' ? 'alert' : 'status'}\n          {...props}\n        >\n          <div className=\"gap-ws-6 flex min-w-0 items-center py-[0.375rem]\">\n            {IconComponent && (\n              <IconComponent\n                aria-hidden=\"true\"\n                focusable=\"false\"\n                className={systemAlertIconVariants({ status, emphasis })}\n              />\n            )}\n            {content && (\n              <span data-slot=\"system-alert-message\" className=\"typography-label-strong-sm\">\n                {content}\n              </span>\n            )}\n          </div>\n\n          {hasActionsBlock && (\n            <div className=\"gap-ws-3 flex shrink-0 items-center\">\n              {actions.length > 0 && actions}\n\n              {dismissible && (\n                <IconButton\n                  icon={RiCloseLine}\n                  preset=\"ghost\"\n                  variant={actionVariant}\n                  size=\"xs\"\n                  aria-label={dismissAriaLabel}\n                  onClick={dismiss}\n                  className={cn(\n                    'shrink-0',\n                    emphasis === 'high' && systemAlertOnColorActionClassName,\n                  )}\n                />\n              )}\n            </div>\n          )}\n        </div>\n      </SystemAlertContext.Provider>\n    );\n  },\n) as SystemAlertWithSubComponents;\n\nSystemAlert.displayName = 'SystemAlert';\n\nSystemAlert.Message = SystemAlertMessage;\nSystemAlert.Action = SystemAlertAction;\n\nexport { SystemAlert };\n"
    },
    {
      "path": "src/components/system-alert/SystemAlert.types.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/system-alert/SystemAlert.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 { systemAlertVariants } from './SystemAlert.variants';\n\nexport type SystemAlertStatus = NonNullable<VariantProps<typeof systemAlertVariants>['status']>;\n\nexport type SystemAlertEmphasis = NonNullable<VariantProps<typeof systemAlertVariants>['emphasis']>;\n\nexport type SystemAlertContextValue = {\n  emphasis: SystemAlertEmphasis;\n  status: SystemAlertStatus;\n};\n\n/** A dismissible page-level status message. */\nexport type SystemAlertProps = HTMLAttributes<HTMLDivElement> & {\n  /** The semantic status of the alert. */\n  status?: SystemAlertStatus;\n  /** Controls whether the alert uses subtle or inverse styling. */\n  emphasis?: SystemAlertEmphasis;\n  /** Controls whether the alert is hidden. */\n  dismissed?: boolean;\n  /** Message content when not using SystemAlert.Message. */\n  message?: ReactNode;\n  /** Callback fired when the dismiss button is clicked. */\n  onDismiss?: () => void;\n  /** When true, renders the dismiss button. */\n  dismissible?: boolean;\n  /** Accessible label for the dismiss button. Defaults to `'Dismiss'`. */\n  dismissAriaLabel?: string;\n};\n\n/** The message displayed inside the feedback surface. */\nexport type SystemAlertMessageProps = {\n  /** Use SystemAlert.Message and SystemAlert.Action inside children. The message slot overrides the message prop. */\n  children: ReactNode;\n};\n\n/** An action styled for `SystemAlert`. */\nexport type SystemAlertActionProps = ButtonProps;\n\nexport type SystemAlertWithSubComponents = ForwardRefExoticComponent<\n  PropsWithoutRef<SystemAlertProps> & RefAttributes<HTMLDivElement>\n> & {\n  Message: ComponentType<SystemAlertMessageProps>;\n  Action: ComponentType<SystemAlertActionProps>;\n};\n"
    },
    {
      "path": "src/components/system-alert/SystemAlert.variants.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/system-alert/SystemAlert.variants.ts",
      "content": "import { cva } from 'class-variance-authority';\n\nexport const systemAlertVariants = cva(\n  'gap-ws-9 px-ws-9 py-ws-3 flex w-full items-center justify-center',\n  {\n    variants: {\n      status: {\n        negative: '',\n        notice: '',\n        positive: '',\n        info: '',\n        neutral: '',\n      },\n      emphasis: {\n        low: '',\n        high: '',\n      },\n    },\n    defaultVariants: {\n      status: 'positive',\n      emphasis: 'low',\n    },\n    compoundVariants: [\n      {\n        status: 'negative',\n        emphasis: 'low',\n        className: 'bg-ws-semantic-negative text-ws-semantic-on-subtle-negative',\n      },\n      {\n        status: 'notice',\n        emphasis: 'low',\n        className: 'bg-ws-semantic-notice text-ws-semantic-on-subtle-notice',\n      },\n      {\n        status: 'positive',\n        emphasis: 'low',\n        className: 'bg-ws-semantic-positive text-ws-semantic-on-subtle-positive',\n      },\n      {\n        status: 'info',\n        emphasis: 'low',\n        className: 'bg-ws-semantic-info text-ws-semantic-on-subtle-info',\n      },\n      {\n        status: 'neutral',\n        emphasis: 'low',\n        className: 'bg-ws-semantic-neutral text-ws-semantic-neutral',\n      },\n      {\n        status: 'negative',\n        emphasis: 'high',\n        className: 'bg-ws-semantic-inverse-negative text-ws-semantic-on-inverse-negative',\n      },\n      {\n        status: 'notice',\n        emphasis: 'high',\n        className: 'bg-ws-semantic-inverse-notice text-ws-semantic-on-inverse-notice',\n      },\n      {\n        status: 'positive',\n        emphasis: 'high',\n        className: 'bg-ws-semantic-inverse-positive text-ws-semantic-on-inverse-positive',\n      },\n      {\n        status: 'info',\n        emphasis: 'high',\n        className: 'bg-ws-semantic-inverse-info text-ws-semantic-on-inverse-info',\n      },\n      {\n        status: 'neutral',\n        emphasis: 'high',\n        className: 'bg-ws-semantic-inverse-neutral text-ws-semantic-on-inverse-neutral',\n      },\n    ],\n  },\n);\n\nexport const systemAlertOnColorActionClassName =\n  'text-current! border-current/24! hover:border-current/40! active:border-current/56! hover:bg-current/8! active:bg-current/12! outline-current!';\n\nexport const systemAlertIconVariants = cva('size-ws-11 shrink-0', {\n  variants: {\n    status: {\n      negative: '',\n      notice: '',\n      positive: '',\n      info: '',\n      neutral: '',\n    },\n    emphasis: {\n      low: '',\n      high: '',\n    },\n  },\n  defaultVariants: {\n    status: 'positive',\n    emphasis: 'low',\n  },\n  compoundVariants: [\n    {\n      status: 'negative',\n      emphasis: 'low',\n      className: 'text-ws-semantic-negative',\n    },\n    {\n      status: 'notice',\n      emphasis: 'low',\n      className: 'text-ws-semantic-notice',\n    },\n    {\n      status: 'positive',\n      emphasis: 'low',\n      className: 'text-ws-semantic-positive',\n    },\n    {\n      status: 'info',\n      emphasis: 'low',\n      className: 'text-ws-semantic-info',\n    },\n  ],\n});\n"
    },
    {
      "path": "src/components/system-alert/SystemAlertAction.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/system-alert/SystemAlertAction.tsx",
      "content": "'use client';\n\nimport { cn } from '@/lib/wideset/utils';\n\nimport { Button } from '../button/Button';\nimport { useSystemAlertContext } from './SystemAlert.context';\nimport type { SystemAlertActionProps } from './SystemAlert.types';\nimport { systemAlertOnColorActionClassName } from './SystemAlert.variants';\n\nconst SystemAlertAction = ({\n  preset = 'border',\n  variant,\n  size = 'xs',\n  className,\n  children,\n  ...props\n}: SystemAlertActionProps) => {\n  const { emphasis, status } = useSystemAlertContext();\n\n  let resolvedVariant = variant;\n  if (!resolvedVariant) {\n    resolvedVariant = emphasis === 'high' && status !== 'notice' ? 'inverse' : 'secondary';\n  }\n  const onColor = !variant && emphasis === 'high';\n\n  return (\n    <Button\n      data-slot=\"system-alert-action\"\n      preset={preset}\n      variant={resolvedVariant}\n      size={size}\n      className={cn(onColor && systemAlertOnColorActionClassName, className)}\n      {...props}\n    >\n      {children}\n    </Button>\n  );\n};\n\nSystemAlertAction.displayName = 'SystemAlert.Action';\n\nexport { SystemAlertAction };\n"
    },
    {
      "path": "src/components/system-alert/SystemAlertMessage.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/system-alert/SystemAlertMessage.tsx",
      "content": "'use client';\n\nimport type { SystemAlertMessageProps } from './SystemAlert.types';\n\nconst SystemAlertMessage = ({ children }: SystemAlertMessageProps) => <>{children}</>;\n\nSystemAlertMessage.displayName = 'SystemAlert.Message';\n\nexport { SystemAlertMessage };\n"
    }
  ],
  "meta": {
    "version": "1.0.0",
    "commit": "8bb3627"
  }
}
