@macrostrat/data-sheet 4.1.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (302) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/dist/actions/builtin.cjs +1 -1
  3. package/dist/actions/builtin.cjs.map +1 -1
  4. package/dist/actions/builtin.d.ts +0 -2
  5. package/dist/actions/builtin.js +1 -1
  6. package/dist/actions/builtin.js.map +1 -1
  7. package/dist/actions/clipboard.cjs +1 -1
  8. package/dist/actions/clipboard.cjs.map +1 -1
  9. package/dist/actions/clipboard.d.ts +3 -2
  10. package/dist/actions/clipboard.js +1 -1
  11. package/dist/actions/clipboard.js.map +1 -1
  12. package/dist/actions/column-controls.cjs +7 -184
  13. package/dist/actions/column-controls.cjs.map +1 -1
  14. package/dist/actions/column-controls.d.ts +1 -1
  15. package/dist/actions/column-controls.js +5 -182
  16. package/dist/actions/column-controls.js.map +1 -1
  17. package/dist/actions/column-filter.cjs +24 -50
  18. package/dist/actions/column-filter.cjs.map +1 -1
  19. package/dist/actions/column-filter.d.ts +6 -4
  20. package/dist/actions/column-filter.js +25 -51
  21. package/dist/actions/column-filter.js.map +1 -1
  22. package/dist/actions/context.cjs +147 -0
  23. package/dist/actions/context.cjs.map +1 -0
  24. package/dist/actions/context.d.ts +93 -0
  25. package/dist/actions/context.js +145 -0
  26. package/dist/actions/context.js.map +1 -0
  27. package/dist/actions/edit-actions.cjs.map +1 -1
  28. package/dist/actions/edit-actions.d.ts +3 -1
  29. package/dist/actions/edit-actions.js.map +1 -1
  30. package/dist/actions/index.d.ts +2 -3
  31. package/dist/actions/selection.cjs +70 -115
  32. package/dist/actions/selection.cjs.map +1 -1
  33. package/dist/actions/selection.d.ts +22 -12
  34. package/dist/actions/selection.js +71 -114
  35. package/dist/actions/selection.js.map +1 -1
  36. package/dist/actions/{table-controls.cjs → table-actions.cjs} +7 -24
  37. package/dist/actions/table-actions.cjs.map +1 -0
  38. package/dist/actions/{table-controls.d.ts → table-actions.d.ts} +0 -4
  39. package/dist/actions/{table-controls.js → table-actions.js} +2 -19
  40. package/dist/actions/table-actions.js.map +1 -0
  41. package/dist/actions/types.d.ts +11 -89
  42. package/dist/components/cell-detail.cjs +6 -6
  43. package/dist/components/cell-detail.cjs.map +1 -1
  44. package/dist/components/cell-detail.js +1 -1
  45. package/dist/components/colors.cjs.map +1 -1
  46. package/dist/components/colors.js.map +1 -1
  47. package/dist/components/editor-popup.cjs +7 -7
  48. package/dist/components/editor-popup.cjs.map +1 -1
  49. package/dist/components/editor-popup.js +1 -1
  50. package/dist/components/index.d.ts +2 -1
  51. package/dist/components/indicators/filter-and-sort.cjs +378 -0
  52. package/dist/components/indicators/filter-and-sort.cjs.map +1 -0
  53. package/dist/components/indicators/filter-and-sort.d.ts +59 -0
  54. package/dist/components/indicators/filter-and-sort.js +376 -0
  55. package/dist/components/indicators/filter-and-sort.js.map +1 -0
  56. package/dist/components/indicators/filter-and-sort.module.sass.cjs +16 -0
  57. package/dist/components/indicators/filter-and-sort.module.sass.cjs.map +1 -0
  58. package/dist/components/indicators/filter-and-sort.module.sass.js +14 -0
  59. package/dist/components/indicators/filter-and-sort.module.sass.js.map +1 -0
  60. package/dist/components/indicators/index.d.ts +4 -0
  61. package/dist/components/indicators/selection.cjs +113 -0
  62. package/dist/components/indicators/selection.cjs.map +1 -0
  63. package/dist/components/indicators/selection.d.ts +3 -0
  64. package/dist/components/indicators/selection.js +111 -0
  65. package/dist/components/indicators/selection.js.map +1 -0
  66. package/dist/components/indicators/selection.module.sass.cjs +19 -0
  67. package/dist/components/indicators/selection.module.sass.cjs.map +1 -0
  68. package/dist/components/indicators/selection.module.sass.js +17 -0
  69. package/dist/components/indicators/selection.module.sass.js.map +1 -0
  70. package/dist/components/indicators/unified-filters.cjs +130 -0
  71. package/dist/components/indicators/unified-filters.cjs.map +1 -0
  72. package/dist/components/indicators/unified-filters.d.ts +10 -0
  73. package/dist/components/indicators/unified-filters.js +130 -0
  74. package/dist/components/indicators/unified-filters.js.map +1 -0
  75. package/dist/components/indicators/view-info.cjs +59 -0
  76. package/dist/components/indicators/view-info.cjs.map +1 -0
  77. package/dist/components/{view-info.d.ts → indicators/view-info.d.ts} +1 -0
  78. package/dist/components/{view-info.js → indicators/view-info.js} +17 -13
  79. package/dist/components/indicators/view-info.js.map +1 -0
  80. package/dist/components/text-areas.cjs +5 -5
  81. package/dist/components/text-areas.cjs.map +1 -1
  82. package/dist/components/text-areas.js +1 -1
  83. package/dist/components/toolbars/actions-toolbar.cjs +185 -0
  84. package/dist/components/toolbars/actions-toolbar.cjs.map +1 -0
  85. package/dist/{actions/toolbar.d.ts → components/toolbars/actions-toolbar.d.ts} +9 -5
  86. package/dist/{actions/toolbar.js → components/toolbars/actions-toolbar.js} +36 -97
  87. package/dist/components/toolbars/actions-toolbar.js.map +1 -0
  88. package/dist/components/toolbars/actions-toolbar.module.sass.cjs +29 -0
  89. package/dist/components/toolbars/actions-toolbar.module.sass.cjs.map +1 -0
  90. package/dist/components/toolbars/actions-toolbar.module.sass.js +27 -0
  91. package/dist/components/toolbars/actions-toolbar.module.sass.js.map +1 -0
  92. package/dist/components/toolbars/active-filters.cjs +120 -0
  93. package/dist/components/toolbars/active-filters.cjs.map +1 -0
  94. package/dist/{actions/filters.d.ts → components/toolbars/active-filters.d.ts} +3 -3
  95. package/dist/components/toolbars/active-filters.js +120 -0
  96. package/dist/components/toolbars/active-filters.js.map +1 -0
  97. package/dist/components/toolbars/index.d.ts +2 -0
  98. package/dist/data-panel.cjs +291 -0
  99. package/dist/data-panel.cjs.map +1 -0
  100. package/dist/data-panel.d.ts +110 -0
  101. package/dist/data-panel.js +289 -0
  102. package/dist/data-panel.js.map +1 -0
  103. package/dist/data-panel.module.sass.cjs +40 -0
  104. package/dist/data-panel.module.sass.cjs.map +1 -0
  105. package/dist/data-panel.module.sass.js +38 -0
  106. package/dist/data-panel.module.sass.js.map +1 -0
  107. package/dist/{core.cjs → data-sheet.cjs} +123 -181
  108. package/dist/data-sheet.cjs.map +1 -0
  109. package/dist/data-sheet.css +241 -13
  110. package/dist/data-sheet.d.ts +16 -0
  111. package/dist/{core.js → data-sheet.js} +92 -150
  112. package/dist/data-sheet.js.map +1 -0
  113. package/dist/data-view.cjs +47 -0
  114. package/dist/data-view.cjs.map +1 -0
  115. package/dist/data-view.d.ts +15 -0
  116. package/dist/data-view.js +45 -0
  117. package/dist/data-view.js.map +1 -0
  118. package/dist/filters/operators.cjs +21 -4
  119. package/dist/filters/operators.cjs.map +1 -1
  120. package/dist/filters/operators.d.ts +5 -4
  121. package/dist/filters/operators.js +21 -4
  122. package/dist/filters/operators.js.map +1 -1
  123. package/dist/index.cjs +106 -47
  124. package/dist/index.cjs.map +1 -1
  125. package/dist/index.d.ts +4 -3
  126. package/dist/index.js +76 -17
  127. package/dist/index.js.map +1 -1
  128. package/dist/notifications.cjs +4 -4
  129. package/dist/notifications.cjs.map +1 -1
  130. package/dist/notifications.js +1 -1
  131. package/dist/postgrest-table/data-loaders.cjs +129 -103
  132. package/dist/postgrest-table/data-loaders.cjs.map +1 -1
  133. package/dist/postgrest-table/data-loaders.d.ts +52 -82
  134. package/dist/postgrest-table/data-loaders.js +110 -84
  135. package/dist/postgrest-table/data-loaders.js.map +1 -1
  136. package/dist/postgrest-table/index.cjs +18 -17
  137. package/dist/postgrest-table/index.cjs.map +1 -1
  138. package/dist/postgrest-table/index.d.ts +4 -3
  139. package/dist/postgrest-table/index.js +9 -8
  140. package/dist/postgrest-table/index.js.map +1 -1
  141. package/dist/{utils → provider}/column-spec.cjs +23 -9
  142. package/dist/provider/column-spec.cjs.map +1 -0
  143. package/dist/{utils → provider}/column-spec.d.ts +77 -2
  144. package/dist/{utils → provider}/column-spec.js +24 -10
  145. package/dist/provider/column-spec.js.map +1 -0
  146. package/dist/provider/core.cjs +382 -0
  147. package/dist/provider/core.cjs.map +1 -0
  148. package/dist/provider/core.d.ts +74 -0
  149. package/dist/provider/core.js +380 -0
  150. package/dist/provider/core.js.map +1 -0
  151. package/dist/provider/index.d.ts +7 -0
  152. package/dist/provider/interactions.cjs +128 -0
  153. package/dist/provider/interactions.cjs.map +1 -0
  154. package/dist/provider/interactions.d.ts +39 -0
  155. package/dist/provider/interactions.js +128 -0
  156. package/dist/provider/interactions.js.map +1 -0
  157. package/dist/provider/selection.cjs +29 -0
  158. package/dist/provider/selection.cjs.map +1 -0
  159. package/dist/provider/selection.d.ts +9 -0
  160. package/dist/provider/selection.js +29 -0
  161. package/dist/provider/selection.js.map +1 -0
  162. package/dist/provider/table-data.cjs +92 -0
  163. package/dist/provider/table-data.cjs.map +1 -0
  164. package/dist/provider/table-data.d.ts +81 -0
  165. package/dist/provider/table-data.js +92 -0
  166. package/dist/provider/table-data.js.map +1 -0
  167. package/dist/provider/types.cjs +22 -0
  168. package/dist/provider/types.cjs.map +1 -0
  169. package/dist/provider/types.d.ts +256 -0
  170. package/dist/provider/types.js +22 -0
  171. package/dist/provider/types.js.map +1 -0
  172. package/dist/{zustand-store.cjs → provider/zustand-store.cjs} +37 -23
  173. package/dist/provider/zustand-store.cjs.map +1 -0
  174. package/dist/{zustand-store.js → provider/zustand-store.js} +22 -8
  175. package/dist/provider/zustand-store.js.map +1 -0
  176. package/dist/{cell-renderer.cjs → renderers/cell-renderer.cjs} +68 -35
  177. package/dist/renderers/cell-renderer.cjs.map +1 -0
  178. package/dist/{cell-renderer.d.ts → renderers/cell-renderer.d.ts} +1 -2
  179. package/dist/{cell-renderer.js → renderers/cell-renderer.js} +66 -33
  180. package/dist/renderers/cell-renderer.js.map +1 -0
  181. package/dist/renderers/column-header-cell.cjs +40 -17
  182. package/dist/renderers/column-header-cell.cjs.map +1 -1
  183. package/dist/renderers/column-header-cell.d.ts +2 -2
  184. package/dist/renderers/column-header-cell.js +40 -17
  185. package/dist/renderers/column-header-cell.js.map +1 -1
  186. package/dist/renderers/index.d.ts +1 -0
  187. package/dist/types.cjs +7 -19
  188. package/dist/types.cjs.map +1 -1
  189. package/dist/types.d.ts +123 -226
  190. package/dist/types.js +7 -19
  191. package/dist/types.js.map +1 -1
  192. package/dist/utils/atoms.cjs +24 -0
  193. package/dist/utils/atoms.cjs.map +1 -0
  194. package/dist/utils/atoms.d.ts +4 -0
  195. package/dist/utils/atoms.js +24 -0
  196. package/dist/utils/atoms.js.map +1 -0
  197. package/dist/utils/debug-overlay.cjs.map +1 -1
  198. package/dist/utils/debug-overlay.js.map +1 -1
  199. package/dist/utils/index.d.ts +2 -3
  200. package/dist/utils/key-handling.cjs +140 -139
  201. package/dist/utils/key-handling.cjs.map +1 -1
  202. package/dist/utils/key-handling.d.ts +4 -2
  203. package/dist/utils/key-handling.js +136 -135
  204. package/dist/utils/key-handling.js.map +1 -1
  205. package/dist/utils/validation.cjs +6 -1
  206. package/dist/utils/validation.cjs.map +1 -1
  207. package/dist/utils/validation.d.ts +1 -1
  208. package/dist/utils/validation.js +6 -1
  209. package/dist/utils/validation.js.map +1 -1
  210. package/package.json +4 -3
  211. package/src/actions/builtin.ts +1 -4
  212. package/src/actions/clipboard.ts +4 -3
  213. package/src/actions/column-controls.ts +12 -228
  214. package/src/actions/column-filter.ts +28 -63
  215. package/src/actions/context.ts +299 -0
  216. package/src/actions/edit-actions.ts +3 -1
  217. package/src/actions/index.ts +2 -3
  218. package/src/actions/selection.ts +109 -156
  219. package/src/actions/{table-controls.ts → table-actions.ts} +0 -20
  220. package/src/actions/types.ts +17 -101
  221. package/src/components/colors.ts +1 -1
  222. package/src/components/index.ts +2 -1
  223. package/src/components/indicators/filter-and-sort.module.sass +13 -0
  224. package/src/components/indicators/filter-and-sort.ts +478 -0
  225. package/src/components/indicators/index.ts +4 -0
  226. package/src/components/indicators/selection.module.sass +22 -0
  227. package/src/components/indicators/selection.ts +141 -0
  228. package/src/components/indicators/unified-filters.ts +161 -0
  229. package/src/components/{view-info.ts → indicators/view-info.ts} +16 -27
  230. package/src/{actions/toolbar.module.sass → components/toolbars/actions-toolbar.module.sass} +17 -4
  231. package/src/{actions/toolbar.ts → components/toolbars/actions-toolbar.ts} +53 -126
  232. package/src/components/toolbars/active-filters.ts +150 -0
  233. package/src/components/toolbars/index.ts +2 -0
  234. package/src/data-panel.module.sass +185 -0
  235. package/src/data-panel.ts +556 -0
  236. package/src/{core.ts → data-sheet.ts} +144 -306
  237. package/src/data-view.ts +70 -0
  238. package/src/filters/operators.ts +38 -6
  239. package/src/index.ts +4 -3
  240. package/src/postgrest-table/data-loaders.ts +250 -181
  241. package/src/postgrest-table/index.ts +10 -9
  242. package/src/{utils → provider}/column-spec.ts +34 -15
  243. package/src/provider/core.ts +585 -0
  244. package/src/provider/index.ts +7 -0
  245. package/src/provider/interactions.ts +161 -0
  246. package/src/provider/selection.ts +31 -0
  247. package/src/provider/table-data.ts +178 -0
  248. package/src/provider/types.ts +273 -0
  249. package/src/{zustand-store.ts → provider/zustand-store.ts} +36 -14
  250. package/src/{cell-renderer.ts → renderers/cell-renderer.ts} +146 -58
  251. package/src/renderers/column-header-cell.ts +51 -17
  252. package/src/renderers/index.ts +1 -0
  253. package/src/types.ts +143 -236
  254. package/src/utils/atoms.ts +28 -0
  255. package/src/utils/debug-overlay.ts +1 -1
  256. package/src/utils/index.ts +2 -8
  257. package/src/utils/key-handling.ts +170 -164
  258. package/src/utils/validation.ts +7 -2
  259. package/dist/actions/filters.cjs +0 -139
  260. package/dist/actions/filters.cjs.map +0 -1
  261. package/dist/actions/filters.js +0 -139
  262. package/dist/actions/filters.js.map +0 -1
  263. package/dist/actions/table-controls.cjs.map +0 -1
  264. package/dist/actions/table-controls.js.map +0 -1
  265. package/dist/actions/toolbar.cjs +0 -246
  266. package/dist/actions/toolbar.cjs.map +0 -1
  267. package/dist/actions/toolbar.js.map +0 -1
  268. package/dist/actions/toolbar.module.sass.cjs +0 -27
  269. package/dist/actions/toolbar.module.sass.cjs.map +0 -1
  270. package/dist/actions/toolbar.module.sass.js +0 -25
  271. package/dist/actions/toolbar.module.sass.js.map +0 -1
  272. package/dist/cell-renderer.cjs.map +0 -1
  273. package/dist/cell-renderer.js.map +0 -1
  274. package/dist/components/view-info.cjs +0 -55
  275. package/dist/components/view-info.cjs.map +0 -1
  276. package/dist/components/view-info.js.map +0 -1
  277. package/dist/core.cjs.map +0 -1
  278. package/dist/core.d.ts +0 -113
  279. package/dist/core.js.map +0 -1
  280. package/dist/provider.cjs +0 -191
  281. package/dist/provider.cjs.map +0 -1
  282. package/dist/provider.d.ts +0 -25
  283. package/dist/provider.js +0 -189
  284. package/dist/provider.js.map +0 -1
  285. package/dist/table-updates/data-parameter.d.ts +0 -14
  286. package/dist/table-updates/filter.d.ts +0 -16
  287. package/dist/table-updates/index.d.ts +0 -19
  288. package/dist/utils/column-spec.cjs.map +0 -1
  289. package/dist/utils/column-spec.js.map +0 -1
  290. package/dist/utils/index.cjs +0 -9
  291. package/dist/utils/index.cjs.map +0 -1
  292. package/dist/utils/index.js +0 -9
  293. package/dist/utils/index.js.map +0 -1
  294. package/dist/zustand-store.cjs.map +0 -1
  295. package/dist/zustand-store.js.map +0 -1
  296. package/src/actions/filters.ts +0 -176
  297. package/src/components/actions.module.sass +0 -8
  298. package/src/provider.ts +0 -250
  299. package/src/table-updates/data-parameter.ts +0 -44
  300. package/src/table-updates/filter.ts +0 -124
  301. package/src/table-updates/index.ts +0 -239
  302. /package/dist/{zustand-store.d.ts → provider/zustand-store.d.ts} +0 -0
@@ -1,20 +1,28 @@
1
1
  /** Lazy loading of data from a PostgREST endpoint */
2
2
 
3
3
  import { useAsyncEffect } from "@macrostrat/ui-components";
4
- import { debounce, range } from "underscore";
4
+ import { debounce } from "underscore";
5
5
  import { useCallback, useEffect, useMemo, useRef } from "react";
6
6
  import update, { Spec } from "immutability-helper";
7
7
  import {
8
+ ClientServerOptions,
8
9
  PostgrestClient,
9
10
  PostgrestFilterBuilder,
10
11
  PostgrestQueryBuilder,
11
12
  } from "@supabase/postgrest-js";
12
13
  import { adjustArraySize, RowRegion } from "./loading-utils.ts";
13
- import { ctx, tableDataAtom, useSelector } from "../provider.ts";
14
+ import {
15
+ ctx,
16
+ dataProviderAtom,
17
+ dataRefreshTokenAtom,
18
+ FetchData,
19
+ FetchDataFilter,
20
+ tableDataAtom,
21
+ TableDataProvider,
22
+ useSelector,
23
+ } from "../provider";
14
24
  import { atom } from "jotai";
15
- import type { ColumnSort } from "../types.ts";
16
-
17
- export type FetchMode = "scroll" | "paged";
25
+ import { FetchDataOptions, FetchMode } from "../types.ts";
18
26
 
19
27
  interface LazyLoaderStateCore<T> {
20
28
  loading: boolean;
@@ -39,7 +47,8 @@ export interface PostgrestOrder<T> {
39
47
  nullsFirst?: boolean;
40
48
  }
41
49
 
42
- /** Operators available for server-side column filtering via PostgREST. */
50
+ /** Operators available for server-side column filtering via PostgREST.
51
+ * `cs`/`ov` target array columns (contains / overlaps). */
43
52
  export type PostgrestFilterOperator =
44
53
  | "eq"
45
54
  | "neq"
@@ -49,7 +58,9 @@ export type PostgrestFilterOperator =
49
58
  | "lt"
50
59
  | "gte"
51
60
  | "lte"
52
- | "is";
61
+ | "is"
62
+ | "cs"
63
+ | "ov";
53
64
 
54
65
  /** A single column sort entry. */
55
66
  export interface ColumnSortEntry {
@@ -65,6 +76,7 @@ export interface PostgrestColumnFilter {
65
76
  }
66
77
 
67
78
  export interface PostgrestFilter {
79
+ id?: string;
68
80
  type: "filter";
69
81
  apply(
70
82
  req: PostgrestFilterBuilder<any, any, any, any>,
@@ -88,6 +100,16 @@ export function applyColumnFilters(
88
100
  ) {
89
101
  for (const cf of filters) {
90
102
  if (cf.value === "" || cf.value == null) continue;
103
+ // Array-column operators need a list value and postgrest-js's dedicated
104
+ // builders (which emit the `{…}` array literal), not a scalar `.filter`.
105
+ if (cf.operator === "cs") {
106
+ req = req.contains(cf.key, splitFilterList(cf.value));
107
+ continue;
108
+ }
109
+ if (cf.operator === "ov") {
110
+ req = req.overlaps(cf.key, splitFilterList(cf.value));
111
+ continue;
112
+ }
91
113
  const val =
92
114
  cf.operator === "like" || cf.operator === "ilike"
93
115
  ? `*${cf.value}*`
@@ -97,6 +119,15 @@ export function applyColumnFilters(
97
119
  return req;
98
120
  }
99
121
 
122
+ /** Split a comma-separated filter value into trimmed, non-empty tokens (the set
123
+ * for `cs`/`ov`); a single value yields a one-element list. */
124
+ function splitFilterList(value: any): string[] {
125
+ return String(value)
126
+ .split(",")
127
+ .map((s) => s.trim())
128
+ .filter((s) => s !== "");
129
+ }
130
+
100
131
  type LazyLoaderAction<T> =
101
132
  | { type: "start-loading" }
102
133
  | {
@@ -109,7 +140,6 @@ type LazyLoaderAction<T> =
109
140
  | { type: "error"; error: Error }
110
141
  | { type: "update-data"; changes: Spec<T[]> }
111
142
  | { type: "reset" }
112
- | { type: "start-reload" }
113
143
  | { type: "configure"; fetchMode: FetchMode; pageSize: number };
114
144
 
115
145
  function lazyLoadingReducer<T>(
@@ -127,7 +157,7 @@ function lazyLoadingReducer<T>(
127
157
  return {
128
158
  ...state,
129
159
  loading: false,
130
- data: update(state.data, action.changes),
160
+ data: update(state.data, action.changes as any),
131
161
  };
132
162
  case "loaded":
133
163
  let data = adjustArraySize(state.data, action.totalSize);
@@ -153,18 +183,15 @@ function lazyLoadingReducer<T>(
153
183
  fetchMode: action.fetchMode,
154
184
  pageSize: action.pageSize,
155
185
  };
156
- case "start-reload":
157
- // Preserve the table dimensions but show ghost/skeleton cells
158
- return {
159
- ...state,
160
- data: new Array(state.data.length).fill(null),
161
- loading: true,
162
- initialized: false,
163
- };
164
186
  case "reset":
187
+ // A view change (or initial load) re-fetches from scratch. Rather than
188
+ // blanking the table (which reads as a jarring empty flash while the
189
+ // request is in flight — very visible on sort/filter), pre-size to a page
190
+ // of `null` ghost/skeleton rows so the body stays populated and the load
191
+ // is legible. `loaded` then adjusts the array to the real size.
165
192
  return {
166
193
  visibleRegion: defaultVisibleRegion,
167
- data: [],
194
+ data: new Array(Math.max(state.pageSize, 0)).fill(null),
168
195
  loading: false,
169
196
  error: null,
170
197
  initialized: false,
@@ -195,12 +222,69 @@ interface QueryConfig extends SortAndFilterOptions {
195
222
  count?: "exact" | "estimated";
196
223
  limit?: number;
197
224
  identityKey: string;
225
+ /** The identity column's default ordering (used when nothing in `order`
226
+ * already sorts it). A string ⇒ ascending; pass a `PostgrestOrder` to set the
227
+ * direction (e.g. `source_id` descending). */
228
+ identityOrder?: PostgrestOrder<any>;
198
229
  lastLoadedRow?: any;
199
230
  lastLoadedRowIndex: number;
200
231
  }
201
232
 
233
+ /** Format a value for a PostgREST logic-tree condition. Reserved characters
234
+ * (`, . : ( )`), spaces, quotes, and backslashes require the value to be
235
+ * double-quoted, with `"` and `\` backslash-escaped inside — otherwise a map
236
+ * name containing a comma would break the `or=(...)` parse. */
237
+ function formatKeysetValue(v: any): string {
238
+ const s = String(v);
239
+ if (s === "" || /[,.:()"\\ ]/.test(s)) {
240
+ return `"${s.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
241
+ }
242
+ return s;
243
+ }
244
+
245
+ /** An equality condition for the cursor prefix (`col.eq.v`, or `col.is.null`). */
246
+ function keysetEq(key: string, v: any): string {
247
+ return v == null ? `${key}.is.null` : `${key}.eq.${formatKeysetValue(v)}`;
248
+ }
249
+
250
+ /**
251
+ * Build the compound keyset predicate (the body of an `or=(...)`) selecting
252
+ * rows strictly after `lastRow` under `clauses` (lexicographic, last clause is
253
+ * the identity tiebreaker):
254
+ *
255
+ * (c1 OP1 v1)
256
+ * OR (c1 = v1 AND c2 OP2 v2)
257
+ * OR (c1 = v1 AND c2 = v2 AND c3 OP3 v3) …
258
+ *
259
+ * `OPi` is `gt` for an ascending clause, `lt` for descending. Nulls-last: a
260
+ * null pivot value has no strictly-ordered non-null successor at its level, so
261
+ * that term is skipped and the tie defers to deeper clauses (the identity key
262
+ * is non-null, so at least its term is always emitted). Returns `null` if no
263
+ * term applies. (Known limit: rows whose *sort* column is null aren't picked up
264
+ * across the non-null→null boundary — an edge for nullable sort columns; the
265
+ * non-null identity tiebreaker keeps pagination from stalling.)
266
+ */
267
+ function buildKeysetPredicate(
268
+ clauses: PostgrestOrder<any>[],
269
+ lastRow: any,
270
+ ): string | null {
271
+ const terms: string[] = [];
272
+ for (let i = 0; i < clauses.length; i++) {
273
+ const v = lastRow[clauses[i].key];
274
+ if (v == null) continue;
275
+ const conds: string[] = [];
276
+ for (let j = 0; j < i; j++) {
277
+ conds.push(keysetEq(clauses[j].key, lastRow[clauses[j].key]));
278
+ }
279
+ const op = (clauses[i].ascending ?? true) ? "gt" : "lt";
280
+ conds.push(`${clauses[i].key}.${op}.${formatKeysetValue(v)}`);
281
+ terms.push(conds.length === 1 ? conds[0] : `and(${conds.join(",")})`);
282
+ }
283
+ return terms.length > 0 ? terms.join(",") : null;
284
+ }
285
+
202
286
  function buildQuery<T>(
203
- client: PostgrestQueryBuilder<T, any, any>,
287
+ client: PostgrestQueryBuilder<any, any, any>,
204
288
  config: QueryConfig,
205
289
  ) {
206
290
  const { columns = "*", count, lastLoadedRowIndex } = config;
@@ -222,21 +306,27 @@ function buildQuery<T>(
222
306
 
223
307
  const orderClauses = buildPostgrestOrderClauses(
224
308
  config.order ?? [],
225
- config.identityKey,
309
+ config.identityOrder ?? config.identityKey,
226
310
  );
227
311
 
228
312
  let hasOrdering = false;
229
313
  for (const clause of orderClauses) {
230
314
  query = query.order(clause.key, clause);
231
- if (config.lastLoadedRow != null) {
232
- const op = (clause.ascending ?? true) ? "gt" : "lt";
233
- const value = config.lastLoadedRow[clause.key];
234
- query = query[op](clause.key, value);
235
- }
236
315
  hasOrdering = true;
237
316
  }
238
317
 
239
- let offset = null;
318
+ // Keyset cursor: rows strictly after the last loaded row under the active
319
+ // ordering. This MUST be a compound predicate, not an independent `gt`/`lt`
320
+ // per column: with a leading low-cardinality sort (e.g. `state`), a plain
321
+ // `state.gt.X AND source_id.lt.Y` drops every row sharing the cursor's
322
+ // `state` (`state.gt.X` is false for them). The lexicographic form keeps the
323
+ // tie broken by the next column, ending on the non-null identity key.
324
+ if (config.lastLoadedRow != null && hasOrdering) {
325
+ const pred = buildKeysetPredicate(orderClauses, config.lastLoadedRow);
326
+ if (pred != null) query = query.or(pred);
327
+ }
328
+
329
+ let offset: number | null = null;
240
330
  if (!hasOrdering && lastLoadedRowIndex > 0) {
241
331
  // We need to load based on offsets
242
332
  offset = lastLoadedRowIndex + 1;
@@ -251,7 +341,6 @@ function buildQuery<T>(
251
341
  }
252
342
  }
253
343
 
254
- console.log("query", query.url.search);
255
344
  return query;
256
345
  }
257
346
 
@@ -275,10 +364,6 @@ const lazyLoaderCoreStateAtom = atom<LazyLoaderStateCore<any>>({
275
364
  /** Current page index (0-based) for paged fetch mode. */
276
365
  export const chunkPageAtom = atom(0);
277
366
 
278
- /** Bump this to force the active chunk loader to reset and re-fetch from
279
- * scratch — e.g. after a mutation (save/delete) that invalidates loaded rows. */
280
- export const dataRefreshTokenAtom = atom(0);
281
-
282
367
  /** Footer state for the optional bottom-of-table indicator: rows loaded, the
283
368
  * source total when known, load status, and — in paged mode — the current
284
369
  * page and total pages. */
@@ -317,6 +402,85 @@ export const tableFooterAtom = atom<TableFooterInfo>((get) => {
317
402
  };
318
403
  });
319
404
 
405
+ /** Auto-load this many pages per burst, then pause (null ⇒ unbounded). Set by
406
+ * a consumer (e.g. `DataPanel`'s `autoLoadPages` prop). */
407
+ export const autoLoadPagesAtom = atom<number | null>(null);
408
+
409
+ /** Row count at the last manual "load more" — the point auto-load resumes
410
+ * counting a fresh burst from. */
411
+ export const resumeBaselineAtom = atom(0);
412
+
413
+ /** Live loading controls, read from the store rather than passed down a
414
+ * boundary contract. Any component inside the provider can call
415
+ * `useLoadControls()` — a footer, a toolbar button, a status line — without the
416
+ * renderer wiring a specific prop shape to it. */
417
+ export interface LoadControls {
418
+ /** Load the next page and resume auto-loading (clears a paused state). */
419
+ loadMore: () => void;
420
+ /** A fetch is in flight. */
421
+ loading: boolean;
422
+ /** More rows remain to load. */
423
+ hasMore: boolean;
424
+ /** Rows loaded so far. */
425
+ loaded: number;
426
+ /** Source total when known, else `null`. */
427
+ total: number | null;
428
+ /** Auto-load is paused at the `autoLoadPages` checkpoint. */
429
+ paused: boolean;
430
+ /** Auto-load is currently permitted (`hasMore && !loading && !paused`) —
431
+ * used to gate an infinite-scroll sentinel. */
432
+ canLoadMore: boolean;
433
+ /** Advance one page *without* resuming a paused auto-load (the sentinel
434
+ * uses this; `loadMore` is the manual, un-pausing variant). */
435
+ advance: () => void;
436
+ }
437
+
438
+ /** Store-managed load controls (see `LoadControls`). Reads the loader's footer
439
+ * state, the loaded rows, and the pause atoms; `loadMore`/`advance` set the
440
+ * visible region so the loader fetches the next chunk. */
441
+ export function useLoadControls(): LoadControls {
442
+ const footer = ctx.useValue(tableFooterAtom);
443
+ const data = ctx.useValue(tableDataAtom) ?? [];
444
+ const { isLocalProvider } = ctx.useValue(dataProviderAtom);
445
+ const resumeBaseline = ctx.useValue(resumeBaselineAtom);
446
+ const autoLoadPages = ctx.useValue(autoLoadPagesAtom);
447
+ const setResumeBaseline = ctx.useSet(resumeBaselineAtom);
448
+ const setVisibleRegion = ctx.useSet(visibleRegionAtom);
449
+
450
+ let loadedCount = 0;
451
+ for (const row of data) if (row != null) loadedCount++;
452
+ const pageSize = footer.pageSize || 100;
453
+ const dataLength = data.length;
454
+ const hasMore = !isLocalProvider && loadedCount < dataLength;
455
+ const paused =
456
+ autoLoadPages != null &&
457
+ loadedCount - resumeBaseline >= autoLoadPages * pageSize;
458
+ const canLoadMore = hasMore && !footer.loading && !paused;
459
+
460
+ const advance = useCallback(() => {
461
+ setVisibleRegion({
462
+ rowIndexStart: 0,
463
+ rowIndexEnd: Math.min(loadedCount + pageSize, dataLength),
464
+ });
465
+ }, [setVisibleRegion, loadedCount, pageSize, dataLength]);
466
+
467
+ const loadMore = useCallback(() => {
468
+ setResumeBaseline(loadedCount);
469
+ advance();
470
+ }, [setResumeBaseline, loadedCount, advance]);
471
+
472
+ return {
473
+ loadMore,
474
+ loading: footer.loading,
475
+ hasMore,
476
+ loaded: footer.loaded,
477
+ total: footer.total,
478
+ paused,
479
+ canLoadMore,
480
+ advance,
481
+ };
482
+ }
483
+
320
484
  export interface ViewInfo {
321
485
  visibleRegion: RowRegion;
322
486
  totalCount: number | null;
@@ -383,30 +547,45 @@ function buildPostgrestOrderClauses(
383
547
  sorts: (ColumnSortEntry | PostgrestOrder<any>)[],
384
548
  identityOrder: PostgrestOrder<any> | string,
385
549
  ): PostgrestOrder<any>[] {
386
- // Clause to build ordering for a Postgrest table.
387
- // There must be an ordering by identity key, and it must be last...
550
+ // Build the ORDER BY for a PostgREST query. Two invariants:
551
+ // 1. Each column appears at most once. Keyset pagination adds a `gt`/`lt`
552
+ // cursor predicate per order clause, so a duplicated column (e.g. the
553
+ // identity key present in both a base order and an active sort, with
554
+ // opposite directions) would emit contradictory `col=lt.X&col=gt.X`
555
+ // bounds that match nothing — an infinite empty-result reload. First
556
+ // occurrence wins (active sorts should be passed ahead of base order).
557
+ // 2. The identity key is ordered last (a stable tiebreaker for the cursor),
558
+ // appended with its default direction only if no clause already sorts it.
388
559
  const identitySort =
389
560
  typeof identityOrder == "string"
390
561
  ? { key: identityOrder, ascending: true }
391
562
  : identityOrder;
392
563
  const identityKey = identitySort.key;
393
- const clauses: PostgrestOrder<any>[] = sorts.map((sort) => {
394
- return {
564
+
565
+ const seen = new Set<string>();
566
+ const clauses: PostgrestOrder<any>[] = [];
567
+ for (const sort of sorts) {
568
+ if (seen.has(sort.key)) continue;
569
+ seen.add(sort.key);
570
+ clauses.push({
395
571
  key: sort.key,
396
572
  ascending: sort.ascending,
397
573
  nullsFirst: "nullsFirst" in sort ? sort.nullsFirst : false,
398
- };
399
- });
400
- // sort the clauses so the identity clause is last
401
- const hasIdentityClause = clauses.some((d) => d.key === identityKey);
402
- if (hasIdentityClause) {
403
- clauses.sort((a, b) => {
404
- if (a.key === identityKey) return 1;
405
- if (b.key === identityKey) return -1;
406
- return 0;
407
574
  });
575
+ }
576
+
577
+ if (seen.has(identityKey)) {
578
+ // Move the (already-deduped) identity clause to the end, keeping the
579
+ // direction the active sort chose.
580
+ const idx = clauses.findIndex((c) => c.key === identityKey);
581
+ const [idClause] = clauses.splice(idx, 1);
582
+ clauses.push(idClause);
408
583
  } else {
409
- clauses.push(identitySort);
584
+ clauses.push({
585
+ key: identitySort.key,
586
+ ascending: identitySort.ascending ?? true,
587
+ nullsFirst: (identitySort as any).nullsFirst ?? false,
588
+ });
410
589
  }
411
590
  return clauses;
412
591
  }
@@ -433,140 +612,6 @@ export function useScrollHandler() {
433
612
  );
434
613
  }
435
614
 
436
- /** The active view state (a filter's id / column / config), passed to a
437
- * `fetchChunk`. A server provider translates `columnKey` + `state` into a
438
- * query; a local (in-memory) provider applies `predicate` directly. Both come
439
- * from the same `TableFilter`, so one filter definition serves either target. */
440
- export interface FetchDataFilter {
441
- id: string;
442
- columnKey?: string;
443
- state: any;
444
- /** Client-side row predicate (from the `TableFilter`). Server providers
445
- * ignore it and translate `columnKey` + `state` instead. */
446
- predicate?: (row: any, state: any) => boolean;
447
- }
448
-
449
- /** Parameters passed to a `fetchChunk` implementation for one window. */
450
- export interface FetchDataParams {
451
- /** Row offset of the requested chunk (chunk-aligned). */
452
- offset: number;
453
- /** Maximum rows to return. */
454
- limit: number;
455
- /** Aborts when the request is superseded (view change / unmount). */
456
- signal: AbortSignal;
457
- /** Active sorts, in priority order. */
458
- sorts: ColumnSort[];
459
- /** Active filters (id + column + config). */
460
- filters: FetchDataFilter[];
461
- /** In scroll mode, the already-loaded row immediately before this chunk
462
- * (and its data-array index), or `null` at the start / in paged mode. Keyset
463
- * sources can page from this cursor (e.g. `WHERE key > cursor`) instead of a
464
- * slow `OFFSET`; offset-based sources can ignore it. */
465
- cursor?: { row: any; index: number } | null;
466
- }
467
-
468
- /** Result of a `fetchChunk` call. `totalCount` reports the source length when
469
- * known (drives sparse-array pre-sizing and a proportional scrollbar); omit it
470
- * for unknown-length sources (the array grows as chunks arrive). */
471
- export interface FetchDataResult<T = any> {
472
- rows: T[];
473
- totalCount?: number | null;
474
- }
475
-
476
- export type FetchData<T = any> = (
477
- params: FetchDataParams,
478
- ) => Promise<FetchDataResult<T>>;
479
-
480
- /**
481
- * A table's data source, addressed uniformly whether it's an in-memory array or
482
- * a remote backend. `fetchChunk` returns a window with the active sorts/filters
483
- * already applied (in memory by the local provider, in SQL by a server one);
484
- * `identity` addresses a row for edits/mutations — stable across re-sorts,
485
- * unlike an array index. The mutation ops are present only for editable /
486
- * persisting sources. The in-memory case (`createLocalProvider`) is just the
487
- * degenerate implementation, so local and server tables share one path.
488
- */
489
- export interface TableDataProvider<T = any> {
490
- fetchData(params: FetchDataParams): Promise<FetchDataResult<T>>;
491
- identity(row: T): string | number;
492
- saveRows?(rows: T[]): Promise<void>;
493
- deleteRows?(ids: Array<string | number>): Promise<void>;
494
- insertRow?(row: Partial<T>): Promise<void>;
495
- }
496
-
497
- /**
498
- * The degenerate provider: an in-memory array. `fetchChunk` applies the active
499
- * filter predicates and sorts over the array and returns the requested slice
500
- * plus the (fully-known) total — the same view engine used for client-side
501
- * tables, expressed as a provider.
502
- */
503
- export function createLocalProvider<T = any>(
504
- data: T[],
505
- options: { identity?: (row: T) => string | number } = {},
506
- ): TableDataProvider<T> {
507
- const identity: (row: T) => string | number =
508
- options.identity ?? defaultLocalIdentity;
509
- return {
510
- identity,
511
- async fetchData({ offset, limit, sorts, filters }) {
512
- let rows = data;
513
- if (filters != null && filters.length > 0) {
514
- rows = rows.filter((row) =>
515
- filters.every((f) =>
516
- f.predicate != null ? f.predicate(row, f.state) : true,
517
- ),
518
- );
519
- }
520
- if (sorts != null && sorts.length > 0) {
521
- rows = [...rows].sort(compareRowsBySorts(sorts));
522
- }
523
- return {
524
- rows: rows.slice(offset, offset + limit),
525
- totalCount: rows.length,
526
- };
527
- },
528
- };
529
- }
530
-
531
- // Stable synthetic identity for in-memory rows lacking a natural `id`. Keyed by
532
- // object reference (a local data array keeps the same row objects across
533
- // re-sorts), so edits survive re-ordering even without an id field.
534
- const _syntheticRowIds = new WeakMap<object, string>();
535
- let _syntheticRowCounter = 0;
536
- function defaultLocalIdentity(row: any): string | number | undefined {
537
- if (row == null) return undefined;
538
- if (row.id != null) return row.id;
539
- if (typeof row !== "object") return row;
540
- let id = _syntheticRowIds.get(row);
541
- if (id == null) {
542
- id = `__row_${_syntheticRowCounter++}`;
543
- _syntheticRowIds.set(row, id);
544
- }
545
- return id;
546
- }
547
-
548
- /** Multi-key row comparator (priority order; nulls first when ascending),
549
- * shared by the local provider and any other in-memory sort. */
550
- export function compareRowsBySorts(sorts: ColumnSort[]) {
551
- return (a: any, b: any): number => {
552
- for (const sort of sorts) {
553
- const av = a?.[sort.key];
554
- const bv = b?.[sort.key];
555
- if (av == null && bv == null) continue;
556
- if (av == null) return sort.ascending ? -1 : 1;
557
- if (bv == null) return sort.ascending ? 1 : -1;
558
- const cmp = av < bv ? -1 : av > bv ? 1 : 0;
559
- if (cmp !== 0) return sort.ascending ? cmp : -cmp;
560
- }
561
- return 0;
562
- };
563
- }
564
-
565
- export interface FetchDataOptions {
566
- pageSize?: number;
567
- fetchMode?: FetchMode;
568
- }
569
-
570
615
  /**
571
616
  * A generic, backend-agnostic windowed data source. Give it a `fetchChunk`
572
617
  * function and it drives the sheet's lazy loading: it loads the chunk covering
@@ -584,6 +629,9 @@ export function useDataLoader<T = any>(
584
629
  ) {
585
630
  const { pageSize = 100, fetchMode = "scroll" } = options;
586
631
  const [state, dispatch] = useLazyLoaderReducer();
632
+
633
+ const { isLocalProvider, provider } = ctx.useValue(dataProviderAtom);
634
+
587
635
  const visibleRegion = ctx.useValue(visibleRegionAtom);
588
636
  const page = ctx.useValue(chunkPageAtom);
589
637
  const setPage = ctx.useSet(chunkPageAtom);
@@ -728,6 +776,11 @@ export function createPostgRESTFetchChunk<T = any>(config: {
728
776
  endpoint: string;
729
777
  table: string;
730
778
  identityKey: string;
779
+ /** Default ordering direction of the identity key (applied when no active
780
+ * sort targets it). `false` ⇒ the table defaults to identity-descending
781
+ * (e.g. newest `source_id` first) without a redundant `baseOrder` entry that
782
+ * would otherwise collide with the identity tiebreaker. Defaults to `true`. */
783
+ identityAscending?: boolean;
731
784
  columns?: string | string[];
732
785
  /** Order applied before the active column sorts (identity key appended last). */
733
786
  baseOrder?: PostgrestOrder<any>[];
@@ -743,9 +796,12 @@ export function createPostgRESTFetchChunk<T = any>(config: {
743
796
  return async ({ limit, signal, sorts, filters, cursor }) => {
744
797
  const client = new PostgrestClient(config.endpoint).from(config.table);
745
798
 
799
+ // Active sorts first so they win the by-key dedupe in
800
+ // `buildPostgrestOrderClauses` (a user sort on the identity column
801
+ // overrides its default direction rather than colliding with it).
746
802
  const order: PostgrestOrder<any>[] = [
747
- ...(config.baseOrder ?? []),
748
803
  ...sorts.map((s) => ({ key: s.key, ascending: s.ascending })),
804
+ ...(config.baseOrder ?? []),
749
805
  ];
750
806
 
751
807
  const pgFilters: PostgrestFilter[] = [];
@@ -764,6 +820,10 @@ export function createPostgRESTFetchChunk<T = any>(config: {
764
820
  count: cursor == null ? "exact" : undefined,
765
821
  limit,
766
822
  identityKey: config.identityKey,
823
+ identityOrder: {
824
+ key: config.identityKey,
825
+ ascending: config.identityAscending ?? true,
826
+ },
767
827
  order,
768
828
  filters: pgFilters,
769
829
  lastLoadedRow: cursor?.row ?? null,
@@ -788,6 +848,9 @@ export function createPostgRESTProvider<T = any>(config: {
788
848
  endpoint: string;
789
849
  table: string;
790
850
  identityKey: string;
851
+ /** Default ordering direction of the identity key (see
852
+ * `createPostgRESTFetchChunk`). `false` ⇒ identity-descending by default. */
853
+ identityAscending?: boolean;
791
854
  columns?: string | string[];
792
855
  baseOrder?: PostgrestOrder<any>[];
793
856
  baseFilter?: (
@@ -829,7 +892,13 @@ function indexOfFirstNullInRegion(
829
892
  data: any[],
830
893
  region: RowRegion,
831
894
  ): number | null {
832
- for (let i = region.rowIndexStart; i < region.rowIndexEnd; i++) {
895
+ // Clamp to the array length: a visible region can outlast the data it was
896
+ // set against (e.g. a keyset page hits the end of a filtered set and the
897
+ // array shrinks below a region end set before the shrink). Scanning past
898
+ // `data.length` reads `undefined` as a fillable null and re-fetches the same
899
+ // now-out-of-range offset forever — the tail-of-filtered-set reload loop.
900
+ const end = Math.min(region.rowIndexEnd, data.length);
901
+ for (let i = region.rowIndexStart; i < end; i++) {
833
902
  if (data[i] == null) {
834
903
  return i;
835
904
  }
@@ -1,20 +1,19 @@
1
1
  import { InputGroup, OverlayToaster } from "@blueprintjs/core";
2
2
  import h from "./main.module.sass";
3
- import { DataSheet } from "../core";
3
+ import { DataSheet } from "../data-sheet.ts";
4
4
  import { LithologyTag, Tag, TagSize } from "@macrostrat/data-components";
5
5
  import {
6
6
  createPostgRESTProvider,
7
- dataRefreshTokenAtom,
8
7
  PostgrestFilter,
9
8
  PostgrestOrder,
10
9
  } from "./data-loaders";
11
- import { useCallback, useEffect, useMemo, useRef } from "react";
10
+ import { ReactNode, useCallback, useEffect, useMemo, useRef } from "react";
12
11
  import { ErrorBoundary, ToasterContext } from "@macrostrat/ui-components";
13
12
  import { PostgrestFilterBuilder } from "@supabase/postgrest-js";
14
13
  import { ColorCell } from "../components";
15
- import { DataSheetProviderProps } from "../types.ts";
14
+ import { DataSheetProviderProps } from "../provider/types.ts";
16
15
  import { atom } from "jotai";
17
- import { columnSpecAtom, ctx } from "../provider.ts";
16
+ import { columnSpecAtom, ctx, dataRefreshTokenAtom } from "../provider";
18
17
  import { ALL_CARDINALITIES, TableAction } from "../actions";
19
18
 
20
19
  export * from "./data-loaders";
@@ -47,7 +46,9 @@ interface PostgRESTTableViewProps<
47
46
  ): PostgrestFilterBuilder<T, any, any, any>;
48
47
  }
49
48
 
50
- export function PostgRESTTableView<T>(props: PostgRESTTableViewProps<T>) {
49
+ export function PostgRESTTableView<T extends object>(
50
+ props: PostgRESTTableViewProps<T>,
51
+ ) {
51
52
  return h(
52
53
  ErrorBoundary,
53
54
  h(ctx.Provider, h(ToasterContext, h(_PostgRESTTableView, props))),
@@ -104,10 +105,10 @@ function _PostgRESTTableView<T>({
104
105
  editable = false,
105
106
  enableFullTableSearch = false,
106
107
  actions,
107
- identityKey = null,
108
+ identityKey,
108
109
  filter: userFilter,
109
110
  ...rest
110
- }: PostgRESTTableViewProps<T>) {
111
+ }: PostgRESTTableViewProps<any>) {
111
112
  // Boundary of Jotai store
112
113
  ctx.useSync(enableFullTextSearchAtom, enableFullTableSearch);
113
114
 
@@ -197,7 +198,7 @@ export function notifyOnError(toaster: OverlayToaster, error: any) {
197
198
  console.error(error);
198
199
  const { message, status, code, details } = error;
199
200
 
200
- let errorDetails = null;
201
+ let errorDetails: ReactNode = null;
201
202
 
202
203
  if (details != null) {
203
204
  if (typeof details === "string") {