@updog/data-editor 0.1.75 → 0.1.77

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
 
@@ -2693,6 +2698,8 @@ declare class DataStore<TRow extends DataEditorRow = DataEditorRow> {
2693
2698
  hasEmptyCells(rowId: TRowId): boolean;
2694
2699
  hasRowMisplaced(rowId: TRowId): boolean;
2695
2700
  getRowsWithMisplaced(): ReadonlySet<TRowId>;
2701
+ /** A column arriving or leaving invalidates every entry. See NOTES.md. */
2702
+ private recheckEmptyCellsAfterColumnsChange;
2696
2703
  private checkRowEmptyCells;
2697
2704
  getValidAndInvalidRows(): {
2698
2705
  valid: TRow[];
@@ -2733,6 +2740,7 @@ declare class DataStore<TRow extends DataEditorRow = DataEditorRow> {
2733
2740
  clearColumn(field: string): Promise<void>;
2734
2741
  clearColumns(fields: string[]): Promise<void>;
2735
2742
  private syncClearToServer;
2743
+ purgeField(columnId: string, rowIds?: TRowId[]): void;
2736
2744
  deleteColumn(columnId: string): Promise<void>;
2737
2745
  deleteColumns(columnIds: readonly string[]): Promise<void>;
2738
2746
  clearRange(rects: SelectionRect[]): Promise<void>;
@@ -3066,6 +3074,47 @@ type RemoteSource = {
3066
3074
  */
3067
3075
  fetch: () => Promise<File | Record<string, unknown>[]>;
3068
3076
  };
3077
+ /** One table returned by a custom format handler. */
3078
+ type CustomImportTable = {
3079
+ /** Table name, shown on the preview card. */
3080
+ name: string;
3081
+ rows: Record<string, unknown>[];
3082
+ };
3083
+ /**
3084
+ * A file format the SDK cannot read, handled by client code.
3085
+ *
3086
+ * The SDK accepts the file, hands it to `handle()`, and stages whatever comes
3087
+ * back. You own the processing; nothing about the file reaches Updog.
3088
+ *
3089
+ * @example
3090
+ * ```ts
3091
+ * const pdf: CustomImportFormat = {
3092
+ * label: "PDF",
3093
+ * extensions: [".pdf"],
3094
+ * handle: async (file, { signal }) => {
3095
+ * const body = new FormData();
3096
+ * body.append("file", file);
3097
+ * const res = await fetch("/api/extract", { method: "POST", body, signal });
3098
+ * return res.json(); // Record<string, unknown>[]
3099
+ * },
3100
+ * };
3101
+ * ```
3102
+ */
3103
+ type CustomImportFormat = {
3104
+ /** Shown in the format hint under the drop zone, e.g. "PDF". */
3105
+ label: string;
3106
+ /** Extensions this handler claims, leading dot included. */
3107
+ extensions: string[];
3108
+ /** Optional MIME match, wildcards allowed: `["image/*"]`. */
3109
+ mimeTypes?: string[];
3110
+ /**
3111
+ * Returns rows, named tables, or a `File` in a format the SDK already reads.
3112
+ * Throw to fail the import; the thrown message is shown to the user.
3113
+ */
3114
+ handle: (file: File, ctx: {
3115
+ signal: AbortSignal;
3116
+ }) => Promise<File | Record<string, unknown>[] | CustomImportTable[]>;
3117
+ };
3069
3118
  /**
3070
3119
  * Controls the initial view when the editor opens.
3071
3120
  *
@@ -3181,6 +3230,11 @@ type DataEditorBaseProps<TRow extends DataEditorRow = DataEditorRow> = {
3181
3230
  * the result of `fetch()`.
3182
3231
  */
3183
3232
  remoteSources?: RemoteSource[];
3233
+ /**
3234
+ * File formats the SDK cannot read, handled by your own code. The SDK accepts
3235
+ * the file and stages whatever `handle()` returns.
3236
+ */
3237
+ customFormats?: CustomImportFormat[];
3184
3238
  /**
3185
3239
  * Which file formats the user can export to. `undefined` allows all
3186
3240
  * formats, `false` disables export entirely.
@@ -3426,4 +3480,4 @@ declare function exportDataEditor<TRow extends DataEditorRow>(params: ExportPara
3426
3480
  declare function DataEditor<TRow extends DataEditorRow = DataEditorRow>(allProps: DataEditorProps<TRow>): react_jsx_runtime.JSX.Element;
3427
3481
 
3428
3482
  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 };
3483
+ 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 };