@updog/data-editor-wc 0.1.3 → 0.1.5

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/README.md +364 -128
  2. package/index.css +1 -1
  3. package/index.d.ts +299 -52
  4. package/package.json +1 -1
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,14 @@ type Filters = {
565
598
  }>;
566
599
  };
567
600
 
601
+ /**
602
+ * A single chunk in the stream returned from `DataEditorChat.onMessage`.
603
+ *
604
+ * - `status` — progress message shown while processing (e.g. "Analyzing 500 rows...").
605
+ * - `message` — chat reply shown to the user.
606
+ * - `rows` — updated rows to apply to the grid. Matched by `primaryKey`.
607
+ * - `transform` — description of the transform applied.
608
+ */
568
609
  type ChatResponseChunk<TRow extends DataEditorRow = DataEditorRow> = {
569
610
  type: "status";
570
611
  content: string;
@@ -578,37 +619,105 @@ type ChatResponseChunk<TRow extends DataEditorRow = DataEditorRow> = {
578
619
  type: "transform";
579
620
  content: string;
580
621
  };
622
+ /** Status of a row in the chat sample, relative to its origin snapshot. */
581
623
  type ChatRowStatus = "new" | "edited" | "original";
624
+ /** A sample row handed to the chat callback, with its current status and validation errors. */
582
625
  type ChatRow<TRow extends DataEditorRow = DataEditorRow> = {
626
+ /** Row data keyed by column ID. */
583
627
  data: TRow;
628
+ /** Whether the row was newly added, edited, or is unchanged. */
584
629
  status: ChatRowStatus;
630
+ /** Validation errors keyed by column ID. */
585
631
  errors: Record<string, string[]>;
632
+ /** The source this row belongs to. */
586
633
  source: string;
587
634
  };
635
+ /** Aggregated error count across the current view, grouped by field and message. */
588
636
  type ChatErrorSummary = {
637
+ /** Column ID where the error occurred. */
589
638
  field: string;
639
+ /** The validation message. */
590
640
  message: string;
641
+ /** How many rows hit this error. */
591
642
  count: number;
643
+ /** A few example values that triggered the error. */
592
644
  examples: string[];
593
645
  };
646
+ /**
647
+ * Context about the current dataset, passed to `loadSuggestions` and extended
648
+ * into `ChatContext` for `onMessage`.
649
+ */
594
650
  type ChatDataContext<TRow extends DataEditorRow = DataEditorRow> = {
651
+ /** Full column definitions. */
595
652
  columns: DataEditorColumn[];
653
+ /** Row identifier field. */
596
654
  primaryKey: keyof TRow;
655
+ /** Total rows in the dataset. */
597
656
  totalRowCount: number;
657
+ /** Rows in the current filtered view. */
598
658
  filteredRowCount: number;
659
+ /** Sample rows, with status and errors. Size controlled by `sampleSize`. */
599
660
  sample: ChatRow<TRow>[];
661
+ /** Aggregated error counts by field and message. */
600
662
  errorSummary: ChatErrorSummary[];
663
+ /** Access all rows. Use for full-dataset operations. */
601
664
  getRows: () => ChatRow<TRow>[];
602
665
  };
666
+ /**
667
+ * The full context passed to `DataEditorChat.onMessage` when the user sends
668
+ * a prompt. Includes the prompt itself and all dataset context.
669
+ */
603
670
  type ChatContext<TRow extends DataEditorRow = DataEditorRow> = ChatDataContext<TRow> & {
671
+ /** The user's chat prompt. */
604
672
  message: string;
605
673
  };
674
+ /**
675
+ * Bring-your-own-AI chat configuration. When provided via the `chat` prop,
676
+ * the editor shows a chat panel alongside the grid. You own the AI
677
+ * integration; the SDK hands you dataset context and renders the streamed
678
+ * response.
679
+ *
680
+ * @example
681
+ * ```ts
682
+ * chat={{
683
+ * sampleSize: 50,
684
+ * onMessage: async function* (context) {
685
+ * yield { type: "status", content: "Thinking..." };
686
+ * const res = await fetch("/api/ai", {
687
+ * method: "POST",
688
+ * body: JSON.stringify({
689
+ * prompt: context.message,
690
+ * columns: context.columns,
691
+ * sample: context.sample.map(r => r.data),
692
+ * errors: context.errorSummary,
693
+ * }),
694
+ * }).then(r => r.json());
695
+ * yield { type: "rows", content: res.updatedRows };
696
+ * yield { type: "transform", content: res.description };
697
+ * yield { type: "message", content: res.reply };
698
+ * },
699
+ * }}
700
+ * ```
701
+ */
606
702
  type DataEditorChat<TRow extends DataEditorRow = DataEditorRow> = {
703
+ /**
704
+ * How many rows to include in the context sample. The SDK picks a
705
+ * representative slice including rows with errors. When omitted, the SDK decides.
706
+ */
607
707
  sampleSize?: number;
708
+ /** Title shown above the suggestion list when the chat is empty. */
608
709
  emptyTitle?: string;
710
+ /** How many suggestions to request from `loadSuggestions`. */
609
711
  suggestionsCount?: number;
712
+ /** Optional prompt generator for the empty-state suggestion chips. */
610
713
  loadSuggestions?: (context: ChatDataContext<TRow>) => Promise<string[]>;
714
+ /**
715
+ * Called when the user sends a message. Receives full dataset context.
716
+ * Returns an async iterable of response chunks — the SDK streams them
717
+ * into the UI.
718
+ */
611
719
  onMessage: (context: ChatContext<TRow>) => AsyncIterable<ChatResponseChunk<TRow>>;
720
+ /** Called when the user cancels a pending request. Use to abort your API call. */
612
721
  onCancel?: () => void;
613
722
  };
614
723
 
@@ -627,8 +736,13 @@ type ValidationError = {
627
736
  * A function that validates a single cell value.
628
737
  * Return a `ValidationError` to flag a problem, or `null` if the value is valid.
629
738
  *
739
+ * A `ValidationError` with `level: "error"` flags the cell in the grid but
740
+ * does not block submission — invalid rows are delivered to `onComplete`
741
+ * alongside valid ones, tagged via the `isValid` flag.
742
+ *
630
743
  * Built-in validator factories: `required(msg)`, `numeric(msg)`, `email(msg)`,
631
- * `date(msg)`, `endDateAfterStart(startField, msg)`. Import them from the package root.
744
+ * `date(msg)`, `oneOf(values, msg)`, `endDateAfterStart(startField, msg)`.
745
+ * Import them from the package root.
632
746
  *
633
747
  * @param value - The current cell value.
634
748
  * @param row - The full row, useful for cross-field checks.
@@ -712,41 +826,62 @@ type ColumnLockMode = "all" | "default";
712
826
  *
713
827
  * @example
714
828
  * ```ts
829
+ * import { required, email, numeric } from "@updog/data-editor";
830
+ *
715
831
  * 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}` },
832
+ * { id: "name", title: "Full Name", size: 200, validate: required("Name is required") },
833
+ * { id: "email", title: "Email", size: 250, validate: [required("Email is required"), email("Invalid email")], unique: true },
834
+ * { id: "role", title: "Role", editor: { type: "select", options: ["Admin", "Editor", "Viewer"] } },
835
+ * { id: "salary", title: "Salary", validate: numeric("Must be a number"), formatter: (v) => v ? `$${v}` : "" },
720
836
  * ];
721
837
  * ```
722
838
  */
723
839
  type DataEditorColumn = {
724
840
  /** Unique column identifier. Must match the keys in your row data. */
725
841
  id: string;
726
- /** Column header text. */
842
+ /** Column header text shown to the user. */
727
843
  title: string;
728
- /** One or more validators to run on every edit. */
844
+ /**
845
+ * One or more validators run on every edit. Each receives the cell value and
846
+ * the full row, and returns a `ValidationError` to flag a problem or `null`
847
+ * if valid. Errors do not block submission — see `CellValidator`.
848
+ */
729
849
  validate?: CellValidator | CellValidator[];
730
- /** When `true`, the editor flags duplicate values in this column as errors. */
850
+ /**
851
+ * When `true`, the editor flags duplicate values in this column as errors.
852
+ * The error message is localized via the `translations` prop
853
+ * (`dataEditor.validation.valueMustBeUnique`).
854
+ */
731
855
  unique?: boolean;
732
- /** Column IDs to revalidate when this column changes. Use for cross-field rules like "end date must be after start date". */
856
+ /**
857
+ * Column IDs to revalidate when this column changes. Use for cross-field
858
+ * rules like "end date must be after start date".
859
+ */
733
860
  dependentFields?: string[];
734
861
  /** Format the display value without changing stored data. E.g. add `$` prefix. */
735
862
  formatter?: (value: string) => string;
736
- /** Transform the value before it enters the store. Runs on every edit and import. */
863
+ /**
864
+ * Transform a value before it enters the store. Runs when rows are uploaded
865
+ * to the data editor.
866
+ */
737
867
  transformer?: (value: unknown) => unknown;
738
868
  /** How the cell is edited. Defaults to text input. */
739
869
  editor?: CellEditor;
740
870
  /** Adds a filter control for this column in the sidebar Filters panel. */
741
871
  filter?: ColumnFilter;
742
- /** Whether this column can be pinned to the left via the header context menu. @default true */
872
+ /**
873
+ * Whether this column can be pinned to the left (right in RTL) via the
874
+ * header context menu. @default true
875
+ */
743
876
  pinnable?: boolean;
744
877
  /** Column width in pixels. @default 150 */
745
878
  size?: number;
746
879
  /**
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.
880
+ * Controls whether cells in this column are locked. A column locked via
881
+ * configuration cannot be unlocked from the UI.
882
+ * - `true` | `"all"` — locked for every row.
883
+ * - `"default"` — locked only for default-source rows; rows added manually,
884
+ * duplicated, or imported remain editable.
750
885
  * - `false` | `undefined` — not locked.
751
886
  */
752
887
  locked?: boolean | ColumnLockMode;
@@ -1146,9 +1281,12 @@ type DataEditorServer<TRow extends DataEditorRow = DataEditorRow, TFilters = Rec
1146
1281
  scrollSensitivity?: number;
1147
1282
  };
1148
1283
 
1149
- /** Actions available inside the `onComplete` callback. */
1284
+ /**
1285
+ * Actions available inside the `onComplete` callback. Call `reset()` after a
1286
+ * successful save to clear the editor and re-fetch via `loadData`.
1287
+ */
1150
1288
  type DataEditorActions = {
1151
- /** Discard all changes and reload the original data. */
1289
+ /** Discard all changes and reload the original data via `loadData`. */
1152
1290
  reset: () => void;
1153
1291
  };
1154
1292
  /**
@@ -1208,31 +1346,55 @@ type DataEditorResult<TRow extends DataEditorRow = DataEditorRow> = {
1208
1346
  invalid: number;
1209
1347
  };
1210
1348
  };
1349
+ /**
1350
+ * Options used to tag a chunk passed to `loadData`'s `onChunk` callback.
1351
+ * Sources are auto-registered on first encounter. Chunks without options go
1352
+ * to "Existing Data".
1353
+ */
1211
1354
  type ChunkSourceOptions = {
1212
- /** Display name for this data source. */
1355
+ /** Display name for this data source. Required when tagging a source. */
1213
1356
  source: string;
1214
- /** Stable identifier. Defaults to `source` value when omitted. */
1357
+ /** Stable identifier. Defaults to the `source` value when omitted. */
1215
1358
  id?: string;
1216
- /** Can the user delete this source? @default false */
1359
+ /** Whether the user can delete this source from the editor. @default false */
1217
1360
  deletable?: boolean;
1218
- /** Marks this source as finished loading. */
1361
+ /**
1362
+ * Marks this source as finished loading. Shows a completion state in the
1363
+ * UI. When the `loadData` promise resolves, any source still loading is
1364
+ * automatically finalized.
1365
+ * @default false
1366
+ */
1219
1367
  done?: boolean;
1220
1368
  };
1221
1369
  type DataSourceId = string;
1222
- /** Per-column data passed to `onValueMatch`: the unique imported values and the allowed select options. */
1370
+ /**
1371
+ * Per-column input to `onValueMatch`: the unique imported values from the
1372
+ * file and the allowed select options defined on the column.
1373
+ */
1223
1374
  type ValueMatchInput = {
1375
+ /** Distinct values seen in the imported file for this column. */
1224
1376
  importedValues: string[];
1377
+ /** Allowed options from the column's `select` editor. */
1225
1378
  options: string[];
1226
1379
  };
1227
- /** Per-column result from `onValueMatch`: maps each imported value to an option value, or `null` to skip auto-matching. */
1380
+ /**
1381
+ * Per-column result from `onValueMatch`. Outer key = column ID, inner key =
1382
+ * imported value, inner value = chosen option, or `null` to skip
1383
+ * auto-matching for that value. Unmapped values fall back to built-in fuzzy
1384
+ * matching.
1385
+ */
1228
1386
  type ValueMatchOutput = Record<string, Record<string, string | null>>;
1229
- /** File formats supported for import and export. */
1387
+ /** File formats supported for import and export. Shared by `importFormats` and `exportFormats`. */
1230
1388
  type DataEditorFormat = "csv" | "tsv" | "xlsx" | "json" | "xml";
1231
1389
  /**
1232
1390
  * A client-defined remote data source (e.g. Google Sheets, S3, Dropbox).
1233
1391
  *
1234
- * The SDK renders a button per source and calls `fetch()` when clicked.
1235
- * The client owns all integration complexity — auth, pickers, downloads.
1392
+ * The SDK renders a button per source on the upload step and calls `fetch()`
1393
+ * when clicked. You own all integration complexity — auth, pickers,
1394
+ * downloads. The SDK just processes the result.
1395
+ *
1396
+ * Return a `File` to go through the standard parse pipeline
1397
+ * (CSV/XLSX/JSON/XML), or return structured records to skip parsing entirely.
1236
1398
  *
1237
1399
  * @example
1238
1400
  * ```ts
@@ -1256,7 +1418,10 @@ type RemoteSource = {
1256
1418
  icon: string;
1257
1419
  /** Optional tooltip text. */
1258
1420
  description?: string;
1259
- /** Returns a File (parsed via CSV/XLSX/JSON/XML pipeline) or structured records (used directly). */
1421
+ /**
1422
+ * Returns a `File` (parsed via the CSV/XLSX/JSON/XML pipeline) or structured
1423
+ * records (used directly, skipping parse).
1424
+ */
1260
1425
  fetch: () => Promise<File | Record<string, unknown>[]>;
1261
1426
  };
1262
1427
  /**
@@ -1271,8 +1436,9 @@ type DataEditorBaseProps<TRow extends DataEditorRow = DataEditorRow> = {
1271
1436
  /** Column definitions. Each entry describes one column in the grid. */
1272
1437
  columns: DataEditorColumn[];
1273
1438
  /**
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.
1439
+ * The column ID used to uniquely identify each row (e.g. `"id"` or
1440
+ * `"employeeId"`). Used to match imported rows against existing data and to
1441
+ * track edits.
1276
1442
  */
1277
1443
  primaryKey: keyof TRow;
1278
1444
  /**
@@ -1326,37 +1492,78 @@ type DataEditorBaseProps<TRow extends DataEditorRow = DataEditorRow> = {
1326
1492
  * ```
1327
1493
  */
1328
1494
  onComplete?: (result: DataEditorResult<TRow>, actions: DataEditorActions) => void;
1329
- /** Controls the initial view. `"editor"` opens the grid, `"uploader"` opens the import wizard first. @default "editor" */
1495
+ /**
1496
+ * Controls the initial view. `"editor"` opens directly to the spreadsheet
1497
+ * grid. `"uploader"` opens the file import wizard first — the user uploads
1498
+ * a file, maps columns, fixes errors, then continues to the grid.
1499
+ * @default "editor"
1500
+ */
1330
1501
  variant?: DataEditorVariant;
1331
- /** Override any UI string. Pass a partial object — only the keys you provide are replaced. */
1502
+ /**
1503
+ * Override any UI string. Pass a partial object — only the keys you provide
1504
+ * are replaced. Every key lives under `dataEditor`.
1505
+ */
1332
1506
  translations?: DataEditorTranslations;
1333
- /** BCP 47 locale tag (e.g. `"en"`, `"fr"`, `"ar"`). Used for plural rules and locale-aware features. @default "en" */
1507
+ /**
1508
+ * BCP 47 locale tag (e.g. `"en"`, `"fr"`, `"ar"`). Used for plural rules
1509
+ * and locale-aware features.
1510
+ * @default "en"
1511
+ */
1334
1512
  locale?: string;
1335
1513
  /**
1336
1514
  * Controls row deletion via the right-click context menu.
1337
- * - `false` — deletion disabled (default).
1515
+ * - `false` — deletion disabled.
1338
1516
  * - `"new"` — only manually added or imported rows can be deleted.
1339
1517
  * - `"all"` — any row can be deleted.
1340
1518
  * @default false
1341
1519
  */
1342
1520
  enableDeleteRow?: "all" | "new" | false;
1343
- /** Show the "Add row" button in the data sources panel. @default true */
1521
+ /**
1522
+ * Show the "Add row" button in the data sources panel. When `false`, users
1523
+ * can only edit existing rows or import data — they can't manually add
1524
+ * blank rows.
1525
+ * @default true
1526
+ */
1344
1527
  enableAddRow?: boolean;
1345
- /** Which file formats the user can import. `undefined` allows all, `[]` disables import entirely. */
1528
+ /**
1529
+ * Which file formats the user can import. `undefined` allows all formats,
1530
+ * `[]` disables import entirely.
1531
+ */
1346
1532
  importFormats?: DataEditorFormat[];
1347
- /** Client-defined remote data sources rendered as buttons on the upload step. */
1533
+ /**
1534
+ * Client-defined remote data sources rendered as buttons on the upload
1535
+ * step. You own the integration; the SDK renders the button and processes
1536
+ * the result of `fetch()`.
1537
+ */
1348
1538
  remoteSources?: RemoteSource[];
1349
- /** Which file formats the user can export. `undefined` allows all, `[]` disables export entirely. */
1539
+ /**
1540
+ * Which file formats the user can export to. `undefined` allows all
1541
+ * formats, `[]` disables export entirely.
1542
+ */
1350
1543
  exportFormats?: DataEditorFormat[];
1351
1544
  /** Row height in pixels. @default 34 */
1352
1545
  rowHeight?: number;
1353
1546
  /** Header row height in pixels. @default 36 */
1354
1547
  headerHeight?: number;
1355
- /** When `true`, hides all editing UI (submit, add row, delete, import). The grid becomes view-only. */
1548
+ /**
1549
+ * When `true`, hides all editing UI (submit, add row, delete, import). The
1550
+ * grid becomes view-only.
1551
+ * @default false
1552
+ */
1356
1553
  readonly?: boolean;
1357
- /** Enable right-to-left layout for RTL languages. @default false */
1554
+ /**
1555
+ * Enable right-to-left layout. Set to `true` for Arabic, Hebrew, and other
1556
+ * RTL languages. Affects grid direction, text alignment, and scrollbar
1557
+ * position.
1558
+ * @default false
1559
+ */
1358
1560
  rtl?: boolean;
1359
- /** Allow creating new columns for unmatched CSV headers during import. @default true */
1561
+ /**
1562
+ * Allow creating new columns for unmatched CSV headers during import. When
1563
+ * enabled, users can keep data from columns that don't match your schema by
1564
+ * creating dynamic columns on the fly.
1565
+ * @default true
1566
+ */
1360
1567
  enableCreateColumn?: boolean;
1361
1568
  /** Override column matching during import. Return a map of `{ csvHeader: columnId | null }`. Unmapped or `null` entries fall back to built-in matching. */
1362
1569
  onColumnMatch?: (headers: string[], columns: DataEditorColumn[]) => Record<string, string | null> | Promise<Record<string, string | null>>;
@@ -1377,30 +1584,63 @@ type DataEditorBaseProps<TRow extends DataEditorRow = DataEditorRow> = {
1377
1584
  * ```
1378
1585
  */
1379
1586
  onValueMatch?: (valuesToMatch: Record<string, ValueMatchInput>) => ValueMatchOutput | Promise<ValueMatchOutput>;
1380
- /** Extra synonyms for column auto-matching, e.g. `{ productsku: ["sku", "articleno"] }`. */
1587
+ /**
1588
+ * Extra synonyms for column auto-matching. Keys are column IDs, values are
1589
+ * alternative names the matching engine should recognize.
1590
+ *
1591
+ * @example
1592
+ * ```ts
1593
+ * synonyms={{
1594
+ * productSku: ["sku", "article_no", "item_code"],
1595
+ * firstName: ["first", "given_name", "fname"],
1596
+ * }}
1597
+ * ```
1598
+ */
1381
1599
  synonyms?: Record<string, string[]>;
1382
- /** Sample rows included in the "Download Example" file. When omitted, a generic row is auto-generated from column config. */
1600
+ /**
1601
+ * Sample rows included in the "Download Example" file. When the user clicks
1602
+ * "Download Example" in the import wizard, the SDK generates a template
1603
+ * file with column headers and these rows. When omitted, a generic example
1604
+ * row is auto-generated from column definitions.
1605
+ */
1383
1606
  sampleData?: Record<string, unknown>[];
1384
- /** Bring Your Own AI chat. When provided, a chat panel is shown alongside the grid. */
1607
+ /**
1608
+ * Bring-your-own-AI chat. When provided, a chat panel is shown alongside
1609
+ * the grid. You own the AI integration; the SDK hands you dataset context
1610
+ * and renders the streamed response.
1611
+ */
1385
1612
  chat?: DataEditorChat<TRow>;
1386
1613
  };
1387
1614
  /**
1388
- * Controls what the editor stores in `localStorage`.
1389
- * Set to `false` to disable all local storage usage.
1615
+ * Controls what the editor stores in `localStorage`. Set to `false` to
1616
+ * disable all local storage usage.
1617
+ *
1618
+ * @default { licenseGrant: true }
1390
1619
  */
1391
1620
  type DataEditorLocalStorage = false | {
1392
- /** Cache the license validation result to skip re-validation on reload. @default true */
1621
+ /**
1622
+ * Cache the license validation result to skip re-validation on reload.
1623
+ * @default true
1624
+ */
1393
1625
  licenseGrant?: boolean;
1394
1626
  };
1395
1627
  /** Shared props present in both modal and inline modes. */
1396
1628
  type DataEditorCommonProps<TRow extends DataEditorRow = DataEditorRow> = DataEditorBaseProps<TRow> & {
1397
- /** Your Updog license key. Validates on each open. */
1629
+ /** Your Updog license key. Validated on each open. */
1398
1630
  apiKey: string;
1399
- /** Controls what the editor stores in `localStorage`. Set to `false` to disable. */
1631
+ /**
1632
+ * Controls what the editor stores in `localStorage`. Set to `false` to
1633
+ * disable all local storage usage.
1634
+ * @default { licenseGrant: true }
1635
+ */
1400
1636
  localStorage?: DataEditorLocalStorage;
1401
- /** CSS class added to the wrapper element. */
1637
+ /** CSS class added to the wrapper element. Use for scoped styling overrides. */
1402
1638
  className?: string;
1403
- /** Called when the SDK catches an internal error. Use for logging, Sentry, etc. Client mode only. */
1639
+ /**
1640
+ * Called when the SDK catches an internal error. The SDK recovers
1641
+ * gracefully where possible — use this for your logging and monitoring
1642
+ * (Sentry, Datadog, etc.). Client mode only.
1643
+ */
1404
1644
  onError?: (error: UpdogError) => void;
1405
1645
  };
1406
1646
  /**
@@ -1410,9 +1650,16 @@ type DataEditorCommonProps<TRow extends DataEditorRow = DataEditorRow> = DataEdi
1410
1650
  type DataEditorModalProps<TRow extends DataEditorRow = DataEditorRow> = DataEditorCommonProps<TRow> & {
1411
1651
  /** Rendering mode. @default "modal" */
1412
1652
  mode?: "modal";
1413
- /** When `true`, the editor modal is visible. This is a controlled prop. Required in modal mode. */
1653
+ /**
1654
+ * Controls modal visibility. This is a controlled prop — you manage the
1655
+ * state. Required in modal mode.
1656
+ */
1414
1657
  open: boolean;
1415
- /** Called when the user closes the modal (clicks X or presses Escape). Required in modal mode. */
1658
+ /**
1659
+ * Called when the user closes the modal (X button or Escape key). If the
1660
+ * user has unsaved changes, the SDK shows a confirmation dialog before
1661
+ * calling `onClose`. Required in modal mode.
1662
+ */
1416
1663
  onClose: () => void;
1417
1664
  };
1418
1665
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@updog/data-editor-wc",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Web Component wrapper for @updog/data-editor. Framework-agnostic, zero dependencies.",
5
5
  "author": "Mikhail Kutateladze <admin@updog.tech>",
6
6
  "homepage": "https://updog.tech",