{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "dropdown-menu",
  "type": "registry:item",
  "title": "Dropdown Menu",
  "description": "A menu of actions behind a button, on the platform's `popover`: the browser puts it in the top layer and closes it on Escape or a click outside. Down or Up on the button opens it; arrow keys, Home, End and typing a letter move among the items; Enter or Space picks one, and focus goes back to the button. It's placed below the button by CSS anchor positioning, or by script where that isn't supported. `items` is `[{ value, label, disabled? }]`.",
  "dependencies": [
    "@zubra/runtime@^5.13.1"
  ],
  "categories": [
    "widget"
  ],
  "registryDependencies": [
    "https://zubra-js.github.io/zubra-ui/r/theme.json"
  ],
  "files": [
    {
      "path": "components/dropdown-menu.js",
      "type": "registry:file",
      "target": "~/src/components/zubra/dropdown-menu.js",
      "content": "// Generated by zubra from dropdown-menu.zb. Do not edit.\nimport { $define, $r, $t } from \"@zubra/runtime\";\nimport { id, emit, onMount } from '@zubra/runtime';\nimport { rovingFocus, typeahead } from '@zubra/runtime/primitives';\nimport { state as __zubraState, computed as __zubraComputed } from \"@zubra/runtime\";\n\nexport const tag = \"dropdown-menu\";\n\nexport default $define(tag, {\n  props: {\n    \"label\": { attribute: \"label\", default: \"Options\", required: false },\n    \"items\": { attribute: \"items\", default: [], required: false },\n  },\n  abi: 3,\n  shadow: false,\n  form: false,\n  slots: [\"label\"],\n  events: [\"itemselect\"],\n  styled: true,\n  styles: \"@layer theme, base, components, utilities;\\n@layer components {\\n@scope (dropdown-menu) to ([data-zb-slotted=\\\"dropdown-menu\\\"]) {\\n  :scope { display: inline-block; }\\n  .trigger { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.45rem 0.8rem; border: 1px solid var(--border, #dde); border-radius: calc(var(--radius, 0.625rem) * 0.8); background: var(--card, #fff); color: inherit; font: inherit; cursor: pointer; }\\n  .trigger::after { content: \\\"\\\"; width: 0.35rem; height: 0.35rem; border: solid currentColor; border-width: 0 2px 2px 0; transform: translateY(-2px) rotate(45deg); }\\n  [popover] { position: fixed; inset: auto; margin: 0; min-width: 11rem; padding: 0.3rem; border: 1px solid var(--border, #dde); border-radius: calc(var(--radius, 0.625rem) * 0.96); background: var(--card, #fff); color: var(--foreground, #1d2130); box-shadow: 0 8px 24px #0d122026; }\\n  @supports (position-area: bottom) {\\n    [popover] { position-area: bottom span-right; position-try-fallbacks: flip-block; margin-top: 4px; }\\n  }\\n  /* Opening and closing: a quick fade and scale from the trigger's side. */\\n  [popover] { opacity: 0; scale: 0.96; translate: 0 -0.25rem; transition: opacity var(--duration-fast, 150ms) var(--ease-out, ease-out), scale var(--duration-fast, 150ms) var(--ease-out, ease-out), translate var(--duration-fast, 150ms) var(--ease-out, ease-out), overlay var(--duration-fast, 150ms) allow-discrete, display var(--duration-fast, 150ms) allow-discrete; }\\n  [popover]:popover-open { opacity: 1; scale: 1; translate: 0; }\\n  @starting-style { [popover]:popover-open { opacity: 0; scale: 0.96; translate: 0 -0.25rem; } }\\n  @media (prefers-reduced-motion: reduce) { *, *::before, *::after, ::backdrop { transition-duration: 0s !important; animation-duration: 0s !important; } }\\n  [role=menuitem] { display: block; width: 100%; padding: 0.4rem 0.6rem; border: 0; border-radius: calc(var(--radius, 0.625rem) * 0.64); background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }\\n  [role=menuitem]:hover, [role=menuitem]:focus { background: var(--accent, #f2f4f8); outline: none; }\\n  [role=menuitem]:disabled { color: var(--muted-foreground, #98a2b3); cursor: default; }\\n}\\n}\\n\",\n  template: \"\\n  <button type=\\\"button\\\" class=\\\"trigger\\\" aria-haspopup=\\\"menu\\\"><!--[--><!--]--></button>\\n  <div popover role=\\\"menu\\\">\\n    <!--[--><!--]-->\\n  </div>\\n\",\n  setup($p, $emit) {\n    const emit = $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 menuId = id()\n  const buttonId = id()\n  const anchored = typeof CSS !== \"undefined\" && CSS.supports(\"position-area: bottom\")\n  const button = __zubraState(null)\n  const menu = __zubraState(null)\n  const open = __zubraState(false)\n  const last = __zubraState(false) // open at the last item (Up on the button)\n\n  const entries = () => [...menu.get().querySelectorAll(\"[role=menuitem]:not(:disabled)\")]\n\n  function toggled(event) {\n    __zubraAssign(open, event.newState === \"open\")\n    if (open.get()) {\n      if (!anchored) place()\n      const all = entries()\n      ;(last.get() ? all.at(-1) : all[0])?.focus()\n      __zubraAssign(last, false)\n    } else if (menu.get().contains(document.activeElement) || document.activeElement === document.body) {\n      button.get().focus()\n    }\n  }\n  function keys(event) {\n    if (event.key !== \"ArrowDown\" && event.key !== \"ArrowUp\") return\n    event.preventDefault()\n    __zubraAssign(last, event.key === \"ArrowUp\")\n    menu.get().showPopover()\n  }\n  function choose(item) {\n    menu.get().hidePopover()\n    button.get().focus()\n    emit(\"itemselect\", item.value)\n  }\n  // Tab out of the menu closes it, as menus do.\n  function left(event) {\n    if (open.get() && !menu.get().contains(event.relatedTarget) && event.relatedTarget !== button.get()) menu.get().hidePopover()\n  }\n  // Without anchor positioning: below the button, or above it if there's no room.\n  function place() {\n    const at = button.get().getBoundingClientRect()\n    const own = menu.get().getBoundingClientRect()\n    menu.get().style.top = `${at.bottom + 4 + own.height <= innerHeight ? at.bottom + 4 : Math.max(4, at.top - own.height - 4)}px`\n    menu.get().style.left = `${Math.min(at.left, innerWidth - own.width - 4)}px`\n  }\n\n  onMount(() => {\n    const roving = rovingFocus(menu.get(), { selector: \"[role=menuitem]\", orientation: \"vertical\" })\n    const typing = typeahead(menu.get(), { selector: \"[role=menuitem]\" })\n    return () => { roving(); typing() }\n  })\n    return [\n      { path: [0], attribute: \"id\", value: () => $r(buttonId) },\n      { path: [0], ref: () => (($el) => (__zubraAssign(button, $el))) },\n      { path: [0], attribute: \"popovertarget\", value: () => $r(menuId) },\n      { path: [0], attribute: \"aria-expanded\", value: () => ($r(open) ? \"true\" : \"false\") },\n      { path: [0], style: \"anchor-name\", value: () => (`--${menuId}`) },\n      { path: [0], on: \"keydown\", handler: () => $r(keys) },\n      { path: [0, 0], slot: \"label\", fallback: { template: \"<!---->\", parts: () => [{ path: [0], anchor: () => $t($p.label) }] } },\n      { path: [1], attribute: \"id\", value: () => $r(menuId) },\n      { path: [1], attribute: \"aria-labelledby\", value: () => $r(buttonId) },\n      { path: [1], ref: () => (($el) => (__zubraAssign(menu, $el))) },\n      { path: [1], style: \"position-anchor\", value: () => (`--${menuId}`) },\n      { path: [1], on: \"toggle\", handler: () => $r(toggled) },\n      { path: [1], on: \"focusout\", handler: () => $r(left) },\n      { path: [1, 0], each: () => $p.items, key: (item, $index) => $r(item).value, block: { template: \"\\n      <button type=\\\"button\\\" role=\\\"menuitem\\\" tabindex=\\\"-1\\\"></button>\\n    \", parts: (item, $index) => [{ path: [0], attribute: \"disabled\", boolean: true, value: () => !(!($r(item).disabled)) }, { path: [0], on: \"click\", handler: () => (() => choose($r(item))) }, { path: [0], text: () => $t($r(item).label) }] } },\n    ];\n  },\n});\n"
    }
  ]
}
