{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "switcher-layout",
  "type": "registry:item",
  "title": "Switcher Layout",
  "description": "Children side by side in equal columns while the container is wide enough, and stacked one above the other below `threshold` (the container's width, not the screen's, so it works in a sidebar as well as the page). More than `limit` children always stack. Every child switches at once: no awkward row of two over one.",
  "dependencies": [
    "@zubra/runtime@^5.13.1"
  ],
  "categories": [
    "layout"
  ],
  "registryDependencies": [
    "https://zubra-js.github.io/zubra-ui/r/theme.json"
  ],
  "files": [
    {
      "path": "components/switcher-layout.js",
      "type": "registry:file",
      "target": "~/src/components/zubra/switcher-layout.js",
      "content": "// Generated by zubra from switcher-layout.zb. Do not edit.\nimport { $define, $r, $t } from \"@zubra/runtime\";\nimport { onMount } from '@zubra/runtime';\nimport { state as __zubraState, computed as __zubraComputed } from \"@zubra/runtime\";\n\nexport const tag = \"switcher-layout\";\n\nexport default $define(tag, {\n  props: {\n    \"threshold\": { attribute: \"threshold\", default: \"30rem\", required: false },\n    \"gap\": { attribute: \"gap\", default: \"1rem\", required: false },\n    \"limit\": { attribute: \"limit\", default: 4, required: false },\n    \"align\": { attribute: \"align\", default: \"stretch\", required: false },\n  },\n  abi: 3,\n  shadow: false,\n  form: false,\n  slots: [\"default\"],\n  events: [],\n  styled: true,\n  styles: \"@layer theme, base, components, utilities;\\n@layer components {\\n@scope (switcher-layout) to ([data-zb-slotted=\\\"switcher-layout\\\"]) {\\n  :scope { display: block; }\\n  .switcher-grid { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: var(--gap); align-items: var(--align); }\\n  .switcher-stacked { grid-auto-flow: row; grid-auto-columns: auto; }\\n  .switcher-probe { position: absolute; width: var(--threshold); height: 0; visibility: hidden; pointer-events: none; }\\n}\\n}\\n\",\n  template: \"\\n  <span class=\\\"switcher-probe\\\" aria-hidden=\\\"true\\\"></span>\\n  <div class=\\\"switcher-grid\\\"><!--[--><!--]--></div>\\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  const box = __zubraState(null)\n  const probe = __zubraState(null)\n  const stacked = __zubraState(false)\n\n  // CSS can't compare a container's width with a custom property, so this measures both.\n  onMount(() => {\n    const check = () => {\n      __zubraAssign(stacked, box.get().children.length > $p.limit || box.get().clientWidth < probe.get().offsetWidth)\n    }\n    const sizes = new ResizeObserver(check)\n    sizes.observe(box.get())\n    const children = new MutationObserver(check)\n    children.observe(box.get(), { childList: true })\n    check()\n    return () => { sizes.disconnect(); children.disconnect() }\n  })\n    return [\n      { path: [0], ref: () => (($el) => (__zubraAssign(probe, $el))) },\n      { path: [0], style: \"--threshold\", value: () => $p.threshold },\n      { path: [1], toggle: \"switcher-stacked\", value: () => $r(stacked) },\n      { path: [1], ref: () => (($el) => (__zubraAssign(box, $el))) },\n      { path: [1], style: \"--gap\", value: () => $p.gap },\n      { path: [1], style: \"--align\", value: () => $p.align },\n      { path: [1, 0], slot: \"default\", fallback: null },\n    ];\n  },\n});\n"
    }
  ]
}
