{
  "name": "resizable",
  "type": "ui:component",
  "title": "ResizableSplit",
  "description": "Pointer- and keyboard-accessible split-pane layout (horizontal/vertical) with drag handle.",
  "dependencies": [
    "@lucide/icons"
  ],
  "registryDependencies": [
    "theme",
    "icon"
  ],
  "files": [
    {
      "path": "src/ui/resizable.tsx",
      "target": "src/ui/resizable.tsx",
      "sha256": "ba29b31ae7e62b2541f7a9b2eea96374622033490013eda899f199a039e24e57",
      "content": "import './theme.css';\nimport { GripVertical } from '@lucide/icons';\nimport { scope, type Ctx, type View } from '@fierst/aster';\nimport { Icon } from './icon';\n\nconst resScope = scope`\n  :scope {\n    display: flex;\n    width: 100%;\n    min-height: 200px;\n    border: 1px solid var(--aster-border);\n    border-radius: var(--aster-radius-lg);\n    background: var(--aster-surface);\n    overflow: hidden;\n    font-family: var(--aster-font-sans);\n  }\n  :scope.dir-vertical { flex-direction: column; }\n  .pane {\n    min-width: 0;\n    min-height: 0;\n    overflow: auto;\n    padding: 1rem;\n  }\n  .handle {\n    position: relative;\n    flex: 0 0 auto;\n    width: 9px;\n    background: var(--aster-border);\n    background-clip: content-box;\n    padding: 0 4px;\n    cursor: col-resize;\n    display: grid;\n    place-items: center;\n    touch-action: none;\n    user-select: none;\n    transition: background-color var(--aster-dur-fast);\n  }\n  :scope.dir-vertical .handle {\n    width: auto;\n    height: 9px;\n    padding: 4px 0;\n    cursor: row-resize;\n  }\n  .handle:hover,\n  .handle.is-dragging { background-color: var(--aster-primary); }\n  .handle:focus-visible { outline: none; background-color: var(--aster-primary); box-shadow: var(--aster-focus-ring); }\n  .grip {\n    width: 18px;\n    height: 24px;\n    border-radius: var(--aster-radius-xs);\n    border: 1px solid var(--aster-border);\n    background: var(--aster-surface);\n    color: var(--aster-on-surface-subtle);\n    display: inline-grid;\n    place-items: center;\n    box-shadow: var(--aster-shadow-xs);\n    pointer-events: none;\n  }\n  :scope.dir-vertical .grip { transform: rotate(90deg); }\n\n  @media (max-width: 639px) {\n    :scope.dir-horizontal.stack-mobile {\n      flex-direction: column;\n      height: auto !important;\n    }\n    :scope.dir-horizontal.stack-mobile > .pane {\n      flex: none !important;\n      width: 100% !important;\n      max-height: 260px;\n    }\n    :scope.dir-horizontal.stack-mobile > .handle {\n      width: 100%;\n      height: 1px;\n      padding: 0;\n      cursor: default;\n      pointer-events: none;\n    }\n    :scope.dir-horizontal.stack-mobile > .handle .grip {\n      display: none;\n    }\n  }\n`;\n\nexport function* ResizableSplit(\n  props: {\n    direction?: 'horizontal' | 'vertical';\n    defaultSplit?: number;\n    min?: number;\n    max?: number;\n    height?: string;\n    /** Automatically stack horizontal panes vertically on mobile (< 640px). Default: true. */\n    stackOnMobile?: boolean;\n    first: View;\n    second: View;\n    onResize?: (pct: number) => void;\n    class?: string;\n  },\n  ctx: Ctx,\n) {\n  let split = props.defaultSplit ?? 50;\n  let dragging = false;\n  let rootEl: HTMLDivElement | null = null;\n\n  for (props of ctx) {\n    const dir = props.direction ?? 'horizontal';\n    const min = props.min ?? 20;\n    const max = props.max ?? 80;\n    split = Math.max(min, Math.min(max, split));\n    const stackOnMobile = props.stackOnMobile ?? true;\n\n    const updateSplit = (next: number) => {\n      const clamped = Math.max(min, Math.min(max, Math.round(next)));\n      if (clamped !== split) {\n        split = clamped;\n        props.onResize?.(clamped);\n        ctx.refresh();\n      }\n    };\n\n    const onPointerDown = (e: Event) => {\n      const target = e.currentTarget as HTMLElement;\n      target.setPointerCapture?.((e as PointerEvent).pointerId);\n      dragging = true;\n      ctx.refresh();\n\n      const onMove = (ev: Event) => {\n        if (!rootEl) return;\n        const rect = rootEl.getBoundingClientRect();\n        if (!(dir === 'horizontal' ? rect.width : rect.height)) return;\n        const ratio =\n          dir === 'horizontal'\n            ? (((ev as MouseEvent).clientX - rect.left) / rect.width) * 100\n            : (((ev as MouseEvent).clientY - rect.top) / rect.height) * 100;\n        updateSplit(ratio);\n      };\n      const onUp = () => {\n        dragging = false;\n        window.removeEventListener('pointermove', onMove);\n        window.removeEventListener('pointerup', onUp);\n        window.removeEventListener('pointercancel', onUp);\n        ctx.refresh();\n      };\n      window.addEventListener('pointermove', onMove, { signal: ctx.signal });\n      window.addEventListener('pointerup', onUp, { signal: ctx.signal });\n      window.addEventListener('pointercancel', onUp, { signal: ctx.signal });\n    };\n\n    const onKeyDown = (e: Event) => {\n      const decKey = dir === 'horizontal' ? 'ArrowLeft' : 'ArrowUp';\n      const incKey = dir === 'horizontal' ? 'ArrowRight' : 'ArrowDown';\n      if ((e as KeyboardEvent).key === decKey) {\n        e.preventDefault();\n        updateSplit(split - 5);\n      } else if ((e as KeyboardEvent).key === incKey) {\n        e.preventDefault();\n        updateSplit(split + 5);\n      } else if ((e as KeyboardEvent).key === 'Home') {\n        e.preventDefault();\n        updateSplit(min);\n      } else if ((e as KeyboardEvent).key === 'End') {\n        e.preventDefault();\n        updateSplit(max);\n      }\n    };\n\n    yield (\n      <div\n        ref={(el: HTMLDivElement) => (rootEl = el)}\n        class={[\n          resScope,\n          dir === 'vertical' ? 'dir-vertical' : 'dir-horizontal',\n          stackOnMobile ? 'stack-mobile' : '',\n          props.class,\n        ]\n          .filter(Boolean)\n          .join(' ')}\n        style={props.height ? { height: props.height } : undefined}\n      >\n        <div class=\"pane\" style={{ flex: `0 0 ${split}%` }}>\n          {props.first}\n        </div>\n        <div\n          role=\"separator\"\n          tabIndex={0}\n          aria-orientation={dir === 'horizontal' ? 'vertical' : 'horizontal'}\n          aria-valuenow={split}\n          aria-valuemin={min}\n          aria-valuemax={max}\n          aria-label=\"Resize panels\"\n          class=\"handle\"\n          class:is-dragging={dragging}\n          on:pointerdown={onPointerDown}\n          onKeyDown={onKeyDown}\n        >\n          <span class=\"grip\" aria-hidden=\"true\">\n            <Icon icon={GripVertical} size={12} />\n          </span>\n        </div>\n        <div class=\"pane\" style={{ flex: '1 1 0%' }}>\n          {props.second}\n        </div>\n      </div>\n    );\n  }\n}\n"
    }
  ]
}
