@macrostrat/data-sheet 4.0.0-dev3 → 4.0.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 (212) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/README.md +44 -0
  3. package/dist/actions/builtin.cjs +36 -5
  4. package/dist/actions/builtin.cjs.map +1 -1
  5. package/dist/actions/builtin.d.ts +3 -2
  6. package/dist/actions/builtin.js +36 -5
  7. package/dist/actions/builtin.js.map +1 -1
  8. package/dist/actions/column-controls.cjs +149 -0
  9. package/dist/actions/column-controls.cjs.map +1 -0
  10. package/dist/actions/column-controls.d.ts +11 -0
  11. package/dist/actions/column-controls.js +147 -0
  12. package/dist/actions/column-controls.js.map +1 -0
  13. package/dist/actions/column-filter.cjs +68 -0
  14. package/dist/actions/column-filter.cjs.map +1 -0
  15. package/dist/actions/column-filter.d.ts +11 -0
  16. package/dist/actions/column-filter.js +66 -0
  17. package/dist/actions/column-filter.js.map +1 -0
  18. package/dist/actions/edit-actions.cjs +42 -0
  19. package/dist/actions/edit-actions.cjs.map +1 -0
  20. package/dist/actions/edit-actions.d.ts +14 -0
  21. package/dist/actions/edit-actions.js +42 -0
  22. package/dist/actions/edit-actions.js.map +1 -0
  23. package/dist/actions/filters.cjs +39 -23
  24. package/dist/actions/filters.cjs.map +1 -1
  25. package/dist/actions/filters.d.ts +6 -3
  26. package/dist/actions/filters.js +41 -25
  27. package/dist/actions/filters.js.map +1 -1
  28. package/dist/actions/index.d.ts +4 -0
  29. package/dist/actions/selection.cjs +39 -30
  30. package/dist/actions/selection.cjs.map +1 -1
  31. package/dist/actions/selection.d.ts +3 -7
  32. package/dist/actions/selection.js +39 -30
  33. package/dist/actions/selection.js.map +1 -1
  34. package/dist/actions/table-controls.cjs +41 -0
  35. package/dist/actions/table-controls.cjs.map +1 -0
  36. package/dist/actions/table-controls.d.ts +4 -0
  37. package/dist/actions/table-controls.js +39 -0
  38. package/dist/actions/table-controls.js.map +1 -0
  39. package/dist/actions/toolbar.cjs +69 -10
  40. package/dist/actions/toolbar.cjs.map +1 -1
  41. package/dist/actions/toolbar.d.ts +9 -6
  42. package/dist/actions/toolbar.js +69 -10
  43. package/dist/actions/toolbar.js.map +1 -1
  44. package/dist/actions/toolbar.module.sass.cjs +12 -7
  45. package/dist/actions/toolbar.module.sass.cjs.map +1 -1
  46. package/dist/actions/toolbar.module.sass.js +12 -7
  47. package/dist/actions/toolbar.module.sass.js.map +1 -1
  48. package/dist/actions/types.d.ts +49 -4
  49. package/dist/cell-renderer.cjs +150 -14
  50. package/dist/cell-renderer.cjs.map +1 -1
  51. package/dist/cell-renderer.d.ts +1 -1
  52. package/dist/cell-renderer.js +151 -15
  53. package/dist/cell-renderer.js.map +1 -1
  54. package/dist/components/cell-detail.cjs +24 -0
  55. package/dist/components/cell-detail.cjs.map +1 -0
  56. package/dist/components/cell-detail.d.ts +12 -0
  57. package/dist/components/cell-detail.js +24 -0
  58. package/dist/components/cell-detail.js.map +1 -0
  59. package/dist/components/editor-popup.cjs +28 -24
  60. package/dist/components/editor-popup.cjs.map +1 -1
  61. package/dist/components/editor-popup.js +29 -25
  62. package/dist/components/editor-popup.js.map +1 -1
  63. package/dist/components/index.d.ts +2 -2
  64. package/dist/components/text-areas.cjs +51 -7
  65. package/dist/components/text-areas.cjs.map +1 -1
  66. package/dist/components/text-areas.d.ts +4 -1
  67. package/dist/components/text-areas.js +51 -7
  68. package/dist/components/text-areas.js.map +1 -1
  69. package/dist/components/view-info.cjs +46 -9
  70. package/dist/components/view-info.cjs.map +1 -1
  71. package/dist/components/view-info.d.ts +5 -1
  72. package/dist/components/view-info.js +47 -10
  73. package/dist/components/view-info.js.map +1 -1
  74. package/dist/core.cjs +167 -73
  75. package/dist/core.cjs.map +1 -1
  76. package/dist/core.d.ts +53 -6
  77. package/dist/core.js +169 -75
  78. package/dist/core.js.map +1 -1
  79. package/dist/data-sheet.css +72 -123
  80. package/dist/filters/operators.cjs +91 -0
  81. package/dist/filters/operators.cjs.map +1 -0
  82. package/dist/filters/operators.d.ts +17 -0
  83. package/dist/filters/operators.js +91 -0
  84. package/dist/filters/operators.js.map +1 -0
  85. package/dist/index.cjs +38 -10
  86. package/dist/index.cjs.map +1 -1
  87. package/dist/index.d.ts +2 -0
  88. package/dist/index.js +44 -16
  89. package/dist/index.js.map +1 -1
  90. package/dist/main.module.sass.cjs +13 -12
  91. package/dist/main.module.sass.cjs.map +1 -1
  92. package/dist/main.module.sass.js +13 -12
  93. package/dist/main.module.sass.js.map +1 -1
  94. package/dist/postgrest-table/data-loaders.cjs +255 -146
  95. package/dist/postgrest-table/data-loaders.cjs.map +1 -1
  96. package/dist/postgrest-table/data-loaders.d.ts +144 -46
  97. package/dist/postgrest-table/data-loaders.js +259 -150
  98. package/dist/postgrest-table/data-loaders.js.map +1 -1
  99. package/dist/postgrest-table/index.cjs +58 -169
  100. package/dist/postgrest-table/index.cjs.map +1 -1
  101. package/dist/postgrest-table/index.d.ts +5 -2
  102. package/dist/postgrest-table/index.js +63 -174
  103. package/dist/postgrest-table/index.js.map +1 -1
  104. package/dist/postgrest-table/loading-utils.cjs +0 -4
  105. package/dist/postgrest-table/loading-utils.cjs.map +1 -1
  106. package/dist/postgrest-table/loading-utils.js +1 -5
  107. package/dist/postgrest-table/loading-utils.js.map +1 -1
  108. package/dist/postgrest-table/main.module.sass.cjs +14 -13
  109. package/dist/postgrest-table/main.module.sass.cjs.map +1 -1
  110. package/dist/postgrest-table/main.module.sass.js +14 -13
  111. package/dist/postgrest-table/main.module.sass.js.map +1 -1
  112. package/dist/provider.cjs +68 -11
  113. package/dist/provider.cjs.map +1 -1
  114. package/dist/provider.d.ts +25 -0
  115. package/dist/provider.js +68 -11
  116. package/dist/provider.js.map +1 -1
  117. package/dist/renderers/column-header-cell.cjs +95 -75
  118. package/dist/renderers/column-header-cell.cjs.map +1 -1
  119. package/dist/renderers/column-header-cell.d.ts +3 -18
  120. package/dist/renderers/column-header-cell.js +98 -78
  121. package/dist/renderers/column-header-cell.js.map +1 -1
  122. package/dist/renderers/index.d.ts +0 -1
  123. package/dist/types.cjs +2 -0
  124. package/dist/types.cjs.map +1 -1
  125. package/dist/types.d.ts +84 -1
  126. package/dist/types.js +2 -0
  127. package/dist/types.js.map +1 -1
  128. package/dist/utils/column-spec.cjs.map +1 -1
  129. package/dist/utils/column-spec.d.ts +101 -1
  130. package/dist/utils/column-spec.js.map +1 -1
  131. package/dist/utils/debug-overlay.cjs +24 -0
  132. package/dist/utils/debug-overlay.cjs.map +1 -0
  133. package/dist/utils/debug-overlay.d.ts +4 -0
  134. package/dist/utils/debug-overlay.js +24 -0
  135. package/dist/utils/debug-overlay.js.map +1 -0
  136. package/dist/utils/index.cjs.map +1 -1
  137. package/dist/utils/index.d.ts +2 -0
  138. package/dist/utils/index.js.map +1 -1
  139. package/dist/utils/key-handling.cjs +52 -6
  140. package/dist/utils/key-handling.cjs.map +1 -1
  141. package/dist/utils/key-handling.js +52 -6
  142. package/dist/utils/key-handling.js.map +1 -1
  143. package/dist/utils/validation.cjs +41 -0
  144. package/dist/utils/validation.cjs.map +1 -0
  145. package/dist/utils/validation.d.ts +26 -0
  146. package/dist/utils/validation.js +41 -0
  147. package/dist/utils/validation.js.map +1 -0
  148. package/dist/zustand-store.cjs +119 -61
  149. package/dist/zustand-store.cjs.map +1 -1
  150. package/dist/zustand-store.js +121 -63
  151. package/dist/zustand-store.js.map +1 -1
  152. package/package.json +3 -3
  153. package/src/actions/builtin.ts +62 -7
  154. package/src/actions/column-controls.ts +185 -0
  155. package/src/actions/column-filter.ts +104 -0
  156. package/src/actions/edit-actions.ts +67 -0
  157. package/src/actions/filters.ts +54 -28
  158. package/src/actions/index.ts +4 -0
  159. package/src/actions/selection.ts +59 -52
  160. package/src/actions/table-controls.ts +46 -0
  161. package/src/actions/toolbar.module.sass +22 -2
  162. package/src/actions/toolbar.ts +113 -16
  163. package/src/actions/types.ts +49 -4
  164. package/src/cell-renderer.ts +211 -16
  165. package/src/components/cell-detail.ts +30 -0
  166. package/src/components/editor-popup.ts +39 -25
  167. package/src/components/index.ts +2 -2
  168. package/src/components/text-areas.ts +80 -16
  169. package/src/components/view-info.ts +63 -4
  170. package/src/core.ts +321 -103
  171. package/src/filters/operators.ts +127 -0
  172. package/src/index.ts +2 -0
  173. package/src/main.module.sass +6 -0
  174. package/src/postgrest-table/data-loaders.ts +459 -209
  175. package/src/postgrest-table/index.ts +81 -254
  176. package/src/postgrest-table/main.module.sass +11 -0
  177. package/src/provider.ts +109 -12
  178. package/src/renderers/column-header-cell.ts +60 -272
  179. package/src/renderers/index.ts +0 -1
  180. package/src/types.ts +76 -2
  181. package/src/utils/column-spec.ts +112 -1
  182. package/src/utils/debug-overlay.ts +22 -0
  183. package/src/utils/index.ts +2 -0
  184. package/src/utils/key-handling.ts +70 -6
  185. package/src/utils/validation.ts +72 -0
  186. package/src/zustand-store.ts +167 -60
  187. package/dist/components/actions.cjs +0 -12
  188. package/dist/components/actions.cjs.map +0 -1
  189. package/dist/components/actions.d.ts +0 -2
  190. package/dist/components/actions.js +0 -12
  191. package/dist/components/actions.js.map +0 -1
  192. package/dist/components/actions.module.sass.cjs +0 -12
  193. package/dist/components/actions.module.sass.cjs.map +0 -1
  194. package/dist/components/actions.module.sass.js +0 -11
  195. package/dist/components/actions.module.sass.js.map +0 -1
  196. package/dist/postgrest-table/lazy-loader-table.cjs +0 -27
  197. package/dist/postgrest-table/lazy-loader-table.cjs.map +0 -1
  198. package/dist/postgrest-table/lazy-loader-table.d.ts +0 -3
  199. package/dist/postgrest-table/lazy-loader-table.js +0 -27
  200. package/dist/postgrest-table/lazy-loader-table.js.map +0 -1
  201. package/dist/renderers/column-header-cell-postgrest.cjs +0 -216
  202. package/dist/renderers/column-header-cell-postgrest.cjs.map +0 -1
  203. package/dist/renderers/column-header-cell-postgrest.d.ts +0 -13
  204. package/dist/renderers/column-header-cell-postgrest.js +0 -216
  205. package/dist/renderers/column-header-cell-postgrest.js.map +0 -1
  206. package/dist/renderers/column-header-cell-postgrest.module.sass.cjs +0 -23
  207. package/dist/renderers/column-header-cell-postgrest.module.sass.cjs.map +0 -1
  208. package/dist/renderers/column-header-cell-postgrest.module.sass.js +0 -22
  209. package/dist/renderers/column-header-cell-postgrest.module.sass.js.map +0 -1
  210. package/src/components/actions.ts +0 -9
  211. package/src/postgrest-table/lazy-loader-table.ts +0 -25
  212. package/src/renderers/column-header-cell-postgrest.ts +0 -282
@@ -1,25 +0,0 @@
1
- import h from "./main.module.sass";
2
- import { DataSheet } from "../core";
3
- import { useTestLazyLoader } from "./data-loaders";
4
-
5
- export function TestLazyLoaderTableView<T>({ ...rest }) {
6
- return h("div.data-sheet-outer", [
7
- h(
8
- DataSheet,
9
- {
10
- ...rest,
11
- editable: false,
12
- },
13
- [
14
- h(TestLazyLoaderManager, {
15
- key: "test-lazy-loader-manager",
16
- }),
17
- ],
18
- ),
19
- ]);
20
- }
21
-
22
- function TestLazyLoaderManager() {
23
- useTestLazyLoader();
24
- return null;
25
- }
@@ -1,282 +0,0 @@
1
- /**
2
- * Column header with server-side sort and filter controls.
3
- *
4
- * Uses Blueprint's ColumnHeaderCell `menuRenderer` prop to provide a
5
- * dropdown menu with sort direction toggles and a filter input.
6
- * The `nameRenderer` prop shows the column name plus visual indicators
7
- * for any active sort or filter.
8
- */
9
- import { ColumnHeaderCell, ColumnHeaderCellProps } from "@blueprintjs/table";
10
- import {
11
- Button,
12
- ButtonGroup,
13
- HTMLSelect,
14
- Icon,
15
- InputGroup,
16
- Menu,
17
- } from "@blueprintjs/core";
18
- import { useCallback, useRef, useState } from "react";
19
- import h from "./column-header-cell-postgrest.module.sass";
20
- import type { ColumnSpec, ColumnDataType } from "../utils/column-spec";
21
- import type {
22
- ColumnSortEntry,
23
- PostgrestColumnFilter,
24
- PostgrestFilterOperator,
25
- } from "../postgrest-table/data-loaders";
26
- import { ColumnHeaderRendererProps } from "./column-header-cell";
27
-
28
- /** Operators appropriate for string columns. */
29
- const STRING_FILTER_OPERATORS: PostgrestFilterOperator[] = [
30
- "eq",
31
- "neq",
32
- "ilike",
33
- ];
34
-
35
- /** Operators appropriate for numeric / integer columns. */
36
- const NUMERIC_FILTER_OPERATORS: PostgrestFilterOperator[] = [
37
- "eq",
38
- "neq",
39
- "gt",
40
- "lt",
41
- "gte",
42
- "lte",
43
- ];
44
-
45
- /** Operators appropriate for boolean columns. */
46
- const BOOLEAN_FILTER_OPERATORS: PostgrestFilterOperator[] = ["eq", "neq"];
47
-
48
- /** Fallback operators when no type information is available. */
49
- const DEFAULT_FILTER_OPERATORS: PostgrestFilterOperator[] = [
50
- "eq",
51
- "neq",
52
- "ilike",
53
- "gt",
54
- "lt",
55
- "gte",
56
- "lte",
57
- ];
58
-
59
- /** Map from data type to the appropriate set of filter operators. */
60
- const OPERATORS_BY_TYPE: Record<string, PostgrestFilterOperator[]> = {
61
- string: STRING_FILTER_OPERATORS,
62
- number: NUMERIC_FILTER_OPERATORS,
63
- integer: NUMERIC_FILTER_OPERATORS,
64
- boolean: BOOLEAN_FILTER_OPERATORS,
65
- };
66
-
67
- export const OPERATOR_LABELS: Record<PostgrestFilterOperator, string> = {
68
- eq: "=",
69
- neq: "≠",
70
- like: "like",
71
- ilike: "contains",
72
- gt: ">",
73
- lt: "<",
74
- gte: "≥",
75
- lte: "≤",
76
- is: "is",
77
- };
78
-
79
- export interface ColumnHeaderActions {
80
- onSetSort: (key: string, ascending: boolean | null) => void;
81
- onSetFilter: (
82
- key: string,
83
- operator: PostgrestFilterOperator | null,
84
- value: string,
85
- ) => void;
86
- onClearColumn: (key: string) => void;
87
- }
88
-
89
- /** The main column header cell renderer for PostgREST tables. */
90
- export function renderPostgRESTColumnHeaderCell(
91
- props: ColumnHeaderRendererProps & { actions: ColumnHeaderActions },
92
- ): React.ReactElement<ColumnHeaderCellProps> | null {
93
- const { col, activeSort, activeFilter, actions } = props;
94
-
95
- const isSortable = col.sortable === true;
96
- const isFilterable =
97
- col.filterable === true || typeof col.filterable === "object";
98
-
99
- // If the column has no sort/filter capabilities, render a plain header
100
- if (!isSortable && !isFilterable) {
101
- return h(ColumnHeaderCell, { name: col.name });
102
- }
103
-
104
- return h(ColumnHeaderCell, {
105
- name: col.name,
106
- nameRenderer: (): any =>
107
- h(ColumnHeaderName, { col, activeFilter, activeSort }),
108
- menuRenderer: () =>
109
- h(ColumnActionsMenu, {
110
- col,
111
- isSortable,
112
- isFilterable,
113
- activeSort,
114
- activeFilter,
115
- actions,
116
- }),
117
- });
118
- }
119
-
120
- /** Column name with active sort/filter indicator icons. */
121
- function ColumnHeaderName({ col, activeSort, activeFilter }) {
122
- const hasSortActive = activeSort != null;
123
- const hasFilterActive = activeFilter != null;
124
- return h("div.column-header-cell", [
125
- h("span.column-name", col.name),
126
- h.if(hasSortActive || hasFilterActive)("span.column-indicators", [
127
- h.if(hasSortActive)(
128
- "span.sort-indicator",
129
- h(Icon, {
130
- icon: activeSort?.ascending ? "sort-asc" : "sort-desc",
131
- size: 12,
132
- }),
133
- ),
134
- h.if(hasFilterActive)(
135
- "span.filter-indicator",
136
- h(Icon, { icon: "filter", size: 12 }),
137
- ),
138
- ]),
139
- ]);
140
- }
141
-
142
- /** Resolve filter operators for a column, considering explicit config,
143
- * inferred data type, and fallback defaults. */
144
- function getOperatorsForColumn(col: ColumnSpec): PostgrestFilterOperator[] {
145
- // Explicit operators in filterable config take priority
146
- if (typeof col.filterable === "object" && col.filterable.operators?.length) {
147
- return col.filterable.operators as PostgrestFilterOperator[];
148
- }
149
- // Otherwise, pick operators based on the inferred data type
150
- if (col.dataType != null) {
151
- return OPERATORS_BY_TYPE[col.dataType] ?? DEFAULT_FILTER_OPERATORS;
152
- }
153
- return DEFAULT_FILTER_OPERATORS;
154
- }
155
-
156
- /** Menu content rendered inside ColumnHeaderCell's built-in dropdown. */
157
- function ColumnActionsMenu({
158
- col,
159
- isSortable,
160
- isFilterable,
161
- activeSort,
162
- activeFilter,
163
- actions,
164
- }) {
165
- const operators = getOperatorsForColumn(col);
166
-
167
- const [filterOperator, setFilterOperator] = useState<PostgrestFilterOperator>(
168
- activeFilter?.operator ?? operators[0],
169
- );
170
- const filterInputRef = useRef<HTMLInputElement>(null);
171
-
172
- const applyFilter = useCallback(() => {
173
- const val = filterInputRef.current?.value ?? "";
174
- if (val.trim() === "") {
175
- actions.onSetFilter(col.key, null, "");
176
- } else {
177
- actions.onSetFilter(col.key, filterOperator, val);
178
- }
179
- }, [col.key, filterOperator, actions]);
180
-
181
- const hasAnyActive =
182
- activeSort != null ||
183
- (activeFilter != null &&
184
- activeFilter.value !== "" &&
185
- activeFilter.value != null);
186
-
187
- return h(Menu, { className: "column-actions-menu" }, [
188
- h("div.column-actions-popover", [
189
- h.if(isSortable)("div.popover-section", [
190
- h("div.popover-section-title", "Sort"),
191
- h("div.sort-buttons", [
192
- h(ButtonGroup, { minimal: true }, [
193
- h(
194
- Button,
195
- {
196
- icon: "sort-asc",
197
- active: activeSort?.ascending === true,
198
- intent: activeSort?.ascending === true ? "primary" : "none",
199
- onClick() {
200
- if (activeSort?.ascending === true) {
201
- actions.onSetSort(col.key, null);
202
- } else {
203
- actions.onSetSort(col.key, true);
204
- }
205
- },
206
- },
207
- "A→Z",
208
- ),
209
- h(
210
- Button,
211
- {
212
- icon: "sort-desc",
213
- active: activeSort?.ascending === false,
214
- intent: activeSort?.ascending === false ? "primary" : "none",
215
- onClick() {
216
- if (activeSort?.ascending === false) {
217
- actions.onSetSort(col.key, null);
218
- } else {
219
- actions.onSetSort(col.key, false);
220
- }
221
- },
222
- },
223
- "Z→A",
224
- ),
225
- ]),
226
- ]),
227
- ]),
228
- h.if(isFilterable)("div.popover-section", [
229
- h("div.popover-section-title", "Filter"),
230
- h("div.filter-row", [
231
- h(HTMLSelect, {
232
- className: "filter-operator-select",
233
- value: filterOperator,
234
- options: operators.map((op) => ({
235
- value: op,
236
- label: OPERATOR_LABELS[op] ?? op,
237
- })),
238
- onChange(e) {
239
- setFilterOperator(e.target.value as PostgrestFilterOperator);
240
- },
241
- }),
242
- h(InputGroup, {
243
- className: "filter-value-input",
244
- small: true,
245
- placeholder: "Value…",
246
- defaultValue: activeFilter?.value ?? "",
247
- inputRef: filterInputRef,
248
- onKeyDown(e) {
249
- if (e.key === "Enter") {
250
- applyFilter();
251
- }
252
- },
253
- rightElement: h(Button, {
254
- icon: "arrow-right",
255
- minimal: true,
256
- small: true,
257
- onClick: applyFilter,
258
- }),
259
- }),
260
- ]),
261
- ]),
262
- h.if(hasAnyActive)("div.clear-section", [
263
- h(
264
- Button,
265
- {
266
- small: true,
267
- minimal: true,
268
- intent: "danger",
269
- icon: "cross",
270
- onClick() {
271
- actions.onClearColumn(col.key);
272
- if (filterInputRef.current) {
273
- filterInputRef.current.value = "";
274
- }
275
- },
276
- },
277
- "Clear all",
278
- ),
279
- ]),
280
- ]),
281
- ]);
282
- }