{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ds-tabs",
  "title": "Tabs UI",
  "description": "Extended tabs with 4 variants (default/line/pill/segmented), 3 sizes, icons, count badges, loading skeletons, vertical orientation, activation mode (automatic/manual), and responsive accordion fallback on mobile. Wraps the shadcn Tabs primitive.",
  "dependencies": [
    "class-variance-authority",
    "radix-ui",
    "lucide-react"
  ],
  "registryDependencies": [
    "@lema-ds/tabs",
    "@lema-ds/skeleton",
    "@lema-ds/ui-i18n",
    "@lema-ds/ds-locale-provider"
  ],
  "files": [
    {
      "path": "components/ds/ds-tabs.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { cva } from \"class-variance-authority\"\nimport { Tabs as TabsPrimitive } from \"radix-ui\"\nimport { Accordion as AccordionPrimitive } from \"radix-ui\"\nimport { ChevronDown } from \"lucide-react\"\n\nimport { cn } from \"@/lib/utils\"\nimport { UI_I18N, type UILocale } from \"@/lib/ui-i18n\"\nimport { useUILocale } from \"@/components/ui/ds-locale-provider\"\nimport { Tabs as TabsRoot, TabsContent } from \"@/components/ui/tabs\"\nimport { Skeleton } from \"@/components/ui/skeleton\"\nimport { useIsMobile } from \"@/hooks/use-mobile\"\n\n// ── Types ──────────────────────────────────────────────────────────────────\n\nexport interface TabItem {\n  /** Unique identifier for the tab. Used as the value prop for Radix primitives. */\n  value: string\n  /** Human-readable label shown in the tab trigger. */\n  label: string\n  /** Lucide icon component rendered before the label. */\n  icon?: React.ElementType\n  /** Numeric badge shown next to the label (e.g. notification count). */\n  count?: number\n  /** Disables the individual tab. */\n  disabled?: boolean\n  /** Content rendered when the tab is active. */\n  content?: React.ReactNode\n}\n\nexport interface TabsProps {\n  /** Array of tab definitions — the declarative API. */\n  items: TabItem[]\n  /** Initial active tab for uncontrolled usage. Defaults to the first item's value. */\n  defaultValue?: string\n  /** Controlled active tab value. */\n  value?: string\n  /** Called when the active tab changes. */\n  onValueChange?: (value: string) => void\n  /** Visual variant for the tab bar. @default \"default\" */\n  variant?: \"default\" | \"line\" | \"pill\" | \"segmented\"\n  /** Trigger size. @default \"md\" */\n  size?: \"sm\" | \"md\" | \"lg\"\n  /** Layout direction. @default \"horizontal\" */\n  orientation?: \"horizontal\" | \"vertical\"\n  /** Whether tabs activate on focus or require a click. @default \"automatic\" */\n  activationMode?: \"automatic\" | \"manual\"\n  /** When true, collapses to an Accordion on viewports below 768px. */\n  responsive?: boolean\n  /** Always render as Accordion regardless of viewport. Useful for stories. */\n  forceAccordion?: boolean\n  /** Shows skeleton placeholders while loading. */\n  loading?: boolean\n  /** Number of skeleton items. Defaults to items.length or 3. */\n  skeletonCount?: number\n  /** Locale for aria-labels. @default \"en-US\" */\n  locale?: UILocale\n  className?: string\n}\n\n// ── CVA Variants ────────────────────────────────────────────────────────────\n\nconst dsTabsListVariants = cva(\n  [\n    \"group/tabs-list inline-flex w-fit items-center justify-center\",\n    \"text-muted-foreground transition-all\",\n  ],\n  {\n    variants: {\n      variant: {\n        default: \"rounded-full bg-muted p-1\",\n        line: \"gap-1 rounded-none border-b border-border bg-transparent pb-px\",\n        pill: \"gap-2 bg-transparent\",\n        segmented: \"rounded-lg bg-muted p-0.5\",\n      },\n      orientation: {\n        horizontal: \"flex-row\",\n        vertical: \"h-fit flex-col rounded-xl\",\n      },\n    },\n    defaultVariants: {\n      variant: \"default\",\n      orientation: \"horizontal\",\n    },\n  }\n)\n\nconst dsTabsTriggerVariants = cva(\n  [\n    \"relative inline-flex shrink-0 items-center justify-center gap-1.5 font-medium whitespace-nowrap transition-all\",\n    \"focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring\",\n    \"disabled:pointer-events-none disabled:opacity-50\",\n    \"[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n    \"group-data-[orientation=vertical]/tabs-list:w-full group-data-[orientation=vertical]/tabs-list:justify-start\",\n    \"data-[state=active]:text-foreground\",\n  ],\n  {\n    variants: {\n      variant: {\n        default: [\n          \"rounded-full border border-transparent\",\n          \"text-foreground/60 hover:text-foreground\",\n          \"data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-xs\",\n        ],\n        line: [\n          \"rounded-none bg-transparent\",\n          \"text-foreground/60 hover:text-foreground\",\n          \"data-[state=active]:bg-transparent data-[state=active]:text-foreground\",\n          // Underline indicator\n          \"after:absolute after:bg-foreground after:opacity-0 after:transition-opacity\",\n          \"group-data-[orientation=horizontal]/tabs-list:after:inset-x-0 group-data-[orientation=horizontal]/tabs-list:after:-bottom-1 group-data-[orientation=horizontal]/tabs-list:after:h-0.5\",\n          \"group-data-[orientation=vertical]/tabs-list:after:inset-y-0 group-data-[orientation=vertical]/tabs-list:after:-right-1 group-data-[orientation=vertical]/tabs-list:after:w-0.5\",\n          \"data-[state=active]:after:opacity-100\",\n        ],\n        pill: [\n          \"rounded-full\",\n          \"text-foreground/60 hover:bg-accent/50 hover:text-foreground\",\n          \"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground data-[state=active]:shadow-xs\",\n          \"data-[state=active]:hover:bg-primary/90\",\n        ],\n        segmented: [\n          \"rounded-md\",\n          \"text-foreground/60 hover:text-foreground\",\n          \"data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-xs\",\n        ],\n      },\n      size: {\n        sm: \"h-7 px-2.5 text-xs [&_svg]:size-3\",\n        md: \"h-9 px-3 text-sm [&_svg]:size-4\",\n        lg: \"h-10 px-4 text-base [&_svg]:size-4\",\n      },\n    },\n    defaultVariants: {\n      variant: \"default\",\n      size: \"md\",\n    },\n  }\n)\n\n// ── Helpers ─────────────────────────────────────────────────────────────────\n\nfunction TabsSkeleton({ count, variant }: { count: number; variant: string }) {\n  return (\n    <div\n      className={cn(\n        \"flex gap-2\",\n        variant === \"segmented\" && \"rounded-lg bg-muted p-0.5\",\n        variant === \"pill\" && \"gap-3\"\n      )}\n    >\n      {Array.from({ length: count }).map((_, i) => (\n        <Skeleton\n          key={i}\n          className={cn(\n            \"h-9\",\n            variant === \"segmented\" ? \"w-20 rounded-md\" : \"w-24 rounded-full\"\n          )}\n        />\n      ))}\n    </div>\n  )\n}\n\n// ── Accordion Fallback (responsive) ─────────────────────────────────────────\n\nfunction AccordionFallback({\n  items,\n  value,\n  onValueChange,\n  size,\n}: {\n  items: TabItem[]\n  value?: string\n  onValueChange?: (value: string) => void\n  size?: \"sm\" | \"md\" | \"lg\"\n}) {\n  const sizeClass =\n    size === \"sm\"\n      ? \"py-2.5 text-xs\"\n      : size === \"lg\"\n        ? \"py-4 text-base\"\n        : \"py-3 text-sm\"\n\n  return (\n    <AccordionPrimitive.Root\n      type=\"single\"\n      collapsible\n      value={value}\n      onValueChange={onValueChange}\n      data-slot=\"tabs-accordion\"\n      className=\"divide-y divide-border rounded-xl border\"\n    >\n      {items.map((item) => {\n        const Icon = item.icon\n        return (\n          <AccordionPrimitive.Item\n            key={item.value}\n            value={item.value}\n            disabled={item.disabled}\n            className=\"group/tabs-accordion-item first:rounded-t-xl last:rounded-b-xl data-open:bg-muted/30\"\n          >\n            <AccordionPrimitive.Header className=\"flex\">\n              <AccordionPrimitive.Trigger\n                data-slot=\"tabs-accordion-trigger\"\n                className={cn(\n                  \"group/tabs-accordion-trigger flex w-full items-center gap-2 px-4 text-left font-medium transition-all outline-none\",\n                  \"hover:bg-muted/30\",\n                  \"disabled:pointer-events-none disabled:opacity-50\",\n                  \"focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring\",\n                  sizeClass\n                )}\n              >\n                {Icon && <Icon className=\"size-4 shrink-0\" />}\n                <span className=\"flex-1 truncate\">{item.label}</span>\n                {item.count !== undefined && (\n                  <span className=\"inline-flex size-5 items-center justify-center rounded-full bg-muted-foreground/20 text-xs font-semibold tabular-nums\">\n                    {item.count}\n                  </span>\n                )}\n                <ChevronDown className=\"size-4 shrink-0 text-muted-foreground transition-transform group-aria-expanded/tabs-accordion-trigger:rotate-180\" />\n              </AccordionPrimitive.Trigger>\n            </AccordionPrimitive.Header>\n            <AccordionPrimitive.Content\n              data-slot=\"tabs-accordion-content\"\n              className=\"overflow-hidden px-4 pb-4 text-sm data-open:animate-accordion-down data-closed:animate-accordion-up\"\n            >\n              {item.content}\n            </AccordionPrimitive.Content>\n          </AccordionPrimitive.Item>\n        )\n      })}\n    </AccordionPrimitive.Root>\n  )\n}\n\n// ── Component ───────────────────────────────────────────────────────────────\n\nexport function Tabs({\n  items,\n  defaultValue,\n  value: controlledValue,\n  onValueChange,\n  variant = \"default\",\n  size = \"md\",\n  orientation = \"horizontal\",\n  activationMode,\n  responsive = false,\n  forceAccordion = false,\n  loading = false,\n  skeletonCount,\n  locale: localeProp,\n  className,\n}: TabsProps) {\n  const locale = useUILocale(localeProp)\n  const t = UI_I18N[locale].tabs\n  const isMobile = useIsMobile()\n  const showAccordion = forceAccordion || (responsive && isMobile)\n\n  const isControlled = controlledValue !== undefined\n  const [internalValue, setInternalValue] = React.useState(\n    defaultValue ?? items[0]?.value ?? \"\"\n  )\n  const activeValue = isControlled ? (controlledValue as string) : internalValue\n\n  const handleValueChange = React.useCallback(\n    (value: string) => {\n      if (!isControlled) setInternalValue(value)\n      onValueChange?.(value)\n    },\n    [isControlled, onValueChange]\n  )\n\n  // Loading\n  if (loading) {\n    return (\n      <TabsSkeleton\n        count={skeletonCount ?? (items.length || 3)}\n        variant={variant}\n      />\n    )\n  }\n\n  // Empty\n  if (items.length === 0) {\n    return null\n  }\n\n  // Responsive accordion fallback\n  if (showAccordion) {\n    return (\n      <AccordionFallback\n        items={items}\n        value={activeValue}\n        onValueChange={handleValueChange}\n        size={size}\n      />\n    )\n  }\n\n  // Normal tabs\n  return (\n    <TabsRoot\n      value={activeValue}\n      onValueChange={handleValueChange}\n      orientation={orientation}\n      activationMode={activationMode}\n      className={cn(orientation === \"horizontal\" && \"flex-col\", className)}\n    >\n      <TabsPrimitive.List\n        data-slot=\"ds-tabs-list\"\n        aria-label={t.tabList}\n        className={cn(dsTabsListVariants({ variant, orientation }))}\n      >\n        {items.map((item) => {\n          const Icon = item.icon\n          return (\n            <TabsPrimitive.Trigger\n              key={item.value}\n              value={item.value}\n              disabled={item.disabled}\n              data-slot=\"ds-tabs-trigger\"\n              className={cn(dsTabsTriggerVariants({ variant, size }))}\n            >\n              {Icon && <Icon />}\n              <span>{item.label}</span>\n              {item.count !== undefined && (\n                <span className=\"inline-flex h-5 min-w-5 items-center justify-center rounded-full bg-muted-foreground/20 px-1.5 text-xs leading-none font-semibold tabular-nums\">\n                  {item.count}\n                </span>\n              )}\n            </TabsPrimitive.Trigger>\n          )\n        })}\n      </TabsPrimitive.List>\n      {items.map((item) => (\n        <TabsContent key={item.value} value={item.value}>\n          {item.content}\n        </TabsContent>\n      ))}\n    </TabsRoot>\n  )\n}\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}
