@datakable/react 2.0.0 → 2.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.
package/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # @datakable/react
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/%40datakable%2Freact?color=cb3837&logo=npm)](https://www.npmjs.com/package/@datakable/react)
4
+ [![npm downloads](https://img.shields.io/npm/dm/%40datakable%2Freact?color=cb3837)](https://www.npmjs.com/package/@datakable/react)
5
+ [![types: TypeScript](https://img.shields.io/npm/types/%40datakable%2Freact?logo=typescript&logoColor=white)](https://www.npmjs.com/package/@datakable/react)
6
+ [![license: MIT](https://img.shields.io/npm/l/%40datakable%2Freact)](https://github.com/Ink01101011/datakable/blob/main/LICENSE)
7
+
3
8
  React bindings for DataKable: the `useDataTable` hook over the
4
9
  [`@datakable/core`](https://github.com/Ink01101011/datakable/tree/main/packages/core) table store. Most apps want
5
10
  [`datakable/react`](https://github.com/Ink01101011/datakable/tree/main/packages/datakable), whose `useDataTable` also installs the default feature
@@ -28,7 +28,7 @@ var import_core = require("@datakable/core");
28
28
  var import_react = require("react");
29
29
 
30
30
  // package.json
31
- var version = "2.0.0";
31
+ var version = "2.0.1";
32
32
 
33
33
  // src/use-data-table.ts
34
34
  var import_codes = require("./codes.cjs");
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/use-data-table.ts","../package.json"],"sourcesContent":["'use client'\n\nimport {\n type AnyFeature,\n type ApiOf,\n type ColumnDef,\n type CreateTableOptions,\n createDeferred,\n createTable,\n type Diagnostic,\n emitTableDiagnostic,\n type InvalidRowsMode,\n isOptionsDefinition,\n keepDiagnostics,\n type RowModel,\n registerPackage,\n type SchemaRow,\n SERVER_SOURCE,\n startTable,\n type Table,\n type TableSchema,\n type TableState,\n type TableStateFor,\n} from '@datakable/core'\nimport {\n type ReactNode,\n version as reactVersion,\n useCallback,\n useEffect,\n useInsertionEffect,\n useLayoutEffect,\n useReducer,\n useRef,\n useSyncExternalStore,\n} from 'react'\nimport { version } from '../package.json'\nimport { reactDiagnostics } from './codes'\n\n// Registers the (development-only) definitions where they are emitted, so bundlers keep them.\nkeepDiagnostics(reactDiagnostics)\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/**\n * `useDataTable` options: `createTable`'s (§3.2), with `cell` / `invalidCell` returning a\n * `ReactNode` (§10). Read once, at creation: `features`, `schema`, `invalidRows`, `initialState`,\n * `name`, `timeout`, `strict`, `diagnostics`. Every other option follows the latest render.\n */\nexport type UseDataTableOptions<\n T,\n S extends TableState = TableState,\n Sch = undefined,\n M extends InvalidRowsMode = 'drop',\n> = Omit<CreateTableOptions<T, S, Sch, M>, 'columns'> & {\n /**\n * Compared by reference (§10): a new array tells the table the columns changed. Define them\n * outside the component or memoise them (`DK_UNSTABLE_COLUMNS` in development).\n */\n columns?: readonly ColumnDef<SchemaRow<T, Sch>, ReactNode>[]\n}\n\n/**\n * What `useDataTable` returns: the table (its methods and the installed features' APIs) with the\n * `state` and `rowModel` of this render. A new object whenever the table notifies, so it can be a\n * dependency of `useMemo` / `memo` children; the same object while nothing changed.\n */\nexport type UseDataTableResult<\n T,\n S extends TableState = TableState,\n M extends InvalidRowsMode = 'drop',\n In = T,\n Api = unknown,\n> = Table<T, S, M, In> &\n Api & {\n /** The state snapshot of this render (`getState()`). */\n readonly state: S\n /** The row model of this render (`getRowModel()`, §6.6): rows, counts, status. */\n readonly rowModel: RowModel<T, M>\n }\n\ntype Options = Record<string, unknown> & { features?: readonly AnyFeature[] }\ntype AnyTable = Table<unknown, TableState> & Record<string, unknown>\ntype Callback = (arg: never) => unknown\n\n/** Options forwarded through `setOptions` when they change; the rest are read once (§3.4). */\nconst SYNCED = [\n 'data',\n 'columns',\n 'rowKey',\n 'state',\n 'onStateChange',\n 'interceptors',\n 'onDiagnostic',\n 'fetcher',\n 'rowCount',\n] as const\n\n/** Given to the table as stable wrappers that call the latest prop (latest-ref). */\nconst CALLBACKS = ['onStateChange', 'onDiagnostic', 'fetcher'] as const\ntype CallbackKey = (typeof CALLBACKS)[number]\n\n/** Renders in a row with a new reference before `DK_UNSTABLE_*` is reported. */\nconst UNSTABLE_AFTER = 2\n\ninterface Instance {\n table: AnyTable\n destroyed: boolean\n mounted: boolean\n /** The options of the latest committed render (what the wrappers call). */\n latest: Options\n /** The option values the table has (user values; callbacks count by presence). */\n synced: Options\n readonly wrappers: Record<CallbackKey, Callback>\n /** `onDiagnostic` calls made while rendering, delivered after the commit. */\n queue: Diagnostic[] | undefined\n rendering: number\n /** Inside the hook's own `setOptions` call. */\n syncing: boolean\n /** That call notified: the next commit is the re-render it caused. */\n selfCaused: boolean\n /**\n * `data` was forwarded in a self-caused re-render. Rows that differ on every render (nested\n * objects, computed fields) would otherwise ingest → notify → re-render forever: the next\n * self-caused re-render keeps the data the table has.\n */\n selfData: boolean\n /** Notifications seen; part of the view cache key (a notification is never silent, §6.6). */\n version: number\n view: { table: AnyTable; version: number; value: object } | undefined\n /**\n * SSR (§7.2): the view of `table` at its creation — initial state, controlled state and data /\n * initialData, no async result (the table is created deferred). `getServerSnapshot`.\n */\n server: { table: AnyTable; value: object } | undefined\n /** React read `getServerSnapshot` on the client: this render hydrates server HTML. */\n hydrating: boolean\n // Dev: DK_UNSTABLE_* bookkeeping.\n /** The options of the previous committed render. */\n seen: Options\n /** Development only (`checkUnstable`). */\n unstable?: Map<string, number>\n warned?: Set<string>\n}\n\nlet registered = false\n\n/**\n * Binds a table to a component (§10): the table is created once per component instance and\n * destroyed on unmount; renders read it through `useSyncExternalStore` (with\n * `getServerSnapshot`), and options are synced with `table.setOptions` in a layout effect, never\n * during render.\n *\n * - `features` (and the other read-once options) are read at creation: a new inline `features`\n * array never recreates the table.\n * - `fetcher`, `onStateChange` and `onDiagnostic` may be inline functions: the table always calls\n * the latest one, and a new reference never refetches (call `refetch()` when a value the fetcher\n * reads changes).\n * - `columns`, `data` and a `rowKey` function are compared by reference: memoise them.\n * - Controlled slices (§3.2): pass `state` and `onStateChange`; changes come back through `state`.\n * - SSR (§7.2): rendering starts no async work. The fetcher's first request and a `searchFn` for an\n * initial query start after the commit (`status: 'pending'` until then; `DK_SSR_ASYNC_DEFERRED`\n * on the server), unless `initialData` already holds their result. `initialState` (e.g. parsed\n * from the URL) applies on the server: client-mode features filter / search / sort the HTML.\n * `getServerSnapshot` is the view at creation; a table that changed before the hydration commit\n * reports `DK_HYDRATION_MISMATCH`.\n *\n * `@datakable/react` installs no features by default; `datakable`'s `useDataTable` installs the\n * default preset.\n */\nexport function useDataTable<\n T,\n S extends TableState = never,\n const Fs extends readonly AnyFeature[] = [],\n const Sch extends TableSchema | undefined = undefined,\n const M extends InvalidRowsMode = 'drop',\n>(\n options: UseDataTableOptions<T, TableStateFor<S, Fs, SchemaRow<T, Sch>>, Sch, M> & {\n features?: Fs\n },\n): UseDataTableResult<\n SchemaRow<T, Sch>,\n TableStateFor<S, Fs, SchemaRow<T, Sch>>,\n M,\n [Sch] extends [TableSchema] ? unknown : T,\n ApiOf<Fs, SchemaRow<T, Sch>>\n>\nexport function useDataTable(options: Options): unknown {\n const ref = useRef<Instance | null>(null)\n // Created during the first render, deferred: its async work (fetcher, searchFn) starts in the\n // mount effect, never on the server.\n if (ref.current === null) {\n ref.current = createInstance(options)\n // React 18's development StrictMode discards the first mount render, ref included (React 19\n // keeps it): that render's table never mounts, so release it once the render is over. A\n // render that commits after this (one that yielded) gets a new table at mount (`recreate`).\n if (\n process.env.NODE_ENV !== 'production' &&\n typeof window !== 'undefined' &&\n reactVersion.startsWith('18.')\n ) {\n const inst = ref.current\n queueMicrotask(() => release(inst))\n }\n }\n const inst = ref.current\n const table = inst.table\n const [, rerender] = useReducer((n: number) => n + 1, 0)\n\n const subscribe = useCallback(\n (onChange: () => void) => {\n // Replaced or destroyed meanwhile (`<Activity>`): nothing to subscribe to.\n if (inst.table !== table || inst.destroyed) return () => {}\n return table.subscribe(() => {\n inst.version++\n if (inst.syncing) inst.selfCaused = true\n onChange()\n })\n },\n [inst, table],\n )\n const getSnapshot = useCallback(() => snapshot(inst, table), [inst, table])\n const getServerSnapshot = useCallback(() => serverSnapshot(inst, table), [inst, table])\n const view = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot)\n\n // Hydration commit (§7.2): before any layout effect can change the table, the snapshot React\n // hydrated with must still be the live one, else React replaces the server HTML at once.\n useInsertionEffect(() => checkHydration(inst), [inst])\n\n useIsomorphicLayoutEffect(() => {\n inst.mounted = true\n // Destroyed while hidden (`<Activity>`): a new table, from the latest options.\n if (inst.destroyed) {\n recreate(inst)\n startTable(inst.table)\n rerender()\n } else {\n // The deferred fetch / searchFn starts now; its status shows before paint.\n startTable(inst.table)\n if (snapshot(inst, inst.table) !== view) rerender()\n }\n return () => {\n inst.mounted = false\n // Deferred: the StrictMode effect re-run mounts again synchronously and keeps the table.\n queueMicrotask(() => {\n if (inst.mounted || inst.destroyed) return\n inst.destroyed = true\n inst.table.destroy()\n })\n }\n }, [inst])\n\n useIsomorphicLayoutEffect(() => {\n inst.latest = options\n const selfCaused = inst.selfCaused\n inst.selfCaused = false\n if (!inst.destroyed) sync(inst, options, selfCaused)\n deliver(inst)\n })\n\n return view\n}\n\n/** Dev (React 18): destroys a table created in render unless it mounted (or was destroyed). */\nfunction release(inst: Instance) {\n if (inst.mounted || inst.destroyed) return\n inst.destroyed = true\n inst.table.destroy()\n}\n\nfunction createInstance(options: Options): Instance {\n const inst: Instance = {\n table: undefined as unknown as AnyTable,\n destroyed: false,\n mounted: false,\n latest: options,\n synced: options,\n wrappers: {\n onStateChange: (updater) => (inst.latest.onStateChange as Callback)(updater),\n onDiagnostic: (d: Diagnostic) => {\n if (inst.rendering === 0) {\n ;(inst.latest.onDiagnostic as ((d: Diagnostic) => void) | undefined)?.(d)\n return\n }\n if (inst.queue === undefined) {\n inst.queue = []\n // Delivered by the next layout effect, or here when this render never commits.\n queueMicrotask(() => deliver(inst))\n }\n inst.queue.push(d)\n },\n fetcher: (params) => (inst.latest.fetcher as Callback)(params),\n },\n queue: undefined,\n rendering: 0,\n syncing: false,\n selfCaused: false,\n selfData: false,\n version: 0,\n view: undefined,\n server: undefined,\n hydrating: false,\n seen: options,\n // Development only (`checkUnstable`): no Map / Set per table in production.\n ...(process.env.NODE_ENV !== 'production' ? { unstable: new Map(), warned: new Set() } : {}),\n }\n // The version checks are development-only (§8.5): production bundles no registry.\n if (process.env.NODE_ENV !== 'production' && !registered) {\n registered = true\n registerPackage('@datakable/react', version)\n }\n build(inst, options)\n return inst\n}\n\n/**\n * The stable wrapper of callback `k`. The fetcher's also carries the server source of the user's\n * `withFetcher` fetcher (§7.1), which is what makes the table load through it.\n */\nfunction wrapper(inst: Instance, k: CallbackKey, v: unknown): Callback {\n const w = inst.wrappers[k]\n if (k === 'fetcher') {\n ;(w as unknown as Record<symbol, unknown>)[SERVER_SOURCE] = (v as Record<symbol, unknown>)[\n SERVER_SOURCE\n ]\n }\n return w\n}\n\nfunction build(inst: Instance, options: Options) {\n const init: Options = { ...options }\n for (const k of CALLBACKS) {\n if (typeof options[k] === 'function') init[k] = wrapper(inst, k, options[k])\n }\n inst.rendering++\n try {\n // Deferred (§7.2): rendering starts no fetch / searchFn (none at all on the server, where\n // effects never run); the mount effect starts it.\n inst.table = createDeferred(() => createTable(init as never)) as unknown as AnyTable\n } finally {\n inst.rendering--\n }\n inst.synced = options\n inst.seen = options\n inst.view = undefined\n inst.server = undefined\n}\n\nfunction recreate(inst: Instance) {\n build(inst, inst.latest)\n inst.destroyed = false\n}\n\n/** The view of the table's snapshot, cached on (table, state, row model, notifications). */\nfunction snapshot(inst: Instance, table: AnyTable): object {\n inst.rendering++\n try {\n const state = table.getState()\n const rowModel = table.getRowModel()\n const v = inst.view\n if (v && v.table === table && v.version === inst.version) {\n const value = v.value as { state: unknown; rowModel: unknown }\n if (value.state === state && value.rowModel === rowModel) return value\n }\n const value = Object.create(table, {\n state: { value: state, enumerable: true },\n rowModel: { value: rowModel, enumerable: true },\n }) as object\n inst.view = { table, version: inst.version, value }\n return value\n } finally {\n inst.rendering--\n }\n}\n\n/**\n * `getServerSnapshot` (§7.2): the view of the table at its creation. React reads it on the server\n * and while hydrating, so both render the same snapshot; async work never ran in it.\n */\nfunction serverSnapshot(inst: Instance, table: AnyTable): object {\n if (inst.table !== table) return snapshot(inst, table)\n // On the client React reads it only to hydrate.\n if (typeof window !== 'undefined') inst.hydrating = true\n const s = inst.server\n if (s && s.table === table) return s.value\n const value = snapshot(inst, table)\n inst.server = { table, value }\n return value\n}\n\n/** `DK_HYDRATION_MISMATCH`: what differs between the hydrated (server) view and the live one. */\nfunction checkHydration(inst: Instance) {\n if (!inst.hydrating) return\n inst.hydrating = false\n const server = inst.server\n if (!server || server.table !== inst.table) return\n const live = snapshot(inst, inst.table) as { state: TableState; rowModel: unknown }\n const hydrated = server.value as { state: TableState; rowModel: unknown }\n if (live === hydrated) return\n const slices: string[] = []\n for (const k of new Set([...Object.keys(hydrated.state), ...Object.keys(live.state)])) {\n if (!Object.is(hydrated.state[k], live.state[k])) slices.push(k)\n }\n if (slices.length === 0) {\n if (live.rowModel === hydrated.rowModel) return\n slices.push('rows')\n }\n // Delivered to onDiagnostic by the layout effect (no update during the commit).\n inst.rendering++\n try {\n emitTableDiagnostic(\n inst.table,\n 'DK_HYDRATION_MISMATCH',\n { slices },\n { trigger: 'hydrate', phase: 'hydrate' },\n )\n } finally {\n inst.rendering--\n }\n}\n\n/**\n * Forwards the changed options with one `setOptions` call. In the re-render caused by that call,\n * values recomputed from the same inputs (same-shape `columns`, `data` with equal rows, a `rowKey`\n * function) are not forwarded again: an inline `columns` / `data` would otherwise loop. A `data`\n * that still differs is forwarded at most once per chain of self-caused re-renders, so rows that\n * are new on every render (`data: [{ … }]` with nested objects) re-ingest but never hang.\n */\nfunction sync(inst: Instance, options: Options, selfCaused: boolean) {\n // Written out (not a module-level flag) so bundlers fold it while parsing (§8.2). The re-render\n // a sync causes is not counted: under `<DataTable columns>` it reuses the props (count reset).\n if (process.env.NODE_ENV !== 'production' && !selfCaused) checkUnstable(inst, options)\n const prev = inst.synced\n if (!selfCaused) inst.selfData = false\n let partial: Record<string, unknown> | undefined\n for (const k of SYNCED) {\n const v = options[k]\n const p = prev[k]\n if (Object.is(v, p)) continue\n let forward: unknown = v\n switch (k) {\n case 'onStateChange':\n case 'onDiagnostic':\n case 'fetcher': {\n const on = typeof v === 'function'\n if (on === (typeof p === 'function')) continue\n forward = on ? wrapper(inst, k, v) : undefined\n break\n }\n case 'state':\n if (sameSlices(v, p)) continue\n break\n case 'interceptors':\n if (sameItems(v, p)) continue\n break\n case 'data':\n // Two empty arrays hold nothing to ingest (e.g. an inline `data: []` with a fetcher).\n if (isEmpty(v) && sameItems(v, p)) continue\n if (selfCaused) {\n if (inst.selfData || sameRows(v, p)) continue\n inst.selfData = true\n }\n break\n case 'columns':\n if (selfCaused && sameShape(v, p)) continue\n break\n case 'rowKey':\n if (selfCaused && typeof v === 'function' && typeof p === 'function') continue\n break\n }\n partial ??= {}\n partial[k] = forward\n }\n if (partial === undefined) return\n inst.syncing = true\n try {\n inst.table.setOptions(partial)\n } finally {\n inst.syncing = false\n }\n const synced = { ...prev }\n for (const k of Object.keys(partial)) synced[k] = options[k]\n inst.synced = synced\n}\n\n/** Delivers the `onDiagnostic` calls queued while rendering. */\nfunction deliver(inst: Instance) {\n const queue = inst.queue\n if (queue === undefined) return\n inst.queue = undefined\n const sink = inst.latest.onDiagnostic as ((d: Diagnostic) => void) | undefined\n for (const d of queue) {\n try {\n sink?.(d)\n } catch (e) {\n // Like a failing sink in the hub: the logger never breaks the table.\n console.error('[DataKable] onDiagnostic threw', e)\n }\n }\n}\n\n// --- comparisons ---------------------------------------------------------------------------------\n\nconst isObject = (v: unknown): v is Record<string, unknown> => v !== null && typeof v === 'object'\n\n/** Controlled slices: the same defined slices, each `Object.is`-equal. */\nfunction sameSlices(a: unknown, b: unknown): boolean {\n if (!isObject(a) || !isObject(b)) return false\n const defined = (o: Record<string, unknown>) => Object.keys(o).filter((k) => o[k] !== undefined)\n const keys = defined(a)\n if (keys.length !== defined(b).length) return false\n for (const k of keys) if (!Object.is(a[k], b[k])) return false\n return true\n}\n\nconst isEmpty = (v: unknown) => Array.isArray(v) && v.length === 0\n\n/** Two arrays with the same items (by reference). */\nfunction sameItems(a: unknown, b: unknown): boolean {\n if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false\n for (let i = 0; i < a.length; i++) if (!Object.is(a[i], b[i])) return false\n return true\n}\n\nconst loose = (v: unknown) => typeof v === 'function' || isObject(v)\n\n/**\n * Two arrays of equal items: each pair the same reference, or objects with the same own keys and\n * `Object.is`-equal values. Rows (`data: rows.map((r) => ({ ...r }))` recomputed in a re-render):\n * exactly that. Columns (`shape`): equal primitive values, while functions and nested objects\n * (`format`, `cell`, `filter`, …) may be new references of the same type.\n */\nfunction sameRows(a: unknown, b: unknown, shape?: boolean): boolean {\n if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false\n for (let i = 0; i < a.length; i++) {\n const x: unknown = a[i]\n const y: unknown = b[i]\n if (Object.is(x, y)) continue\n if (!isObject(x) || !isObject(y)) return false\n const keys = Object.keys(x)\n if (keys.length !== Object.keys(y).length) return false\n for (const k of keys) {\n if (!Object.hasOwn(y, k)) return false\n const vx = x[k]\n const vy = y[k]\n if (Object.is(vx, vy)) continue\n if (!(shape && loose(vx) && loose(vy) && typeof vx === typeof vy)) return false\n }\n }\n return true\n}\n\n/** Column arrays of the same shape (see {@link sameRows}). */\nconst sameShape = (a: unknown, b: unknown) => sameRows(a, b, true)\n\n// --- dev: DK_UNSTABLE_COLUMNS / DK_UNSTABLE_OPTION -----------------------------------------------\n\n/** The first function option of a feature that is a new reference: `features[i].<option>`. */\nfunction changedFeatureOption(a: unknown, b: unknown): string | undefined {\n if (!Array.isArray(a) || !Array.isArray(b) || a === b) return undefined\n for (let i = 0; i < a.length; i++) {\n const f = a[i] as AnyFeature | undefined\n const g = b[i] as AnyFeature | undefined\n if (!f || !g || f === g || f.name !== g.name) continue\n if (!isOptionsDefinition(f.options) || !isOptionsDefinition(g.options)) continue\n const fv = f.options.values\n const gv = g.options.values\n if (!fv || !gv) continue\n for (const k of Object.keys(fv)) {\n if (typeof fv[k] === 'function' && fv[k] !== gv[k]) return `features[${i}].${k}`\n }\n }\n return undefined\n}\n\n/** Counts renders in a row that pass a new reference for the same thing; reports each once. */\nfunction checkUnstable(inst: Instance, options: Options) {\n const seen = inst.seen\n inst.seen = options\n const changed = (k: string) => !Object.is(options[k], seen[k])\n const fn = (k: string) =>\n changed(k) && typeof options[k] === 'function' && typeof seen[k] === 'function'\n track(inst, 'columns', changed('columns') && sameShape(options.columns, seen.columns))\n track(inst, 'data', changed('data') && sameRows(options.data, seen.data))\n track(inst, 'fetcher', fn('fetcher'))\n track(inst, 'rowKey', fn('rowKey'))\n const option = changedFeatureOption(options.features, seen.features)\n track(inst, 'features', option !== undefined, option)\n}\n\nfunction track(inst: Instance, key: string, unstable: boolean, option = key) {\n const seen = inst.unstable as Map<string, number>\n const warned = inst.warned as Set<string>\n const n = unstable ? (seen.get(key) ?? 0) + 1 : 0\n seen.set(key, n)\n if (n < UNSTABLE_AFTER || warned.has(key)) return\n warned.add(key)\n if (key === 'columns') emitTableDiagnostic(inst.table, 'DK_UNSTABLE_COLUMNS', { renders: n })\n else emitTableDiagnostic(inst.table, 'DK_UNSTABLE_OPTION', { option, renders: n })\n}\n","{\n \"name\": \"@datakable/react\",\n \"version\": \"2.0.0\",\n \"description\": \"React bindings for DataKable — useDataTable hook and DataTable component.\",\n \"license\": \"MIT\",\n \"author\": \"Supakit Kitjanabumrungsak\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/Ink01101011/datakable.git\",\n \"directory\": \"packages/react\"\n },\n \"homepage\": \"https://github.com/Ink01101011/datakable#readme\",\n \"bugs\": \"https://github.com/Ink01101011/datakable/issues\",\n \"keywords\": [\n \"react\",\n \"datatable\",\n \"table\",\n \"data-grid\",\n \"typescript\",\n \"type-safe\",\n \"headless\"\n ],\n \"type\": \"module\",\n \"sideEffects\": [\n \"./dist/messages.js\",\n \"./dist/messages.cjs\",\n \"./dist/styles.css\"\n ],\n \"engines\": {\n \"node\": \">=18.18.0\"\n },\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"messages\": [\n \"./dist/messages.d.ts\"\n ],\n \"styles.css\": [\n \"./dist/styles.css.d.ts\"\n ]\n }\n },\n \"exports\": {\n \".\": {\n \"import\": {\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/index.d.cts\",\n \"default\": \"./dist/index.cjs\"\n }\n },\n \"./messages\": {\n \"import\": {\n \"types\": \"./dist/messages.d.ts\",\n \"default\": \"./dist/messages.js\"\n },\n \"require\": {\n \"types\": \"./dist/messages.d.cts\",\n \"default\": \"./dist/messages.cjs\"\n }\n },\n \"./styles.css\": {\n \"types\": {\n \"import\": \"./dist/styles.css.d.ts\",\n \"require\": \"./dist/styles.css.d.cts\"\n },\n \"default\": \"./dist/styles.css\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"build\": \"tsup && node ../../scripts/write-styles-dts.mjs\",\n \"dev\": \"tsup --watch\",\n \"typecheck\": \"tsc -p tsconfig.json\",\n \"check:pkg\": \"publint --strict && attw --pack . && node scripts/check-catalog.mjs\",\n \"check:catalog\": \"node scripts/check-catalog.mjs\"\n },\n \"dependencies\": {\n \"@datakable/core\": \"workspace:^\"\n },\n \"peerDependencies\": {\n \"react\": \">=18\"\n },\n \"peerDependenciesMeta\": {\n \"react\": {\n \"optional\": true\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;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AW,MAAM;AACtD;AAEA,SAAS,MAAM,MAAgB,KAAa,UAAmB,SAAS,KAAK;AAC3E,QAAM,OAAO,KAAK;AAClB,QAAM,SAAS,KAAK;AACpB,QAAM,IAAI,YAAY,KAAK,IAAI,GAAG,KAAK,KAAK,IAAI;AAChD,OAAK,IAAI,KAAK,CAAC;AACf,MAAI,IAAI,kBAAkB,OAAO,IAAI,GAAG,EAAG;AAC3C,SAAO,IAAI,GAAG;AACd,MAAI,QAAQ,UAAW,sCAAoB,KAAK,OAAO,uBAAuB,EAAE,SAAS,EAAE,CAAC;AAAA,MACvF,sCAAoB,KAAK,OAAO,sBAAsB,EAAE,QAAQ,SAAS,EAAE,CAAC;AACnF;","names":["reactVersion","inst","value"]}
1
+ {"version":3,"sources":["../src/use-data-table.ts","../package.json"],"sourcesContent":["'use client'\n\nimport {\n type AnyFeature,\n type ApiOf,\n type ColumnDef,\n type CreateTableOptions,\n createDeferred,\n createTable,\n type Diagnostic,\n emitTableDiagnostic,\n type InvalidRowsMode,\n isOptionsDefinition,\n keepDiagnostics,\n type RowModel,\n registerPackage,\n type SchemaRow,\n SERVER_SOURCE,\n startTable,\n type Table,\n type TableSchema,\n type TableState,\n type TableStateFor,\n} from '@datakable/core'\nimport {\n type ReactNode,\n version as reactVersion,\n useCallback,\n useEffect,\n useInsertionEffect,\n useLayoutEffect,\n useReducer,\n useRef,\n useSyncExternalStore,\n} from 'react'\nimport { version } from '../package.json'\nimport { reactDiagnostics } from './codes'\n\n// Registers the (development-only) definitions where they are emitted, so bundlers keep them.\nkeepDiagnostics(reactDiagnostics)\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/**\n * `useDataTable` options: `createTable`'s (§3.2), with `cell` / `invalidCell` returning a\n * `ReactNode` (§10). Read once, at creation: `features`, `schema`, `invalidRows`, `initialState`,\n * `name`, `timeout`, `strict`, `diagnostics`. Every other option follows the latest render.\n */\nexport type UseDataTableOptions<\n T,\n S extends TableState = TableState,\n Sch = undefined,\n M extends InvalidRowsMode = 'drop',\n> = Omit<CreateTableOptions<T, S, Sch, M>, 'columns'> & {\n /**\n * Compared by reference (§10): a new array tells the table the columns changed. Define them\n * outside the component or memoise them (`DK_UNSTABLE_COLUMNS` in development).\n */\n columns?: readonly ColumnDef<SchemaRow<T, Sch>, ReactNode>[]\n}\n\n/**\n * What `useDataTable` returns: the table (its methods and the installed features' APIs) with the\n * `state` and `rowModel` of this render. A new object whenever the table notifies, so it can be a\n * dependency of `useMemo` / `memo` children; the same object while nothing changed.\n */\nexport type UseDataTableResult<\n T,\n S extends TableState = TableState,\n M extends InvalidRowsMode = 'drop',\n In = T,\n Api = unknown,\n> = Table<T, S, M, In> &\n Api & {\n /** The state snapshot of this render (`getState()`). */\n readonly state: S\n /** The row model of this render (`getRowModel()`, §6.6): rows, counts, status. */\n readonly rowModel: RowModel<T, M>\n }\n\ntype Options = Record<string, unknown> & { features?: readonly AnyFeature[] }\ntype AnyTable = Table<unknown, TableState> & Record<string, unknown>\ntype Callback = (arg: never) => unknown\n\n/** Options forwarded through `setOptions` when they change; the rest are read once (§3.4). */\nconst SYNCED = [\n 'data',\n 'columns',\n 'rowKey',\n 'state',\n 'onStateChange',\n 'interceptors',\n 'onDiagnostic',\n 'fetcher',\n 'rowCount',\n] as const\n\n/** Given to the table as stable wrappers that call the latest prop (latest-ref). */\nconst CALLBACKS = ['onStateChange', 'onDiagnostic', 'fetcher'] as const\ntype CallbackKey = (typeof CALLBACKS)[number]\n\n/** Renders in a row with a new reference before `DK_UNSTABLE_*` is reported. */\nconst UNSTABLE_AFTER = 2\n\ninterface Instance {\n table: AnyTable\n destroyed: boolean\n mounted: boolean\n /** The options of the latest committed render (what the wrappers call). */\n latest: Options\n /** The option values the table has (user values; callbacks count by presence). */\n synced: Options\n readonly wrappers: Record<CallbackKey, Callback>\n /** `onDiagnostic` calls made while rendering, delivered after the commit. */\n queue: Diagnostic[] | undefined\n rendering: number\n /** Inside the hook's own `setOptions` call. */\n syncing: boolean\n /** That call notified: the next commit is the re-render it caused. */\n selfCaused: boolean\n /**\n * `data` was forwarded in a self-caused re-render. Rows that differ on every render (nested\n * objects, computed fields) would otherwise ingest → notify → re-render forever: the next\n * self-caused re-render keeps the data the table has.\n */\n selfData: boolean\n /** Notifications seen; part of the view cache key (a notification is never silent, §6.6). */\n version: number\n view: { table: AnyTable; version: number; value: object } | undefined\n /**\n * SSR (§7.2): the view of `table` at its creation — initial state, controlled state and data /\n * initialData, no async result (the table is created deferred). `getServerSnapshot`.\n */\n server: { table: AnyTable; value: object } | undefined\n /** React read `getServerSnapshot` on the client: this render hydrates server HTML. */\n hydrating: boolean\n // Dev: DK_UNSTABLE_* bookkeeping.\n /** The options of the previous committed render. */\n seen: Options\n /** Development only (`checkUnstable`). */\n unstable?: Map<string, number>\n warned?: Set<string>\n}\n\nlet registered = false\n\n/**\n * Binds a table to a component (§10): the table is created once per component instance and\n * destroyed on unmount; renders read it through `useSyncExternalStore` (with\n * `getServerSnapshot`), and options are synced with `table.setOptions` in a layout effect, never\n * during render.\n *\n * - `features` (and the other read-once options) are read at creation: a new inline `features`\n * array never recreates the table.\n * - `fetcher`, `onStateChange` and `onDiagnostic` may be inline functions: the table always calls\n * the latest one, and a new reference never refetches (call `refetch()` when a value the fetcher\n * reads changes).\n * - `columns`, `data` and a `rowKey` function are compared by reference: memoise them.\n * - Controlled slices (§3.2): pass `state` and `onStateChange`; changes come back through `state`.\n * - SSR (§7.2): rendering starts no async work. The fetcher's first request and a `searchFn` for an\n * initial query start after the commit (`status: 'pending'` until then; `DK_SSR_ASYNC_DEFERRED`\n * on the server), unless `initialData` already holds their result. `initialState` (e.g. parsed\n * from the URL) applies on the server: client-mode features filter / search / sort the HTML.\n * `getServerSnapshot` is the view at creation; a table that changed before the hydration commit\n * reports `DK_HYDRATION_MISMATCH`.\n *\n * `@datakable/react` installs no features by default; `datakable`'s `useDataTable` installs the\n * default preset.\n */\nexport function useDataTable<\n T,\n S extends TableState = never,\n const Fs extends readonly AnyFeature[] = [],\n const Sch extends TableSchema | undefined = undefined,\n const M extends InvalidRowsMode = 'drop',\n>(\n options: UseDataTableOptions<T, TableStateFor<S, Fs, SchemaRow<T, Sch>>, Sch, M> & {\n features?: Fs\n },\n): UseDataTableResult<\n SchemaRow<T, Sch>,\n TableStateFor<S, Fs, SchemaRow<T, Sch>>,\n M,\n [Sch] extends [TableSchema] ? unknown : T,\n ApiOf<Fs, SchemaRow<T, Sch>>\n>\nexport function useDataTable(options: Options): unknown {\n const ref = useRef<Instance | null>(null)\n // Created during the first render, deferred: its async work (fetcher, searchFn) starts in the\n // mount effect, never on the server.\n if (ref.current === null) {\n ref.current = createInstance(options)\n // React 18's development StrictMode discards the first mount render, ref included (React 19\n // keeps it): that render's table never mounts, so release it once the render is over. A\n // render that commits after this (one that yielded) gets a new table at mount (`recreate`).\n if (\n process.env.NODE_ENV !== 'production' &&\n typeof window !== 'undefined' &&\n reactVersion.startsWith('18.')\n ) {\n const inst = ref.current\n queueMicrotask(() => release(inst))\n }\n }\n const inst = ref.current\n const table = inst.table\n const [, rerender] = useReducer((n: number) => n + 1, 0)\n\n const subscribe = useCallback(\n (onChange: () => void) => {\n // Replaced or destroyed meanwhile (`<Activity>`): nothing to subscribe to.\n if (inst.table !== table || inst.destroyed) return () => {}\n return table.subscribe(() => {\n inst.version++\n if (inst.syncing) inst.selfCaused = true\n onChange()\n })\n },\n [inst, table],\n )\n const getSnapshot = useCallback(() => snapshot(inst, table), [inst, table])\n const getServerSnapshot = useCallback(() => serverSnapshot(inst, table), [inst, table])\n const view = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot)\n\n // Hydration commit (§7.2): before any layout effect can change the table, the snapshot React\n // hydrated with must still be the live one, else React replaces the server HTML at once.\n useInsertionEffect(() => checkHydration(inst), [inst])\n\n useIsomorphicLayoutEffect(() => {\n inst.mounted = true\n // Destroyed while hidden (`<Activity>`): a new table, from the latest options.\n if (inst.destroyed) {\n recreate(inst)\n startTable(inst.table)\n rerender()\n } else {\n // The deferred fetch / searchFn starts now; its status shows before paint.\n startTable(inst.table)\n if (snapshot(inst, inst.table) !== view) rerender()\n }\n return () => {\n inst.mounted = false\n // Deferred: the StrictMode effect re-run mounts again synchronously and keeps the table.\n queueMicrotask(() => {\n if (inst.mounted || inst.destroyed) return\n inst.destroyed = true\n inst.table.destroy()\n })\n }\n }, [inst])\n\n useIsomorphicLayoutEffect(() => {\n inst.latest = options\n const selfCaused = inst.selfCaused\n inst.selfCaused = false\n if (!inst.destroyed) sync(inst, options, selfCaused)\n deliver(inst)\n })\n\n return view\n}\n\n/** Dev (React 18): destroys a table created in render unless it mounted (or was destroyed). */\nfunction release(inst: Instance) {\n if (inst.mounted || inst.destroyed) return\n inst.destroyed = true\n inst.table.destroy()\n}\n\nfunction createInstance(options: Options): Instance {\n const inst: Instance = {\n table: undefined as unknown as AnyTable,\n destroyed: false,\n mounted: false,\n latest: options,\n synced: options,\n wrappers: {\n onStateChange: (updater) => (inst.latest.onStateChange as Callback)(updater),\n onDiagnostic: (d: Diagnostic) => {\n if (inst.rendering === 0) {\n ;(inst.latest.onDiagnostic as ((d: Diagnostic) => void) | undefined)?.(d)\n return\n }\n if (inst.queue === undefined) {\n inst.queue = []\n // Delivered by the next layout effect, or here when this render never commits.\n queueMicrotask(() => deliver(inst))\n }\n inst.queue.push(d)\n },\n fetcher: (params) => (inst.latest.fetcher as Callback)(params),\n },\n queue: undefined,\n rendering: 0,\n syncing: false,\n selfCaused: false,\n selfData: false,\n version: 0,\n view: undefined,\n server: undefined,\n hydrating: false,\n seen: options,\n // Development only (`checkUnstable`): no Map / Set per table in production.\n ...(process.env.NODE_ENV !== 'production' ? { unstable: new Map(), warned: new Set() } : {}),\n }\n // The version checks are development-only (§8.5): production bundles no registry.\n if (process.env.NODE_ENV !== 'production' && !registered) {\n registered = true\n registerPackage('@datakable/react', version)\n }\n build(inst, options)\n return inst\n}\n\n/**\n * The stable wrapper of callback `k`. The fetcher's also carries the server source of the user's\n * `withFetcher` fetcher (§7.1), which is what makes the table load through it.\n */\nfunction wrapper(inst: Instance, k: CallbackKey, v: unknown): Callback {\n const w = inst.wrappers[k]\n if (k === 'fetcher') {\n ;(w as unknown as Record<symbol, unknown>)[SERVER_SOURCE] = (v as Record<symbol, unknown>)[\n SERVER_SOURCE\n ]\n }\n return w\n}\n\nfunction build(inst: Instance, options: Options) {\n const init: Options = { ...options }\n for (const k of CALLBACKS) {\n if (typeof options[k] === 'function') init[k] = wrapper(inst, k, options[k])\n }\n inst.rendering++\n try {\n // Deferred (§7.2): rendering starts no fetch / searchFn (none at all on the server, where\n // effects never run); the mount effect starts it.\n inst.table = createDeferred(() => createTable(init as never)) as unknown as AnyTable\n } finally {\n inst.rendering--\n }\n inst.synced = options\n inst.seen = options\n inst.view = undefined\n inst.server = undefined\n}\n\nfunction recreate(inst: Instance) {\n build(inst, inst.latest)\n inst.destroyed = false\n}\n\n/** The view of the table's snapshot, cached on (table, state, row model, notifications). */\nfunction snapshot(inst: Instance, table: AnyTable): object {\n inst.rendering++\n try {\n const state = table.getState()\n const rowModel = table.getRowModel()\n const v = inst.view\n if (v && v.table === table && v.version === inst.version) {\n const value = v.value as { state: unknown; rowModel: unknown }\n if (value.state === state && value.rowModel === rowModel) return value\n }\n const value = Object.create(table, {\n state: { value: state, enumerable: true },\n rowModel: { value: rowModel, enumerable: true },\n }) as object\n inst.view = { table, version: inst.version, value }\n return value\n } finally {\n inst.rendering--\n }\n}\n\n/**\n * `getServerSnapshot` (§7.2): the view of the table at its creation. React reads it on the server\n * and while hydrating, so both render the same snapshot; async work never ran in it.\n */\nfunction serverSnapshot(inst: Instance, table: AnyTable): object {\n if (inst.table !== table) return snapshot(inst, table)\n // On the client React reads it only to hydrate.\n if (typeof window !== 'undefined') inst.hydrating = true\n const s = inst.server\n if (s && s.table === table) return s.value\n const value = snapshot(inst, table)\n inst.server = { table, value }\n return value\n}\n\n/** `DK_HYDRATION_MISMATCH`: what differs between the hydrated (server) view and the live one. */\nfunction checkHydration(inst: Instance) {\n if (!inst.hydrating) return\n inst.hydrating = false\n const server = inst.server\n if (!server || server.table !== inst.table) return\n const live = snapshot(inst, inst.table) as { state: TableState; rowModel: unknown }\n const hydrated = server.value as { state: TableState; rowModel: unknown }\n if (live === hydrated) return\n const slices: string[] = []\n for (const k of new Set([...Object.keys(hydrated.state), ...Object.keys(live.state)])) {\n if (!Object.is(hydrated.state[k], live.state[k])) slices.push(k)\n }\n if (slices.length === 0) {\n if (live.rowModel === hydrated.rowModel) return\n slices.push('rows')\n }\n // Delivered to onDiagnostic by the layout effect (no update during the commit).\n inst.rendering++\n try {\n emitTableDiagnostic(\n inst.table,\n 'DK_HYDRATION_MISMATCH',\n { slices },\n { trigger: 'hydrate', phase: 'hydrate' },\n )\n } finally {\n inst.rendering--\n }\n}\n\n/**\n * Forwards the changed options with one `setOptions` call. In the re-render caused by that call,\n * values recomputed from the same inputs (same-shape `columns`, `data` with equal rows, a `rowKey`\n * function) are not forwarded again: an inline `columns` / `data` would otherwise loop. A `data`\n * that still differs is forwarded at most once per chain of self-caused re-renders, so rows that\n * are new on every render (`data: [{ … }]` with nested objects) re-ingest but never hang.\n */\nfunction sync(inst: Instance, options: Options, selfCaused: boolean) {\n // Written out (not a module-level flag) so bundlers fold it while parsing (§8.2). The re-render\n // a sync causes is not counted: under `<DataTable columns>` it reuses the props (count reset).\n if (process.env.NODE_ENV !== 'production' && !selfCaused) checkUnstable(inst, options)\n const prev = inst.synced\n if (!selfCaused) inst.selfData = false\n let partial: Record<string, unknown> | undefined\n for (const k of SYNCED) {\n const v = options[k]\n const p = prev[k]\n if (Object.is(v, p)) continue\n let forward: unknown = v\n switch (k) {\n case 'onStateChange':\n case 'onDiagnostic':\n case 'fetcher': {\n const on = typeof v === 'function'\n if (on === (typeof p === 'function')) continue\n forward = on ? wrapper(inst, k, v) : undefined\n break\n }\n case 'state':\n if (sameSlices(v, p)) continue\n break\n case 'interceptors':\n if (sameItems(v, p)) continue\n break\n case 'data':\n // Two empty arrays hold nothing to ingest (e.g. an inline `data: []` with a fetcher).\n if (isEmpty(v) && sameItems(v, p)) continue\n if (selfCaused) {\n if (inst.selfData || sameRows(v, p)) continue\n inst.selfData = true\n }\n break\n case 'columns':\n if (selfCaused && sameShape(v, p)) continue\n break\n case 'rowKey':\n if (selfCaused && typeof v === 'function' && typeof p === 'function') continue\n break\n }\n partial ??= {}\n partial[k] = forward\n }\n if (partial === undefined) return\n inst.syncing = true\n try {\n inst.table.setOptions(partial)\n } finally {\n inst.syncing = false\n }\n const synced = { ...prev }\n for (const k of Object.keys(partial)) synced[k] = options[k]\n inst.synced = synced\n}\n\n/** Delivers the `onDiagnostic` calls queued while rendering. */\nfunction deliver(inst: Instance) {\n const queue = inst.queue\n if (queue === undefined) return\n inst.queue = undefined\n const sink = inst.latest.onDiagnostic as ((d: Diagnostic) => void) | undefined\n for (const d of queue) {\n try {\n sink?.(d)\n } catch (e) {\n // Like a failing sink in the hub: the logger never breaks the table.\n console.error('[DataKable] onDiagnostic threw', e)\n }\n }\n}\n\n// --- comparisons ---------------------------------------------------------------------------------\n\nconst isObject = (v: unknown): v is Record<string, unknown> => v !== null && typeof v === 'object'\n\n/** Controlled slices: the same defined slices, each `Object.is`-equal. */\nfunction sameSlices(a: unknown, b: unknown): boolean {\n if (!isObject(a) || !isObject(b)) return false\n const defined = (o: Record<string, unknown>) => Object.keys(o).filter((k) => o[k] !== undefined)\n const keys = defined(a)\n if (keys.length !== defined(b).length) return false\n for (const k of keys) if (!Object.is(a[k], b[k])) return false\n return true\n}\n\nconst isEmpty = (v: unknown) => Array.isArray(v) && v.length === 0\n\n/** Two arrays with the same items (by reference). */\nfunction sameItems(a: unknown, b: unknown): boolean {\n if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false\n for (let i = 0; i < a.length; i++) if (!Object.is(a[i], b[i])) return false\n return true\n}\n\nconst loose = (v: unknown) => typeof v === 'function' || isObject(v)\n\n/**\n * Two arrays of equal items: each pair the same reference, or objects with the same own keys and\n * `Object.is`-equal values. Rows (`data: rows.map((r) => ({ ...r }))` recomputed in a re-render):\n * exactly that. Columns (`shape`): equal primitive values, while functions and nested objects\n * (`format`, `cell`, `filter`, …) may be new references of the same type.\n */\nfunction sameRows(a: unknown, b: unknown, shape?: boolean): boolean {\n if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false\n for (let i = 0; i < a.length; i++) {\n const x: unknown = a[i]\n const y: unknown = b[i]\n if (Object.is(x, y)) continue\n if (!isObject(x) || !isObject(y)) return false\n const keys = Object.keys(x)\n if (keys.length !== Object.keys(y).length) return false\n for (const k of keys) {\n if (!Object.hasOwn(y, k)) return false\n const vx = x[k]\n const vy = y[k]\n if (Object.is(vx, vy)) continue\n if (!(shape && loose(vx) && loose(vy) && typeof vx === typeof vy)) return false\n }\n }\n return true\n}\n\n/** Column arrays of the same shape (see {@link sameRows}). */\nconst sameShape = (a: unknown, b: unknown) => sameRows(a, b, true)\n\n// --- dev: DK_UNSTABLE_COLUMNS / DK_UNSTABLE_OPTION -----------------------------------------------\n\n/** The first function option of a feature that is a new reference: `features[i].<option>`. */\nfunction changedFeatureOption(a: unknown, b: unknown): string | undefined {\n if (!Array.isArray(a) || !Array.isArray(b) || a === b) return undefined\n for (let i = 0; i < a.length; i++) {\n const f = a[i] as AnyFeature | undefined\n const g = b[i] as AnyFeature | undefined\n if (!f || !g || f === g || f.name !== g.name) continue\n if (!isOptionsDefinition(f.options) || !isOptionsDefinition(g.options)) continue\n const fv = f.options.values\n const gv = g.options.values\n if (!fv || !gv) continue\n for (const k of Object.keys(fv)) {\n if (typeof fv[k] === 'function' && fv[k] !== gv[k]) return `features[${i}].${k}`\n }\n }\n return undefined\n}\n\n/** Counts renders in a row that pass a new reference for the same thing; reports each once. */\nfunction checkUnstable(inst: Instance, options: Options) {\n const seen = inst.seen\n inst.seen = options\n const changed = (k: string) => !Object.is(options[k], seen[k])\n const fn = (k: string) =>\n changed(k) && typeof options[k] === 'function' && typeof seen[k] === 'function'\n track(inst, 'columns', changed('columns') && sameShape(options.columns, seen.columns))\n track(inst, 'data', changed('data') && sameRows(options.data, seen.data))\n track(inst, 'fetcher', fn('fetcher'))\n track(inst, 'rowKey', fn('rowKey'))\n const option = changedFeatureOption(options.features, seen.features)\n track(inst, 'features', option !== undefined, option)\n}\n\nfunction track(inst: Instance, key: string, unstable: boolean, option = key) {\n const seen = inst.unstable as Map<string, number>\n const warned = inst.warned as Set<string>\n const n = unstable ? (seen.get(key) ?? 0) + 1 : 0\n seen.set(key, n)\n if (n < UNSTABLE_AFTER || warned.has(key)) return\n warned.add(key)\n if (key === 'columns') emitTableDiagnostic(inst.table, 'DK_UNSTABLE_COLUMNS', { renders: n })\n else emitTableDiagnostic(inst.table, 'DK_UNSTABLE_OPTION', { option, renders: n })\n}\n","{\n \"name\": \"@datakable/react\",\n \"version\": \"2.0.1\",\n \"description\": \"React bindings for DataKable — useDataTable hook and DataTable component.\",\n \"license\": \"MIT\",\n \"author\": \"Supakit Kitjanabumrungsak\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/Ink01101011/datakable.git\",\n \"directory\": \"packages/react\"\n },\n \"homepage\": \"https://github.com/Ink01101011/datakable#readme\",\n \"bugs\": \"https://github.com/Ink01101011/datakable/issues\",\n \"keywords\": [\n \"react\",\n \"react-table\",\n \"datatable\",\n \"data-table\",\n \"data-grid\",\n \"datagrid\",\n \"table\",\n \"typescript\",\n \"type-safe\",\n \"headless\",\n \"headless-ui\",\n \"zero-config\",\n \"sorting\",\n \"filtering\",\n \"search\",\n \"pagination\",\n \"react-hooks\",\n \"react-component\",\n \"use-data-table\",\n \"ssr\",\n \"rsc\"\n ],\n \"type\": \"module\",\n \"sideEffects\": [\n \"./dist/messages.js\",\n \"./dist/messages.cjs\",\n \"./dist/styles.css\"\n ],\n \"engines\": {\n \"node\": \">=18.18.0\"\n },\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"messages\": [\n \"./dist/messages.d.ts\"\n ],\n \"styles.css\": [\n \"./dist/styles.css.d.ts\"\n ]\n }\n },\n \"exports\": {\n \".\": {\n \"import\": {\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/index.d.cts\",\n \"default\": \"./dist/index.cjs\"\n }\n },\n \"./messages\": {\n \"import\": {\n \"types\": \"./dist/messages.d.ts\",\n \"default\": \"./dist/messages.js\"\n },\n \"require\": {\n \"types\": \"./dist/messages.d.cts\",\n \"default\": \"./dist/messages.cjs\"\n }\n },\n \"./styles.css\": {\n \"types\": {\n \"import\": \"./dist/styles.css.d.ts\",\n \"require\": \"./dist/styles.css.d.cts\"\n },\n \"default\": \"./dist/styles.css\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"build\": \"tsup && node ../../scripts/write-styles-dts.mjs\",\n \"dev\": \"tsup --watch\",\n \"typecheck\": \"tsc -p tsconfig.json\",\n \"check:pkg\": \"publint --strict && attw --pack . && node scripts/check-catalog.mjs\",\n \"check:catalog\": \"node scripts/check-catalog.mjs\"\n },\n \"dependencies\": {\n \"@datakable/core\": \"workspace:^\"\n },\n \"peerDependencies\": {\n \"react\": \">=18\"\n },\n \"peerDependenciesMeta\": {\n \"react\": {\n \"optional\": true\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,kBAqBO;AACP,mBAUO;;;AChCL,cAAW;;;ADkCb,mBAAiC;AAAA,IAGjC,6BAAgB,6BAAgB;AAMhC,IAAM,4BAA4B,OAAO,WAAW,cAAc,yBAAY;AA4C9E,IAAM,SAAS;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAA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AAO,IAAI,GAAG,EAAG;AAC3C,SAAO,IAAI,GAAG;AACd,MAAI,QAAQ,UAAW,sCAAoB,KAAK,OAAO,uBAAuB,EAAE,SAAS,EAAE,CAAC;AAAA,MACvF,sCAAoB,KAAK,OAAO,sBAAsB,EAAE,QAAQ,SAAS,EAAE,CAAC;AACnF;","names":["reactVersion","inst","value"]}
@@ -23,7 +23,7 @@ import {
23
23
  } from "react";
24
24
 
25
25
  // package.json
26
- var version = "2.0.0";
26
+ var version = "2.0.1";
27
27
 
28
28
  // src/use-data-table.ts
29
29
  import { reactDiagnostics } from "./codes.js";
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/use-data-table.ts","../package.json"],"sourcesContent":["'use client'\n\nimport {\n type AnyFeature,\n type ApiOf,\n type ColumnDef,\n type CreateTableOptions,\n createDeferred,\n createTable,\n type Diagnostic,\n emitTableDiagnostic,\n type InvalidRowsMode,\n isOptionsDefinition,\n keepDiagnostics,\n type RowModel,\n registerPackage,\n type SchemaRow,\n SERVER_SOURCE,\n startTable,\n type Table,\n type TableSchema,\n type TableState,\n type TableStateFor,\n} from '@datakable/core'\nimport {\n type ReactNode,\n version as reactVersion,\n useCallback,\n useEffect,\n useInsertionEffect,\n useLayoutEffect,\n useReducer,\n useRef,\n useSyncExternalStore,\n} from 'react'\nimport { version } from '../package.json'\nimport { reactDiagnostics } from './codes'\n\n// Registers the (development-only) definitions where they are emitted, so bundlers keep them.\nkeepDiagnostics(reactDiagnostics)\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/**\n * `useDataTable` options: `createTable`'s (§3.2), with `cell` / `invalidCell` returning a\n * `ReactNode` (§10). Read once, at creation: `features`, `schema`, `invalidRows`, `initialState`,\n * `name`, `timeout`, `strict`, `diagnostics`. Every other option follows the latest render.\n */\nexport type UseDataTableOptions<\n T,\n S extends TableState = TableState,\n Sch = undefined,\n M extends InvalidRowsMode = 'drop',\n> = Omit<CreateTableOptions<T, S, Sch, M>, 'columns'> & {\n /**\n * Compared by reference (§10): a new array tells the table the columns changed. Define them\n * outside the component or memoise them (`DK_UNSTABLE_COLUMNS` in development).\n */\n columns?: readonly ColumnDef<SchemaRow<T, Sch>, ReactNode>[]\n}\n\n/**\n * What `useDataTable` returns: the table (its methods and the installed features' APIs) with the\n * `state` and `rowModel` of this render. A new object whenever the table notifies, so it can be a\n * dependency of `useMemo` / `memo` children; the same object while nothing changed.\n */\nexport type UseDataTableResult<\n T,\n S extends TableState = TableState,\n M extends InvalidRowsMode = 'drop',\n In = T,\n Api = unknown,\n> = Table<T, S, M, In> &\n Api & {\n /** The state snapshot of this render (`getState()`). */\n readonly state: S\n /** The row model of this render (`getRowModel()`, §6.6): rows, counts, status. */\n readonly rowModel: RowModel<T, M>\n }\n\ntype Options = Record<string, unknown> & { features?: readonly AnyFeature[] }\ntype AnyTable = Table<unknown, TableState> & Record<string, unknown>\ntype Callback = (arg: never) => unknown\n\n/** Options forwarded through `setOptions` when they change; the rest are read once (§3.4). */\nconst SYNCED = [\n 'data',\n 'columns',\n 'rowKey',\n 'state',\n 'onStateChange',\n 'interceptors',\n 'onDiagnostic',\n 'fetcher',\n 'rowCount',\n] as const\n\n/** Given to the table as stable wrappers that call the latest prop (latest-ref). */\nconst CALLBACKS = ['onStateChange', 'onDiagnostic', 'fetcher'] as const\ntype CallbackKey = (typeof CALLBACKS)[number]\n\n/** Renders in a row with a new reference before `DK_UNSTABLE_*` is reported. */\nconst UNSTABLE_AFTER = 2\n\ninterface Instance {\n table: AnyTable\n destroyed: boolean\n mounted: boolean\n /** The options of the latest committed render (what the wrappers call). */\n latest: Options\n /** The option values the table has (user values; callbacks count by presence). */\n synced: Options\n readonly wrappers: Record<CallbackKey, Callback>\n /** `onDiagnostic` calls made while rendering, delivered after the commit. */\n queue: Diagnostic[] | undefined\n rendering: number\n /** Inside the hook's own `setOptions` call. */\n syncing: boolean\n /** That call notified: the next commit is the re-render it caused. */\n selfCaused: boolean\n /**\n * `data` was forwarded in a self-caused re-render. Rows that differ on every render (nested\n * objects, computed fields) would otherwise ingest → notify → re-render forever: the next\n * self-caused re-render keeps the data the table has.\n */\n selfData: boolean\n /** Notifications seen; part of the view cache key (a notification is never silent, §6.6). */\n version: number\n view: { table: AnyTable; version: number; value: object } | undefined\n /**\n * SSR (§7.2): the view of `table` at its creation — initial state, controlled state and data /\n * initialData, no async result (the table is created deferred). `getServerSnapshot`.\n */\n server: { table: AnyTable; value: object } | undefined\n /** React read `getServerSnapshot` on the client: this render hydrates server HTML. */\n hydrating: boolean\n // Dev: DK_UNSTABLE_* bookkeeping.\n /** The options of the previous committed render. */\n seen: Options\n /** Development only (`checkUnstable`). */\n unstable?: Map<string, number>\n warned?: Set<string>\n}\n\nlet registered = false\n\n/**\n * Binds a table to a component (§10): the table is created once per component instance and\n * destroyed on unmount; renders read it through `useSyncExternalStore` (with\n * `getServerSnapshot`), and options are synced with `table.setOptions` in a layout effect, never\n * during render.\n *\n * - `features` (and the other read-once options) are read at creation: a new inline `features`\n * array never recreates the table.\n * - `fetcher`, `onStateChange` and `onDiagnostic` may be inline functions: the table always calls\n * the latest one, and a new reference never refetches (call `refetch()` when a value the fetcher\n * reads changes).\n * - `columns`, `data` and a `rowKey` function are compared by reference: memoise them.\n * - Controlled slices (§3.2): pass `state` and `onStateChange`; changes come back through `state`.\n * - SSR (§7.2): rendering starts no async work. The fetcher's first request and a `searchFn` for an\n * initial query start after the commit (`status: 'pending'` until then; `DK_SSR_ASYNC_DEFERRED`\n * on the server), unless `initialData` already holds their result. `initialState` (e.g. parsed\n * from the URL) applies on the server: client-mode features filter / search / sort the HTML.\n * `getServerSnapshot` is the view at creation; a table that changed before the hydration commit\n * reports `DK_HYDRATION_MISMATCH`.\n *\n * `@datakable/react` installs no features by default; `datakable`'s `useDataTable` installs the\n * default preset.\n */\nexport function useDataTable<\n T,\n S extends TableState = never,\n const Fs extends readonly AnyFeature[] = [],\n const Sch extends TableSchema | undefined = undefined,\n const M extends InvalidRowsMode = 'drop',\n>(\n options: UseDataTableOptions<T, TableStateFor<S, Fs, SchemaRow<T, Sch>>, Sch, M> & {\n features?: Fs\n },\n): UseDataTableResult<\n SchemaRow<T, Sch>,\n TableStateFor<S, Fs, SchemaRow<T, Sch>>,\n M,\n [Sch] extends [TableSchema] ? unknown : T,\n ApiOf<Fs, SchemaRow<T, Sch>>\n>\nexport function useDataTable(options: Options): unknown {\n const ref = useRef<Instance | null>(null)\n // Created during the first render, deferred: its async work (fetcher, searchFn) starts in the\n // mount effect, never on the server.\n if (ref.current === null) {\n ref.current = createInstance(options)\n // React 18's development StrictMode discards the first mount render, ref included (React 19\n // keeps it): that render's table never mounts, so release it once the render is over. A\n // render that commits after this (one that yielded) gets a new table at mount (`recreate`).\n if (\n process.env.NODE_ENV !== 'production' &&\n typeof window !== 'undefined' &&\n reactVersion.startsWith('18.')\n ) {\n const inst = ref.current\n queueMicrotask(() => release(inst))\n }\n }\n const inst = ref.current\n const table = inst.table\n const [, rerender] = useReducer((n: number) => n + 1, 0)\n\n const subscribe = useCallback(\n (onChange: () => void) => {\n // Replaced or destroyed meanwhile (`<Activity>`): nothing to subscribe to.\n if (inst.table !== table || inst.destroyed) return () => {}\n return table.subscribe(() => {\n inst.version++\n if (inst.syncing) inst.selfCaused = true\n onChange()\n })\n },\n [inst, table],\n )\n const getSnapshot = useCallback(() => snapshot(inst, table), [inst, table])\n const getServerSnapshot = useCallback(() => serverSnapshot(inst, table), [inst, table])\n const view = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot)\n\n // Hydration commit (§7.2): before any layout effect can change the table, the snapshot React\n // hydrated with must still be the live one, else React replaces the server HTML at once.\n useInsertionEffect(() => checkHydration(inst), [inst])\n\n useIsomorphicLayoutEffect(() => {\n inst.mounted = true\n // Destroyed while hidden (`<Activity>`): a new table, from the latest options.\n if (inst.destroyed) {\n recreate(inst)\n startTable(inst.table)\n rerender()\n } else {\n // The deferred fetch / searchFn starts now; its status shows before paint.\n startTable(inst.table)\n if (snapshot(inst, inst.table) !== view) rerender()\n }\n return () => {\n inst.mounted = false\n // Deferred: the StrictMode effect re-run mounts again synchronously and keeps the table.\n queueMicrotask(() => {\n if (inst.mounted || inst.destroyed) return\n inst.destroyed = true\n inst.table.destroy()\n })\n }\n }, [inst])\n\n useIsomorphicLayoutEffect(() => {\n inst.latest = options\n const selfCaused = inst.selfCaused\n inst.selfCaused = false\n if (!inst.destroyed) sync(inst, options, selfCaused)\n deliver(inst)\n })\n\n return view\n}\n\n/** Dev (React 18): destroys a table created in render unless it mounted (or was destroyed). */\nfunction release(inst: Instance) {\n if (inst.mounted || inst.destroyed) return\n inst.destroyed = true\n inst.table.destroy()\n}\n\nfunction createInstance(options: Options): Instance {\n const inst: Instance = {\n table: undefined as unknown as AnyTable,\n destroyed: false,\n mounted: false,\n latest: options,\n synced: options,\n wrappers: {\n onStateChange: (updater) => (inst.latest.onStateChange as Callback)(updater),\n onDiagnostic: (d: Diagnostic) => {\n if (inst.rendering === 0) {\n ;(inst.latest.onDiagnostic as ((d: Diagnostic) => void) | undefined)?.(d)\n return\n }\n if (inst.queue === undefined) {\n inst.queue = []\n // Delivered by the next layout effect, or here when this render never commits.\n queueMicrotask(() => deliver(inst))\n }\n inst.queue.push(d)\n },\n fetcher: (params) => (inst.latest.fetcher as Callback)(params),\n },\n queue: undefined,\n rendering: 0,\n syncing: false,\n selfCaused: false,\n selfData: false,\n version: 0,\n view: undefined,\n server: undefined,\n hydrating: false,\n seen: options,\n // Development only (`checkUnstable`): no Map / Set per table in production.\n ...(process.env.NODE_ENV !== 'production' ? { unstable: new Map(), warned: new Set() } : {}),\n }\n // The version checks are development-only (§8.5): production bundles no registry.\n if (process.env.NODE_ENV !== 'production' && !registered) {\n registered = true\n registerPackage('@datakable/react', version)\n }\n build(inst, options)\n return inst\n}\n\n/**\n * The stable wrapper of callback `k`. The fetcher's also carries the server source of the user's\n * `withFetcher` fetcher (§7.1), which is what makes the table load through it.\n */\nfunction wrapper(inst: Instance, k: CallbackKey, v: unknown): Callback {\n const w = inst.wrappers[k]\n if (k === 'fetcher') {\n ;(w as unknown as Record<symbol, unknown>)[SERVER_SOURCE] = (v as Record<symbol, unknown>)[\n SERVER_SOURCE\n ]\n }\n return w\n}\n\nfunction build(inst: Instance, options: Options) {\n const init: Options = { ...options }\n for (const k of CALLBACKS) {\n if (typeof options[k] === 'function') init[k] = wrapper(inst, k, options[k])\n }\n inst.rendering++\n try {\n // Deferred (§7.2): rendering starts no fetch / searchFn (none at all on the server, where\n // effects never run); the mount effect starts it.\n inst.table = createDeferred(() => createTable(init as never)) as unknown as AnyTable\n } finally {\n inst.rendering--\n }\n inst.synced = options\n inst.seen = options\n inst.view = undefined\n inst.server = undefined\n}\n\nfunction recreate(inst: Instance) {\n build(inst, inst.latest)\n inst.destroyed = false\n}\n\n/** The view of the table's snapshot, cached on (table, state, row model, notifications). */\nfunction snapshot(inst: Instance, table: AnyTable): object {\n inst.rendering++\n try {\n const state = table.getState()\n const rowModel = table.getRowModel()\n const v = inst.view\n if (v && v.table === table && v.version === inst.version) {\n const value = v.value as { state: unknown; rowModel: unknown }\n if (value.state === state && value.rowModel === rowModel) return value\n }\n const value = Object.create(table, {\n state: { value: state, enumerable: true },\n rowModel: { value: rowModel, enumerable: true },\n }) as object\n inst.view = { table, version: inst.version, value }\n return value\n } finally {\n inst.rendering--\n }\n}\n\n/**\n * `getServerSnapshot` (§7.2): the view of the table at its creation. React reads it on the server\n * and while hydrating, so both render the same snapshot; async work never ran in it.\n */\nfunction serverSnapshot(inst: Instance, table: AnyTable): object {\n if (inst.table !== table) return snapshot(inst, table)\n // On the client React reads it only to hydrate.\n if (typeof window !== 'undefined') inst.hydrating = true\n const s = inst.server\n if (s && s.table === table) return s.value\n const value = snapshot(inst, table)\n inst.server = { table, value }\n return value\n}\n\n/** `DK_HYDRATION_MISMATCH`: what differs between the hydrated (server) view and the live one. */\nfunction checkHydration(inst: Instance) {\n if (!inst.hydrating) return\n inst.hydrating = false\n const server = inst.server\n if (!server || server.table !== inst.table) return\n const live = snapshot(inst, inst.table) as { state: TableState; rowModel: unknown }\n const hydrated = server.value as { state: TableState; rowModel: unknown }\n if (live === hydrated) return\n const slices: string[] = []\n for (const k of new Set([...Object.keys(hydrated.state), ...Object.keys(live.state)])) {\n if (!Object.is(hydrated.state[k], live.state[k])) slices.push(k)\n }\n if (slices.length === 0) {\n if (live.rowModel === hydrated.rowModel) return\n slices.push('rows')\n }\n // Delivered to onDiagnostic by the layout effect (no update during the commit).\n inst.rendering++\n try {\n emitTableDiagnostic(\n inst.table,\n 'DK_HYDRATION_MISMATCH',\n { slices },\n { trigger: 'hydrate', phase: 'hydrate' },\n )\n } finally {\n inst.rendering--\n }\n}\n\n/**\n * Forwards the changed options with one `setOptions` call. In the re-render caused by that call,\n * values recomputed from the same inputs (same-shape `columns`, `data` with equal rows, a `rowKey`\n * function) are not forwarded again: an inline `columns` / `data` would otherwise loop. A `data`\n * that still differs is forwarded at most once per chain of self-caused re-renders, so rows that\n * are new on every render (`data: [{ … }]` with nested objects) re-ingest but never hang.\n */\nfunction sync(inst: Instance, options: Options, selfCaused: boolean) {\n // Written out (not a module-level flag) so bundlers fold it while parsing (§8.2). The re-render\n // a sync causes is not counted: under `<DataTable columns>` it reuses the props (count reset).\n if (process.env.NODE_ENV !== 'production' && !selfCaused) checkUnstable(inst, options)\n const prev = inst.synced\n if (!selfCaused) inst.selfData = false\n let partial: Record<string, unknown> | undefined\n for (const k of SYNCED) {\n const v = options[k]\n const p = prev[k]\n if (Object.is(v, p)) continue\n let forward: unknown = v\n switch (k) {\n case 'onStateChange':\n case 'onDiagnostic':\n case 'fetcher': {\n const on = typeof v === 'function'\n if (on === (typeof p === 'function')) continue\n forward = on ? wrapper(inst, k, v) : undefined\n break\n }\n case 'state':\n if (sameSlices(v, p)) continue\n break\n case 'interceptors':\n if (sameItems(v, p)) continue\n break\n case 'data':\n // Two empty arrays hold nothing to ingest (e.g. an inline `data: []` with a fetcher).\n if (isEmpty(v) && sameItems(v, p)) continue\n if (selfCaused) {\n if (inst.selfData || sameRows(v, p)) continue\n inst.selfData = true\n }\n break\n case 'columns':\n if (selfCaused && sameShape(v, p)) continue\n break\n case 'rowKey':\n if (selfCaused && typeof v === 'function' && typeof p === 'function') continue\n break\n }\n partial ??= {}\n partial[k] = forward\n }\n if (partial === undefined) return\n inst.syncing = true\n try {\n inst.table.setOptions(partial)\n } finally {\n inst.syncing = false\n }\n const synced = { ...prev }\n for (const k of Object.keys(partial)) synced[k] = options[k]\n inst.synced = synced\n}\n\n/** Delivers the `onDiagnostic` calls queued while rendering. */\nfunction deliver(inst: Instance) {\n const queue = inst.queue\n if (queue === undefined) return\n inst.queue = undefined\n const sink = inst.latest.onDiagnostic as ((d: Diagnostic) => void) | undefined\n for (const d of queue) {\n try {\n sink?.(d)\n } catch (e) {\n // Like a failing sink in the hub: the logger never breaks the table.\n console.error('[DataKable] onDiagnostic threw', e)\n }\n }\n}\n\n// --- comparisons ---------------------------------------------------------------------------------\n\nconst isObject = (v: unknown): v is Record<string, unknown> => v !== null && typeof v === 'object'\n\n/** Controlled slices: the same defined slices, each `Object.is`-equal. */\nfunction sameSlices(a: unknown, b: unknown): boolean {\n if (!isObject(a) || !isObject(b)) return false\n const defined = (o: Record<string, unknown>) => Object.keys(o).filter((k) => o[k] !== undefined)\n const keys = defined(a)\n if (keys.length !== defined(b).length) return false\n for (const k of keys) if (!Object.is(a[k], b[k])) return false\n return true\n}\n\nconst isEmpty = (v: unknown) => Array.isArray(v) && v.length === 0\n\n/** Two arrays with the same items (by reference). */\nfunction sameItems(a: unknown, b: unknown): boolean {\n if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false\n for (let i = 0; i < a.length; i++) if (!Object.is(a[i], b[i])) return false\n return true\n}\n\nconst loose = (v: unknown) => typeof v === 'function' || isObject(v)\n\n/**\n * Two arrays of equal items: each pair the same reference, or objects with the same own keys and\n * `Object.is`-equal values. Rows (`data: rows.map((r) => ({ ...r }))` recomputed in a re-render):\n * exactly that. Columns (`shape`): equal primitive values, while functions and nested objects\n * (`format`, `cell`, `filter`, …) may be new references of the same type.\n */\nfunction sameRows(a: unknown, b: unknown, shape?: boolean): boolean {\n if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false\n for (let i = 0; i < a.length; i++) {\n const x: unknown = a[i]\n const y: unknown = b[i]\n if (Object.is(x, y)) continue\n if (!isObject(x) || !isObject(y)) return false\n const keys = Object.keys(x)\n if (keys.length !== Object.keys(y).length) return false\n for (const k of keys) {\n if (!Object.hasOwn(y, k)) return false\n const vx = x[k]\n const vy = y[k]\n if (Object.is(vx, vy)) continue\n if (!(shape && loose(vx) && loose(vy) && typeof vx === typeof vy)) return false\n }\n }\n return true\n}\n\n/** Column arrays of the same shape (see {@link sameRows}). */\nconst sameShape = (a: unknown, b: unknown) => sameRows(a, b, true)\n\n// --- dev: DK_UNSTABLE_COLUMNS / DK_UNSTABLE_OPTION -----------------------------------------------\n\n/** The first function option of a feature that is a new reference: `features[i].<option>`. */\nfunction changedFeatureOption(a: unknown, b: unknown): string | undefined {\n if (!Array.isArray(a) || !Array.isArray(b) || a === b) return undefined\n for (let i = 0; i < a.length; i++) {\n const f = a[i] as AnyFeature | undefined\n const g = b[i] as AnyFeature | undefined\n if (!f || !g || f === g || f.name !== g.name) continue\n if (!isOptionsDefinition(f.options) || !isOptionsDefinition(g.options)) continue\n const fv = f.options.values\n const gv = g.options.values\n if (!fv || !gv) continue\n for (const k of Object.keys(fv)) {\n if (typeof fv[k] === 'function' && fv[k] !== gv[k]) return `features[${i}].${k}`\n }\n }\n return undefined\n}\n\n/** Counts renders in a row that pass a new reference for the same thing; reports each once. */\nfunction checkUnstable(inst: Instance, options: Options) {\n const seen = inst.seen\n inst.seen = options\n const changed = (k: string) => !Object.is(options[k], seen[k])\n const fn = (k: string) =>\n changed(k) && typeof options[k] === 'function' && typeof seen[k] === 'function'\n track(inst, 'columns', changed('columns') && sameShape(options.columns, seen.columns))\n track(inst, 'data', changed('data') && sameRows(options.data, seen.data))\n track(inst, 'fetcher', fn('fetcher'))\n track(inst, 'rowKey', fn('rowKey'))\n const option = changedFeatureOption(options.features, seen.features)\n track(inst, 'features', option !== undefined, option)\n}\n\nfunction track(inst: Instance, key: string, unstable: boolean, option = key) {\n const seen = inst.unstable as Map<string, number>\n const warned = inst.warned as Set<string>\n const n = unstable ? (seen.get(key) ?? 0) + 1 : 0\n seen.set(key, n)\n if (n < UNSTABLE_AFTER || warned.has(key)) return\n warned.add(key)\n if (key === 'columns') emitTableDiagnostic(inst.table, 'DK_UNSTABLE_COLUMNS', { renders: n })\n else emitTableDiagnostic(inst.table, 'DK_UNSTABLE_OPTION', { option, renders: n })\n}\n","{\n \"name\": \"@datakable/react\",\n \"version\": \"2.0.0\",\n \"description\": \"React bindings for DataKable — useDataTable hook and DataTable component.\",\n \"license\": \"MIT\",\n \"author\": \"Supakit Kitjanabumrungsak\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/Ink01101011/datakable.git\",\n \"directory\": \"packages/react\"\n },\n \"homepage\": \"https://github.com/Ink01101011/datakable#readme\",\n \"bugs\": \"https://github.com/Ink01101011/datakable/issues\",\n \"keywords\": [\n \"react\",\n \"datatable\",\n \"table\",\n \"data-grid\",\n \"typescript\",\n \"type-safe\",\n \"headless\"\n ],\n \"type\": \"module\",\n \"sideEffects\": [\n \"./dist/messages.js\",\n \"./dist/messages.cjs\",\n \"./dist/styles.css\"\n ],\n \"engines\": {\n \"node\": \">=18.18.0\"\n },\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"messages\": [\n \"./dist/messages.d.ts\"\n ],\n \"styles.css\": [\n \"./dist/styles.css.d.ts\"\n ]\n }\n },\n \"exports\": {\n \".\": {\n \"import\": {\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/index.d.cts\",\n \"default\": \"./dist/index.cjs\"\n }\n },\n \"./messages\": {\n \"import\": {\n \"types\": \"./dist/messages.d.ts\",\n \"default\": \"./dist/messages.js\"\n },\n \"require\": {\n \"types\": \"./dist/messages.d.cts\",\n \"default\": \"./dist/messages.cjs\"\n }\n },\n \"./styles.css\": {\n \"types\": {\n \"import\": \"./dist/styles.css.d.ts\",\n \"require\": \"./dist/styles.css.d.cts\"\n },\n \"default\": \"./dist/styles.css\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"build\": \"tsup && node ../../scripts/write-styles-dts.mjs\",\n \"dev\": \"tsup --watch\",\n \"typecheck\": \"tsc -p tsconfig.json\",\n \"check:pkg\": \"publint --strict && attw --pack . && node scripts/check-catalog.mjs\",\n \"check:catalog\": \"node scripts/check-catalog.mjs\"\n },\n \"dependencies\": {\n \"@datakable/core\": \"workspace:^\"\n },\n \"peerDependencies\": {\n \"react\": \">=18\"\n },\n \"peerDependenciesMeta\": {\n \"react\": {\n \"optional\": true\n }\n }\n}\n"],"mappings":";;;AAEA;AAAA,EAKE;AAAA,EACA;AAAA,EAEA;AAAA,EAEA;AAAA,EACA;AAAA,EAEA;AAAA,EAEA;AAAA,EACA;AAAA,OAKK;AACP;AAAA,EAEE,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;AChCL,cAAW;;;ADkCb,SAAS,wBAAwB;AAGjC,gBAAgB,gBAAgB;AAMhC,IAAM,4BAA4B,OAAO,WAAW,cAAc,YAAY;AA4C9E,IAAM,SAAS;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGA,IAAM,YAAY,CAAC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AAS,EAAE,CAAC;AAAA,MACvF,qBAAoB,KAAK,OAAO,sBAAsB,EAAE,QAAQ,SAAS,EAAE,CAAC;AACnF;","names":["inst","value"]}
1
+ {"version":3,"sources":["../src/use-data-table.ts","../package.json"],"sourcesContent":["'use client'\n\nimport {\n type AnyFeature,\n type ApiOf,\n type ColumnDef,\n type CreateTableOptions,\n createDeferred,\n createTable,\n type Diagnostic,\n emitTableDiagnostic,\n type InvalidRowsMode,\n isOptionsDefinition,\n keepDiagnostics,\n type RowModel,\n registerPackage,\n type SchemaRow,\n SERVER_SOURCE,\n startTable,\n type Table,\n type TableSchema,\n type TableState,\n type TableStateFor,\n} from '@datakable/core'\nimport {\n type ReactNode,\n version as reactVersion,\n useCallback,\n useEffect,\n useInsertionEffect,\n useLayoutEffect,\n useReducer,\n useRef,\n useSyncExternalStore,\n} from 'react'\nimport { version } from '../package.json'\nimport { reactDiagnostics } from './codes'\n\n// Registers the (development-only) definitions where they are emitted, so bundlers keep them.\nkeepDiagnostics(reactDiagnostics)\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/**\n * `useDataTable` options: `createTable`'s (§3.2), with `cell` / `invalidCell` returning a\n * `ReactNode` (§10). Read once, at creation: `features`, `schema`, `invalidRows`, `initialState`,\n * `name`, `timeout`, `strict`, `diagnostics`. Every other option follows the latest render.\n */\nexport type UseDataTableOptions<\n T,\n S extends TableState = TableState,\n Sch = undefined,\n M extends InvalidRowsMode = 'drop',\n> = Omit<CreateTableOptions<T, S, Sch, M>, 'columns'> & {\n /**\n * Compared by reference (§10): a new array tells the table the columns changed. Define them\n * outside the component or memoise them (`DK_UNSTABLE_COLUMNS` in development).\n */\n columns?: readonly ColumnDef<SchemaRow<T, Sch>, ReactNode>[]\n}\n\n/**\n * What `useDataTable` returns: the table (its methods and the installed features' APIs) with the\n * `state` and `rowModel` of this render. A new object whenever the table notifies, so it can be a\n * dependency of `useMemo` / `memo` children; the same object while nothing changed.\n */\nexport type UseDataTableResult<\n T,\n S extends TableState = TableState,\n M extends InvalidRowsMode = 'drop',\n In = T,\n Api = unknown,\n> = Table<T, S, M, In> &\n Api & {\n /** The state snapshot of this render (`getState()`). */\n readonly state: S\n /** The row model of this render (`getRowModel()`, §6.6): rows, counts, status. */\n readonly rowModel: RowModel<T, M>\n }\n\ntype Options = Record<string, unknown> & { features?: readonly AnyFeature[] }\ntype AnyTable = Table<unknown, TableState> & Record<string, unknown>\ntype Callback = (arg: never) => unknown\n\n/** Options forwarded through `setOptions` when they change; the rest are read once (§3.4). */\nconst SYNCED = [\n 'data',\n 'columns',\n 'rowKey',\n 'state',\n 'onStateChange',\n 'interceptors',\n 'onDiagnostic',\n 'fetcher',\n 'rowCount',\n] as const\n\n/** Given to the table as stable wrappers that call the latest prop (latest-ref). */\nconst CALLBACKS = ['onStateChange', 'onDiagnostic', 'fetcher'] as const\ntype CallbackKey = (typeof CALLBACKS)[number]\n\n/** Renders in a row with a new reference before `DK_UNSTABLE_*` is reported. */\nconst UNSTABLE_AFTER = 2\n\ninterface Instance {\n table: AnyTable\n destroyed: boolean\n mounted: boolean\n /** The options of the latest committed render (what the wrappers call). */\n latest: Options\n /** The option values the table has (user values; callbacks count by presence). */\n synced: Options\n readonly wrappers: Record<CallbackKey, Callback>\n /** `onDiagnostic` calls made while rendering, delivered after the commit. */\n queue: Diagnostic[] | undefined\n rendering: number\n /** Inside the hook's own `setOptions` call. */\n syncing: boolean\n /** That call notified: the next commit is the re-render it caused. */\n selfCaused: boolean\n /**\n * `data` was forwarded in a self-caused re-render. Rows that differ on every render (nested\n * objects, computed fields) would otherwise ingest → notify → re-render forever: the next\n * self-caused re-render keeps the data the table has.\n */\n selfData: boolean\n /** Notifications seen; part of the view cache key (a notification is never silent, §6.6). */\n version: number\n view: { table: AnyTable; version: number; value: object } | undefined\n /**\n * SSR (§7.2): the view of `table` at its creation — initial state, controlled state and data /\n * initialData, no async result (the table is created deferred). `getServerSnapshot`.\n */\n server: { table: AnyTable; value: object } | undefined\n /** React read `getServerSnapshot` on the client: this render hydrates server HTML. */\n hydrating: boolean\n // Dev: DK_UNSTABLE_* bookkeeping.\n /** The options of the previous committed render. */\n seen: Options\n /** Development only (`checkUnstable`). */\n unstable?: Map<string, number>\n warned?: Set<string>\n}\n\nlet registered = false\n\n/**\n * Binds a table to a component (§10): the table is created once per component instance and\n * destroyed on unmount; renders read it through `useSyncExternalStore` (with\n * `getServerSnapshot`), and options are synced with `table.setOptions` in a layout effect, never\n * during render.\n *\n * - `features` (and the other read-once options) are read at creation: a new inline `features`\n * array never recreates the table.\n * - `fetcher`, `onStateChange` and `onDiagnostic` may be inline functions: the table always calls\n * the latest one, and a new reference never refetches (call `refetch()` when a value the fetcher\n * reads changes).\n * - `columns`, `data` and a `rowKey` function are compared by reference: memoise them.\n * - Controlled slices (§3.2): pass `state` and `onStateChange`; changes come back through `state`.\n * - SSR (§7.2): rendering starts no async work. The fetcher's first request and a `searchFn` for an\n * initial query start after the commit (`status: 'pending'` until then; `DK_SSR_ASYNC_DEFERRED`\n * on the server), unless `initialData` already holds their result. `initialState` (e.g. parsed\n * from the URL) applies on the server: client-mode features filter / search / sort the HTML.\n * `getServerSnapshot` is the view at creation; a table that changed before the hydration commit\n * reports `DK_HYDRATION_MISMATCH`.\n *\n * `@datakable/react` installs no features by default; `datakable`'s `useDataTable` installs the\n * default preset.\n */\nexport function useDataTable<\n T,\n S extends TableState = never,\n const Fs extends readonly AnyFeature[] = [],\n const Sch extends TableSchema | undefined = undefined,\n const M extends InvalidRowsMode = 'drop',\n>(\n options: UseDataTableOptions<T, TableStateFor<S, Fs, SchemaRow<T, Sch>>, Sch, M> & {\n features?: Fs\n },\n): UseDataTableResult<\n SchemaRow<T, Sch>,\n TableStateFor<S, Fs, SchemaRow<T, Sch>>,\n M,\n [Sch] extends [TableSchema] ? unknown : T,\n ApiOf<Fs, SchemaRow<T, Sch>>\n>\nexport function useDataTable(options: Options): unknown {\n const ref = useRef<Instance | null>(null)\n // Created during the first render, deferred: its async work (fetcher, searchFn) starts in the\n // mount effect, never on the server.\n if (ref.current === null) {\n ref.current = createInstance(options)\n // React 18's development StrictMode discards the first mount render, ref included (React 19\n // keeps it): that render's table never mounts, so release it once the render is over. A\n // render that commits after this (one that yielded) gets a new table at mount (`recreate`).\n if (\n process.env.NODE_ENV !== 'production' &&\n typeof window !== 'undefined' &&\n reactVersion.startsWith('18.')\n ) {\n const inst = ref.current\n queueMicrotask(() => release(inst))\n }\n }\n const inst = ref.current\n const table = inst.table\n const [, rerender] = useReducer((n: number) => n + 1, 0)\n\n const subscribe = useCallback(\n (onChange: () => void) => {\n // Replaced or destroyed meanwhile (`<Activity>`): nothing to subscribe to.\n if (inst.table !== table || inst.destroyed) return () => {}\n return table.subscribe(() => {\n inst.version++\n if (inst.syncing) inst.selfCaused = true\n onChange()\n })\n },\n [inst, table],\n )\n const getSnapshot = useCallback(() => snapshot(inst, table), [inst, table])\n const getServerSnapshot = useCallback(() => serverSnapshot(inst, table), [inst, table])\n const view = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot)\n\n // Hydration commit (§7.2): before any layout effect can change the table, the snapshot React\n // hydrated with must still be the live one, else React replaces the server HTML at once.\n useInsertionEffect(() => checkHydration(inst), [inst])\n\n useIsomorphicLayoutEffect(() => {\n inst.mounted = true\n // Destroyed while hidden (`<Activity>`): a new table, from the latest options.\n if (inst.destroyed) {\n recreate(inst)\n startTable(inst.table)\n rerender()\n } else {\n // The deferred fetch / searchFn starts now; its status shows before paint.\n startTable(inst.table)\n if (snapshot(inst, inst.table) !== view) rerender()\n }\n return () => {\n inst.mounted = false\n // Deferred: the StrictMode effect re-run mounts again synchronously and keeps the table.\n queueMicrotask(() => {\n if (inst.mounted || inst.destroyed) return\n inst.destroyed = true\n inst.table.destroy()\n })\n }\n }, [inst])\n\n useIsomorphicLayoutEffect(() => {\n inst.latest = options\n const selfCaused = inst.selfCaused\n inst.selfCaused = false\n if (!inst.destroyed) sync(inst, options, selfCaused)\n deliver(inst)\n })\n\n return view\n}\n\n/** Dev (React 18): destroys a table created in render unless it mounted (or was destroyed). */\nfunction release(inst: Instance) {\n if (inst.mounted || inst.destroyed) return\n inst.destroyed = true\n inst.table.destroy()\n}\n\nfunction createInstance(options: Options): Instance {\n const inst: Instance = {\n table: undefined as unknown as AnyTable,\n destroyed: false,\n mounted: false,\n latest: options,\n synced: options,\n wrappers: {\n onStateChange: (updater) => (inst.latest.onStateChange as Callback)(updater),\n onDiagnostic: (d: Diagnostic) => {\n if (inst.rendering === 0) {\n ;(inst.latest.onDiagnostic as ((d: Diagnostic) => void) | undefined)?.(d)\n return\n }\n if (inst.queue === undefined) {\n inst.queue = []\n // Delivered by the next layout effect, or here when this render never commits.\n queueMicrotask(() => deliver(inst))\n }\n inst.queue.push(d)\n },\n fetcher: (params) => (inst.latest.fetcher as Callback)(params),\n },\n queue: undefined,\n rendering: 0,\n syncing: false,\n selfCaused: false,\n selfData: false,\n version: 0,\n view: undefined,\n server: undefined,\n hydrating: false,\n seen: options,\n // Development only (`checkUnstable`): no Map / Set per table in production.\n ...(process.env.NODE_ENV !== 'production' ? { unstable: new Map(), warned: new Set() } : {}),\n }\n // The version checks are development-only (§8.5): production bundles no registry.\n if (process.env.NODE_ENV !== 'production' && !registered) {\n registered = true\n registerPackage('@datakable/react', version)\n }\n build(inst, options)\n return inst\n}\n\n/**\n * The stable wrapper of callback `k`. The fetcher's also carries the server source of the user's\n * `withFetcher` fetcher (§7.1), which is what makes the table load through it.\n */\nfunction wrapper(inst: Instance, k: CallbackKey, v: unknown): Callback {\n const w = inst.wrappers[k]\n if (k === 'fetcher') {\n ;(w as unknown as Record<symbol, unknown>)[SERVER_SOURCE] = (v as Record<symbol, unknown>)[\n SERVER_SOURCE\n ]\n }\n return w\n}\n\nfunction build(inst: Instance, options: Options) {\n const init: Options = { ...options }\n for (const k of CALLBACKS) {\n if (typeof options[k] === 'function') init[k] = wrapper(inst, k, options[k])\n }\n inst.rendering++\n try {\n // Deferred (§7.2): rendering starts no fetch / searchFn (none at all on the server, where\n // effects never run); the mount effect starts it.\n inst.table = createDeferred(() => createTable(init as never)) as unknown as AnyTable\n } finally {\n inst.rendering--\n }\n inst.synced = options\n inst.seen = options\n inst.view = undefined\n inst.server = undefined\n}\n\nfunction recreate(inst: Instance) {\n build(inst, inst.latest)\n inst.destroyed = false\n}\n\n/** The view of the table's snapshot, cached on (table, state, row model, notifications). */\nfunction snapshot(inst: Instance, table: AnyTable): object {\n inst.rendering++\n try {\n const state = table.getState()\n const rowModel = table.getRowModel()\n const v = inst.view\n if (v && v.table === table && v.version === inst.version) {\n const value = v.value as { state: unknown; rowModel: unknown }\n if (value.state === state && value.rowModel === rowModel) return value\n }\n const value = Object.create(table, {\n state: { value: state, enumerable: true },\n rowModel: { value: rowModel, enumerable: true },\n }) as object\n inst.view = { table, version: inst.version, value }\n return value\n } finally {\n inst.rendering--\n }\n}\n\n/**\n * `getServerSnapshot` (§7.2): the view of the table at its creation. React reads it on the server\n * and while hydrating, so both render the same snapshot; async work never ran in it.\n */\nfunction serverSnapshot(inst: Instance, table: AnyTable): object {\n if (inst.table !== table) return snapshot(inst, table)\n // On the client React reads it only to hydrate.\n if (typeof window !== 'undefined') inst.hydrating = true\n const s = inst.server\n if (s && s.table === table) return s.value\n const value = snapshot(inst, table)\n inst.server = { table, value }\n return value\n}\n\n/** `DK_HYDRATION_MISMATCH`: what differs between the hydrated (server) view and the live one. */\nfunction checkHydration(inst: Instance) {\n if (!inst.hydrating) return\n inst.hydrating = false\n const server = inst.server\n if (!server || server.table !== inst.table) return\n const live = snapshot(inst, inst.table) as { state: TableState; rowModel: unknown }\n const hydrated = server.value as { state: TableState; rowModel: unknown }\n if (live === hydrated) return\n const slices: string[] = []\n for (const k of new Set([...Object.keys(hydrated.state), ...Object.keys(live.state)])) {\n if (!Object.is(hydrated.state[k], live.state[k])) slices.push(k)\n }\n if (slices.length === 0) {\n if (live.rowModel === hydrated.rowModel) return\n slices.push('rows')\n }\n // Delivered to onDiagnostic by the layout effect (no update during the commit).\n inst.rendering++\n try {\n emitTableDiagnostic(\n inst.table,\n 'DK_HYDRATION_MISMATCH',\n { slices },\n { trigger: 'hydrate', phase: 'hydrate' },\n )\n } finally {\n inst.rendering--\n }\n}\n\n/**\n * Forwards the changed options with one `setOptions` call. In the re-render caused by that call,\n * values recomputed from the same inputs (same-shape `columns`, `data` with equal rows, a `rowKey`\n * function) are not forwarded again: an inline `columns` / `data` would otherwise loop. A `data`\n * that still differs is forwarded at most once per chain of self-caused re-renders, so rows that\n * are new on every render (`data: [{ … }]` with nested objects) re-ingest but never hang.\n */\nfunction sync(inst: Instance, options: Options, selfCaused: boolean) {\n // Written out (not a module-level flag) so bundlers fold it while parsing (§8.2). The re-render\n // a sync causes is not counted: under `<DataTable columns>` it reuses the props (count reset).\n if (process.env.NODE_ENV !== 'production' && !selfCaused) checkUnstable(inst, options)\n const prev = inst.synced\n if (!selfCaused) inst.selfData = false\n let partial: Record<string, unknown> | undefined\n for (const k of SYNCED) {\n const v = options[k]\n const p = prev[k]\n if (Object.is(v, p)) continue\n let forward: unknown = v\n switch (k) {\n case 'onStateChange':\n case 'onDiagnostic':\n case 'fetcher': {\n const on = typeof v === 'function'\n if (on === (typeof p === 'function')) continue\n forward = on ? wrapper(inst, k, v) : undefined\n break\n }\n case 'state':\n if (sameSlices(v, p)) continue\n break\n case 'interceptors':\n if (sameItems(v, p)) continue\n break\n case 'data':\n // Two empty arrays hold nothing to ingest (e.g. an inline `data: []` with a fetcher).\n if (isEmpty(v) && sameItems(v, p)) continue\n if (selfCaused) {\n if (inst.selfData || sameRows(v, p)) continue\n inst.selfData = true\n }\n break\n case 'columns':\n if (selfCaused && sameShape(v, p)) continue\n break\n case 'rowKey':\n if (selfCaused && typeof v === 'function' && typeof p === 'function') continue\n break\n }\n partial ??= {}\n partial[k] = forward\n }\n if (partial === undefined) return\n inst.syncing = true\n try {\n inst.table.setOptions(partial)\n } finally {\n inst.syncing = false\n }\n const synced = { ...prev }\n for (const k of Object.keys(partial)) synced[k] = options[k]\n inst.synced = synced\n}\n\n/** Delivers the `onDiagnostic` calls queued while rendering. */\nfunction deliver(inst: Instance) {\n const queue = inst.queue\n if (queue === undefined) return\n inst.queue = undefined\n const sink = inst.latest.onDiagnostic as ((d: Diagnostic) => void) | undefined\n for (const d of queue) {\n try {\n sink?.(d)\n } catch (e) {\n // Like a failing sink in the hub: the logger never breaks the table.\n console.error('[DataKable] onDiagnostic threw', e)\n }\n }\n}\n\n// --- comparisons ---------------------------------------------------------------------------------\n\nconst isObject = (v: unknown): v is Record<string, unknown> => v !== null && typeof v === 'object'\n\n/** Controlled slices: the same defined slices, each `Object.is`-equal. */\nfunction sameSlices(a: unknown, b: unknown): boolean {\n if (!isObject(a) || !isObject(b)) return false\n const defined = (o: Record<string, unknown>) => Object.keys(o).filter((k) => o[k] !== undefined)\n const keys = defined(a)\n if (keys.length !== defined(b).length) return false\n for (const k of keys) if (!Object.is(a[k], b[k])) return false\n return true\n}\n\nconst isEmpty = (v: unknown) => Array.isArray(v) && v.length === 0\n\n/** Two arrays with the same items (by reference). */\nfunction sameItems(a: unknown, b: unknown): boolean {\n if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false\n for (let i = 0; i < a.length; i++) if (!Object.is(a[i], b[i])) return false\n return true\n}\n\nconst loose = (v: unknown) => typeof v === 'function' || isObject(v)\n\n/**\n * Two arrays of equal items: each pair the same reference, or objects with the same own keys and\n * `Object.is`-equal values. Rows (`data: rows.map((r) => ({ ...r }))` recomputed in a re-render):\n * exactly that. Columns (`shape`): equal primitive values, while functions and nested objects\n * (`format`, `cell`, `filter`, …) may be new references of the same type.\n */\nfunction sameRows(a: unknown, b: unknown, shape?: boolean): boolean {\n if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false\n for (let i = 0; i < a.length; i++) {\n const x: unknown = a[i]\n const y: unknown = b[i]\n if (Object.is(x, y)) continue\n if (!isObject(x) || !isObject(y)) return false\n const keys = Object.keys(x)\n if (keys.length !== Object.keys(y).length) return false\n for (const k of keys) {\n if (!Object.hasOwn(y, k)) return false\n const vx = x[k]\n const vy = y[k]\n if (Object.is(vx, vy)) continue\n if (!(shape && loose(vx) && loose(vy) && typeof vx === typeof vy)) return false\n }\n }\n return true\n}\n\n/** Column arrays of the same shape (see {@link sameRows}). */\nconst sameShape = (a: unknown, b: unknown) => sameRows(a, b, true)\n\n// --- dev: DK_UNSTABLE_COLUMNS / DK_UNSTABLE_OPTION -----------------------------------------------\n\n/** The first function option of a feature that is a new reference: `features[i].<option>`. */\nfunction changedFeatureOption(a: unknown, b: unknown): string | undefined {\n if (!Array.isArray(a) || !Array.isArray(b) || a === b) return undefined\n for (let i = 0; i < a.length; i++) {\n const f = a[i] as AnyFeature | undefined\n const g = b[i] as AnyFeature | undefined\n if (!f || !g || f === g || f.name !== g.name) continue\n if (!isOptionsDefinition(f.options) || !isOptionsDefinition(g.options)) continue\n const fv = f.options.values\n const gv = g.options.values\n if (!fv || !gv) continue\n for (const k of Object.keys(fv)) {\n if (typeof fv[k] === 'function' && fv[k] !== gv[k]) return `features[${i}].${k}`\n }\n }\n return undefined\n}\n\n/** Counts renders in a row that pass a new reference for the same thing; reports each once. */\nfunction checkUnstable(inst: Instance, options: Options) {\n const seen = inst.seen\n inst.seen = options\n const changed = (k: string) => !Object.is(options[k], seen[k])\n const fn = (k: string) =>\n changed(k) && typeof options[k] === 'function' && typeof seen[k] === 'function'\n track(inst, 'columns', changed('columns') && sameShape(options.columns, seen.columns))\n track(inst, 'data', changed('data') && sameRows(options.data, seen.data))\n track(inst, 'fetcher', fn('fetcher'))\n track(inst, 'rowKey', fn('rowKey'))\n const option = changedFeatureOption(options.features, seen.features)\n track(inst, 'features', option !== undefined, option)\n}\n\nfunction track(inst: Instance, key: string, unstable: boolean, option = key) {\n const seen = inst.unstable as Map<string, number>\n const warned = inst.warned as Set<string>\n const n = unstable ? (seen.get(key) ?? 0) + 1 : 0\n seen.set(key, n)\n if (n < UNSTABLE_AFTER || warned.has(key)) return\n warned.add(key)\n if (key === 'columns') emitTableDiagnostic(inst.table, 'DK_UNSTABLE_COLUMNS', { renders: n })\n else emitTableDiagnostic(inst.table, 'DK_UNSTABLE_OPTION', { option, renders: n })\n}\n","{\n \"name\": \"@datakable/react\",\n \"version\": \"2.0.1\",\n \"description\": \"React bindings for DataKable — useDataTable hook and DataTable component.\",\n \"license\": \"MIT\",\n \"author\": \"Supakit Kitjanabumrungsak\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/Ink01101011/datakable.git\",\n \"directory\": \"packages/react\"\n },\n \"homepage\": \"https://github.com/Ink01101011/datakable#readme\",\n \"bugs\": \"https://github.com/Ink01101011/datakable/issues\",\n \"keywords\": [\n \"react\",\n \"react-table\",\n \"datatable\",\n \"data-table\",\n \"data-grid\",\n \"datagrid\",\n \"table\",\n \"typescript\",\n \"type-safe\",\n \"headless\",\n \"headless-ui\",\n \"zero-config\",\n \"sorting\",\n \"filtering\",\n \"search\",\n \"pagination\",\n \"react-hooks\",\n \"react-component\",\n \"use-data-table\",\n \"ssr\",\n \"rsc\"\n ],\n \"type\": \"module\",\n \"sideEffects\": [\n \"./dist/messages.js\",\n \"./dist/messages.cjs\",\n \"./dist/styles.css\"\n ],\n \"engines\": {\n \"node\": \">=18.18.0\"\n },\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"messages\": [\n \"./dist/messages.d.ts\"\n ],\n \"styles.css\": [\n \"./dist/styles.css.d.ts\"\n ]\n }\n },\n \"exports\": {\n \".\": {\n \"import\": {\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/index.d.cts\",\n \"default\": \"./dist/index.cjs\"\n }\n },\n \"./messages\": {\n \"import\": {\n \"types\": \"./dist/messages.d.ts\",\n \"default\": \"./dist/messages.js\"\n },\n \"require\": {\n \"types\": \"./dist/messages.d.cts\",\n \"default\": \"./dist/messages.cjs\"\n }\n },\n \"./styles.css\": {\n \"types\": {\n \"import\": \"./dist/styles.css.d.ts\",\n \"require\": \"./dist/styles.css.d.cts\"\n },\n \"default\": \"./dist/styles.css\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"build\": \"tsup && node ../../scripts/write-styles-dts.mjs\",\n \"dev\": \"tsup --watch\",\n \"typecheck\": \"tsc -p tsconfig.json\",\n \"check:pkg\": \"publint --strict && attw --pack . && node scripts/check-catalog.mjs\",\n \"check:catalog\": \"node scripts/check-catalog.mjs\"\n },\n \"dependencies\": {\n \"@datakable/core\": \"workspace:^\"\n },\n \"peerDependencies\": {\n \"react\": \">=18\"\n },\n \"peerDependenciesMeta\": {\n \"react\": {\n \"optional\": true\n }\n }\n}\n"],"mappings":";;;AAEA;AAAA,EAKE;AAAA,EACA;AAAA,EAEA;AAAA,EAEA;AAAA,EACA;AAAA,EAEA;AAAA,EAEA;AAAA,EACA;AAAA,OAKK;AACP;AAAA,EAEE,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;AChCL,cAAW;;;ADkCb,SAAS,wBAAwB;AAGjC,gBAAgB,gBAAgB;AAMhC,IAAM,4BAA4B,OAAO,WAAW,cAAc,YAAY;AA4C9E,IAAM,SAAS;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGA,IAAM,YAAY,CAAC,iBAAiB,gBAAgB,SAAS;AAI7D,IAAM,iBAAiB;AA0CvB,IAAI,aAAa;AA0CV,SAAS,aAAa,SAA2B;AACtD,QAAM,MAAM,OAAwB,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ANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datakable/react",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "React bindings for DataKable — useDataTable hook and DataTable component.",
5
5
  "license": "MIT",
6
6
  "author": "Supakit Kitjanabumrungsak",
@@ -13,12 +13,26 @@
13
13
  "bugs": "https://github.com/Ink01101011/datakable/issues",
14
14
  "keywords": [
15
15
  "react",
16
+ "react-table",
16
17
  "datatable",
17
- "table",
18
+ "data-table",
18
19
  "data-grid",
20
+ "datagrid",
21
+ "table",
19
22
  "typescript",
20
23
  "type-safe",
21
- "headless"
24
+ "headless",
25
+ "headless-ui",
26
+ "zero-config",
27
+ "sorting",
28
+ "filtering",
29
+ "search",
30
+ "pagination",
31
+ "react-hooks",
32
+ "react-component",
33
+ "use-data-table",
34
+ "ssr",
35
+ "rsc"
22
36
  ],
23
37
  "type": "module",
24
38
  "sideEffects": [
@@ -76,7 +90,7 @@
76
90
  "dist"
77
91
  ],
78
92
  "dependencies": {
79
- "@datakable/core": "^2.0.0"
93
+ "@datakable/core": "^2.0.1"
80
94
  },
81
95
  "peerDependencies": {
82
96
  "react": ">=18"