@svgrid/mcp 3.0.29 → 3.0.30
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/dist/data.js +11 -3
- package/dist/validate.d.ts +10 -0
- package/dist/validate.js +115 -3
- package/package.json +1 -1
- package/server.json +2 -2
package/dist/data.js
CHANGED
|
@@ -4063,6 +4063,14 @@ export const examples = [
|
|
|
4063
4063
|
"blurb": "702. Change review: an agent's edits, accepted by group A customer table with the dirt a CRM export carries. Run the cleanup agent and its edits arrive as proposals, not writes: each changed cell",
|
|
4064
4064
|
"source": "<script lang=\"ts\">\n /**\n * 702. Change review: an agent's edits, accepted by group\n * --------------------------------------------------------\n * A customer table with the dirt a CRM export carries. Run the cleanup\n * agent and its edits arrive as proposals, not writes: each changed cell\n * shows the proposed value with the old one struck through beside it, and\n * the panel groups them by what they do.\n *\n * Trim spaces, Change to Title Case, Reformat Phone,\n * Divide Revenue by 100 rule groups: every member follows the rule\n * Country: 5 values -> ... a mapping table, one decision\n * Fill empty Region split by value; the low-confidence fills\n * (two of them wrong) lead the sample\n *\n * Accept a group and one setRows call writes it; Ctrl+Z in the grid puts it\n * back. Edit a cell that has a proposal, then accept: the proposal is\n * marked stale and your value stays. Import the CRM update and one cell gets\n * a second, different proposal: a conflict, decided in the panel.\n *\n * The agent here is a few fixed rules standing in for a model, so the demo\n * runs without a key. With one, reviewSmartFill / reviewClassify feed the\n * same review from the AI helpers.\n */\n import { SvButton, SvGrid, type GridColumns, type SvGridApi } from '@svgrid/grid'\n import { createReview, fromRows, SvReviewPanel, type ProposalInput } from '@svgrid/enterprise/review'\n\n type Customer = {\n id: string\n company: string\n contact: string\n phone: string\n country: string\n region: string\n revenue: number\n }\n\n const COMPANIES = ['Acme Corp', 'Globex', 'Initech', 'Umbrella Labs', 'Hooli', 'Vandelay Imports', 'Stark Industries',\n 'Wayne Holdings', 'Tyrell Systems', 'Cyberdyne', 'Aperture Science', 'Soylent Foods', 'Oscorp', 'Wonka Partners',\n 'Gringotts', 'Monarch Group', 'Pied Piper', 'Dunder Paper', 'Prestige Worldwide', 'Massive Dynamic']\n const PEOPLE = ['maria silva', 'wei chen', 'aisha khan', 'carlos ruiz', 'emma berg', 'liam novak', 'sofia rossi',\n 'noah okafor', 'yuki tanaka', 'omar haddad']\n const COUNTRIES = ['United States', 'usa', 'Germany', 'U.S.', 'Japan', 'US', 'United Kingdom', 'United States of America', 'Brazil', 'U.S.A.']\n const REGION_OF: Record<string, string> = { 'United States': 'AMER', Brazil: 'AMER', Germany: 'EMEA', 'United Kingdom': 'EMEA', Japan: 'APAC' }\n const US = new Set(['usa', 'U.S.', 'US', 'United States of America', 'U.S.A.'])\n\n const seed = (): Customer[] =>\n COMPANIES.map((name, i) => {\n const country = COUNTRIES[i % COUNTRIES.length]\n const a = 200 + ((i * 37) % 700)\n const b = 100 + ((i * 53) % 800)\n const c = 1000 + ((i * 271) % 9000)\n return {\n id: `c${i + 1}`,\n company: i % 3 === 0 ? `${name} ` : i % 7 === 1 ? ` ${name}` : name,\n contact: i % 2 === 0 ? PEOPLE[i % PEOPLE.length].toUpperCase() : titleCase(PEOPLE[i % PEOPLE.length]),\n phone: i % 4 === 3 ? `${a}-${b}-${c}` : `(${a}) ${b}-${c}`,\n country,\n region: i % 3 === 1 ? '' : REGION_OF[US.has(country) ? 'United States' : country] ?? '',\n // Six rows came in from the old billing system, in cents.\n revenue: i % 3 === 2 ? (40 + i * 13) * 1000 * 100 : (40 + i * 13) * 1000,\n }\n })\n\n function titleCase(s: string) {\n return s.replace(/\\b\\p{Ll}/gu, (ch) => ch.toUpperCase())\n }\n\n let rows = $state(seed())\n let api = $state<SvGridApi<any, Customer> | null>(null)\n const review = createReview<Customer>({ api: () => api, setRows: (next) => (rows = next) })\n\n const columns: GridColumns<Customer> = [\n { field: 'company', header: 'Company', width: 190, editable: true },\n { field: 'contact', header: 'Contact', width: 150, editable: true },\n { field: 'phone', header: 'Phone', width: 140, editable: true },\n { field: 'country', header: 'Country', width: 170, editable: true },\n { field: 'region', header: 'Region', width: 100, editable: true },\n { field: 'revenue', header: 'Revenue', width: 130, editable: true, editorType: 'number', format: { type: 'currency', currency: 'USD', options: { maximumFractionDigits: 0 } } },\n ]\n\n /** A few fixed rules standing in for a cleanup model. */\n function runAgent() {\n const proposals: ProposalInput[] = []\n for (const r of rows) {\n const add = (field: keyof Customer, after: unknown, extra: Partial<ProposalInput> = {}) => {\n if (r[field] !== after) proposals.push({ rowId: r.id, field, before: r[field], after, ...extra })\n }\n add('company', r.company.trim())\n add('contact', titleCase(r.contact.toLowerCase()))\n const digits = r.phone.replace(/\\D/g, '')\n add('phone', `${digits.slice(0, 3)}-${digits.slice(3, 6)}-${digits.slice(6)}`)\n const country = US.has(r.country) ? 'United States' : r.country\n add('country', country)\n if (!r.region) {\n // Two guesses are wrong, and the agent says it is unsure of them.\n // c5 is in Japan and c11 in the United States.\n const guess = r.id === 'c5' ? 'EMEA' : r.id === 'c11' ? 'APAC' : null\n const unsure = guess !== null\n add('region', guess ?? REGION_OF[country], {\n confidence: unsure ? 0.42 : 0.93,\n reason: unsure ? 'guessed from the company name' : `from Country (${country})`,\n })\n }\n if (r.revenue >= 1_000_000) add('revenue', r.revenue / 100, { reason: 'billing export was in cents' })\n }\n review.add({ source: { kind: 'agent', id: 'cleanup', label: 'Cleanup agent' }, proposals })\n }\n\n /** The CRM sends its own region for one customer, different from the agent's. */\n function runImport() {\n if (!api) return\n const set = fromRows<Customer>([{ id: 'c2', region: 'EMEA' }, { id: 'c8', region: 'EMEA' }], {\n api,\n key: 'id',\n source: { kind: 'import', id: 'crm-update.csv', label: 'crm-update.csv' },\n })\n review.add(set)\n }\n\n function reset() {\n review.clear()\n rows = seed()\n }\n\n const pending = $derived(review.pending().length)\n\n // A phone has no room for both side by side, and the demo stage has a fixed\n // height: show one at a time. The grid stays mounted, so its api does too.\n let narrow = $state(false)\n let view = $state<'grid' | 'review'>('grid')\n $effect(() => {\n const mq = window.matchMedia('(max-width: 860px)')\n const sync = () => (narrow = mq.matches)\n sync()\n mq.addEventListener('change', sync)\n return () => mq.removeEventListener('change', sync)\n })\n</script>\n\n<div class=\"cr-demo\">\n <div class=\"cr-bar\">\n <SvButton size=\"sm\" onclick={runAgent}>Run cleanup agent</SvButton>\n <SvButton size=\"sm\" variant=\"outline\" onclick={runImport}>Import crm-update.csv</SvButton>\n <SvButton size=\"sm\" variant=\"ghost\" onclick={reset}>Reset</SvButton>\n <span class=\"cr-note\">{pending ? `${pending} proposed, nothing written yet` : 'The data is as loaded'}</span>\n </div>\n {#if narrow}\n <div class=\"cr-bar\" role=\"group\" aria-label=\"Show\">\n <SvButton size=\"sm\" variant={view === 'grid' ? 'secondary' : 'ghost'} onclick={() => (view = 'grid')}>Grid</SvButton>\n <SvButton size=\"sm\" variant={view === 'review' ? 'secondary' : 'ghost'} onclick={() => (view = 'review')}>Review ({pending})</SvButton>\n </div>\n {/if}\n <div class=\"cr-split\">\n <div class=\"cr-grid\" class:cr-hidden={narrow && view === 'review'}>\n <SvGrid\n data={rows}\n columns={review.columns(columns)}\n getRowId={(r) => r.id}\n conditionalFormats={review.formats}\n editable\n containerHeight={460}\n onApiReady={(a) => (api = a)}\n />\n </div>\n <div class=\"cr-panel\" class:cr-hidden={narrow && view === 'grid'}>\n <SvReviewPanel {review} title=\"Review the agent's changes\" />\n </div>\n </div>\n</div>\n\n<style>\n .cr-demo {\n display: flex;\n flex-direction: column;\n gap: 10px;\n font-family: var(--sg-font, inherit);\n color: var(--sg-fg);\n }\n .cr-bar {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 8px;\n }\n .cr-note {\n color: var(--sg-muted);\n font-size: 13px;\n }\n .cr-split {\n display: grid;\n grid-template-columns: minmax(0, 1fr) 340px;\n gap: 12px;\n align-items: start;\n }\n .cr-grid,\n .cr-panel {\n min-width: 0;\n }\n /* The stage has a fixed height: the panel scrolls within the grid's. */\n .cr-panel {\n max-height: 460px;\n overflow: auto;\n }\n .cr-hidden {\n display: none;\n }\n @media (max-width: 860px) {\n .cr-split {\n grid-template-columns: minmax(0, 1fr);\n }\n }\n</style>\n"
|
|
4065
4065
|
},
|
|
4066
|
+
{
|
|
4067
|
+
"id": "703-test-run-tree",
|
|
4068
|
+
"path": "examples/src/demos/703-test-run-tree.svelte",
|
|
4069
|
+
"title": "Test Run Tree",
|
|
4070
|
+
"category": "Tree & Hierarchy",
|
|
4071
|
+
"blurb": "703. Test results tree - reload one subtree A release-qualification board for a kernel candidate. Each test environment (architecture + machine) holds its reported issues and its",
|
|
4072
|
+
"source": "<script lang=\"ts\">\n /**\n * 703. Test results tree - reload one subtree\n * -------------------------------------------\n * A release-qualification board for a kernel candidate. Each test\n * environment (architecture + machine) holds its reported issues and its\n * test plans; a plan holds its runs, and a run its results split into\n * Failed, Passed and Skipped.\n *\n * The grid's own `treeData` builds the hierarchy from flat rows whose ids\n * are paths (`env:amd64-precision-3680/plans/automated/runs/2`). The reload\n * icon on an environment, plan or run row asks the server for that subtree\n * only and splices the answer back into the flat array in place. `getRowId`\n * keeps the ids stable, so the controlled `expanded` map leaves every open\n * node open across the reload.\n *\n * The server here is in memory and does not wait for you: a running run\n * reports a result every couple of seconds, and the grid sees it only when\n * that run, or a node above it, is reloaded. Rerun queues a new run, Add\n * result posts a manual result, Add records an environment issue, and the\n * environment checkboxes approve or reject in bulk. Every request is in the\n * log under the grid.\n */\n import {\n SvGrid,\n SvModal,\n SvButton,\n SvTextInput,\n SvTextArea,\n SvDropDownList,\n SvSegmented,\n tableFeatures,\n renderSnippet,\n type GridColumns,\n } from '@svgrid/grid'\n\n type Outcome = 'failed' | 'passed' | 'skipped'\n type Review = 'undecided' | 'approved' | 'rejected'\n type RunStatus = 'queued' | 'running' | 'complete'\n type Kind = 'env' | 'issues' | 'issue' | 'plans' | 'plan' | 'run' | 'bucket' | 'result'\n\n // ---- Server records --------------------------------------------------------\n type TestResult = { test: string; outcome: Outcome; seconds: number; comment: string }\n type RunRec = {\n n: number\n status: RunStatus\n startedAt: number\n startAt: number\n results: TestResult[]\n pending: TestResult[]\n }\n type PlanRec = { key: string; name: string; manual: boolean; tests: string[]; runs: RunRec[] }\n type IssueRec = { n: number; title: string; bug: string }\n type EnvRec = {\n key: string\n arch: string\n machine: string\n hardware: string\n review: Review\n issues: IssueRec[]\n plans: PlanRec[]\n }\n\n // ---- What the API returns: one flat row per node ---------------------------\n type TestRow = {\n id: string\n parentId: string | null\n kind: Kind\n name: string\n detail: string\n fetchedAt: number\n arch?: string\n review?: Review\n manual?: boolean\n tests?: string[]\n runStatus?: RunStatus\n done?: number\n total?: number\n outcome?: Outcome\n count?: number\n seconds?: number\n }\n\n const OUTCOMES: Outcome[] = ['failed', 'passed', 'skipped']\n const OUTCOME_LABEL: Record<Outcome, string> = { failed: 'Failed', passed: 'Passed', skipped: 'Skipped' }\n const REVIEW_LABEL: Record<Review, string> = { undecided: 'Undecided', approved: 'Approved', rejected: 'Rejected' }\n const RELOADABLE = new Set<Kind>(['env', 'plan', 'run'])\n\n const ARTEFACT = 'linux-generic 6.11.0-19.19'\n\n const AUTOMATED = [\n 'boot/kernel-version',\n 'cpu/topology',\n 'cpu/frequency-governor',\n 'memory/stress-ng-60s',\n 'disk/read-performance',\n 'disk/smart-self-test',\n 'ethernet/ping-gateway',\n 'wireless/connect-wpa2-5ghz',\n 'bluetooth/detect',\n 'suspend/resume-cycle',\n 'suspend/wireless-after-resume',\n 'usb/storage-insert',\n 'graphics/modeset',\n ]\n const MANUAL = [\n 'audio/headphone-jack-playback',\n 'camera/preview',\n 'display/external-hdmi-hotplug',\n 'keys/brightness',\n 'touchpad/two-finger-scroll',\n ]\n\n // Failures and skips each machine produces, with the comment the harness\n // attaches. Everything else passes.\n const FAILS: Record<string, Record<string, string>> = {\n 'amd64-thinkpad-x13-g4': { 'suspend/wireless-after-resume': 'wlp0s20f3 has no carrier 30 s after resume' },\n 'amd64-precision-3680': {\n 'graphics/modeset': 'DP-2: atomic commit failed, -EINVAL',\n 'disk/read-performance': '1.1 GB/s, threshold 1.5 GB/s',\n },\n 'riscv64-visionfive-2': {\n 'disk/smart-self-test': 'no NVMe controller on PCIe bus 0000:01',\n 'disk/read-performance': 'no block device to test',\n 'cpu/frequency-governor': 'schedutil not available',\n },\n }\n const SKIPS: Record<string, string[]> = {\n 'amd64-thinkpad-x13-g4': ['bluetooth/detect'],\n 'arm64-rpi5-8gb': ['wireless/connect-wpa2-5ghz', 'suspend/resume-cycle', 'suspend/wireless-after-resume'],\n 'riscv64-visionfive-2': ['graphics/modeset', 'bluetooth/detect'],\n 'arm64-manual': ['camera/preview'],\n }\n\n // Seeded so a reload of the page draws the same durations.\n let seed = 703\n function rand(): number {\n seed = (seed * 1103515245 + 12345) & 0x7fffffff\n return seed / 0x7fffffff\n }\n\n function resultsFor(envKey: string, tests: string[]): TestResult[] {\n return tests.map((test) => {\n const comment = FAILS[envKey]?.[test]\n const skipped = SKIPS[envKey]?.includes(test)\n return {\n test,\n outcome: comment ? 'failed' : skipped ? 'skipped' : 'passed',\n seconds: skipped ? 0 : Math.round(2 + rand() * 70),\n comment: comment ?? (skipped ? 'requirement not met on this machine' : ''),\n }\n })\n }\n\n const T0 = Date.now()\n function completeRun(n: number, envKey: string, tests: string[], minutesAgo: number): RunRec {\n return { n, status: 'complete', startedAt: T0 - minutesAgo * 60_000, startAt: 0, results: resultsFor(envKey, tests), pending: [] }\n }\n function liveRun(n: number, envKey: string, tests: string[], reported: number, minutesAgo: number): RunRec {\n const all = resultsFor(envKey, tests)\n return { n, status: 'running', startedAt: T0 - minutesAgo * 60_000, startAt: 0, results: all.slice(0, reported), pending: all.slice(reported) }\n }\n\n const db: EnvRec[] = [\n {\n key: 'amd64-precision-3680', arch: 'amd64', machine: 'dell-precision-3680', hardware: 'Core i9-14900K, RTX A2000',\n review: 'undecided',\n issues: [{ n: 1, title: 'DisplayPort 2 stays dark after modeset', bug: 'BUG-4127' }],\n plans: [{\n key: 'automated', name: 'Automated testing', manual: false, tests: AUTOMATED,\n runs: [completeRun(1, 'amd64-precision-3680', AUTOMATED, 190), liveRun(2, 'amd64-precision-3680', AUTOMATED, 6, 4)],\n }],\n },\n {\n key: 'arm64-manual', arch: 'arm64', machine: 'user manual tests', hardware: 'Lab bench, any arm64 laptop',\n review: 'approved',\n issues: [],\n plans: [{\n key: 'manual', name: 'Manual testing', manual: true, tests: MANUAL,\n runs: [{ ...completeRun(1, 'arm64-manual', MANUAL, 300), results: resultsFor('arm64-manual', MANUAL).slice(0, 4), status: 'running' }],\n }],\n },\n {\n key: 'amd64-thinkpad-x13-g4', arch: 'amd64', machine: 'lenovo-thinkpad-x13-g4', hardware: 'Core i7-1365U, AX211 Wi-Fi',\n review: 'undecided',\n issues: [{ n: 1, title: 'Wi-Fi does not come back after suspend (iwlwifi)', bug: 'BUG-4119' }],\n plans: [\n { key: 'automated', name: 'Automated testing', manual: false, tests: AUTOMATED, runs: [completeRun(1, 'amd64-thinkpad-x13-g4', AUTOMATED, 75)] },\n { key: 'manual', name: 'Manual testing', manual: true, tests: MANUAL, runs: [] },\n ],\n },\n {\n key: 'arm64-rpi5-8gb', arch: 'arm64', machine: 'raspberry-pi-5-8gb', hardware: 'Cortex-A76, 8 GB',\n review: 'undecided',\n issues: [],\n plans: [{ key: 'automated', name: 'Automated testing', manual: false, tests: AUTOMATED, runs: [liveRun(1, 'arm64-rpi5-8gb', AUTOMATED, 3, 2)] }],\n },\n {\n key: 'riscv64-visionfive-2', arch: 'riscv64', machine: 'starfive-visionfive-2', hardware: 'JH7110, 8 GB',\n review: 'rejected',\n issues: [{ n: 1, title: 'PCIe NVMe not detected on boot', bug: 'BUG-4102' }],\n plans: [{ key: 'automated', name: 'Automated testing', manual: false, tests: AUTOMATED, runs: [completeRun(1, 'riscv64-visionfive-2', AUTOMATED, 420)] }],\n },\n ]\n\n // ---- Rows for one environment, in tree order ------------------------------\n function envRows(env: EnvRec, at: number): TestRow[] {\n const id = `env:${env.key}`\n const out: TestRow[] = [{ id, parentId: null, kind: 'env', name: env.machine, arch: env.arch, detail: env.hardware, review: env.review, fetchedAt: at }]\n\n const issuesId = `${id}/issues`\n out.push({ id: issuesId, parentId: id, kind: 'issues', name: 'Reported environment issues', count: env.issues.length, detail: '', fetchedAt: at })\n for (const issue of env.issues) {\n out.push({ id: `${issuesId}/${issue.n}`, parentId: issuesId, kind: 'issue', name: issue.title, detail: issue.bug, fetchedAt: at })\n }\n\n const plansId = `${id}/plans`\n out.push({ id: plansId, parentId: id, kind: 'plans', name: 'Test plans', count: env.plans.length, detail: '', fetchedAt: at })\n for (const plan of env.plans) {\n const planId = `${plansId}/${plan.key}`\n out.push({\n id: planId, parentId: plansId, kind: 'plan', name: plan.name, manual: plan.manual, tests: plan.tests,\n detail: `${plan.tests.length} tests, ${plan.runs.length} run${plan.runs.length === 1 ? '' : 's'}`, fetchedAt: at,\n })\n // Newest run first, the one a reviewer cares about.\n for (const run of [...plan.runs].reverse()) {\n const runId = `${planId}/runs/${run.n}`\n out.push({\n id: runId, parentId: planId, kind: 'run', name: `Run ${run.n}`, runStatus: run.status,\n done: run.results.length, total: plan.tests.length,\n detail: run.status === 'queued' ? 'waiting for a machine' : `started ${clock(run.startedAt)}`, fetchedAt: at,\n })\n for (const outcome of OUTCOMES) {\n const bucketId = `${runId}/${outcome}`\n const hits = run.results.filter((r) => r.outcome === outcome)\n out.push({ id: bucketId, parentId: runId, kind: 'bucket', name: OUTCOME_LABEL[outcome], outcome, count: hits.length, detail: '', fetchedAt: at })\n for (const r of hits) {\n out.push({ id: `${bucketId}/${r.test}`, parentId: bucketId, kind: 'result', name: r.test, outcome, seconds: r.seconds, detail: r.comment, fetchedAt: at })\n }\n }\n }\n }\n return out\n }\n\n // ---- The server -------------------------------------------------------------\n const wait = () => new Promise<void>((resolve) => setTimeout(resolve, 260 + Math.random() * 420))\n const envKeyOf = (id: string) => id.slice(4).split('/')[0]\n const findEnv = (id: string) => db.find((e) => e.key === envKeyOf(id))\n function findPlan(id: string): PlanRec | undefined {\n const m = /\\/plans\\/([^/]+)/.exec(id)\n return m ? findEnv(id)?.plans.find((p) => p.key === m[1]) : undefined\n }\n function findRun(id: string): RunRec | undefined {\n const m = /\\/runs\\/(\\d+)/.exec(id)\n return m ? findPlan(id)?.runs.find((r) => r.n === Number(m[1])) : undefined\n }\n const inSubtree = (rootId: string, id: string) => id === rootId || id.startsWith(rootId + '/')\n\n const server = {\n snapshot(): TestRow[] {\n const at = Date.now()\n return db.flatMap((env) => envRows(env, at))\n },\n async getSubtree(id: string): Promise<TestRow[]> {\n await wait()\n const env = findEnv(id)\n return env ? envRows(env, Date.now()).filter((r) => inSubtree(id, r.id)) : []\n },\n async setReview(envIds: string[], review: Review): Promise<void> {\n await wait()\n for (const id of envIds) {\n const env = findEnv(id)\n if (env) env.review = review\n }\n },\n async addIssue(envId: string, title: string, bug: string): Promise<void> {\n await wait()\n const env = findEnv(envId)\n if (env) env.issues.push({ n: env.issues.length + 1, title, bug })\n },\n async rerun(planId: string): Promise<number> {\n await wait()\n const env = findEnv(planId)\n const plan = findPlan(planId)\n if (!env || !plan) return 0\n const n = plan.runs.length + 1\n plan.runs.push(\n plan.manual\n // A manual run is open until a tester has reported every test.\n ? { n, status: 'running', startedAt: Date.now(), startAt: 0, results: [], pending: [] }\n : { n, status: 'queued', startedAt: 0, startAt: Date.now() + 3000, results: [], pending: resultsFor(env.key, plan.tests) },\n )\n return n\n },\n async addResult(runId: string, result: TestResult): Promise<void> {\n await wait()\n const plan = findPlan(runId)\n const run = findRun(runId)\n if (!plan || !run) return\n run.results = [...run.results.filter((r) => r.test !== result.test), result]\n run.pending = run.pending.filter((r) => r.test !== result.test)\n if (run.results.length >= plan.tests.length) run.status = 'complete'\n },\n // The lab keeps working whether or not anyone is looking.\n tick() {\n const now = Date.now()\n for (const env of db) {\n for (const plan of env.plans) {\n for (const run of plan.runs) {\n if (run.status === 'queued' && run.startAt <= now) {\n run.status = 'running'\n run.startedAt = now\n } else if (run.status === 'running' && run.pending.length) {\n run.results.push(run.pending.shift()!)\n if (!run.pending.length) run.status = 'complete'\n }\n }\n }\n }\n },\n }\n\n // ---- Client state -----------------------------------------------------------\n const firstLoad = server.snapshot()\n let rows = $state<TestRow[]>(firstLoad)\n let expanded = $state<Record<string, boolean>>({\n 'env:amd64-precision-3680': true,\n 'env:amd64-precision-3680/plans': true,\n 'env:amd64-precision-3680/plans/automated': true,\n 'env:amd64-precision-3680/plans/automated/runs/2': true,\n 'env:arm64-manual': true,\n 'env:arm64-manual/plans': true,\n 'env:arm64-manual/plans/manual': true,\n 'env:arm64-manual/plans/manual/runs/1': true,\n })\n let reloading = $state<Record<string, boolean>>({})\n let arrived = $state<Record<string, number>>({})\n let selected = $state<Record<string, boolean>>({})\n let now = $state(Date.now())\n\n type LogEntry = { n: number; at: number; method: 'GET' | 'POST' | 'PATCH'; path: string; note: string }\n let log = $state<LogEntry[]>([{ n: 1, at: Date.now(), method: 'GET', path: `/api/v1/artefacts/${slug(ARTEFACT)}/environments`, note: `${firstLoad.length} rows, page load` }])\n function record(method: LogEntry['method'], path: string, note: string) {\n log = [{ n: (log[0]?.n ?? 0) + 1, at: Date.now(), method, path, note }, ...log].slice(0, 5)\n }\n\n $effect(() => {\n const lab = setInterval(() => server.tick(), 1800)\n const clockTimer = setInterval(() => (now = Date.now()), 1000)\n return () => {\n clearInterval(lab)\n clearInterval(clockTimer)\n }\n })\n\n function apiPath(id: string): string {\n return `/api/v1/environments/${id.slice(4)}`\n }\n\n /** Re-read one node and everything under it, and splice it back in place. */\n async function reload(id: string): Promise<void> {\n if (reloading[id]) return\n reloading = { ...reloading, [id]: true }\n const t0 = performance.now()\n try {\n const next = await server.getSubtree(id)\n const before = new Map(rows.filter((r) => inSubtree(id, r.id)).map((r) => [r.id, r]))\n const at = rows.findIndex((r) => r.id === id)\n const rest = rows.filter((r) => !inSubtree(id, r.id))\n // The subtree is one contiguous block starting at the node, so the rows\n // before it are exactly rest's first `at` entries.\n rows = at < 0 ? [...rest, ...next] : [...rest.slice(0, at), ...next, ...rest.slice(at)]\n\n const stamp = Date.now()\n const fresh = next.filter((r) => !before.has(r.id) && (r.kind === 'result' || r.kind === 'issue' || r.kind === 'run'))\n if (fresh.length) arrived = { ...arrived, ...Object.fromEntries(fresh.map((r) => [r.id, stamp])) }\n\n const results = fresh.filter((r) => r.kind === 'result').length\n const ms = Math.round(performance.now() - t0)\n const note = results\n ? `${results} new result${results === 1 ? '' : 's'}`\n : fresh.length ? `${fresh.length} new` : 'no changes'\n record('GET', apiPath(id), `${next.length} rows, ${ms} ms, ${note}`)\n } finally {\n reloading = Object.fromEntries(Object.entries(reloading).filter(([key]) => key !== id))\n }\n }\n\n function reloadAll() {\n for (const r of rows) if (r.kind === 'env') void reload(r.id)\n }\n\n async function setReview(envIds: string[], review: Review) {\n await server.setReview(envIds, review)\n record('PATCH', '/api/v1/environments/review', `${envIds.length} set to ${REVIEW_LABEL[review]}`)\n const ids = new Set(envIds)\n rows = rows.map((r) => (ids.has(r.id) ? { ...r, review } : r))\n selected = {}\n }\n\n async function rerun(planId: string) {\n const n = await server.rerun(planId)\n record('POST', `${apiPath(planId)}/runs`, `Run ${n} created`)\n expanded = { ...expanded, [planId]: true }\n await reload(planId)\n }\n\n // ---- Dialogs ----------------------------------------------------------------\n type Dialog = { kind: 'issue'; envId: string; title: string } | { kind: 'result'; runId: string; title: string } | null\n let dialog = $state<Dialog>(null)\n let form = $state({ title: '', bug: '', test: '', outcome: 'passed' as Outcome, comment: '' })\n let saving = $state(false)\n\n function envLabel(envId: string): string {\n const env = rows.find((r) => r.id === envId)\n return env ? `${env.arch} ${env.name}` : ''\n }\n\n function openIssue(issuesId: string) {\n const envId = issuesId.replace(/\\/issues$/, '')\n form = { title: '', bug: '', test: '', outcome: 'passed', comment: '' }\n dialog = { kind: 'issue', envId, title: `Report an issue on ${envLabel(envId)}` }\n }\n\n /** Tests in the run's plan that have no result yet. */\n function untested(runId: string): string[] {\n const planId = runId.replace(/\\/runs\\/\\d+$/, '')\n const plan = rows.find((r) => r.id === planId)\n const reported = new Set(rows.filter((r) => r.kind === 'result' && inSubtree(runId, r.id)).map((r) => r.name))\n return (plan?.tests ?? []).filter((t) => !reported.has(t))\n }\n\n function openResult(runId: string) {\n const first = untested(runId)[0] ?? ''\n const run = rows.find((r) => r.id === runId)\n form = { title: '', bug: '', test: first, outcome: 'passed', comment: '' }\n dialog = { kind: 'result', runId, title: `Add a result to ${run?.name ?? 'run'}, ${envLabel(runId.split('/')[0])}` }\n }\n\n const testOptions = $derived(dialog?.kind === 'result' ? untested(dialog.runId).map((t) => ({ value: t, label: t })) : [])\n const outcomeOptions = OUTCOMES.map((o) => ({ value: o, label: OUTCOME_LABEL[o] }))\n const canSave = $derived(\n !saving && (dialog?.kind === 'issue' ? form.title.trim() !== '' : dialog?.kind === 'result' ? form.test !== '' : false),\n )\n\n async function save() {\n const d = dialog\n if (!d || !canSave) return\n saving = true\n try {\n if (d.kind === 'issue') {\n await server.addIssue(d.envId, form.title.trim(), form.bug.trim() || 'not filed')\n record('POST', `${apiPath(d.envId)}/issues`, form.title.trim())\n const issuesId = `${d.envId}/issues`\n expanded = { ...expanded, [d.envId]: true, [issuesId]: true }\n dialog = null\n await reload(issuesId)\n } else {\n const outcome = form.outcome\n await server.addResult(d.runId, { test: form.test, outcome, seconds: 0, comment: form.comment.trim() })\n record('POST', `${apiPath(d.runId)}/results`, `${form.test}: ${OUTCOME_LABEL[outcome]}`)\n expanded = { ...expanded, [d.runId]: true, [`${d.runId}/${outcome}`]: true }\n dialog = null\n await reload(d.runId)\n }\n } finally {\n saving = false\n }\n }\n\n // ---- Toolbar ----------------------------------------------------------------\n const selectedIds = $derived(Object.keys(selected).filter((id) => selected[id]))\n const envs = $derived(rows.filter((r) => r.kind === 'env'))\n const summary = $derived.by(() => {\n let failed = 0\n let running = 0\n for (const r of rows) {\n if (r.kind === 'bucket' && r.outcome === 'failed') failed += r.count ?? 0\n if (r.kind === 'run' && r.runStatus !== 'complete') running += 1\n }\n const approved = envs.filter((e) => e.review === 'approved').length\n return { failed, running, approved }\n })\n\n function expandAll() {\n const parents = new Set(rows.map((r) => r.parentId).filter((p): p is string => p != null))\n expanded = Object.fromEntries([...parents].map((id) => [id, true]))\n }\n\n function toggleSelected(id: string) {\n selected = { ...selected, [id]: !selected[id] }\n }\n\n // ---- Formatting -------------------------------------------------------------\n function clock(t: number): string {\n return new Date(t).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })\n }\n function ago(t: number): string {\n const s = Math.max(0, Math.round((now - t) / 1000))\n if (s < 5) return 'just now'\n if (s < 60) return `${s} s ago`\n return `${Math.floor(s / 60)} min ago`\n }\n function slug(s: string): string {\n return s.replace(/[^a-z0-9.]+/gi, '-')\n }\n function labelOf(r: TestRow): string {\n if (r.kind === 'issues') return `${r.name} (${r.count ?? 0})`\n if (r.kind === 'bucket') return `${r.name} ${r.count ?? 0}`\n return r.name\n }\n const isNew = (id: string) => arrived[id] != null && now - arrived[id] < 6000\n // A running run's counts go stale while the lab keeps reporting.\n const isBehind = (r: TestRow) => r.kind === 'run' && r.runStatus !== 'complete' && now - r.fetchedAt > 15_000\n\n const features = tableFeatures({})\n const columns: GridColumns<TestRow> = [\n { id: 'name', header: 'Environment / test', width: 380, fieldFn: (r) => labelOf(r), cell: (ctx) => renderSnippet(NameCell, { row: ctx.row.original }) },\n { id: 'status', header: 'Status', width: 150, fieldFn: (r) => r.review ?? r.runStatus ?? r.outcome ?? '', cell: (ctx) => renderSnippet(StatusCell, { row: ctx.row.original }) },\n { id: 'detail', header: 'Detail', width: 260, fieldFn: (r) => r.detail, cell: (ctx) => renderSnippet(DetailCell, { row: ctx.row.original }) },\n { id: 'updated', header: 'Fetched', width: 110, fieldFn: (r) => (RELOADABLE.has(r.kind) ? ago(r.fetchedAt) : ''), cell: (ctx) => renderSnippet(UpdatedCell, { row: ctx.row.original }) },\n { id: 'actions', header: '', width: 190, fieldFn: () => '', cell: (ctx) => renderSnippet(ActionsCell, { row: ctx.row.original }) },\n ]\n</script>\n\n{#snippet NameCell(props: { row: TestRow })}\n {@const r = props.row}\n <span class=\"tr703-name\" data-kind={r.kind}>\n {#if r.kind === 'env'}\n <input\n type=\"checkbox\"\n class=\"tr703-check\"\n checked={!!selected[r.id]}\n onclick={(e) => e.stopPropagation()}\n onchange={() => toggleSelected(r.id)}\n aria-label={`Select ${r.arch} ${r.name}`}\n />\n {/if}\n {#if RELOADABLE.has(r.kind)}\n <button\n type=\"button\"\n class=\"tr703-reload\"\n class:tr703-spin={!!reloading[r.id]}\n disabled={!!reloading[r.id]}\n title=\"Reload this subtree from the server\"\n aria-label={`Reload ${r.kind === 'env' ? `${r.arch} ${r.name}` : r.name}`}\n onclick={(e) => { e.stopPropagation(); void reload(r.id) }}\n >\n <svg viewBox=\"0 0 16 16\" width=\"13\" height=\"13\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\">\n <path d=\"M13.5 8a5.5 5.5 0 1 1-1.6-3.9\" />\n <polyline points=\"13.5 2.5 13.5 5.5 10.5 5.5\" />\n </svg>\n </button>\n {/if}\n {#if r.kind === 'env'}\n <span class=\"tr703-arch\">{r.arch}</span>\n {:else if r.kind === 'bucket' || r.kind === 'result'}\n <span class=\"tr703-glyph\" data-outcome={r.outcome} aria-hidden=\"true\">\n {#if r.outcome === 'passed'}\n <svg viewBox=\"0 0 16 16\" width=\"13\" height=\"13\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\"><circle cx=\"8\" cy=\"8\" r=\"6.5\" /><polyline points=\"5 8.2 7.1 10.2 11 6\" /></svg>\n {:else if r.outcome === 'failed'}\n <svg viewBox=\"0 0 16 16\" width=\"13\" height=\"13\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\"><circle cx=\"8\" cy=\"8\" r=\"6.5\" /><path d=\"M5.8 5.8l4.4 4.4M10.2 5.8l-4.4 4.4\" /></svg>\n {:else}\n <svg viewBox=\"0 0 16 16\" width=\"13\" height=\"13\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\"><circle cx=\"8\" cy=\"8\" r=\"6.5\" /><path d=\"M5 8h6\" /></svg>\n {/if}\n </span>\n {/if}\n <span class=\"tr703-label\" class:tr703-mono={r.kind === 'result'}>{labelOf(r)}</span>\n {#if isNew(r.id)}<span class=\"tr703-new\">new</span>{/if}\n </span>\n{/snippet}\n\n{#snippet StatusCell(props: { row: TestRow })}\n {@const r = props.row}\n {#if r.kind === 'env' && r.review}\n <span class=\"tr703-pill\" data-tone={r.review}>{REVIEW_LABEL[r.review]}</span>\n {:else if r.kind === 'run'}\n {#if r.runStatus === 'queued'}\n <span class=\"tr703-pill\" data-tone=\"undecided\">Queued</span>\n {:else if r.runStatus === 'running'}\n <span class=\"tr703-progress\" title={`${r.done} of ${r.total} tests reported`}>\n <span class=\"tr703-bar\"><span style={`width:${((r.done ?? 0) / (r.total || 1)) * 100}%`}></span></span>\n <span class=\"tr703-num\">{r.done}/{r.total}</span>\n </span>\n {:else}\n <span class=\"tr703-pill\" data-tone=\"done\">Complete</span>\n {/if}\n {:else if r.kind === 'plan'}\n <span class=\"tr703-tag\">{r.manual ? 'manual' : 'automated'}</span>\n {:else if r.kind === 'result' && r.outcome}\n <span class=\"tr703-pill\" data-tone={r.outcome}>{OUTCOME_LABEL[r.outcome]}</span>\n {/if}\n{/snippet}\n\n{#snippet DetailCell(props: { row: TestRow })}\n {@const r = props.row}\n {#if r.kind === 'result'}\n <span class=\"tr703-detail\">\n {#if r.seconds}<span class=\"tr703-num\">{r.seconds} s</span>{/if}\n {#if r.detail}<span class=\"tr703-muted\" title={r.detail}>{r.detail}</span>{/if}\n </span>\n {:else if r.kind === 'issue'}\n <span class=\"tr703-bug\">{r.detail}</span>\n {:else}\n <span class=\"tr703-muted\">{r.detail}</span>\n {/if}\n{/snippet}\n\n{#snippet UpdatedCell(props: { row: TestRow })}\n {@const r = props.row}\n {#if RELOADABLE.has(r.kind)}\n <span class=\"tr703-ago\" class:tr703-behind={isBehind(r)} title={isBehind(r) ? 'The lab may have reported more results since. Reload this run.' : undefined}>\n {ago(r.fetchedAt)}\n </span>\n {/if}\n{/snippet}\n\n{#snippet ActionsCell(props: { row: TestRow })}\n {@const r = props.row}\n <span class=\"tr703-actions\">\n {#if r.kind === 'env'}\n {#if r.review === 'undecided'}\n <button type=\"button\" class=\"tr703-link\" onclick={() => setReview([r.id], 'approved')}>Approve</button>\n <button type=\"button\" class=\"tr703-link\" onclick={() => setReview([r.id], 'rejected')}>Reject</button>\n {:else}\n <button type=\"button\" class=\"tr703-link\" onclick={() => setReview([r.id], 'undecided')}>Reopen</button>\n {/if}\n {:else if r.kind === 'issues'}\n <button type=\"button\" class=\"tr703-link\" onclick={() => openIssue(r.id)}>Add</button>\n {:else if r.kind === 'plan'}\n <button type=\"button\" class=\"tr703-link\" onclick={() => rerun(r.id)}>Rerun</button>\n {:else if r.kind === 'run' && r.runStatus !== 'queued' && untested(r.id).length}\n <button type=\"button\" class=\"tr703-link\" onclick={() => openResult(r.id)}>Add result</button>\n {/if}\n </span>\n{/snippet}\n\n<section class=\"tr703 flex flex-col flex-1 min-h-0 gap-3\">\n <header class=\"tr703-head\">\n <div class=\"tr703-artefact\">\n <span class=\"tr703-mono\">{ARTEFACT}</span>\n <span class=\"tr703-tag\">proposed</span>\n </div>\n <div class=\"tr703-facts\">\n <span><strong>{summary.approved}</strong> of {envs.length} environments approved</span>\n <span><strong>{summary.failed}</strong> failed results</span>\n <span><strong>{summary.running}</strong> {summary.running === 1 ? 'run' : 'runs'} open</span>\n </div>\n </header>\n\n <div class=\"tr703-toolbar\">\n {#if selectedIds.length}\n <span class=\"tr703-muted\">{selectedIds.length} selected</span>\n <SvButton size=\"sm\" onclick={() => setReview(selectedIds, 'approved')}>Approve</SvButton>\n <SvButton size=\"sm\" variant=\"outline\" onclick={() => setReview(selectedIds, 'rejected')}>Reject</SvButton>\n <SvButton size=\"sm\" variant=\"ghost\" onclick={() => (selected = {})}>Clear</SvButton>\n {:else}\n <span class=\"tr703-muted\">Tick environments to review them together. The reload icon re-reads that node and everything under it.</span>\n {/if}\n <span class=\"tr703-spacer\"></span>\n <SvButton size=\"sm\" variant=\"outline\" onclick={expandAll}>Expand all</SvButton>\n <SvButton size=\"sm\" variant=\"outline\" onclick={() => (expanded = {})}>Collapse all</SvButton>\n <SvButton size=\"sm\" variant=\"outline\" onclick={reloadAll}>Reload all</SvButton>\n </div>\n\n <div class=\"tr703-grid flex-1 min-h-0\">\n <SvGrid\n data={rows}\n {columns}\n {features}\n treeData={{ parentField: 'parentId', column: 'name', indentPx: 18 }}\n getRowId={(r) => r.id}\n {expanded}\n onExpandedChange={(next) => (expanded = next)}\n selectionMode=\"none\"\n filterMode=\"none\"\n enableInlineEditing={false}\n rowHeight={36}\n containerHeight=\"100%\"\n fitColumns\n columnResize\n responsive\n />\n </div>\n\n <ol class=\"tr703-log\" aria-label=\"Requests\" aria-live=\"polite\">\n {#each log as entry (entry.n)}\n <li>\n <span class=\"tr703-method\" data-method={entry.method}>{entry.method}</span>\n <span class=\"tr703-path\">{entry.path}</span>\n <span class=\"tr703-muted\">{entry.note}</span>\n </li>\n {/each}\n </ol>\n</section>\n\n<SvModal open={dialog != null} onClose={() => (dialog = null)} title={dialog?.title ?? ''} width={480}>\n {#if dialog?.kind === 'issue'}\n <div class=\"tr703-form\">\n <label class=\"tr703-field\">\n <span>What is wrong with this environment</span>\n <SvTextInput value={form.title} onChange={(v) => (form.title = v)} placeholder=\"Fan runs at full speed after resume\" ariaLabel=\"Issue\" block autofocus />\n </label>\n <label class=\"tr703-field\">\n <span>Bug reference</span>\n <SvTextInput value={form.bug} onChange={(v) => (form.bug = v)} placeholder=\"BUG-4130\" ariaLabel=\"Bug reference\" block />\n </label>\n </div>\n {:else if dialog?.kind === 'result'}\n <div class=\"tr703-form\">\n {#if testOptions.length}\n <div class=\"tr703-field\">\n <span>Test</span>\n <SvDropDownList options={testOptions} value={form.test} onChange={(v) => (form.test = String(v))} ariaLabel=\"Test\" block />\n </div>\n <div class=\"tr703-field\">\n <span>Outcome</span>\n <SvSegmented options={outcomeOptions} value={form.outcome} onChange={(v) => (form.outcome = OUTCOMES.find((o) => o === v) ?? 'passed')} />\n </div>\n <label class=\"tr703-field\">\n <span>Comment</span>\n <SvTextArea value={form.comment} onChange={(v) => (form.comment = v)} rows={3} placeholder=\"What the tester saw\" ariaLabel=\"Comment\" block />\n </label>\n {:else}\n <p class=\"tr703-muted\">Every test in this plan already has a result in this run.</p>\n {/if}\n </div>\n {/if}\n {#snippet footer()}\n <SvButton variant=\"ghost\" onclick={() => (dialog = null)}>Cancel</SvButton>\n <SvButton variant=\"primary\" disabled={!canSave} loading={saving} onclick={save}>Save</SvButton>\n {/snippet}\n</SvModal>\n\n<style>\n .tr703 { min-height: 0; }\n\n .tr703-head {\n display: flex;\n flex-wrap: wrap;\n align-items: baseline;\n justify-content: space-between;\n gap: 8px 16px;\n flex-shrink: 0;\n }\n .tr703-artefact { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; color: var(--sg-fg); }\n .tr703-facts { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12.5px; color: var(--sg-muted); }\n .tr703-facts strong { color: var(--sg-fg); font-variant-numeric: tabular-nums; }\n\n .tr703-toolbar {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 8px;\n min-height: 32px;\n flex-shrink: 0;\n font-size: 12.5px;\n }\n .tr703-spacer { flex: 1; }\n\n .tr703-grid {\n border: 1px solid var(--sg-border);\n border-radius: 8px;\n overflow: hidden;\n }\n\n .tr703-log {\n list-style: none;\n margin: 0;\n padding: 8px 10px;\n border: 1px solid var(--sg-border);\n border-radius: 8px;\n background: var(--sg-header-bg);\n font-size: 11.5px;\n flex-shrink: 0;\n display: grid;\n gap: 2px;\n }\n .tr703-log li { display: flex; gap: 8px; min-width: 0; white-space: nowrap; }\n .tr703-path {\n font-family: ui-monospace, SFMono-Regular, Menlo, monospace;\n color: var(--sg-fg);\n overflow: hidden;\n text-overflow: ellipsis;\n min-width: 0;\n }\n .tr703-method {\n font-family: ui-monospace, SFMono-Regular, Menlo, monospace;\n font-weight: 600;\n width: 44px;\n flex-shrink: 0;\n color: var(--sg-muted);\n }\n .tr703-method[data-method='POST'], .tr703-method[data-method='PATCH'] { color: var(--sg-accent); }\n\n .tr703-form { display: grid; gap: 14px; }\n .tr703-field { display: grid; gap: 6px; font-size: 12.5px; color: var(--sg-muted); }\n\n /* Cells render inside the grid, so their rules are global. */\n :global(.tr703-name) {\n display: inline-flex;\n align-items: center;\n gap: 7px;\n min-width: 0;\n }\n :global(.tr703-name[data-kind='env'] .tr703-label) { font-weight: 600; }\n :global(.tr703-label) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n :global(.tr703-mono) { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92em; }\n :global(.tr703-check) { width: 14px; height: 14px; margin: 0; accent-color: var(--sg-accent); flex-shrink: 0; }\n :global(.tr703-reload) {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 20px;\n height: 20px;\n padding: 0;\n border: 0;\n border-radius: 4px;\n background: transparent;\n color: var(--sg-muted);\n cursor: pointer;\n flex-shrink: 0;\n }\n :global(.tr703-reload:hover) { background: var(--sg-header-bg); color: var(--sg-fg); }\n :global(.tr703-reload:focus-visible) { outline: 2px solid var(--sg-focus-ring, var(--sg-accent)); outline-offset: 1px; }\n :global(.tr703-reload:disabled) { cursor: default; }\n :global(.tr703-spin svg) { animation: tr703-spin 0.8s linear infinite; }\n @keyframes -global-tr703-spin { to { transform: rotate(360deg); } }\n :global(.tr703-arch) {\n font-family: ui-monospace, SFMono-Regular, Menlo, monospace;\n font-size: 11.5px;\n font-weight: 600;\n color: var(--sg-fg);\n }\n :global(.tr703-glyph) { display: inline-flex; flex-shrink: 0; }\n :global(.tr703-glyph[data-outcome='failed']) { color: var(--sg-danger, #dc2626); }\n :global(.tr703-glyph[data-outcome='passed']) { color: var(--sg-success, #16a34a); }\n :global(.tr703-glyph[data-outcome='skipped']) { color: var(--sg-muted); }\n :global(.tr703-new) {\n font-size: 10px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.04em;\n padding: 0 6px;\n border-radius: 999px;\n color: var(--sg-accent);\n border: 1px solid currentColor;\n flex-shrink: 0;\n }\n\n :global(.tr703-pill) {\n display: inline-block;\n padding: 1px 10px;\n border-radius: 999px;\n font-size: 11.5px;\n border: 1px solid var(--sg-border);\n color: var(--sg-muted);\n white-space: nowrap;\n }\n :global(.tr703-pill[data-tone='approved']),\n :global(.tr703-pill[data-tone='passed']) {\n color: var(--sg-success, #16a34a);\n border-color: color-mix(in srgb, var(--sg-success, #16a34a) 45%, transparent);\n }\n :global(.tr703-pill[data-tone='rejected']),\n :global(.tr703-pill[data-tone='failed']) {\n color: var(--sg-danger, #dc2626);\n border-color: color-mix(in srgb, var(--sg-danger, #dc2626) 45%, transparent);\n }\n :global(.tr703-pill[data-tone='done']) { color: var(--sg-fg); }\n :global(.tr703-tag) {\n font-size: 11px;\n padding: 0 7px;\n border-radius: 4px;\n background: var(--sg-header-bg);\n color: var(--sg-muted);\n font-weight: 500;\n }\n :global(.tr703-progress) { display: inline-flex; align-items: center; gap: 8px; width: 100%; }\n :global(.tr703-bar) {\n flex: 1;\n max-width: 80px;\n height: 5px;\n border-radius: 999px;\n background: var(--sg-border);\n overflow: hidden;\n }\n :global(.tr703-bar > span) { display: block; height: 100%; background: var(--sg-accent); transition: width 300ms ease; }\n :global(.tr703-num) { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--sg-fg); }\n\n :global(.tr703-detail) { display: inline-flex; gap: 10px; min-width: 0; }\n :global(.tr703-muted) { color: var(--sg-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n :global(.tr703-bug) { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--sg-fg); }\n :global(.tr703-ago) { font-size: 12px; color: var(--sg-muted); font-variant-numeric: tabular-nums; }\n :global(.tr703-behind) { color: var(--sg-warning, #b45309); }\n\n :global(.tr703-actions) { display: flex; justify-content: flex-end; gap: 12px; width: 100%; padding-right: 10px; }\n :global(.tr703-link) {\n border: 0;\n padding: 0;\n background: transparent;\n color: var(--sg-accent);\n font-size: 12.5px;\n cursor: pointer;\n }\n :global(.tr703-link:hover) { text-decoration: underline; }\n :global(.tr703-link:focus-visible) { outline: 2px solid var(--sg-focus-ring, var(--sg-accent)); outline-offset: 2px; border-radius: 2px; }\n</style>\n"
|
|
4073
|
+
},
|
|
4066
4074
|
{
|
|
4067
4075
|
"id": "704-agent-review-desk",
|
|
4068
4076
|
"path": "examples/src/demos/704-agent-review-desk.svelte",
|
|
@@ -4373,7 +4381,7 @@ export const docs = [
|
|
|
4373
4381
|
"path": "docs/brand/social/README.md",
|
|
4374
4382
|
"title": "GitHub social preview images",
|
|
4375
4383
|
"section": "Brand",
|
|
4376
|
-
"markdown": "# GitHub social preview images\n\nOn-brand 1280x640 cards for GitHub's repo **Social preview** (Settings ->\nGeneral -> Social preview). All are PNG, 1280x640 (GitHub's recommended size),\nand well under the 1 MB upload limit.\n\n| File | Use |\n| --- | --- |\n| `svgrid-github-social.png` | Primary. Headline lockup: \"The Svelte 5 data grid. / Headless-first. Render-ready.\" |\n| `svgrid-github-social-product.png` | Product card: headline + a mini-grid showing an accent-highlighted cell. |\n| `svgrid-github-social-centered.png` | Centered, minimal: mark + wordmark + tagline. |\n\n## Apply on GitHub\n\n1. Repo -> **Settings** -> **General**.\n2. Scroll to **Social preview** -> **Edit** -> upload one of the PNGs above.\n\n(The image lives in GitHub's settings, not in code - it is not auto-read from\nthe repo.
|
|
4384
|
+
"markdown": "# GitHub social preview images\n\nOn-brand 1280x640 cards for GitHub's repo **Social preview** (Settings ->\nGeneral -> Social preview). All are PNG, 1280x640 (GitHub's recommended size),\nand well under the 1 MB upload limit.\n\n| File | Use |\n| --- | --- |\n| `svgrid-github-social.png` | Primary. Headline lockup: \"The Svelte 5 data grid. / Headless-first. Render-ready.\" |\n| `svgrid-github-social-product.png` | Product card: headline + a mini-grid showing an accent-highlighted cell. |\n| `svgrid-github-social-centered.png` | Centered, minimal: mark + wordmark + tagline. |\n\n## Apply on GitHub\n\n1. Repo -> **Settings** -> **General**.\n2. Scroll to **Social preview** -> **Edit** -> upload one of the PNGs above.\n\n(The image lives in GitHub's settings, not in code - it is not auto-read from\nthe repo. The PNGs are gitignored; render them with the script below.)\n\n## Regenerate\n\n```bash\nnode tools/render-social-preview.mjs\n```\n\nRenders all three via Chromium (Playwright) at 1280x640. Brand tokens (dark\nnavy gradient, the 4-tile mark, the Svelte orange->red accent) are lifted from\n`website/public/og-image.svg`; edit the variant markup in the script to tweak\ncopy or layout. Inter is pulled from Google Fonts when online and falls back to\nthe system sans otherwise.\n"
|
|
4377
4385
|
},
|
|
4378
4386
|
{
|
|
4379
4387
|
"slug": "changelog",
|
|
@@ -5024,7 +5032,7 @@ export const docs = [
|
|
|
5024
5032
|
"path": "docs/help/base/templates.md",
|
|
5025
5033
|
"title": "Ready-to-use bases",
|
|
5026
5034
|
"section": "SvGrid Base",
|
|
5027
|
-
"markdown": "# Ready-to-use bases\n\nEach base below is one `<SvBase>` with sample data: the fields, the saved\nviews and the forms a team would set up on day one. Open the source of any of\nthem, replace the sample rows with your own, and it is your app's tool.\n\nAll of them share the same parts, so what works in one works in all: the table\ntabs (where a base has more than one table), the view bar (Hide fields, Filter, Group, Sort, Color, Row height, search), the\nexpanded record with its changes and comments, Space on a row to open it,\n\"+ Add row\", the field editor, the selection bar for editing or deleting many\nrows at once, and dragging the pinned columns' edge.\n\n## Project tracker\n\nTwo tables, Tasks and Milestones. Tasks have a status, tags, an assignee,\ndates, an estimate, progress, a budget, files and a milestone; each milestone\nlists its tasks with their average progress and their budget. The\n[tutorial](./start.md) builds the task table step by step.\n\n## Content calendar\n\n<div data-docs-demo=\"511-base-content-calendar\" data-height=\"640\"></div>\n\nTwo tables, Posts and Campaigns. A post has a stage, channels, an author, a\npublish date, a cover image, a word count, a brief and its campaign; a\ncampaign lists its posts and adds up their words.\n\n- **Content plan:** the posts in publishing order, colored by stage, word\n counts summed in the footer.\n- **Pipeline:** a Kanban by stage; dragging a card moves the post along.\n- **Publishing calendar:** posts on their publish date; drag one to another\n day, or pick an empty day to schedule a new one.\n- **Covers:** a gallery of the cover images.\n- **Pitch an idea:** a form with the title, channels, author and brief.\n\n## Sales CRM\n\n<div data-docs-demo=\"512-base-sales-crm\" data-height=\"640\"></div>\n\nThree tables: Deals, Accounts and Contacts. A deal links to an account and a\ncontact and has a stage, an owner, a value, a probability, a close date, the\nnext step, a source and a priority. An account lists its deals and contacts\nand rolls up its pipeline value; a contact lists its deals.\n\n- **All deals:** biggest first, colored by stage; the footer sums the value\n and averages the probability.\n- **Pipeline:** a Kanban by stage.\n- **Closing calendar:** deals on their close date.\n- **Open deals by owner:** grouped by owner, Won and Lost filtered out; each\n group shows its own totals.\n- **New lead:** a form that starts a deal in the Lead stage.\n\nLinking a deal to an account lists it on the account, and the other way\nround. Hover a chip to preview the account, click it to open it (\"Open in\nAccounts\" goes there), and create a new account from the link picker.\n\n## Product roadmap\n\n<div data-docs-demo=\"513-base-product-roadmap\" data-height=\"640\"></div>\n\nTwo tables, Features and Feedback. A feature has a quarter, a status, teams,\na lead, impact, effort in days, start and target dates, customer votes and a\nspec link; each customer request links to the feature it is about, and the\nfeature counts them.\n\n- **Roadmap by quarter:** grouped by quarter, highest impact first, each\n group with its effort and votes; \"+\" in a group adds a feature to that\n quarter.\n- **Status board:** a Kanban by status.\n- **Timeline:** each feature from its start to its target date.\n- **Now:** in progress, in beta or blocked, by target date.\n- **Request a feature:** a form for anyone in the company.\n\n## Hiring tracker\n\n<div data-docs-demo=\"514-base-hiring-tracker\" data-height=\"640\"></div>\n\nTwo tables, Candidates and Roles. A candidate has a photo, a role, a stage, a\nrecruiter, a rating, the interview date, the salary ask, an email, a resume,\nthe source and notes; a role has its team, hiring manager and headcount, and\nlists its candidates.\n\n- **Hiring pipeline:** a Kanban by stage.\n- **All candidates:** best rated first, colored by stage.\n- **Faces:** a gallery of the photos.\n- **Interviews:** a calendar of interview dates.\n- **Apply:** the form a candidate fills in, with their resume.\n\n## Inventory\n\n<div data-docs-demo=\"515-base-inventory\" data-height=\"640\"></div>\n\nTwo tables, Items and Suppliers. An item has photos, a category, a location,\na supplier, the quantity, the unit cost, the stock value (a formula,\n`{Qty} * {Unit cost}`), the condition, who has it checked out, when it was\nlast counted and a barcode; a supplier lists its items and the units in\nstock.\n\n- **Stock by category:** grouped by category, the footer and each group\n summing quantity and value.\n- **Photos:** a gallery.\n- **By location:** a Kanban by location; dragging an item moves it.\n- **Reorder:** three or fewer in stock, red at zero and amber below four.\n- **Add an item:** a form.\n\n## Bug tracker\n\n<div data-docs-demo=\"520-base-bug-tracker\" data-height=\"640\"></div>\n\nTwo tables, Bugs and Releases. A bug has a severity, a status, the areas it\ntouches, who reported it and who is on it, the release it ships in, the\nsteps to reproduce, and when it was reported and fixed. A release lists its\nbugs and counts them.\n\n\n\n- **Triage:** grouped by status, colored by severity.\n- **Board:** a Kanban by status.\n- **Critical now:** critical bugs that are not fixed.\n- **Bugs by area:** a bar chart.\n- **Report a bug:** the form anyone can fill in.\n\nAutomations: a critical bug that is not fixed turns red and raises a notice;\nsetting Status to Fixed stamps \"Fixed on\"; a bug from the form starts as\nNew; **Start** in the Fix column moves a bug to In progress.\n\n## Event planning\n\n<div data-docs-demo=\"521-base-event-planning\" data-height=\"640\"></div>\n\nThree tables: Events, Attendees and Checklist. An event has a date, a venue,\na status, an owner, a budget and a capacity; it counts who registered and\nworks out the seats left (`{Capacity} - {Registered}`). Attendees have a\nticket type and check in on the day; checklist items have a team and a due\ndate.\n\n\n\n- **Calendar:** events on their date, colored by status.\n- **Planning board:** a Kanban by status.\n- **Guest list:** attendees grouped by event.\n- **Tickets by type:** a donut.\n- **RSVP:** the form a guest fills in.\n\nAutomations: an event that turns Confirmed gets its checklist (three items\ncreated in Checklist and linked back to it); an event with no seats left\nturns red and raises a notice, also when the last seat goes from the\nAttendees table; a guest who RSVPs is told they are in.\n\n## OKRs\n\n<div data-docs-demo=\"522-base-okrs\" data-height=\"640\"></div>\n\nTwo tables, Key results and Objectives. A key result measures something from\na start value to a target; its progress is a formula,\n`MAX(0, MIN(1, ({Current} - {Start}) / ({Target} - {Start})))`, and its\nconfidence says whether it will get there. An objective has a quarter and an\nowner, and averages the progress of its key results with a rollup.\n\n\n\n- **By objective:** key results grouped by objective, colored by confidence.\n- **Confidence:** a Kanban.\n- **Weekly check-in:** the numbers to update, least recently checked first.\n- **Progress by objective:** a bar chart of the rollup.\n\nAutomations: a key result that falls Off track turns red and raises a\nnotice; one that reaches its target is marked Achieved.\n\n## Expense approvals\n\n<div data-docs-demo=\"523-base-expenses\" data-height=\"640\"></div>\n\nTwo tables, Expenses and Budgets. An expense has an amount, a category, a\ndate, who spent it, a receipt, a status from Draft to Paid, and who approved\nit and when. A budget category lists its expenses, adds up what was spent\n(a rollup) and shows what is left (a formula over the rollup).\n\n\n\n- **This month:** newest first, colored by status, totals in the footer.\n- **Approvals:** a Kanban by status.\n- **Spend by category:** a pie of the amounts.\n- **Receipts:** a gallery.\n- **Submit an expense:** the form.\n\nAutomations: an expense over $1,000 goes to Needs approval; **Approve** in\nthe Review column approves it and records who and when; a rejected expense\nturns red; one sent with the form starts as Submitted; a category over its\nbudget raises a notice.\n\n## Employee onboarding\n\n<div data-docs-demo=\"524-base-onboarding\" data-height=\"640\"></div>\n\nThree tables: People, Checklist and Departments. A person has a photo, a\nrole, a department, a manager, a start date and a status; checklist items\nhave an owner (IT, HR or the manager) and a due date; departments list their\npeople and count them.\n\n\n\n- **Pipeline:** a Kanban by status.\n- **Photo directory:** a gallery.\n- **Start dates:** a calendar.\n- **By department:** grouped by department.\n- **Add a new hire:** the form.\n\nAutomations: a new hire, from \"+ Add row\" or the form, gets a checklist:\nthree items for IT, HR and their manager, created in Checklist and linked\nback. Someone starting within a week has their start date colored, and\n**Activate** in the Ready column marks them Active.\n\n## Start from your own database\n\nEvery template here is also a database. `npm create @svgrid@latest my-base\n-- -t base` offers each one by name and writes it as SQL to `db/schema.sql`,\nwith its records, views and automations, on Postgres in the browser, your\nown Postgres or Supabase ([From a database to an app](./quick-start.md)):\n\n```bash\nnpm create @svgrid@latest my-base -- -t base --data supabase --sample bug-tracker\n```\n\nThe names: `project-tracker`, `sales-crm`, `content-calendar`,\n`product-roadmap`, `hiring-tracker`, `inventory`, `bug-tracker`,\n`event-planning`, `okrs`, `expenses`, `onboarding`. A base you changed\nhere goes the same way: \"All tables\", then **Download as SQL**.\n"
|
|
5035
|
+
"markdown": "# Ready-to-use bases\n\nEach base below is one `<SvBase>` with sample data: the fields, the saved\nviews and the forms a team would set up on day one. Open the source of any of\nthem, replace the sample rows with your own, and it is your app's tool.\n\nTo try one with nothing installed, open it full screen at\n[svgrid.com/base](https://svgrid.com/base); the bar at the top switches between\nthem.\n\nAll of them share the same parts, so what works in one works in all: the table\ntabs (where a base has more than one table), the view bar (Hide fields, Filter, Group, Sort, Color, Row height, search), the\nexpanded record with its changes and comments, Space on a row to open it,\n\"+ Add row\", the field editor, the selection bar for editing or deleting many\nrows at once, and dragging the pinned columns' edge.\n\n## Project tracker\n\nTwo tables, Tasks and Milestones. Tasks have a status, tags, an assignee,\ndates, an estimate, progress, a budget, files and a milestone; each milestone\nlists its tasks with their average progress and their budget. The\n[tutorial](./start.md) builds the task table step by step.\n\n## Content calendar\n\n<div data-docs-demo=\"511-base-content-calendar\" data-height=\"640\"></div>\n\nTwo tables, Posts and Campaigns. A post has a stage, channels, an author, a\npublish date, a cover image, a word count, a brief and its campaign; a\ncampaign lists its posts and adds up their words.\n\n- **Content plan:** the posts in publishing order, colored by stage, word\n counts summed in the footer.\n- **Pipeline:** a Kanban by stage; dragging a card moves the post along.\n- **Publishing calendar:** posts on their publish date; drag one to another\n day, or pick an empty day to schedule a new one.\n- **Covers:** a gallery of the cover images.\n- **Pitch an idea:** a form with the title, channels, author and brief.\n\n## Sales CRM\n\n<div data-docs-demo=\"512-base-sales-crm\" data-height=\"640\"></div>\n\nThree tables: Deals, Accounts and Contacts. A deal links to an account and a\ncontact and has a stage, an owner, a value, a probability, a close date, the\nnext step, a source and a priority. An account lists its deals and contacts\nand rolls up its pipeline value; a contact lists its deals.\n\n- **All deals:** biggest first, colored by stage; the footer sums the value\n and averages the probability.\n- **Pipeline:** a Kanban by stage.\n- **Closing calendar:** deals on their close date.\n- **Open deals by owner:** grouped by owner, Won and Lost filtered out; each\n group shows its own totals.\n- **New lead:** a form that starts a deal in the Lead stage.\n\nLinking a deal to an account lists it on the account, and the other way\nround. Hover a chip to preview the account, click it to open it (\"Open in\nAccounts\" goes there), and create a new account from the link picker.\n\n## Product roadmap\n\n<div data-docs-demo=\"513-base-product-roadmap\" data-height=\"640\"></div>\n\nTwo tables, Features and Feedback. A feature has a quarter, a status, teams,\na lead, impact, effort in days, start and target dates, customer votes and a\nspec link; each customer request links to the feature it is about, and the\nfeature counts them.\n\n- **Roadmap by quarter:** grouped by quarter, highest impact first, each\n group with its effort and votes; \"+\" in a group adds a feature to that\n quarter.\n- **Status board:** a Kanban by status.\n- **Timeline:** each feature from its start to its target date.\n- **Now:** in progress, in beta or blocked, by target date.\n- **Request a feature:** a form for anyone in the company.\n\n## Hiring tracker\n\n<div data-docs-demo=\"514-base-hiring-tracker\" data-height=\"640\"></div>\n\nTwo tables, Candidates and Roles. A candidate has a photo, a role, a stage, a\nrecruiter, a rating, the interview date, the salary ask, an email, a resume,\nthe source and notes; a role has its team, hiring manager and headcount, and\nlists its candidates.\n\n- **Hiring pipeline:** a Kanban by stage.\n- **All candidates:** best rated first, colored by stage.\n- **Faces:** a gallery of the photos.\n- **Interviews:** a calendar of interview dates.\n- **Apply:** the form a candidate fills in, with their resume.\n\n## Inventory\n\n<div data-docs-demo=\"515-base-inventory\" data-height=\"640\"></div>\n\nTwo tables, Items and Suppliers. An item has photos, a category, a location,\na supplier, the quantity, the unit cost, the stock value (a formula,\n`{Qty} * {Unit cost}`), the condition, who has it checked out, when it was\nlast counted and a barcode; a supplier lists its items and the units in\nstock.\n\n- **Stock by category:** grouped by category, the footer and each group\n summing quantity and value.\n- **Photos:** a gallery.\n- **By location:** a Kanban by location; dragging an item moves it.\n- **Reorder:** three or fewer in stock, red at zero and amber below four.\n- **Add an item:** a form.\n\n## Bug tracker\n\n<div data-docs-demo=\"520-base-bug-tracker\" data-height=\"640\"></div>\n\nTwo tables, Bugs and Releases. A bug has a severity, a status, the areas it\ntouches, who reported it and who is on it, the release it ships in, the\nsteps to reproduce, and when it was reported and fixed. A release lists its\nbugs and counts them.\n\n\n\n- **Triage:** grouped by status, colored by severity.\n- **Board:** a Kanban by status.\n- **Critical now:** critical bugs that are not fixed.\n- **Bugs by area:** a bar chart.\n- **Report a bug:** the form anyone can fill in.\n\nAutomations: a critical bug that is not fixed turns red and raises a notice;\nsetting Status to Fixed stamps \"Fixed on\"; a bug from the form starts as\nNew; **Start** in the Fix column moves a bug to In progress.\n\n## Event planning\n\n<div data-docs-demo=\"521-base-event-planning\" data-height=\"640\"></div>\n\nThree tables: Events, Attendees and Checklist. An event has a date, a venue,\na status, an owner, a budget and a capacity; it counts who registered and\nworks out the seats left (`{Capacity} - {Registered}`). Attendees have a\nticket type and check in on the day; checklist items have a team and a due\ndate.\n\n\n\n- **Calendar:** events on their date, colored by status.\n- **Planning board:** a Kanban by status.\n- **Guest list:** attendees grouped by event.\n- **Tickets by type:** a donut.\n- **RSVP:** the form a guest fills in.\n\nAutomations: an event that turns Confirmed gets its checklist (three items\ncreated in Checklist and linked back to it); an event with no seats left\nturns red and raises a notice, also when the last seat goes from the\nAttendees table; a guest who RSVPs is told they are in.\n\n## OKRs\n\n<div data-docs-demo=\"522-base-okrs\" data-height=\"640\"></div>\n\nTwo tables, Key results and Objectives. A key result measures something from\na start value to a target; its progress is a formula,\n`MAX(0, MIN(1, ({Current} - {Start}) / ({Target} - {Start})))`, and its\nconfidence says whether it will get there. An objective has a quarter and an\nowner, and averages the progress of its key results with a rollup.\n\n\n\n- **By objective:** key results grouped by objective, colored by confidence.\n- **Confidence:** a Kanban.\n- **Weekly check-in:** the numbers to update, least recently checked first.\n- **Progress by objective:** a bar chart of the rollup.\n\nAutomations: a key result that falls Off track turns red and raises a\nnotice; one that reaches its target is marked Achieved.\n\n## Expense approvals\n\n<div data-docs-demo=\"523-base-expenses\" data-height=\"640\"></div>\n\nTwo tables, Expenses and Budgets. An expense has an amount, a category, a\ndate, who spent it, a receipt, a status from Draft to Paid, and who approved\nit and when. A budget category lists its expenses, adds up what was spent\n(a rollup) and shows what is left (a formula over the rollup).\n\n\n\n- **This month:** newest first, colored by status, totals in the footer.\n- **Approvals:** a Kanban by status.\n- **Spend by category:** a pie of the amounts.\n- **Receipts:** a gallery.\n- **Submit an expense:** the form.\n\nAutomations: an expense over $1,000 goes to Needs approval; **Approve** in\nthe Review column approves it and records who and when; a rejected expense\nturns red; one sent with the form starts as Submitted; a category over its\nbudget raises a notice.\n\n## Employee onboarding\n\n<div data-docs-demo=\"524-base-onboarding\" data-height=\"640\"></div>\n\nThree tables: People, Checklist and Departments. A person has a photo, a\nrole, a department, a manager, a start date and a status; checklist items\nhave an owner (IT, HR or the manager) and a due date; departments list their\npeople and count them.\n\n\n\n- **Pipeline:** a Kanban by status.\n- **Photo directory:** a gallery.\n- **Start dates:** a calendar.\n- **By department:** grouped by department.\n- **Add a new hire:** the form.\n\nAutomations: a new hire, from \"+ Add row\" or the form, gets a checklist:\nthree items for IT, HR and their manager, created in Checklist and linked\nback. Someone starting within a week has their start date colored, and\n**Activate** in the Ready column marks them Active.\n\n## Start from your own database\n\nEvery template here is also a database. `npm create @svgrid@latest my-base\n-- -t base` offers each one by name and writes it as SQL to `db/schema.sql`,\nwith its records, views and automations, on Postgres in the browser, your\nown Postgres or Supabase ([From a database to an app](./quick-start.md)):\n\n```bash\nnpm create @svgrid@latest my-base -- -t base --data supabase --sample bug-tracker\n```\n\nThe names: `project-tracker`, `sales-crm`, `content-calendar`,\n`product-roadmap`, `hiring-tracker`, `inventory`, `bug-tracker`,\n`event-planning`, `okrs`, `expenses`, `onboarding`. A base you changed\nhere goes the same way: \"All tables\", then **Download as SQL**.\n"
|
|
5028
5036
|
},
|
|
5029
5037
|
{
|
|
5030
5038
|
"slug": "help/base/views",
|
|
@@ -6032,7 +6040,7 @@ export const docs = [
|
|
|
6032
6040
|
"path": "docs/help/rows/tree-data.md",
|
|
6033
6041
|
"title": "Tree data",
|
|
6034
6042
|
"section": "Rows",
|
|
6035
|
-
"markdown": "# Tree data\n\nNest rows into an expandable hierarchy with the `treeData` prop.\n\n<div data-docs-demo=\"426-tree-data\" data-height=\"520\"></div>\n\n<!-- tutorial:tree-data -->\n<figure class=\"docs-tutorial\" id=\"tutorial-tree-data\" data-docs-tutorial=\"tree-data\">\n<video class=\"docs-tutorial-video\" src=\"/tutorials/tree-data.mp4\" poster=\"/tutorials/tree-data.poster.webp\" width=\"960\" height=\"540\" muted loop playsinline preload=\"none\" aria-label=\"Tree data in SvGrid, 31 second tutorial\"><track kind=\"captions\" srclang=\"en\" label=\"English\" src=\"/tutorials/tree-data.vtt\" default>Your browser does not play embedded video. <a href=\"/tutorials/tree-data.mp4\">Download the MP4</a>.</video>\n<figcaption><strong>Tree data in SvGrid</strong> (31 s, silent).</figcaption>\n<details class=\"docs-tutorial-transcript\"><summary>Transcript</summary>\n<p>Tree data is one prop. Point treeData at the parent field and name the tree column, and flat rows become a hierarchy.</p>\n<p>Click an expander to open a branch. Children indent under their parent and keep every column.</p>\n<p>Expand all and Collapse all walk the whole tree through the grid API.</p>\n<p>Nested objects work too: flatten them once with flattenTreeData, and the same prop takes it from there.</p>\n</details>\n</figure>\n<!-- /tutorial:tree-data -->\n\nTree rows are **real data rows**. They keep their own cells, formatting,\nediting and selection, and only gain an expander plus indentation in the tree\ncolumn. That is the difference from row grouping, where the parent is a\nsynthetic full-width banner standing in for its children.\n\n## Flat data (parent id)\n\nThe model nests by parent id, so data that already carries one needs no\npreparation:\n\nThe examples on this page run against these rows:\n\n```svelte {preamble}\n<script lang=\"ts\">\n import { SvGrid, type GridColumns } from '@svgrid/grid'\n\n type Person = {\n id: number\n name: string\n email: string\n department: string\n age: number\n salary: number\n city: string\n startDate: string\n active: boolean\n }\n\n const people: Person[] = [\n { id: 1, name: 'Ada Lovelace', email: 'ada@example.com', department: 'Engineering', age: 36, salary: 142000, city: 'London', startDate: '2021-03-01', active: true },\n { id: 2, name: 'Grace Hopper', email: 'grace@example.com', department: 'Engineering', age: 45, salary: 168000, city: 'New York', startDate: '2019-07-15', active: true },\n { id: 3, name: 'Linus Torvalds', email: 'linus@example.com', department: 'Platform', age: 54, salary: 155000, city: 'Portland', startDate: '2020-01-20', active: false },\n { id: 4, name: 'Radia Perlman', email: 'radia@example.com', department: 'Networking', age: 49, salary: 161000, city: 'Seattle', startDate: '2022-09-05', active: true },\n { id: 5, name: 'Barbara Liskov', email: 'barbara@example.com', department: 'Platform', age: 52, salary: 172000, city: 'Boston', startDate: '2018-11-11', active: true },\n ]\n\n const columns: GridColumns<Person> = [\n { field: 'name', header: 'Name', width: 200 },\n { field: 'department', header: 'Department', width: 150 },\n { field: 'city', header: 'City', width: 140 },\n { field: 'age', header: 'Age', width: 90 },\n { field: 'salary', header: 'Salary', width: 130, format: { type: 'currency', currency: 'USD' } },\n ]\n</script>\n```\n\n```svelte\n<script lang=\"ts\">\n import { SvGrid } from '@svgrid/grid'\n\n const people = [\n { id: 1, managerId: null, name: 'Ada', title: 'CEO' },\n { id: 2, managerId: 1, name: 'Grace', title: 'VP Engineering' },\n { id: 3, managerId: 2, name: 'Alan', title: 'Principal Engineer' },\n ]\n</script>\n\n<SvGrid\n data={people}\n {columns}\n treeData={{ parentField: 'managerId', column: 'name' }}\n/>\n```\n\n| Option | Meaning |\n| --- | --- |\n| `parentField` | Field holding each row's parent id. Required. |\n| `idField` | Field holding the row's own id. Defaults to `'id'`. |\n| `column` | Column that carries the expander + indent. Defaults to the first visible column. |\n| `indentPx` | Indent per depth level, in px. Default `12`. |\n\n## Nested data (children arrays)\n\nThe grid only builds rows for the objects in `data`, so children nested inside\na parent are never rows. Flatten them first:\n\n```svelte\n<script lang=\"ts\">\n import { SvGrid, flattenTreeData } from '@svgrid/grid'\n\n const tree = [\n { id: 1, name: 'src', children: [\n { id: 2, name: 'components', children: [{ id: 3, name: 'Grid.svelte' }] },\n ] },\n ]\n\n // Stamps `__parentId` on every child and returns one flat list, children\n // directly after their parent.\n const rows = flattenTreeData(tree, { childrenField: 'children' })\n</script>\n\n<SvGrid data={rows} {columns} treeData={{ parentField: '__parentId', column: 'name' }} />\n```\n\n`flattenTreeData` takes `childrenField`, plus optional `idField` (default\n`'id'`) and `parentField` (default `'__parentId'`) if you want a different link\nfield.\n\n## Accessibility\n\nTurning on `treeData` puts the grid in the `treegrid` role. Every row gets\n`aria-level`, and expandable rows get `aria-expanded`. Keyboard:\n\n| Key | Action |\n| --- | --- |\n| <kbd>→</kbd> | Expand the focused row |\n| <kbd>←</kbd> | Collapse the focused row |\n| <kbd>Enter</kbd> / click | Toggle via the expander button |\n\nRows without children render a spacer where the chevron would be, so values\nstay aligned with their expandable siblings.\n\n## Edge cases\n\n- **Missing parent.** A row whose `parentField` points at an id that is not in\n the data becomes a root rather than disappearing. Losing rows silently is\n worse than a shallower tree - this matters when a filter removes a parent but\n keeps a child.\n- **Self-parenting.** A row that names itself as its parent is treated as a root.\n- **Cycles.** A loop in the parent chain is detected and stops the walk instead\n of recursing forever.\n- **Grouping.** `treeData` replaces row grouping - a row cannot be both a\n hierarchy node and bucketed under a group banner.\n\n## Server-side trees\n\nFor hierarchies too large to send at once, load children on demand with the\nEnterprise `createServerRowModel` (`treeData: true`) over a `ServerDataSource`\ninstead - see [Server tree data](../server/server-tree-data.md). The two share\nthe same treegrid keyboard and ARIA contract.\n\n## More examples\n\n### Project WBS tree\n\nPhase → task → subtask with % complete that rolls up via effort-weighted average when you edit any leaf.\n\n<div data-docs-demo=\"29-wbs-project-tree\" data-height=\"460\"></div>\n\n### Bill of Materials\n\nBicycle BOM, 4 levels deep. Edit any leaf part's qty or unit cost; subtotals roll up through the assembly chain to the grand total.\n\n<div data-docs-demo=\"30-bom-tree\" data-height=\"460\"></div>\n\n## See also\n\n- [Demo #426 Tree data](https://svgrid.com/demos/426-tree-data/)\n- [Grouping & aggregation](../grouping-aggregation.md) - the row-bucketing shape\n- [Master / detail](./master-detail.md) - a rich panel under a row, rather than child rows\n"
|
|
6043
|
+
"markdown": "# Tree data\n\nNest rows into an expandable hierarchy with the `treeData` prop.\n\n<div data-docs-demo=\"426-tree-data\" data-height=\"520\"></div>\n\n<!-- tutorial:tree-data -->\n<figure class=\"docs-tutorial\" id=\"tutorial-tree-data\" data-docs-tutorial=\"tree-data\">\n<video class=\"docs-tutorial-video\" src=\"/tutorials/tree-data.mp4\" poster=\"/tutorials/tree-data.poster.webp\" width=\"960\" height=\"540\" muted loop playsinline preload=\"none\" aria-label=\"Tree data in SvGrid, 31 second tutorial\"><track kind=\"captions\" srclang=\"en\" label=\"English\" src=\"/tutorials/tree-data.vtt\" default>Your browser does not play embedded video. <a href=\"/tutorials/tree-data.mp4\">Download the MP4</a>.</video>\n<figcaption><strong>Tree data in SvGrid</strong> (31 s, silent).</figcaption>\n<details class=\"docs-tutorial-transcript\"><summary>Transcript</summary>\n<p>Tree data is one prop. Point treeData at the parent field and name the tree column, and flat rows become a hierarchy.</p>\n<p>Click an expander to open a branch. Children indent under their parent and keep every column.</p>\n<p>Expand all and Collapse all walk the whole tree through the grid API.</p>\n<p>Nested objects work too: flatten them once with flattenTreeData, and the same prop takes it from there.</p>\n</details>\n</figure>\n<!-- /tutorial:tree-data -->\n\nTree rows are **real data rows**. They keep their own cells, formatting,\nediting and selection, and only gain an expander plus indentation in the tree\ncolumn. That is the difference from row grouping, where the parent is a\nsynthetic full-width banner standing in for its children.\n\n## Flat data (parent id)\n\nThe model nests by parent id, so data that already carries one needs no\npreparation:\n\nThe examples on this page run against these rows:\n\n```svelte {preamble}\n<script lang=\"ts\">\n import { SvGrid, type GridColumns } from '@svgrid/grid'\n\n type Person = {\n id: number\n name: string\n email: string\n department: string\n age: number\n salary: number\n city: string\n startDate: string\n active: boolean\n }\n\n const people: Person[] = [\n { id: 1, name: 'Ada Lovelace', email: 'ada@example.com', department: 'Engineering', age: 36, salary: 142000, city: 'London', startDate: '2021-03-01', active: true },\n { id: 2, name: 'Grace Hopper', email: 'grace@example.com', department: 'Engineering', age: 45, salary: 168000, city: 'New York', startDate: '2019-07-15', active: true },\n { id: 3, name: 'Linus Torvalds', email: 'linus@example.com', department: 'Platform', age: 54, salary: 155000, city: 'Portland', startDate: '2020-01-20', active: false },\n { id: 4, name: 'Radia Perlman', email: 'radia@example.com', department: 'Networking', age: 49, salary: 161000, city: 'Seattle', startDate: '2022-09-05', active: true },\n { id: 5, name: 'Barbara Liskov', email: 'barbara@example.com', department: 'Platform', age: 52, salary: 172000, city: 'Boston', startDate: '2018-11-11', active: true },\n ]\n\n const columns: GridColumns<Person> = [\n { field: 'name', header: 'Name', width: 200 },\n { field: 'department', header: 'Department', width: 150 },\n { field: 'city', header: 'City', width: 140 },\n { field: 'age', header: 'Age', width: 90 },\n { field: 'salary', header: 'Salary', width: 130, format: { type: 'currency', currency: 'USD' } },\n ]\n</script>\n```\n\n```svelte\n<script lang=\"ts\">\n import { SvGrid } from '@svgrid/grid'\n\n const people = [\n { id: 1, managerId: null, name: 'Ada', title: 'CEO' },\n { id: 2, managerId: 1, name: 'Grace', title: 'VP Engineering' },\n { id: 3, managerId: 2, name: 'Alan', title: 'Principal Engineer' },\n ]\n</script>\n\n<SvGrid\n data={people}\n {columns}\n treeData={{ parentField: 'managerId', column: 'name' }}\n/>\n```\n\n| Option | Meaning |\n| --- | --- |\n| `parentField` | Field holding each row's parent id. Required. |\n| `idField` | Field holding the row's own id. Defaults to `'id'`. |\n| `column` | Column that carries the expander + indent. Defaults to the first visible column. |\n| `indentPx` | Indent per depth level, in px. Default `12`. |\n\n## Nested data (children arrays)\n\nThe grid only builds rows for the objects in `data`, so children nested inside\na parent are never rows. Flatten them first:\n\n```svelte\n<script lang=\"ts\">\n import { SvGrid, flattenTreeData } from '@svgrid/grid'\n\n const tree = [\n { id: 1, name: 'src', children: [\n { id: 2, name: 'components', children: [{ id: 3, name: 'Grid.svelte' }] },\n ] },\n ]\n\n // Stamps `__parentId` on every child and returns one flat list, children\n // directly after their parent.\n const rows = flattenTreeData(tree, { childrenField: 'children' })\n</script>\n\n<SvGrid data={rows} {columns} treeData={{ parentField: '__parentId', column: 'name' }} />\n```\n\n`flattenTreeData` takes `childrenField`, plus optional `idField` (default\n`'id'`) and `parentField` (default `'__parentId'`) if you want a different link\nfield.\n\n## Accessibility\n\nTurning on `treeData` puts the grid in the `treegrid` role. Every row gets\n`aria-level`, and expandable rows get `aria-expanded`. Keyboard:\n\n| Key | Action |\n| --- | --- |\n| <kbd>→</kbd> | Expand the focused row |\n| <kbd>←</kbd> | Collapse the focused row |\n| <kbd>Enter</kbd> / click | Toggle via the expander button |\n\nRows without children render a spacer where the chevron would be, so values\nstay aligned with their expandable siblings.\n\n## Edge cases\n\n- **Missing parent.** A row whose `parentField` points at an id that is not in\n the data becomes a root rather than disappearing. Losing rows silently is\n worse than a shallower tree - this matters when a filter removes a parent but\n keeps a child.\n- **Self-parenting.** A row that names itself as its parent is treated as a root.\n- **Cycles.** A loop in the parent chain is detected and stops the walk instead\n of recursing forever.\n- **Grouping.** `treeData` replaces row grouping - a row cannot be both a\n hierarchy node and bucketed under a group banner.\n\n## Server-side trees\n\nFor hierarchies too large to send at once, load children on demand with the\nEnterprise `createServerRowModel` (`treeData: true`) over a `ServerDataSource`\ninstead - see [Server tree data](../server/server-tree-data.md). The two share\nthe same treegrid keyboard and ARIA contract.\n\n## More examples\n\n### Test results tree with subtree reload\n\nA release-qualification board as a tree: test environments hold reported issues and test plans, plans hold runs, runs hold their Failed, Passed and Skipped results. The reload icon on an environment, plan or run re-reads that subtree only and splices it back in place, so open nodes stay open; the lab keeps reporting results in the background and a running run shows them after a reload. Rerun, Add result, Add issue and bulk Approve or Reject go through the same server, logged under the grid.\n\n<div data-docs-demo=\"703-test-run-tree\" data-height=\"580\"></div>\n\n\n### Project WBS tree\n\nPhase → task → subtask with % complete that rolls up via effort-weighted average when you edit any leaf.\n\n<div data-docs-demo=\"29-wbs-project-tree\" data-height=\"460\"></div>\n\n### Bill of Materials\n\nBicycle BOM, 4 levels deep. Edit any leaf part's qty or unit cost; subtotals roll up through the assembly chain to the grand total.\n\n<div data-docs-demo=\"30-bom-tree\" data-height=\"460\"></div>\n\n## See also\n\n- [Demo #426 Tree data](https://svgrid.com/demos/426-tree-data/)\n- [Grouping & aggregation](../grouping-aggregation.md) - the row-bucketing shape\n- [Master / detail](./master-detail.md) - a rich panel under a row, rather than child rows\n"
|
|
6036
6044
|
},
|
|
6037
6045
|
{
|
|
6038
6046
|
"slug": "help/rows/tree-rows",
|
package/dist/validate.d.ts
CHANGED
|
@@ -111,6 +111,16 @@ export declare function blankOut(src: string): string;
|
|
|
111
111
|
* small relative to the word so "foo" does not "resolve" to "bar".
|
|
112
112
|
*/
|
|
113
113
|
export declare function nearest(word: string, candidates: readonly string[]): string | null;
|
|
114
|
+
/**
|
|
115
|
+
* Known names about the same thing as `word`, best first, for when `nearest`
|
|
116
|
+
* found no spelling to offer. `detailRenderer` is no typo of anything, but it
|
|
117
|
+
* shares "detail" with `renderDetailRow` and `isDetailRow`, and that short list
|
|
118
|
+
* is what lets a model pick instead of guessing again.
|
|
119
|
+
*
|
|
120
|
+
* Advice only - never a rename. A shared word must be one that few candidates
|
|
121
|
+
* carry, so `rowFoo` does not come back with every prop that starts with `row`.
|
|
122
|
+
*/
|
|
123
|
+
export declare function related(word: string, candidates: readonly string[], limit?: number): string[];
|
|
114
124
|
/** Run every static rule. Exported for tests and for hosts that skip compiling. */
|
|
115
125
|
/**
|
|
116
126
|
* Apply the mechanically-safe renames to the source, returning the corrected
|
package/dist/validate.js
CHANGED
|
@@ -118,6 +118,12 @@ export function nearest(word, candidates) {
|
|
|
118
118
|
// same idea, so the comparison also runs with the verb prefix removed.
|
|
119
119
|
const core = (s) => s.replace(/^(?:get|set|create|make|build|use|enable|with)/i, '');
|
|
120
120
|
const lowerCore = core(lower);
|
|
121
|
+
// `rowHeightAuto` for `autoRowHeight`: the same words in another order is as
|
|
122
|
+
// certain as a typo, and edit distance cannot see it.
|
|
123
|
+
const order = (s) => words(s).sort().join(' ');
|
|
124
|
+
const sameWords = candidates.filter((c) => c !== word && order(c) === order(word));
|
|
125
|
+
if (sameWords.length === 1)
|
|
126
|
+
return sameWords[0];
|
|
121
127
|
const budget = word.length <= 4 ? 1 : word.length <= 8 ? 2 : 3;
|
|
122
128
|
let best = null;
|
|
123
129
|
let bestScore = Infinity;
|
|
@@ -129,8 +135,103 @@ export function nearest(word, candidates) {
|
|
|
129
135
|
best = c;
|
|
130
136
|
}
|
|
131
137
|
}
|
|
138
|
+
// Three edits turn `onRowSelected` into `onRowsDelete`, the opposite. When
|
|
139
|
+
// another name shares more of the words, the spelling match is a
|
|
140
|
+
// coincidence, and since a guess here is applied as a rename, offer none.
|
|
141
|
+
if (best) {
|
|
142
|
+
const top = related(word, candidates, 1)[0];
|
|
143
|
+
if (top && top !== best && sharedStems(word, top) > sharedStems(word, best))
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
132
146
|
return best;
|
|
133
147
|
}
|
|
148
|
+
/** `onRowSelectionChange` -> `on row selection change`. */
|
|
149
|
+
function words(name) {
|
|
150
|
+
return name
|
|
151
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
|
|
152
|
+
.replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')
|
|
153
|
+
.toLowerCase()
|
|
154
|
+
.split(/[^a-z0-9]+/)
|
|
155
|
+
.filter(Boolean);
|
|
156
|
+
}
|
|
157
|
+
// Words that say how a prop is switched on, not what it is about.
|
|
158
|
+
const FILLER_WORDS = new Set(['enable', 'show', 'allow', 'use', 'is', 'has', 'get', 'set', 'with']);
|
|
159
|
+
const STEM_SUFFIXES = ['ations', 'ation', 'ings', 'ing', 'able', 'ion', 'ed', 'es', 's'];
|
|
160
|
+
const STEM_ALIASES = { pagin: 'pag', paginat: 'pag', renderer: 'render' };
|
|
161
|
+
/** Crude stem, so `sorting`, `sortable` and `sorted` all read as `sort`. */
|
|
162
|
+
function stem(word) {
|
|
163
|
+
let w = STEM_ALIASES[word] ?? word;
|
|
164
|
+
for (const s of STEM_SUFFIXES) {
|
|
165
|
+
if (w.length - s.length >= 3 && w.endsWith(s)) {
|
|
166
|
+
w = w.slice(0, -s.length);
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (w.length > 3 && w.endsWith('e'))
|
|
171
|
+
w = w.slice(0, -1);
|
|
172
|
+
return STEM_ALIASES[w] ?? w;
|
|
173
|
+
}
|
|
174
|
+
const stems = (name) => new Set(words(name).filter((w) => !FILLER_WORDS.has(w)).map(stem));
|
|
175
|
+
function sharedStems(a, b) {
|
|
176
|
+
const other = stems(b);
|
|
177
|
+
let n = 0;
|
|
178
|
+
for (const w of stems(a))
|
|
179
|
+
if (other.has(w))
|
|
180
|
+
n++;
|
|
181
|
+
return n;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Known names about the same thing as `word`, best first, for when `nearest`
|
|
185
|
+
* found no spelling to offer. `detailRenderer` is no typo of anything, but it
|
|
186
|
+
* shares "detail" with `renderDetailRow` and `isDetailRow`, and that short list
|
|
187
|
+
* is what lets a model pick instead of guessing again.
|
|
188
|
+
*
|
|
189
|
+
* Advice only - never a rename. A shared word must be one that few candidates
|
|
190
|
+
* carry, so `rowFoo` does not come back with every prop that starts with `row`.
|
|
191
|
+
*/
|
|
192
|
+
export function related(word, candidates, limit = 5) {
|
|
193
|
+
const mine = stems(word);
|
|
194
|
+
if (!mine.size)
|
|
195
|
+
return [];
|
|
196
|
+
const sets = candidates.map((c) => ({ name: c, stems: stems(c) }));
|
|
197
|
+
const df = new Map();
|
|
198
|
+
for (const { stems: s } of sets)
|
|
199
|
+
for (const w of s)
|
|
200
|
+
df.set(w, (df.get(w) ?? 0) + 1);
|
|
201
|
+
const distinctive = Math.max(2, Math.floor(candidates.length / 10));
|
|
202
|
+
const scored = [];
|
|
203
|
+
for (const { name, stems: s } of sets) {
|
|
204
|
+
if (name === word)
|
|
205
|
+
continue;
|
|
206
|
+
let score = 0;
|
|
207
|
+
let sharp = false;
|
|
208
|
+
for (const w of mine) {
|
|
209
|
+
if (!s.has(w))
|
|
210
|
+
continue;
|
|
211
|
+
const n = df.get(w);
|
|
212
|
+
score += Math.log(1 + candidates.length / n);
|
|
213
|
+
if (n <= distinctive)
|
|
214
|
+
sharp = true;
|
|
215
|
+
}
|
|
216
|
+
if (!sharp)
|
|
217
|
+
continue;
|
|
218
|
+
// Of two names sharing the same words, the one with fewer others is closer.
|
|
219
|
+
scored.push({ name, score: score - 0.1 * (s.size - 1) });
|
|
220
|
+
}
|
|
221
|
+
return scored
|
|
222
|
+
.sort((a, b) => b.score - a.score || a.name.length - b.name.length)
|
|
223
|
+
.slice(0, limit)
|
|
224
|
+
.map((s) => s.name);
|
|
225
|
+
}
|
|
226
|
+
/** "`a`, `b` (boolean)" - a member's type rides along when it is short enough to help. */
|
|
227
|
+
function listMembers(names, members) {
|
|
228
|
+
return names
|
|
229
|
+
.map((n) => {
|
|
230
|
+
const type = members?.find((m) => m.name === n)?.type.replace(/\s+/g, ' ');
|
|
231
|
+
return type && type.length <= 40 ? `\`${n}\` (${type})` : `\`${n}\``;
|
|
232
|
+
})
|
|
233
|
+
.join(', ');
|
|
234
|
+
}
|
|
134
235
|
/** Index of the bracket matching the one at `open`, or -1. */
|
|
135
236
|
function matchBracket(src, open) {
|
|
136
237
|
const pairs = { '{': '}', '[': ']', '(': ')' };
|
|
@@ -549,6 +650,7 @@ function checkGridProps(ctx) {
|
|
|
549
650
|
continue;
|
|
550
651
|
}
|
|
551
652
|
const guess = nearest(name, known);
|
|
653
|
+
const near = guess ? [] : related(name, known);
|
|
552
654
|
push(ctx, {
|
|
553
655
|
rule: 'svgrid/unknown-prop',
|
|
554
656
|
severity: 'error',
|
|
@@ -556,7 +658,9 @@ function checkGridProps(ctx) {
|
|
|
556
658
|
message: `\`${name}\` is not a prop of <SvGrid> in @svgrid/grid@${surface.gridVersion}.`,
|
|
557
659
|
fix: guess
|
|
558
660
|
? `Did you mean \`${guess}\`?`
|
|
559
|
-
:
|
|
661
|
+
: near.length
|
|
662
|
+
? `Related props: ${listMembers(near, surface.props)}. If none fits, call svgrid_search with what the prop should do.`
|
|
663
|
+
: 'Call svgrid_search with the prop name, or read the reference/SvGrid doc for the prop list.',
|
|
560
664
|
rename: guess ? { from: name, to: guess } : undefined,
|
|
561
665
|
see: 'reference/SvGrid',
|
|
562
666
|
});
|
|
@@ -697,12 +801,15 @@ function checkColumns(ctx) {
|
|
|
697
801
|
continue;
|
|
698
802
|
}
|
|
699
803
|
const guess = nearest(key, known);
|
|
804
|
+
const near = guess ? [] : related(key, known, 3);
|
|
700
805
|
push(ctx, {
|
|
701
806
|
rule: 'svgrid/unknown-column-key',
|
|
702
807
|
severity: 'error',
|
|
703
808
|
line,
|
|
704
809
|
message: `\`${key}\` is not a key of ColumnDef in @svgrid/grid@${surface.gridVersion}.`,
|
|
705
|
-
fix: guess
|
|
810
|
+
fix: guess
|
|
811
|
+
? `Did you mean \`${guess}\`?`
|
|
812
|
+
: `${near.length ? `Related: ${listMembers(near, surface.columnDef)}. ` : ''}Valid keys: ${known.join(', ')}.`,
|
|
706
813
|
see: 'help/columns/column-definitions',
|
|
707
814
|
});
|
|
708
815
|
}
|
|
@@ -920,12 +1027,17 @@ function checkEnterpriseUsage(ctx) {
|
|
|
920
1027
|
const hint = API_METHOD_HINTS[method];
|
|
921
1028
|
const spelling = nearest(method, all);
|
|
922
1029
|
const guess = hint ?? spelling;
|
|
1030
|
+
const near = guess ? [] : related(method, all);
|
|
923
1031
|
push(ctx, {
|
|
924
1032
|
rule: 'svgrid/unknown-api-method',
|
|
925
1033
|
severity: 'error',
|
|
926
1034
|
line,
|
|
927
1035
|
message: `The grid API has no \`${method}()\` in @svgrid/grid@${ctx.surface.gridVersion}.`,
|
|
928
|
-
fix: guess
|
|
1036
|
+
fix: guess
|
|
1037
|
+
? `Use \`${guess}\`.`
|
|
1038
|
+
: near.length
|
|
1039
|
+
? `Related methods: ${listMembers(near)}. If none fits, call svgrid_get with ref:"api" for the api surface.`
|
|
1040
|
+
: 'Call svgrid_get with ref:"api" for the api surface.',
|
|
929
1041
|
// Only the spelling guess is a bare identifier. An API_METHOD_HINTS
|
|
930
1042
|
// value is a call expression - `exportData({ format: "xlsx" })` - and
|
|
931
1043
|
// substituting that for an identifier would emit `api.exportData({...})(...)`.
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"type": "commercial",
|
|
6
6
|
"url": "https://svgrid.com/pricing"
|
|
7
7
|
},
|
|
8
|
-
"version": "3.0.
|
|
8
|
+
"version": "3.0.30",
|
|
9
9
|
"description": "Model Context Protocol server for SvGrid, the Svelte 5 data grid: checks the code your AI writes against the real API surface, plus version-pinned docs, API reference and 373 demo sources.",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"author": "jQWidgets <sales@jqwidgets.com>",
|
package/server.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "com.svgrid/svgrid",
|
|
4
4
|
"title": "SvGrid",
|
|
5
5
|
"description": "Checks AI-written SvGrid code against the real API, plus version-pinned Svelte 5 grid docs.",
|
|
6
|
-
"version": "3.0.
|
|
6
|
+
"version": "3.0.30",
|
|
7
7
|
"websiteUrl": "https://svgrid.com/docs/help/mcp-server/",
|
|
8
8
|
"repository": {
|
|
9
9
|
"url": "https://github.com/sv-grid/sv-grid",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"registryType": "npm",
|
|
16
16
|
"registryBaseUrl": "https://registry.npmjs.org",
|
|
17
17
|
"identifier": "@svgrid/mcp",
|
|
18
|
-
"version": "3.0.
|
|
18
|
+
"version": "3.0.30",
|
|
19
19
|
"runtimeHint": "npx",
|
|
20
20
|
"transport": {
|
|
21
21
|
"type": "stdio"
|