@updog/data-editor 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.
package/index.d.ts CHANGED
@@ -485,6 +485,8 @@ declare var export_default = {
485
485
  csvWarning_one: "{{count}} row had formatting issues (row {{rows}})",
486
486
  csvWarning_other:
487
487
  "{{count}} rows had formatting issues (rows {{rows}})",
488
+ customEmpty: "No tables were found in this file",
489
+ customFailed: "Could not process the file",
488
490
  downloadExample: "Download sample file",
489
491
  fileInputLabel: "Choose files to upload",
490
492
  fileTooLarge: "The file is too large to process",
@@ -531,6 +533,7 @@ declare var export_default = {
531
533
  "Unmatched columns won't be imported. Match this column to keep the data. You can transform columns after importing.",
532
534
  },
533
535
  sheetPreview: {
536
+ cancel: "Cancel processing",
534
537
  emptySheet: "Empty sheet",
535
538
  rowCount_one: "{{count}} row",
536
539
  rowCount_other: "{{count}} rows",
@@ -1659,6 +1662,8 @@ type MergeEntry<TRow> = {
1659
1662
  sourceId: DataSourceId;
1660
1663
  isNew: boolean;
1661
1664
  isEdited: boolean;
1665
+ /** Diff basis the row carried before the merge. Present only when isEdited. */
1666
+ originalRow?: TRow;
1662
1667
  };
1663
1668
  type RemovalPlan<TRow> = {
1664
1669
  rowsToDelete: Set<TRowId>;
@@ -1668,6 +1673,7 @@ type RemovalPlan<TRow> = {
1668
1673
  originalSourceId: DataSourceId;
1669
1674
  isNew: boolean;
1670
1675
  isEdited: boolean;
1676
+ originalRow?: TRow;
1671
1677
  }>;
1672
1678
  };
1673
1679
  type ExtendedRemovalPlan<TRow> = RemovalPlan<TRow> & {
@@ -1702,7 +1708,7 @@ declare class SourceManager<TRow extends DataEditorRow = DataEditorRow> {
1702
1708
  finalizeAllSources(): void;
1703
1709
  values(): IterableIterator<DataSourceState>;
1704
1710
  getHiddenSourceIds(): Set<DataSourceId>;
1705
- saveMergeSnapshot(sourceId: DataSourceId, rowId: TRowId, existingRow: TRow, previousSourceId: DataSourceId, isNew: boolean, isEdited: boolean): void;
1711
+ saveMergeSnapshot(sourceId: DataSourceId, rowId: TRowId, existingRow: TRow, previousSourceId: DataSourceId, isNew: boolean, isEdited: boolean, originalRow?: TRow): void;
1706
1712
  /**
1707
1713
  * Public so commands can re-install merge entries during undo of a remove.
1708
1714
  */
@@ -1939,9 +1945,8 @@ type IDirtyTracker<TRow extends DataEditorRow = DataEditorRow> = {
1939
1945
  hasOriginalRow(id: TRowId): boolean;
1940
1946
  trackNonBackendRow(id: TRowId): void;
1941
1947
  markNew(id: TRowId): void;
1942
- markEdited(id: TRowId): void;
1943
- snapshotOriginal(id: TRowId, row: TRow): void;
1944
1948
  classifyOnFirstEdit(id: TRowId, row: TRow): void;
1949
+ classifyOverwrite(id: TRowId, originalRow: TRow, currentRow: TRow): void;
1945
1950
  checkRevert(id: TRowId, currentRow: TRow): {
1946
1951
  wasNew: boolean;
1947
1952
  wasEdited: boolean;
@@ -1953,7 +1958,7 @@ type IDirtyTracker<TRow extends DataEditorRow = DataEditorRow> = {
1953
1958
  isNew: boolean;
1954
1959
  isEdited: boolean;
1955
1960
  };
1956
- restoreMergeClassification(id: TRowId, isNew: boolean, isEdited: boolean): void;
1961
+ restoreMergeClassification(id: TRowId, isNew: boolean, isEdited: boolean, originalRow?: TRow): void;
1957
1962
  clear(): void;
1958
1963
  };
1959
1964
 
@@ -2733,6 +2738,7 @@ declare class DataStore<TRow extends DataEditorRow = DataEditorRow> {
2733
2738
  clearColumn(field: string): Promise<void>;
2734
2739
  clearColumns(fields: string[]): Promise<void>;
2735
2740
  private syncClearToServer;
2741
+ purgeField(columnId: string, rowIds?: TRowId[]): void;
2736
2742
  deleteColumn(columnId: string): Promise<void>;
2737
2743
  deleteColumns(columnIds: readonly string[]): Promise<void>;
2738
2744
  clearRange(rects: SelectionRect[]): Promise<void>;
@@ -3066,6 +3072,47 @@ type RemoteSource = {
3066
3072
  */
3067
3073
  fetch: () => Promise<File | Record<string, unknown>[]>;
3068
3074
  };
3075
+ /** One table returned by a custom format handler. */
3076
+ type CustomImportTable = {
3077
+ /** Table name, shown on the preview card. */
3078
+ name: string;
3079
+ rows: Record<string, unknown>[];
3080
+ };
3081
+ /**
3082
+ * A file format the SDK cannot read, handled by client code.
3083
+ *
3084
+ * The SDK accepts the file, hands it to `handle()`, and stages whatever comes
3085
+ * back. You own the processing; nothing about the file reaches Updog.
3086
+ *
3087
+ * @example
3088
+ * ```ts
3089
+ * const pdf: CustomImportFormat = {
3090
+ * label: "PDF",
3091
+ * extensions: [".pdf"],
3092
+ * handle: async (file, { signal }) => {
3093
+ * const body = new FormData();
3094
+ * body.append("file", file);
3095
+ * const res = await fetch("/api/extract", { method: "POST", body, signal });
3096
+ * return res.json(); // Record<string, unknown>[]
3097
+ * },
3098
+ * };
3099
+ * ```
3100
+ */
3101
+ type CustomImportFormat = {
3102
+ /** Shown in the format hint under the drop zone, e.g. "PDF". */
3103
+ label: string;
3104
+ /** Extensions this handler claims, leading dot included. */
3105
+ extensions: string[];
3106
+ /** Optional MIME match, wildcards allowed: `["image/*"]`. */
3107
+ mimeTypes?: string[];
3108
+ /**
3109
+ * Returns rows, named tables, or a `File` in a format the SDK already reads.
3110
+ * Throw to fail the import; the thrown message is shown to the user.
3111
+ */
3112
+ handle: (file: File, ctx: {
3113
+ signal: AbortSignal;
3114
+ }) => Promise<File | Record<string, unknown>[] | CustomImportTable[]>;
3115
+ };
3069
3116
  /**
3070
3117
  * Controls the initial view when the editor opens.
3071
3118
  *
@@ -3181,6 +3228,11 @@ type DataEditorBaseProps<TRow extends DataEditorRow = DataEditorRow> = {
3181
3228
  * the result of `fetch()`.
3182
3229
  */
3183
3230
  remoteSources?: RemoteSource[];
3231
+ /**
3232
+ * File formats the SDK cannot read, handled by your own code. The SDK accepts
3233
+ * the file and stages whatever `handle()` returns.
3234
+ */
3235
+ customFormats?: CustomImportFormat[];
3184
3236
  /**
3185
3237
  * Which file formats the user can export to. `undefined` allows all
3186
3238
  * formats, `false` disables export entirely.
@@ -3426,4 +3478,4 @@ declare function exportDataEditor<TRow extends DataEditorRow>(params: ExportPara
3426
3478
  declare function DataEditor<TRow extends DataEditorRow = DataEditorRow>(allProps: DataEditorProps<TRow>): react_jsx_runtime.JSX.Element;
3427
3479
 
3428
3480
  export { DataEditor, downloadExampleFile, exportDataEditor };
3429
- export type { CellValidator, ChatContext, ChatErrorSummary, ChatResponseChunk, ChatRow, ChatRowStatus, ChunkSourceOptions, DataEditorChat, DataEditorColumn, DataEditorFormat, DataEditorInlineProps, DataEditorLocalStorage, DataEditorModalProps, DataEditorMode, DataEditorProps, DataEditorResult, DataEditorRow, DataEditorSourceResult, DataEditorTranslations, DataEditorVariant, InitialRowChange, RemoteSource, ResultRow, UpdogError, UpdogErrorCode, ValidationError, ValueMatchInput, ValueMatchOutput };
3481
+ 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 };