@sportsdataverse/sdvtables 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/NOTICE.md +4 -0
- package/README.md +519 -2
- package/data/table_themes.json +12136 -0
- package/data/table_themes.json.sha256 +1 -0
- package/dist/aggrid.d.ts +104 -0
- package/dist/aggrid.js +230 -0
- package/dist/aggrid.js.map +1 -0
- package/dist/chunk-3TJR7TKS.js +223 -0
- package/dist/chunk-3TJR7TKS.js.map +1 -0
- package/dist/chunk-R375P3MN.js +2315 -0
- package/dist/chunk-R375P3MN.js.map +1 -0
- package/dist/chunk-UTOVFIFT.js +15176 -0
- package/dist/chunk-UTOVFIFT.js.map +1 -0
- package/dist/chunk-VLF2S6VW.js +181 -0
- package/dist/chunk-VLF2S6VW.js.map +1 -0
- package/dist/chunk-WBTFIGYK.js +189 -0
- package/dist/chunk-WBTFIGYK.js.map +1 -0
- package/dist/engine-BFIPJUlC.d.ts +190 -0
- package/dist/export.d.ts +88 -0
- package/dist/export.js +310 -0
- package/dist/export.js.map +1 -0
- package/dist/html.d.ts +333 -0
- package/dist/html.js +6 -0
- package/dist/html.js.map +1 -0
- package/dist/index.d.ts +264 -0
- package/dist/index.js +141 -0
- package/dist/index.js.map +1 -0
- package/dist/mui.d.ts +134 -0
- package/dist/mui.js +193 -0
- package/dist/mui.js.map +1 -0
- package/dist/react.d.ts +72 -0
- package/dist/react.js +184 -0
- package/dist/react.js.map +1 -0
- package/dist/spec-A88vJX5A.d.ts +748 -0
- package/dist/tanstack-table.d.ts +113 -0
- package/dist/tanstack-table.js +98 -0
- package/dist/tanstack-table.js.map +1 -0
- package/dist/tokens-CHwBt9gs.d.ts +75 -0
- package/package.json +123 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/html/interactive.ts","../src/html/controls.ts"],"names":[],"mappings":";;;;AAMO,SAAS,mBAAwB,KAAA,EA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AAA;AAAA,EACzC,CAAA,MAAO;AAEL,IAAA,IAAA,CAAK,IAAA,CAAK,CAAC,CAAA,KAAM,CAAA,CAAE,YAAA,CAAa,UAAU,CAAA,KAAM,MAAA,CAAO,MAAA,CAAO,GAAG,CAAC,CAAA,EAAG,KAAA,EAAM;AAC3E,IAAA,KAAA,CAAM,SAAA,CAAU,MAAA,CAAO,GAAA,EAAK,MAAA,CAAO,GAAG,CAAA;AAAA,EACxC;AACF","file":"chunk-3TJR7TKS.js","sourcesContent":["import type { Table } from \"../engine.js\";\nimport { tableId } from \"../table-id.js\";\nimport { escapeAttr, escapeHtml } from \"./escape.js\";\nimport { type RenderOptions, assemble, renderParts, tableHTML } from \"./parts.js\";\n\n/** J31 (A4, A5): the engine-driven render options, built in ONE place for renderInteractive, hydrate and `<SdvTable/>`. */\nexport function tableRenderOptions<Row>(table: Table<Row>): RenderOptions {\n const sel = table.getSelection();\n return {\n interactive: true,\n sort: table.state.sort,\n hidden: table.state.hidden,\n selected: new Set(table.rows.flatMap((r, i) => (sel.has(table.rowId(r)) ? [i] : []))),\n // A49: always the full source rows, so colours, legends, outlier limits and row-accent palettes hold still\n // while the user pages, types, sorts or brushes, and index row selectors mean source rows\n domainRows: table.allRows,\n // Task 10 (A48): a selectable grid whose one tab stop is the cursor row\n grid: table.state.cursor,\n };\n}\n\n/** The pager's page text, `\"Page <page> of <pageCount>\"` with a 1-based page, e.g. `\"Page 1 of 3\"`. */\nexport function pagerLabel<Row>(table: Table<Row>): string {\n return `Page ${table.state.page + 1} of ${table.pageCount}`;\n}\n\n/**\n * M8: one input per filterable column that is SHOWN, labelled with its shown header text (`labels`, from\n * `RenderedParts.labels`, so a marginalia rename or scaleNote suffix carries over). A hidden column gets no input; a\n * filter already set on it stays active. The one rule renderToolbar, hydrate and `<SdvTable/>` all follow.\n */\nexport function filterInputs<Row>(\n table: Table<Row>,\n labels: ReadonlyMap<string, string>,\n): { key: string; label: string; value: string }[] {\n return table.columns.flatMap((c) => {\n const label = labels.get(c.key);\n const f = table.state.filters[c.key];\n return c.filterable === true && label !== undefined\n ? [{ key: c.key, label, value: typeof f === \"string\" ? f : \"\" }]\n : [];\n });\n}\n\n// a <label> that screen readers announce and sighted users never see; inline so the shared theme sheet stays unchanged\nexport const SR_ONLY: string =\n \"position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0\";\n/** `label` and `placeholder` are escaped HTML; `data` is a trusted attribute. */\nconst searchInput = (\n id: string,\n label: string,\n placeholder: string,\n cls: string,\n data: string,\n value: string,\n): string =>\n `<label for=\"${escapeAttr(id)}\" style=\"${SR_ONLY}\">${label}</label><input type=\"search\" id=\"${escapeAttr(id)}\" class=\"${cls}\" ${data} placeholder=\"${placeholder}\" value=\"${escapeAttr(value)}\"/>`;\n\n/**\n * Global search box, then one filter input per shown `filterable` column, each with a visually hidden `<label>`\n * naming the column by its shown header text. `value` is written last (React's attribute order). `labels` defaults\n * to a render of the table's current page; pass `renderParts(…).labels` when you already have one.\n */\nexport function renderToolbar<Row>(\n table: Table<Row>,\n labels: ReadonlyMap<string, string> = renderParts(table.spec, table.rows, tableRenderOptions(table)).labels,\n): string {\n const id = tableId(table.spec);\n const global = searchInput(\n `${id}-search`,\n \"Search all columns\",\n \"Search\",\n \"sdvt-global-filter\",\n 'data-sdv-global-filter=\"\"',\n table.state.globalFilter,\n );\n const perColumn = filterInputs(table, labels)\n .map((f, j) => {\n const label = `Filter ${escapeHtml(f.label)}`;\n return searchInput(\n `${id}-filter-${j}`,\n label,\n label,\n \"sdvt-filter\",\n `data-sdv-filter=\"${escapeAttr(f.key)}\"`,\n f.value,\n );\n })\n .join(\"\");\n return `<div class=\"sdvt-toolbar\">${global}${perColumn}</div>`;\n}\n\n/**\n * The pager: Previous and Next buttons around {@link pagerLabel}, a polite live region. Rendered only when\n * `pageSize` is finite. An edge button is `aria-disabled`, not `disabled`, so a keyboard user paging to the end\n * keeps focus on it (a disabled button drops focus to the page body); a click on it does nothing.\n */\nexport function renderPager<Row>(table: Table<Row>): string {\n const prev = table.state.page === 0 ? ' aria-disabled=\"true\"' : \"\";\n const next = table.state.page >= table.pageCount - 1 ? ' aria-disabled=\"true\"' : \"\";\n return `<nav class=\"sdvt-pager\" data-sdv-pager=\"\" aria-label=\"Pagination\"><button type=\"button\" class=\"sdvt-page\" data-sdv-page=\"prev\" aria-label=\"Previous page\"${prev}>‹</button><span class=\"sdvt-page-label\" data-sdv-page-label=\"\" aria-live=\"polite\">${pagerLabel(table)}</span><button type=\"button\" class=\"sdvt-page\" data-sdv-page=\"next\" aria-label=\"Next page\"${next}>›</button></nav>`;\n}\n\n/** The interactive document: the wrapper holding the style, toolbar, body block and pager, in that order. */\nexport function renderInteractive<Row>(table: Table<Row>, opts: RenderOptions = {}): string {\n const p = renderParts(table.spec, table.rows, { ...opts, ...tableRenderOptions(table) });\n const pager = table.state.pageSize === Number.POSITIVE_INFINITY ? \"\" : renderPager(table);\n return assemble(\n p,\n `${renderToolbar(table, p.labels)}<div class=\"sdvt-body\" data-sdv-body=\"\">${tableHTML(p)}</div>${pager}`,\n );\n}\n","import { type Table, type TableCursor, nextSortDir } from \"../engine.js\";\n\n// a body row of THIS table's block (a host page's or an outer table's tr[data-row] is never one)\nconst BODY_ROW = \"[data-sdv-body] tr.sdvt-row[data-row]\";\n\n/** J31: the engine id of the body row an event landed in; null for a header, toolbar, pager, group row, or outside the table. */\nexport function rowIdAt<Row>(table: Table<Row>, target: EventTarget | null): string | null {\n // scoped to the body block: a host page or outer table with its own tr[data-row] is never read as one of ours\n const tr = target instanceof Element ? target.closest(BODY_ROW) : null;\n const row = tr === null ? undefined : table.rows[Number(tr.getAttribute(\"data-row\"))];\n const id = row === undefined ? \"\" : table.rowId(row);\n return id === \"\" ? null : id;\n}\n\n/**\n * J31 (A18, A29): mark the body rows whose engine id is `id` with `sdvt-hover` and unmark the rest; `null` unmarks all.\n * A class toggle, never `innerHTML`, so it writes only the rows whose state changes. Shared by hydrate and\n * `<SdvTable/>`, which call it on each `hover` event AND after each body render, since a render rebuilds the rows.\n */\n// ponytail: O(rows on the page) reads per hover. Measured in the Phase 8 Task 5 review on a synthetic DOM of the same\n// shape as an unpaged 2,000-row table, not a hydrated one: 0.84 ms a hover in headless Chromium (26.5 ms in jsdom),\n// 0.19 ms at pageSize 25. Linear, so ~4 ms at 10,000 rows on one page, a quarter of a 60 Hz frame: past that, keep an\n// id → <tr> map rebuilt in render\nexport function applyHover<Row>(root: Element, table: Table<Row>, id: string | null): void {\n for (const tr of Array.from(root.querySelectorAll(BODY_ROW))) {\n const row = id === null ? undefined : table.rows[Number(tr.getAttribute(\"data-row\"))];\n tr.classList.toggle(\"sdvt-hover\", row !== undefined && table.rowId(row) === id);\n }\n}\n\n/** A click anywhere inside the table wrapper — shared by hydrate and `<SdvTable/>`. */\nexport function handleClick<Row>(table: Table<Row>, target: EventTarget | null): void {\n const el =\n target instanceof Element ? target.closest<HTMLElement>(\"[data-sdv-sort],[data-sdv-page]\") : null;\n if (!el) {\n // J31: a click on a body row toggles its id in the selection\n const id = rowIdAt(table, target);\n if (id === null) return;\n const next = new Set(table.getSelection());\n if (!next.delete(id)) next.add(id);\n table.setSelection(next);\n return;\n }\n if (el.getAttribute(\"aria-disabled\") === \"true\") return; // M1: an edge pager button keeps focus and does nothing\n const sortCol = el.getAttribute(\"data-sdv-sort\");\n const page = el.getAttribute(\"data-sdv-page\");\n if (sortCol !== null) table.setSort(sortCol, nextSortDir(table.state.sort, sortCol));\n else if (page === \"prev\") table.setPage(table.state.page - 1);\n else if (page === \"next\") table.setPage(table.state.page + 1);\n}\n\n/** An `input` event anywhere inside the wrapper. */\nexport function handleInput<Row>(table: Table<Row>, target: EventTarget | null): void {\n if (!(target instanceof HTMLInputElement)) return;\n const col = target.getAttribute(\"data-sdv-filter\");\n if (col !== null) table.setFilter(col, target.value === \"\" ? null : target.value);\n else if (target.hasAttribute(\"data-sdv-global-filter\")) table.setGlobalFilter(target.value);\n}\n\n/** J31: `mouseover` / `mouseleave` inside the wrapper → the engine's hover event (null off a body row). */\nexport function handleHover<Row>(table: Table<Row>, target: EventTarget | null): void {\n table.setHover(rowIdAt(table, target));\n}\n\n// M5: the attributes that name a control; a control rebuilt under focus gets focus back by name\nconst CONTROLS = [\"data-sdv-sort\", \"data-sdv-filter\", \"data-sdv-global-filter\", \"data-sdv-page\"] as const;\nconst FOCUSABLE = \"a[href],button,input,select,textarea,[tabindex]\";\n\n/**\n * Remembers what has focus inside `el` by names a re-render keeps: a control by its `data-sdv-*` attribute (and an\n * input's caret), a focusable element inside a rendered cell by row, column key and its index among that cell's\n * focusables. Call it before a re-render; the returned function, called after it, moves focus to the rebuilt element\n * when the re-render replaced the focused one (shadow-root mounts included), and does nothing otherwise. Shared by\n * hydrate and `<SdvTable/>`.\n */\nexport function captureFocus(el: Element): () => void {\n const root = el.getRootNode() as Document | ShadowRoot;\n const focused = root.activeElement ?? el.ownerDocument.activeElement;\n if (focused === null || !el.contains(focused)) return () => {};\n const name = CONTROLS.find((a) => focused.hasAttribute(a));\n const value = name === undefined ? null : focused.getAttribute(name);\n const caret =\n focused instanceof HTMLInputElement\n ? { start: focused.selectionStart, end: focused.selectionEnd }\n : undefined;\n const td = name === undefined ? focused.closest(\"[data-sdv-body] tr[data-row] td[data-col]\") : null;\n const cellAt = td\n ? {\n row: td.parentElement?.getAttribute(\"data-row\"),\n col: td.getAttribute(\"data-col\"),\n n: Array.from(td.querySelectorAll(FOCUSABLE)).indexOf(focused),\n }\n : undefined;\n // Task 10: the focused body row itself (the grid's roving tab stop) comes back by its data-row\n const row = name === undefined && focused.matches(BODY_ROW) ? focused.getAttribute(\"data-row\") : null;\n return () => {\n if (el.contains(focused)) return;\n if (name !== undefined) {\n const next = Array.from(el.querySelectorAll<HTMLElement>(`[${name}]`)).find(\n (n) => n.getAttribute(name) === value,\n );\n next?.focus();\n if (next instanceof HTMLInputElement && caret?.start != null && caret.end != null)\n next.setSelectionRange(caret.start, caret.end);\n } else if (row !== null) {\n Array.from(el.querySelectorAll<HTMLElement>(BODY_ROW))\n .find((r) => r.getAttribute(\"data-row\") === row)\n ?.focus();\n } else if (cellAt && cellAt.n >= 0) {\n const tds = Array.from(el.querySelectorAll(\"[data-sdv-body] tr[data-row]\"))\n .find((r) => r.getAttribute(\"data-row\") === cellAt.row)\n ?.querySelectorAll(\"td[data-col]\");\n const cell = Array.from(tds ?? []).find((c) => c.getAttribute(\"data-col\") === cellAt.col);\n cell?.querySelectorAll<HTMLElement>(FOCUSABLE)[cellAt.n]?.focus();\n }\n };\n}\n\n/** Task 10: what a key means to an interactive table (see {@link keyAction}). */\nexport type KeyAction =\n | { readonly type: \"cursor\"; readonly row: number; readonly col: string | null }\n | { readonly type: \"sort\"; readonly col: string }\n | { readonly type: \"search\" }\n | { readonly type: \"toggle\"; readonly row: number };\n\n/** Task 10: everything {@link keyAction} reads; {@link handleKeydown} gathers it from the engine and the DOM. */\nexport interface KeyContext {\n /** the `data-row` of the body row the key landed in, or null (toolbar, header, pager) */\n readonly focused: number | null;\n /**\n * the key landed on that body row itself, not on a link or button inside it (that control keeps its Enter, Space\n * and left/right keys)\n */\n readonly onRow: boolean;\n /** the engine's cursor (`table.state.cursor`) */\n readonly cursor: TableCursor;\n /** the sorted column (`table.state.sort?.col`), or null */\n readonly sorted: string | null;\n /** the shown sortable columns in header order: the `data-sdv-sort` buttons */\n readonly cols: readonly string[];\n /** the page's body rows' `data-row` values in display order (`groupBy` reorders them) */\n readonly order: readonly number[];\n /** `spec.interactive.hotkeys !== false`: the letter keys and `/` are on */\n readonly hotkeys: boolean;\n}\n\ntype Move = \"down\" | \"up\" | \"left\" | \"right\" | \"sort\" | \"search\" | \"toggle\";\n// a Map, not an object literal: KEYS[\"constructor\"] would be Object.prototype's and slip past the undefined check\nconst KEYS: ReadonlyMap<string, Move> = new Map([\n [\"j\", \"down\"],\n [\"k\", \"up\"],\n [\"h\", \"left\"],\n [\"l\", \"right\"],\n [\"s\", \"sort\"],\n [\"/\", \"search\"],\n [\"ArrowDown\", \"down\"],\n [\"ArrowUp\", \"up\"],\n [\"ArrowLeft\", \"left\"],\n [\"ArrowRight\", \"right\"],\n [\"Enter\", \"toggle\"],\n [\" \", \"toggle\"],\n]);\n// G19's keys, which `hotkeys: false` turns off; the arrows, Enter and Space are the grid's own keyboard model\nconst LETTERS: ReadonlySet<string> = new Set([\"j\", \"k\", \"h\", \"l\", \"s\", \"/\"]);\nconst clamp = (i: number, n: number): number => Math.max(0, Math.min(i, n - 1));\n\n/**\n * Task 10 (A45, G19): the action a keydown means, or null when it means nothing here. Pure. `j`/`k` (and the down and\n * up arrows) move the cursor row in display order, and enter the grid at the cursor row when the key came from\n * outside the rows; `h`/`l` (left and right arrows) move the cursor column over the shown sortable columns, starting\n * from the cursor column, else the sorted one, else the first; `s` sorts that column; `/` goes to the search box;\n * Enter and Space toggle the selection of the row the key landed on. Moves stop at the edges: `j`/`k` stop at the\n * first and last row of the CURRENT page and never turn it (the pager does), `h`/`l` at the first and last sortable\n * column. A left/right key that lands on a link or button inside a row (`focused` set, `onRow` false) is that\n * control's: null.\n *\n * @example\n * ```ts\n * import { keyAction } from \"@sportsdataverse/sdvtables/html\";\n *\n * // `l` on the first row of a table sorted by wins: the cursor column moves right, to net_epa\n * keyAction(\"l\", {\n * focused: 0,\n * onRow: true,\n * cursor: { row: 0, col: null },\n * sorted: \"wins\",\n * cols: [\"team\", \"wins\", \"net_epa\"],\n * order: [0, 1, 2],\n * hotkeys: true,\n * });\n * ```\n */\nexport function keyAction(key: string, k: KeyContext): KeyAction | null {\n const what = KEYS.get(key);\n if (what === undefined || (!k.hotkeys && LETTERS.has(key))) return null;\n const shown = (c: string | null): c is string => c !== null && k.cols.includes(c);\n const col = shown(k.cursor.col) ? k.cursor.col : shown(k.sorted) ? k.sorted : (k.cols[0] ?? null);\n const row = k.focused ?? k.cursor.row;\n switch (what) {\n case \"down\":\n case \"up\": {\n const at = k.order.indexOf(row);\n if (at < 0) return null;\n const next = k.focused === null ? row : k.order[clamp(at + (what === \"down\" ? 1 : -1), k.order.length)];\n return next === undefined ? null : { type: \"cursor\", row: next, col: k.cursor.col };\n }\n case \"left\":\n case \"right\": {\n if (k.focused !== null && !k.onRow) return null; // fix 1: a link or button in a cell keeps its own left/right\n const step = what === \"right\" ? 1 : -1;\n const next = col === null ? undefined : k.cols[clamp(k.cols.indexOf(col) + step, k.cols.length)];\n return next === undefined ? null : { type: \"cursor\", row, col: next };\n }\n case \"sort\":\n return col === null ? null : { type: \"sort\", col };\n case \"search\":\n return { type: \"search\" };\n case \"toggle\":\n return k.onRow && k.focused !== null ? { type: \"toggle\", row: k.focused } : null;\n }\n}\n\n// typing in a field is never a hotkey (A45); contenteditable=\"false\" is not a field\nconst TEXT_FIELD = 'input,textarea,select,[contenteditable]:not([contenteditable=\"false\"])';\n\n/**\n * Task 10 (A45, A48): a keydown anywhere inside `root`, the table wrapper; shared by hydrate and `<SdvTable/>`.\n * Ignored with Ctrl, Meta or Alt held, during IME composition, or when it comes from a text field (input, textarea,\n * select, contenteditable). Otherwise {@link keyAction} decides, and a key that acts is consumed (`preventDefault`):\n * a cursor move focuses the destination row BEFORE the engine re-renders, so the re-render's focus restore keeps it\n * there; `s` and Enter/Space go through {@link handleClick} on the column's sort button or on the row, exactly as a\n * click, once per press (a held key's repeats are consumed but toggle nothing); `/` focuses the search box, and passes\n * through to the browser (quick-find) when `root` has none. `spec.interactive.hotkeys: false` leaves only the arrows,\n * Enter and Space.\n *\n * @example\n * ```ts\n * import { createTable, defineTable } from \"@sportsdataverse/sdvtables\";\n * import { handleKeydown, renderHTML } from \"@sportsdataverse/sdvtables/html\";\n *\n * // 2024 AFC: Kansas City 15 wins, Buffalo 13\n * const spec = defineTable<{ team: string; wins: number }>()\n * .columns((c) => [c.text(\"team\"), c.int(\"wins\")])\n * .build();\n * const table = createTable(spec, [\n * { team: \"KC\", wins: 15 },\n * { team: \"BUF\", wins: 13 },\n * ]);\n * const root = document.createElement(\"div\");\n * root.innerHTML = renderHTML(table, { fonts: false });\n * root.addEventListener(\"keydown\", (e) => handleKeydown(table, root, e));\n * root\n * .querySelector(\"[data-sdv-body] tr[data-row]\")\n * ?.dispatchEvent(new KeyboardEvent(\"keydown\", { key: \"j\", bubbles: true, cancelable: true }));\n * table.state.cursor; // { row: 1, col: null }\n * ```\n */\nexport function handleKeydown<Row>(table: Table<Row>, root: Element, e: KeyboardEvent): void {\n const t = e.target;\n if (e.defaultPrevented || e.isComposing || e.ctrlKey || e.metaKey || e.altKey) return;\n if (!(t instanceof Element) || t.closest(TEXT_FIELD) !== null) return;\n const rows = Array.from(root.querySelectorAll<HTMLElement>(BODY_ROW));\n const sorts = Array.from(root.querySelectorAll<HTMLElement>(\"[data-sdv-body] [data-sdv-sort]\"));\n const near = t.closest(BODY_ROW);\n const rowEl = near !== null && root.contains(near) ? near : null; // never an outer table's row\n const s = table.state;\n const action = keyAction(e.key, {\n focused: rowEl === null ? null : Number(rowEl.getAttribute(\"data-row\")),\n onRow: rowEl === t,\n cursor: s.cursor,\n sorted: s.sort?.col ?? null,\n cols: sorts.map((b) => b.getAttribute(\"data-sdv-sort\") ?? \"\"),\n order: rows.map((r) => Number(r.getAttribute(\"data-row\"))),\n hotkeys: table.spec.interactive?.hotkeys !== false,\n });\n const box = action?.type === \"search\" ? root.querySelector<HTMLElement>(\"[data-sdv-global-filter]\") : null;\n if (action === null || (action.type === \"search\" && box === null)) return; // fix 1 (I1): no box, `/` is the browser's\n e.preventDefault();\n if (action.type === \"search\") box?.focus();\n else if (action.type === \"sort\")\n handleClick(table, sorts.find((b) => b.getAttribute(\"data-sdv-sort\") === action.col) ?? null);\n else if (action.type === \"toggle\") {\n if (!e.repeat) handleClick(table, rowEl); // fix 1: holding Enter or Space toggles once, not at key-repeat rate\n } else {\n // focus first: hydrate and <SdvTable/> restore focus to the focused row's data-row after the re-render\n rows.find((r) => r.getAttribute(\"data-row\") === String(action.row))?.focus();\n table.setCursor(action.row, action.col);\n }\n}\n"]}
|