@standardbeagle/edit-db 0.4.597 → 0.4.688

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.
@@ -1,3 +1,4 @@
1
+ import { DefaultSort } from './useEditorConfig';
1
2
  import { Table, Column, Join } from '../types/schema';
2
3
  import { ColumnDef, ColumnFiltersState, SortingState } from '@tanstack/react-table';
3
4
  import { DrillFrame } from '../lib/drill-stack';
@@ -129,4 +130,12 @@ interface UseDataTableResult {
129
130
  * @param onOpenColumn - Callback when opening a side panel column
130
131
  * @returns Data table state and control functions
131
132
  */
133
+ /**
134
+ * The sort a grid opens with, from the host's `defaultSort` config: the table's
135
+ * own entry wins over `"*"`. Empty when nothing is configured, when the named
136
+ * column is not on the table, or when it cannot drive an ORDER BY (blob/JSON),
137
+ * so the caller falls back to its positional default instead of erroring the
138
+ * first query.
139
+ */
140
+ export declare function resolveConfiguredSort(table: Table | null, defaultSort: Record<string, DefaultSort> | undefined): SortingState;
132
141
  export declare function useDataTable(table: Table | null, id?: string, filterTable?: string, filterColumn?: string, onExpandContent?: (rowIndex: number, columnName: string) => void, onOpenColumn?: (panel: DrillFrame) => void): UseDataTableResult;
@@ -1,5 +1,10 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { TableAction } from '../lib/table-action';
3
+ /** One configured grid sort: the column name and its direction (ascending unless `desc`). */
4
+ export interface DefaultSort {
5
+ column: string;
6
+ desc?: boolean;
7
+ }
3
8
  /**
4
9
  * Optional, opt-in editor features. Kept tiny and separate from the data/schema
5
10
  * contexts so feature flags don't force those providers to re-render and so
@@ -32,6 +37,19 @@ export interface EditorConfig {
32
37
  * annotate but sit in the middle of the natural column order.
33
38
  */
34
39
  trailingColumns?: string[];
40
+ /**
41
+ * Sort a grid opens with, keyed by table name; `"*"` covers every table
42
+ * without its own entry. Resolved by `resolveConfiguredSort` in
43
+ * useDataTable, which drops an entry naming a column the table lacks or
44
+ * cannot ORDER BY, so a host-wide `id desc` is safe on keyless tables.
45
+ */
46
+ defaultSort?: Record<string, DefaultSort>;
47
+ /**
48
+ * Column the header quick-search starts on, keyed by table name. Applied by
49
+ * the header only when the column is one it can search (string/numeric);
50
+ * anything else falls back to the first searchable column.
51
+ */
52
+ defaultSearchColumns?: Record<string, string>;
35
53
  /**
36
54
  * Host-contributed actions on each table in the navigation list, rendered in
37
55
  * the table's kebab menu AFTER the built-in Download actions. The host owns
@@ -10,4 +10,4 @@ import { ExportFormat, ExportResult } from '../lib/export';
10
10
  * <see cref="DEFAULT_ROW_CAP"/> bounds the drain; the result reports
11
11
  * `truncated` so the caller can warn instead of silently shipping a partial file.
12
12
  */
13
- export declare function useTableExport(): (table: Table, format: ExportFormat) => Promise<ExportResult>;
13
+ export declare function useTableExport(): (table: Table, format: ExportFormat, signal?: AbortSignal) => Promise<ExportResult>;
@@ -0,0 +1 @@
1
+ export {};
@@ -26,6 +26,8 @@ export declare const UTF8_BOM = "\uFEFF";
26
26
  * `null`/`undefined` become a bare empty field; an empty string becomes a
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
+ * String values that would execute as a spreadsheet formula are prefixed with
30
+ * an apostrophe.
29
31
  */
30
32
  export declare function formatCsvCell(value: unknown): string;
31
33
  export interface CsvOptions {
@@ -62,8 +64,12 @@ export interface ExportAllOptions {
62
64
  * Pull one page at the given offset. This is the ONLY data seam — the caller
63
65
  * closes over the existing fetcher/query-builder so the current filters and
64
66
  * sort are honored, and no new HTTP client is introduced.
67
+ *
68
+ * The abort signal is passed to the seam on every page — not left for each
69
+ * call site to close over — so cancelling reaches the IN-FLIGHT request,
70
+ * not just the loop's next iteration.
65
71
  */
66
- fetchPage: (offset: number, limit: number) => Promise<ExportPage>;
72
+ fetchPage: (offset: number, limit: number, signal: AbortSignal | undefined) => Promise<ExportPage>;
67
73
  /** Page size for each fetch. Default 500. */
68
74
  pageSize?: number;
69
75
  /** Hard stop after this many rows; the result is marked `truncated`. */
@@ -45,10 +45,19 @@ export interface FormatOptions {
45
45
  export declare function resolveDisplayFormat(column: Column, formatKey?: string): DisplayFormat | null;
46
46
  /** "4 hours ago" / "in 3 days" via Intl.RelativeTimeFormat. */
47
47
  export declare function formatRelative(date: Date, now?: Date): string;
48
+ /**
49
+ * Display labels for an enum column, or null when it has none that can be
50
+ * trusted. `enum-labels` are positional against `enum-values`, so a count
51
+ * mismatch would mislabel every value; it is treated as no labels at all.
52
+ */
53
+ export declare function usableEnumLabels(column: Column): string[] | null;
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
+ export declare function enumLabelFor(value: unknown, column: Column): string | null;
48
56
  /**
49
57
  * Format a scalar value for display, given its column. Returns a muted
50
- * placeholder for null/empty, a locale-formatted node for known formats (with a
51
- * `title` revealing the exact value), or the plain string otherwise.
58
+ * placeholder for null/empty, the enum label for a labelled enum value (with
59
+ * the stored value in `title`), a locale-formatted node for known formats (with
60
+ * a `title` revealing the exact value), or the plain string otherwise.
52
61
  */
53
62
  export declare function formatColumnValue(value: unknown, column: Column, options?: FormatOptions): ReactNode;
54
63
  /**
@@ -38,6 +38,17 @@ interface RowData {
38
38
  }
39
39
  export declare function isGraphQlName(value: unknown): value is string;
40
40
  export declare function assertGraphQlName(value: unknown, kind: string): asserts value is string;
41
+ /**
42
+ * The single producer of a table's generated filter input type name.
43
+ *
44
+ * The server names it `TableFilter<graphQlName>Input`
45
+ * (DbTable.TableFilterTypeName, src/BifrostQL.Core/Model/DbTable.cs). Spelling
46
+ * it inline invites the `<graphQlName>Filter` guess, which parses fine and then
47
+ * fails server-side with "Unknown type '<graphQlName>Filter'." on every
48
+ * FILTERED request while the unfiltered path keeps working. Every builder that
49
+ * declares a `$filter` variable calls this, so the two sides cannot drift.
50
+ */
51
+ export declare function tableFilterTypeName(table: Table): string;
41
52
  export declare function getFilterOperators(paramType: string): string[];
42
53
  /**
43
54
  * Parses the header filter (a JSON `[column, operator, value, type]` tuple carried
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Which column the header quick-search starts on. The host's configured column
3
+ * for the table wins when it is one of the searchable options; otherwise the
4
+ * first option, so a table with no configuration behaves as before. Returns the
5
+ * option's `value` (the `name,paramType` pair the header keys its picker by).
6
+ */
7
+ export declare function pickDefaultSearchColumn(options: ReadonlyArray<{
8
+ key: string;
9
+ value: string;
10
+ }> | undefined, configured: string | undefined): string;
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@standardbeagle/edit-db",
3
3
  "private": false,
4
- "version": "0.4.597",
4
+ "version": "0.4.688",
5
5
  "type": "module",
6
6
  "dependencies": {
7
7
  "@radix-ui/react-slot": "^1.2.4",
@@ -39,7 +39,7 @@
39
39
  "storybook": "^10.4.1",
40
40
  "tailwindcss": "^4.3.0",
41
41
  "typescript": "^5.9.3",
42
- "vite": "^7.3.6",
42
+ "vite": "^8.2.2",
43
43
  "vite-plugin-dts": "^4.5.4",
44
44
  "vitest": "^4.1.8"
45
45
  },