@datakable/react 0.0.0-stage → 1.0.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.
@@ -0,0 +1,423 @@
1
+ "use client";
2
+
3
+ // src/data-table.tsx
4
+ import {
5
+ boundaryDiagnostics,
6
+ defaultFormat,
7
+ deriveColumns,
8
+ describeReturn,
9
+ emitTableDiagnostic,
10
+ keepDiagnostics,
11
+ matchesSlot,
12
+ slotDiagnostics
13
+ } from "@datakable/core";
14
+ import {
15
+ Component,
16
+ useEffect,
17
+ useLayoutEffect,
18
+ useMemo
19
+ } from "react";
20
+ import {
21
+ cellSlot,
22
+ invalidCellSlot,
23
+ registerRenderOperations,
24
+ renderDiagnostics
25
+ } from "./render-codes.js";
26
+ import { useDataTable } from "./use-data-table.js";
27
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
28
+ keepDiagnostics(renderDiagnostics, boundaryDiagnostics, slotDiagnostics);
29
+ registerRenderOperations();
30
+ var useIsomorphicLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
31
+ function DataTable(props) {
32
+ if (props.table !== void 0) {
33
+ return /* @__PURE__ */ jsx(DataTableView, { table: props.table, components: props.components, caption: props.caption });
34
+ }
35
+ return /* @__PURE__ */ jsx(ZeroConfig, { ...props });
36
+ }
37
+ function ZeroConfig(props) {
38
+ const { components, caption, table: _, ...options } = props;
39
+ const view = useDataTable(options);
40
+ return /* @__PURE__ */ jsx(DataTableView, { table: view, components, caption });
41
+ }
42
+ var WARN = "\u26A0";
43
+ var BUSY = ["validating", "pending", "searching", "fetching"];
44
+ var LOADING = ["validating", "searching", "fetching"];
45
+ function hasAsyncSource(table) {
46
+ const options = table.getOptions();
47
+ if (typeof options.fetcher === "function") return true;
48
+ if (!Array.isArray(options.features)) return false;
49
+ for (const f of options.features) {
50
+ if (typeof f?.options?.values?.searchFn === "function") return true;
51
+ }
52
+ return false;
53
+ }
54
+ function resolveColumns(defs) {
55
+ const out = [];
56
+ for (let index = 0; index < defs.length; index++) {
57
+ const def = defs[index];
58
+ if (def === null || typeof def !== "object") continue;
59
+ const id = typeof def.key === "string" ? def.key : def.id;
60
+ if (typeof id !== "string") continue;
61
+ out.push({ def, index, id, header: typeof def.header === "string" ? def.header : id });
62
+ }
63
+ return out;
64
+ }
65
+ var segment = (s) => String(typeof s === "object" ? s.key : s);
66
+ function issueTitle(issues) {
67
+ const paths = /* @__PURE__ */ new Set();
68
+ for (const i of issues) paths.add(i.path?.length ? i.path.map(segment).join(".") : "(row)");
69
+ return `Invalid: ${[...paths].join(", ")}`;
70
+ }
71
+ var tableOf = (view) => Object.hasOwn(view, "rowModel") ? Object.getPrototypeOf(view) : view;
72
+ function report(table, failures) {
73
+ const bySlot = /* @__PURE__ */ new Map();
74
+ for (const f of failures) {
75
+ const k = `${f.slot}\0${f.expected === void 0 ? "throw" : "return"}`;
76
+ const list = bySlot.get(k);
77
+ if (list) list.push(f);
78
+ else bySlot.set(k, [f]);
79
+ }
80
+ for (const list of bySlot.values()) {
81
+ const first = list[0];
82
+ const rows = list.slice(0, 3).map((f) => f.row);
83
+ const fallback = "those cells rendered \u26A0";
84
+ try {
85
+ if (first.expected === void 0) {
86
+ const e = first.error;
87
+ emitTableDiagnostic(
88
+ table,
89
+ "DK_CALLBACK_FAILED",
90
+ {
91
+ slot: first.slot,
92
+ column: first.column,
93
+ rows,
94
+ count: list.length,
95
+ fallback,
96
+ ...e instanceof Error ? { errorName: e.name } : {}
97
+ },
98
+ { cause: e }
99
+ );
100
+ } else if (process.env.NODE_ENV !== "production") {
101
+ emitTableDiagnostic(table, "DK_CALLBACK_BAD_RETURN", {
102
+ slot: first.slot,
103
+ column: first.column,
104
+ expected: first.expected,
105
+ received: first.received ?? "undefined",
106
+ count: list.length,
107
+ rows,
108
+ fallback
109
+ });
110
+ }
111
+ } catch {
112
+ }
113
+ }
114
+ }
115
+ function cellContent(col, row, failures, table) {
116
+ const def = col.def;
117
+ const value = row.getValue(col.id);
118
+ const issues = row.valid ? void 0 : row.getCellIssues(col.id);
119
+ let slot = "cell";
120
+ try {
121
+ if (issues !== void 0 && issues.length > 0) {
122
+ if (def.invalidCell) {
123
+ slot = "invalidCell";
124
+ const out = def.invalidCell({ original: row.original, value, issues });
125
+ if (matchesSlot(invalidCellSlot, out)) return guard(out, table, col, row, "invalidCell");
126
+ return bad(failures, col, row, slot, "a value (not a Promise)", out);
127
+ }
128
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
129
+ defaultFormat(value),
130
+ " ",
131
+ /* @__PURE__ */ jsx("span", { "data-dk-invalid-marker": "", "aria-hidden": "true", children: WARN })
132
+ ] });
133
+ }
134
+ if (def.cell) {
135
+ const out = def.cell({ row: row.original, value });
136
+ if (matchesSlot(cellSlot, out)) return guard(out, table, col, row, "cell");
137
+ return bad(failures, col, row, slot, "a value (not a Promise)", out);
138
+ }
139
+ if (def.format) {
140
+ slot = "format";
141
+ const out = def.format(value);
142
+ if (typeof out === "string") return out;
143
+ bad(failures, col, row, slot, "a string", out);
144
+ return defaultFormat(value);
145
+ }
146
+ return defaultFormat(value);
147
+ } catch (error) {
148
+ failures.push({ slot: `columns[${col.index}].${slot}`, column: col.id, row: row.index, error });
149
+ return WARN;
150
+ }
151
+ }
152
+ function guard(out, table, col, row, slot) {
153
+ if (typeof out !== "object" || out === null) return out;
154
+ return /* @__PURE__ */ jsx(CellBoundary, { table, col, slot, row: row.index, original: row.original, children: out });
155
+ }
156
+ function bad(failures, col, row, slot, expected, out) {
157
+ failures.push({
158
+ slot: `columns[${col.index}].${slot}`,
159
+ column: col.id,
160
+ row: row.index,
161
+ expected,
162
+ received: describeReturn(out)
163
+ });
164
+ return WARN;
165
+ }
166
+ var ariaSort = (dir) => dir === "asc" ? "ascending" : dir === "desc" ? "descending" : "none";
167
+ function DataTableView(props) {
168
+ const view = props.table;
169
+ const parts = props.components ?? {};
170
+ const { state, rowModel } = view;
171
+ const { rows, status, isInitialLoad } = rowModel;
172
+ const defs = view.getOptions().columns;
173
+ const data = view.getData();
174
+ const derivedFrom = defs === void 0 ? data : void 0;
175
+ const columns = useMemo(
176
+ () => resolveColumns(defs ?? (derivedFrom ? deriveColumns(derivedFrom) : [])),
177
+ [defs, derivedFrom]
178
+ );
179
+ const failures = [];
180
+ const table = tableOf(view);
181
+ useIsomorphicLayoutEffect(() => {
182
+ if (failures.length > 0) report(table, failures);
183
+ });
184
+ const sortable = typeof view.toggleSort === "function";
185
+ const searchState = state.search;
186
+ const paged = typeof view.getPageCount === "function";
187
+ const loading = isInitialLoad && (LOADING.includes(status) || status === "pending" && hasAsyncSource(view));
188
+ const failed = isInitialLoad && status === "error";
189
+ const span = Math.max(columns.length, 1);
190
+ const retryLoad = () => void view.refetch();
191
+ const Search = parts.SearchInput ?? DefaultSearchInput;
192
+ const Pager = parts.Pagination ?? DefaultPagination;
193
+ const Empty = parts.Empty ?? DefaultEmpty;
194
+ const Loading = parts.Loading ?? DefaultLoading;
195
+ const ErrorState = parts.Error ?? DefaultError;
196
+ let body;
197
+ if (loading) {
198
+ body = stateRow(span, "loading", /* @__PURE__ */ jsx(Loading, { status }));
199
+ } else if (failed) {
200
+ body = stateRow(span, "error", /* @__PURE__ */ jsx(ErrorState, { status, reason: "load", retry: retryLoad }));
201
+ } else if (rows.length === 0) {
202
+ body = stateRow(span, "empty", /* @__PURE__ */ jsx(Empty, { filtered: rowModel.totalCount > 0 }));
203
+ } else {
204
+ body = rows.map((row) => {
205
+ const valid = row.valid;
206
+ return /* @__PURE__ */ jsx(
207
+ "tr",
208
+ {
209
+ "data-invalid": valid ? void 0 : "true",
210
+ "aria-invalid": valid ? void 0 : "true",
211
+ title: valid ? void 0 : issueTitle(row.issues),
212
+ children: columns.map((col) => {
213
+ const issues = valid ? void 0 : row.getCellIssues(col.id);
214
+ const broken = issues !== void 0 && issues.length > 0;
215
+ return /* @__PURE__ */ jsx(
216
+ "td",
217
+ {
218
+ "data-invalid": broken ? "true" : void 0,
219
+ "aria-invalid": broken ? "true" : void 0,
220
+ title: broken ? issueTitle(issues) : void 0,
221
+ children: cellContent(col, row, failures, table)
222
+ },
223
+ col.index
224
+ );
225
+ })
226
+ },
227
+ row.key
228
+ );
229
+ });
230
+ }
231
+ return /* @__PURE__ */ jsxs(
232
+ "div",
233
+ {
234
+ "data-datakable": "",
235
+ "data-status": status,
236
+ "data-initial-load": isInitialLoad ? "true" : "false",
237
+ "aria-busy": BUSY.includes(status) ? "true" : void 0,
238
+ children: [
239
+ searchState && /* @__PURE__ */ jsx("div", { "data-dk-search": "", "data-status": searchState.status, children: /* @__PURE__ */ jsx(
240
+ Search,
241
+ {
242
+ value: searchState.input,
243
+ status: searchState.status,
244
+ onChange: (q) => void view.setSearch?.(q),
245
+ onSubmit: () => void view.flushSearch?.(),
246
+ onClear: () => view.clearSearch?.()
247
+ }
248
+ ) }),
249
+ !loading && !failed && status !== "idle" && /* @__PURE__ */ jsx(RefreshIndicator, { status, retry: retryLoad }),
250
+ /* @__PURE__ */ jsxs("table", { children: [
251
+ props.caption != null && /* @__PURE__ */ jsx("caption", { children: props.caption }),
252
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: columns.map((col) => {
253
+ const canSort = sortable && col.def.sortable !== false;
254
+ const dir = canSort ? view.getSortDirection?.(col.id) ?? false : false;
255
+ return /* @__PURE__ */ jsx(
256
+ "th",
257
+ {
258
+ scope: "col",
259
+ "aria-sort": canSort ? ariaSort(dir) : void 0,
260
+ "data-sort": dir || void 0,
261
+ children: canSort ? /* @__PURE__ */ jsxs(
262
+ "button",
263
+ {
264
+ type: "button",
265
+ onClick: (e) => view.toggleSort?.(col.id, { multi: e.shiftKey }),
266
+ children: [
267
+ col.header,
268
+ /* @__PURE__ */ jsx("span", { "data-dk-sort-indicator": "", "aria-hidden": "true", children: dir === "asc" ? " \u25B2" : dir === "desc" ? " \u25BC" : "" })
269
+ ]
270
+ }
271
+ ) : col.header
272
+ },
273
+ col.index
274
+ );
275
+ }) }) }),
276
+ /* @__PURE__ */ jsx("tbody", { children: /* @__PURE__ */ jsx(
277
+ BodyBoundary,
278
+ {
279
+ table,
280
+ resetKey: rowModel,
281
+ fallback: (retry) => stateRow(span, "error", /* @__PURE__ */ jsx(ErrorState, { status, reason: "render", retry })),
282
+ children: body
283
+ }
284
+ ) })
285
+ ] }),
286
+ paged && /* @__PURE__ */ jsx(
287
+ Pager,
288
+ {
289
+ pageIndex: state.pagination.pageIndex,
290
+ pageSize: state.pagination.pageSize,
291
+ pageCount: view.getPageCount?.() ?? 0,
292
+ canPrev: view.canPrevPage?.() ?? false,
293
+ canNext: view.canNextPage?.() ?? false,
294
+ prev: () => view.prevPage?.(),
295
+ next: () => view.nextPage?.(),
296
+ setPageIndex: (i) => view.setPageIndex?.(i),
297
+ setPageSize: (n) => view.setPageSize?.(n)
298
+ }
299
+ )
300
+ ]
301
+ }
302
+ );
303
+ }
304
+ function stateRow(span, kind, content) {
305
+ return /* @__PURE__ */ jsx("tr", { "data-dk-state": kind, children: /* @__PURE__ */ jsx("td", { colSpan: span, children: content }) });
306
+ }
307
+ var BodyBoundary = class extends Component {
308
+ constructor() {
309
+ super(...arguments);
310
+ this.state = { failed: false, key: this.props.resetKey };
311
+ this.retry = () => this.setState({ failed: false });
312
+ }
313
+ static getDerivedStateFromError() {
314
+ return { failed: true };
315
+ }
316
+ static getDerivedStateFromProps(props, state) {
317
+ return props.resetKey === state.key ? null : { failed: false, key: props.resetKey };
318
+ }
319
+ componentDidCatch(error) {
320
+ try {
321
+ emitTableDiagnostic(
322
+ this.props.table,
323
+ "DK_RENDER_FAILED",
324
+ { op: "render:table", ...error instanceof Error ? { errorName: error.name } : {} },
325
+ { cause: error }
326
+ );
327
+ } catch {
328
+ }
329
+ }
330
+ render() {
331
+ return this.state.failed ? this.props.fallback(this.retry) : this.props.children;
332
+ }
333
+ };
334
+ var CellBoundary = class extends Component {
335
+ constructor() {
336
+ super(...arguments);
337
+ this.state = {
338
+ failed: false,
339
+ original: this.props.original,
340
+ def: this.props.col.def
341
+ };
342
+ }
343
+ static getDerivedStateFromError() {
344
+ return { failed: true };
345
+ }
346
+ static getDerivedStateFromProps(props, state) {
347
+ return props.original === state.original && props.col.def === state.def ? null : { failed: false, original: props.original, def: props.col.def };
348
+ }
349
+ componentDidCatch(error) {
350
+ const { table, col, slot, row } = this.props;
351
+ try {
352
+ emitTableDiagnostic(
353
+ table,
354
+ "DK_RENDER_FAILED",
355
+ {
356
+ op: "render:cell",
357
+ slot: `columns[${col.index}].${slot}`,
358
+ column: col.id,
359
+ row,
360
+ ...error instanceof Error ? { errorName: error.name } : {}
361
+ },
362
+ { cause: error }
363
+ );
364
+ } catch {
365
+ }
366
+ }
367
+ render() {
368
+ return this.state.failed ? WARN : this.props.children;
369
+ }
370
+ };
371
+ function DefaultSearchInput({ value, status, onChange, onSubmit, onClear }) {
372
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
373
+ /* @__PURE__ */ jsx(
374
+ "input",
375
+ {
376
+ type: "search",
377
+ "aria-label": "Search",
378
+ value,
379
+ onChange: (e) => onChange(e.target.value),
380
+ onKeyDown: (e) => {
381
+ if (e.key === "Enter") onSubmit();
382
+ else if (e.key === "Escape") onClear();
383
+ }
384
+ }
385
+ ),
386
+ (status === "pending" || status === "searching") && /* @__PURE__ */ jsx("span", { role: "status", "data-dk-spinner": "", "aria-label": "Searching" })
387
+ ] });
388
+ }
389
+ function DefaultPagination(p) {
390
+ return /* @__PURE__ */ jsxs("nav", { "aria-label": "Pagination", "data-dk-pagination": "", children: [
391
+ /* @__PURE__ */ jsx("button", { type: "button", "aria-label": "Previous page", disabled: !p.canPrev, onClick: p.prev, children: "\u2039" }),
392
+ /* @__PURE__ */ jsxs("span", { "data-dk-page": "", children: [
393
+ "Page ",
394
+ p.pageIndex + 1,
395
+ " of ",
396
+ Math.max(p.pageCount, 1)
397
+ ] }),
398
+ /* @__PURE__ */ jsx("button", { type: "button", "aria-label": "Next page", disabled: !p.canNext, onClick: p.next, children: "\u203A" })
399
+ ] });
400
+ }
401
+ var DefaultEmpty = ({ filtered }) => /* @__PURE__ */ jsx(Fragment, { children: filtered ? "No matching rows" : "No rows" });
402
+ var DefaultLoading = (_) => /* @__PURE__ */ jsx("span", { role: "status", children: "Loading\u2026" });
403
+ function DefaultError({ reason, retry }) {
404
+ return /* @__PURE__ */ jsxs("div", { role: "alert", children: [
405
+ reason === "load" ? "Could not load the rows." : "Could not display the rows.",
406
+ " ",
407
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: retry, children: "Retry" })
408
+ ] });
409
+ }
410
+ function RefreshIndicator({ status, retry }) {
411
+ if (status === "error") {
412
+ return /* @__PURE__ */ jsxs("div", { "data-dk-refresh": "", "data-status": status, role: "alert", children: [
413
+ "Could not refresh; showing the previous rows.",
414
+ " ",
415
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: retry, children: "Retry" })
416
+ ] });
417
+ }
418
+ return /* @__PURE__ */ jsx("div", { "data-dk-refresh": "", "data-status": status, role: "status", children: "Updating\u2026" });
419
+ }
420
+ export {
421
+ DataTable
422
+ };
423
+ //# sourceMappingURL=data-table.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/data-table.tsx"],"sourcesContent":["'use client'\n\nimport {\n type AnyFeature,\n boundaryDiagnostics,\n defaultFormat,\n deriveColumns,\n describeReturn,\n emitTableDiagnostic,\n type InvalidRowsMode,\n keepDiagnostics,\n matchesSlot,\n type RowIssue,\n type RowModelStatus,\n type SearchStatus,\n slotDiagnostics,\n type TableSchema,\n type TableState,\n} from '@datakable/core'\nimport {\n Component,\n type ComponentType,\n type ReactNode,\n useEffect,\n useLayoutEffect,\n useMemo,\n} from 'react'\nimport {\n cellSlot,\n invalidCellSlot,\n registerRenderOperations,\n renderDiagnostics,\n} from './render-codes'\nimport { type UseDataTableOptions, useDataTable } from './use-data-table'\n\n// The codes this module emits (bundlers keep the definitions; see core's `keepDiagnostics`).\nkeepDiagnostics(renderDiagnostics, boundaryDiagnostics, slotDiagnostics)\n\n// The ops its boundaries stand for (§3.4: `render:table`, `render:cell`). Registered at import:\n// the dist is one file per module (T37), so hook-only bundles (`useDataTable` without\n// `<DataTable />`) never include this module, and this call ships only with `<DataTable />`.\nregisterRenderOperations()\n\n// No @types/node here: declare just what is read.\ndeclare const process: { env: { NODE_ENV?: string } }\n\n/** No layout effects on the server (React 18 warns about them there). */\nconst useIsomorphicLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect\n\n// --- public types --------------------------------------------------------------------------------\n\n/** Props of `components.SearchInput`: the search feature's `input`, bound both ways. */\nexport interface SearchInputProps {\n /** `state.search.input` (updates as the user types). */\n value: string\n /** `state.search.status`: `pending` while a debounce waits, `searching` while a request runs. */\n status: SearchStatus\n /** `setSearch(value)`. */\n onChange(value: string): void\n /** `flushSearch()` (Enter). */\n onSubmit(): void\n /** `clearSearch()` (Esc). */\n onClear(): void\n}\n\n/** Props of `components.Pagination` (the pagination feature's state and API). */\nexport interface PaginationProps {\n pageIndex: number\n pageSize: number\n pageCount: number\n canPrev: boolean\n canNext: boolean\n prev(): void\n next(): void\n setPageIndex(index: number): void\n setPageSize(size: number): void\n}\n\n/** Props of `components.Empty`: shown when the table has loaded and has no rows to show. */\nexport interface EmptyProps {\n /** `true` when there is data but filters / search removed every row. */\n filtered: boolean\n}\n\n/** Props of `components.Loading`: the first load (`isInitialLoad`, nothing to show yet). */\nexport interface LoadingProps {\n status: RowModelStatus\n}\n\n/** Props of `components.Error`: the first load failed, or the body failed to render. */\nexport interface ErrorProps {\n status: RowModelStatus\n /**\n * `'load'`: `status === 'error'` on the first load. `'render'`: a component in the body outside\n * the cells threw (a component inside a cell renders `⚠` in that cell only).\n */\n reason: 'load' | 'render'\n /** `'load'`: `refetch()`. `'render'`: renders the body again. */\n retry(): void\n}\n\n/** `<DataTable components={...} />`: replaces the default parts (unstyled, `data-*` hooks only). */\nexport interface DataTableComponents {\n SearchInput?: ComponentType<SearchInputProps>\n Pagination?: ComponentType<PaginationProps>\n Empty?: ComponentType<EmptyProps>\n Loading?: ComponentType<LoadingProps>\n Error?: ComponentType<ErrorProps>\n}\n\n/** What `<DataTable table={...} />` reads: the value `useDataTable` returns. */\nexport interface DataTableSource {\n readonly state: TableState\n readonly rowModel: {\n readonly rows: readonly DataTableRow[]\n readonly filteredCount: number\n readonly totalCount: number\n readonly status: RowModelStatus\n readonly isInitialLoad: boolean\n }\n getOptions(): { readonly columns?: readonly unknown[] | undefined }\n getData(): readonly unknown[]\n refetch(): Promise<unknown>\n}\n\n/** The part of a `Row` (§6.6) `<DataTable />` renders from. */\ninterface DataTableRow {\n readonly key: string | number\n readonly index: number\n readonly original: unknown\n readonly valid: boolean\n readonly issues: readonly RowIssue[]\n getValue(id: string): unknown\n getCellIssues(id: string): readonly RowIssue[]\n}\n\n/** `<DataTable />`'s own props, next to `table` or the `useDataTable` options. */\nexport interface DataTableOwnProps {\n components?: DataTableComponents | undefined\n caption?: ReactNode\n}\n\n/**\n * `<DataTable table={useDataTable(...)} />`, or `<DataTable data={rows} />` with the\n * `useDataTable` options as props (zero-config: columns derived from the data).\n */\nexport type DataTableProps<\n T = unknown,\n Sch = undefined,\n M extends InvalidRowsMode = InvalidRowsMode,\n> = DataTableOwnProps &\n (\n | { table: DataTableSource }\n | (UseDataTableOptions<T, TableState, Sch, M> & {\n features?: readonly AnyFeature[]\n table?: undefined\n })\n )\n\n// --- component -----------------------------------------------------------------------------------\n\n/**\n * The zero-config table (§10). Renders what the installed features provide: sort buttons with\n * `aria-sort`, a search input bound to `input` (Enter = `flushSearch`, Esc = `clearSearch`),\n * pagination, and the Loading / Error / Empty states from `status` + `isInitialLoad` (§6.6).\n * Unstyled: style it through the `data-*` hooks (`data-status`, `data-initial-load`,\n * `data-invalid`, `data-sort`, …) or replace parts with `components`.\n *\n * `@datakable/react`'s `DataTable` installs no features with `data`; `datakable`'s installs the\n * default preset.\n */\nexport function DataTable<\n T,\n const Sch extends TableSchema | undefined = undefined,\n const M extends InvalidRowsMode = 'drop',\n>(props: DataTableProps<T, Sch, M>): ReactNode\nexport function DataTable(\n props: DataTableOwnProps & { table?: DataTableSource | undefined },\n): ReactNode {\n if (props.table !== undefined) {\n return (\n <DataTableView table={props.table} components={props.components} caption={props.caption} />\n )\n }\n return <ZeroConfig {...(props as DataTableOwnProps & { table?: undefined })} />\n}\n\nfunction ZeroConfig(props: DataTableOwnProps & { table?: undefined }) {\n const { components, caption, table: _, ...options } = props\n const view = useDataTable(options as never) as unknown as DataTableSource\n return <DataTableView table={view} components={components} caption={caption} />\n}\n\n/** Loose access to the installed features' APIs (the table is typed per feature set). */\ntype Api = DataTableSource & {\n toggleSort?(id: string, opts?: { multi?: boolean }): void\n getSortDirection?(id: string): 'asc' | 'desc' | false\n setSearch?(q: string): Promise<unknown>\n flushSearch?(): Promise<unknown>\n clearSearch?(): void\n setPageIndex?(i: number): void\n setPageSize?(n: number): void\n nextPage?(): void\n prevPage?(): void\n getPageCount?(): number\n canNextPage?(): boolean\n canPrevPage?(): boolean\n}\n\n/** The column fields `<DataTable />` reads (types are checked where the columns are written). */\ninterface ColumnLike {\n key?: unknown\n id?: unknown\n header?: unknown\n sortable?: unknown\n cell?: (ctx: { row: unknown; value: unknown }) => ReactNode\n format?: (value: unknown) => unknown\n invalidCell?: (ctx: {\n original: unknown\n value: unknown\n issues: readonly RowIssue[]\n }) => ReactNode\n}\n\ninterface Column {\n readonly def: ColumnLike\n readonly index: number\n readonly id: string\n readonly header: ReactNode\n}\n\n/** A cell callback that threw or broke its contract during this render (reported after commit). */\ninterface Failure {\n slot: string\n column: string\n row: number\n error?: unknown\n /** Bad return: what the contract expects and the type received. */\n expected?: string\n received?: string\n}\n\nconst WARN = '⚠'\nconst BUSY: readonly RowModelStatus[] = ['validating', 'pending', 'searching', 'fetching']\nconst LOADING: readonly RowModelStatus[] = ['validating', 'searching', 'fetching']\n\n/**\n * The table loads its rows asynchronously: a `fetcher`, or a feature with a `searchFn` (its\n * `defineOptions` values). With nothing applied yet, its `'pending'` is a load waiting to start\n * (deferred until the client, §7.2), so `<DataTable />` shows Loading — also in the server HTML.\n */\nfunction hasAsyncSource(table: DataTableSource): boolean {\n const options = table.getOptions() as { fetcher?: unknown; features?: unknown }\n if (typeof options.fetcher === 'function') return true\n if (!Array.isArray(options.features)) return false\n for (const f of options.features as readonly {\n options?: { values?: { searchFn?: unknown } }\n }[]) {\n if (typeof f?.options?.values?.searchFn === 'function') return true\n }\n return false\n}\n\nfunction resolveColumns(defs: readonly unknown[]): Column[] {\n const out: Column[] = []\n for (let index = 0; index < defs.length; index++) {\n const def = defs[index] as ColumnLike | null | undefined\n if (def === null || typeof def !== 'object') continue\n const id = typeof def.key === 'string' ? def.key : def.id\n if (typeof id !== 'string') continue\n out.push({ def, index, id, header: typeof def.header === 'string' ? def.header : id })\n }\n return out\n}\n\nconst segment = (s: PropertyKey | { readonly key: PropertyKey }) =>\n String(typeof s === 'object' ? s.key : s)\n\n/**\n * The redacted issue text for `title` (§5.1): the issue paths only. Schema messages embed the\n * received value, so they are never shown.\n */\nfunction issueTitle(issues: readonly RowIssue[]): string {\n const paths = new Set<string>()\n for (const i of issues) paths.add(i.path?.length ? i.path.map(segment).join('.') : '(row)')\n return `Invalid: ${[...paths].join(', ')}`\n}\n\n/** The table behind a `useDataTable` view (its prototype), for reporting diagnostics. */\nconst tableOf = (view: object): object =>\n Object.hasOwn(view, 'rowModel') ? (Object.getPrototypeOf(view) as object) : view\n\nfunction report(table: object, failures: readonly Failure[]) {\n const bySlot = new Map<string, Failure[]>()\n for (const f of failures) {\n const k = `${f.slot}\\0${f.expected === undefined ? 'throw' : 'return'}`\n const list = bySlot.get(k)\n if (list) list.push(f)\n else bySlot.set(k, [f])\n }\n for (const list of bySlot.values()) {\n const first = list[0] as Failure\n const rows = list.slice(0, 3).map((f) => f.row)\n const fallback = 'those cells rendered ⚠'\n try {\n if (first.expected === undefined) {\n const e = first.error\n emitTableDiagnostic(\n table,\n 'DK_CALLBACK_FAILED',\n {\n slot: first.slot,\n column: first.column,\n rows,\n count: list.length,\n fallback,\n ...(e instanceof Error ? { errorName: e.name } : {}),\n },\n { cause: e },\n )\n } else if (process.env.NODE_ENV !== 'production') {\n emitTableDiagnostic(table, 'DK_CALLBACK_BAD_RETURN', {\n slot: first.slot,\n column: first.column,\n expected: first.expected,\n received: first.received ?? 'undefined',\n count: list.length,\n rows,\n fallback,\n })\n }\n } catch {\n // Not a table made by createTable (a hand-made `table` prop): nothing to report to.\n }\n }\n}\n\n/**\n * Renders one cell's content; a throwing or contract-breaking callback renders `⚠`. An object\n * returned by `cell` / `invalidCell` (an element, an array) may hold components that throw while\n * React renders them, so it gets its own boundary; primitives cannot, so they get none (no cost).\n */\nfunction cellContent(\n col: Column,\n row: DataTableRow,\n failures: Failure[],\n table: object,\n): ReactNode {\n const def = col.def\n const value = row.getValue(col.id)\n const issues = row.valid ? undefined : row.getCellIssues(col.id)\n let slot = 'cell'\n try {\n if (issues !== undefined && issues.length > 0) {\n if (def.invalidCell) {\n slot = 'invalidCell'\n const out = def.invalidCell({ original: row.original, value, issues })\n if (matchesSlot(invalidCellSlot, out)) return guard(out, table, col, row, 'invalidCell')\n return bad(failures, col, row, slot, 'a value (not a Promise)', out)\n }\n return (\n <>\n {defaultFormat(value)}{' '}\n <span data-dk-invalid-marker=\"\" aria-hidden=\"true\">\n {WARN}\n </span>\n </>\n )\n }\n if (def.cell) {\n const out = def.cell({ row: row.original, value })\n if (matchesSlot(cellSlot, out)) return guard(out, table, col, row, 'cell')\n return bad(failures, col, row, slot, 'a value (not a Promise)', out)\n }\n if (def.format) {\n slot = 'format'\n const out = def.format(value)\n if (typeof out === 'string') return out\n bad(failures, col, row, slot, 'a string', out)\n return defaultFormat(value)\n }\n return defaultFormat(value)\n } catch (error) {\n failures.push({ slot: `columns[${col.index}].${slot}`, column: col.id, row: row.index, error })\n return WARN\n }\n}\n\n/** Wraps object content in a per-cell boundary (`render:cell`); primitives pass through as-is. */\nfunction guard(\n out: ReactNode,\n table: object,\n col: Column,\n row: DataTableRow,\n slot: 'cell' | 'invalidCell',\n): ReactNode {\n if (typeof out !== 'object' || out === null) return out\n return (\n <CellBoundary table={table} col={col} slot={slot} row={row.index} original={row.original}>\n {out}\n </CellBoundary>\n )\n}\n\nfunction bad(\n failures: Failure[],\n col: Column,\n row: DataTableRow,\n slot: string,\n expected: string,\n out: unknown,\n): ReactNode {\n failures.push({\n slot: `columns[${col.index}].${slot}`,\n column: col.id,\n row: row.index,\n expected,\n received: describeReturn(out),\n })\n return WARN\n}\n\nconst ariaSort = (dir: 'asc' | 'desc' | false) =>\n dir === 'asc' ? 'ascending' : dir === 'desc' ? 'descending' : 'none'\n\nfunction DataTableView(props: {\n table: DataTableSource\n components: DataTableComponents | undefined\n caption: ReactNode\n}) {\n const view = props.table as Api\n const parts = props.components ?? {}\n const { state, rowModel } = view\n const { rows, status, isInitialLoad } = rowModel\n const defs = view.getOptions().columns\n const data = view.getData()\n // Zero-config columns follow the data; given columns follow their reference (§10).\n const derivedFrom = defs === undefined ? data : undefined\n const columns = useMemo(\n () => resolveColumns(defs ?? (derivedFrom ? deriveColumns(derivedFrom) : [])),\n [defs, derivedFrom],\n )\n const failures: Failure[] = []\n const table = tableOf(view)\n // After commit, never during render: a sink may set state.\n useIsomorphicLayoutEffect(() => {\n if (failures.length > 0) report(table, failures)\n })\n\n const sortable = typeof view.toggleSort === 'function'\n const searchState = state.search as { input: string; status: SearchStatus } | undefined\n const paged = typeof view.getPageCount === 'function'\n // Loading (§6.6, §10): nothing to show yet and rows on their way — in flight, or deferred async\n // work that has not started (SSR, §7.2: 'pending').\n const loading =\n isInitialLoad && (LOADING.includes(status) || (status === 'pending' && hasAsyncSource(view)))\n const failed = isInitialLoad && status === 'error'\n const span = Math.max(columns.length, 1)\n const retryLoad = () => void view.refetch()\n\n const Search = parts.SearchInput ?? DefaultSearchInput\n const Pager = parts.Pagination ?? DefaultPagination\n const Empty = parts.Empty ?? DefaultEmpty\n const Loading = parts.Loading ?? DefaultLoading\n const ErrorState = parts.Error ?? DefaultError\n\n let body: ReactNode\n if (loading) {\n body = stateRow(span, 'loading', <Loading status={status} />)\n } else if (failed) {\n body = stateRow(span, 'error', <ErrorState status={status} reason=\"load\" retry={retryLoad} />)\n } else if (rows.length === 0) {\n body = stateRow(span, 'empty', <Empty filtered={rowModel.totalCount > 0} />)\n } else {\n body = rows.map((row) => {\n const valid = row.valid\n return (\n <tr\n key={row.key}\n data-invalid={valid ? undefined : 'true'}\n aria-invalid={valid ? undefined : 'true'}\n title={valid ? undefined : issueTitle(row.issues)}\n >\n {columns.map((col) => {\n const issues = valid ? undefined : row.getCellIssues(col.id)\n const broken = issues !== undefined && issues.length > 0\n return (\n <td\n key={col.index}\n data-invalid={broken ? 'true' : undefined}\n aria-invalid={broken ? 'true' : undefined}\n title={broken ? issueTitle(issues) : undefined}\n >\n {cellContent(col, row, failures, table)}\n </td>\n )\n })}\n </tr>\n )\n })\n }\n\n return (\n <div\n data-datakable=\"\"\n data-status={status}\n data-initial-load={isInitialLoad ? 'true' : 'false'}\n aria-busy={BUSY.includes(status) ? 'true' : undefined}\n >\n {searchState && (\n <div data-dk-search=\"\" data-status={searchState.status}>\n <Search\n value={searchState.input}\n status={searchState.status}\n onChange={(q) => void view.setSearch?.(q)}\n onSubmit={() => void view.flushSearch?.()}\n onClear={() => view.clearSearch?.()}\n />\n </div>\n )}\n {!loading && !failed && status !== 'idle' && (\n <RefreshIndicator status={status} retry={retryLoad} />\n )}\n <table>\n {props.caption != null && <caption>{props.caption}</caption>}\n <thead>\n <tr>\n {columns.map((col) => {\n const canSort = sortable && col.def.sortable !== false\n const dir = canSort ? (view.getSortDirection?.(col.id) ?? false) : false\n return (\n <th\n key={col.index}\n scope=\"col\"\n aria-sort={canSort ? ariaSort(dir) : undefined}\n data-sort={dir || undefined}\n >\n {canSort ? (\n <button\n type=\"button\"\n onClick={(e) => view.toggleSort?.(col.id, { multi: e.shiftKey })}\n >\n {col.header}\n <span data-dk-sort-indicator=\"\" aria-hidden=\"true\">\n {dir === 'asc' ? ' ▲' : dir === 'desc' ? ' ▼' : ''}\n </span>\n </button>\n ) : (\n col.header\n )}\n </th>\n )\n })}\n </tr>\n </thead>\n <tbody>\n <BodyBoundary\n table={table}\n resetKey={rowModel}\n fallback={(retry) =>\n stateRow(span, 'error', <ErrorState status={status} reason=\"render\" retry={retry} />)\n }\n >\n {body}\n </BodyBoundary>\n </tbody>\n </table>\n {paged && (\n <Pager\n pageIndex={(state.pagination as { pageIndex: number }).pageIndex}\n pageSize={(state.pagination as { pageSize: number }).pageSize}\n pageCount={view.getPageCount?.() ?? 0}\n canPrev={view.canPrevPage?.() ?? false}\n canNext={view.canNextPage?.() ?? false}\n prev={() => view.prevPage?.()}\n next={() => view.nextPage?.()}\n setPageIndex={(i) => view.setPageIndex?.(i)}\n setPageSize={(n) => view.setPageSize?.(n)}\n />\n )}\n </div>\n )\n}\n\nfunction stateRow(span: number, kind: string, content: ReactNode) {\n return (\n <tr data-dk-state={kind}>\n <td colSpan={span}>{content}</td>\n </tr>\n )\n}\n\n// --- error boundaries (DK_RENDER_FAILED) ---------------------------------------------------------\n\ninterface BoundaryProps {\n table: object\n /** A new value (the next row model) renders the body again. */\n resetKey: unknown\n fallback(retry: () => void): ReactNode\n children: ReactNode\n}\n\n/**\n * Catches a component that throws inside the body outside any cell boundary (§10: a\n * `components.Empty` / `Loading` / `Error` part): reports `DK_RENDER_FAILED` (`render:table`) and\n * shows the Error state; the header, search and pagination keep working.\n */\nclass BodyBoundary extends Component<BoundaryProps, { failed: boolean; key: unknown }> {\n override state = { failed: false, key: this.props.resetKey }\n\n static getDerivedStateFromError() {\n return { failed: true }\n }\n\n static getDerivedStateFromProps(props: BoundaryProps, state: { key: unknown }) {\n return props.resetKey === state.key ? null : { failed: false, key: props.resetKey }\n }\n\n override componentDidCatch(error: unknown) {\n try {\n emitTableDiagnostic(\n this.props.table,\n 'DK_RENDER_FAILED',\n { op: 'render:table', ...(error instanceof Error ? { errorName: error.name } : {}) },\n { cause: error },\n )\n } catch {\n // Not a table made by createTable: nothing to report to.\n }\n }\n\n retry = () => this.setState({ failed: false })\n\n override render() {\n return this.state.failed ? this.props.fallback(this.retry) : this.props.children\n }\n}\n\ninterface CellBoundaryProps {\n table: object\n col: Column\n slot: 'cell' | 'invalidCell'\n /** The row's index in the data (`row.index`). */\n row: number\n /** The row's data: a new object (or new columns) renders a failed cell again. */\n original: unknown\n children: ReactNode\n}\n\ninterface CellBoundaryState {\n failed: boolean\n original: unknown\n def: ColumnLike\n}\n\n/**\n * One cell's boundary (`render:cell`, §3.4): a component returned by `cell` / `invalidCell` that\n * throws renders `⚠` in that cell only and reports `DK_RENDER_FAILED` (deduped per column); the\n * other cells, rows and the table keep working. Only wraps object content (see `guard`).\n */\nclass CellBoundary extends Component<CellBoundaryProps, CellBoundaryState> {\n override state: CellBoundaryState = {\n failed: false,\n original: this.props.original,\n def: this.props.col.def,\n }\n\n static getDerivedStateFromError() {\n return { failed: true }\n }\n\n static getDerivedStateFromProps(props: CellBoundaryProps, state: CellBoundaryState) {\n return props.original === state.original && props.col.def === state.def\n ? null\n : { failed: false, original: props.original, def: props.col.def }\n }\n\n override componentDidCatch(error: unknown) {\n const { table, col, slot, row } = this.props\n try {\n emitTableDiagnostic(\n table,\n 'DK_RENDER_FAILED',\n {\n op: 'render:cell',\n slot: `columns[${col.index}].${slot}`,\n column: col.id,\n row,\n ...(error instanceof Error ? { errorName: error.name } : {}),\n },\n { cause: error },\n )\n } catch {\n // Not a table made by createTable: nothing to report to.\n }\n }\n\n override render() {\n return this.state.failed ? WARN : this.props.children\n }\n}\n\n// --- default parts (unstyled) --------------------------------------------------------------------\n\nfunction DefaultSearchInput({ value, status, onChange, onSubmit, onClear }: SearchInputProps) {\n return (\n <>\n <input\n type=\"search\"\n aria-label=\"Search\"\n value={value}\n onChange={(e) => onChange(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === 'Enter') onSubmit()\n else if (e.key === 'Escape') onClear()\n }}\n />\n {(status === 'pending' || status === 'searching') && (\n <span role=\"status\" data-dk-spinner=\"\" aria-label=\"Searching\" />\n )}\n </>\n )\n}\n\nfunction DefaultPagination(p: PaginationProps) {\n return (\n <nav aria-label=\"Pagination\" data-dk-pagination=\"\">\n <button type=\"button\" aria-label=\"Previous page\" disabled={!p.canPrev} onClick={p.prev}>\n ‹\n </button>\n <span data-dk-page=\"\">\n Page {p.pageIndex + 1} of {Math.max(p.pageCount, 1)}\n </span>\n <button type=\"button\" aria-label=\"Next page\" disabled={!p.canNext} onClick={p.next}>\n ›\n </button>\n </nav>\n )\n}\n\nconst DefaultEmpty = ({ filtered }: EmptyProps) => <>{filtered ? 'No matching rows' : 'No rows'}</>\n\nconst DefaultLoading = (_: LoadingProps) => <span role=\"status\">Loading…</span>\n\nfunction DefaultError({ reason, retry }: ErrorProps) {\n return (\n <div role=\"alert\">\n {reason === 'load' ? 'Could not load the rows.' : 'Could not display the rows.'}{' '}\n <button type=\"button\" onClick={retry}>\n Retry\n </button>\n </div>\n )\n}\n\n/** Over stale rows (§6.6): the table is busy, or a later update failed. */\nfunction RefreshIndicator({ status, retry }: { status: RowModelStatus; retry(): void }) {\n if (status === 'error') {\n return (\n <div data-dk-refresh=\"\" data-status={status} role=\"alert\">\n Could not refresh; showing the previous rows.{' '}\n <button type=\"button\" onClick={retry}>\n Retry\n </button>\n </div>\n )\n }\n return (\n <div data-dk-refresh=\"\" data-status={status} role=\"status\">\n Updating…\n </div>\n )\n}\n"],"mappings":";;;AAEA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EAIA;AAAA,OAGK;AACP;AAAA,EACE;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAmC,oBAAoB;AAoJjD,SAoLE,UApLF,KAoLE,YApLF;AAjJN,gBAAgB,mBAAmB,qBAAqB,e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;AAExE,SAAS,aAAa,EAAE,QAAQ,MAAM,GAAe;AACnD,SACE,qBAAC,SAAI,MAAK,SACP;AAAA,eAAW,SAAS,6BAA6B;AAAA,IAA+B;AAAA,IACjF,oBAAC,YAAO,MAAK,UAAS,SAAS,OAAO,mBAEtC;AAAA,KACF;AAEJ;AAGA,SAAS,iBAAiB,EAAE,QAAQ,MAAM,GAA8C;AACtF,MAAI,WAAW,SAAS;AACtB,WACE,qBAAC,SAAI,mBAAgB,IAAG,eAAa,QAAQ,MAAK,SAAQ;AAAA;AAAA,MACV;AAAA,MAC9C,oBAAC,YAAO,MAAK,UAAS,SAAS,OAAO,mBAEtC;AAAA,OACF;AAAA,EAEJ;AACA,SACE,oBAAC,SAAI,mBAAgB,IAAG,eAAa,QAAQ,MAAK,UAAS,4BAE3D;AAEJ;","names":[]}
package/dist/index.cjs ADDED
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/index.ts
22
+ var index_exports = {};
23
+ __export(index_exports, {
24
+ DataTable: () => import_data_table.DataTable,
25
+ cellSlot: () => import_render_codes.cellSlot,
26
+ invalidCellSlot: () => import_render_codes.invalidCellSlot,
27
+ reactDiagnostics: () => import_codes.reactDiagnostics,
28
+ renderDiagnostics: () => import_render_codes.renderDiagnostics,
29
+ renderMessages: () => import_render_codes.renderMessages,
30
+ useDataTable: () => import_use_data_table.useDataTable
31
+ });
32
+ module.exports = __toCommonJS(index_exports);
33
+ __reExport(index_exports, require("@datakable/core"), module.exports);
34
+ var import_codes = require("./codes.cjs");
35
+ var import_data_table = require("./data-table.cjs");
36
+ var import_render_codes = require("./render-codes.cjs");
37
+ var import_use_data_table = require("./use-data-table.cjs");
38
+ // Annotate the CommonJS export names for ESM import in node:
39
+ 0 && (module.exports = {
40
+ DataTable,
41
+ cellSlot,
42
+ invalidCellSlot,
43
+ reactDiagnostics,
44
+ renderDiagnostics,
45
+ renderMessages,
46
+ useDataTable,
47
+ ...require("@datakable/core")
48
+ });
49
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from '@datakable/core'\nexport { reactDiagnostics } from './codes'\nexport {\n DataTable,\n type DataTableComponents,\n type DataTableOwnProps,\n type DataTableProps,\n type DataTableSource,\n type EmptyProps,\n type ErrorProps,\n type LoadingProps,\n type PaginationProps,\n type SearchInputProps,\n} from './data-table'\nexport { cellSlot, invalidCellSlot, renderDiagnostics, renderMessages } from './render-codes'\nexport { type UseDataTableOptions, type UseDataTableResult, useDataTable } from './use-data-table'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAc,4BAAd;AACA,mBAAiC;AACjC,wBAWO;AACP,0BAA6E;AAC7E,4BAAgF;","names":[]}