{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ds-switch",
  "title": "Switch UI",
  "description": "Extended switch with label positioning, semantic color variants (success/destructive/warning), skeleton loading, and error state.",
  "dependencies": [
    "class-variance-authority",
    "lucide-react"
  ],
  "registryDependencies": [
    "@lema-ds/switch",
    "@lema-ds/label",
    "@lema-ds/skeleton",
    "@lema-ds/ui-i18n",
    "@lema-ds/ds-locale-provider",
    "@lema-ds/tokens"
  ],
  "files": [
    {
      "path": "components/ds/ds-switch.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Switch as SwitchRoot } from \"@/components/ui/switch\"\nimport { Label } from \"@/components/ui/label\"\nimport { Skeleton } from \"@/components/ui/skeleton\"\nimport { UI_I18N, type UILocale } from \"@/lib/ui-i18n\"\nimport { useUILocale } from \"@/components/ui/ds-locale-provider\"\n\n// ── Types ──\n\nexport type SwitchColor = \"default\" | \"success\" | \"destructive\" | \"warning\"\n\nexport interface SwitchProps\n  extends\n    Omit<React.ComponentProps<typeof SwitchRoot>, \"size\">,\n    VariantProps<typeof switchVariants> {\n  label?: string\n  labelPosition?: \"left\" | \"right\"\n  color?: SwitchColor\n  loading?: boolean\n  error?: string\n  locale?: UILocale\n}\n\n// ── Variants ──\n\nexport const switchVariants = cva(\"\", {\n  variants: {\n    color: {\n      default: \"\",\n      success: \"data-checked:border-success data-checked:bg-success\",\n      destructive:\n        \"data-checked:border-destructive data-checked:bg-destructive\",\n      warning: \"data-checked:border-warning data-checked:bg-warning\",\n    },\n    size: {\n      sm: \"data-[size=sm]:h-4 data-[size=sm]:w-7 [&_[data-slot=switch-thumb]]:data-[size=sm]:h-3 [&_[data-slot=switch-thumb]]:data-[size=sm]:w-3\",\n      md: \"\",\n      lg: \"h-6 w-13 [&_[data-slot=switch-thumb]]:h-5 [&_[data-slot=switch-thumb]]:w-6\",\n    },\n  },\n  defaultVariants: { color: \"default\", size: \"md\" },\n})\n\n// ── Component ──\n\nfunction Switch({\n  color = \"default\",\n  size = \"md\",\n  label,\n  labelPosition = \"right\",\n  loading = false,\n  error,\n  locale: localeProp,\n  disabled,\n  className,\n  id,\n  ...props\n}: SwitchProps) {\n  const locale = useUILocale(localeProp)\n  const i18n = UI_I18N[locale]\n  const generatedId = React.useId()\n  const switchId = id ?? generatedId\n  const errorId = error ? `${switchId}-error` : undefined\n\n  const isDisabled = disabled || loading\n\n  if (loading) {\n    return (\n      <div\n        data-slot=\"ds-switch\"\n        className={cn(\n          \"inline-flex items-center gap-2\",\n          labelPosition === \"left\" && \"flex-row-reverse\"\n        )}\n      >\n        <Skeleton\n          className={cn(\n            \"rounded-full\",\n            size === \"sm\" ? \"h-4 w-7\" : size === \"lg\" ? \"h-6 w-13\" : \"h-5 w-11\"\n          )}\n        />\n        {label && <Skeleton className=\"h-4 w-20 rounded-md\" />}\n      </div>\n    )\n  }\n\n  const switchElement = (\n    <SwitchRoot\n      id={switchId}\n      data-slot=\"ds-switch\"\n      data-color={color}\n      disabled={isDisabled}\n      className={cn(switchVariants({ color, size }), className)}\n      aria-invalid={!!error}\n      aria-describedby={errorId}\n      aria-label={!label ? i18n.switch.toggle : undefined}\n      {...props}\n    />\n  )\n\n  if (!label && !error) return switchElement\n\n  return (\n    <div data-slot=\"ds-switch-wrapper\" className=\"flex flex-col gap-1\">\n      <div\n        className={cn(\n          \"inline-flex items-center gap-2\",\n          labelPosition === \"left\" && \"flex-row-reverse\"\n        )}\n      >\n        {switchElement}\n        {label && (\n          <Label\n            htmlFor={switchId}\n            data-slot=\"ds-switch-label\"\n            className={cn(\n              \"cursor-pointer font-medium text-muted-foreground select-none\",\n              size === \"sm\" && \"text-xs\",\n              size === \"md\" && \"text-sm\",\n              size === \"lg\" && \"text-base\"\n            )}\n          >\n            {label}\n          </Label>\n        )}\n      </div>\n      {error && (\n        <p\n          id={errorId}\n          data-slot=\"ds-switch-error\"\n          className={cn(\n            \"text-destructive\",\n            size === \"sm\" ? \"text-xs\" : \"text-xs\"\n          )}\n          role=\"alert\"\n        >\n          {error}\n        </p>\n      )}\n    </div>\n  )\n}\n\nexport { Switch }\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}
