@macrostrat/data-sheet 4.4.1 → 4.5.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 (48) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/dist/data-panel.cjs +3 -1
  3. package/dist/data-panel.cjs.map +1 -1
  4. package/dist/data-panel.d.ts +1 -1
  5. package/dist/data-panel.js +3 -1
  6. package/dist/data-panel.js.map +1 -1
  7. package/dist/data-sheet.cjs +3 -1
  8. package/dist/data-sheet.cjs.map +1 -1
  9. package/dist/data-sheet.d.ts +1 -1
  10. package/dist/data-sheet.js +3 -1
  11. package/dist/data-sheet.js.map +1 -1
  12. package/dist/index.cjs +4 -0
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.js +5 -1
  15. package/dist/index.js.map +1 -1
  16. package/dist/postgrest-table/data-loaders.cjs +67 -2
  17. package/dist/postgrest-table/data-loaders.cjs.map +1 -1
  18. package/dist/postgrest-table/data-loaders.d.ts +8 -1
  19. package/dist/postgrest-table/data-loaders.js +67 -2
  20. package/dist/postgrest-table/data-loaders.js.map +1 -1
  21. package/dist/provider/core.cjs +23 -2
  22. package/dist/provider/core.cjs.map +1 -1
  23. package/dist/provider/core.d.ts +2 -2
  24. package/dist/provider/core.js +23 -2
  25. package/dist/provider/core.js.map +1 -1
  26. package/dist/provider/distinct-values.cjs +65 -0
  27. package/dist/provider/distinct-values.cjs.map +1 -0
  28. package/dist/provider/distinct-values.d.ts +21 -0
  29. package/dist/provider/distinct-values.js +65 -0
  30. package/dist/provider/distinct-values.js.map +1 -0
  31. package/dist/provider/index.d.ts +1 -0
  32. package/dist/provider/table-data.cjs +21 -0
  33. package/dist/provider/table-data.cjs.map +1 -1
  34. package/dist/provider/table-data.d.ts +22 -0
  35. package/dist/provider/table-data.js +21 -0
  36. package/dist/provider/table-data.js.map +1 -1
  37. package/dist/types.cjs.map +1 -1
  38. package/dist/types.d.ts +27 -4
  39. package/dist/types.js.map +1 -1
  40. package/package.json +1 -1
  41. package/src/data-panel.ts +3 -1
  42. package/src/data-sheet.ts +3 -1
  43. package/src/postgrest-table/data-loaders.ts +106 -3
  44. package/src/provider/core.ts +36 -3
  45. package/src/provider/distinct-values.ts +127 -0
  46. package/src/provider/index.ts +1 -0
  47. package/src/provider/table-data.ts +51 -0
  48. package/src/types.ts +33 -4
package/src/types.ts CHANGED
@@ -8,16 +8,37 @@ import {
8
8
  TableElementStatus,
9
9
  VisibleCells,
10
10
  } from "./provider";
11
- import type { ColumnSpec, ColumnSpecOptions } from "./provider";
11
+ import type { ColumnSort, ColumnSpec, ColumnSpecOptions } from "./provider";
12
12
  import { ReactNode } from "react";
13
- import { TableAction, TableActionContext, TableFilter } from "./actions";
13
+ import {
14
+ ActiveFilterEntry,
15
+ TableAction,
16
+ TableActionContext,
17
+ TableFilter,
18
+ } from "./actions";
14
19
  import { Region, TableProps } from "@blueprintjs/table";
15
20
 
16
21
  export type FetchMode = "scroll" | "paged";
17
22
 
18
- export interface FetchDataOptions {
23
+ export interface InitialDataChunk<T = any> {
24
+ rows: T[];
25
+ /** Total rows in the source, when the caller's fetch reported it. */
26
+ totalCount?: number | null;
27
+ }
28
+
29
+ export interface FetchDataOptions<T = any> {
19
30
  pageSize?: number;
20
31
  fetchMode?: FetchMode;
32
+ /** Rows already in hand for the first window — typically fetched outside the
33
+ * view (a server render, a parent that needed the data anyway) — so mounting
34
+ * doesn't re-request a page the caller already has. The loader starts
35
+ * populated and initialized; scrolling past the seed fetches as usual, and any
36
+ * view change discards it and re-fetches (the seed only describes the view it
37
+ * was fetched for, so pass matching `initialFilters` / `initialSorts`).
38
+ *
39
+ * Pass `totalCount` when it's known — the array is pre-sized to it, so the
40
+ * scrollbar and the counter are right from the first paint. */
41
+ initialData?: T[] | InitialDataChunk<T>;
21
42
  /** Debounce (ms) applied to view-state → refetch, so rapid changes (typing a
22
43
  * text filter) collapse into one fetch once the view settles. The input stays
23
44
  * instant; only the fetch waits. `0` (default) keeps immediate refetching. */
@@ -57,10 +78,18 @@ export interface DataViewCoreProps<T> extends InteractionOptions {
57
78
  /** Bump to force a re-fetch from scratch (e.g. after an immediate edit that
58
79
  * mutated rows through the provider). */
59
80
  refreshToken?: number | string;
81
+ /** Filters active from the start, applied when the store is *created* rather
82
+ * than in an effect — so a restored view (from a link, a saved query, a
83
+ * server render) never fires an unfiltered fetch first and immediately
84
+ * supersedes it. Uncontrolled: the user's later changes win, and changing
85
+ * this prop afterwards does nothing. */
86
+ initialFilters?: ActiveFilterEntry[];
87
+ /** Sorts active from the start. Same contract as `initialFilters`. */
88
+ initialSorts?: ColumnSort[];
60
89
  }
61
90
 
62
91
  export interface DataViewSharedProps<T = any>
63
- extends FetchDataOptions, DataViewCoreProps<T> {
92
+ extends FetchDataOptions<T>, DataViewCoreProps<T> {
64
93
  /** Configurable table actions shown in a selection-aware toolbar.
65
94
  * When provided, the actions toolbar renders alongside the existing
66
95
  * edit toolbar. Actions are filtered by the current selection cardinality. */