@standardbeagle/edit-db 0.4.740 → 0.4.831
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/dist/common/schema-queries.d.ts +1 -1
- package/dist/components/data-table-column-header.d.ts +6 -5
- package/dist/components/data-table.d.ts +8 -4
- package/dist/components/empty-value.d.ts +5 -2
- package/dist/components/filters/boolean-filter.d.ts +5 -4
- package/dist/components/filters/date-filter.d.ts +5 -4
- package/dist/components/filters/fk-filter.d.ts +36 -4
- package/dist/components/filters/number-filter.d.ts +5 -4
- package/dist/components/filters/text-filter.d.ts +5 -4
- package/dist/components/form-runner.d.ts +4 -1
- package/dist/components/grouped-grid-summary.d.ts +3 -1
- package/dist/edit-db.css +2 -2
- package/dist/editor.es.js +4118 -3752
- package/dist/editor.umd.cjs +19 -14
- package/dist/hooks/useColumnSizingPersistence.d.ts +6 -5
- package/dist/hooks/useColumnVisibilityPersistence.d.ts +7 -7
- package/dist/hooks/useDataTable.d.ts +6 -2
- package/dist/hooks/useRowHoverActions.d.ts +6 -3
- package/dist/lib/cell-commit.d.ts +10 -0
- package/dist/lib/column-order.d.ts +2 -2
- package/dist/lib/delete-summary.d.ts +18 -0
- package/dist/lib/export.d.ts +1 -1
- package/dist/lib/fk.d.ts +2 -1
- package/dist/lib/form-runner-nav.d.ts +7 -2
- package/dist/lib/format-value.d.ts +8 -11
- package/dist/lib/grid-grouping.d.ts +43 -7
- package/dist/lib/json-text.d.ts +17 -0
- package/dist/lib/mutation-payload.d.ts +19 -0
- package/dist/lib/query-builder.d.ts +40 -1
- package/dist/lib/row-id.d.ts +14 -1
- package/dist/lib/scalar-types.d.ts +7 -0
- package/dist/lib/search-column.d.ts +7 -0
- package/dist/lib/table-features.d.ts +17 -0
- package/dist/types/schema.d.ts +12 -1
- package/package.json +21 -22
- package/dist/common/saved-objects.test.d.ts +0 -1
- package/dist/common/schema-queries.test.d.ts +0 -1
- package/dist/components/bulk-edit-dialog.test.d.ts +0 -0
- package/dist/components/content-viewer.test.d.ts +0 -1
- package/dist/components/data-table-column-header.test.d.ts +0 -0
- package/dist/components/data-table.test.d.ts +0 -0
- package/dist/components/empty-value.test.d.ts +0 -0
- package/dist/components/export-button.test.d.ts +0 -1
- package/dist/components/filters/fk-filter.test.d.ts +0 -1
- package/dist/components/filters/number-filter.test.d.ts +0 -1
- package/dist/components/fk-cell-popover.test.d.ts +0 -1
- package/dist/components/form-runner.test.d.ts +0 -0
- package/dist/components/form-subform.test.d.ts +0 -0
- package/dist/components/grouped-grid-summary.test.d.ts +0 -0
- package/dist/components/m2m-panel.test.d.ts +0 -0
- package/dist/components/ui/select.test.d.ts +0 -1
- package/dist/components/ui/table.test.d.ts +0 -1
- package/dist/data-edit.test.d.ts +0 -0
- package/dist/hooks/useColumnVisibilityPersistence.test.d.ts +0 -1
- package/dist/hooks/useCompositeTableRef.test.d.ts +0 -1
- package/dist/hooks/useDataTable.test.d.ts +0 -1
- package/dist/hooks/useDebouncedCommit.test.d.ts +0 -1
- package/dist/hooks/useDeleteMutation.test.d.ts +0 -0
- package/dist/hooks/useDeltaMutation.test.d.ts +0 -0
- package/dist/hooks/useFitMode.test.d.ts +0 -1
- package/dist/hooks/usePanelSize.test.d.ts +0 -1
- package/dist/hooks/usePath.test.d.ts +0 -1
- package/dist/hooks/useSchemaFilter.test.d.ts +0 -1
- package/dist/hooks/useTableExport.test.d.ts +0 -1
- package/dist/hooks/useTableMutation.test.d.ts +0 -0
- package/dist/hooks/useTableRef.test.d.ts +0 -1
- package/dist/hooks/useTableStats.test.d.ts +0 -1
- package/dist/lib/column-order.test.d.ts +0 -1
- package/dist/lib/composite-pk-roundtrip.test.d.ts +0 -1
- package/dist/lib/content-detect.sniff.test.d.ts +0 -1
- package/dist/lib/content-detect.test.d.ts +0 -1
- package/dist/lib/date-input.test.d.ts +0 -1
- package/dist/lib/drill-stack.test.d.ts +0 -1
- package/dist/lib/export.test.d.ts +0 -1
- package/dist/lib/field-validation.test.d.ts +0 -1
- package/dist/lib/fk.test.d.ts +0 -1
- package/dist/lib/form-definition.test.d.ts +0 -1
- package/dist/lib/form-runner-nav.test.d.ts +0 -1
- package/dist/lib/form-subform.test.d.ts +0 -1
- package/dist/lib/form-widget.test.d.ts +0 -1
- package/dist/lib/format-value-render.test.d.ts +0 -1
- package/dist/lib/format-value.test.d.ts +0 -1
- package/dist/lib/grid-grouping.test.d.ts +0 -1
- package/dist/lib/invalidate.test.d.ts +0 -1
- package/dist/lib/label-match.test.d.ts +0 -1
- package/dist/lib/m2m.test.d.ts +0 -1
- package/dist/lib/mutation-payload.test.d.ts +0 -1
- package/dist/lib/pk-hygiene.test.d.ts +0 -1
- package/dist/lib/polymorphic.test.d.ts +0 -1
- package/dist/lib/query-builder.test.d.ts +0 -1
- package/dist/lib/row-id.test.d.ts +0 -1
- package/dist/lib/rows-by-pk-query.test.d.ts +0 -1
- package/dist/lib/scalar-types.test.d.ts +0 -1
- package/dist/lib/search-column.test.d.ts +0 -1
- package/dist/lib/table-ref.test.d.ts +0 -1
- package/dist/table-list.test.d.ts +0 -0
- package/dist/table-view.chart.test.d.ts +0 -1
- package/dist/table-view.test.d.ts +0 -0
|
@@ -10,10 +10,11 @@ export interface UseColumnSizingPersistenceResult {
|
|
|
10
10
|
* Owns per-table column sizing, persisted to localStorage.
|
|
11
11
|
*
|
|
12
12
|
* Writes are debounced so a live ('onChange') resize drag doesn't write on every
|
|
13
|
-
* mousemove. `
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
13
|
+
* mousemove. `loaded` remembers the sizing object last read from storage, and
|
|
14
|
+
* the effect skips persisting while the state is still that very object — it
|
|
15
|
+
* would only write back what storage already holds (on mount and after a
|
|
16
|
+
* table switch). `pendingSizingRef` carries the latest unsaved state so a
|
|
17
|
+
* table switch or unmount flushes it instead of dropping a resize made less
|
|
18
|
+
* than the debounce window ago.
|
|
18
19
|
*/
|
|
19
20
|
export declare function useColumnSizingPersistence(tableName?: string): UseColumnSizingPersistenceResult;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ColumnVisibilityState } from '@tanstack/react-table';
|
|
2
2
|
/**
|
|
3
3
|
* Read a stored selection. Returns null — not `{}` — when there is nothing
|
|
4
4
|
* stored, because "no stored preference" (fall back to the host defaults) and
|
|
5
5
|
* "stored: everything visible" are different states.
|
|
6
6
|
*/
|
|
7
|
-
export declare function loadColumnVisibility(tableName: string):
|
|
8
|
-
export declare function saveColumnVisibility(tableName: string, visibility:
|
|
7
|
+
export declare function loadColumnVisibility(tableName: string): ColumnVisibilityState | null;
|
|
8
|
+
export declare function saveColumnVisibility(tableName: string, visibility: ColumnVisibilityState): void;
|
|
9
9
|
export declare function clearColumnVisibility(tableName: string): void;
|
|
10
10
|
/**
|
|
11
11
|
* Turn a host's list of columns to show into table state: everything named is
|
|
@@ -13,10 +13,10 @@ export declare function clearColumnVisibility(tableName: string): void;
|
|
|
13
13
|
* that this table doesn't have are ignored, so one config can cover a schema
|
|
14
14
|
* that varies between deployments.
|
|
15
15
|
*/
|
|
16
|
-
export declare function visibilityFromDefaults(allColumnIds: string[], defaultVisible?: string[]):
|
|
16
|
+
export declare function visibilityFromDefaults(allColumnIds: string[], defaultVisible?: string[]): ColumnVisibilityState;
|
|
17
17
|
export interface UseColumnVisibilityPersistenceResult {
|
|
18
|
-
columnVisibility:
|
|
19
|
-
setColumnVisibility: React.Dispatch<React.SetStateAction<
|
|
18
|
+
columnVisibility: ColumnVisibilityState;
|
|
19
|
+
setColumnVisibility: React.Dispatch<React.SetStateAction<ColumnVisibilityState>>;
|
|
20
20
|
/** Drop the stored selection and go back to the host defaults for this table. */
|
|
21
21
|
resetColumnVisibility: () => void;
|
|
22
22
|
}
|
|
@@ -31,4 +31,4 @@ export interface UseColumnVisibilityPersistenceResult {
|
|
|
31
31
|
* must not store its defaults — that would freeze today's defaults into every
|
|
32
32
|
* viewer's storage and make a later change to them invisible.
|
|
33
33
|
*/
|
|
34
|
-
export declare function useColumnVisibilityPersistence(tableName: string | undefined, defaultVisibility:
|
|
34
|
+
export declare function useColumnVisibilityPersistence(tableName: string | undefined, defaultVisibility: ColumnVisibilityState): UseColumnVisibilityPersistenceResult;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DefaultSort } from './useEditorConfig';
|
|
2
|
-
import { Table, Column, Join } from '../types/schema';
|
|
2
|
+
import { Table, Column, Join, SchemaContextValue } from '../types/schema';
|
|
3
3
|
import { ColumnDef, ColumnFiltersState, SortingState } from '@tanstack/react-table';
|
|
4
|
+
import { DataTableFeatures } from '../lib/table-features';
|
|
4
5
|
import { DrillFrame } from '../lib/drill-stack';
|
|
5
6
|
import { ExportRunner } from '../lib/export';
|
|
6
7
|
import { GridGroupMemberRequest, GroupingRow, GroupingSort } from '../lib/grid-grouping';
|
|
@@ -40,13 +41,15 @@ export declare function getMultiJoinRows(row: RowData, join: Join): RowData[];
|
|
|
40
41
|
*/
|
|
41
42
|
export declare function getSingleJoinRow(row: RowData, join: Join): RowData | undefined;
|
|
42
43
|
export declare function getMultiJoinTotal(row: RowData, join: Join): number;
|
|
44
|
+
/** Exported for tests: the grid's column defs for a table. */
|
|
45
|
+
export declare const getTableColumns: (table: Table, schema: SchemaContextValue, onExpandContent?: (rowIndex: number, columnName: string) => void, onOpenColumn?: (panel: DrillFrame) => void) => ColumnDef<DataTableFeatures, RowData, unknown>[];
|
|
43
46
|
/**
|
|
44
47
|
* Return type for the useDataTable hook.
|
|
45
48
|
* @interface UseDataTableResult
|
|
46
49
|
*/
|
|
47
50
|
interface UseDataTableResult {
|
|
48
51
|
/** Column definitions for the table */
|
|
49
|
-
columns: ColumnDef<RowData, unknown>[];
|
|
52
|
+
columns: ColumnDef<DataTableFeatures, RowData, unknown>[];
|
|
50
53
|
/** Current sorting state */
|
|
51
54
|
sorting: SortingState;
|
|
52
55
|
/** Active column filters */
|
|
@@ -68,6 +71,7 @@ interface UseDataTableResult {
|
|
|
68
71
|
column: Column;
|
|
69
72
|
sumColumn: Column | null;
|
|
70
73
|
rows: GroupingRow[];
|
|
74
|
+
truncated: boolean;
|
|
71
75
|
loading: boolean;
|
|
72
76
|
error: Error | null;
|
|
73
77
|
sort: GroupingSort;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PointerEvent
|
|
1
|
+
import { PointerEvent } from 'react';
|
|
2
2
|
export interface HoveredRow {
|
|
3
3
|
rowId: string;
|
|
4
4
|
el: HTMLElement;
|
|
@@ -8,8 +8,11 @@ export interface UseRowHoverActionsResult {
|
|
|
8
8
|
hoverRow: (rowId: string, el: HTMLElement) => void;
|
|
9
9
|
scheduleDismiss: () => void;
|
|
10
10
|
cancelDismiss: () => void;
|
|
11
|
-
/**
|
|
12
|
-
|
|
11
|
+
/**
|
|
12
|
+
* True (once) when a long-press just opened the actions, so the click
|
|
13
|
+
* that follows the finger lift is swallowed instead of selecting the row.
|
|
14
|
+
*/
|
|
15
|
+
consumeSuppressedClick: () => boolean;
|
|
13
16
|
startPress: (rowId: string, el: HTMLElement, e: PointerEvent) => void;
|
|
14
17
|
onPressMove: () => void;
|
|
15
18
|
cancelPress: () => void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether an inline-editor commit leaves a cell at its stored value, so the
|
|
3
|
+
* grid un-stages it instead of marking the row dirty.
|
|
4
|
+
*
|
|
5
|
+
* The inline editor seeds a NULL cell with '' (a text input cannot hold null)
|
|
6
|
+
* and commits on blur, so tabbing through a NULL cell commits ''. That is the
|
|
7
|
+
* NULL it was shown, not an edit: counting it as one staged '' for every
|
|
8
|
+
* nullable column the user only looked at, and "Save all" wrote it.
|
|
9
|
+
*/
|
|
10
|
+
export declare function isUnchangedCellValue(originalValue: unknown, value: unknown): boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColumnDef } from '@tanstack/react-table';
|
|
1
|
+
import { ColumnDef, RowData, TableFeatures } from '@tanstack/react-table';
|
|
2
2
|
export interface ColumnOrderConfig {
|
|
3
3
|
/** Columns to place first, in this order. */
|
|
4
4
|
leading?: string[];
|
|
@@ -14,4 +14,4 @@ export interface ColumnOrderConfig {
|
|
|
14
14
|
* Order is independent of visibility: a column the viewer switches back on lands
|
|
15
15
|
* in its configured place rather than at the end.
|
|
16
16
|
*/
|
|
17
|
-
export declare function orderColumns<TData>(columns: ColumnDef<TData, unknown>[], { leading, trailing }: ColumnOrderConfig): ColumnDef<TData, unknown>[];
|
|
17
|
+
export declare function orderColumns<TFeatures extends TableFeatures, TData extends RowData>(columns: ColumnDef<TFeatures, TData, unknown>[], { leading, trailing }: ColumnOrderConfig): ColumnDef<TFeatures, TData, unknown>[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { PkFilter } from './row-id';
|
|
2
|
+
export interface DeleteSummary {
|
|
3
|
+
/** One human-readable line per row, capped at `maxLabels`. */
|
|
4
|
+
labels: string[];
|
|
5
|
+
/** Rows beyond the cap, for an "and N more" line. */
|
|
6
|
+
remaining: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Describes the rows a delete confirmation is about, so the dialog can name
|
|
10
|
+
* them instead of asking the reader to trust that the right row was selected.
|
|
11
|
+
*
|
|
12
|
+
* Falls back to the key alone when the row is not on the current page — a
|
|
13
|
+
* confirmation that names the key is still better than one that names nothing.
|
|
14
|
+
*/
|
|
15
|
+
export declare function describeDeleteRows(pks: readonly PkFilter[], rows: readonly Record<string, unknown>[], options?: {
|
|
16
|
+
maxLabels?: number;
|
|
17
|
+
maxDescriptors?: number;
|
|
18
|
+
}): DeleteSummary;
|
package/dist/lib/export.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export declare const UTF8_BOM = "\uFEFF";
|
|
|
27
27
|
* quoted empty pair (`""`) so the two stay distinguishable in the output bytes.
|
|
28
28
|
* bigint and Date get exact/stable string forms; objects are JSON-encoded.
|
|
29
29
|
* String values that would execute as a spreadsheet formula are prefixed with
|
|
30
|
-
* an apostrophe.
|
|
30
|
+
* an apostrophe; a string holding only a numeric literal is not.
|
|
31
31
|
*/
|
|
32
32
|
export declare function formatCsvCell(value: unknown): string;
|
|
33
33
|
export interface CsvOptions {
|
package/dist/lib/fk.d.ts
CHANGED
|
@@ -8,7 +8,8 @@ export interface FkEqFilterResult {
|
|
|
8
8
|
* Coerce a raw cell/route value to the JS type matching a GraphQL scalar so the
|
|
9
9
|
* variable payload agrees with its declared type (e.g. a Boolean FK is sent as
|
|
10
10
|
* `true`, not `"true"`). Unparseable numerics are passed through untouched so
|
|
11
|
-
* the server reports the real error instead of receiving `NaN`.
|
|
11
|
+
* the server reports the real error instead of receiving `NaN`. A Boolean value
|
|
12
|
+
* outside true/false/0/1 throws (see coerceBooleanForGql).
|
|
12
13
|
*/
|
|
13
14
|
export declare function coerceForGql(value: unknown, gqlType: string): unknown;
|
|
14
15
|
/** The base GraphQL scalar of a column (`paramType` minus non-null marker), defaulting to String. */
|
|
@@ -13,7 +13,12 @@ export type NavDirection = 'first' | 'prev' | 'next' | 'last';
|
|
|
13
13
|
* the "no records" state rather than a negative offset.
|
|
14
14
|
*/
|
|
15
15
|
export declare function nextIndex(current: number, total: number, direction: NavDirection): number;
|
|
16
|
-
/**
|
|
17
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Whether a navigation step from `current` would actually move (false at a
|
|
18
|
+
* bound). `current` is null while the runner sits on a pinned key (a Jump or a
|
|
19
|
+
* subform Edit): its offset and the total are unknown, so only First has a
|
|
20
|
+
* well-defined target — any relative step would land on an arbitrary row.
|
|
21
|
+
*/
|
|
22
|
+
export declare function canNavigate(current: number | null, total: number, direction: NavDirection): boolean;
|
|
18
23
|
/** Human 1-based position label, e.g. "3 of 12". Empty table reads "0 of 0". */
|
|
19
24
|
export declare function positionLabel(index: number, total: number): string;
|
|
@@ -53,6 +53,14 @@ export declare function formatRelative(date: Date, now?: Date): string;
|
|
|
53
53
|
export declare function usableEnumLabels(column: Column): string[] | null;
|
|
54
54
|
/** The label for one enum value, or null when the column has no usable labels or the value is not one of them. */
|
|
55
55
|
export declare function enumLabelFor(value: unknown, column: Column): string | null;
|
|
56
|
+
/** Renders one cell value of a column. Built once per column by {@link columnFormatter}. */
|
|
57
|
+
export type CellFormatter = (value: unknown) => ReactNode;
|
|
58
|
+
/**
|
|
59
|
+
* The cell formatter for a column: resolves its display format, enum labels and Intl
|
|
60
|
+
* formatters once, so rendering a cell is a lookup and one format call. See
|
|
61
|
+
* {@link formatColumnValue} for what it renders.
|
|
62
|
+
*/
|
|
63
|
+
export declare function columnFormatter(column: Column, formatKey?: string): CellFormatter;
|
|
56
64
|
/**
|
|
57
65
|
* Format a scalar value for display, given its column. Returns a muted
|
|
58
66
|
* placeholder for null/empty, the enum label for a labelled enum value (with
|
|
@@ -60,17 +68,6 @@ export declare function enumLabelFor(value: unknown, column: Column): string | n
|
|
|
60
68
|
* a `title` revealing the exact value), or the plain string otherwise.
|
|
61
69
|
*/
|
|
62
70
|
export declare function formatColumnValue(value: unknown, column: Column, options?: FormatOptions): ReactNode;
|
|
63
|
-
/**
|
|
64
|
-
* Format a raw date/datetime string for grid-cell display via toLocaleString,
|
|
65
|
-
* blanking sentinel "unset" instants.
|
|
66
|
-
*
|
|
67
|
-
* Only exact placeholder/sentinel instants are blanked, not legitimate
|
|
68
|
-
* historical dates. A broad "before 1973" cutoff hid real dates (e.g. a 1900
|
|
69
|
-
* birthdate or a 1969 record). The two markers that actually mean "unset":
|
|
70
|
-
* the Unix epoch (timestamp 0, i.e. 1970-01-01T00:00:00Z) and .NET/SQL
|
|
71
|
-
* DateTime.MinValue (year 0001-01-01).
|
|
72
|
-
*/
|
|
73
|
-
export declare function formatDateCellValue(value: string): string;
|
|
74
71
|
/**
|
|
75
72
|
* Formats a number into an abbreviated string representation.
|
|
76
73
|
*
|
|
@@ -27,12 +27,32 @@ export type GroupingSort = {
|
|
|
27
27
|
desc: boolean;
|
|
28
28
|
};
|
|
29
29
|
export declare const DEFAULT_GROUPING_SORT: GroupingSort;
|
|
30
|
+
/**
|
|
31
|
+
* Most buckets one grouping request shows. The aggregate is asked for one more
|
|
32
|
+
* (the cap+1 sentinel) so a cut is reported instead of passing as the whole set;
|
|
33
|
+
* without an explicit limit the server's default row window (100) cut silently.
|
|
34
|
+
*/
|
|
35
|
+
export declare const GROUPING_BUCKET_CAP = 1000;
|
|
36
|
+
/**
|
|
37
|
+
* Most buckets shown under the server's row ceiling (`_maxQueryRows`, read with
|
|
38
|
+
* the schema). The server clamps every requested window to the ceiling, so the
|
|
39
|
+
* page stays one below it and the cap+1 sentinel still fits: under a ceiling of
|
|
40
|
+
* 500 the page is 499 and the request asks for 500.
|
|
41
|
+
*/
|
|
42
|
+
export declare function groupingPage(maxQueryRows: number | undefined): number;
|
|
43
|
+
/** Aggregate buckets plus whether the server had more than it returned. */
|
|
44
|
+
export interface GroupingResult {
|
|
45
|
+
rows: GroupingRow[];
|
|
46
|
+
truncated: boolean;
|
|
47
|
+
}
|
|
30
48
|
export interface GridGroupingRequest {
|
|
31
49
|
query: string;
|
|
32
50
|
variables: Record<string, unknown>;
|
|
33
51
|
groupBy: Column;
|
|
34
52
|
sumBy: Column | null;
|
|
35
53
|
sort: GroupingSort;
|
|
54
|
+
/** Most buckets shown; the request asks for one more as the truncation sentinel. */
|
|
55
|
+
page: number;
|
|
36
56
|
}
|
|
37
57
|
export interface GridGroupMemberRequest {
|
|
38
58
|
query: string;
|
|
@@ -40,6 +60,11 @@ export interface GridGroupMemberRequest {
|
|
|
40
60
|
/** Response field selected from the current schema, never parsed from query text. */
|
|
41
61
|
responseKey: string;
|
|
42
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Columns the grouped grid can sum: every numeric scalar, BigInt and Decimal
|
|
65
|
+
* included (the usual types for amounts and counters).
|
|
66
|
+
*/
|
|
67
|
+
export declare function isSummableColumn(column: Column): boolean;
|
|
43
68
|
export declare function groupingSumColumnFromUrl(value: string | null, table: Table | null): Column | null;
|
|
44
69
|
/**
|
|
45
70
|
* Update one of the grouping-owned URL fields without disturbing filters, the
|
|
@@ -51,13 +76,24 @@ export declare function withGroupingUrlParam(search: URLSearchParams, param: typ
|
|
|
51
76
|
/** Remove grouping state when navigation changes the source table. */
|
|
52
77
|
export declare function withoutGroupingUrlParams(search: URLSearchParams): URLSearchParams;
|
|
53
78
|
/** Builds the schema-derived aggregate document used by the grouped grid. */
|
|
54
|
-
export declare function buildGridGroupingRequest(table: Table, groupBy: Column, columnFilters: ColumnFiltersState, headerFilter: string, sumBy?: Column | null, sort?: GroupingSort): GridGroupingRequest;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
79
|
+
export declare function buildGridGroupingRequest(table: Table, groupBy: Column, columnFilters: ColumnFiltersState, headerFilter: string, maxQueryRows: number | undefined, sumBy?: Column | null, sort?: GroupingSort): GridGroupingRequest;
|
|
80
|
+
/**
|
|
81
|
+
* Defined aggregate ordering for the server-grouped replacement surface.
|
|
82
|
+
* `exactKeys` is set for a BigInt or Decimal key column: those keys arrive as
|
|
83
|
+
* decimal strings and must compare by value, or "10" sorts before "9" (and
|
|
84
|
+
* Number() would merge distinct keys past 15–17 significant digits). A text
|
|
85
|
+
* column of digit strings keeps text order.
|
|
86
|
+
*/
|
|
87
|
+
export declare function compareGroupingRowsByKey(left: GroupingRow, right: GroupingRow, exactKeys?: boolean): number;
|
|
58
88
|
/** Sort aggregate buckets by the selected key/count direction with a stable key tie-breaker. */
|
|
59
|
-
export declare function compareGroupingRows(left: GroupingRow, right: GroupingRow, sort?: GroupingSort): number;
|
|
60
|
-
/**
|
|
61
|
-
|
|
89
|
+
export declare function compareGroupingRows(left: GroupingRow, right: GroupingRow, sort?: GroupingSort, exactKeys?: boolean): number;
|
|
90
|
+
/**
|
|
91
|
+
* Reads the aggregate buckets (with the configured measure, never derived from
|
|
92
|
+
* page rows), dropping the cap+1 sentinel and reporting a cut — by the cap or
|
|
93
|
+
* by the server's row ceiling, both folded into `request.page` — as
|
|
94
|
+
* `truncated`. The server windows buckets in key order, so a truncated count
|
|
95
|
+
* sort ranks only the buckets shown; the summary says so.
|
|
96
|
+
*/
|
|
97
|
+
export declare function readGroupingResult(data: Record<string, unknown> | undefined, table: Table, request: Pick<GridGroupingRequest, 'groupBy' | 'sumBy' | 'sort' | 'page'>): GroupingResult;
|
|
62
98
|
/** Schema-derived member query for a single aggregate key. It merges, never replaces, active filters. */
|
|
63
99
|
export declare function buildGridGroupMemberRequest(table: Table, groupBy: Column, value: unknown, columnFilters: ColumnFiltersState, headerFilter: string, sort?: readonly string[]): GridGroupMemberRequest;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-indents JSON text without parsing its values.
|
|
3
|
+
*
|
|
4
|
+
* `JSON.stringify(JSON.parse(text))` is not a formatter: it reads every number
|
|
5
|
+
* into an IEEE-754 double, so `9007199254740993` comes back as
|
|
6
|
+
* `9007199254740992`, `1.50` as `1.5` and `1e3` as `1000`. Seeding an editor
|
|
7
|
+
* with that output and saving writes a different value than the one stored.
|
|
8
|
+
*
|
|
9
|
+
* This walks the text token by token and copies every string and number
|
|
10
|
+
* literal verbatim; only the whitespace between tokens changes.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Returns `text` re-indented with `indent` spaces per level (0 = minified), or
|
|
14
|
+
* null when `text` is not valid JSON. Number and string tokens are copied
|
|
15
|
+
* byte-for-byte.
|
|
16
|
+
*/
|
|
17
|
+
export declare function reformatJsonText(text: string, indent: number): string | null;
|
|
@@ -35,3 +35,22 @@ export declare function buildBulkUpdatePayloads(table: Pick<Table, 'primaryKeys'
|
|
|
35
35
|
* stages every edited row or none.
|
|
36
36
|
*/
|
|
37
37
|
export declare function buildStagedUpdatePayloads(table: Pick<Table, 'primaryKeys'>, editableColumns: Column[], idColumns: Column[], freshRows: readonly Record<string, unknown>[], changesForRow: (row: Record<string, unknown>) => Record<string, unknown> | undefined): Record<string, unknown>[];
|
|
38
|
+
/**
|
|
39
|
+
* Whether a column is nullable text where '' and NULL are both real values, so
|
|
40
|
+
* the form and the inline cell editor offer an explicit "Set NULL" control and
|
|
41
|
+
* hold NULL as null rather than as ''. Dates (never ''), JSON and binary
|
|
42
|
+
* content, enums and FK pickers (their own "(none)") are excluded.
|
|
43
|
+
*/
|
|
44
|
+
export declare function offersExplicitNull(column: Column): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* The edit form shows NULL as an empty field wherever its input cannot hold
|
|
47
|
+
* null (dates, numbers, JSON text), seeding it with ''. Saving an unrelated
|
|
48
|
+
* field then sent '' over every NULL it had shown. Map that '' back to null for
|
|
49
|
+
* a nullable column when the stored value was NULL (or absent, as on an
|
|
50
|
+
* insert), and for any nullable date column (an empty string is never a date).
|
|
51
|
+
*
|
|
52
|
+
* Columns with an explicit NULL control ({@link offersExplicitNull}) are left
|
|
53
|
+
* alone: the form seeds their NULL as null and "Set NULL" writes null, so a ''
|
|
54
|
+
* there is text the user cleared, a real value.
|
|
55
|
+
*/
|
|
56
|
+
export declare function restoreBlankNulls(formValues: Record<string, unknown>, originalRow: Record<string, unknown>, columns: Column[]): Record<string, unknown>;
|
|
@@ -17,6 +17,23 @@ export interface ColumnFilterValue {
|
|
|
17
17
|
operator: string;
|
|
18
18
|
value: unknown;
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Operator of a composite-FK tuple filter: "rows whose FK columns equal this
|
|
22
|
+
* parent row's key". It sits on the FK's anchor column, and its value is a
|
|
23
|
+
* {@link FkTupleValue} naming EVERY source column of the FK, so the predicate is
|
|
24
|
+
* an AND of `{col: {_eq: $v}}` per column, never one column's guess.
|
|
25
|
+
*/
|
|
26
|
+
export declare const FK_TUPLE_OPERATOR = "_fk_tuple";
|
|
27
|
+
/**
|
|
28
|
+
* Ordered `[childColumn, value]` pairs of a tuple filter, in the FK's source
|
|
29
|
+
* column order. Pairs, not an object: the order is the FK's, and no column name
|
|
30
|
+
* can collide with an object key like `__proto__`. Values stay as the server
|
|
31
|
+
* sent them (BigInt/Decimal keys as decimal strings) and are coerced per child
|
|
32
|
+
* column when the predicate is built.
|
|
33
|
+
*/
|
|
34
|
+
export type FkTupleValue = [string, string | number | boolean][];
|
|
35
|
+
/** Whether `value` is a well-formed {@link FkTupleValue}: ≥1 pair, valid distinct column names, scalar values. */
|
|
36
|
+
export declare function isFkTupleValue(value: unknown): value is FkTupleValue;
|
|
20
37
|
export interface ColumnFilterResult {
|
|
21
38
|
variables: Record<string, unknown>;
|
|
22
39
|
params: string[];
|
|
@@ -99,6 +116,12 @@ export declare function toWireFilter(operator: string, value: unknown, gqlType:
|
|
|
99
116
|
operator: string;
|
|
100
117
|
value: unknown;
|
|
101
118
|
};
|
|
119
|
+
/**
|
|
120
|
+
* The same tuple predicate as a GraphQL input OBJECT (for surfaces that pass the
|
|
121
|
+
* filter as a variable, like the chart), keyed by each column's GraphQL name.
|
|
122
|
+
* Null when the tuple would be refused by {@link buildColumnFilters}.
|
|
123
|
+
*/
|
|
124
|
+
export declare function fkTupleFilterObject(value: unknown, table: Table): Record<string, unknown> | null;
|
|
102
125
|
export declare function buildColumnFilters(columnFilters: ColumnFiltersState, table: Table): ColumnFilterResult;
|
|
103
126
|
/**
|
|
104
127
|
* Every reason the requested filters could not be fully applied, header filter
|
|
@@ -106,7 +129,23 @@ export declare function buildColumnFilters(columnFilters: ColumnFiltersState, ta
|
|
|
106
129
|
* advertising, which is the only condition under which the grid query may run.
|
|
107
130
|
*/
|
|
108
131
|
export declare function collectFilterErrors(table: Table, filterString: string, columnFilters: ColumnFiltersState): string[];
|
|
132
|
+
/**
|
|
133
|
+
* The `cf` URL param codec — its one producer and one consumer.
|
|
134
|
+
*
|
|
135
|
+
* Format: a JSON array of `[columnId, operator, value]` triples.
|
|
136
|
+
* - Single-column filters: `value` is the scalar (or `[lo, hi]` for
|
|
137
|
+
* `_between`), as it always was, so every cf link written before tuple
|
|
138
|
+
* filters existed decodes unchanged.
|
|
139
|
+
* - Composite-FK tuple filters: `operator` is {@link FK_TUPLE_OPERATOR} and
|
|
140
|
+
* `value` is the {@link FkTupleValue} pair list, e.g.
|
|
141
|
+
* `["tenant_id","_fk_tuple",[["tenant_id","7"],["order_id","9007199254740993"]]]`.
|
|
142
|
+
*
|
|
143
|
+
* Key values travel as JSON strings when the server sent strings (BigInt,
|
|
144
|
+
* Decimal), so no value passes through a JS number. A triple that fails
|
|
145
|
+
* validation is dropped on decode, never guessed into a different filter.
|
|
146
|
+
*/
|
|
109
147
|
export declare function serializeColumnFilters(columnFilters: ColumnFiltersState): string;
|
|
148
|
+
/** Decodes a `cf` param written by {@link serializeColumnFilters}; see the format there. */
|
|
110
149
|
export declare function deserializeColumnFilters(raw: string): ColumnFiltersState;
|
|
111
150
|
/**
|
|
112
151
|
* Returns the GraphQL type of the first PK column. For composite PKs use {@link getPkTypes}.
|
|
@@ -194,7 +233,7 @@ export interface DrillDownTarget {
|
|
|
194
233
|
* filter column and polymorphic links need the server-injected discriminator;
|
|
195
234
|
* both must keep MODEL B's parent traversal.
|
|
196
235
|
*/
|
|
197
|
-
export declare function canFlatFilterDrill(childJoin:
|
|
236
|
+
export declare function canFlatFilterDrill({ parentTable, childJoin }: Pick<DrillDownTarget, 'parentTable' | 'childJoin'>): boolean;
|
|
198
237
|
/**
|
|
199
238
|
* Resolve the parent table + child collection field for a parent→child
|
|
200
239
|
* related-records drill-down. The child is `table`; the parent is `filterTable`
|
package/dist/lib/row-id.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import { Table } from '../types/schema';
|
|
1
|
+
import { Column, Table } from '../types/schema';
|
|
2
2
|
export type PkFilter = Record<string, unknown>;
|
|
3
|
+
/**
|
|
4
|
+
* Every primary-key column of `table`, in key declaration order. Composite keys
|
|
5
|
+
* need all of them for a by-id filter and an update's WHERE clause; a key name
|
|
6
|
+
* with no matching column is dropped (the caller's key-count checks catch it).
|
|
7
|
+
*/
|
|
8
|
+
export declare function pkColumnsOf(table: Pick<Table, 'primaryKeys' | 'columns'>): Column[];
|
|
3
9
|
export interface PkEqFilterResult {
|
|
4
10
|
filterText: string;
|
|
5
11
|
variables: Record<string, unknown>;
|
|
@@ -24,6 +30,13 @@ export declare function encodeRouteParts(values: readonly unknown[]): string;
|
|
|
24
30
|
export declare function decodeRouteParts(raw: string, expectedCount: number): string[];
|
|
25
31
|
export declare function rowIdOf(row: Record<string, unknown> | null | undefined, table: TableLike, index: number): string;
|
|
26
32
|
export declare function pkFilterFor(row: Record<string, unknown> | null | undefined, table: TableLike): PkFilter | null;
|
|
33
|
+
/**
|
|
34
|
+
* The key-equality predicate and its variable declarations, without values:
|
|
35
|
+
* `{col: {_eq: $pk_col}}` per key column, `and`-wrapped when composite. The one
|
|
36
|
+
* producer of the `pk_<col>` variable names, for query text built before the
|
|
37
|
+
* key values are known; {@link buildPkEqFilter} binds them.
|
|
38
|
+
*/
|
|
39
|
+
export declare function pkEqDeclaration(table: TableLike): Pick<PkEqFilterResult, 'filterText' | 'params'>;
|
|
27
40
|
export declare function buildPkEqFilter(row: Record<string, unknown> | null | undefined, table: Pick<Table, 'primaryKeys' | 'columns'>): PkEqFilterResult | null;
|
|
28
41
|
export declare function encodePkRoute(filter: PkFilter, table: TableLike): string;
|
|
29
42
|
/**
|
|
@@ -18,6 +18,13 @@ export declare function isIntegerScalar(paramType: string | undefined): boolean;
|
|
|
18
18
|
export declare function isNumericScalar(paramType: string | undefined): boolean;
|
|
19
19
|
/** Columns whose value must never be routed through a JS number. */
|
|
20
20
|
export declare function isExactScalar(paramType: string | undefined): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Orders two plain decimal strings exactly ("-3" < "9.5" < "10" <
|
|
23
|
+
* "9007199254740993"), or returns null when either is not plain decimal text.
|
|
24
|
+
* The server writes BigInt and Decimal values as such strings; text order would
|
|
25
|
+
* put "10" before "9", and Number() rounds past 15–17 significant digits.
|
|
26
|
+
*/
|
|
27
|
+
export declare function compareDecimalText(left: string, right: string): number | null;
|
|
21
28
|
/** DateTime and DateTimeOffset — the columns whose bounds are instants. */
|
|
22
29
|
export declare function isTimestampScalar(paramType: string | undefined): boolean;
|
|
23
30
|
export declare function isBooleanScalar(paramType: string | undefined): boolean;
|
|
@@ -8,3 +8,10 @@ export declare function pickDefaultSearchColumn(options: ReadonlyArray<{
|
|
|
8
8
|
key: string;
|
|
9
9
|
value: string;
|
|
10
10
|
}> | undefined, configured: string | undefined): string;
|
|
11
|
+
/**
|
|
12
|
+
* The URL the header quick search navigates to: the current query string with
|
|
13
|
+
* only `filter` replaced. Column filters (`cf`) and grouping (`gb`/`gs`) stay,
|
|
14
|
+
* and URLSearchParams encodes the term, so `&`, `+`, `#` or `%` in it reach the
|
|
15
|
+
* filter intact. Null when the term is not a value of the column's scalar.
|
|
16
|
+
*/
|
|
17
|
+
export declare function quickSearchUrl(current: URLSearchParams, columnName: string, paramType: string, term: string): string | null;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The TanStack Table features the data grid uses. Sorting, filtering and
|
|
3
|
+
* pagination are all server-side (manual*), so no client row models are
|
|
4
|
+
* registered — only the state and column/table APIs each feature adds.
|
|
5
|
+
* Shared so column definitions, filters and headers type-check against the
|
|
6
|
+
* same feature set the table is built with.
|
|
7
|
+
*/
|
|
8
|
+
export declare const dataTableFeatures: {
|
|
9
|
+
columnFilteringFeature: import('@tanstack/react-table').TableFeature;
|
|
10
|
+
columnSizingFeature: import('@tanstack/react-table').TableFeature;
|
|
11
|
+
columnResizingFeature: import('@tanstack/react-table').TableFeature;
|
|
12
|
+
columnVisibilityFeature: import('@tanstack/react-table').TableFeature;
|
|
13
|
+
rowPaginationFeature: import('@tanstack/react-table').TableFeature;
|
|
14
|
+
rowSelectionFeature: import('@tanstack/react-table').TableFeature;
|
|
15
|
+
rowSortingFeature: import('@tanstack/react-table').TableFeature;
|
|
16
|
+
};
|
|
17
|
+
export type DataTableFeatures = typeof dataTableFeatures;
|
package/dist/types/schema.d.ts
CHANGED
|
@@ -152,8 +152,14 @@ export interface ManyToManyJoin {
|
|
|
152
152
|
* @interface Table
|
|
153
153
|
*/
|
|
154
154
|
export interface Table {
|
|
155
|
-
/** Original database table name */
|
|
155
|
+
/** Original database table name, unqualified: two schemas can share it. */
|
|
156
156
|
dbName: string;
|
|
157
|
+
/**
|
|
158
|
+
* Database schema that owns the table (`_dbSchema.schema`). `schema.dbName` is the
|
|
159
|
+
* table's unambiguous DB identity; send that, never the bare `dbName`, to a host
|
|
160
|
+
* that resolves DB names. Optional only because hand-built fixtures omit it.
|
|
161
|
+
*/
|
|
162
|
+
schema?: string;
|
|
157
163
|
/** GraphQL type name for the table */
|
|
158
164
|
graphQlName: string;
|
|
159
165
|
/** Alias for graphQlName */
|
|
@@ -212,4 +218,9 @@ export interface SchemaContextValue {
|
|
|
212
218
|
data: Table[];
|
|
213
219
|
/** Find a table by its GraphQL name */
|
|
214
220
|
findTable: (tableName: string) => Table | undefined;
|
|
221
|
+
/**
|
|
222
|
+
* The server's row ceiling (`_maxQueryRows`, its `max-query-rows`). Set once the
|
|
223
|
+
* schema loads; grouping sizes its window from it and refuses to run without it.
|
|
224
|
+
*/
|
|
225
|
+
maxQueryRows?: number;
|
|
215
226
|
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@standardbeagle/edit-db",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.831",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@radix-ui/react-slot": "^1.5.0",
|
|
8
8
|
"@tanstack/react-form": "^1.33.5",
|
|
9
|
-
"@tanstack/react-query": "^5.
|
|
10
|
-
"@tanstack/react-table": "^
|
|
9
|
+
"@tanstack/react-query": "^5.107.1",
|
|
10
|
+
"@tanstack/react-table": "^9.3.1",
|
|
11
11
|
"class-variance-authority": "^0.7.1",
|
|
12
12
|
"clsx": "^2.1.1",
|
|
13
13
|
"lucide-react": "^0.577.0",
|
|
@@ -17,31 +17,30 @@
|
|
|
17
17
|
"tailwind-merge": "^3.7.0"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@
|
|
21
|
-
"@storybook/addon-links": "^10.6.
|
|
22
|
-
"@storybook/react": "^10.6.
|
|
23
|
-
"@storybook/react-vite": "^10.6.
|
|
24
|
-
"@tailwindcss/vite": "^4.3.
|
|
25
|
-
"@testing-library/
|
|
20
|
+
"@eslint/js": "^10.0.1",
|
|
21
|
+
"@storybook/addon-links": "^10.6.6",
|
|
22
|
+
"@storybook/react": "^10.6.6",
|
|
23
|
+
"@storybook/react-vite": "^10.6.6",
|
|
24
|
+
"@tailwindcss/vite": "^4.3.5",
|
|
25
|
+
"@testing-library/dom": "^10.4.2",
|
|
26
|
+
"@testing-library/jest-dom": "^7.0.1",
|
|
26
27
|
"@testing-library/react": "^16.3.3",
|
|
27
28
|
"@types/react": "^18.3.29",
|
|
28
29
|
"@types/react-dom": "^18.3.7",
|
|
29
|
-
"@typescript-eslint/eslint-plugin": "^8.69.0",
|
|
30
|
-
"@typescript-eslint/parser": "^8.69.0",
|
|
31
30
|
"@vitejs/plugin-react-swc": "^4.3.3",
|
|
32
31
|
"ajv": "^8.20.0",
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"eslint": "^
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"tailwindcss": "^4.3.3",
|
|
32
|
+
"browserslist": "^4.29.5",
|
|
33
|
+
"eslint": "^10.14.0",
|
|
34
|
+
"eslint-plugin-react-hooks": "^7.1.1",
|
|
35
|
+
"globals": "^17.14.0",
|
|
36
|
+
"jsdom": "^31.0.0",
|
|
37
|
+
"storybook": "^10.6.6",
|
|
38
|
+
"tailwindcss": "^4.3.5",
|
|
41
39
|
"typescript": "^5.9.3",
|
|
42
|
-
"
|
|
40
|
+
"typescript-eslint": "^8.72.2",
|
|
41
|
+
"vite": "^8.3.7",
|
|
43
42
|
"vite-plugin-dts": "^5.1.0",
|
|
44
|
-
"vitest": "^
|
|
43
|
+
"vitest": "^5.1.0"
|
|
45
44
|
},
|
|
46
45
|
"peerDependencies": {
|
|
47
46
|
"@tanstack/react-query": "^5.0.0"
|
|
@@ -69,7 +68,7 @@
|
|
|
69
68
|
"scripts": {
|
|
70
69
|
"dev": "vite",
|
|
71
70
|
"build": "tsc && vite build --mode production",
|
|
72
|
-
"lint": "eslint . --
|
|
71
|
+
"lint": "eslint . --report-unused-disable-directives --max-warnings 0",
|
|
73
72
|
"preview": "vite preview",
|
|
74
73
|
"storybook": "storybook dev -p 6006",
|
|
75
74
|
"storybook-build": "storybook build",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|