{"schemaVersion":1,"slug":"component-focus-grid","kind":"component","version":"0.1.0","files":[{"path":"Component.jsx","content":"'use client'\nimport React from 'react'\nimport Example from './focus-grid.jsx'\nimport './collection.css'\nexport default function Component(props) {\n  return <div className=\"lq-component\" data-family=\"navigation\"><Example {...props}/></div>\n}\n","sha256":"25488cccccc5639682c7f3ef173fe7f89d570addfeb5d157364075e661a2d5c6"},{"path":"focus-grid.jsx","content":"'use client'\nimport React, { useRef, useState } from 'react'\nimport { Stage, Status, labels } from './shared.jsx'\nexport default function Grid({ locale = 'en' }) {\n  const t = labels(locale),\n    [cursor, move] = useState(0),\n    [selected, open] = useState(null),\n    buttons = useRef([])\n  const id = (i) => 'ABC'[Math.floor(i / 3)] + ((i % 3) + 1)\n  function navigate(e, i) {\n    const row = Math.floor(i / 3) * 3\n    const target = {\n      ArrowRight: Math.min(row + 2, i + 1),\n      ArrowLeft: Math.max(row, i - 1),\n      ArrowUp: Math.max(i % 3, i - 3),\n      ArrowDown: Math.min(6 + (i % 3), i + 3),\n      Home: e.ctrlKey ? 0 : row,\n      End: e.ctrlKey ? 8 : row + 2,\n    }[e.key]\n    if (target !== undefined) {\n      e.preventDefault()\n      move(target)\n      buttons.current[target]?.focus()\n    }\n  }\n  return (\n    <Stage locale={locale}>\n      <p>\n        {t(\n          'Use arrow keys to move. Enter opens a desk.',\n          '用方向键移动，按 Enter 打开席位。',\n          'Usa las flechas para moverte y pulsa Intro para abrir una mesa.',\n          '矢印キーで移動し、Enter で席を開きます。',\n        )}\n      </p>\n      <table role=\"grid\" aria-label={t('Reading desks', '阅读席', 'Mesas de lectura', '閲覧席')}>\n        <tbody>\n          {[0, 1, 2].map((row) => (\n            <tr key={row}>\n              {[0, 1, 2].map((col) => {\n                const i = row * 3 + col\n                return (\n                  <td key={col} aria-selected={i === selected}>\n                    <button\n                      ref={(el) => {\n                        buttons.current[i] = el\n                      }}\n                      tabIndex={i === cursor ? 0 : -1}\n                      onFocus={() => move(i)}\n                      onKeyDown={(e) => navigate(e, i)}\n                      onClick={() => {\n                        move(i)\n                        open(i)\n                      }}\n                    >\n                      {id(i)}\n                    </button>\n                  </td>\n                )\n              })}\n            </tr>\n          ))}\n        </tbody>\n      </table>\n      <Status>\n        {selected === null\n          ? t('Choose a desk', '请选择席位', 'Elige una mesa', '席を選択')\n          : t('Desk', '阅读席', 'Mesa', '閲覧席') +\n            ' ' +\n            id(selected) +\n            ' · ' +\n            [\n              t('Window', '临窗', 'Ventana', '窓側'),\n              t('Quiet zone', '静音区', 'Zona tranquila', '静音エリア'),\n              t('Shared table', '共享桌', 'Mesa compartida', '共有机'),\n            ][Math.floor(selected / 3)]}\n      </Status>\n    </Stage>\n  )\n}\n","sha256":"65e3d0c9cc1db9df9298e4e1adbf8d094701c92f6c554fec7288c338c668de4a"},{"path":"collection.css","content":"/* Portable styles for the optional wrapper in Component.jsx. */\n.lq-component {\n  --cc-ink:#162632; --cc-muted:#526572; --cc-stroke:#cbd5dc; --cc-tint:#edf3f6;\n  --cc-blue:#426981; --cc-surface:#fff; --cc-inverse:#fff;\n  font:400 15px/1.55 system-ui,sans-serif; color:var(--cc-ink);\n  min-width:0; width:100%; overflow-wrap:anywhere; color-scheme:light;\n}\n.lq-component *, .lq-component *::before,.lq-component *::after { box-sizing:border-box; }\n.lq-component :is(h2,h3,h4,p,ul,ol,dl,form,fieldset,figure,table) { margin:0 0 .85em; }\n.lq-component :is(h2,h3) { font-size:clamp(20px,2vw,29px); line-height:1.18; letter-spacing:-.035em; }\n.lq-component h4 {font-size:1rem}\n.lq-component :is(ol,ul){padding-inline-start:1.4em}\n.lq-component label { display:inline-flex; flex-direction:column; gap:4px; max-width:100%; font-size:14px; font-weight:550; }\n.lq-component label:has(input[type=checkbox]),.lq-component label:has(input[type=radio]) {flex-direction:row;align-items:center}\n.lq-component :is(input,select,textarea,button){font:inherit;max-width:100%;accent-color:var(--cc-blue)}\n.lq-component :is(input:not([type=checkbox],[type=radio],[type=range],[type=file]),select,textarea){\n  color:var(--cc-ink); background:var(--cc-surface); border:1px solid #a9bac5; border-radius:6px; padding:7px 10px;min-width:0;\n}\n.lq-component textarea{min-height:64px}\n.lq-component :is(button,summary){cursor:pointer;}\n.lq-component button{\n  color:var(--cc-ink);background:var(--cc-tint);border:1px solid var(--cc-stroke);\n  border-radius:6px;min-height:35px;padding:5px 11px;font-weight:600;font-size:14px;\n}\n.lq-component button:disabled{opacity:.5;cursor:default}\n.lq-component button[aria-pressed=true],.lq-component [role=tab][aria-selected=true]{background:var(--cc-ink);color:var(--cc-inverse)}\n.lq-component :focus-visible{outline:2px solid var(--cc-blue);outline-offset:2px}\n.lq-component output {display:block;color:var(--cc-ink);font-weight:650;font-variant-numeric:tabular-nums}\n.lq-component :is(.collection-actions,.collection-row,.demo-actions){display:flex;align-items:end;gap:9px;flex-wrap:wrap;margin-block:12px}\n.lq-component :is(.collection-fields,.form-fields){display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,180px),1fr));gap:14px;margin-block:14px}\n.lq-component :is(.collection-output,.demo-output){padding:12px;border-inline-start:3px solid var(--cc-blue);background:var(--cc-tint);margin-block:14px}\n.lq-component fieldset {border:1px solid var(--cc-stroke);border-radius:8px;padding:12px;min-width:0}\n.lq-component .collection-demo>*,.lq-component .viz-study>*{max-width:100%}\n.lq-component :is(form,fieldset)>label {margin:0 10px 10px 0}\n.lq-component :is(button+button,label+button) {margin-inline-start:3px}\n.lq-component table{width:100%;border-collapse:collapse;font-variant-numeric:tabular-nums;overflow-wrap:anywhere}\n.lq-component :is(th,td){padding:6px;text-align:start;border-bottom:1px solid var(--cc-stroke)}\n.lq-component dialog{max-width:min(90vw,500px);border:1px solid var(--cc-stroke);border-radius:10px;padding:20px;color:var(--cc-ink);background:white}\n.lq-component dialog::backdrop{background:rgb(17 29 39/.45)}\n.lq-component :is(svg,canvas,img){max-width:100%}\n@media(hover:hover){.lq-component button:not(:disabled):hover{border-color:var(--cc-blue)}}\n@media(pointer:coarse){.lq-component button,.lq-component select,.lq-component input[type=range]{min-height:44px}}\n@media(prefers-reduced-motion:reduce){.lq-component *, .lq-component *::before,.lq-component *::after{animation-duration:0s!important;transition-duration:0s!important;scroll-behavior:auto!important}}\n.lq-component :is(.viz-study,.wf-demo,.collection-demo)>label {margin:0 16px 12px 0}\n.lq-component .viz-study>svg[role=img]{display:block;margin:6px 0 14px}\n.lq-component .viz-study>output{border-top:1px solid var(--cc-stroke);padding:12px 0 0;font-variant-numeric:tabular-nums}\n.lq-component :is(.wf-demo,.collection-demo) form{display:flex;align-items:end;flex-wrap:wrap;gap:9px 14px}\n.lq-component :is(.wf-demo,.collection-demo) label textarea{width:min(100%,34rem)}\n.lq-component :is(.wf-demo,.collection-demo)>:is(output,[role=status]){display:block;margin-top:12px;color:var(--cc-blue);font-weight:600}\n.lq-component .collection-fields>.collection-row,.lq-component .collection-fields>.collection-output,.lq-component .collection-fields>svg{grid-column:1/-1}\n","sha256":"9a629a50c65fc07377b3d164b571ed33b8bd54c392ff4dab06c4fd317c0864ab"},{"path":"shared.jsx","content":"'use client'\nimport React, { useEffect, useRef } from 'react'\nexport function words(locale, ...values) {\n  return values[{ en: 0, 'zh-CN': 1, es: 2, ja: 3 }[locale] ?? 0] || values[0]\n}\nexport const labels =\n  (locale) =>\n  (...values) =>\n    words(locale, ...values)\nexport function fixtures(t) {\n  return [\n    t('Field notes', '实地笔记', 'Notas de campo', 'フィールドノート'),\n    t('Release brief', '发布简报', 'Ficha de lanzamiento', 'リリース概要'),\n    t('Design review', '设计审阅', 'Revisión de diseño', 'デザインレビュー'),\n  ]\n}\nexport function Stage({ children, locale }) {\n  return (\n    <section className=\"collection-demo\" lang={locale}>\n      {children}\n    </section>\n  )\n}\nexport function Actions({ children }) {\n  return <div className=\"collection-actions\">{children}</div>\n}\nexport function Status({ children }) {\n  return (\n    <p role=\"status\" aria-live=\"polite\" aria-atomic=\"true\">\n      {children}\n    </p>\n  )\n}\nexport function Dialog({ title, onClose, children }) {\n  const ref = useRef(null)\n  useEffect(() => {\n    const dialog = ref.current,\n      trigger = document.activeElement\n    dialog.showModal()\n    return () => {\n      if (dialog.open) dialog.close()\n      if (trigger?.isConnected) trigger.focus()\n    }\n  }, [])\n  return (\n    <dialog\n      ref={ref}\n      aria-label={title}\n      onCancel={(e) => {\n        e.stopPropagation()\n        e.preventDefault()\n        onClose()\n      }}\n    >\n      <h3>{title}</h3>\n      {children}\n    </dialog>\n  )\n}\n","sha256":"1f5fcfc55fa58b6f5f5c0a911e6bca0a3213beb3390beb6ae347ae4e89e10428"},{"path":"README.md","content":"# Spatial focus grid\n\nNavigate nine reading desks by row and column, then open a desk without tabbing through every cell.\n\nImport the default export from Component.jsx into a React client entry. The locale prop accepts en, zh-CN, es and ja. Use your host’s existing React dependency and test and build commands. The sample runs locally.\n","sha256":"b3cbb81d7d0493656c0d0580c06535262e90ca88c0af3c5f9b674b6a58f07267"}]}
