grist-widget-sdk 0.3.26 → 0.4.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/CHANGELOG.md +53 -0
- package/README.md +1 -1
- package/dist/app.cjs +1139 -4336
- package/dist/app.cjs.map +1 -1
- package/dist/app.d.cts +1 -3
- package/dist/app.d.ts +1 -3
- package/dist/app.js +9 -517
- package/dist/app.js.map +1 -1
- package/dist/chunk-4ZGVKGDF.js +204 -0
- package/dist/chunk-4ZGVKGDF.js.map +1 -0
- package/dist/{chunk-YQNMIL33.js → chunk-B5ZZNLVS.js} +528 -181
- package/dist/chunk-B5ZZNLVS.js.map +1 -0
- package/dist/chunk-O7NY46QY.js +1830 -0
- package/dist/chunk-O7NY46QY.js.map +1 -0
- package/dist/chunk-P6VTEKWO.js +618 -0
- package/dist/chunk-P6VTEKWO.js.map +1 -0
- package/dist/emulator/testing.cjs +2084 -391
- package/dist/emulator/testing.cjs.map +1 -1
- package/dist/emulator/testing.d.cts +55 -7
- package/dist/emulator/testing.d.ts +55 -7
- package/dist/emulator/testing.js +144 -19
- package/dist/emulator/testing.js.map +1 -1
- package/dist/emulator.cjs +59 -249
- package/dist/emulator.cjs.map +1 -1
- package/dist/emulator.d.cts +3 -5
- package/dist/emulator.d.ts +3 -5
- package/dist/emulator.js +5 -11
- package/dist/index.cjs +1373 -4859
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +81 -260
- package/dist/index.d.ts +81 -260
- package/dist/index.js +8 -161
- package/dist/{inline-C7DkvuET.d.cts → templates-CGmRIQBV.d.cts} +89 -35
- package/dist/{inline-DpcT8tV9.d.ts → templates-Cq94qOcf.d.ts} +89 -35
- package/dist/{types-D3JxUCfL.d.cts → types-DBStn0Dk.d.cts} +2 -26
- package/dist/{types-D3JxUCfL.d.ts → types-DBStn0Dk.d.ts} +2 -26
- package/dist/use-grist-BK0eke9K.d.cts +358 -0
- package/dist/use-grist-C5DMZ3wU.d.ts +358 -0
- package/package.json +8 -37
- package/dist/advanced.cjs +0 -2799
- package/dist/advanced.cjs.map +0 -1
- package/dist/advanced.d.cts +0 -822
- package/dist/advanced.d.ts +0 -822
- package/dist/advanced.js +0 -875
- package/dist/advanced.js.map +0 -1
- package/dist/chunk-22U7WAY3.js +0 -463
- package/dist/chunk-22U7WAY3.js.map +0 -1
- package/dist/chunk-64SVRWW7.js +0 -758
- package/dist/chunk-64SVRWW7.js.map +0 -1
- package/dist/chunk-ELGVOHFD.js +0 -32
- package/dist/chunk-ELGVOHFD.js.map +0 -1
- package/dist/chunk-EPEBKXVN.js +0 -470
- package/dist/chunk-EPEBKXVN.js.map +0 -1
- package/dist/chunk-GTTD5HPO.js +0 -36
- package/dist/chunk-GTTD5HPO.js.map +0 -1
- package/dist/chunk-JASMM2YC.js +0 -243
- package/dist/chunk-JASMM2YC.js.map +0 -1
- package/dist/chunk-N3X46JW2.js +0 -37
- package/dist/chunk-N3X46JW2.js.map +0 -1
- package/dist/chunk-PDGEZ24B.js +0 -2366
- package/dist/chunk-PDGEZ24B.js.map +0 -1
- package/dist/chunk-PM3B4WYV.js +0 -12
- package/dist/chunk-PM3B4WYV.js.map +0 -1
- package/dist/chunk-REV5AUXD.js +0 -25
- package/dist/chunk-REV5AUXD.js.map +0 -1
- package/dist/chunk-TZB3OZA6.js +0 -1630
- package/dist/chunk-TZB3OZA6.js.map +0 -1
- package/dist/chunk-YQNMIL33.js.map +0 -1
- package/dist/create-grist-emulator-BCqp1BF9.d.ts +0 -81
- package/dist/create-grist-emulator-DBM8OSIR.d.cts +0 -81
- package/dist/emulator/devtools.cjs +0 -1404
- package/dist/emulator/devtools.cjs.map +0 -1
- package/dist/emulator/devtools.d.cts +0 -48
- package/dist/emulator/devtools.d.ts +0 -48
- package/dist/emulator/devtools.js +0 -508
- package/dist/emulator/devtools.js.map +0 -1
- package/dist/emulator/transports.cjs +0 -1132
- package/dist/emulator/transports.cjs.map +0 -1
- package/dist/emulator/transports.d.cts +0 -38
- package/dist/emulator/transports.d.ts +0 -38
- package/dist/emulator/transports.js +0 -12
- package/dist/emulator/transports.js.map +0 -1
- package/dist/templates-8k2LKoO-.d.cts +0 -24
- package/dist/templates-DIwi_mvI.d.ts +0 -24
- package/dist/use-grist-reads-DUMvJgV7.d.ts +0 -480
- package/dist/use-grist-reads-DpjVuI0H.d.cts +0 -480
- package/dist/use-grist-types-DdOLEJXN.d.cts +0 -499
- package/dist/use-grist-types-kwxoFeub.d.ts +0 -499
- package/dist/use-grist-widget-options-from-context-CGOlQ5Vc.d.cts +0 -43
- package/dist/use-grist-widget-options-from-context-CGOlQ5Vc.d.ts +0 -43
package/dist/index.d.ts
CHANGED
|
@@ -1,276 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import { G as GristSdkAlertsWidgetSlice, a as UseGristResult, b as GetGristSdkAlertDescriptorsOptions, c as GristSdkAlertDescriptor, U as UseGristOptions, d as UseGristSelectionResult, e as UseGristStatusResult, f as UseGristThemeResult, g as UseGristWritesResult } from './use-grist-types-kwxoFeub.js';
|
|
4
|
-
export { B as BuildReplicaDocumentFromDocApiOptions, h as GristAttachmentUploadResult, i as GristEncodedAttachmentList, j as GristFetchedAttachment, k as GristFetchedAttachmentBlob, l as GristSdkAlertKind, m as GristSdkAlertSeverity, n as GristTheme, o as GristWidgetActionStatus, p as GristWidgetMode, R as ReplicaTableColumnMetaLite, V as ValidateColumnMappingsResult, q as buildReplicaColumnsFromColumnar, r as buildReplicaDocumentFromDocApi, s as extractAttachmentIdsFromUploadPayload, t as extractFirstAttachmentIdFromUploadPayload, u as extractGristAttachmentId, v as extractGristAttachmentIdsFromCell, w as fetchAttachmentBase64, x as fetchAttachmentBase64ForCell, y as fetchAttachmentBlob, z as formatAccessInsufficientMessage, A as formatColumnMappingAlertMessage, C as formatLinkStaleAlertMessage, D as formatMappingPendingAlertMessage, E as formatMappingUnreportedAlertMessage, F as formatSectionNotLinkedAlertMessage, H as formatSourceNotWiredAlertMessage, I as getAttachmentDownloadUrl, J as getAttachmentDownloadUrlForCell, K as getGristSdkAlertDescriptors, L as getGristSdkAlertSeverity, M as getGristSdkAlertTitle, N as gristAttachmentCellValue, O as gristAttachmentCellValues, P as isAccessInsufficientError, Q as isWidgetSectionNotLinked, S as loadColumnMetadataByTable, T as mergeGristAttachmentCellValue, W as orderedColumnIds, X as parseGristAttachmentUploadResponse, Y as parseGristAttachmentUploadResponseIds, Z as uploadGristAttachment, _ as validateColumnMappings } from './use-grist-types-kwxoFeub.js';
|
|
5
|
-
import { a as GristNoiseColumnsOptions } from './use-grist-reads-DUMvJgV7.js';
|
|
6
|
-
import { GristWidgetSnapshot } from './advanced.js';
|
|
7
|
-
export { F as FetchGristTableRowsOptions, b as GristAccessToken, c as GristCapabilities, d as GristCellValue, e as GristColumnInfo, f as GristColumnLike, g as GristColumnarTable, h as GristSafeParseCellResult, i as GristSafeParseIssue, j as GristSafeParseIssueCode, k as GristSafeRefListValue, l as GristSafeRefValue, m as GristSafeTableCellIssue, n as GristSafeTableCellMeta, o as GristTableRowsOrder, p as GristUserActionTuple, q as GristWidgetStatus, L as ListColumnsOptions, r as ListTablesOptions, S as SafeParseGristTableDataOptions, s as SafeParseGristTableDataResult, t as SafeParseGristValuesOptions, U as UseGristCoreOptions, u as UseGristCoreResult, v as computeRowCount, w as decodeColumnarToReplicaRows, x as fetchGristRow, y as fetchGristTableRows, z as fetchWithGristAuth, A as findRowIndexById, B as getGristAccessToken, C as gristAddColumnAction, D as gristAddRecordAction, E as gristAddTableAction, H as gristAddVisibleColumnAction, I as gristBulkAddRecordAction, J as gristBulkRemoveRecordAction, K as gristBulkUpdateRecordAction, M as gristCellValueSchema, N as gristDuplicateTableAction, O as gristModifyColumnAction, P as gristRemoveColumnAction, Q as gristRemoveRecordAction, R as gristRemoveTableAction, T as gristRenameColumnAction, V as gristRenameTableAction, W as gristReplaceTableDataAction, X as gristSafeRefListValueSchema, Y as gristSafeRefValueSchema, Z as gristSetDocumentInfoAction, _ as gristUpdateRecordAction, $ as inferDisplayHelpersByRef, a0 as isGristNoiseColumn, a1 as materializeGristRowsFromColumnar, a2 as rowAtIndex, a3 as safeParseGristTableData, a4 as safeParseGristValues, a5 as safeParseRowsToDisplayRows, a6 as sortRowsByGristOrder, a7 as tableDataToRows } from './use-grist-reads-DUMvJgV7.js';
|
|
1
|
+
import { U as UseGristOptions, G as GristNoiseColumnsOptions } from './use-grist-C5DMZ3wU.js';
|
|
2
|
+
export { a as GristAttachmentUploadResult, b as GristCellIssue, c as GristColumnInfo, d as GristColumnarTable, e as GristFetchedAttachmentBlob, f as GristMappedRow, g as GristSdkAlertKind, h as GristTheme, i as GristUserActionTuple, j as GristWidgetActionStatus, k as GristWidgetMode, l as GristWidgetStatus, L as ListColumnsOptions, m as ListTablesOptions, S as StandardSchema, n as UseGristResult, V as ValidateColumnMappingsResult, o as checkGristCell, p as extractGristAttachmentId, q as extractGristAttachmentIdsFromCell, r as gristAddColumnAction, s as gristAddRecordAction, t as gristAddTableAction, u as gristAddVisibleColumnAction, v as gristAttachmentCellValue, w as gristAttachmentCellValues, x as gristModifyColumnAction, y as gristRemoveColumnAction, z as gristRemoveRecordAction, A as gristRenameColumnAction, B as gristUpdateRecordAction, C as mergeGristAttachmentCellValue, D as tableDataToRows, E as useGrist, F as useGristContext, H as useGristOptional } from './use-grist-C5DMZ3wU.js';
|
|
8
3
|
import * as react from 'react';
|
|
9
4
|
import { ReactNode } from 'react';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
declare function inferGristFormulaKind(isFormula: boolean, formulaTrimmed: string): GristFormulaKind;
|
|
14
|
-
/** Use when `formulaKind` may be missing (e.g. older document builds). */
|
|
15
|
-
declare function resolveGristFormulaKind(col: GristReplicaColumn): GristFormulaKind;
|
|
16
|
-
/** Serialize cell values for JSON output. */
|
|
17
|
-
declare function serializeJsonFriendly(value: unknown): unknown;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Ensure `rows` is a concrete array for emulator / merge logic.
|
|
21
|
-
* Call at host boundaries (`createDocument`, tests); JSON may still omit `rows` for schema-only.
|
|
22
|
-
*/
|
|
23
|
-
declare function normalizeReplicaTableInput<T extends GristReplicaTable>(table: T): T & {
|
|
24
|
-
rows: GristReplicaRow[];
|
|
25
|
-
};
|
|
26
|
-
/** Apply {@link normalizeReplicaTableInput} to every table; shallow-copies the document shell. */
|
|
27
|
-
declare function normalizeReplicaDocumentInput<T extends GristReplicaDocument>(doc: T): T;
|
|
28
|
-
/** How row arrays appear in serialized replica JSON from {@link buildReplicaJsonPayload}. */
|
|
29
|
-
type ReplicaJsonIncludeRows = "none" | "samples" | "full";
|
|
30
|
-
/**
|
|
31
|
-
* Clone a replica document for JSON output: strip rows, cap to first N, or pass through.
|
|
32
|
-
* Does not mutate the source document.
|
|
33
|
-
*/
|
|
34
|
-
declare function buildReplicaJsonPayload(doc: GristReplicaDocument, options: {
|
|
35
|
-
includeRows: ReplicaJsonIncludeRows;
|
|
36
|
-
sampleRowLimit?: number;
|
|
37
|
-
}): GristReplicaDocument;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Grist stores column widget configuration in `_grist_Tables_column.widgetOptions`
|
|
41
|
-
* as a JSON string. Choice fields use `choices: string[]` plus optional
|
|
42
|
-
* `choiceOptions: Record<string, Style>` (e.g. `fillColor`, `textColor`).
|
|
43
|
-
*
|
|
44
|
-
* @see https://github.com/gristlabs/grist-core/blob/main/app/client/widgets/ChoiceEditor.js
|
|
45
|
-
*/
|
|
46
|
-
/** One selectable choice for UI (value stored in the cell is `value`). */
|
|
47
|
-
type GristChoiceListEntry = {
|
|
48
|
-
value: string;
|
|
49
|
-
label: string;
|
|
50
|
-
fillColor?: string;
|
|
51
|
-
textColor?: string;
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* Parse a cell value from `_grist_Tables_column.widgetOptions` into a plain object.
|
|
55
|
-
*/
|
|
56
|
-
declare function parseGristWidgetOptionsCell(raw: unknown): Record<string, unknown> | undefined;
|
|
57
|
-
/**
|
|
58
|
-
* Normalizes Grist Choice / ChoiceList widgetOptions into a flat list for dropdowns.
|
|
59
|
-
* `choices` entries are string labels (the stored cell value). Per-choice styling
|
|
60
|
-
* lives in `choiceOptions[label]`.
|
|
61
|
-
*/
|
|
62
|
-
declare function normalizeGristChoiceListEntries(widgetOptions: Record<string, unknown> | undefined): GristChoiceListEntry[];
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Encoding helpers for Grist cell values.
|
|
66
|
-
*
|
|
67
|
-
* Grist sends some types as marshalled tuples or numeric epochs. This file
|
|
68
|
-
* exposes pure decode/encode functions so widget code never has to spelunk
|
|
69
|
-
* Grist's wire format.
|
|
70
|
-
*
|
|
71
|
-
* References: Grist `grist/RowRecord` and `grist/DocActions` typings.
|
|
72
|
-
*/
|
|
73
|
-
|
|
74
|
-
/** `["E", "ErrorClass", "message", traceback?]` — Grist error sentinel. */
|
|
75
|
-
type GristEncodedError = ["E", string, string?, string?];
|
|
76
|
-
/** `["L", ...items]` — list (used for ChoiceList, RefList, Attachments). */
|
|
77
|
-
type GristEncodedList = ["L", ...unknown[]];
|
|
78
|
-
/** `["D", epochSeconds, "tz/Name"]` — DateTime with timezone. */
|
|
79
|
-
type GristEncodedDateTime = ["D", number, string];
|
|
80
|
-
/** `["d", epochSeconds]` — Date (no time). */
|
|
81
|
-
type GristEncodedDate = ["d", number];
|
|
82
|
-
/** `["R", tableId, rowId]` — explicit reference. */
|
|
83
|
-
type GristEncodedRef = ["R", string, number];
|
|
84
|
-
/** `["r", rowId]` — bare reference (when table is contextual). */
|
|
85
|
-
type GristEncodedBareRef = ["r", number];
|
|
86
|
-
/** `["P", encoded]` — pending marker. */
|
|
87
|
-
type GristEncodedPending = ["P"];
|
|
88
|
-
type GristDecodedValue = null | string | number | boolean | Date | GristDecodedValue[] | {
|
|
89
|
-
__error: true;
|
|
90
|
-
type: string;
|
|
91
|
-
message?: string;
|
|
92
|
-
traceback?: string;
|
|
93
|
-
} | {
|
|
94
|
-
__ref: true;
|
|
95
|
-
tableId?: string;
|
|
96
|
-
rowId: number;
|
|
97
|
-
};
|
|
98
|
-
/**
|
|
99
|
-
* Normalises a Grist `fetchTable` cell that points at a row in another table.
|
|
100
|
-
* Most payloads use a bare numeric row id, but `Ref:*` values may appear as
|
|
101
|
-
* `["R", tableId, rowId]` or `["r", rowId]` (same shape as {@link decodeGristValue}).
|
|
102
|
-
*/
|
|
103
|
-
declare function coerceGristDocApiRefRowId(value: unknown): number | undefined;
|
|
104
|
-
/**
|
|
105
|
-
* Decodes a Grist cell value into an idiomatic JS value.
|
|
106
|
-
*
|
|
107
|
-
* Pass the column's metadata (from `useGristSchema` or `_grist_Tables_column`)
|
|
108
|
-
* for type-aware decoding (e.g. `Date` columns return `Date` even when stored as a number).
|
|
109
|
-
*/
|
|
110
|
-
declare function decodeGristValue(value: unknown, column?: GristReplicaColumn): GristDecodedValue;
|
|
111
|
-
/** Convenience: true when the cell is a Grist error sentinel. */
|
|
112
|
-
declare function isGristCellError(value: unknown): value is GristEncodedError;
|
|
113
|
-
/**
|
|
114
|
-
* Encodes a JS value into Grist's expected wire form for a given column type.
|
|
115
|
-
*
|
|
116
|
-
* Use before passing values to `applyUserActions` or `TableOperations.update`
|
|
117
|
-
* for `Date`, `DateTime`, `Ref`, `RefList`, and `ChoiceList` columns.
|
|
118
|
-
*/
|
|
119
|
-
declare function encodeGristValue(value: unknown, column?: GristReplicaColumn): unknown;
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Pure projections from the handshake snapshot for boundary / shell UI.
|
|
123
|
-
*
|
|
124
|
-
* Blocking states (`booting`, `unavailable`, `error`) map to full-screen chrome
|
|
125
|
-
* via `<GristBoundary>`. Non-blocking degradations stay on the alert path
|
|
126
|
-
* ({@link getGristSdkAlertDescriptors}).
|
|
127
|
-
*/
|
|
128
|
-
|
|
129
|
-
type GristBoundaryBlockingKind = "booting" | "unavailable" | "error";
|
|
130
|
-
type GristBoundaryBootPhase = "idle" | "detecting" | "negotiating" | "generic";
|
|
131
|
-
type GristBoundaryView = {
|
|
132
|
-
mode: "blocking";
|
|
133
|
-
kind: GristBoundaryBlockingKind;
|
|
134
|
-
bootPhase?: GristBoundaryBootPhase;
|
|
135
|
-
title: string;
|
|
136
|
-
message: string;
|
|
137
|
-
showRetry: boolean;
|
|
138
|
-
} | {
|
|
139
|
-
mode: "ready";
|
|
140
|
-
};
|
|
141
|
-
/**
|
|
142
|
-
* Human-readable boot label from lifecycle phase (for spinners / progress UI).
|
|
143
|
-
*/
|
|
144
|
-
declare function deriveBoundaryBootLabel(snapshot: GristWidgetSnapshot): string;
|
|
145
|
-
declare function deriveBoundaryBootPhase(snapshot: GristWidgetSnapshot): GristBoundaryBootPhase;
|
|
146
|
-
/**
|
|
147
|
-
* Turn internal handshake errors into short, actionable copy for `<GristBoundary>`.
|
|
148
|
-
*/
|
|
149
|
-
declare function formatBoundaryUserMessage(raw: string | null, snapshot: GristWidgetSnapshot): string;
|
|
150
|
-
/**
|
|
151
|
-
* Classify how `<GristBoundary>` should render: full-screen blocking vs children.
|
|
152
|
-
*/
|
|
153
|
-
declare function deriveBoundaryView(snapshot: GristWidgetSnapshot): GristBoundaryView;
|
|
154
|
-
/** Copy for `gate="canRender"` while column mappings are not yet usable. */
|
|
155
|
-
declare const GRIST_BOUNDARY_PREPARING_COPY: {
|
|
156
|
-
readonly title: "Map your columns";
|
|
157
|
-
readonly message: "Open the widget settings in Grist (Creator Panel → Custom widget) and connect each required column to your table.";
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* React hook: widget slice + optional handshake snapshot for
|
|
162
|
-
* {@link getGristSdkAlertDescriptors}.
|
|
163
|
-
*/
|
|
164
|
-
declare function useGristSdkAlertDescriptors(widget?: GristSdkAlertsWidgetSlice | UseGristResult, options?: GetGristSdkAlertDescriptorsOptions): GristSdkAlertDescriptor[];
|
|
5
|
+
import { a as GristReplicaTable, l as GristRequiredAccess, m as GristDocumentMode, e as GristReplicaColumn, i as GristReadyOptions, G as GristReplicaDocument, n as GristFormulaKind } from './types-DBStn0Dk.js';
|
|
6
|
+
export { o as GristApplyUserActionsOptions, p as GristColumnToMap, q as GristColumnsToMap, c as GristCursorPos, j as GristFetchSelectedOptions, r as GristReplicaRow, f as GristRowRecord, k as GristTableOperations, b as GristWidgetColumnMap, d as GristWidgetInteraction } from './types-DBStn0Dk.js';
|
|
165
7
|
|
|
166
8
|
type GristWidgetProviderProps = {
|
|
9
|
+
/** Read once, at mount: what the widget asks Grist for. */
|
|
167
10
|
options?: UseGristOptions;
|
|
168
11
|
children: ReactNode;
|
|
169
12
|
};
|
|
170
13
|
/**
|
|
171
|
-
*
|
|
172
|
-
* `
|
|
173
|
-
*
|
|
174
|
-
* Owns a {@link GristHandshakeManager} and mounts the slice / full-result context
|
|
175
|
-
* tree underneath it so `useRpcHeartbeatCoalesce()` in slice hooks sees the manager
|
|
176
|
-
* (ordering required — see `tests/sdk/handshake-rpc-coalesce.test.tsx`).
|
|
14
|
+
* Connects to Grist for the widgets below it: `useGrist()` under it reads this
|
|
15
|
+
* connection. `mountGristWidget()` renders it; render it yourself only for a
|
|
16
|
+
* page that manages its own React root.
|
|
177
17
|
*/
|
|
178
18
|
declare function GristWidgetProvider({ options, children }: GristWidgetProviderProps): react.JSX.Element;
|
|
179
|
-
/**
|
|
180
|
-
* Access the full `UseGristResult` from inside a `<GristWidgetProvider>`.
|
|
181
|
-
*
|
|
182
|
-
* The returned object updates whenever any Grist state changes (record selection,
|
|
183
|
-
* widget options, etc.). Individual methods on the result (e.g. `w.fetchTable`,
|
|
184
|
-
* `w.listTables`) are referentially stable and safe to use in `useEffect` deps.
|
|
185
|
-
* See `UseGristResult` JSDoc for details.
|
|
186
|
-
*/
|
|
187
|
-
declare function useGristContext<TRow = Record<string, unknown>, TMapped = Record<string, unknown>>(): UseGristResult<TRow, TMapped>;
|
|
188
|
-
declare function useGristOptional<TRow = Record<string, unknown>, TMapped = Record<string, unknown>>(): UseGristResult<TRow, TMapped> | null;
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Primary Grist hook — use inside `<GristWidgetProvider>` via `useGristContext()`,
|
|
192
|
-
* or standalone in a single-leaf widget.
|
|
193
|
-
*/
|
|
194
|
-
declare function useGrist<TRow = Record<string, unknown>, TMapped = Record<string, unknown>>(options?: UseGristOptions): UseGristResult<TRow, TMapped>;
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Slice subscriber: status + current-table info. Re-renders on status, error,
|
|
198
|
-
* `currentTableId`, or `currentTableLoading` changes only.
|
|
199
|
-
*
|
|
200
|
-
* Must be called inside `<GristWidgetProvider>` — for standalone usage use
|
|
201
|
-
* `useGrist()` directly.
|
|
202
|
-
*/
|
|
203
|
-
declare function useGristStatus(): UseGristStatusResult;
|
|
204
|
-
/**
|
|
205
|
-
* Slice subscriber for the selection / mappings / widget-options stream.
|
|
206
|
-
* Must be called inside `<GristWidgetProvider>`.
|
|
207
|
-
*/
|
|
208
|
-
declare function useGristSelection<TRow = Record<string, unknown>, TMapped = Record<string, unknown>>(): UseGristSelectionResult<TRow, TMapped>;
|
|
209
|
-
/**
|
|
210
|
-
* Slice subscriber for writes (`table`, `getTable`, `applyActions`, `actionStatus`).
|
|
211
|
-
* Must be called inside `<GristWidgetProvider>`.
|
|
212
|
-
*/
|
|
213
|
-
declare function useGristWrites(): UseGristWritesResult;
|
|
214
|
-
/**
|
|
215
|
-
* Slice subscriber for the host theme. Must be called inside `<GristWidgetProvider>`.
|
|
216
|
-
*/
|
|
217
|
-
declare function useGristTheme(): UseGristThemeResult;
|
|
218
19
|
|
|
219
|
-
type GristBoundaryGate = "ready" | "canRender";
|
|
220
20
|
type GristBoundaryProps = {
|
|
221
|
-
/**
|
|
222
|
-
* Pass an explicit widget instance (e.g. when not using `<GristWidgetProvider>`).
|
|
223
|
-
* Otherwise the boundary reads from the nearest provider.
|
|
224
|
-
*/
|
|
225
|
-
widget?: UseGristResult;
|
|
226
|
-
/**
|
|
227
|
-
* When `"canRender"`, children render only after mappings are usable
|
|
228
|
-
* (`capabilities.canRender`). Use for widgets that require mapped columns.
|
|
229
|
-
*/
|
|
230
|
-
gate?: GristBoundaryGate;
|
|
231
|
-
/** Rendered while `grist.ready` is in flight. */
|
|
232
|
-
bootingFallback?: ReactNode;
|
|
233
|
-
/** Shown when `gate="canRender"` and mappings are not yet usable. */
|
|
234
|
-
preparingFallback?: ReactNode;
|
|
235
|
-
/** Rendered when the widget is not embedded in Grist (e.g. opened directly). */
|
|
236
|
-
unavailableFallback?: ReactNode | ((actions: GristBoundaryActions) => ReactNode);
|
|
237
|
-
/** Rendered on any error from `useGristReady`, subscriptions, or actions. */
|
|
238
|
-
errorFallback?: (error: string, actions: GristBoundaryActions) => ReactNode;
|
|
239
|
-
/**
|
|
240
|
-
* Delay before showing "unavailable" UI. Helps avoid false negatives on slow
|
|
241
|
-
* networks where the plugin API handshake arrives late.
|
|
242
|
-
*/
|
|
243
|
-
unavailableGraceMs?: number;
|
|
244
21
|
children: ReactNode;
|
|
245
22
|
};
|
|
246
|
-
type GristBoundaryActions = {
|
|
247
|
-
reload: () => Promise<void>;
|
|
248
|
-
isReloading: boolean;
|
|
249
|
-
};
|
|
250
|
-
type GristBoundaryScreenProps = {
|
|
251
|
-
title: string;
|
|
252
|
-
message: string;
|
|
253
|
-
/** Affects WAI-ARIA role only (`alert` vs `status`); copy uses the same neutral styles. */
|
|
254
|
-
tone?: "default" | "error";
|
|
255
|
-
showRetry?: boolean;
|
|
256
|
-
actions?: GristBoundaryActions;
|
|
257
|
-
retryLabel?: string;
|
|
258
|
-
retryBusyLabel?: string;
|
|
259
|
-
};
|
|
260
|
-
/** Centered full-viewport chrome for booting / unavailable / error states. */
|
|
261
|
-
declare function GristBoundaryScreen({ title, message, tone, showRetry, actions, retryLabel, retryBusyLabel, }: GristBoundaryScreenProps): react.JSX.Element;
|
|
262
23
|
/**
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
* <GristBoundary>
|
|
268
|
-
* <MyWidget />
|
|
269
|
-
* </GristBoundary>
|
|
270
|
-
* </GristWidgetProvider>
|
|
271
|
-
* ```
|
|
24
|
+
* Renders the widget once Grist is connected, has granted the access it
|
|
25
|
+
* declares, and every required declared column is mapped; until then, a
|
|
26
|
+
* screen that says what is missing (with a retry where one can help).
|
|
27
|
+
* Requires `<GristWidgetProvider>`; `mountGristWidget()` renders both.
|
|
272
28
|
*/
|
|
273
|
-
declare function GristBoundary({
|
|
29
|
+
declare function GristBoundary({ children }: GristBoundaryProps): react.JSX.Element;
|
|
30
|
+
|
|
31
|
+
/** How row arrays appear in serialized replica JSON from {@link buildReplicaJsonPayload}. */
|
|
32
|
+
type ReplicaJsonIncludeRows = "none" | "samples" | "full";
|
|
274
33
|
|
|
275
34
|
type ColumnExcludeContext = {
|
|
276
35
|
tableId: string;
|
|
@@ -332,9 +91,71 @@ declare function useGristSchema(options?: UseGristSchemaOptions): UseGristSchema
|
|
|
332
91
|
type UseWidgetMetadataInput = {
|
|
333
92
|
title: string;
|
|
334
93
|
description: string;
|
|
335
|
-
syncToParent?: boolean;
|
|
336
94
|
};
|
|
337
95
|
declare function useWidgetMetadata(input?: UseWidgetMetadataInput | null): void;
|
|
338
96
|
|
|
339
|
-
|
|
340
|
-
|
|
97
|
+
/**
|
|
98
|
+
* Encoding helpers for Grist cell values.
|
|
99
|
+
*
|
|
100
|
+
* Grist sends some types as marshalled tuples or numeric epochs. This file
|
|
101
|
+
* exposes pure decode/encode functions so widget code never has to spelunk
|
|
102
|
+
* Grist's wire format.
|
|
103
|
+
*
|
|
104
|
+
* References: Grist `grist/RowRecord` and `grist/DocActions` typings.
|
|
105
|
+
*/
|
|
106
|
+
|
|
107
|
+
/** `["E", "ErrorClass", "message", traceback?]` — Grist error sentinel. */
|
|
108
|
+
type GristEncodedError = ["E", string, string?, string?];
|
|
109
|
+
type GristDecodedValue = null | string | number | boolean | Date | GristDecodedValue[] | {
|
|
110
|
+
__error: true;
|
|
111
|
+
type: string;
|
|
112
|
+
message?: string;
|
|
113
|
+
traceback?: string;
|
|
114
|
+
} | {
|
|
115
|
+
__ref: true;
|
|
116
|
+
tableId?: string;
|
|
117
|
+
rowId: number;
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Decodes a Grist cell value into an idiomatic JS value.
|
|
121
|
+
*
|
|
122
|
+
* Pass the column's metadata (from `useGristSchema` or `_grist_Tables_column`)
|
|
123
|
+
* for type-aware decoding (e.g. `Date` columns return `Date` even when stored as a number).
|
|
124
|
+
*/
|
|
125
|
+
declare function decodeGristValue(value: unknown, column?: GristReplicaColumn): GristDecodedValue;
|
|
126
|
+
/** Convenience: true when the cell is a Grist error sentinel. */
|
|
127
|
+
declare function isGristCellError(value: unknown): value is GristEncodedError;
|
|
128
|
+
/**
|
|
129
|
+
* Encodes a JS value into Grist's expected wire form for a given column type.
|
|
130
|
+
*
|
|
131
|
+
* Use before passing values to `applyUserActions` or `TableOperations.update`
|
|
132
|
+
* for `Date`, `DateTime`, `Ref`, `RefList`, and `ChoiceList` columns.
|
|
133
|
+
*/
|
|
134
|
+
declare function encodeGristValue(value: unknown, column?: GristReplicaColumn): unknown;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Grist stores column widget configuration in `_grist_Tables_column.widgetOptions`
|
|
138
|
+
* as a JSON string. Choice fields use `choices: string[]` plus optional
|
|
139
|
+
* `choiceOptions: Record<string, Style>` (e.g. `fillColor`, `textColor`).
|
|
140
|
+
*
|
|
141
|
+
* @see https://github.com/gristlabs/grist-core/blob/main/app/client/widgets/ChoiceEditor.js
|
|
142
|
+
*/
|
|
143
|
+
/** One selectable choice for UI (value stored in the cell is `value`). */
|
|
144
|
+
type GristChoiceListEntry = {
|
|
145
|
+
value: string;
|
|
146
|
+
label: string;
|
|
147
|
+
fillColor?: string;
|
|
148
|
+
textColor?: string;
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* Normalizes Grist Choice / ChoiceList widgetOptions into a flat list for dropdowns.
|
|
152
|
+
* `choices` entries are string labels (the stored cell value). Per-choice styling
|
|
153
|
+
* lives in `choiceOptions[label]`.
|
|
154
|
+
*/
|
|
155
|
+
declare function normalizeGristChoiceListEntries(widgetOptions: Record<string, unknown> | undefined): GristChoiceListEntry[];
|
|
156
|
+
|
|
157
|
+
/** Use when `formulaKind` may be missing (e.g. older document builds). */
|
|
158
|
+
declare function resolveGristFormulaKind(col: GristReplicaColumn): GristFormulaKind;
|
|
159
|
+
|
|
160
|
+
export { GristBoundary, GristDocumentMode, GristFormulaKind, GristNoiseColumnsOptions, GristReadyOptions, GristReplicaColumn, GristReplicaDocument, GristReplicaTable, GristRequiredAccess, GristWidgetProvider, UseGristOptions, decodeGristValue, encodeGristValue, isGristCellError, normalizeGristChoiceListEntries, resolveGristFormulaKind, useGristSchema, useWidgetMetadata };
|
|
161
|
+
export type { GristBoundaryProps, GristChoiceListEntry, GristSchemaTableView, GristWidgetProviderProps, ReplicaDocumentJsonOptions, UseGristSchemaOptions, UseGristSchemaResult, UseWidgetMetadataInput };
|
package/dist/index.js
CHANGED
|
@@ -1,216 +1,63 @@
|
|
|
1
1
|
import {
|
|
2
|
-
GRIST_BOUNDARY_PREPARING_COPY,
|
|
3
2
|
GristBoundary,
|
|
4
|
-
GristBoundaryScreen,
|
|
5
3
|
GristWidgetProvider,
|
|
6
|
-
|
|
7
|
-
buildReplicaDocumentFromDocApi,
|
|
8
|
-
deriveBoundaryBootLabel,
|
|
9
|
-
deriveBoundaryBootPhase,
|
|
10
|
-
deriveBoundaryView,
|
|
11
|
-
extractAttachmentIdsFromUploadPayload,
|
|
12
|
-
extractFirstAttachmentIdFromUploadPayload,
|
|
4
|
+
checkGristCell,
|
|
13
5
|
extractGristAttachmentId,
|
|
14
6
|
extractGristAttachmentIdsFromCell,
|
|
15
|
-
fetchAttachmentBase64,
|
|
16
|
-
fetchAttachmentBase64ForCell,
|
|
17
|
-
fetchAttachmentBlob,
|
|
18
|
-
formatAccessInsufficientMessage,
|
|
19
|
-
formatBoundaryUserMessage,
|
|
20
|
-
formatColumnMappingAlertMessage,
|
|
21
|
-
formatLinkStaleAlertMessage,
|
|
22
|
-
formatMappingPendingAlertMessage,
|
|
23
|
-
formatMappingUnreportedAlertMessage,
|
|
24
|
-
formatSectionNotLinkedAlertMessage,
|
|
25
|
-
formatSourceNotWiredAlertMessage,
|
|
26
|
-
getAttachmentDownloadUrl,
|
|
27
|
-
getAttachmentDownloadUrlForCell,
|
|
28
|
-
getGristSdkAlertDescriptors,
|
|
29
|
-
getGristSdkAlertSeverity,
|
|
30
|
-
getGristSdkAlertTitle,
|
|
31
7
|
gristAttachmentCellValue,
|
|
32
8
|
gristAttachmentCellValues,
|
|
33
|
-
inferGristFormulaKind,
|
|
34
|
-
isAccessInsufficientError,
|
|
35
|
-
isWidgetSectionNotLinked,
|
|
36
|
-
loadColumnMetadataByTable,
|
|
37
9
|
mergeGristAttachmentCellValue,
|
|
38
|
-
|
|
39
|
-
parseGristAttachmentUploadResponse,
|
|
40
|
-
parseGristAttachmentUploadResponseIds,
|
|
10
|
+
normalizeGristChoiceListEntries,
|
|
41
11
|
resolveGristFormulaKind,
|
|
42
|
-
|
|
43
|
-
uploadGristAttachment,
|
|
12
|
+
tableDataToRows,
|
|
44
13
|
useGrist,
|
|
45
14
|
useGristContext,
|
|
46
15
|
useGristOptional,
|
|
47
16
|
useGristSchema,
|
|
48
|
-
useGristSdkAlertDescriptors,
|
|
49
|
-
useGristSelection,
|
|
50
|
-
useGristStatus,
|
|
51
|
-
useGristTheme,
|
|
52
|
-
useGristWrites,
|
|
53
17
|
useWidgetMetadata
|
|
54
|
-
} from "./chunk-
|
|
55
|
-
import {
|
|
56
|
-
fetchWithGristAuth,
|
|
57
|
-
getGristAccessToken,
|
|
58
|
-
useGristWidgetOptionsFromContext
|
|
59
|
-
} from "./chunk-EPEBKXVN.js";
|
|
60
|
-
import {
|
|
61
|
-
validateColumnMappings
|
|
62
|
-
} from "./chunk-TZB3OZA6.js";
|
|
63
|
-
import {
|
|
64
|
-
buildReplicaJsonPayload,
|
|
65
|
-
normalizeReplicaDocumentInput,
|
|
66
|
-
normalizeReplicaTableInput
|
|
67
|
-
} from "./chunk-GTTD5HPO.js";
|
|
18
|
+
} from "./chunk-O7NY46QY.js";
|
|
68
19
|
import {
|
|
69
|
-
isGristNoiseColumn
|
|
70
|
-
} from "./chunk-REV5AUXD.js";
|
|
71
|
-
import {
|
|
72
|
-
computeRowCount,
|
|
73
|
-
decodeColumnarToReplicaRows,
|
|
74
|
-
fetchGristRow,
|
|
75
|
-
fetchGristTableRows,
|
|
76
|
-
findRowIndexById,
|
|
77
|
-
materializeGristRowsFromColumnar,
|
|
78
|
-
rowAtIndex,
|
|
79
|
-
safeParseRowsToDisplayRows,
|
|
80
|
-
sortRowsByGristOrder,
|
|
81
|
-
tableDataToRows
|
|
82
|
-
} from "./chunk-JASMM2YC.js";
|
|
83
|
-
import "./chunk-N3X46JW2.js";
|
|
84
|
-
import {
|
|
85
|
-
coerceGristDocApiRefRowId,
|
|
86
20
|
decodeGristValue,
|
|
87
21
|
encodeGristValue,
|
|
88
22
|
gristAddColumnAction,
|
|
89
23
|
gristAddRecordAction,
|
|
90
24
|
gristAddTableAction,
|
|
91
25
|
gristAddVisibleColumnAction,
|
|
92
|
-
gristBulkAddRecordAction,
|
|
93
|
-
gristBulkRemoveRecordAction,
|
|
94
|
-
gristBulkUpdateRecordAction,
|
|
95
|
-
gristCellValueSchema,
|
|
96
|
-
gristDuplicateTableAction,
|
|
97
26
|
gristModifyColumnAction,
|
|
98
27
|
gristRemoveColumnAction,
|
|
99
28
|
gristRemoveRecordAction,
|
|
100
|
-
gristRemoveTableAction,
|
|
101
29
|
gristRenameColumnAction,
|
|
102
|
-
gristRenameTableAction,
|
|
103
|
-
gristReplaceTableDataAction,
|
|
104
|
-
gristSafeRefListValueSchema,
|
|
105
|
-
gristSafeRefValueSchema,
|
|
106
|
-
gristSetDocumentInfoAction,
|
|
107
30
|
gristUpdateRecordAction,
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
normalizeGristChoiceListEntries,
|
|
111
|
-
parseGristWidgetOptionsCell,
|
|
112
|
-
safeParseGristTableData,
|
|
113
|
-
safeParseGristValues
|
|
114
|
-
} from "./chunk-64SVRWW7.js";
|
|
31
|
+
isGristCellError
|
|
32
|
+
} from "./chunk-4ZGVKGDF.js";
|
|
115
33
|
export {
|
|
116
|
-
GRIST_BOUNDARY_PREPARING_COPY,
|
|
117
34
|
GristBoundary,
|
|
118
|
-
GristBoundaryScreen,
|
|
119
35
|
GristWidgetProvider,
|
|
120
|
-
|
|
121
|
-
buildReplicaDocumentFromDocApi,
|
|
122
|
-
buildReplicaJsonPayload,
|
|
123
|
-
coerceGristDocApiRefRowId,
|
|
124
|
-
computeRowCount,
|
|
125
|
-
decodeColumnarToReplicaRows,
|
|
36
|
+
checkGristCell,
|
|
126
37
|
decodeGristValue,
|
|
127
|
-
deriveBoundaryBootLabel,
|
|
128
|
-
deriveBoundaryBootPhase,
|
|
129
|
-
deriveBoundaryView,
|
|
130
38
|
encodeGristValue,
|
|
131
|
-
extractAttachmentIdsFromUploadPayload,
|
|
132
|
-
extractFirstAttachmentIdFromUploadPayload,
|
|
133
39
|
extractGristAttachmentId,
|
|
134
40
|
extractGristAttachmentIdsFromCell,
|
|
135
|
-
fetchAttachmentBase64,
|
|
136
|
-
fetchAttachmentBase64ForCell,
|
|
137
|
-
fetchAttachmentBlob,
|
|
138
|
-
fetchGristRow,
|
|
139
|
-
fetchGristTableRows,
|
|
140
|
-
fetchWithGristAuth,
|
|
141
|
-
findRowIndexById,
|
|
142
|
-
formatAccessInsufficientMessage,
|
|
143
|
-
formatBoundaryUserMessage,
|
|
144
|
-
formatColumnMappingAlertMessage,
|
|
145
|
-
formatLinkStaleAlertMessage,
|
|
146
|
-
formatMappingPendingAlertMessage,
|
|
147
|
-
formatMappingUnreportedAlertMessage,
|
|
148
|
-
formatSectionNotLinkedAlertMessage,
|
|
149
|
-
formatSourceNotWiredAlertMessage,
|
|
150
|
-
getAttachmentDownloadUrl,
|
|
151
|
-
getAttachmentDownloadUrlForCell,
|
|
152
|
-
getGristAccessToken,
|
|
153
|
-
getGristSdkAlertDescriptors,
|
|
154
|
-
getGristSdkAlertSeverity,
|
|
155
|
-
getGristSdkAlertTitle,
|
|
156
41
|
gristAddColumnAction,
|
|
157
42
|
gristAddRecordAction,
|
|
158
43
|
gristAddTableAction,
|
|
159
44
|
gristAddVisibleColumnAction,
|
|
160
45
|
gristAttachmentCellValue,
|
|
161
46
|
gristAttachmentCellValues,
|
|
162
|
-
gristBulkAddRecordAction,
|
|
163
|
-
gristBulkRemoveRecordAction,
|
|
164
|
-
gristBulkUpdateRecordAction,
|
|
165
|
-
gristCellValueSchema,
|
|
166
|
-
gristDuplicateTableAction,
|
|
167
47
|
gristModifyColumnAction,
|
|
168
48
|
gristRemoveColumnAction,
|
|
169
49
|
gristRemoveRecordAction,
|
|
170
|
-
gristRemoveTableAction,
|
|
171
50
|
gristRenameColumnAction,
|
|
172
|
-
gristRenameTableAction,
|
|
173
|
-
gristReplaceTableDataAction,
|
|
174
|
-
gristSafeRefListValueSchema,
|
|
175
|
-
gristSafeRefValueSchema,
|
|
176
|
-
gristSetDocumentInfoAction,
|
|
177
51
|
gristUpdateRecordAction,
|
|
178
|
-
inferDisplayHelpersByRef,
|
|
179
|
-
inferGristFormulaKind,
|
|
180
|
-
isAccessInsufficientError,
|
|
181
52
|
isGristCellError,
|
|
182
|
-
isGristNoiseColumn,
|
|
183
|
-
isWidgetSectionNotLinked,
|
|
184
|
-
loadColumnMetadataByTable,
|
|
185
|
-
materializeGristRowsFromColumnar,
|
|
186
53
|
mergeGristAttachmentCellValue,
|
|
187
54
|
normalizeGristChoiceListEntries,
|
|
188
|
-
normalizeReplicaDocumentInput,
|
|
189
|
-
normalizeReplicaTableInput,
|
|
190
|
-
orderedColumnIds,
|
|
191
|
-
parseGristAttachmentUploadResponse,
|
|
192
|
-
parseGristAttachmentUploadResponseIds,
|
|
193
|
-
parseGristWidgetOptionsCell,
|
|
194
55
|
resolveGristFormulaKind,
|
|
195
|
-
rowAtIndex,
|
|
196
|
-
safeParseGristTableData,
|
|
197
|
-
safeParseGristValues,
|
|
198
|
-
safeParseRowsToDisplayRows,
|
|
199
|
-
serializeJsonFriendly,
|
|
200
|
-
sortRowsByGristOrder,
|
|
201
56
|
tableDataToRows,
|
|
202
|
-
uploadGristAttachment,
|
|
203
57
|
useGrist,
|
|
204
58
|
useGristContext,
|
|
205
59
|
useGristOptional,
|
|
206
60
|
useGristSchema,
|
|
207
|
-
|
|
208
|
-
useGristSelection,
|
|
209
|
-
useGristStatus,
|
|
210
|
-
useGristTheme,
|
|
211
|
-
useGristWidgetOptionsFromContext,
|
|
212
|
-
useGristWrites,
|
|
213
|
-
useWidgetMetadata,
|
|
214
|
-
validateColumnMappings
|
|
61
|
+
useWidgetMetadata
|
|
215
62
|
};
|
|
216
63
|
//# sourceMappingURL=index.js.map
|