{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tab-list",
  "type": "registry:item",
  "title": "Tab List",
  "description": "Tabs: a tab list and the panels it switches between. The panels are the slotted elements with a `data-tab` attribute matching a tab's value; they get role=tabpanel, are labelled by their tab, and are hidden unless chosen. Arrow keys, Home and End move between the tabs (one tab stop), and the focused tab is chosen as it moves, unless `manual`, where Enter or Space chooses it. `tabs` is `[{ value, label }]`; `value` is two-way and defaults to the first tab.",
  "dependencies": [
    "@zubra/runtime@^5.13.1"
  ],
  "categories": [
    "widget"
  ],
  "registryDependencies": [
    "https://zubra-js.github.io/zubra-ui/r/theme.json"
  ],
  "files": [
    {
      "path": "components/tab-list.js",
      "type": "registry:file",
      "target": "~/src/components/zubra/tab-list.js",
      "content": "// Generated by zubra from tab-list.zb. Do not edit.\nimport { $define, $r, $t } from \"@zubra/runtime\";\nimport { id, host, effect, onMount } from '@zubra/runtime';\nimport { rovingFocus } from '@zubra/runtime/primitives';\nimport { state as __zubraState, computed as __zubraComputed } from \"@zubra/runtime\";\n\nexport const tag = \"tab-list\";\n\nexport default $define(tag, {\n  props: {\n    \"value\": { attribute: \"value\", default: \"\", required: false, model: true },\n    \"tabs\": { attribute: \"tabs\", default: [], required: false },\n    \"label\": { attribute: \"label\", default: \"\", required: false },\n    \"manual\": { attribute: \"manual\", default: false, required: false },\n  },\n  abi: 3,\n  shadow: false,\n  form: false,\n  slots: [\"default\"],\n  events: [\"valuechange\"],\n  styled: true,\n  styles: \"@layer theme, base, components, utilities;\\n@layer components {\\n@scope (tab-list) to ([data-zb-slotted=\\\"tab-list\\\"]) {\\n  :scope { display: block; }\\n  [role=tablist] { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border, #dde); }\\n  [role=tab] { padding: 0.55rem 0.9rem; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: none; color: var(--muted-foreground, #667085); font: inherit; font-weight: 600; cursor: pointer; }\\n  [role=tab][aria-selected=true] { color: var(--foreground, #1d2130); border-bottom-color: var(--primary, #36c); }\\n  [role=tab]:focus-visible { outline: 2px solid var(--primary, #36c); outline-offset: -2px; border-radius: calc(var(--radius, 0.625rem) * 0.48); }\\n  [role=tabpanel] { padding: 1rem 0.25rem; }\\n  /* The panel a tab shows fades up into place. */\\n  [role=tabpanel]:not([hidden]) { animation: panel-in var(--duration-normal, 200ms) var(--ease-out, ease-out); }\\n  @keyframes panel-in { from { opacity: 0; translate: 0 0.35rem; } }\\n  @media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; animation-iteration-count: 1 !important; } }\\n  [role=tabpanel]:focus-visible { outline: 2px solid var(--primary, #36c); outline-offset: 2px; }\\n}\\n}\\n\",\n  template: \"\\n  <div role=\\\"tablist\\\">\\n    <!--[--><!--]-->\\n  </div>\\n  <!--[--><!--]-->\\n\",\n  setup($p, $emit) {\nfunction __zubraAssign(signal, value) { signal.set(value); return value }\nfunction __zubraUpdate(signal, delta, prefix) { const old = signal.get(); signal.set(old + delta); return prefix ? old + delta : old }\n                                                            \n                                                         \n\n  const uid = id()\n  const element = host()\n  const current = __zubraComputed(() => ($p.value || $p.tabs[0]?.value || \"\"))\n  const list = __zubraState(null)\n  /** Counts changes to the panels themselves: one added or taken away, or its `data-tab` changed. */\n  const panelChanges = __zubraState(0)\n\n  const tabId = (tab) => `${uid}-tab-${tab}`\n  const panels = () => [...element.querySelectorAll(\"[data-tab]\")].filter((panel) => panel.closest(\"tab-list\") === element)\n\n  // The panels are the page's elements, not this template's: set them up here.\n  effect(() => {\n    if (!list.get()) return\n    const chosen = current.get()\n    $p.tabs.length // and again when the tabs change\n    panelChanges.get() // and when the panels do\n    for (const panel of panels()) {\n      panel.id ||= `${uid}-panel-${panel.dataset.tab}`\n      panel.setAttribute(\"role\", \"tabpanel\")\n      panel.setAttribute(\"aria-labelledby\", tabId(panel.dataset.tab))\n      if (!panel.hasAttribute(\"tabindex\")) panel.tabIndex = 0\n      panel.hidden = panel.dataset.tab !== chosen\n      list.get().querySelector(`[data-value=\"${CSS.escape(panel.dataset.tab)}\"]`)?.setAttribute(\"aria-controls\", panel.id)\n    }\n  })\n\n  // A framework may add a panel after the tabs have chosen, or change a panel's tab in the same\n  // pass as it changes `value`, after this has run: watch for both, and set the panels up again.\n  onMount(() => {\n    const isPanel = (node) => node.nodeType === 1 && (node.hasAttribute(\"data-tab\") || node.querySelector(\"[data-tab]\") !== null)\n    const watch = new MutationObserver((records) => {\n      if (records.some((record) => record.type === \"attributes\" || [...record.addedNodes, ...record.removedNodes].some(isPanel))) __zubraAssign(panelChanges, panelChanges.get() + (1))\n    })\n    watch.observe(element, { childList: true, subtree: true, attributes: true, attributeFilter: [\"data-tab\"] })\n    return () => watch.disconnect()\n  })\n\n  onMount(() => rovingFocus(list.get(), {\n    selector: \"[role=tab]\",\n    orientation: \"horizontal\",\n    onMove: (tab) => { if (!$p.manual) $p.value = tab.dataset.value },\n  }))\n    return [\n      { path: [0], attribute: \"aria-label\", value: () => ($p.label || null) },\n      { path: [0], ref: () => (($el) => (__zubraAssign(list, $el))) },\n      { path: [0, 0], each: () => $p.tabs, key: (tab, $index) => $r(tab).value, block: { template: \"\\n      <button type=\\\"button\\\" role=\\\"tab\\\"></button>\\n    \", parts: (tab, $index) => [{ path: [0], attribute: \"id\", value: () => (tabId($r(tab).value)) }, { path: [0], attribute: \"data-value\", value: () => $r(tab).value }, { path: [0], attribute: \"aria-selected\", value: () => (($r(tab).value === $r(current)) ? \"true\" : \"false\") }, { path: [0], attribute: \"tabindex\", value: () => (($r(tab).value === $r(current)) ? 0 : -(1)) }, { path: [0], on: \"click\", handler: () => (() => ($p.value = $r(tab).value)) }, { path: [0], text: () => $t($r(tab).label) }] } },\n      { path: [1], slot: \"default\", fallback: null },\n    ];\n  },\n});\n"
    }
  ]
}
