{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "settings-list",
  "title": "Settings List",
  "description": "Settings section with an optional heading and description above a list of rows.",
  "dependencies": [
    "@vllnt/ui@^0.3.0"
  ],
  "registryDependencies": [],
  "files": [
    {
      "path": "registry/default/settings-list/settings-list.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport { ChevronRight } from \"lucide-react\";\n\nimport { cn } from \"@vllnt/ui\";\nimport { itemVariants } from \"@vllnt/ui\";\n\nconst settingsListVariants = cva(\"w-full\", {\n  defaultVariants: {\n    variant: \"inset-grouped\",\n  },\n  variants: {\n    variant: {\n      \"inset-grouped\":\n        \"overflow-hidden rounded-lg border bg-card text-card-foreground\",\n      plain: \"\",\n    },\n  },\n});\n\nconst interactiveRowClasses =\n  \"cursor-pointer text-left transition-colors hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring motion-reduce:transition-none\";\n\n/** Surface style of a `SettingsList` (Penpot axis `Style`). */\nexport type SettingsListVariant = NonNullable<\n  VariantProps<typeof settingsListVariants>[\"variant\"]\n>;\n\n/** Props for `SettingsList`. `title` labels the section for assistive tech. */\nexport type SettingsListProps = Omit<\n  React.ComponentPropsWithoutRef<\"section\">,\n  \"title\"\n> &\n  VariantProps<typeof settingsListVariants> & {\n    description?: React.ReactNode;\n    title?: React.ReactNode;\n  };\n\n/** ARIA props `SettingsListItem` injects into its `control` element. */\nexport type SettingsListControlProps = {\n  \"aria-describedby\"?: string;\n  \"aria-labelledby\"?: string;\n};\n\ntype SettingsListItemBaseProps = Omit<\n  React.ComponentPropsWithoutRef<\"li\">,\n  \"children\" | \"onClick\"\n> & {\n  description?: React.ReactNode;\n  label: React.ReactNode;\n  leading?: React.ReactNode;\n  meta?: React.ReactNode;\n};\n\ntype SettingsListItemTrailingProps =\n  | { chevron?: boolean; control?: never; href: string; onClick?: never }\n  | {\n      chevron?: boolean;\n      control?: never;\n      href?: never;\n      onClick: React.MouseEventHandler<HTMLButtonElement>;\n    }\n  | {\n      chevron?: never;\n      control: React.ReactElement<SettingsListControlProps>;\n      href?: never;\n      onClick?: never;\n    }\n  | { chevron?: never; control?: never; href?: never; onClick?: never };\n\n/**\n * Props for `SettingsListItem`. A row has at most one trailing control: a\n * `control` element (for example a `Switch`), or `href` / `onClick` with an\n * optional `chevron`. The union rejects every other combination.\n */\nexport type SettingsListItemProps = SettingsListItemBaseProps &\n  SettingsListItemTrailingProps;\n\ntype SettingsListRowShellProps = {\n  children: React.ReactNode;\n  href?: string;\n  onClick?: React.MouseEventHandler<HTMLButtonElement>;\n};\n\nfunction SettingsListRowShell({\n  children,\n  href,\n  onClick,\n}: SettingsListRowShellProps): React.JSX.Element {\n  const rowClassName = cn(itemVariants(), \"w-full px-4 py-3\");\n\n  if (href !== undefined) {\n    return (\n      <a className={cn(rowClassName, interactiveRowClasses)} href={href}>\n        {children}\n      </a>\n    );\n  }\n  if (onClick !== undefined) {\n    return (\n      <button\n        className={cn(rowClassName, interactiveRowClasses)}\n        onClick={onClick}\n        type=\"button\"\n      >\n        {children}\n      </button>\n    );\n  }\n  return <div className={rowClassName}>{children}</div>;\n}\n\n/**\n * Settings section: an optional heading and description above a list of rows.\n * The root is a `<section>` labelled by `title`; rows are `<li>` elements of a\n * `<ul role=\"list\">` separated by CSS dividers.\n *\n * @example\n * <SettingsList title=\"Account\" variant=\"inset-grouped\">\n *   <SettingsListItem label=\"Notifications\" control={<Switch />} />\n * </SettingsList>\n */\nexport const SettingsList = ({\n  children,\n  className,\n  description,\n  ref: reference,\n  title,\n  variant,\n  ...props\n}: SettingsListProps & { ref?: React.Ref<HTMLElement> }) => {\n  const baseId = React.useId();\n  const titleId = `${baseId}-title`;\n  const descriptionId = `${baseId}-description`;\n\n  return (\n    <section\n      aria-describedby={description ? descriptionId : undefined}\n      aria-labelledby={title ? titleId : undefined}\n      className={cn(settingsListVariants({ variant }), className)}\n      data-slot=\"settings-list\"\n      ref={reference}\n      {...props}\n    >\n      {title || description ? (\n        <header className=\"flex flex-col gap-1 border-b px-4 py-3\">\n          {title ? (\n            <h2 className=\"text-sm font-semibold\" id={titleId}>\n              {title}\n            </h2>\n          ) : null}\n          {description ? (\n            <p className=\"text-sm text-muted-foreground\" id={descriptionId}>\n              {description}\n            </p>\n          ) : null}\n        </header>\n      ) : null}\n      <ul className=\"divide-y divide-border\">{children}</ul>\n    </section>\n  );\n};\n\nSettingsList.displayName = \"SettingsList\";\n\n/**\n * One row of a `SettingsList`: label, optional description, leading icon or\n * avatar, right-side value and one trailing control. A `control` element is\n * labelled by the row label and described by the row description. `href`\n * renders a link and `onClick` a button, both with a visible focus ring.\n *\n * @example\n * <SettingsListItem label=\"Language\" meta=\"English\" href=\"/language\" />\n */\nexport const SettingsListItem = ({\n  chevron,\n  className,\n  control,\n  description,\n  href,\n  label,\n  leading,\n  meta,\n  onClick,\n  ref: reference,\n  ...props\n}: SettingsListItemProps & { ref?: React.Ref<HTMLLIElement> }) => {\n  const baseId = React.useId();\n  const labelId = `${baseId}-label`;\n  const descriptionId = `${baseId}-description`;\n  const isInteractive = href !== undefined || onClick !== undefined;\n  const showChevron = isInteractive && chevron !== false;\n\n  return (\n    <li\n      className={className}\n      data-slot=\"settings-list-item\"\n      ref={reference}\n      {...props}\n    >\n      <SettingsListRowShell href={href} onClick={onClick}>\n        {leading ? (\n          <span className=\"flex shrink-0 items-center justify-center [&_svg]:size-5\">\n            {leading}\n          </span>\n        ) : null}\n        <span className=\"flex min-w-0 flex-1 flex-col gap-0.5\">\n          <span className=\"font-medium\" id={labelId}>\n            {label}\n          </span>\n          {description ? (\n            <span className=\"text-muted-foreground\" id={descriptionId}>\n              {description}\n            </span>\n          ) : null}\n        </span>\n        {meta ? (\n          <span className=\"max-w-32 shrink-0 text-right text-muted-foreground\">\n            {meta}\n          </span>\n        ) : null}\n        {control === undefined\n          ? null\n          : React.cloneElement(control, {\n              \"aria-describedby\":\n                control.props[\"aria-describedby\"] ??\n                (description ? descriptionId : undefined),\n              \"aria-labelledby\": control.props[\"aria-labelledby\"] ?? labelId,\n            })}\n        {showChevron ? (\n          <ChevronRight\n            aria-hidden=\"true\"\n            className=\"size-4 shrink-0 text-muted-foreground\"\n          />\n        ) : null}\n      </SettingsListRowShell>\n    </li>\n  );\n};\n\nSettingsListItem.displayName = \"SettingsListItem\";\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component",
  "version": "0.3.0",
  "stability": "stable",
  "platforms": [
    "web"
  ]
}
