@updog/data-editor 0.1.88 → 0.1.89
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/index.d.ts +78 -2
- package/index.js +598 -540
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -1286,7 +1286,7 @@ type ColumnFormat = {
|
|
|
1286
1286
|
* `license.*` codes cover license validation failures (previously a separate
|
|
1287
1287
|
* `LicenseErrorCode` enum).
|
|
1288
1288
|
*/
|
|
1289
|
-
type UpdogErrorCode = "PARSE_ERROR" | "RENDER_ERROR" | "TRANSFORM_ERROR" | "VALIDATION_ERROR" | "WORKER_ERROR" | "COMMAND_ERROR" | "OPERATION_ERROR" | "license.invalid" | "license.missing" | "license.domain_not_allowed" | "license.subscription_inactive" | "license.trial_expired";
|
|
1289
|
+
type UpdogErrorCode = "PARSE_ERROR" | "RENDER_ERROR" | "TRANSFORM_ERROR" | "VALIDATION_ERROR" | "WORKER_ERROR" | "COMMAND_ERROR" | "OPERATION_ERROR" | "HOOK_ERROR" | "license.invalid" | "license.missing" | "license.domain_not_allowed" | "license.subscription_inactive" | "license.trial_expired";
|
|
1290
1290
|
/**
|
|
1291
1291
|
* An internal error caught by the SDK and passed to `onError`. The SDK
|
|
1292
1292
|
* recovers gracefully where possible — `onError` is for your logging and
|
|
@@ -2250,6 +2250,11 @@ declare class DataStore<TRow extends DataEditorRow = DataEditorRow> {
|
|
|
2250
2250
|
* the dialog is out of scope (spec section 10).
|
|
2251
2251
|
*/
|
|
2252
2252
|
private reportAmbiguity;
|
|
2253
|
+
/**
|
|
2254
|
+
* `fieldReader`, public: the value takes the column's storage shape; a
|
|
2255
|
+
* field outside the schema returns it untouched.
|
|
2256
|
+
*/
|
|
2257
|
+
readFieldValue(field: string, value: unknown): unknown;
|
|
2253
2258
|
/**
|
|
2254
2259
|
* The column's reader with no verdict behind it. A formula result is one
|
|
2255
2260
|
* value, so there is nothing to vote on; the reader is here to give the
|
|
@@ -2469,6 +2474,43 @@ type ColumnDelta = {
|
|
|
2469
2474
|
newValues: Map<TRowId, unknown>;
|
|
2470
2475
|
};
|
|
2471
2476
|
|
|
2477
|
+
/** One input row: the schema shape after reading plus the raw file row. */
|
|
2478
|
+
type RowImportInputRow = {
|
|
2479
|
+
/**
|
|
2480
|
+
* Keys are your schema column ids; values went through format reading,
|
|
2481
|
+
* value mapping, and the column's `transformer`.
|
|
2482
|
+
*/
|
|
2483
|
+
row: Record<string, unknown>;
|
|
2484
|
+
/**
|
|
2485
|
+
* Keys are the file's headers, unmapped ones included; values are the
|
|
2486
|
+
* cell texts as they appear in the file.
|
|
2487
|
+
*/
|
|
2488
|
+
raw: Record<string, string>;
|
|
2489
|
+
};
|
|
2490
|
+
type RowImportMeta = {
|
|
2491
|
+
/** Zero-based chunk number within the current workbook. */
|
|
2492
|
+
chunkIndex: number;
|
|
2493
|
+
/** Total number of chunks in the current workbook. */
|
|
2494
|
+
chunkCount: number;
|
|
2495
|
+
isLastChunk: boolean;
|
|
2496
|
+
/** The workbook being imported: source name, sheet (XLSX), file headers. */
|
|
2497
|
+
workbook: {
|
|
2498
|
+
name: string;
|
|
2499
|
+
sheetName?: string;
|
|
2500
|
+
headers: string[];
|
|
2501
|
+
};
|
|
2502
|
+
/** This workbook's column mapping: file header → schema column id. */
|
|
2503
|
+
mapping: Record<string, string | undefined>;
|
|
2504
|
+
/** The `context` prop, untouched. */
|
|
2505
|
+
context: unknown;
|
|
2506
|
+
};
|
|
2507
|
+
/**
|
|
2508
|
+
* Chunk in, chunk out. The returned array is positional: element `i` answers
|
|
2509
|
+
* `rows[i]`, `null` drops that row, elements past `rows.length` append new
|
|
2510
|
+
* rows. Returning nothing leaves the chunk as it is.
|
|
2511
|
+
*/
|
|
2512
|
+
type RowImportHook = (rows: RowImportInputRow[], meta: RowImportMeta) => (Record<string, unknown> | null)[] | void | Promise<(Record<string, unknown> | null)[] | void>;
|
|
2513
|
+
|
|
2472
2514
|
/** Numeric row identifier. V8 stores small integers (Smi) inline — no heap allocation. */
|
|
2473
2515
|
type TRowId = number;
|
|
2474
2516
|
type SortType = "text" | "number" | "date" | "time";
|
|
@@ -2960,6 +3002,40 @@ type DataEditorBaseProps<TRow extends DataEditorRow = DataEditorRow> = {
|
|
|
2960
3002
|
* ```
|
|
2961
3003
|
*/
|
|
2962
3004
|
onValueMatch?: (valuesToMatch: Record<string, ValueMatchInput>) => ValueMatchOutput | Promise<ValueMatchOutput>;
|
|
3005
|
+
/**
|
|
3006
|
+
* Edit, drop, or append rows between the file and the editor. Called once
|
|
3007
|
+
* per chunk of 5,000 rows of each imported workbook, after every cell went
|
|
3008
|
+
* through format reading, value mapping, and the column's `transformer` —
|
|
3009
|
+
* the raw file row rides along in `raw`, unmapped headers included.
|
|
3010
|
+
*
|
|
3011
|
+
* The returned array is positional: element `i` replaces `rows[i].row`,
|
|
3012
|
+
* `null` drops that row, elements past `rows.length` append new rows.
|
|
3013
|
+
* Return nothing to leave the chunk as it is. Every field the hook changed
|
|
3014
|
+
* is re-read as if it came from the file — format reading, value mapping,
|
|
3015
|
+
* and `transformer` run again on it.
|
|
3016
|
+
*
|
|
3017
|
+
* A thrown error, a timeout of 30 seconds per chunk, or an array shorter
|
|
3018
|
+
* than the input counts as a failure: the chunk lands unchanged, one
|
|
3019
|
+
* `HOOK_ERROR` reaches `onError`, and the hook stays off for the rest of
|
|
3020
|
+
* that import run.
|
|
3021
|
+
*
|
|
3022
|
+
* @example
|
|
3023
|
+
* ```ts
|
|
3024
|
+
* // Split "USD 100" from the file's price column into two schema fields.
|
|
3025
|
+
* onRowImport={(rows) =>
|
|
3026
|
+
* rows.map(({ row, raw }) => {
|
|
3027
|
+
* const [currency, amount] = (raw["price"] ?? "").split(" ");
|
|
3028
|
+
* return { ...row, currency, amount };
|
|
3029
|
+
* })
|
|
3030
|
+
* }
|
|
3031
|
+
* ```
|
|
3032
|
+
*/
|
|
3033
|
+
onRowImport?: RowImportHook;
|
|
3034
|
+
/**
|
|
3035
|
+
* Anything you want your hooks to see: `onRowImport` receives it untouched
|
|
3036
|
+
* as `meta.context`.
|
|
3037
|
+
*/
|
|
3038
|
+
context?: unknown;
|
|
2963
3039
|
/**
|
|
2964
3040
|
* Extra synonyms layered on top of the built-ins, in two tables that stay
|
|
2965
3041
|
* apart: `columns` scores a file header against your columns, `values`
|
|
@@ -3154,4 +3230,4 @@ declare function exportDataEditor<TRow extends DataEditorRow>(params: ExportPara
|
|
|
3154
3230
|
declare function DataEditor<TRow extends DataEditorRow = DataEditorRow>(allProps: DataEditorProps<TRow>): react.JSX.Element;
|
|
3155
3231
|
|
|
3156
3232
|
export { DataEditor, downloadExampleFile, exportDataEditor };
|
|
3157
|
-
export type { CellValidator, ChatContext, ChatErrorSummary, ChatResponseChunk, ChatRow, ChatRowStatus, ChunkSourceOptions, CustomImportFormat, CustomImportTable, DataEditorChat, DataEditorColumn, DataEditorFormat, DataEditorInlineProps, DataEditorLocalStorage, DataEditorModalProps, DataEditorMode, DataEditorProps, DataEditorResult, DataEditorRow, DataEditorSourceResult, DataEditorTranslations, DataEditorVariant, InitialRowChange, RemoteSource, ResultRow, UpdogError, UpdogErrorCode, ValidationError, ValueMatchInput, ValueMatchOutput };
|
|
3233
|
+
export type { CellValidator, ChatContext, ChatErrorSummary, ChatResponseChunk, ChatRow, ChatRowStatus, ChunkSourceOptions, CustomImportFormat, CustomImportTable, DataEditorChat, DataEditorColumn, DataEditorFormat, DataEditorInlineProps, DataEditorLocalStorage, DataEditorModalProps, DataEditorMode, DataEditorProps, DataEditorResult, DataEditorRow, DataEditorSourceResult, DataEditorTranslations, DataEditorVariant, InitialRowChange, RemoteSource, ResultRow, RowImportHook, RowImportInputRow, RowImportMeta, UpdogError, UpdogErrorCode, ValidationError, ValueMatchInput, ValueMatchOutput };
|