@updog/data-editor-wc 0.1.88 → 0.1.90

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.
Files changed (3) hide show
  1. package/index.d.ts +77 -1
  2. package/index.js +4820 -4710
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -1121,7 +1121,7 @@ type DataEditorChat<TRow extends DataEditorRow = DataEditorRow> = {
1121
1121
  * `license.*` codes cover license validation failures (previously a separate
1122
1122
  * `LicenseErrorCode` enum).
1123
1123
  */
1124
- 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";
1124
+ 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";
1125
1125
  /**
1126
1126
  * An internal error caught by the SDK and passed to `onError`. The SDK
1127
1127
  * recovers gracefully where possible — `onError` is for your logging and
@@ -1147,6 +1147,48 @@ type UpdogError = {
1147
1147
  originalError?: unknown;
1148
1148
  };
1149
1149
 
1150
+ /** One input row: the schema shape after reading plus the raw file row. */
1151
+ type RowImportInputRow = {
1152
+ /**
1153
+ * Keys are your schema column ids; values went through format reading,
1154
+ * value mapping, and the column's `transformer`.
1155
+ */
1156
+ row: Record<string, unknown>;
1157
+ /**
1158
+ * Keys are the file's headers, unmapped ones included; values are the
1159
+ * cell texts as they appear in the file.
1160
+ */
1161
+ raw: Record<string, string>;
1162
+ };
1163
+ type RowImportMeta = {
1164
+ /** Zero-based chunk number within the current workbook. */
1165
+ chunkIndex: number;
1166
+ /** Total number of chunks in the current workbook. */
1167
+ chunkCount: number;
1168
+ isLastChunk: boolean;
1169
+ /** The workbook being imported: source name, sheet (XLSX), file headers. */
1170
+ workbook: {
1171
+ name: string;
1172
+ sheetName?: string;
1173
+ headers: string[];
1174
+ };
1175
+ /** This workbook's column mapping: file header → schema column id. */
1176
+ mapping: Record<string, string | undefined>;
1177
+ /** The `context` prop, untouched. */
1178
+ context: unknown;
1179
+ /**
1180
+ * Aborted when the import is cancelled and when the chunk's 30-second
1181
+ * timeout fires; hand it to your own fetch.
1182
+ */
1183
+ signal: AbortSignal;
1184
+ };
1185
+ /**
1186
+ * Chunk in, chunk out. The returned array is positional: element `i` answers
1187
+ * `rows[i]`, `null` drops that row, elements past `rows.length` append new
1188
+ * rows. Returning nothing leaves the chunk as it is.
1189
+ */
1190
+ type RowImportHook = (rows: RowImportInputRow[], meta: RowImportMeta) => (Record<string, unknown> | null)[] | void | Promise<(Record<string, unknown> | null)[] | void>;
1191
+
1150
1192
  /**
1151
1193
  * A single row in the submit result, with orthogonal flags describing its state.
1152
1194
  *
@@ -1561,6 +1603,40 @@ type DataEditorBaseProps<TRow extends DataEditorRow = DataEditorRow> = {
1561
1603
  * ```
1562
1604
  */
1563
1605
  onValueMatch?: (valuesToMatch: Record<string, ValueMatchInput>) => ValueMatchOutput | Promise<ValueMatchOutput>;
1606
+ /**
1607
+ * Edit, drop, or append rows between the file and the editor. Called once
1608
+ * per chunk of 5,000 rows of each imported workbook, after every cell went
1609
+ * through format reading, value mapping, and the column's `transformer` —
1610
+ * the raw file row rides along in `raw`, unmapped headers included.
1611
+ *
1612
+ * The returned array is positional: element `i` replaces `rows[i].row`,
1613
+ * `null` drops that row, elements past `rows.length` append new rows.
1614
+ * Return nothing to leave the chunk as it is. Every field the hook changed
1615
+ * is re-read as if it came from the file — format reading, value mapping,
1616
+ * and `transformer` run again on it.
1617
+ *
1618
+ * A thrown error, a timeout of 30 seconds per chunk, or an array shorter
1619
+ * than the input counts as a failure: the chunk lands unchanged, one
1620
+ * `HOOK_ERROR` reaches `onError`, and the hook stays off for the rest of
1621
+ * that import run.
1622
+ *
1623
+ * @example
1624
+ * ```ts
1625
+ * // Split "USD 100" from the file's price column into two schema fields.
1626
+ * onRowImport={(rows) =>
1627
+ * rows.map(({ row, raw }) => {
1628
+ * const [currency, amount] = (raw["price"] ?? "").split(" ");
1629
+ * return { ...row, currency, amount };
1630
+ * })
1631
+ * }
1632
+ * ```
1633
+ */
1634
+ onRowImport?: RowImportHook;
1635
+ /**
1636
+ * Anything you want your hooks to see: `onRowImport` receives it untouched
1637
+ * as `meta.context`.
1638
+ */
1639
+ context?: unknown;
1564
1640
  /**
1565
1641
  * Extra synonyms layered on top of the built-ins, in two tables that stay
1566
1642
  * apart: `columns` scores a file header against your columns, `values`