@pythia-software/query-table-react 0.1.0 → 0.3.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.
- package/README.md +9 -0
- package/dist/index.d.ts +44 -2
- package/dist/index.js +659 -115
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -20,6 +20,11 @@ function Orders({ schema, rows }) {
|
|
|
20
20
|
}
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
+
`table.selection.replace(ids)` atomically makes any iterable of stable row IDs
|
|
24
|
+
the complete selection, including IDs outside the displayed page.
|
|
25
|
+
`table.selection.retain(ids)` atomically intersects the current selection with
|
|
26
|
+
an iterable. Both operations reset the Shift-click range anchor.
|
|
27
|
+
|
|
23
28
|
## Privacy defaults
|
|
24
29
|
|
|
25
30
|
URL synchronization and durable browser storage are disabled by default. Set
|
|
@@ -31,3 +36,7 @@ is appropriate; sensitive applications should use an access-controlled server
|
|
|
31
36
|
|
|
32
37
|
See the [repository README](https://github.com/Pythia-Software/query-table#readme)
|
|
33
38
|
for transport and schema examples.
|
|
39
|
+
|
|
40
|
+
## Shared computed column definitions
|
|
41
|
+
|
|
42
|
+
Pass a stable `computedColumnStore` (for example, `httpComputedColumnStore("/api/computed-columns")` from core) to `useQueryTable`. `api.computed` exposes the catalogue, compile/preview, save with revision checking, and reload operations. Queries store only `@computed/<id>` SELECT references; formula evaluation stays in browser workers. Without a store, definitions are in memory for the mounted hook. See the repository’s `docs/computed-columns.md` for the complete integration contract and PostgreSQL adapter.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FormulaNode, FormulaValue, FormulaResult, ComputedColumn, FieldDef, ComputedColumnDraft, FormulaPlan, ColumnPreview, RowId, SelectColumn, QueryState, FieldSchema, SavedQuery, StorageAdapter, AggOp, AggregationClause, AggregationResult, WhereClause, DistinctValuesResult, OrderByClause, Transport, ComputedColumnStore } from '@pythia-software/query-table-core';
|
|
2
|
+
|
|
3
|
+
type FormulaWorkerFactory = () => Worker;
|
|
4
|
+
/** Host applications with a restrictive CSP can supply their own worker factory. */
|
|
5
|
+
declare const createFormulaWorker: FormulaWorkerFactory;
|
|
6
|
+
declare function evaluateFormulaRows(ast: FormulaNode, inputs: Record<string, FormulaValue>[], signal?: AbortSignal, factory?: FormulaWorkerFactory): Promise<FormulaResult[]>;
|
|
7
|
+
|
|
8
|
+
interface ComputedColumnsApi<Row> {
|
|
9
|
+
definitions: ComputedColumn[];
|
|
10
|
+
catalogue: FieldDef<Row>[];
|
|
11
|
+
loading: boolean;
|
|
12
|
+
error: string | null;
|
|
13
|
+
reload: () => Promise<void>;
|
|
14
|
+
save: (column: ComputedColumnDraft, expectedRevision: string | null) => Promise<ComputedColumn>;
|
|
15
|
+
compile: (source: string, editingId?: string) => FormulaPlan;
|
|
16
|
+
/** Sample the first N matching rows in current sort order, independent of table paging. */
|
|
17
|
+
preview: (source: string, count: number, signal?: AbortSignal, editingId?: string, includeInputs?: boolean) => Promise<ColumnPreview>;
|
|
18
|
+
}
|
|
2
19
|
|
|
3
20
|
interface SelectionApi {
|
|
4
21
|
selected: Set<RowId>;
|
|
@@ -9,6 +26,10 @@ interface SelectionApi {
|
|
|
9
26
|
toggle: (id: RowId, shiftKey?: boolean) => void;
|
|
10
27
|
/** Select / clear every row currently on the page. */
|
|
11
28
|
setPage: (ids: RowId[], selected: boolean) => void;
|
|
29
|
+
/** Atomically replace the complete selection with arbitrary stable row ids. */
|
|
30
|
+
replace: (ids: Iterable<RowId>) => void;
|
|
31
|
+
/** Atomically retain only selected ids that are also present in `ids`. */
|
|
32
|
+
retain: (ids: Iterable<RowId>) => void;
|
|
12
33
|
/** Header checkbox tri-state for the current page. */
|
|
13
34
|
pageState: (pageIds: RowId[]) => "none" | "some" | "all";
|
|
14
35
|
clear: () => void;
|
|
@@ -85,6 +106,10 @@ interface UseQueryTableOptions<Row> {
|
|
|
85
106
|
* Pass localStorageAdapter() explicitly only when filter values are safe to
|
|
86
107
|
* retain as cleartext JSON on the device. */
|
|
87
108
|
storage?: StorageAdapter;
|
|
109
|
+
/** Shared reusable definitions, independent of saved-query storage. */
|
|
110
|
+
computedColumnStore?: ComputedColumnStore;
|
|
111
|
+
/** Override the worker factory when CSP disallows blob workers. */
|
|
112
|
+
formulaWorkerFactory?: FormulaWorkerFactory;
|
|
88
113
|
/** Seed query, normalized and resource-bounded before use. When omitted the
|
|
89
114
|
* hook resolves: opted-in URL → storage.loadLast → schema defaults. */
|
|
90
115
|
initialQuery?: QueryState;
|
|
@@ -168,10 +193,26 @@ interface QueryTableApi<Row> {
|
|
|
168
193
|
autoRefresh: AutoRefreshApi;
|
|
169
194
|
refreshRow: (id: RowId) => Promise<void>;
|
|
170
195
|
aggregations: AggregationsApi;
|
|
196
|
+
/** Append a predicate as its own AND term. */
|
|
171
197
|
addFilter: (clause: WhereClause) => void;
|
|
198
|
+
/** Replace the whole term at `index` with a single predicate. */
|
|
172
199
|
updateFilter: (index: number, clause: WhereClause) => void;
|
|
200
|
+
/** Remove the whole term at `index`. */
|
|
173
201
|
removeFilter: (index: number) => void;
|
|
174
202
|
clearFilters: () => void;
|
|
203
|
+
/** Replace one predicate inside a term (predIndex 0 for a literal term). */
|
|
204
|
+
updatePredicate: (termIndex: number, predIndex: number, clause: WhereClause) => void;
|
|
205
|
+
/** Remove one predicate; a group of one flattens to a literal, an emptied term drops. */
|
|
206
|
+
removePredicate: (termIndex: number, predIndex: number) => void;
|
|
207
|
+
/** Logically invert one predicate (flips the op, else toggles its NOT flag). */
|
|
208
|
+
negatePredicate: (termIndex: number, predIndex: number) => void;
|
|
209
|
+
/** Move the term at `fromIndex` to `toIndex` (an index in the list with the
|
|
210
|
+
* dragged term removed, so a drag preview's slot maps straight to the result). */
|
|
211
|
+
reorderFilters: (fromIndex: number, toIndex: number) => void;
|
|
212
|
+
/** OR-merge the term at `sourceIndex` into the term at `targetIndex`: the
|
|
213
|
+
* target becomes (or stays) an OR group holding both terms' predicates, and
|
|
214
|
+
* the source term is removed. This is the drag-onto-another-filter gesture. */
|
|
215
|
+
mergeFilters: (sourceIndex: number, targetIndex: number) => void;
|
|
175
216
|
/** Reset the complete query state back to schema defaults. */
|
|
176
217
|
resetAll: () => void;
|
|
177
218
|
/** Keystroke-driven filter-value autocomplete (Transport.fetchDistinctValues). */
|
|
@@ -179,6 +220,7 @@ interface QueryTableApi<Row> {
|
|
|
179
220
|
toggleSort: (field: string, additive?: boolean) => void;
|
|
180
221
|
setSort: (orderBy: OrderByClause[]) => void;
|
|
181
222
|
select: SelectApi<Row>;
|
|
223
|
+
computed: ComputedColumnsApi<Row>;
|
|
182
224
|
setLimit: (limit: number) => void;
|
|
183
225
|
setOffset: (offset: number) => void;
|
|
184
226
|
nextPage: () => void;
|
|
@@ -199,4 +241,4 @@ interface AggregationsApiState {
|
|
|
199
241
|
}
|
|
200
242
|
declare function useAggregations<Row>(query: QueryState, schema: FieldSchema<Row>, transport: Transport<Row> | undefined, clientRows: Row[] | undefined, debounceMs: number, nonce: number): AggregationsApiState;
|
|
201
243
|
|
|
202
|
-
export { type AggregationPatch, type AggregationsApi, type AggregationsApiState, type AutoRefreshApi, type AutoRefreshConfig, type AutoRefreshStatus, type ColumnDragApi, type QueryTableApi, type SavedQueriesApi, type SelectApi, type SelectionApi, type UseQueryTableOptions, useAggregations, useColumnDrag, useQueryTable, useSavedQueries, useSelect, useSelection };
|
|
244
|
+
export { type AggregationPatch, type AggregationsApi, type AggregationsApiState, type AutoRefreshApi, type AutoRefreshConfig, type AutoRefreshStatus, type ColumnDragApi, type ComputedColumnsApi, type FormulaWorkerFactory, type QueryTableApi, type SavedQueriesApi, type SelectApi, type SelectionApi, type UseQueryTableOptions, createFormulaWorker, evaluateFormulaRows, useAggregations, useColumnDrag, useQueryTable, useSavedQueries, useSelect, useSelection };
|