@updog/data-editor-wc 0.1.75 → 0.1.76

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 (4) hide show
  1. package/index.css +1 -1
  2. package/index.d.ts +49 -0
  3. package/index.js +3803 -3591
  4. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -483,6 +483,8 @@ declare var export_default = {
483
483
  csvWarning_one: "{{count}} row had formatting issues (row {{rows}})",
484
484
  csvWarning_other:
485
485
  "{{count}} rows had formatting issues (rows {{rows}})",
486
+ customEmpty: "No tables were found in this file",
487
+ customFailed: "Could not process the file",
486
488
  downloadExample: "Download sample file",
487
489
  fileInputLabel: "Choose files to upload",
488
490
  fileTooLarge: "The file is too large to process",
@@ -529,6 +531,7 @@ declare var export_default = {
529
531
  "Unmatched columns won't be imported. Match this column to keep the data. You can transform columns after importing.",
530
532
  },
531
533
  sheetPreview: {
534
+ cancel: "Cancel processing",
532
535
  emptySheet: "Empty sheet",
533
536
  rowCount_one: "{{count}} row",
534
537
  rowCount_other: "{{count}} rows",
@@ -1261,6 +1264,47 @@ type RemoteSource = {
1261
1264
  */
1262
1265
  fetch: () => Promise<File | Record<string, unknown>[]>;
1263
1266
  };
1267
+ /** One table returned by a custom format handler. */
1268
+ type CustomImportTable = {
1269
+ /** Table name, shown on the preview card. */
1270
+ name: string;
1271
+ rows: Record<string, unknown>[];
1272
+ };
1273
+ /**
1274
+ * A file format the SDK cannot read, handled by client code.
1275
+ *
1276
+ * The SDK accepts the file, hands it to `handle()`, and stages whatever comes
1277
+ * back. You own the processing; nothing about the file reaches Updog.
1278
+ *
1279
+ * @example
1280
+ * ```ts
1281
+ * const pdf: CustomImportFormat = {
1282
+ * label: "PDF",
1283
+ * extensions: [".pdf"],
1284
+ * handle: async (file, { signal }) => {
1285
+ * const body = new FormData();
1286
+ * body.append("file", file);
1287
+ * const res = await fetch("/api/extract", { method: "POST", body, signal });
1288
+ * return res.json(); // Record<string, unknown>[]
1289
+ * },
1290
+ * };
1291
+ * ```
1292
+ */
1293
+ type CustomImportFormat = {
1294
+ /** Shown in the format hint under the drop zone, e.g. "PDF". */
1295
+ label: string;
1296
+ /** Extensions this handler claims, leading dot included. */
1297
+ extensions: string[];
1298
+ /** Optional MIME match, wildcards allowed: `["image/*"]`. */
1299
+ mimeTypes?: string[];
1300
+ /**
1301
+ * Returns rows, named tables, or a `File` in a format the SDK already reads.
1302
+ * Throw to fail the import; the thrown message is shown to the user.
1303
+ */
1304
+ handle: (file: File, ctx: {
1305
+ signal: AbortSignal;
1306
+ }) => Promise<File | Record<string, unknown>[] | CustomImportTable[]>;
1307
+ };
1264
1308
  /**
1265
1309
  * Controls the initial view when the editor opens.
1266
1310
  *
@@ -1376,6 +1420,11 @@ type DataEditorBaseProps<TRow extends DataEditorRow = DataEditorRow> = {
1376
1420
  * the result of `fetch()`.
1377
1421
  */
1378
1422
  remoteSources?: RemoteSource[];
1423
+ /**
1424
+ * File formats the SDK cannot read, handled by your own code. The SDK accepts
1425
+ * the file and stages whatever `handle()` returns.
1426
+ */
1427
+ customFormats?: CustomImportFormat[];
1379
1428
  /**
1380
1429
  * Which file formats the user can export to. `undefined` allows all
1381
1430
  * formats, `false` disables export entirely.