@updog/data-editor-wc 0.1.4 → 0.1.6

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
@@ -516,17 +516,48 @@ type ExpandPluralKeys<T> = T extends Record<string, unknown>
516
516
  */
517
517
  type DataEditorTranslations = DeepPartial<ExpandPluralKeys<typeof export_default>>;
518
518
 
519
+ /**
520
+ * Categories of internal errors surfaced through the `onError` callback.
521
+ *
522
+ * - `PARSE_ERROR` — file parsing failed (corrupt CSV, invalid XLSX, etc.).
523
+ * - `RENDER_ERROR` — component render failed (caught by error boundary).
524
+ * - `TRANSFORM_ERROR` — data transformation failed (column transform, value mapping).
525
+ * - `VALIDATION_ERROR` — validation execution failed (validator threw instead of returning).
526
+ * - `WORKER_ERROR` — Web Worker failed (filter worker, chat transform worker).
527
+ * - `COMMAND_ERROR` — undo/redo command failed.
528
+ * - `OPERATION_ERROR` — general operation failed (bulk mutations, imports).
529
+ */
519
530
  type UpdogErrorCode = "PARSE_ERROR" | "RENDER_ERROR" | "TRANSFORM_ERROR" | "VALIDATION_ERROR" | "WORKER_ERROR" | "COMMAND_ERROR" | "OPERATION_ERROR";
531
+ /**
532
+ * An internal error caught by the SDK and passed to `onError`. The SDK
533
+ * recovers gracefully where possible — `onError` is for your logging and
534
+ * monitoring (Sentry, Datadog, etc.).
535
+ *
536
+ * @example
537
+ * ```ts
538
+ * onError={(error) => {
539
+ * Sentry.captureException(error.originalError ?? error, {
540
+ * tags: { code: error.code, source: error.source },
541
+ * });
542
+ * }}
543
+ * ```
544
+ */
520
545
  type UpdogError = {
546
+ /** The error category. */
521
547
  code: UpdogErrorCode;
548
+ /** Human-readable description. */
522
549
  message: string;
550
+ /** Module or subsystem that raised the error. */
523
551
  source: string;
552
+ /** The underlying thrown value, when available. */
524
553
  originalError?: unknown;
525
554
  };
526
555
 
527
556
  /**
528
557
  * Base row shape. Each key is a column ID, each value is the cell data.
529
- * Extend this with your own type for type-safe column access.
558
+ * Extend this with your own type via the `<DataEditor<TRow>>` generic for
559
+ * type-safe column access. When the generic is omitted, rows are typed as
560
+ * `Record<string, unknown>`.
530
561
  *
531
562
  * @example
532
563
  * ```ts
@@ -535,7 +566,9 @@ type UpdogError = {
535
566
  * ```
536
567
  */
537
568
  type DataEditorRow = Record<string, unknown>;
569
+ /** Sort direction. */
538
570
  type SortDirection = "asc" | "desc";
571
+ /** Current sort state. `null` means no active sort. */
539
572
  type SortState = {
540
573
  columnId: string;
541
574
  direction: SortDirection;
@@ -565,6 +598,29 @@ type Filters = {
565
598
  }>;
566
599
  };
567
600
 
601
+ /**
602
+ * A single operation the LLM wants to apply to rows in the current filtered view.
603
+ *
604
+ * - `edit` — `fn` is `(r, ctx) => void`. Mutates `r` in place. Changed fields
605
+ * become column deltas. Rows with no changes are no-ops.
606
+ * - `delete` — `fn` is `(r, ctx) => boolean`. Truthy means "flag this row for
607
+ * deletion". Soft delete via `DeleteRowCommand`.
608
+ */
609
+ type ChatOp = {
610
+ action: "edit";
611
+ fn: string;
612
+ } | {
613
+ action: "delete";
614
+ fn: string;
615
+ };
616
+ /**
617
+ * A single chunk in the stream returned from `DataEditorChat.onMessage`.
618
+ *
619
+ * - `status` — progress message shown while processing (e.g. "Analyzing 500 rows...").
620
+ * - `message` — chat reply shown to the user.
621
+ * - `rows` — updated rows to apply to the grid. Matched by `primaryKey`.
622
+ * - `ops` — array of per-row operations (edits and/or deletes) to apply in order.
623
+ */
568
624
  type ChatResponseChunk<TRow extends DataEditorRow = DataEditorRow> = {
569
625
  type: "status";
570
626
  content: string;
@@ -575,40 +631,108 @@ type ChatResponseChunk<TRow extends DataEditorRow = DataEditorRow> = {
575
631
  type: "rows";
576
632
  content: TRow[];
577
633
  } | {
578
- type: "transform";
579
- content: string;
634
+ type: "ops";
635
+ content: ChatOp[];
580
636
  };
637
+ /** Status of a row in the chat sample, relative to its origin snapshot. */
581
638
  type ChatRowStatus = "new" | "edited" | "original";
639
+ /** A sample row handed to the chat callback, with its current status and validation errors. */
582
640
  type ChatRow<TRow extends DataEditorRow = DataEditorRow> = {
641
+ /** Row data keyed by column ID. */
583
642
  data: TRow;
643
+ /** Whether the row was newly added, edited, or is unchanged. */
584
644
  status: ChatRowStatus;
645
+ /** Validation errors keyed by column ID. */
585
646
  errors: Record<string, string[]>;
647
+ /** The source this row belongs to. */
586
648
  source: string;
587
649
  };
650
+ /** Aggregated error count across the current view, grouped by field and message. */
588
651
  type ChatErrorSummary = {
652
+ /** Column ID where the error occurred. */
589
653
  field: string;
654
+ /** The validation message. */
590
655
  message: string;
656
+ /** How many rows hit this error. */
591
657
  count: number;
658
+ /** A few example values that triggered the error. */
592
659
  examples: string[];
593
660
  };
661
+ /**
662
+ * Context about the current dataset, passed to `loadSuggestions` and extended
663
+ * into `ChatContext` for `onMessage`.
664
+ */
594
665
  type ChatDataContext<TRow extends DataEditorRow = DataEditorRow> = {
666
+ /** Full column definitions. */
595
667
  columns: DataEditorColumn[];
668
+ /** Row identifier field. */
596
669
  primaryKey: keyof TRow;
670
+ /** Total rows in the dataset. */
597
671
  totalRowCount: number;
672
+ /** Rows in the current filtered view. */
598
673
  filteredRowCount: number;
674
+ /** Sample rows, with status and errors. Size controlled by `sampleSize`. */
599
675
  sample: ChatRow<TRow>[];
676
+ /** Aggregated error counts by field and message. */
600
677
  errorSummary: ChatErrorSummary[];
678
+ /** Access all rows. Use for full-dataset operations. */
601
679
  getRows: () => ChatRow<TRow>[];
602
680
  };
681
+ /**
682
+ * The full context passed to `DataEditorChat.onMessage` when the user sends
683
+ * a prompt. Includes the prompt itself and all dataset context.
684
+ */
603
685
  type ChatContext<TRow extends DataEditorRow = DataEditorRow> = ChatDataContext<TRow> & {
686
+ /** The user's chat prompt. */
604
687
  message: string;
605
688
  };
689
+ /**
690
+ * Bring-your-own-AI chat configuration. When provided via the `chat` prop,
691
+ * the editor shows a chat panel alongside the grid. You own the AI
692
+ * integration; the SDK hands you dataset context and renders the streamed
693
+ * response.
694
+ *
695
+ * @example
696
+ * ```ts
697
+ * chat={{
698
+ * sampleSize: 50,
699
+ * onMessage: async function* (context) {
700
+ * yield { type: "status", content: "Thinking..." };
701
+ * const res = await fetch("/api/ai", {
702
+ * method: "POST",
703
+ * body: JSON.stringify({
704
+ * prompt: context.message,
705
+ * columns: context.columns,
706
+ * sample: context.sample.map(r => r.data),
707
+ * errors: context.errorSummary,
708
+ * }),
709
+ * }).then(r => r.json());
710
+ * yield { type: "rows", content: res.updatedRows };
711
+ * yield { type: "ops", content: res.ops };
712
+ * yield { type: "message", content: res.reply };
713
+ * },
714
+ * }}
715
+ * ```
716
+ */
606
717
  type DataEditorChat<TRow extends DataEditorRow = DataEditorRow> = {
718
+ /**
719
+ * How many rows to include in the context sample. The SDK picks a
720
+ * representative slice including rows with errors. When omitted, the SDK decides.
721
+ */
607
722
  sampleSize?: number;
723
+ /** Title shown above the suggestion list when the chat is empty. */
608
724
  emptyTitle?: string;
725
+ /** How many suggestions to request from `loadSuggestions`. */
609
726
  suggestionsCount?: number;
727
+ /** Optional prompt generator for the empty-state suggestion chips. */
610
728
  loadSuggestions?: (context: ChatDataContext<TRow>) => Promise<string[]>;
729
+ /**
730
+ * Called when the user sends a message. Receives full dataset context.
731
+ * Returns an async iterable of response chunks — the SDK streams them
732
+ * into the UI.
733
+ */
611
734
  onMessage: (context: ChatContext<TRow>) => AsyncIterable<ChatResponseChunk<TRow>>;
735
+ /** Called when the user cancels a pending request. Use to abort your API call. */
612
736
  onCancel?: () => void;
613
737
  };
614
738
 
@@ -627,8 +751,13 @@ type ValidationError = {
627
751
  * A function that validates a single cell value.
628
752
  * Return a `ValidationError` to flag a problem, or `null` if the value is valid.
629
753
  *
754
+ * A `ValidationError` with `level: "error"` flags the cell in the grid but
755
+ * does not block submission — invalid rows are delivered to `onComplete`
756
+ * alongside valid ones, tagged via the `isValid` flag.
757
+ *
630
758
  * Built-in validator factories: `required(msg)`, `numeric(msg)`, `email(msg)`,
631
- * `date(msg)`, `endDateAfterStart(startField, msg)`. Import them from the package root.
759
+ * `date(msg)`, `oneOf(values, msg)`, `endDateAfterStart(startField, msg)`.
760
+ * Import them from the package root.
632
761
  *
633
762
  * @param value - The current cell value.
634
763
  * @param row - The full row, useful for cross-field checks.
@@ -712,41 +841,62 @@ type ColumnLockMode = "all" | "default";
712
841
  *
713
842
  * @example
714
843
  * ```ts
844
+ * import { required, email, numeric } from "@updog/data-editor";
845
+ *
715
846
  * const columns: DataEditorColumn[] = [
716
- * { id: "name", title: "Full Name", width: 200, validate: required },
717
- * { id: "email", title: "Email", width: 250, validate: [required, email], unique: true },
718
- * { id: "role", title: "Role", editor: { type: "select", options: roleOptions } },
719
- * { id: "salary", title: "Salary", validate: numeric, formatter: (v) => `$${v}` },
847
+ * { id: "name", title: "Full Name", size: 200, validate: required("Name is required") },
848
+ * { id: "email", title: "Email", size: 250, validate: [required("Email is required"), email("Invalid email")], unique: true },
849
+ * { id: "role", title: "Role", editor: { type: "select", options: ["Admin", "Editor", "Viewer"] } },
850
+ * { id: "salary", title: "Salary", validate: numeric("Must be a number"), formatter: (v) => v ? `$${v}` : "" },
720
851
  * ];
721
852
  * ```
722
853
  */
723
854
  type DataEditorColumn = {
724
855
  /** Unique column identifier. Must match the keys in your row data. */
725
856
  id: string;
726
- /** Column header text. */
857
+ /** Column header text shown to the user. */
727
858
  title: string;
728
- /** One or more validators to run on every edit. */
859
+ /**
860
+ * One or more validators run on every edit. Each receives the cell value and
861
+ * the full row, and returns a `ValidationError` to flag a problem or `null`
862
+ * if valid. Errors do not block submission — see `CellValidator`.
863
+ */
729
864
  validate?: CellValidator | CellValidator[];
730
- /** When `true`, the editor flags duplicate values in this column as errors. */
865
+ /**
866
+ * When `true`, the editor flags duplicate values in this column as errors.
867
+ * The error message is localized via the `translations` prop
868
+ * (`dataEditor.validation.valueMustBeUnique`).
869
+ */
731
870
  unique?: boolean;
732
- /** Column IDs to revalidate when this column changes. Use for cross-field rules like "end date must be after start date". */
871
+ /**
872
+ * Column IDs to revalidate when this column changes. Use for cross-field
873
+ * rules like "end date must be after start date".
874
+ */
733
875
  dependentFields?: string[];
734
876
  /** Format the display value without changing stored data. E.g. add `$` prefix. */
735
877
  formatter?: (value: string) => string;
736
- /** Transform the value before it enters the store. Runs on every edit and import. */
878
+ /**
879
+ * Transform a value before it enters the store. Runs when rows are uploaded
880
+ * to the data editor.
881
+ */
737
882
  transformer?: (value: unknown) => unknown;
738
883
  /** How the cell is edited. Defaults to text input. */
739
884
  editor?: CellEditor;
740
885
  /** Adds a filter control for this column in the sidebar Filters panel. */
741
886
  filter?: ColumnFilter;
742
- /** Whether this column can be pinned to the left via the header context menu. @default true */
887
+ /**
888
+ * Whether this column can be pinned to the left (right in RTL) via the
889
+ * header context menu. @default true
890
+ */
743
891
  pinnable?: boolean;
744
892
  /** Column width in pixels. @default 150 */
745
893
  size?: number;
746
894
  /**
747
- * Controls whether cells in this column are locked.
748
- * - `true` | `"all"` locked for all rows.
749
- * - `"default"` — locked only for default-source rows; non-default-source rows remain editable.
895
+ * Controls whether cells in this column are locked. A column locked via
896
+ * configuration cannot be unlocked from the UI.
897
+ * - `true` | `"all"` — locked for every row.
898
+ * - `"default"` — locked only for default-source rows; rows added manually,
899
+ * duplicated, or imported remain editable.
750
900
  * - `false` | `undefined` — not locked.
751
901
  */
752
902
  locked?: boolean | ColumnLockMode;
@@ -1146,9 +1296,12 @@ type DataEditorServer<TRow extends DataEditorRow = DataEditorRow, TFilters = Rec
1146
1296
  scrollSensitivity?: number;
1147
1297
  };
1148
1298
 
1149
- /** Actions available inside the `onComplete` callback. */
1299
+ /**
1300
+ * Actions available inside the `onComplete` callback. Call `reset()` after a
1301
+ * successful save to clear the editor and re-fetch via `loadData`.
1302
+ */
1150
1303
  type DataEditorActions = {
1151
- /** Discard all changes and reload the original data. */
1304
+ /** Discard all changes and reload the original data via `loadData`. */
1152
1305
  reset: () => void;
1153
1306
  };
1154
1307
  /**
@@ -1208,31 +1361,55 @@ type DataEditorResult<TRow extends DataEditorRow = DataEditorRow> = {
1208
1361
  invalid: number;
1209
1362
  };
1210
1363
  };
1364
+ /**
1365
+ * Options used to tag a chunk passed to `loadData`'s `onChunk` callback.
1366
+ * Sources are auto-registered on first encounter. Chunks without options go
1367
+ * to "Existing Data".
1368
+ */
1211
1369
  type ChunkSourceOptions = {
1212
- /** Display name for this data source. */
1370
+ /** Display name for this data source. Required when tagging a source. */
1213
1371
  source: string;
1214
- /** Stable identifier. Defaults to `source` value when omitted. */
1372
+ /** Stable identifier. Defaults to the `source` value when omitted. */
1215
1373
  id?: string;
1216
- /** Can the user delete this source? @default false */
1374
+ /** Whether the user can delete this source from the editor. @default false */
1217
1375
  deletable?: boolean;
1218
- /** Marks this source as finished loading. */
1376
+ /**
1377
+ * Marks this source as finished loading. Shows a completion state in the
1378
+ * UI. When the `loadData` promise resolves, any source still loading is
1379
+ * automatically finalized.
1380
+ * @default false
1381
+ */
1219
1382
  done?: boolean;
1220
1383
  };
1221
1384
  type DataSourceId = string;
1222
- /** Per-column data passed to `onValueMatch`: the unique imported values and the allowed select options. */
1385
+ /**
1386
+ * Per-column input to `onValueMatch`: the unique imported values from the
1387
+ * file and the allowed select options defined on the column.
1388
+ */
1223
1389
  type ValueMatchInput = {
1390
+ /** Distinct values seen in the imported file for this column. */
1224
1391
  importedValues: string[];
1392
+ /** Allowed options from the column's `select` editor. */
1225
1393
  options: string[];
1226
1394
  };
1227
- /** Per-column result from `onValueMatch`: maps each imported value to an option value, or `null` to skip auto-matching. */
1395
+ /**
1396
+ * Per-column result from `onValueMatch`. Outer key = column ID, inner key =
1397
+ * imported value, inner value = chosen option, or `null` to skip
1398
+ * auto-matching for that value. Unmapped values fall back to built-in fuzzy
1399
+ * matching.
1400
+ */
1228
1401
  type ValueMatchOutput = Record<string, Record<string, string | null>>;
1229
- /** File formats supported for import and export. */
1402
+ /** File formats supported for import and export. Shared by `importFormats` and `exportFormats`. */
1230
1403
  type DataEditorFormat = "csv" | "tsv" | "xlsx" | "json" | "xml";
1231
1404
  /**
1232
1405
  * A client-defined remote data source (e.g. Google Sheets, S3, Dropbox).
1233
1406
  *
1234
- * The SDK renders a button per source and calls `fetch()` when clicked.
1235
- * The client owns all integration complexity — auth, pickers, downloads.
1407
+ * The SDK renders a button per source on the upload step and calls `fetch()`
1408
+ * when clicked. You own all integration complexity — auth, pickers,
1409
+ * downloads. The SDK just processes the result.
1410
+ *
1411
+ * Return a `File` to go through the standard parse pipeline
1412
+ * (CSV/XLSX/JSON/XML), or return structured records to skip parsing entirely.
1236
1413
  *
1237
1414
  * @example
1238
1415
  * ```ts
@@ -1256,7 +1433,10 @@ type RemoteSource = {
1256
1433
  icon: string;
1257
1434
  /** Optional tooltip text. */
1258
1435
  description?: string;
1259
- /** Returns a File (parsed via CSV/XLSX/JSON/XML pipeline) or structured records (used directly). */
1436
+ /**
1437
+ * Returns a `File` (parsed via the CSV/XLSX/JSON/XML pipeline) or structured
1438
+ * records (used directly, skipping parse).
1439
+ */
1260
1440
  fetch: () => Promise<File | Record<string, unknown>[]>;
1261
1441
  };
1262
1442
  /**
@@ -1271,8 +1451,9 @@ type DataEditorBaseProps<TRow extends DataEditorRow = DataEditorRow> = {
1271
1451
  /** Column definitions. Each entry describes one column in the grid. */
1272
1452
  columns: DataEditorColumn[];
1273
1453
  /**
1274
- * The column ID used to uniquely identify each row (e.g. `"id"` or `"employeeId"`).
1275
- * Used to match imported rows to existing data and to track edits.
1454
+ * The column ID used to uniquely identify each row (e.g. `"id"` or
1455
+ * `"employeeId"`). Used to match imported rows against existing data and to
1456
+ * track edits.
1276
1457
  */
1277
1458
  primaryKey: keyof TRow;
1278
1459
  /**
@@ -1326,37 +1507,78 @@ type DataEditorBaseProps<TRow extends DataEditorRow = DataEditorRow> = {
1326
1507
  * ```
1327
1508
  */
1328
1509
  onComplete?: (result: DataEditorResult<TRow>, actions: DataEditorActions) => void;
1329
- /** Controls the initial view. `"editor"` opens the grid, `"uploader"` opens the import wizard first. @default "editor" */
1510
+ /**
1511
+ * Controls the initial view. `"editor"` opens directly to the spreadsheet
1512
+ * grid. `"uploader"` opens the file import wizard first — the user uploads
1513
+ * a file, maps columns, fixes errors, then continues to the grid.
1514
+ * @default "editor"
1515
+ */
1330
1516
  variant?: DataEditorVariant;
1331
- /** Override any UI string. Pass a partial object — only the keys you provide are replaced. */
1517
+ /**
1518
+ * Override any UI string. Pass a partial object — only the keys you provide
1519
+ * are replaced. Every key lives under `dataEditor`.
1520
+ */
1332
1521
  translations?: DataEditorTranslations;
1333
- /** BCP 47 locale tag (e.g. `"en"`, `"fr"`, `"ar"`). Used for plural rules and locale-aware features. @default "en" */
1522
+ /**
1523
+ * BCP 47 locale tag (e.g. `"en"`, `"fr"`, `"ar"`). Used for plural rules
1524
+ * and locale-aware features.
1525
+ * @default "en"
1526
+ */
1334
1527
  locale?: string;
1335
1528
  /**
1336
1529
  * Controls row deletion via the right-click context menu.
1337
- * - `false` — deletion disabled (default).
1530
+ * - `false` — deletion disabled.
1338
1531
  * - `"new"` — only manually added or imported rows can be deleted.
1339
1532
  * - `"all"` — any row can be deleted.
1340
1533
  * @default false
1341
1534
  */
1342
1535
  enableDeleteRow?: "all" | "new" | false;
1343
- /** Show the "Add row" button in the data sources panel. @default true */
1536
+ /**
1537
+ * Show the "Add row" button in the data sources panel. When `false`, users
1538
+ * can only edit existing rows or import data — they can't manually add
1539
+ * blank rows.
1540
+ * @default true
1541
+ */
1344
1542
  enableAddRow?: boolean;
1345
- /** Which file formats the user can import. `undefined` allows all, `[]` disables import entirely. */
1543
+ /**
1544
+ * Which file formats the user can import. `undefined` allows all formats,
1545
+ * `[]` disables import entirely.
1546
+ */
1346
1547
  importFormats?: DataEditorFormat[];
1347
- /** Client-defined remote data sources rendered as buttons on the upload step. */
1548
+ /**
1549
+ * Client-defined remote data sources rendered as buttons on the upload
1550
+ * step. You own the integration; the SDK renders the button and processes
1551
+ * the result of `fetch()`.
1552
+ */
1348
1553
  remoteSources?: RemoteSource[];
1349
- /** Which file formats the user can export. `undefined` allows all, `[]` disables export entirely. */
1554
+ /**
1555
+ * Which file formats the user can export to. `undefined` allows all
1556
+ * formats, `[]` disables export entirely.
1557
+ */
1350
1558
  exportFormats?: DataEditorFormat[];
1351
1559
  /** Row height in pixels. @default 34 */
1352
1560
  rowHeight?: number;
1353
1561
  /** Header row height in pixels. @default 36 */
1354
1562
  headerHeight?: number;
1355
- /** When `true`, hides all editing UI (submit, add row, delete, import). The grid becomes view-only. */
1563
+ /**
1564
+ * When `true`, hides all editing UI (submit, add row, delete, import). The
1565
+ * grid becomes view-only.
1566
+ * @default false
1567
+ */
1356
1568
  readonly?: boolean;
1357
- /** Enable right-to-left layout for RTL languages. @default false */
1569
+ /**
1570
+ * Enable right-to-left layout. Set to `true` for Arabic, Hebrew, and other
1571
+ * RTL languages. Affects grid direction, text alignment, and scrollbar
1572
+ * position.
1573
+ * @default false
1574
+ */
1358
1575
  rtl?: boolean;
1359
- /** Allow creating new columns for unmatched CSV headers during import. @default true */
1576
+ /**
1577
+ * Allow creating new columns for unmatched CSV headers during import. When
1578
+ * enabled, users can keep data from columns that don't match your schema by
1579
+ * creating dynamic columns on the fly.
1580
+ * @default true
1581
+ */
1360
1582
  enableCreateColumn?: boolean;
1361
1583
  /** Override column matching during import. Return a map of `{ csvHeader: columnId | null }`. Unmapped or `null` entries fall back to built-in matching. */
1362
1584
  onColumnMatch?: (headers: string[], columns: DataEditorColumn[]) => Record<string, string | null> | Promise<Record<string, string | null>>;
@@ -1377,30 +1599,63 @@ type DataEditorBaseProps<TRow extends DataEditorRow = DataEditorRow> = {
1377
1599
  * ```
1378
1600
  */
1379
1601
  onValueMatch?: (valuesToMatch: Record<string, ValueMatchInput>) => ValueMatchOutput | Promise<ValueMatchOutput>;
1380
- /** Extra synonyms for column auto-matching, e.g. `{ productsku: ["sku", "articleno"] }`. */
1602
+ /**
1603
+ * Extra synonyms for column auto-matching. Keys are column IDs, values are
1604
+ * alternative names the matching engine should recognize.
1605
+ *
1606
+ * @example
1607
+ * ```ts
1608
+ * synonyms={{
1609
+ * productSku: ["sku", "article_no", "item_code"],
1610
+ * firstName: ["first", "given_name", "fname"],
1611
+ * }}
1612
+ * ```
1613
+ */
1381
1614
  synonyms?: Record<string, string[]>;
1382
- /** Sample rows included in the "Download Example" file. When omitted, a generic row is auto-generated from column config. */
1615
+ /**
1616
+ * Sample rows included in the "Download Example" file. When the user clicks
1617
+ * "Download Example" in the import wizard, the SDK generates a template
1618
+ * file with column headers and these rows. When omitted, a generic example
1619
+ * row is auto-generated from column definitions.
1620
+ */
1383
1621
  sampleData?: Record<string, unknown>[];
1384
- /** Bring Your Own AI chat. When provided, a chat panel is shown alongside the grid. */
1622
+ /**
1623
+ * Bring-your-own-AI chat. When provided, a chat panel is shown alongside
1624
+ * the grid. You own the AI integration; the SDK hands you dataset context
1625
+ * and renders the streamed response.
1626
+ */
1385
1627
  chat?: DataEditorChat<TRow>;
1386
1628
  };
1387
1629
  /**
1388
- * Controls what the editor stores in `localStorage`.
1389
- * Set to `false` to disable all local storage usage.
1630
+ * Controls what the editor stores in `localStorage`. Set to `false` to
1631
+ * disable all local storage usage.
1632
+ *
1633
+ * @default { licenseGrant: true }
1390
1634
  */
1391
1635
  type DataEditorLocalStorage = false | {
1392
- /** Cache the license validation result to skip re-validation on reload. @default true */
1636
+ /**
1637
+ * Cache the license validation result to skip re-validation on reload.
1638
+ * @default true
1639
+ */
1393
1640
  licenseGrant?: boolean;
1394
1641
  };
1395
1642
  /** Shared props present in both modal and inline modes. */
1396
1643
  type DataEditorCommonProps<TRow extends DataEditorRow = DataEditorRow> = DataEditorBaseProps<TRow> & {
1397
- /** Your Updog license key. Validates on each open. */
1644
+ /** Your Updog license key. Validated on each open. */
1398
1645
  apiKey: string;
1399
- /** Controls what the editor stores in `localStorage`. Set to `false` to disable. */
1646
+ /**
1647
+ * Controls what the editor stores in `localStorage`. Set to `false` to
1648
+ * disable all local storage usage.
1649
+ * @default { licenseGrant: true }
1650
+ */
1400
1651
  localStorage?: DataEditorLocalStorage;
1401
- /** CSS class added to the wrapper element. */
1652
+ /** CSS class added to the wrapper element. Use for scoped styling overrides. */
1402
1653
  className?: string;
1403
- /** Called when the SDK catches an internal error. Use for logging, Sentry, etc. Client mode only. */
1654
+ /**
1655
+ * Called when the SDK catches an internal error. The SDK recovers
1656
+ * gracefully where possible — use this for your logging and monitoring
1657
+ * (Sentry, Datadog, etc.). Client mode only.
1658
+ */
1404
1659
  onError?: (error: UpdogError) => void;
1405
1660
  };
1406
1661
  /**
@@ -1410,9 +1665,16 @@ type DataEditorCommonProps<TRow extends DataEditorRow = DataEditorRow> = DataEdi
1410
1665
  type DataEditorModalProps<TRow extends DataEditorRow = DataEditorRow> = DataEditorCommonProps<TRow> & {
1411
1666
  /** Rendering mode. @default "modal" */
1412
1667
  mode?: "modal";
1413
- /** When `true`, the editor modal is visible. This is a controlled prop. Required in modal mode. */
1668
+ /**
1669
+ * Controls modal visibility. This is a controlled prop — you manage the
1670
+ * state. Required in modal mode.
1671
+ */
1414
1672
  open: boolean;
1415
- /** Called when the user closes the modal (clicks X or presses Escape). Required in modal mode. */
1673
+ /**
1674
+ * Called when the user closes the modal (X button or Escape key). If the
1675
+ * user has unsaved changes, the SDK shows a confirmation dialog before
1676
+ * calling `onClose`. Required in modal mode.
1677
+ */
1416
1678
  onClose: () => void;
1417
1679
  };
1418
1680
  /**