@databricks/appkit-ui 0.93.0 → 0.94.1

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/CLAUDE.md CHANGED
@@ -7,6 +7,7 @@ npx @databricks/appkit docs <query>
7
7
  ```
8
8
 
9
9
  - View documentation index: `npx @databricks/appkit docs`
10
+ - Look up components, hooks and functions by name: `npx @databricks/appkit docs BarChart DataTable Select useAnalyticsQuery sql`
10
11
  - View a section: `npx @databricks/appkit docs "appkit-ui API reference"`
11
12
  - Full index (all API entries): `npx @databricks/appkit docs --full`
12
13
  - View specific doc: `npx @databricks/appkit docs ./docs/plugins/analytics.md`
@@ -78,37 +78,258 @@ function formatCollapsedSection(section) {
78
78
  function formatExpandedSection(section) {
79
79
  return `## ${section.name}${section.body}`;
80
80
  }
81
- function runDocs(query, options) {
81
+ const EXAMPLE_HEADINGS = new Set(["Example", "Examples"]);
82
+ const COMPONENT_PAGE_HEADINGS = new Set([
83
+ ...EXAMPLE_HEADINGS,
84
+ "Usage",
85
+ "Props"
86
+ ]);
87
+ const NOT_PROSE = /^(```|\||<!--|\*\*Source:\*\*)/;
88
+ /** The exported docs carry each heading's anchor link (`## Props[​](#props "Direct link to Props")`). */
89
+ function cleanLine(line) {
90
+ return line.replace(/\[\u200b\]\(#[^\s)]*(?: "[^"]*")?\)/g, "").trimEnd();
91
+ }
92
+ const linesByFile = /* @__PURE__ */ new Map();
93
+ function linesOf(file) {
94
+ let lines = linesByFile.get(file);
95
+ if (!lines) {
96
+ let inCode = false;
97
+ lines = fs.readFileSync(file, "utf-8").split("\n").map((raw) => {
98
+ const fence = raw.startsWith("```");
99
+ if (fence) inCode = !inCode;
100
+ return {
101
+ text: cleanLine(raw),
102
+ code: fence || inCode
103
+ };
104
+ });
105
+ linesByFile.set(file, lines);
106
+ }
107
+ return lines;
108
+ }
109
+ const headingOf = (line) => line.code ? null : line.text.match(/^(#+) (.*)$/);
110
+ function markdownFiles(dir) {
111
+ if (!fs.existsSync(dir)) return [];
112
+ return fs.readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name)).flatMap((entry) => {
113
+ const file = path.join(dir, entry.name);
114
+ if (entry.isDirectory()) return markdownFiles(file);
115
+ return entry.name.endsWith(".md") ? [file] : [];
116
+ });
117
+ }
118
+ /**
119
+ * Every documented name: component pages and their parts (`api/appkit-ui/<group>/<Name>.md`, `## SelectItem`),
120
+ * reference pages (`api/appkit/<Kind>.<name>.md`), and hooks documented in guides (`### useAnalyticsQuery`).
121
+ */
122
+ function apiIndex(packageRoot) {
123
+ const docsDir = path.join(packageRoot, "docs");
124
+ const index = /* @__PURE__ */ new Map();
125
+ for (const file of markdownFiles(docsDir)) {
126
+ const rel = path.relative(docsDir, file).split(path.sep).join("/");
127
+ const reference = rel.match(/^api\/appkit\/[A-Za-z]+\.(\w+)\.md$/);
128
+ const kind = reference ? "reference" : /^api\/appkit-ui\/[^/]+\/[^/]+\.md$/.test(rel) ? "component" : "guide";
129
+ const add = (name, line, level) => {
130
+ if (!index.has(name)) index.set(name, {
131
+ kind,
132
+ file,
133
+ line,
134
+ level
135
+ });
136
+ };
137
+ if (reference) {
138
+ add(reference[1], 0, 1);
139
+ continue;
140
+ }
141
+ linesOf(file).forEach((line, i) => {
142
+ const heading = !line.code && line.text.match(/^(#{1,4}) `?([A-Za-z]\w*)`?$/);
143
+ if (!heading) return;
144
+ const [, hashes, name] = heading;
145
+ if (kind === "component" ? !COMPONENT_PAGE_HEADINGS.has(name) : /^use[A-Z]/.test(name)) add(name, i, hashes.length);
146
+ });
147
+ }
148
+ return index;
149
+ }
150
+ const unescapeCell = (cell) => cell.replace(/\\([\\`*_{}[\]()#+\-.!<>|])/g, "$1").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&#123;/g, "{").replace(/&#125;/g, "}").replace(/`/g, "");
151
+ function tableCells(row) {
152
+ return row.replace(/^\|\s*|\s*\|$/g, "").split(/\s*(?<!\\)\|\s*/).map(unescapeCell);
153
+ }
154
+ /** A description's summary sentence (the TSDoc convention). */
155
+ const firstSentence = (text) => text.replace(/^(.+?\.)\s+[A-Z`(].*$/, "$1");
156
+ /**
157
+ * A doc section as an agent reads it: prose and signatures, one line per prop. Without `details` (several names),
158
+ * no examples and props get their summary sentence. Component pages repeat their description and share notes and
159
+ * props across pages, so on them what has been printed is referred back to instead.
160
+ */
161
+ function condense(lines, kind, owner, details, printed) {
162
+ const out = [];
163
+ let lastText = "";
164
+ let intro = "";
165
+ const push = (text) => {
166
+ out.push(text);
167
+ if (text.trim()) lastText = text;
168
+ };
169
+ const sharedProps = /* @__PURE__ */ new Map();
170
+ let skipLevel = 0;
171
+ let propsTable = false;
172
+ for (const [i, line] of lines.entries()) {
173
+ const { text } = line;
174
+ const heading = headingOf(line);
175
+ if (heading) {
176
+ const level = heading[1].length;
177
+ if (skipLevel && level > skipLevel) continue;
178
+ const title = heading[2];
179
+ const skip = kind === "component" && title === "Usage" || !details && EXAMPLE_HEADINGS.has(title);
180
+ skipLevel = skip ? level : 0;
181
+ if (!skip && !(kind === "component" && title === "Props")) push(text);
182
+ continue;
183
+ }
184
+ if (skipLevel) continue;
185
+ if (line.code) {
186
+ push(text);
187
+ continue;
188
+ }
189
+ if (text.startsWith("|")) {
190
+ if (/^\|[\s:|-]+\|$/.test(text)) continue;
191
+ if (/^\|[\s:|-]+\|$/.test(lines[i + 1]?.text ?? "")) {
192
+ propsTable = /^\|\s*Prop\s*\|/.test(text);
193
+ continue;
194
+ }
195
+ const cells = tableCells(text);
196
+ if (propsTable && cells.length === 5) {
197
+ const [name, type, required, def, desc] = cells;
198
+ const prop = `- ${name}${required ? "" : "?"}: ${type}${def && def !== "-" ? ` = ${def}` : ""}${desc && desc !== "-" ? ` — ${details ? desc : firstSentence(desc)}` : ""}`;
199
+ const earlier = details ? void 0 : printed.get(prop);
200
+ if (earlier) {
201
+ sharedProps.set(earlier, [...sharedProps.get(earlier) ?? [], name]);
202
+ continue;
203
+ }
204
+ printed.set(prop, owner);
205
+ push(prop);
206
+ } else push(`- ${cells.join(" | ")}`);
207
+ continue;
208
+ }
209
+ if (NOT_PROSE.test(text)) continue;
210
+ if (kind === "component" && text.trim()) {
211
+ const earlier = printed.get(text);
212
+ if (earlier && earlier !== owner) {
213
+ const reference = `(as in ${earlier})`;
214
+ if (lastText !== reference) push(reference);
215
+ continue;
216
+ }
217
+ if (text === intro) continue;
218
+ intro ||= text;
219
+ printed.set(text, owner);
220
+ }
221
+ if (text.trim() || out.length && out[out.length - 1].trim()) push(text);
222
+ }
223
+ for (const [earlier, props] of sharedProps) push(`- ${props.join(", ")}: as in ${earlier}`);
224
+ return out.join("\n").trim();
225
+ }
226
+ function sectionLines(entry) {
227
+ const lines = linesOf(entry.file);
228
+ let end = entry.line + 1;
229
+ for (; end < lines.length; end++) {
230
+ const heading = headingOf(lines[end]);
231
+ if (heading && heading[1].length <= entry.level) break;
232
+ }
233
+ return lines.slice(entry.line, end);
234
+ }
235
+ /** Reference pages detail every member; among several names, one gets its declaration and member names. */
236
+ function declarationOnly(lines, name) {
237
+ const end = lines.findIndex((line, i) => i > 0 && headingOf(line)?.[1] === "##");
238
+ const declaration = end < 0 ? lines : lines.slice(0, end);
239
+ const members = lines.flatMap((line) => {
240
+ const heading = headingOf(line);
241
+ return heading?.[1] === "###" ? [heading[2]] : [];
242
+ });
243
+ if (!members.length) return declaration;
244
+ const prose = (text) => ({
245
+ text,
246
+ code: false
247
+ });
248
+ return [
249
+ ...declaration,
250
+ prose(""),
251
+ prose(`Members: ${members.join(", ")} (\`appkit docs ${name}\` for each)`)
252
+ ];
253
+ }
254
+ function firstProseLine(entry) {
255
+ for (const line of sectionLines(entry).slice(1)) {
256
+ if (headingOf(line)) return "";
257
+ if (!line.code && line.text.trim() && !NOT_PROSE.test(line.text)) return line.text.trim();
258
+ }
259
+ return "";
260
+ }
261
+ /** Names close to an unknown one: those sharing a word with it (DateRangePicker: date, range, picker). */
262
+ function similarNames(index, name) {
263
+ const words = name.split(/(?=[A-Z])|[^A-Za-z]/).map((w) => w.toLowerCase()).filter((w) => w.length > 2);
264
+ const hits = (text) => words.filter((w) => text.toLowerCase().includes(w)).length;
265
+ const scores = new Map([...index].map(([candidate, entry]) => [candidate, 2 * hits(candidate) + (entry.kind === "component" ? hits(firstProseLine(entry)) : 0)]));
266
+ return [...scores.keys()].filter((candidate) => (scores.get(candidate) ?? 0) > 0).sort((a, b) => (scores.get(b) ?? 0) - (scores.get(a) ?? 0)).slice(0, 6);
267
+ }
268
+ /**
269
+ * `appkit docs NAME...`: what each name's docs say and whether any was found, or null for a section query. Names
270
+ * come as separate arguments or as one ("BarChart DataTable"); a section name has spaces too, so a single argument
271
+ * that isn't all names and matches a section is a section query. One that matches neither also lists the sections.
272
+ */
273
+ function lookUp(packageRoot, queries, sections) {
274
+ const names = queries.flatMap((q) => q.split(/[\s,]+/)).filter(Boolean);
275
+ if (!names.length) return null;
276
+ const index = apiIndex(packageRoot);
277
+ const single = queries.length === 1;
278
+ const allNames = names.every((name) => index.has(name));
279
+ if (single && !allNames && findSections(sections, queries[0]).length) return null;
280
+ const details = names.length === 1;
281
+ const printed = /* @__PURE__ */ new Map();
282
+ const entries = names.map((name) => {
283
+ const entry = index.get(name);
284
+ if (!entry) {
285
+ const similar = similarNames(index, name);
286
+ return `=== ${name}\nNot documented.${similar.length ? ` Similar: ${similar.join(", ")}` : ""}`;
287
+ }
288
+ const section = sectionLines(entry);
289
+ const lines = entry.kind === "reference" && !details ? declarationOnly(section, name) : section;
290
+ return `=== ${name} (${path.relative(packageRoot, entry.file)})\n${condense(lines, entry.kind, name, details, printed)}`;
291
+ });
292
+ const found = names.some((name) => index.has(name));
293
+ if (single && !found && sections.length) entries.push(`No section matches either. Sections: ${sections.map((s) => s.name).join(", ")}`);
294
+ return {
295
+ text: entries.join("\n\n"),
296
+ found
297
+ };
298
+ }
299
+ function runDocs(queries, options) {
82
300
  const packageRoot = findPackageRoot();
301
+ const [query] = queries;
83
302
  if (query && isFilePath(query)) {
84
303
  readDocFile(packageRoot, query);
85
304
  return;
86
305
  }
87
306
  const content = readLlmsTxt(packageRoot);
307
+ const { header, sections } = parseSections(content);
308
+ const answer = lookUp(packageRoot, queries, sections);
309
+ if (answer) {
310
+ console.log(answer.text);
311
+ if (!answer.found) process.exit(1);
312
+ return;
313
+ }
88
314
  if (options.full) {
89
315
  console.log(content.replaceAll(` ${COLLAPSED_MARKER}`, ""));
90
316
  return;
91
317
  }
92
- const { header, sections } = parseSections(content);
93
- if (query) {
94
- const matched = findSections(sections, query);
95
- if (matched.length === 0) {
96
- const available = sections.map((s) => ` - ${s.name}`).join("\n");
97
- console.error(`No section matching "${query}". Available sections:\n${available}`);
98
- process.exit(1);
99
- }
318
+ const matched = query ? findSections(sections, query) : [];
319
+ if (matched.length) {
100
320
  console.log(matched.map(formatExpandedSection).join("\n"));
101
321
  return;
102
322
  }
103
323
  const output = header + sections.map((s) => s.collapsed ? formatCollapsedSection(s) : formatExpandedSection(s)).join("\n");
104
324
  console.log(output);
105
325
  }
106
- const docsCommand = new Command("docs").description("Display embedded documentation").argument("[query]", "Section name (e.g. 'plugins') or path to a doc file (e.g. './docs.md')").option("--full", "Show complete index including all API reference entries").addHelpText("after", `
326
+ const docsCommand = new Command("docs").description("Display embedded documentation").argument("[query...]", "Section name (e.g. 'plugins'), path to a doc file (e.g. './docs.md'), or API names (e.g. BarChart DataTable sql)").option("--full", "Show complete index including all API reference entries").addHelpText("after", `
107
327
  Examples:
108
328
  $ appkit docs
109
329
  $ appkit docs plugins
110
330
  $ appkit docs "appkit-ui API reference"
111
331
  $ appkit docs ./docs/plugins/analytics.md
332
+ $ appkit docs BarChart DataTable Select useAnalyticsQuery sql
112
333
  $ appkit docs --full`).action(runDocs);
113
334
 
114
335
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"docs.js","names":[],"sources":["../../../src/cli/commands/docs.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { Command } from \"commander\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nconst COLLAPSED_MARKER = \"[collapsed]\";\n\ninterface Section {\n name: string;\n body: string;\n collapsed: boolean;\n}\n\nfunction findPackageRoot(): string {\n let dir = __dirname;\n while (dir !== path.parse(dir).root) {\n if (fs.existsSync(path.join(dir, \"package.json\"))) {\n return dir;\n }\n dir = path.dirname(dir);\n }\n throw new Error(\"Could not find package root\");\n}\n\nfunction parseSections(content: string): {\n header: string;\n sections: Section[];\n} {\n const parts = content.split(/^(## .+)$/m);\n const header = parts[0];\n const sections: Section[] = [];\n\n for (let i = 1; i < parts.length; i += 2) {\n const rawName = parts[i].replace(/^## /, \"\");\n const body = parts[i + 1] ?? \"\";\n const collapsed = rawName.includes(COLLAPSED_MARKER);\n const name = rawName.replace(COLLAPSED_MARKER, \"\").trim();\n sections.push({ name, body, collapsed });\n }\n\n return { header, sections };\n}\n\nfunction countPages(body: string): number {\n return (body.match(/^- \\[/gm) || []).length;\n}\n\nfunction findSections(sections: Section[], query: string): Section[] {\n const q = query.toLowerCase();\n return sections.filter((s) => s.name.toLowerCase().includes(q));\n}\n\nfunction isFilePath(arg: string): boolean {\n return arg.startsWith(\"./\") && arg.endsWith(\".md\");\n}\n\nfunction readLlmsTxt(packageRoot: string): string {\n const llmsPath = path.join(packageRoot, \"llms.txt\");\n if (!fs.existsSync(llmsPath)) {\n console.error(\"Error: llms.txt not found in package\");\n process.exit(1);\n }\n return fs.readFileSync(llmsPath, \"utf-8\");\n}\n\nfunction readDocFile(packageRoot: string, docPath: string): void {\n let normalizedPath = docPath;\n normalizedPath = normalizedPath.replace(/^\\.\\//, \"\");\n normalizedPath = normalizedPath.replace(/^\\//, \"\");\n normalizedPath = normalizedPath.replace(/^appkit\\//, \"\");\n\n const fullPath = path.join(packageRoot, normalizedPath);\n\n if (!fs.existsSync(fullPath)) {\n console.error(`Error: Documentation file not found: ${docPath}`);\n console.error(`Tried: ${fullPath}`);\n process.exit(1);\n }\n\n console.log(fs.readFileSync(fullPath, \"utf-8\"));\n}\n\nfunction formatCollapsedSection(section: Section): string {\n const pages = countPages(section.body);\n return [\n `## ${section.name} (${pages} pages)`,\n \"\",\n `> Use \\`appkit docs \"${section.name}\"\\` to expand, or \\`appkit docs --full\\` to expand all sections.`,\n \"\",\n ].join(\"\\n\");\n}\n\nfunction formatExpandedSection(section: Section): string {\n return `## ${section.name}${section.body}`;\n}\n\nfunction runDocs(query: string | undefined, options: { full?: boolean }) {\n const packageRoot = findPackageRoot();\n\n if (query && isFilePath(query)) {\n readDocFile(packageRoot, query);\n return;\n }\n\n const content = readLlmsTxt(packageRoot);\n\n if (options.full) {\n console.log(content.replaceAll(` ${COLLAPSED_MARKER}`, \"\"));\n return;\n }\n\n const { header, sections } = parseSections(content);\n\n if (query) {\n const matched = findSections(sections, query);\n if (matched.length === 0) {\n const available = sections.map((s) => ` - ${s.name}`).join(\"\\n\");\n console.error(\n `No section matching \"${query}\". Available sections:\\n${available}`,\n );\n process.exit(1);\n }\n console.log(matched.map(formatExpandedSection).join(\"\\n\"));\n return;\n }\n\n const output =\n header +\n sections\n .map((s) =>\n s.collapsed ? formatCollapsedSection(s) : formatExpandedSection(s),\n )\n .join(\"\\n\");\n console.log(output);\n}\n\nexport const docsCommand = new Command(\"docs\")\n .description(\"Display embedded documentation\")\n .argument(\n \"[query]\",\n \"Section name (e.g. 'plugins') or path to a doc file (e.g. './docs.md')\",\n )\n .option(\"--full\", \"Show complete index including all API reference entries\")\n .addHelpText(\n \"after\",\n `\nExamples:\n $ appkit docs\n $ appkit docs plugins\n $ appkit docs \"appkit-ui API reference\"\n $ appkit docs ./docs/plugins/analytics.md\n $ appkit docs --full`,\n )\n .action(runDocs);\n"],"mappings":";;;;;;AAMA,MAAM,aAAa,cAAc,OAAO,KAAK,IAAI;AACjD,MAAM,YAAY,KAAK,QAAQ,WAAW;AAE1C,MAAM,mBAAmB;AAQzB,SAAS,kB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uBAAuB,EAAE,GAAG,sBAAsB,EAAE,CACnE,CACA,KAAK,KAAK;AACf,SAAQ,IAAI,OAAO;;AAGrB,MAAa,cAAc,IAAI,QAAQ,OAAO,CAC3C,YAAY,iCAAiC,CAC7C,SACC,WACA,yEACD,CACA,OAAO,UAAU,0DAA0D,CAC3E,YACC,SACA;;;;;;wBAOD,CACA,OAAO,QAAQ"}
1
+ {"version":3,"file":"docs.js","names":[],"sources":["../../../src/cli/commands/docs.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { Command } from \"commander\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nconst COLLAPSED_MARKER = \"[collapsed]\";\n\nexport interface Section {\n name: string;\n body: string;\n collapsed: boolean;\n}\n\nfunction findPackageRoot(): string {\n let dir = __dirname;\n while (dir !== path.parse(dir).root) {\n if (fs.existsSync(path.join(dir, \"package.json\"))) {\n return dir;\n }\n dir = path.dirname(dir);\n }\n throw new Error(\"Could not find package root\");\n}\n\nfunction parseSections(content: string): {\n header: string;\n sections: Section[];\n} {\n const parts = content.split(/^(## .+)$/m);\n const header = parts[0];\n const sections: Section[] = [];\n\n for (let i = 1; i < parts.length; i += 2) {\n const rawName = parts[i].replace(/^## /, \"\");\n const body = parts[i + 1] ?? \"\";\n const collapsed = rawName.includes(COLLAPSED_MARKER);\n const name = rawName.replace(COLLAPSED_MARKER, \"\").trim();\n sections.push({ name, body, collapsed });\n }\n\n return { header, sections };\n}\n\nfunction countPages(body: string): number {\n return (body.match(/^- \\[/gm) || []).length;\n}\n\nfunction findSections(sections: Section[], query: string): Section[] {\n const q = query.toLowerCase();\n return sections.filter((s) => s.name.toLowerCase().includes(q));\n}\n\nfunction isFilePath(arg: string): boolean {\n return arg.startsWith(\"./\") && arg.endsWith(\".md\");\n}\n\nfunction readLlmsTxt(packageRoot: string): string {\n const llmsPath = path.join(packageRoot, \"llms.txt\");\n if (!fs.existsSync(llmsPath)) {\n console.error(\"Error: llms.txt not found in package\");\n process.exit(1);\n }\n return fs.readFileSync(llmsPath, \"utf-8\");\n}\n\nfunction readDocFile(packageRoot: string, docPath: string): void {\n let normalizedPath = docPath;\n normalizedPath = normalizedPath.replace(/^\\.\\//, \"\");\n normalizedPath = normalizedPath.replace(/^\\//, \"\");\n normalizedPath = normalizedPath.replace(/^appkit\\//, \"\");\n\n const fullPath = path.join(packageRoot, normalizedPath);\n\n if (!fs.existsSync(fullPath)) {\n console.error(`Error: Documentation file not found: ${docPath}`);\n console.error(`Tried: ${fullPath}`);\n process.exit(1);\n }\n\n console.log(fs.readFileSync(fullPath, \"utf-8\"));\n}\n\nfunction formatCollapsedSection(section: Section): string {\n const pages = countPages(section.body);\n return [\n `## ${section.name} (${pages} pages)`,\n \"\",\n `> Use \\`appkit docs \"${section.name}\"\\` to expand, or \\`appkit docs --full\\` to expand all sections.`,\n \"\",\n ].join(\"\\n\");\n}\n\nfunction formatExpandedSection(section: Section): string {\n return `## ${section.name}${section.body}`;\n}\n\ntype PageKind = \"component\" | \"reference\" | \"guide\";\n\ninterface ApiEntry {\n kind: PageKind;\n file: string;\n line: number;\n level: number;\n}\n\ntype Printed = Map<string, string>;\n\n// Component pages (tools/generate-component-mdx.ts) put each component's sections under Example, Usage and Props\n// headings; TypeDoc's reference pages put theirs under Examples.\nconst EXAMPLE_HEADINGS = new Set([\"Example\", \"Examples\"]);\nconst COMPONENT_PAGE_HEADINGS = new Set([\n ...EXAMPLE_HEADINGS,\n \"Usage\",\n \"Props\",\n]);\n// Code fences, table rows, comments and the generator's source link.\nconst NOT_PROSE = /^(```|\\||<!--|\\*\\*Source:\\*\\*)/;\n\n/** The exported docs carry each heading's anchor link (`## Props[​](#props \"Direct link to Props\")`). */\nfunction cleanLine(line: string): string {\n return line.replace(/\\[\\u200b\\]\\(#[^\\s)]*(?: \"[^\"]*\")?\\)/g, \"\").trimEnd();\n}\n\n/** A doc line, and whether it is code (a fence or inside one), where `#` starts no heading. */\ninterface Line {\n text: string;\n code: boolean;\n}\n\nconst linesByFile = new Map<string, Line[]>();\nfunction linesOf(file: string): Line[] {\n let lines = linesByFile.get(file);\n if (!lines) {\n let inCode = false;\n lines = fs\n .readFileSync(file, \"utf-8\")\n .split(\"\\n\")\n .map((raw) => {\n const fence = raw.startsWith(\"```\");\n if (fence) inCode = !inCode;\n return { text: cleanLine(raw), code: fence || inCode };\n });\n linesByFile.set(file, lines);\n }\n return lines;\n}\n\nconst headingOf = (line: Line) =>\n line.code ? null : line.text.match(/^(#+) (.*)$/);\n\nfunction markdownFiles(dir: string): string[] {\n if (!fs.existsSync(dir)) return [];\n return fs\n .readdirSync(dir, { withFileTypes: true })\n .sort((a, b) => a.name.localeCompare(b.name))\n .flatMap((entry) => {\n const file = path.join(dir, entry.name);\n if (entry.isDirectory()) return markdownFiles(file);\n return entry.name.endsWith(\".md\") ? [file] : [];\n });\n}\n\n/**\n * Every documented name: component pages and their parts (`api/appkit-ui/<group>/<Name>.md`, `## SelectItem`),\n * reference pages (`api/appkit/<Kind>.<name>.md`), and hooks documented in guides (`### useAnalyticsQuery`).\n */\nfunction apiIndex(packageRoot: string): Map<string, ApiEntry> {\n const docsDir = path.join(packageRoot, \"docs\");\n const index = new Map<string, ApiEntry>();\n for (const file of markdownFiles(docsDir)) {\n const rel = path.relative(docsDir, file).split(path.sep).join(\"/\");\n const reference = rel.match(/^api\\/appkit\\/[A-Za-z]+\\.(\\w+)\\.md$/);\n const kind: PageKind = reference\n ? \"reference\"\n : /^api\\/appkit-ui\\/[^/]+\\/[^/]+\\.md$/.test(rel)\n ? \"component\"\n : \"guide\";\n const add = (name: string, line: number, level: number) => {\n if (!index.has(name)) index.set(name, { kind, file, line, level });\n };\n if (reference) {\n add(reference[1], 0, 1);\n continue;\n }\n linesOf(file).forEach((line, i) => {\n const heading =\n !line.code && line.text.match(/^(#{1,4}) `?([A-Za-z]\\w*)`?$/);\n if (!heading) return;\n const [, hashes, name] = heading;\n const isApi =\n kind === \"component\"\n ? !COMPONENT_PAGE_HEADINGS.has(name)\n : /^use[A-Z]/.test(name);\n if (isApi) add(name, i, hashes.length);\n });\n }\n return index;\n}\n\nconst unescapeCell = (cell: string) =>\n cell\n .replace(/\\\\([\\\\`*_{}[\\]()#+\\-.!<>|])/g, \"$1\")\n .replace(/&lt;/g, \"<\")\n .replace(/&gt;/g, \">\")\n .replace(/&#123;/g, \"{\")\n .replace(/&#125;/g, \"}\")\n .replace(/`/g, \"\");\n\n// The props table buildPropsSection (tools/generate-component-mdx.ts) writes: Prop | Type | Required (✓) | Default\n// (- for none) | Description, with its escapes undone.\nfunction tableCells(row: string): string[] {\n return row\n .replace(/^\\|\\s*|\\s*\\|$/g, \"\")\n .split(/\\s*(?<!\\\\)\\|\\s*/)\n .map(unescapeCell);\n}\n\n/** A description's summary sentence (the TSDoc convention). */\nconst firstSentence = (text: string) =>\n text.replace(/^(.+?\\.)\\s+[A-Z`(].*$/, \"$1\");\n\n/**\n * A doc section as an agent reads it: prose and signatures, one line per prop. Without `details` (several names),\n * no examples and props get their summary sentence. Component pages repeat their description and share notes and\n * props across pages, so on them what has been printed is referred back to instead.\n */\nfunction condense(\n lines: Line[],\n kind: PageKind,\n owner: string,\n details: boolean,\n printed: Printed,\n): string {\n const out: string[] = [];\n let lastText = \"\";\n let intro = \"\";\n const push = (text: string) => {\n out.push(text);\n if (text.trim()) lastText = text;\n };\n const sharedProps = new Map<string, string[]>();\n let skipLevel = 0;\n let propsTable = false;\n for (const [i, line] of lines.entries()) {\n const { text } = line;\n const heading = headingOf(line);\n if (heading) {\n const level = heading[1].length;\n if (skipLevel && level > skipLevel) continue;\n const title = heading[2];\n const skip =\n (kind === \"component\" && title === \"Usage\") ||\n (!details && EXAMPLE_HEADINGS.has(title));\n skipLevel = skip ? level : 0;\n if (!skip && !(kind === \"component\" && title === \"Props\")) push(text);\n continue;\n }\n if (skipLevel) continue;\n if (line.code) {\n push(text);\n continue;\n }\n if (text.startsWith(\"|\")) {\n if (/^\\|[\\s:|-]+\\|$/.test(text)) continue;\n if (/^\\|[\\s:|-]+\\|$/.test(lines[i + 1]?.text ?? \"\")) {\n propsTable = /^\\|\\s*Prop\\s*\\|/.test(text);\n continue;\n }\n const cells = tableCells(text);\n if (propsTable && cells.length === 5) {\n const [name, type, required, def, desc] = cells;\n const optional = required ? \"\" : \"?\";\n const value = def && def !== \"-\" ? ` = ${def}` : \"\";\n const note =\n desc && desc !== \"-\"\n ? ` — ${details ? desc : firstSentence(desc)}`\n : \"\";\n const prop = `- ${name}${optional}: ${type}${value}${note}`;\n const earlier = details ? undefined : printed.get(prop);\n if (earlier) {\n sharedProps.set(earlier, [...(sharedProps.get(earlier) ?? []), name]);\n continue;\n }\n printed.set(prop, owner);\n push(prop);\n } else {\n push(`- ${cells.join(\" | \")}`);\n }\n continue;\n }\n if (NOT_PROSE.test(text)) continue;\n if (kind === \"component\" && text.trim()) {\n // The generator repeats a page's intro in its component's section; other names' text is referred back to.\n const earlier = printed.get(text);\n if (earlier && earlier !== owner) {\n const reference = `(as in ${earlier})`;\n if (lastText !== reference) push(reference);\n continue;\n }\n if (text === intro) continue;\n intro ||= text;\n printed.set(text, owner);\n }\n if (text.trim() || (out.length && out[out.length - 1].trim())) push(text);\n }\n for (const [earlier, props] of sharedProps) {\n push(`- ${props.join(\", \")}: as in ${earlier}`);\n }\n return out.join(\"\\n\").trim();\n}\n\nfunction sectionLines(entry: ApiEntry): Line[] {\n const lines = linesOf(entry.file);\n let end = entry.line + 1;\n for (; end < lines.length; end++) {\n const heading = headingOf(lines[end]);\n if (heading && heading[1].length <= entry.level) break;\n }\n return lines.slice(entry.line, end);\n}\n\n/** Reference pages detail every member; among several names, one gets its declaration and member names. */\nfunction declarationOnly(lines: Line[], name: string): Line[] {\n const end = lines.findIndex(\n (line, i) => i > 0 && headingOf(line)?.[1] === \"##\",\n );\n const declaration = end < 0 ? lines : lines.slice(0, end);\n const members = lines.flatMap((line) => {\n const heading = headingOf(line);\n return heading?.[1] === \"###\" ? [heading[2]] : [];\n });\n if (!members.length) return declaration;\n const prose = (text: string) => ({ text, code: false });\n return [\n ...declaration,\n prose(\"\"),\n prose(`Members: ${members.join(\", \")} (\\`appkit docs ${name}\\` for each)`),\n ];\n}\n\nfunction firstProseLine(entry: ApiEntry): string {\n for (const line of sectionLines(entry).slice(1)) {\n if (headingOf(line)) return \"\";\n if (!line.code && line.text.trim() && !NOT_PROSE.test(line.text)) {\n return line.text.trim();\n }\n }\n return \"\";\n}\n\n/** Names close to an unknown one: those sharing a word with it (DateRangePicker: date, range, picker). */\nfunction similarNames(index: Map<string, ApiEntry>, name: string): string[] {\n const words = name\n .split(/(?=[A-Z])|[^A-Za-z]/)\n .map((w) => w.toLowerCase())\n .filter((w) => w.length > 2);\n const hits = (text: string) =>\n words.filter((w) => text.toLowerCase().includes(w)).length;\n // A component's description names what it does (\"Date picker component\" for Calendar); reference pages'\n // descriptions are too generic to match on.\n const scores = new Map(\n [...index].map(([candidate, entry]) => [\n candidate,\n 2 * hits(candidate) +\n (entry.kind === \"component\" ? hits(firstProseLine(entry)) : 0),\n ]),\n );\n return [...scores.keys()]\n .filter((candidate) => (scores.get(candidate) ?? 0) > 0)\n .sort((a, b) => (scores.get(b) ?? 0) - (scores.get(a) ?? 0))\n .slice(0, 6);\n}\n\n/**\n * `appkit docs NAME...`: what each name's docs say and whether any was found, or null for a section query. Names\n * come as separate arguments or as one (\"BarChart DataTable\"); a section name has spaces too, so a single argument\n * that isn't all names and matches a section is a section query. One that matches neither also lists the sections.\n */\nexport function lookUp(\n packageRoot: string,\n queries: string[],\n sections: Section[],\n): { text: string; found: boolean } | null {\n const names = queries.flatMap((q) => q.split(/[\\s,]+/)).filter(Boolean);\n if (!names.length) return null;\n const index = apiIndex(packageRoot);\n const single = queries.length === 1;\n const allNames = names.every((name) => index.has(name));\n if (single && !allNames && findSections(sections, queries[0]).length) {\n return null;\n }\n\n const details = names.length === 1;\n const printed: Printed = new Map();\n const entries = names.map((name) => {\n const entry = index.get(name);\n if (!entry) {\n const similar = similarNames(index, name);\n return `=== ${name}\\nNot documented.${similar.length ? ` Similar: ${similar.join(\", \")}` : \"\"}`;\n }\n const section = sectionLines(entry);\n const lines =\n entry.kind === \"reference\" && !details\n ? declarationOnly(section, name)\n : section;\n const where = path.relative(packageRoot, entry.file);\n return `=== ${name} (${where})\\n${condense(lines, entry.kind, name, details, printed)}`;\n });\n const found = names.some((name) => index.has(name));\n if (single && !found && sections.length) {\n entries.push(\n `No section matches either. Sections: ${sections.map((s) => s.name).join(\", \")}`,\n );\n }\n return { text: entries.join(\"\\n\\n\"), found };\n}\n\nfunction runDocs(queries: string[], options: { full?: boolean }) {\n const packageRoot = findPackageRoot();\n const [query] = queries;\n\n if (query && isFilePath(query)) {\n readDocFile(packageRoot, query);\n return;\n }\n\n const content = readLlmsTxt(packageRoot);\n const { header, sections } = parseSections(content);\n\n const answer = lookUp(packageRoot, queries, sections);\n if (answer) {\n console.log(answer.text);\n if (!answer.found) process.exit(1);\n return;\n }\n\n if (options.full) {\n console.log(content.replaceAll(` ${COLLAPSED_MARKER}`, \"\"));\n return;\n }\n\n const matched = query ? findSections(sections, query) : [];\n if (matched.length) {\n console.log(matched.map(formatExpandedSection).join(\"\\n\"));\n return;\n }\n\n const output =\n header +\n sections\n .map((s) =>\n s.collapsed ? formatCollapsedSection(s) : formatExpandedSection(s),\n )\n .join(\"\\n\");\n console.log(output);\n}\n\nexport const docsCommand = new Command(\"docs\")\n .description(\"Display embedded documentation\")\n .argument(\n \"[query...]\",\n \"Section name (e.g. 'plugins'), path to a doc file (e.g. './docs.md'), or API names (e.g. BarChart DataTable sql)\",\n )\n .option(\"--full\", \"Show complete index including all API reference entries\")\n .addHelpText(\n \"after\",\n `\nExamples:\n $ appkit docs\n $ appkit docs plugins\n $ appkit docs \"appkit-ui API reference\"\n $ appkit docs ./docs/plugins/analytics.md\n $ appkit docs BarChart DataTable Select useAnalyticsQuery sql\n $ appkit docs --full`,\n )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face ChartBaseProps {
48
48
  * - "diverging": Two-tone for positive/negative values
49
49
  */
50
50
  colorPalette?: ChartColorPalette;
51
- /** Custom colors for series (overrides colorPalette) */
51
+ /**
52
+ * Custom colors for series (overrides colorPalette) as hex, `rgb()` or `hsl()` strings, since ECharts draws on a
53
+ * canvas and cannot resolve `var()` or parse `oklch()` (those draw gray); without it, series colors are the CSS
54
+ * variables `--chart-cat-1` to `--chart-cat-8` on `:root` (`--chart-seq-*` and `--chart-div-*` for the
55
+ * sequential and diverging palettes), held to the same formats.
56
+ */
52
57
  colors?: string[];
53
58
  /** Chart height in pixels. Defaults to filling its parent (see `chartSizeStyle`). */
54
59
  height?: number;
@@ -65,9 +70,9 @@ interface ChartBaseProps {
65
70
  /** Additional ECharts options to merge */
66
71
  options?: Record<string, unknown>;
67
72
  /**
68
- * Formats measure values in the chart's built-in value axes, tooltips, and
69
- * value labels. `field` is the corresponding `yKey`, so one formatter can
70
- * select a different format for each series.
73
+ * `(value: string | number, field: string) => string`. Formats measure values in the chart's built-in value
74
+ * axes, tooltips, and value labels. `field` is the corresponding `yKey`, so one formatter can select a different
75
+ * format for each series.
71
76
  *
72
77
  * For charts with multiple series on one value axis, axis ticks use the
73
78
  * first `yKey`; each tooltip uses its own series field.
@@ -136,7 +141,7 @@ interface QueryProps extends ChartBaseProps {
136
141
  }
137
142
  /** Props for direct data injection */
138
143
  interface DataProps extends ChartBaseProps {
139
- /** Arrow Table or JSON array */
144
+ /** Arrow Table or an array of row objects (interfaces and `as const` arrays too). */
140
145
  data: ChartDataInput;
141
146
  queryKey?: never;
142
147
  parameters?: never;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/react/charts/types.ts"],"mappings":";;;;;AAcA;;;;;AAUA;KAVY,UAAA;;KAUA,WAAA;;KAGA,SAAA;AAWZ;AAAA,KAAY,SAAA,GAAY,KAAA,GAAQ,MAAA;;KAGpB,QAAA,GAAW,MAAA;;KAGX,cAAA,GAAiB,KAAA;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}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../src/react/charts/types.ts"],"sourcesContent":["import type { Table } from \"apache-arrow\";\n\n// ============================================================================\n// Data Format Types\n// ============================================================================\n\n/**\n * Supported data formats for analytics queries.\n *\n * \"json\" and \"arrow\" are legacy aliases kept for backwards compatibility\n * with appkit-ui < 0.33.0 — safe to remove once no consumer is on a\n * pre-0.33.0 version. resolveFormat() normalizes them to their canonical\n * equivalents before any downstream code reads the value.\n */\nexport type DataFormat =\n | \"json_array\"\n | \"arrow_stream\"\n | \"auto\"\n /** @deprecated Use \"json_array\". Safe to remove once no consumer is on appkit-ui < 0.33.0. */\n | \"json\"\n /** @deprecated Use \"arrow_stream\". Safe to remove once no consumer is on appkit-ui < 0.33.0. */\n | \"arrow\";\n\n/** Chart orientation */\nexport type Orientation = \"vertical\" | \"horizontal\";\n\n/** Supported chart types */\nexport type ChartType =\n | \"bar\"\n | \"line\"\n | \"area\"\n | \"pie\"\n | \"donut\"\n | \"scatter\"\n | \"radar\"\n | \"heatmap\";\n\n/** Data that can be passed to unified charts */\nexport type ChartData = Table | Record<string, unknown>[];\n\n/** One row of chart data (indexable, to type plain data modules). */\nexport type ChartRow = Record<string, unknown>;\n\n/** A chart's `data`: an Arrow Table, or rows (interfaces and `as const` arrays too). */\nexport type ChartDataInput = Table | readonly object[];\n\n/** Formats a measure value for chart axes, tooltips, and value labels. */\nexport type ChartValueFormatter = (\n value: string | number,\n field: string,\n) => string;\n\n// ============================================================================\n// Base Props (shared by all charts)\n// ============================================================================\n\n/** Color palette types for different visualization needs */\nexport type ChartColorPalette = \"categorical\" | \"sequential\" | \"diverging\";\n\n/** Resolved colors for the chart UI — axis text, titles, grid lines, and tooltip. */\nexport interface ChartUITokens {\n /** Axis tick labels (≈ `--muted-foreground`) */\n axisLabel: string;\n /** Axis names, legend, title, and visualMap text (≈ `--foreground`) */\n axisTitle: string;\n /** Axis, tick, and split (grid) lines (≈ `--border`) */\n grid: string;\n /** Tooltip popover background (≈ `--popover`) */\n tooltipBg: string;\n}\n\n/** Common visual and behavior props for all charts */\nexport interface ChartBaseProps {\n /** Chart title */\n title?: string;\n /** Show legend */\n showLegend?: boolean;\n /**\n * Color palette to use. Auto-selected based on chart type if not specified.\n * - \"categorical\": Distinct colors for different categories (bar, pie, line)\n * - \"sequential\": Gradient for magnitude/intensity (heatmap)\n * - \"diverging\": Two-tone for positive/negative values\n */\n colorPalette?: ChartColorPalette;\n /** Custom colors for series (overrides colorPalette) */\n colors?: string[];\n /** Chart height in pixels. Defaults to filling its parent (see `chartSizeStyle`). */\n height?: number;\n /** Additional CSS classes */\n className?: string;\n\n /** X-axis field key. Auto-detected from schema if not provided. */\n xKey?: string;\n /** Y-axis field key(s). Auto-detected from schema if not provided. */\n yKey?: string | string[];\n\n /** Accessibility label for screen readers */\n ariaLabel?: string;\n /** Test ID for automated testing */\n testId?: string;\n\n /** Additional ECharts options to merge */\n options?: Record<string, unknown>;\n\n /**\n * Formats measure values in the chart's built-in value axes, tooltips, and\n * value labels. `field` is the corresponding `yKey`, so one formatter can\n * select a different format for each series.\n *\n * For charts with multiple series on one value axis, axis ticks use the\n * first `yKey`; each tooltip uses its own series field.\n */\n valueFormatter?: ChartValueFormatter;\n\n /**\n * Pointer-only: charts render to <canvas>, so this does not fire for keyboard\n * users. Provide a keyboard-accessible equivalent (e.g. a table row action) for\n * the same action.\n */\n onDataClick?: (datum: ChartClickDatum) => void;\n\n /**\n * Controlled selection by category name. Matching data element(s) render at full\n * prominence while the rest are dimmed. Drive it from your own state to reflect a\n * cross-filter or selection. Categorical charts (bar, pie/donut) show emphasis;\n * other chart types ignore it.\n */\n selected?: string | string[];\n}\n\n// ============================================================================\n// Interaction / Click Events\n// ============================================================================\n\n/**\n * A normalized description of a clicked chart element.\n *\n * In the common cross-filter case, {@link ChartClickDatum.name} carries the\n * dimension value of the clicked element.\n */\nexport interface ChartClickDatum {\n /** Category label of the clicked element — the dimension value in the common cross-filter case. */\n name: string;\n /**\n * The datum's scalar value:\n * - bar / pie — the datum itself.\n * - time-series / scatter — the y-component of the `[x, y]` point (see\n * {@link ChartClickDatum.x} / {@link ChartClickDatum.y}).\n * - heatmap — the cell value (the third entry of ECharts'\n * `[xIndex, yIndex, value]` triple), *not* an axis index.\n * - radar — `null`; the item holds one value per indicator, so there is no\n * single scalar to report. Read the vector from {@link ChartClickDatum.raw}.\n *\n * `null` whenever there is no scalar value to surface.\n */\n value: number | string | null;\n x?: number | string;\n y?: number | string;\n seriesName?: string;\n dataIndex: number;\n seriesIndex: number;\n // Untouched ECharts event params.\n raw: unknown;\n}\n\n// ============================================================================\n// Query-based Props (chart fetches data)\n// ============================================================================\n\n/** Props for query-based data fetching */\nexport interface QueryProps extends ChartBaseProps {\n /** Analytics query key registered with analytics plugin */\n queryKey: string;\n /** Query parameters passed to the analytics endpoint */\n parameters?: Record<string, unknown>;\n /**\n * Data format to use\n * - \"json_array\": Use JSON format (smaller payloads, simpler)\n * - \"arrow_stream\": Use Arrow format (faster for large datasets)\n * - \"auto\": Automatically select based on expected data size\n * @default \"auto\"\n */\n format?: DataFormat;\n /** Transform raw data before rendering */\n transformer?: <T>(data: T) => T;\n // Discriminator: cannot use direct data with query\n data?: never;\n}\n\n// ============================================================================\n// Data-based Props (chart receives data externally)\n// ============================================================================\n\n/** Props for direct data injection */\nexport interface DataProps extends ChartBaseProps {\n /** Arrow Table or JSON array */\n data: ChartDataInput;\n\n // Discriminator: cannot use query props with direct data\n queryKey?: never;\n parameters?: never;\n format?: never;\n transformer?: never;\n}\n\n// ============================================================================\n// Union Types for Each Chart\n// ============================================================================\n\n/** Base union type - either query-based or data-based */\nexport type UnifiedChartProps = QueryProps | DataProps;\n\n// ============================================================================\n// Chart-Specific Props\n// ============================================================================\n\n/** Props specific to bar charts */\nexport interface BarChartSpecificProps {\n /** Chart orientation @default \"vertical\" */\n orientation?: Orientation;\n /** Stack bars */\n stacked?: boolean;\n}\n\n/** Props specific to line charts */\nexport interface LineChartSpecificProps {\n /** Chart orientation @default \"vertical\" */\n orientation?: Orientation;\n /** Show data point symbols @default false */\n showSymbol?: boolean;\n /** Smooth line curves @default true */\n smooth?: boolean;\n}\n\n/** Props specific to area charts */\nexport interface AreaChartSpecificProps {\n /** Chart orientation @default \"vertical\" */\n orientation?: Orientation;\n /** Show data point symbols @default false */\n showSymbol?: boolean;\n /** Smooth line curves @default true */\n smooth?: boolean;\n /** Stack areas @default false */\n stacked?: boolean;\n}\n\n/** Props specific to scatter charts */\nexport interface ScatterChartSpecificProps {\n /** Symbol size @default 8 */\n symbolSize?: number;\n}\n\n/** Props specific to pie/donut charts */\nexport interface PieChartSpecificProps {\n /** Inner radius for donut charts (0-100%) @default 0 */\n innerRadius?: number;\n /** Show labels on slices @default true */\n showLabels?: boolean;\n /** Label position @default \"outside\" */\n labelPosition?: \"outside\" | \"inside\" | \"center\";\n}\n\n/** Props specific to radar charts */\nexport interface RadarChartSpecificProps {\n /** Show area fill @default true */\n showArea?: boolean;\n}\n\n/** Props specific to heatmap charts */\nexport interface HeatmapChartSpecificProps {\n /**\n * Field key for the Y-axis categories.\n * For heatmaps, data should have: xKey (column), yAxisKey (row), and yKey (value).\n */\n yAxisKey?: string;\n /** Min value for color scale (auto-detected if not provided) */\n min?: number;\n /** Max value for color scale (auto-detected if not provided) */\n max?: number;\n /** Show value labels on cells @default false */\n showLabels?: boolean;\n}\n\n// ============================================================================\n// Complete Chart Props (union + specific)\n// ============================================================================\n\nexport type BarChartProps = (QueryProps | DataProps) & BarChartSpecificProps;\nexport type LineChartProps = (QueryProps | DataProps) & LineChartSpecificProps;\nexport type AreaChartProps = (QueryProps | DataProps) & AreaChartSpecificProps;\nexport type ScatterChartProps = (QueryProps | DataProps) &\n ScatterChartSpecificProps;\nexport type PieChartProps = (QueryProps | DataProps) & PieChartSpecificProps;\nexport type DonutChartProps = (QueryProps | DataProps) & PieChartSpecificProps;\nexport type RadarChartProps = (QueryProps | DataProps) &\n RadarChartSpecificProps;\nexport type HeatmapChartProps = (QueryProps | DataProps) &\n HeatmapChartSpecificProps;\n\n// ============================================================================\n// Internal Types\n// ============================================================================\n\n/** Base normalized data shared by all chart types */\nexport interface NormalizedChartDataBase {\n xData: (string | number)[];\n xField: string;\n yFields: string[];\n chartType: \"timeseries\" | \"categorical\";\n}\n\n/** Normalized chart data for rendering (standard charts) */\nexport interface NormalizedChartData extends NormalizedChartDataBase {\n yDataMap: Record<string, (string | number)[]>;\n}\n\n/** Type guard to check if data is an Arrow Table */\nexport function isArrowTable(data: ChartData): data is Table {\n return (\n data !== null &&\n typeof data === \"object\" &&\n \"schema\" in data &&\n \"numRows\" in data &&\n typeof (data as Table).getChild === \"function\"\n );\n}\n\n/** Type guard to check if props are query-based */\nexport function isQueryProps(props: UnifiedChartProps): props is QueryProps {\n return (\n \"queryKey\" in props &&\n typeof props.queryKey === \"string\" &&\n props.queryKey.length > 0\n );\n}\n\n/** Type guard to check if props are data-based */\nexport function isDataProps(props: UnifiedChartProps): props is DataProps {\n return \"data\" in props && props.data != null;\n}\n"],"mappings":";;AA6TA,SAAgB,aAAa,MAAgC;AAC3D,QACE,SAAS,QACT,OAAO,SAAS,YAChB,YAAY,QACZ,aAAa,QACb,OAAQ,KAAe,aAAa;;;AAKxC,SAAgB,aAAa,OAA+C;AAC1E,QACE,cAAc,SACd,OAAO,MAAM,aAAa,YAC1B,MAAM,SAAS,SAAS;;;AAK5B,SAAgB,YAAY,OAA8C;AACxE,QAAO,UAAU,SAAS,MAAM,QAAQ"}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../src/react/charts/types.ts"],"sourcesContent":["import type { Table } from \"apache-arrow\";\n\n// ============================================================================\n// Data Format Types\n// ============================================================================\n\n/**\n * Supported data formats for analytics queries.\n *\n * \"json\" and \"arrow\" are legacy aliases kept for backwards compatibility\n * with appkit-ui < 0.33.0 — safe to remove once no consumer is on a\n * pre-0.33.0 version. resolveFormat() normalizes them to their canonical\n * equivalents before any downstream code reads the value.\n */\nexport type DataFormat =\n | \"json_array\"\n | \"arrow_stream\"\n | \"auto\"\n /** @deprecated Use \"json_array\". Safe to remove once no consumer is on appkit-ui < 0.33.0. */\n | \"json\"\n /** @deprecated Use \"arrow_stream\". Safe to remove once no consumer is on appkit-ui < 0.33.0. */\n | \"arrow\";\n\n/** Chart orientation */\nexport type Orientation = \"vertical\" | \"horizontal\";\n\n/** Supported chart types */\nexport type ChartType =\n | \"bar\"\n | \"line\"\n | \"area\"\n | \"pie\"\n | \"donut\"\n | \"scatter\"\n | \"radar\"\n | \"heatmap\";\n\n/** Data that can be passed to unified charts */\nexport type ChartData = Table | Record<string, unknown>[];\n\n/** One row of chart data (indexable, to type plain data modules). */\nexport type ChartRow = Record<string, unknown>;\n\n/** A chart's `data`: an Arrow Table, or rows (interfaces and `as const` arrays too). */\nexport type ChartDataInput = Table | readonly object[];\n\n/** Formats a measure value for chart axes, tooltips, and value labels. */\nexport type ChartValueFormatter = (\n value: string | number,\n field: string,\n) => string;\n\n// ============================================================================\n// Base Props (shared by all charts)\n// ============================================================================\n\n/** Color palette types for different visualization needs */\nexport type ChartColorPalette = \"categorical\" | \"sequential\" | \"diverging\";\n\n/** Resolved colors for the chart UI — axis text, titles, grid lines, and tooltip. */\nexport interface ChartUITokens {\n /** Axis tick labels (≈ `--muted-foreground`) */\n axisLabel: string;\n /** Axis names, legend, title, and visualMap text (≈ `--foreground`) */\n axisTitle: string;\n /** Axis, tick, and split (grid) lines (≈ `--border`) */\n grid: string;\n /** Tooltip popover background (≈ `--popover`) */\n tooltipBg: string;\n}\n\n/** Common visual and behavior props for all charts */\nexport interface ChartBaseProps {\n /** Chart title */\n title?: string;\n /** Show legend */\n showLegend?: boolean;\n /**\n * Color palette to use. Auto-selected based on chart type if not specified.\n * - \"categorical\": Distinct colors for different categories (bar, pie, line)\n * - \"sequential\": Gradient for magnitude/intensity (heatmap)\n * - \"diverging\": Two-tone for positive/negative values\n */\n colorPalette?: ChartColorPalette;\n /**\n * Custom colors for series (overrides colorPalette) as hex, `rgb()` or `hsl()` strings, since ECharts draws on a\n * canvas and cannot resolve `var()` or parse `oklch()` (those draw gray); without it, series colors are the CSS\n * variables `--chart-cat-1` to `--chart-cat-8` on `:root` (`--chart-seq-*` and `--chart-div-*` for the\n * sequential and diverging palettes), held to the same formats.\n */\n colors?: string[];\n /** Chart height in pixels. Defaults to filling its parent (see `chartSizeStyle`). */\n height?: number;\n /** Additional CSS classes */\n className?: string;\n\n /** X-axis field key. Auto-detected from schema if not provided. */\n xKey?: string;\n /** Y-axis field key(s). Auto-detected from schema if not provided. */\n yKey?: string | string[];\n\n /** Accessibility label for screen readers */\n ariaLabel?: string;\n /** Test ID for automated testing */\n testId?: string;\n\n /** Additional ECharts options to merge */\n options?: Record<string, unknown>;\n\n /**\n * `(value: string | number, field: string) => string`. Formats measure values in the chart's built-in value\n * axes, tooltips, and value labels. `field` is the corresponding `yKey`, so one formatter can select a different\n * format for each series.\n *\n * For charts with multiple series on one value axis, axis ticks use the\n * first `yKey`; each tooltip uses its own series field.\n */\n valueFormatter?: ChartValueFormatter;\n\n /**\n * Pointer-only: charts render to <canvas>, so this does not fire for keyboard\n * users. Provide a keyboard-accessible equivalent (e.g. a table row action) for\n * the same action.\n */\n onDataClick?: (datum: ChartClickDatum) => void;\n\n /**\n * Controlled selection by category name. Matching data element(s) render at full\n * prominence while the rest are dimmed. Drive it from your own state to reflect a\n * cross-filter or selection. Categorical charts (bar, pie/donut) show emphasis;\n * other chart types ignore it.\n */\n selected?: string | string[];\n}\n\n// ============================================================================\n// Interaction / Click Events\n// ============================================================================\n\n/**\n * A normalized description of a clicked chart element.\n *\n * In the common cross-filter case, {@link ChartClickDatum.name} carries the\n * dimension value of the clicked element.\n */\nexport interface ChartClickDatum {\n /** Category label of the clicked element — the dimension value in the common cross-filter case. */\n name: string;\n /**\n * The datum's scalar value:\n * - bar / pie — the datum itself.\n * - time-series / scatter — the y-component of the `[x, y]` point (see\n * {@link ChartClickDatum.x} / {@link ChartClickDatum.y}).\n * - heatmap — the cell value (the third entry of ECharts'\n * `[xIndex, yIndex, value]` triple), *not* an axis index.\n * - radar — `null`; the item holds one value per indicator, so there is no\n * single scalar to report. Read the vector from {@link ChartClickDatum.raw}.\n *\n * `null` whenever there is no scalar value to surface.\n */\n value: number | string | null;\n x?: number | string;\n y?: number | string;\n seriesName?: string;\n dataIndex: number;\n seriesIndex: number;\n // Untouched ECharts event params.\n raw: unknown;\n}\n\n// ============================================================================\n// Query-based Props (chart fetches data)\n// ============================================================================\n\n/** Props for query-based data fetching */\nexport interface QueryProps extends ChartBaseProps {\n /** Analytics query key registered with analytics plugin */\n queryKey: string;\n /** Query parameters passed to the analytics endpoint */\n parameters?: Record<string, unknown>;\n /**\n * Data format to use\n * - \"json_array\": Use JSON format (smaller payloads, simpler)\n * - \"arrow_stream\": Use Arrow format (faster for large datasets)\n * - \"auto\": Automatically select based on expected data size\n * @default \"auto\"\n */\n format?: DataFormat;\n /** Transform raw data before rendering */\n transformer?: <T>(data: T) => T;\n // Discriminator: cannot use direct data with query\n data?: never;\n}\n\n// ============================================================================\n// Data-based Props (chart receives data externally)\n// ============================================================================\n\n/** Props for direct data injection */\nexport interface DataProps extends ChartBaseProps {\n /** Arrow Table or an array of row objects (interfaces and `as const` arrays too). */\n data: ChartDataInput;\n\n // Discriminator: cannot use query props with direct data\n queryKey?: never;\n parameters?: never;\n format?: never;\n transformer?: never;\n}\n\n// ============================================================================\n// Union Types for Each Chart\n// ============================================================================\n\n/** Base union type - either query-based or data-based */\nexport type UnifiedChartProps = QueryProps | DataProps;\n\n// ============================================================================\n// Chart-Specific Props\n// ============================================================================\n\n/** Props specific to bar charts */\nexport interface BarChartSpecificProps {\n /** Chart orientation @default \"vertical\" */\n orientation?: Orientation;\n /** Stack bars */\n stacked?: boolean;\n}\n\n/** Props specific to line charts */\nexport interface LineChartSpecificProps {\n /** Chart orientation @default \"vertical\" */\n orientation?: Orientation;\n /** Show data point symbols @default false */\n showSymbol?: boolean;\n /** Smooth line curves @default true */\n smooth?: boolean;\n}\n\n/** Props specific to area charts */\nexport interface AreaChartSpecificProps {\n /** Chart orientation @default \"vertical\" */\n orientation?: Orientation;\n /** Show data point symbols @default false */\n showSymbol?: boolean;\n /** Smooth line curves @default true */\n smooth?: boolean;\n /** Stack areas @default false */\n stacked?: boolean;\n}\n\n/** Props specific to scatter charts */\nexport interface ScatterChartSpecificProps {\n /** Symbol size @default 8 */\n symbolSize?: number;\n}\n\n/** Props specific to pie/donut charts */\nexport interface PieChartSpecificProps {\n /** Inner radius for donut charts (0-100%) @default 0 */\n innerRadius?: number;\n /** Show labels on slices @default true */\n showLabels?: boolean;\n /** Label position @default \"outside\" */\n labelPosition?: \"outside\" | \"inside\" | \"center\";\n}\n\n/** Props specific to radar charts */\nexport interface RadarChartSpecificProps {\n /** Show area fill @default true */\n showArea?: boolean;\n}\n\n/** Props specific to heatmap charts */\nexport interface HeatmapChartSpecificProps {\n /**\n * Field key for the Y-axis categories.\n * For heatmaps, data should have: xKey (column), yAxisKey (row), and yKey (value).\n */\n yAxisKey?: string;\n /** Min value for color scale (auto-detected if not provided) */\n min?: number;\n /** Max value for color scale (auto-detected if not provided) */\n max?: number;\n /** Show value labels on cells @default false */\n showLabels?: boolean;\n}\n\n// ============================================================================\n// Complete Chart Props (union + specific)\n// ============================================================================\n\nexport type BarChartProps = (QueryProps | DataProps) & BarChartSpecificProps;\nexport type LineChartProps = (QueryProps | DataProps) & LineChartSpecificProps;\nexport type AreaChartProps = (QueryProps | DataProps) & AreaChartSpecificProps;\nexport type ScatterChartProps = (QueryProps | DataProps) &\n ScatterChartSpecificProps;\nexport type PieChartProps = (QueryProps | DataProps) & PieChartSpecificProps;\nexport type DonutChartProps = (QueryProps | DataProps) & PieChartSpecificProps;\nexport type RadarChartProps = (QueryProps | DataProps) &\n RadarChartSpecificProps;\nexport type HeatmapChartProps = (QueryProps | DataProps) &\n HeatmapChartSpecificProps;\n\n// ============================================================================\n// Internal Types\n// ============================================================================\n\n/** Base normalized data shared by all chart types */\nexport interface NormalizedChartDataBase {\n xData: (string | number)[];\n xField: string;\n yFields: string[];\n chartType: \"timeseries\" | \"categorical\";\n}\n\n/** Normalized chart data for rendering (standard charts) */\nexport interface NormalizedChartData extends NormalizedChartDataBase {\n yDataMap: Record<string, (string | number)[]>;\n}\n\n/** Type guard to check if data is an Arrow Table */\nexport function isArrowTable(data: ChartData): data is Table {\n return (\n data !== null &&\n typeof data === \"object\" &&\n \"schema\" in data &&\n \"numRows\" in data &&\n typeof (data as Table).getChild === \"function\"\n );\n}\n\n/** Type guard to check if props are query-based */\nexport function isQueryProps(props: UnifiedChartProps): props is QueryProps {\n return (\n \"queryKey\" in props &&\n typeof props.queryKey === \"string\" &&\n props.queryKey.length > 0\n );\n}\n\n/** Type guard to check if props are data-based */\nexport function isDataProps(props: UnifiedChartProps): props is DataProps {\n return \"data\" in props && props.data != null;\n}\n"],"mappings":";;AAkUA,SAAgB,aAAa,MAAgC;AAC3D,QACE,SAAS,QACT,OAAO,SAAS,YAChB,YAAY,QACZ,aAAa,QACb,OAAQ,KAAe,aAAa;;;AAKxC,SAAgB,aAAa,OAA+C;AAC1E,QACE,cAAc,SACd,OAAO,MAAM,aAAa,YAC1B,MAAM,SAAS,SAAS;;;AAK5B,SAAgB,YAAY,OAA8C;AACxE,QAAO,UAAU,SAAS,MAAM,QAAQ"}
@@ -14,6 +14,12 @@ import * as react_jsx_runtime0 from "react/jsx-runtime";
14
14
  * - Responsive design
15
15
  * - Supports opinionated mode (auto columns) and full-control mode (`children(table)`)
16
16
  *
17
+ * In opinionated mode the columns are the keys of the first row that match `/^[a-zA-Z_][a-zA-Z0-9_]*$/` (other
18
+ * keys are dropped), headed by the key in Title Case. Every cell whose value parses as a number, numeric strings
19
+ * included, is right-aligned and formatted: a key containing `cost`, `price`, `spend`, `revenue` or `usd` shows as
20
+ * USD, and any other value of 1000 or more is abbreviated (10021 shows as 10K). For ids, zip codes or years, render
21
+ * a `Table` from `useAnalyticsQuery` rows instead.
22
+ *
17
23
  * @param props - Props for the DataTable component
18
24
  * @param props.queryKey - The query key to fetch the data
19
25
  * @param props.parameters - The parameters to pass to the query. Required - use `{}` if none.
@@ -1 +1 @@
1
- {"version":3,"file":"data-table.d.ts","names":[],"sources":["../../../src/react/table/data-table.tsx"],"mappings":";;;;;;;AAuEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,SAAA,CAAU,KAAA,EAAO,cAAA,GAAc,kBAAA,CAAA,GAAA,CAAA,OAAA"}
1
+ {"version":3,"file":"data-table.d.ts","names":[],"sources":["../../../src/react/table/data-table.tsx"],"mappings":";;;;;;;AA6EA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,SAAA,CAAU,KAAA,EAAO,cAAA,GAAc,kBAAA,CAAA,GAAA,CAAA,OAAA"}
@@ -22,6 +22,12 @@ import { flexRender } from "@tanstack/react-table";
22
22
  * - Responsive design
23
23
  * - Supports opinionated mode (auto columns) and full-control mode (`children(table)`)
24
24
  *
25
+ * In opinionated mode the columns are the keys of the first row that match `/^[a-zA-Z_][a-zA-Z0-9_]*$/` (other
26
+ * keys are dropped), headed by the key in Title Case. Every cell whose value parses as a number, numeric strings
27
+ * included, is right-aligned and formatted: a key containing `cost`, `price`, `spend`, `revenue` or `usd` shows as
28
+ * USD, and any other value of 1000 or more is abbreviated (10021 shows as 10K). For ids, zip codes or years, render
29
+ * a `Table` from `useAnalyticsQuery` rows instead.
30
+ *
25
31
  * @param props - Props for the DataTable component
26
32
  * @param props.queryKey - The query key to fetch the data
27
33
  * @param props.parameters - The parameters to pass to the query. Required - use `{}` if none.
@@ -1 +1 @@
1
- {"version":3,"file":"data-table.js","names":["Table"],"sources":["../../../src/react/table/data-table.tsx"],"sourcesContent":["import { flexRender } from \"@tanstack/react-table\";\nimport { ChevronDown } from \"lucide-react\";\n\nimport { formatFieldLabel } from \"../lib/format\";\nimport { Button } from \"../ui/button\";\nimport {\n DropdownMenu,\n DropdownMenuCheckboxItem,\n DropdownMenuContent,\n DropdownMenuTrigger,\n} from \"../ui/dropdown-menu\";\nimport { Input } from \"../ui/input\";\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from \"../ui/select\";\nimport {\n Table,\n TableBody,\n TableCell,\n TableHead,\n TableHeader,\n TableRow,\n} from \"../ui/table\";\nimport { TableWrapper } from \"./table-wrapper\";\nimport type { DataTableLabels, DataTableProps } from \"./types\";\n\n/**\n * Production-ready data table with automatic data fetching and state management\n *\n * Features:\n * - Automatic column generation from data structure\n * - Integrated with useAnalyticsQuery for data fetching\n * - Built-in loading, error, and empty states\n * - Dynamic filtering, sorting and pagination\n * - Column visibility controls\n * - Responsive design\n * - Supports opinionated mode (auto columns) and full-control mode (`children(table)`)\n *\n * @param props - Props for the DataTable component\n * @param props.queryKey - The query key to fetch the data\n * @param props.parameters - The parameters to pass to the query. Required - use `{}` if none.\n * @param props.filterColumn - The column to filter by\n * @param props.filterPlaceholder - The placeholder for the filter input\n * @param props.children - Optional children for full control mode\n * @returns - The rendered data table component\n *\n * @example\n * // Opinionated mode\n * <DataTable\n * queryKey=\"users-list\"\n * parameters={{ status: \"active\" }}\n * filterColumn=\"email\"\n * filterPlaceholder=\"Filter by email...\"\n * />\n * @example\n * // full control mode\n * <DataTable queryKey=\"users-list\" parameters={{ status: \"active\" }}>\n * {(table) => (\n * <div>\n * <h2>Custom Table UI</h2>\n * {table.getRowModel().rows.map(row => (\n * <div key={row.id}>{row.original.name}</div>\n * ))}\n * </div>\n * )}\n * </DataTable>\n */\nexport function DataTable(props: DataTableProps) {\n const {\n parameters,\n queryKey,\n filterColumn,\n filterPlaceholder,\n transform,\n labels,\n ariaLabel,\n testId,\n className,\n enableRowSelection,\n onRowSelectionChange,\n children,\n pageSize = 10,\n pageSizeOptions = [10, 25, 50, 100],\n } = props;\n\n const defaultLabels: Required<DataTableLabels> = {\n columnsButton: \"Columns\",\n noResults: \"No results found.\",\n rowsFound: `\\${count} row(s) found`,\n previousButton: \"Previous\",\n nextButton: \"Next\",\n rowsPerPage: \"Rows per page\",\n showing: `Showing \\${from} to \\${to} of \\${total}`,\n };\n\n const finalLabels = { ...defaultLabels, ...labels };\n\n return (\n <TableWrapper\n queryKey={queryKey}\n parameters={parameters}\n ariaLabel={ariaLabel}\n testId={testId}\n className={className}\n transformer={transform}\n enableRowSelection={enableRowSelection}\n onRowSelectionChange={onRowSelectionChange}\n pageSize={pageSize}\n >\n {(table) => {\n if (children) {\n return children(table);\n }\n\n const data = table.options.data;\n\n const defaultFilterColumn =\n filterColumn ||\n (data && data.length > 0\n ? Object.keys(data[0] as Record<string, any>).find(\n (key) =>\n typeof (data[0] as Record<string, any>)[key] === \"string\",\n )\n : null);\n\n const totalRows = table.getFilteredRowModel().rows.length;\n const currentPage = table.getState().pagination.pageIndex + 1;\n const currentPageSize = table.getState().pagination.pageSize;\n const fromRow =\n totalRows === 0 ? 0 : (currentPage - 1) * currentPageSize + 1;\n const toRow = Math.min(currentPage * currentPageSize, totalRows);\n\n return (\n <div className=\"w-full\">\n <div className=\"flex items-center py-4 gap-2\">\n {defaultFilterColumn && (\n <Input\n placeholder={\n filterPlaceholder ||\n `Filter by ${formatFieldLabel(defaultFilterColumn)}...`\n }\n value={\n (table\n .getColumn(defaultFilterColumn)\n ?.getFilterValue() as string) ?? \"\"\n }\n onChange={(event) =>\n table\n .getColumn(defaultFilterColumn)\n ?.setFilterValue(event.target.value)\n }\n className=\"max-w-sm\"\n />\n )}\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button variant=\"outline\" className=\"ml-auto\">\n {finalLabels.columnsButton}{\" \"}\n <ChevronDown className=\"ml-2 h-4 w-4\" />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\">\n {table\n .getAllColumns()\n .filter((column) => column.getCanHide())\n .map((column) => {\n return (\n <DropdownMenuCheckboxItem\n key={column.id}\n className=\"capitalize\"\n checked={column.getIsVisible()}\n onCheckedChange={(value) =>\n column.toggleVisibility(!!value)\n }\n >\n {formatFieldLabel(column.id)}\n </DropdownMenuCheckboxItem>\n );\n })}\n </DropdownMenuContent>\n </DropdownMenu>\n </div>\n <div className=\"overflow-hidden rounded-md border border-border\">\n <div className=\"max-h-[600px] overflow-y-auto\">\n <Table>\n <TableHeader className=\"sticky top-0 bg-background z-10\">\n {table.getHeaderGroups().map((headerGroup) => (\n <TableRow key={headerGroup.id}>\n {headerGroup.headers.map((header) => {\n const isSelectColumn = header.column.id === \"select\";\n return (\n <TableHead\n key={header.id}\n style={{\n width: header.getSize(),\n position: \"relative\",\n }}\n className={\n isSelectColumn ? \"w-[40px] p-0\" : undefined\n }\n >\n {header.isPlaceholder\n ? null\n : flexRender(\n header.column.columnDef.header,\n header.getContext(),\n )}\n </TableHead>\n );\n })}\n </TableRow>\n ))}\n </TableHeader>\n <TableBody>\n {table.getRowModel().rows?.length ? (\n table.getRowModel().rows.map((row) => (\n <TableRow\n key={row.id}\n data-state={row.getIsSelected() && \"selected\"}\n >\n {row.getVisibleCells().map((cell) => {\n const isSelectColumn = cell.column.id === \"select\";\n return (\n <TableCell\n key={cell.id}\n style={{\n width: cell.column.getSize(),\n }}\n className={\n isSelectColumn ? \"w-[40px] p-0\" : undefined\n }\n >\n {flexRender(\n cell.column.columnDef.cell,\n cell.getContext(),\n )}\n </TableCell>\n );\n })}\n </TableRow>\n ))\n ) : (\n <TableRow>\n <TableCell\n colSpan={table.getAllColumns().length}\n className=\"h-24 text-center\"\n >\n {finalLabels.noResults}\n </TableCell>\n </TableRow>\n )}\n </TableBody>\n </Table>\n </div>\n </div>\n {/* On mobile, flex-col-reverse places pagination buttons above the info row for easier thumb access */}\n <div className=\"flex flex-col-reverse sm:flex-row items-start sm:items-center justify-between gap-3 py-4\">\n <div className=\"flex flex-wrap items-center gap-3 sm:gap-6\">\n <div className=\"text-foreground text-sm\">\n {totalRows > 0\n ? finalLabels.showing\n .replace(`\\${from}`, fromRow.toString())\n .replace(`\\${to}`, toRow.toString())\n .replace(`\\${total}`, totalRows.toString())\n : finalLabels.noResults}\n </div>\n <div className=\"flex items-center gap-2\">\n <span className=\"text-sm text-foreground\">\n {finalLabels.rowsPerPage}\n </span>\n <Select\n value={currentPageSize.toString()}\n onValueChange={(value) => {\n table.setPageSize(Number(value));\n }}\n >\n <SelectTrigger className=\"w-[70px]\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {pageSizeOptions.map((size) => (\n <SelectItem key={size} value={size.toString()}>\n {size}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n </div>\n <div className=\"space-x-2\">\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={() => table.previousPage()}\n disabled={!table.getCanPreviousPage()}\n >\n {finalLabels.previousButton}\n </Button>\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={() => table.nextPage()}\n disabled={!table.getCanNextPage()}\n >\n {finalLabels.nextButton}\n </Button>\n </div>\n </div>\n </div>\n );\n }}\n </TableWrapper>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuEA,SAAgB,UAAU,OAAuB;CAC/C,MAAM,EACJ,YACA,UACA,cACA,mBACA,WACA,QACA,WACA,QACA,WACA,oBACA,sBACA,UACA,WAAW,IACX,kBAAkB;EAAC;EAAI;EAAI;EAAI;EAAI,KACjC;CAYJ,MAAM,cAAc;EATlB,eAAe;EACf,WAAW;EACX,WAAW;EACX,gBAAgB;EAChB,YAAY;EACZ,aAAa;EACb,SAAS;EAG6B,GAAG;EAAQ;AAEnD,QACE,oBAAC;EACW;EACE;EACD;EACH;EACG;EACX,aAAa;EACO;EACE;EACZ;aAER,UAAU;AACV,OAAI,SACF,QAAO,SAAS,MAAM;GAGxB,MAAM,OAAO,MAAM,QAAQ;GAE3B,MAAM,sBACJ,iBACC,QAAQ,KAAK,SAAS,IACnB,OAAO,KAAK,KAAK,GAA0B,CAAC,MACzC,QACC,OA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F,EACN,qBAAC;OAAI,WAAU;kBACb,oBAAC;QACC,SAAQ;QACR,MAAK;QACL,eAAe,MAAM,cAAc;QACnC,UAAU,CAAC,MAAM,oBAAoB;kBAEpC,YAAY;SACN,EACT,oBAAC;QACC,SAAQ;QACR,MAAK;QACL,eAAe,MAAM,UAAU;QAC/B,UAAU,CAAC,MAAM,gBAAgB;kBAEhC,YAAY;SACN;QACL;OACF;;KACF;;GAGG"}
1
+ {"version":3,"file":"data-table.js","names":["Table"],"sources":["../../../src/react/table/data-table.tsx"],"sourcesContent":["import { flexRender } from \"@tanstack/react-table\";\nimport { ChevronDown } from \"lucide-react\";\n\nimport { formatFieldLabel } from \"../lib/format\";\nimport { Button } from \"../ui/button\";\nimport {\n DropdownMenu,\n DropdownMenuCheckboxItem,\n DropdownMenuContent,\n DropdownMenuTrigger,\n} from \"../ui/dropdown-menu\";\nimport { Input } from \"../ui/input\";\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from \"../ui/select\";\nimport {\n Table,\n TableBody,\n TableCell,\n TableHead,\n TableHeader,\n TableRow,\n} from \"../ui/table\";\nimport { TableWrapper } from \"./table-wrapper\";\nimport type { DataTableLabels, DataTableProps } from \"./types\";\n\n/**\n * Production-ready data table with automatic data fetching and state management\n *\n * Features:\n * - Automatic column generation from data structure\n * - Integrated with useAnalyticsQuery for data fetching\n * - Built-in loading, error, and empty states\n * - Dynamic filtering, sorting and pagination\n * - Column visibility controls\n * - Responsive design\n * - Supports opinionated mode (auto columns) and full-control mode (`children(table)`)\n *\n * In opinionated mode the columns are the keys of the first row that match `/^[a-zA-Z_][a-zA-Z0-9_]*$/` (other\n * keys are dropped), headed by the key in Title Case. Every cell whose value parses as a number, numeric strings\n * included, is right-aligned and formatted: a key containing `cost`, `price`, `spend`, `revenue` or `usd` shows as\n * USD, and any other value of 1000 or more is abbreviated (10021 shows as 10K). For ids, zip codes or years, render\n * a `Table` from `useAnalyticsQuery` rows instead.\n *\n * @param props - Props for the DataTable component\n * @param props.queryKey - The query key to fetch the data\n * @param props.parameters - The parameters to pass to the query. Required - use `{}` if none.\n * @param props.filterColumn - The column to filter by\n * @param props.filterPlaceholder - The placeholder for the filter input\n * @param props.children - Optional children for full control mode\n * @returns - The rendered data table component\n *\n * @example\n * // Opinionated mode\n * <DataTable\n * queryKey=\"users-list\"\n * parameters={{ status: \"active\" }}\n * filterColumn=\"email\"\n * filterPlaceholder=\"Filter by email...\"\n * />\n * @example\n * // full control mode\n * <DataTable queryKey=\"users-list\" parameters={{ status: \"active\" }}>\n * {(table) => (\n * <div>\n * <h2>Custom Table UI</h2>\n * {table.getRowModel().rows.map(row => (\n * <div key={row.id}>{row.original.name}</div>\n * ))}\n * </div>\n * )}\n * </DataTable>\n */\nexport function DataTable(props: DataTableProps) {\n const {\n parameters,\n queryKey,\n filterColumn,\n filterPlaceholder,\n transform,\n labels,\n ariaLabel,\n testId,\n className,\n enableRowSelection,\n onRowSelectionChange,\n children,\n pageSize = 10,\n pageSizeOptions = [10, 25, 50, 100],\n } = props;\n\n const defaultLabels: Required<DataTableLabels> = {\n columnsButton: \"Columns\",\n noResults: \"No results found.\",\n rowsFound: `\\${count} row(s) found`,\n previousButton: \"Previous\",\n nextButton: \"Next\",\n rowsPerPage: \"Rows per page\",\n showing: `Showing \\${from} to \\${to} of \\${total}`,\n };\n\n const finalLabels = { ...defaultLabels, ...labels };\n\n return (\n <TableWrapper\n queryKey={queryKey}\n parameters={parameters}\n ariaLabel={ariaLabel}\n testId={testId}\n className={className}\n transformer={transform}\n enableRowSelection={enableRowSelection}\n onRowSelectionChange={onRowSelectionChange}\n pageSize={pageSize}\n >\n {(table) => {\n if (children) {\n return children(table);\n }\n\n const data = table.options.data;\n\n const defaultFilterColumn =\n filterColumn ||\n (data && data.length > 0\n ? Object.keys(data[0] as Record<string, any>).find(\n (key) =>\n typeof (data[0] as Record<string, any>)[key] === \"string\",\n )\n : null);\n\n const totalRows = table.getFilteredRowModel().rows.length;\n const currentPage = table.getState().pagination.pageIndex + 1;\n const currentPageSize = table.getState().pagination.pageSize;\n const fromRow =\n totalRows === 0 ? 0 : (currentPage - 1) * currentPageSize + 1;\n const toRow = Math.min(currentPage * currentPageSize, totalRows);\n\n return (\n <div className=\"w-full\">\n <div className=\"flex items-center py-4 gap-2\">\n {defaultFilterColumn && (\n <Input\n placeholder={\n filterPlaceholder ||\n `Filter by ${formatFieldLabel(defaultFilterColumn)}...`\n }\n value={\n (table\n .getColumn(defaultFilterColumn)\n ?.getFilterValue() as string) ?? \"\"\n }\n onChange={(event) =>\n table\n .getColumn(defaultFilterColumn)\n ?.setFilterValue(event.target.value)\n }\n className=\"max-w-sm\"\n />\n )}\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button variant=\"outline\" className=\"ml-auto\">\n {finalLabels.columnsButton}{\" \"}\n <ChevronDown className=\"ml-2 h-4 w-4\" />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\">\n {table\n .getAllColumns()\n .filter((column) => column.getCanHide())\n .map((column) => {\n return (\n <DropdownMenuCheckboxItem\n key={column.id}\n className=\"capitalize\"\n checked={column.getIsVisible()}\n onCheckedChange={(value) =>\n column.toggleVisibility(!!value)\n }\n >\n {formatFieldLabel(column.id)}\n </DropdownMenuCheckboxItem>\n );\n })}\n </DropdownMenuContent>\n </DropdownMenu>\n </div>\n <div className=\"overflow-hidden rounded-md border border-border\">\n <div className=\"max-h-[600px] overflow-y-auto\">\n <Table>\n <TableHeader className=\"sticky top-0 bg-background z-10\">\n {table.getHeaderGroups().map((headerGroup) => (\n <TableRow key={headerGroup.id}>\n {headerGroup.headers.map((header) => {\n const isSelectColumn = header.column.id === \"select\";\n return (\n <TableHead\n key={header.id}\n style={{\n width: header.getSize(),\n position: \"relative\",\n }}\n className={\n isSelectColumn ? \"w-[40px] p-0\" : undefined\n }\n >\n {header.isPlaceholder\n ? null\n : flexRender(\n header.column.columnDef.header,\n header.getContext(),\n )}\n </TableHead>\n );\n })}\n </TableRow>\n ))}\n </TableHeader>\n <TableBody>\n {table.getRowModel().rows?.length ? (\n table.getRowModel().rows.map((row) => (\n <TableRow\n key={row.id}\n data-state={row.getIsSelected() && \"selected\"}\n >\n {row.getVisibleCells().map((cell) => {\n const isSelectColumn = cell.column.id === \"select\";\n return (\n <TableCell\n key={cell.id}\n style={{\n width: cell.column.getSize(),\n }}\n className={\n isSelectColumn ? \"w-[40px] p-0\" : undefined\n }\n >\n {flexRender(\n cell.column.columnDef.cell,\n cell.getContext(),\n )}\n </TableCell>\n );\n })}\n </TableRow>\n ))\n ) : (\n <TableRow>\n <TableCell\n colSpan={table.getAllColumns().length}\n className=\"h-24 text-center\"\n >\n {finalLabels.noResults}\n </TableCell>\n </TableRow>\n )}\n </TableBody>\n </Table>\n </div>\n </div>\n {/* On mobile, flex-col-reverse places pagination buttons above the info row for easier thumb access */}\n <div className=\"flex flex-col-reverse sm:flex-row items-start sm:items-center justify-between gap-3 py-4\">\n <div className=\"flex flex-wrap items-center gap-3 sm:gap-6\">\n <div className=\"text-foreground text-sm\">\n {totalRows > 0\n ? finalLabels.showing\n .replace(`\\${from}`, fromRow.toString())\n .replace(`\\${to}`, toRow.toString())\n .replace(`\\${total}`, totalRows.toString())\n : finalLabels.noResults}\n </div>\n <div className=\"flex items-center gap-2\">\n <span className=\"text-sm text-foreground\">\n {finalLabels.rowsPerPage}\n </span>\n <Select\n value={currentPageSize.toString()}\n onValueChange={(value) => {\n table.setPageSize(Number(value));\n }}\n >\n <SelectTrigger className=\"w-[70px]\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {pageSizeOptions.map((size) => (\n <SelectItem key={size} value={size.toString()}>\n {size}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n </div>\n <div className=\"space-x-2\">\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={() => table.previousPage()}\n disabled={!table.getCanPreviousPage()}\n >\n {finalLabels.previousButton}\n </Button>\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={() => table.nextPage()}\n disabled={!table.getCanNextPage()}\n >\n {finalLabels.nextButton}\n </Button>\n </div>\n </div>\n </div>\n );\n }}\n </TableWrapper>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6EA,SAAgB,UAAU,OAAuB;CAC/C,MAAM,EACJ,YACA,UACA,cACA,mBACA,WACA,QACA,WACA,QACA,WACA,oBACA,sBACA,UACA,WAAW,IACX,kBAAkB;EAAC;EAAI;EAAI;EAAI;EAAI,KACjC;CAYJ,MAAM,cAAc;EATlB,eAAe;EACf,WAAW;EACX,WAAW;EACX,gBAAgB;EAChB,YAAY;EACZ,aAAa;EACb,SAAS;EAG6B,GAAG;EAAQ;AAEnD,QACE,oBAAC;EACW;EACE;EACD;EACH;EACG;EACX,aAAa;EACO;EACE;EACZ;aAER,UAAU;AACV,OAAI,SACF,QAAO,SAAS,MAAM;GAGxB,MAAM,OAAO,MAAM,QAAQ;GAE3B,MAAM,sBACJ,iBACC,QAAQ,KAAK,SAAS,IACnB,OAAO,KAAK,KAAK,GAA0B,CAAC,MACzC,QACC,OAAQ,KAAK,GAA2B,SAAS,SACpD,GACD;GAEN,MAAM,YAAY,MAAM,qBAAqB,CAAC,KAAK;GACnD,MAAM,cAAc,MAAM,UAAU,CAAC,WAAW,YAAY;GAC5D,MAAM,kBAAkB,MAAM,UAAU,CAAC,WAAW;GACpD,MAAM,UACJ,cAAc,IAAI,KAAK,cAAc,KAAK,kBAAkB;GAC9D,MAAM,QAAQ,KAAK,IAAI,cAAc,iBAAiB,UAAU;AAEhE,UACE,qBAAC;IAAI,WAAU;;KACb,qBAAC;MAAI,WAAU;iBACZ,uBACC,oBAAC;OACC,aACE,qBACA,aAAa,iBAAiB,oBAAoB,CAAC;OAErD,OACG,MACE,UAAU,oBAAoB,EAC7B,gBAAgB,IAAe;OAErC,WAAW,UACT,MACG,UAAU,oBAAoB,EAC7B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YAAY,CAClB;YAXI,KAAK,GAYA;UAEd;UArBG,IAAI,GAsBA,CACX,GAEF,oBAAC,sBACC,oBAAC;QACC,SAAS,MAAM,eAAe,CAAC;QAC/B,WAAU;kBAET,YAAY;SACH,GACH,GAEH,IACN;QACJ;OACF;KAEN,qBAAC;MAAI,WAAU;iBACb,qBAAC;OAAI,WAAU;kBACb,oBAAC;QAAI,WAAU;kBACZ,YAAY,IACT,YAAY,QACT,QAAQ,YAAY,QAAQ,UAAU,CAAC,CACvC,QAAQ,UAAU,MAAM,UAAU,CAAC,CACnC,QAAQ,aAAa,UAAU,UAAU,CAAC,GAC7C,YAAY;SACZ,EACN,qBAAC;QAAI,WAAU;mBACb,oBAAC;SAAK,WAAU;mBACb,YAAY;UACR,EACP,qBAAC;SACC,OAAO,gBAAgB,UAAU;SACjC,gBAAgB,UAAU;AACxB,gBAAM,YAAY,OAAO,MAAM,CAAC;;oBAGlC,oBAAC;UAAc,WAAU;oBACvB,oBAAC,gBAAc;WACD,EAChB,oBAAC,2BACE,gBAAgB,KAAK,SACpB,oBAAC;UAAsB,OAAO,KAAK,UAAU;oBAC1C;YADc,KAEJ,CACb,GACY;UACT;SACL;QACF,EACN,qBAAC;OAAI,WAAU;kBACb,oBAAC;QACC,SAAQ;QACR,MAAK;QACL,eAAe,MAAM,cAAc;QACnC,UAAU,CAAC,MAAM,oBAAoB;kBAEpC,YAAY;SACN,EACT,oBAAC;QACC,SAAQ;QACR,MAAK;QACL,eAAe,MAAM,UAAU;QAC/B,UAAU,CAAC,MAAM,gBAAgB;kBAEhC,YAAY;SACN;QACL;OACF;;KACF;;GAGG"}
@@ -5,7 +5,7 @@ import * as class_variance_authority_types0 from "class-variance-authority/types
5
5
 
6
6
  //#region src/react/ui/button.d.ts
7
7
  declare const buttonVariants: (props?: ({
8
- variant?: "default" | "link" | "destructive" | "secondary" | "outline" | "ghost" | null | undefined;
8
+ variant?: "default" | "destructive" | "secondary" | "outline" | "ghost" | "link" | null | undefined;
9
9
  size?: "default" | "sm" | "lg" | "icon" | "icon-sm" | "icon-lg" | null | undefined;
10
10
  } & class_variance_authority_types0.ClassProp) | undefined) => string;
11
11
  /** Clickable button with multiple variants and sizes */