@updog/data-editor-wc 0.1.15 → 0.1.17

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 +6 -12
  2. package/index.d.ts +13 -24
  3. package/index.js +101 -89
  4. package/package.json +1 -1
package/README.md CHANGED
@@ -61,14 +61,13 @@ How you wire the element into a framework (Angular's `CUSTOM_ELEMENTS_SCHEMA`, V
61
61
  const res = await fetch("/api/employees");
62
62
  onChunk(await res.json());
63
63
  },
64
- onComplete: async (result, actions) => {
64
+ onComplete: async (result) => {
65
65
  for (const source of result.sources) {
66
66
  const inserts = source.rows.filter((r) => r.isNew && !r.isDeleted && r.isValid);
67
67
  const updates = source.rows.filter((r) => !r.isNew && r.isChanged && !r.isDeleted && r.isValid);
68
68
  const deletes = source.rows.filter((r) => r.isDeleted && !r.isNew);
69
69
  await persist(source.sourceId, { inserts, updates, deletes });
70
70
  }
71
- actions.reset();
72
71
  editor.hide();
73
72
  },
74
73
  });
@@ -109,7 +108,7 @@ Everything else — objects, functions, arrays — must be set as a JS property
109
108
  const editor = document.querySelector("updog-editor");
110
109
  editor.columns = [...];
111
110
  editor.loadData = async (onChunk) => { ... };
112
- editor.onComplete = (result, actions) => { ... };
111
+ editor.onComplete = async (result) => { ... };
113
112
  ```
114
113
 
115
114
  ### `configure(props)`
@@ -122,7 +121,7 @@ editor.configure({
122
121
  primaryKey: "id",
123
122
  columns: [...],
124
123
  loadData: async (onChunk) => onChunk(await fetchRows()),
125
- onComplete: (result, actions) => { save(result); actions.reset(); },
124
+ onComplete: async (result) => { await save(result); },
126
125
  });
127
126
  ```
128
127
 
@@ -146,7 +145,7 @@ In inline mode, `show()` / `hide()` and the `open` attribute don't apply. The `c
146
145
  | `mode` | `"modal"` \| `"inline"` | No | `"modal"` | Rendering mode. |
147
146
  | `open` | `boolean` | Modal only | — | Controlled modal visibility. Equivalent to `show()` / `hide()`. |
148
147
  | `loadData` | `(onChunk) => Promise<void>` | No | — | Async data loader. Stream rows in chunks, optionally tagged by source. |
149
- | `onComplete` | `(result, actions) => void` | No | — | Called on submit. See [Submission Result](#submission-result). |
148
+ | `onComplete` | `(result) => void \| Promise<void>` | No | — | Called on submit. See [Submission Result](#submission-result). |
150
149
  | `variant` | `"editor"` \| `"uploader"` | No | `"editor"` | Initial view. `"uploader"` opens the import wizard first. |
151
150
  | `translations` | `DataEditorTranslations` | No | — | Partial i18n overrides. |
152
151
  | `locale` | `string` | No | `"en"` | BCP 47 locale tag. |
@@ -303,7 +302,7 @@ editor.loadData = async (onChunk) => {
303
302
 
304
303
  ## Submission Result
305
304
 
306
- `onComplete(result, actions)` fires when the user submits.
305
+ `onComplete(result)` fires when the user submits. May return a promise.
307
306
 
308
307
  ```ts
309
308
  type DataEditorResult = {
@@ -320,23 +319,18 @@ type DataEditorResult = {
320
319
  }[];
321
320
  counts: { new: number; changed: number; deleted: number; invalid: number };
322
321
  };
323
-
324
- type DataEditorActions = {
325
- reset: () => void; // discard changes and reload via loadData
326
- };
327
322
  ```
328
323
 
329
324
  Pristine backend rows (unchanged, not deleted, not new) are omitted from `sources[].rows` — they're no-ops. The flags are orthogonal: a row can be new, changed, and deleted at once. You own the routing rules:
330
325
 
331
326
  ```js
332
- editor.onComplete = async (result, actions) => {
327
+ editor.onComplete = async (result) => {
333
328
  for (const source of result.sources) {
334
329
  const inserts = source.rows.filter((r) => r.isNew && !r.isDeleted && r.isValid);
335
330
  const updates = source.rows.filter((r) => !r.isNew && r.isChanged && !r.isDeleted && r.isValid);
336
331
  const deletes = source.rows.filter((r) => r.isDeleted && !r.isNew);
337
332
  await persist(source.sourceId, { inserts, updates, deletes });
338
333
  }
339
- actions.reset();
340
334
  };
341
335
  ```
342
336
 
package/index.d.ts CHANGED
@@ -959,14 +959,6 @@ type ScaleServerConfig = {
959
959
  url: string;
960
960
  };
961
961
 
962
- /**
963
- * Actions available inside the `onComplete` callback. Call `reset()` after a
964
- * successful save to clear the editor and re-fetch via `loadData`.
965
- */
966
- type DataEditorActions = {
967
- /** Discard all changes and reload the original data via `loadData`. */
968
- reset: () => void;
969
- };
970
962
  /**
971
963
  * A single row in the submit result, with orthogonal flags describing its state.
972
964
  *
@@ -1004,14 +996,13 @@ type DataEditorSourceResult<TRow extends DataEditorRow = DataEditorRow> = {
1004
996
  *
1005
997
  * @example
1006
998
  * ```ts
1007
- * onComplete={async (result, actions) => {
999
+ * onComplete={async (result) => {
1008
1000
  * for (const source of result.sources) {
1009
1001
  * const inserts = source.rows.filter(r => r.isNew && !r.isDeleted && r.isValid);
1010
1002
  * const updates = source.rows.filter(r => !r.isNew && r.isChanged && !r.isDeleted && r.isValid);
1011
1003
  * const deletes = source.rows.filter(r => r.isDeleted && !r.isNew);
1012
1004
  * await persist(source.sourceId, { inserts, updates, deletes });
1013
1005
  * }
1014
- * actions.reset();
1015
1006
  * }}
1016
1007
  * ```
1017
1008
  */
@@ -1148,22 +1139,21 @@ type DataEditorBaseProps<TRow extends DataEditorRow = DataEditorRow> = {
1148
1139
  loadData?: (onChunk: (rows: TRow[], options?: ChunkSourceOptions) => void) => Promise<void>;
1149
1140
  /**
1150
1141
  * Called when the user clicks "Submit". Receives the edited data grouped
1151
- * by source. Use `actions.reset()` to clear changes after a successful save.
1142
+ * by source. May return a promise.
1152
1143
  *
1153
1144
  * @example
1154
1145
  * ```ts
1155
- * onComplete={async (result, actions) => {
1146
+ * onComplete={async (result) => {
1156
1147
  * for (const source of result.sources) {
1157
1148
  * const inserts = source.rows.filter(r => r.isNew && !r.isDeleted && r.isValid);
1158
1149
  * const updates = source.rows.filter(r => !r.isNew && r.isChanged && !r.isDeleted && r.isValid);
1159
1150
  * const deletes = source.rows.filter(r => r.isDeleted && !r.isNew);
1160
1151
  * await persist(source.sourceId, { inserts, updates, deletes });
1161
1152
  * }
1162
- * actions.reset();
1163
1153
  * }}
1164
1154
  * ```
1165
1155
  */
1166
- onComplete?: (result: DataEditorResult<TRow>, actions: DataEditorActions) => void;
1156
+ onComplete?: (result: DataEditorResult<TRow>) => void | Promise<void>;
1167
1157
  /**
1168
1158
  * Controls the initial view. `"editor"` opens directly to the spreadsheet
1169
1159
  * grid. `"uploader"` opens the file import wizard first — the user uploads
@@ -1199,9 +1189,9 @@ type DataEditorBaseProps<TRow extends DataEditorRow = DataEditorRow> = {
1199
1189
  enableAddRow?: boolean;
1200
1190
  /**
1201
1191
  * Which file formats the user can import. `undefined` allows all formats,
1202
- * `[]` disables import entirely.
1192
+ * `false` disables import entirely.
1203
1193
  */
1204
- importFormats?: DataEditorFormat[];
1194
+ importFormats?: DataEditorFormat[] | false;
1205
1195
  /**
1206
1196
  * Client-defined remote data sources rendered as buttons on the upload
1207
1197
  * step. You own the integration; the SDK renders the button and processes
@@ -1210,9 +1200,9 @@ type DataEditorBaseProps<TRow extends DataEditorRow = DataEditorRow> = {
1210
1200
  remoteSources?: RemoteSource[];
1211
1201
  /**
1212
1202
  * Which file formats the user can export to. `undefined` allows all
1213
- * formats, `[]` disables export entirely.
1203
+ * formats, `false` disables export entirely.
1214
1204
  */
1215
- exportFormats?: DataEditorFormat[];
1205
+ exportFormats?: DataEditorFormat[] | false;
1216
1206
  /** Row height in pixels. @default 34 */
1217
1207
  rowHeight?: number;
1218
1208
  /** Header row height in pixels. @default 36 */
@@ -1231,7 +1221,7 @@ type DataEditorBaseProps<TRow extends DataEditorRow = DataEditorRow> = {
1231
1221
  */
1232
1222
  rtl?: boolean;
1233
1223
  /**
1234
- * Allow creating new columns for unmatched CSV headers during import. When
1224
+ * Allow creating new columns for unmatched headers during import. When
1235
1225
  * enabled, users can keep data from columns that don't match your schema by
1236
1226
  * creating dynamic columns on the fly.
1237
1227
  * @default true
@@ -1368,7 +1358,7 @@ type DataEditorInlineProps<TRow extends DataEditorRow = DataEditorRow> = DataEdi
1368
1358
  * columns={columns}
1369
1359
  * primaryKey="id"
1370
1360
  * loadData={async (onChunk) => onChunk(await fetchRows())}
1371
- * onComplete={(result, actions) => { saveChanges(result); actions.reset(); }}
1361
+ * onComplete={async (result) => { await saveChanges(result); }}
1372
1362
  * />
1373
1363
  *
1374
1364
  * // Inline mode
@@ -1378,7 +1368,7 @@ type DataEditorInlineProps<TRow extends DataEditorRow = DataEditorRow> = DataEdi
1378
1368
  * columns={columns}
1379
1369
  * primaryKey="id"
1380
1370
  * loadData={async (onChunk) => onChunk(await fetchRows())}
1381
- * onComplete={(result, actions) => { saveChanges(result); actions.reset(); }}
1371
+ * onComplete={async (result) => { await saveChanges(result); }}
1382
1372
  * />
1383
1373
  * ```
1384
1374
  */
@@ -1409,9 +1399,8 @@ type Props = DataEditorProps;
1409
1399
  * onChunk(rows);
1410
1400
  * };
1411
1401
  *
1412
- * editor.onComplete = (result, actions) => {
1413
- * console.log("Valid rows:", result.valid);
1414
- * actions.reset();
1402
+ * editor.onComplete = async (result) => {
1403
+ * await save(result);
1415
1404
  * };
1416
1405
  *
1417
1406
  * editor.addEventListener("close", () => editor.hide());
package/index.js CHANGED
@@ -25232,49 +25232,53 @@ async function Mv(e) {
25232
25232
  }
25233
25233
  //#endregion
25234
25234
  //#region src/components/DataEditor/ConfirmCompleteDialog/index.tsx
25235
- var Nv = ({ open: e, onClose: t, onConfirm: n }) => {
25236
- let { store: r } = Bd(), { t: i } = k(), { newRowCount: a, dirtyRowCount: o, deletedRowCount: s, errorCount: c } = nl(r), l = o - a, u = c > 0;
25235
+ var Nv = ({ open: e, onClose: t, onConfirm: n, loading: r = !1 }) => {
25236
+ let { store: i } = Bd(), { t: a } = k(), { newRowCount: o, dirtyRowCount: s, deletedRowCount: c, errorCount: l } = nl(i), u = s - o, d = l > 0;
25237
25237
  return /* @__PURE__ */ (0, E.jsxs)(fs, {
25238
25238
  open: e,
25239
- onOpenChange: t,
25240
- title: i("dataEditor.confirmSubmit.title"),
25239
+ onOpenChange: (0, _.useCallback)((e) => {
25240
+ r || e || t();
25241
+ }, [r, t]),
25242
+ title: a("dataEditor.confirmSubmit.title"),
25241
25243
  className: "updog__confirm-complete-dialog",
25242
25244
  children: [/* @__PURE__ */ (0, E.jsxs)(us, {
25243
25245
  className: "updog__confirm-complete-dialog__body",
25244
25246
  children: [
25245
- /* @__PURE__ */ (0, E.jsx)(W, { children: i("dataEditor.confirmSubmit.text") }),
25247
+ /* @__PURE__ */ (0, E.jsx)(W, { children: a("dataEditor.confirmSubmit.text") }),
25246
25248
  /* @__PURE__ */ (0, E.jsxs)("ul", {
25247
25249
  className: "updog__confirm-complete-dialog__list",
25248
25250
  children: [
25249
- a > 0 && /* @__PURE__ */ (0, E.jsx)(W, {
25251
+ o > 0 && /* @__PURE__ */ (0, E.jsx)(W, {
25250
25252
  as: "li",
25251
- children: i("dataEditor.confirmSubmit.createRows", { count: a })
25253
+ children: a("dataEditor.confirmSubmit.createRows", { count: o })
25252
25254
  }),
25253
- l > 0 && /* @__PURE__ */ (0, E.jsx)(W, {
25255
+ u > 0 && /* @__PURE__ */ (0, E.jsx)(W, {
25254
25256
  as: "li",
25255
- children: i("dataEditor.confirmSubmit.updateRows", { count: l })
25257
+ children: a("dataEditor.confirmSubmit.updateRows", { count: u })
25256
25258
  }),
25257
- s > 0 && /* @__PURE__ */ (0, E.jsx)(W, {
25259
+ c > 0 && /* @__PURE__ */ (0, E.jsx)(W, {
25258
25260
  as: "li",
25259
- children: i("dataEditor.confirmSubmit.deleteRows", { count: s })
25261
+ children: a("dataEditor.confirmSubmit.deleteRows", { count: c })
25260
25262
  })
25261
25263
  ]
25262
25264
  }),
25263
- u && /* @__PURE__ */ (0, E.jsx)(Ke, {
25265
+ d && /* @__PURE__ */ (0, E.jsx)(Ke, {
25264
25266
  color: "yellow",
25265
- text: i("dataEditor.confirmSubmit.bannerTitle", { count: c })
25267
+ text: a("dataEditor.confirmSubmit.bannerTitle", { count: l })
25266
25268
  })
25267
25269
  ]
25268
25270
  }), /* @__PURE__ */ (0, E.jsxs)(ds, { children: [/* @__PURE__ */ (0, E.jsx)(tt, {
25269
25271
  variant: "outlined",
25270
25272
  color: "neutral",
25271
25273
  onClick: t,
25272
- children: i("dataEditor.common.cancel")
25274
+ disabled: r,
25275
+ children: a("dataEditor.common.cancel")
25273
25276
  }), /* @__PURE__ */ (0, E.jsx)(tt, {
25274
25277
  onClick: n,
25275
25278
  variant: "filled",
25276
25279
  color: "primary",
25277
- children: i("dataEditor.confirmSubmit.action")
25280
+ loading: r,
25281
+ children: a("dataEditor.confirmSubmit.action")
25278
25282
  })] })]
25279
25283
  });
25280
25284
  }, Pv = () => {
@@ -25293,67 +25297,74 @@ var Nv = ({ open: e, onClose: t, onConfirm: n }) => {
25293
25297
  })
25294
25298
  });
25295
25299
  }, Fv = () => {
25296
- let { store: e, columns: t, onComplete: n, exportFormats: r, readonly: i, navigateToCell: a } = Bd(), { t: o, rtl: s } = k(), { canUndo: c, canRedo: l, undo: u, redo: d } = dl(e, a), { dirtyRowCount: f, deletedRowCount: p, isLoading: m, sources: h, phase: g } = nl(e), v = f > 0 || p > 0, y = m || h.some((e) => e.isLoading), b = g === "processing", [x, S] = (0, _.useState)(!1), { value: C, setTrue: w, setFalse: T } = el(!1), D = (0, _.useCallback)(() => {
25297
- n && (n(e.getResultBySource(), { reset: () => e.clear() }), T());
25300
+ let { store: e, columns: t, onComplete: n, exportFormats: r, readonly: i, navigateToCell: a } = Bd(), { t: o, rtl: s } = k(), { canUndo: c, canRedo: l, undo: u, redo: d } = dl(e, a), { dirtyRowCount: f, deletedRowCount: p, isLoading: m, sources: h, phase: g } = nl(e), v = f > 0 || p > 0, y = m || h.some((e) => e.isLoading), b = g === "processing", [x, S] = (0, _.useState)(!1), { value: C, setTrue: w, setFalse: T } = el(!1), [D, O] = (0, _.useState)(!1), A = (0, _.useCallback)(async () => {
25301
+ if (!n) return;
25302
+ let t = e.getResultBySource();
25303
+ O(!0);
25304
+ try {
25305
+ await n(t), e.clear(), T();
25306
+ } catch {} finally {
25307
+ O(!1);
25308
+ }
25298
25309
  }, [
25299
25310
  e,
25300
25311
  n,
25301
25312
  T
25302
- ]), O = o("dataEditor.footer.export"), A = o("dataEditor.footer.exportAll"), j = o("dataEditor.footer.exportFiltered"), M = o("dataEditor.footer.csvFormat"), N = o("dataEditor.footer.excelFormat"), P = o("dataEditor.footer.jsonFormat"), F = o("dataEditor.footer.tsvFormat"), I = o("dataEditor.footer.xmlFormat"), L = (0, _.useMemo)(() => [
25313
+ ]), j = o("dataEditor.footer.export"), M = o("dataEditor.footer.exportAll"), N = o("dataEditor.footer.exportFiltered"), P = o("dataEditor.footer.csvFormat"), F = o("dataEditor.footer.excelFormat"), I = o("dataEditor.footer.jsonFormat"), L = o("dataEditor.footer.tsvFormat"), R = o("dataEditor.footer.xmlFormat"), z = (0, _.useMemo)(() => [
25303
25314
  {
25304
25315
  menuId: "csv",
25305
25316
  format: "csv",
25306
- text: M
25317
+ text: P
25307
25318
  },
25308
25319
  {
25309
25320
  menuId: "tsv",
25310
25321
  format: "tsv",
25311
- text: F
25322
+ text: L
25312
25323
  },
25313
25324
  {
25314
25325
  menuId: "excel",
25315
25326
  format: "xlsx",
25316
- text: N
25327
+ text: F
25317
25328
  },
25318
25329
  {
25319
25330
  menuId: "json",
25320
25331
  format: "json",
25321
- text: P
25332
+ text: I
25322
25333
  },
25323
25334
  {
25324
25335
  menuId: "xml",
25325
25336
  format: "xml",
25326
- text: I
25337
+ text: R
25327
25338
  }
25328
25339
  ], [
25329
- M,
25330
- F,
25331
- N,
25332
25340
  P,
25333
- I
25334
- ]), R = r.length > 0 && (!e.isServer() || e.hasServerExport), z = (0, _.useMemo)(() => {
25335
- let e = L.filter((e) => r.includes(e.format));
25341
+ L,
25342
+ F,
25343
+ I,
25344
+ R
25345
+ ]), B = r !== !1 && (!e.isServer() || e.hasServerExport), V = (0, _.useMemo)(() => {
25346
+ let e = r === !1 ? [] : z.filter((e) => r.includes(e.format));
25336
25347
  return [{
25337
25348
  id: "export-all",
25338
- text: A,
25349
+ text: M,
25339
25350
  options: e.map((e) => ({
25340
25351
  id: `all-${e.menuId}`,
25341
25352
  text: e.text
25342
25353
  }))
25343
25354
  }, {
25344
25355
  id: "export-filtered",
25345
- text: j,
25356
+ text: N,
25346
25357
  options: e.map((e) => ({
25347
25358
  id: `filtered-${e.menuId}`,
25348
25359
  text: e.text
25349
25360
  }))
25350
25361
  }];
25351
25362
  }, [
25352
- A,
25353
- j,
25354
- L,
25363
+ M,
25364
+ N,
25365
+ z,
25355
25366
  r
25356
- ]), B = (0, _.useCallback)((n) => {
25367
+ ]), H = (0, _.useCallback)((n) => {
25357
25368
  let [r, i] = n.split("-"), a = {
25358
25369
  csv: "csv",
25359
25370
  tsv: "tsv",
@@ -25372,7 +25383,7 @@ var Nv = ({ open: e, onClose: t, onConfirm: n }) => {
25372
25383
  e,
25373
25384
  t,
25374
25385
  s
25375
- ]), V = o("dataEditor.footer.submit");
25386
+ ]), U = o("dataEditor.footer.submit");
25376
25387
  return /* @__PURE__ */ (0, E.jsxs)(E.Fragment, { children: [/* @__PURE__ */ (0, E.jsxs)("footer", {
25377
25388
  className: "updog__data-editor-footer",
25378
25389
  children: [/* @__PURE__ */ (0, E.jsx)(Pv, {}), /* @__PURE__ */ (0, E.jsxs)("div", {
@@ -25399,9 +25410,9 @@ var Nv = ({ open: e, onClose: t, onConfirm: n }) => {
25399
25410
  children: /* @__PURE__ */ (0, E.jsx)(ke, { className: "rtl-mirror" })
25400
25411
  })
25401
25412
  })] }),
25402
- R && /* @__PURE__ */ (0, E.jsx)(rc, {
25403
- options: z,
25404
- onSelect: B,
25413
+ B && /* @__PURE__ */ (0, E.jsx)(rc, {
25414
+ options: V,
25415
+ onSelect: H,
25405
25416
  placement: "top-end",
25406
25417
  children: /* @__PURE__ */ (0, E.jsx)(tt, {
25407
25418
  variant: "outlined",
@@ -25410,20 +25421,21 @@ var Nv = ({ open: e, onClose: t, onConfirm: n }) => {
25410
25421
  disabled: y || b,
25411
25422
  spinnerPosition: "end",
25412
25423
  endIcon: /* @__PURE__ */ (0, E.jsx)(ie, {}),
25413
- children: O
25424
+ children: j
25414
25425
  })
25415
25426
  }),
25416
25427
  !i && /* @__PURE__ */ (0, E.jsx)(tt, {
25417
- disabled: !v || b,
25428
+ disabled: !v || b || D,
25418
25429
  onClick: w,
25419
- children: V
25430
+ children: U
25420
25431
  })
25421
25432
  ]
25422
25433
  })]
25423
25434
  }), /* @__PURE__ */ (0, E.jsx)(Nv, {
25424
25435
  open: C,
25425
25436
  onClose: T,
25426
- onConfirm: D
25437
+ onConfirm: A,
25438
+ loading: D
25427
25439
  })] });
25428
25440
  }, Iv = ({ initialValues: e, existingNames: t, onClose: n, onSubmit: r }) => {
25429
25441
  let { t: i } = k(), a = e.id !== void 0, o = (0, _.useMemo)(() => {
@@ -38633,7 +38645,7 @@ var dN = ({ source: e }) => {
38633
38645
  }, fN = () => {
38634
38646
  let { store: e, columns: t, navigateToCell: n, navigateToCellRef: r, setShowUploader: i, enableAddRow: a, importFormats: o, readonly: s } = Bd(), { t: c } = k(), { sources: l, phase: u } = nl(e), d = u !== "idle", f = (0, _.useMemo)(() => {
38635
38647
  let e = [];
38636
- return o.length > 0 && e.push({
38648
+ return o !== !1 && o.length > 0 && e.push({
38637
38649
  id: "import_data",
38638
38650
  text: c("dataEditor.dataSources.importData"),
38639
38651
  icon: /* @__PURE__ */ (0, E.jsx)(Ve, { size: "1rem" })
@@ -38670,7 +38682,7 @@ var dN = ({ source: e }) => {
38670
38682
  n,
38671
38683
  r,
38672
38684
  c
38673
- ]), m = c("dataEditor.dataSources.addDataSource"), h = !s && (a || o.length > 0) ? /* @__PURE__ */ (0, E.jsx)(rc, {
38685
+ ]), m = c("dataEditor.dataSources.addDataSource"), h = !s && (a || o !== !1 && o.length > 0) ? /* @__PURE__ */ (0, E.jsx)(rc, {
38674
38686
  options: f,
38675
38687
  onSelect: p,
38676
38688
  placement: "bottom-end",
@@ -45008,7 +45020,7 @@ var pz = ({ source: e }) => e.icon.trimStart().startsWith("<") ? /* @__PURE__ */
45008
45020
  title: e.description,
45009
45021
  children: e.label
45010
45022
  }), hz = () => {
45011
- let { importFormats: e, remoteSources: t } = Bd(), { t: n } = k(), { remoteSourceLoading: r, remoteSourceError: i, handleRemoteSourceSelect: a } = fB();
45023
+ let { importFormats: e, remoteSources: t } = Bd(), n = e === !1 ? [] : e, { t: r } = k(), { remoteSourceLoading: i, remoteSourceError: a, handleRemoteSourceSelect: o } = fB();
45012
45024
  return /* @__PURE__ */ (0, E.jsxs)("div", {
45013
45025
  className: "updog__source-picker",
45014
45026
  children: [
@@ -45021,108 +45033,108 @@ var pz = ({ source: e }) => e.icon.trimStart().startsWith("<") ? /* @__PURE__ */
45021
45033
  size: "sm",
45022
45034
  weight: "medium",
45023
45035
  className: "updog__source-picker__link",
45024
- children: n("dataEditor.uploader.uploadFile.clickToUpload")
45036
+ children: r("dataEditor.uploader.uploadFile.clickToUpload")
45025
45037
  }), /* @__PURE__ */ (0, E.jsx)(W, {
45026
45038
  as: "span",
45027
45039
  size: "sm",
45028
- children: n("dataEditor.uploader.uploadFile.orDragAndDrop")
45040
+ children: r("dataEditor.uploader.uploadFile.orDragAndDrop")
45029
45041
  })]
45030
45042
  }), /* @__PURE__ */ (0, E.jsx)(W, {
45031
45043
  as: "span",
45032
45044
  size: "xs",
45033
- children: e.map((e) => e.toUpperCase()).join(", ")
45045
+ children: n.map((e) => e.toUpperCase()).join(", ")
45034
45046
  })]
45035
45047
  }),
45036
45048
  t.length > 0 && /* @__PURE__ */ (0, E.jsxs)(E.Fragment, { children: [/* @__PURE__ */ (0, E.jsx)(Zs, {}), /* @__PURE__ */ (0, E.jsx)("div", {
45037
45049
  className: "updog__source-picker__sources-list",
45038
45050
  children: t.map((e) => /* @__PURE__ */ (0, E.jsx)(mz, {
45039
45051
  source: e,
45040
- loading: r === e.id,
45041
- disabled: !!r,
45042
- onSelect: a
45052
+ loading: i === e.id,
45053
+ disabled: !!i,
45054
+ onSelect: o
45043
45055
  }, e.id))
45044
45056
  })] }),
45045
- i && /* @__PURE__ */ (0, E.jsx)(W, {
45057
+ a && /* @__PURE__ */ (0, E.jsx)(W, {
45046
45058
  size: "sm",
45047
45059
  className: "updog__source-picker__error",
45048
- children: i
45060
+ children: a
45049
45061
  })
45050
45062
  ]
45051
45063
  });
45052
45064
  }, gz = () => {
45053
- let { columns: e, importFormats: t, sampleData: n } = Bd(), { t: r } = k(), { parsedCsv: i, xlsxFile: a, handleFileRemoved: o, parseFile: s } = fB(), c = [
45065
+ let { columns: e, importFormats: t, sampleData: n } = Bd(), r = t === !1 ? [] : t, { t: i } = k(), { parsedCsv: a, xlsxFile: o, handleFileRemoved: s, parseFile: c } = fB(), l = [
45054
45066
  {
45055
45067
  id: "csv",
45056
45068
  format: "csv",
45057
- text: r("dataEditor.footer.csvFormat")
45069
+ text: i("dataEditor.footer.csvFormat")
45058
45070
  },
45059
45071
  {
45060
45072
  id: "tsv",
45061
45073
  format: "tsv",
45062
- text: r("dataEditor.footer.tsvFormat")
45074
+ text: i("dataEditor.footer.tsvFormat")
45063
45075
  },
45064
45076
  {
45065
45077
  id: "xlsx",
45066
45078
  format: "xlsx",
45067
- text: r("dataEditor.footer.excelFormat")
45079
+ text: i("dataEditor.footer.excelFormat")
45068
45080
  },
45069
45081
  {
45070
45082
  id: "json",
45071
45083
  format: "json",
45072
- text: r("dataEditor.footer.jsonFormat")
45084
+ text: i("dataEditor.footer.jsonFormat")
45073
45085
  },
45074
45086
  {
45075
45087
  id: "xml",
45076
45088
  format: "xml",
45077
- text: r("dataEditor.footer.xmlFormat")
45089
+ text: i("dataEditor.footer.xmlFormat")
45078
45090
  }
45079
- ].filter((e) => t.includes(e.format)), l = {
45091
+ ].filter((e) => r.includes(e.format)), u = {
45080
45092
  csv: "CSV",
45081
45093
  tsv: "TSV",
45082
45094
  xlsx: "Excel",
45083
45095
  json: "JSON",
45084
45096
  xml: "XML"
45085
- }, u = (() => {
45086
- let e = t.map((e) => l[e]);
45097
+ }, d = (() => {
45098
+ let e = r.map((e) => u[e]);
45087
45099
  if (e.length === 0) return "";
45088
- if (e.length === 1) return r("dataEditor.uploader.uploadFile.textDynamic", { formats: e[0] });
45089
- let n = e[e.length - 1];
45090
- return r("dataEditor.uploader.uploadFile.textDynamic", { formats: `${e.slice(0, -1).join(", ")} or ${n}` });
45091
- })(), d = (0, _.useCallback)((t) => {
45100
+ if (e.length === 1) return i("dataEditor.uploader.uploadFile.textDynamic", { formats: e[0] });
45101
+ let t = e[e.length - 1];
45102
+ return i("dataEditor.uploader.uploadFile.textDynamic", { formats: `${e.slice(0, -1).join(", ")} or ${t}` });
45103
+ })(), f = (0, _.useCallback)((t) => {
45092
45104
  jv(e, t, n);
45093
- }, [e, n]), f = {
45105
+ }, [e, n]), p = {
45094
45106
  csv: { "text/csv": [".csv"] },
45095
45107
  tsv: { "text/tab-separated-values": [".tsv"] },
45096
45108
  xlsx: { "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [".xlsx"] },
45097
45109
  json: { "application/json": [".json"] },
45098
45110
  xml: { "application/xml": [".xml"] }
45099
- }, { getRootProps: p, getInputProps: m, isDragActive: h } = uz({
45100
- accept: t.reduce((e, t) => ({
45111
+ }, { getRootProps: m, getInputProps: h, isDragActive: g } = uz({
45112
+ accept: r.reduce((e, t) => ({
45101
45113
  ...e,
45102
- ...f[t]
45114
+ ...p[t]
45103
45115
  }), {}),
45104
45116
  maxFiles: 1,
45105
- disabled: !!i || !!a,
45117
+ disabled: !!a || !!o,
45106
45118
  onDrop: (e) => {
45107
- e.length > 0 && s(e[0]);
45119
+ e.length > 0 && c(e[0]);
45108
45120
  }
45109
- }), g = !!i || !!a, v = i?.fileName ?? a?.name, y = (e) => {
45110
- e.stopPropagation(), o();
45121
+ }), v = !!a || !!o, y = a?.fileName ?? o?.name, b = (e) => {
45122
+ e.stopPropagation(), s();
45111
45123
  };
45112
45124
  return /* @__PURE__ */ (0, E.jsxs)(Ud, { children: [/* @__PURE__ */ (0, E.jsxs)(Vd, { children: [/* @__PURE__ */ (0, E.jsxs)("div", {
45113
45125
  className: "updog__step-select-files__aside-content",
45114
45126
  children: [/* @__PURE__ */ (0, E.jsx)(W, {
45115
45127
  weight: "bold",
45116
- children: r("dataEditor.uploader.uploadFile.title")
45128
+ children: i("dataEditor.uploader.uploadFile.title")
45117
45129
  }), /* @__PURE__ */ (0, E.jsx)(W, {
45118
45130
  className: "updog__step-select-files__text",
45119
- children: u
45131
+ children: d
45120
45132
  })]
45121
45133
  }), /* @__PURE__ */ (0, E.jsx)("footer", {
45122
45134
  className: "updog__step-select-files__footer",
45123
45135
  children: /* @__PURE__ */ (0, E.jsx)(rc, {
45124
- options: c,
45125
- onSelect: d,
45136
+ options: l,
45137
+ onSelect: f,
45126
45138
  placement: "top-start",
45127
45139
  matchTriggerWidth: !0,
45128
45140
  children: /* @__PURE__ */ (0, E.jsx)(tt, {
@@ -45130,19 +45142,19 @@ var pz = ({ source: e }) => e.icon.trimStart().startsWith("<") ? /* @__PURE__ */
45130
45142
  color: "neutral",
45131
45143
  className: "updog__step-select-files__download-btn",
45132
45144
  startIcon: /* @__PURE__ */ (0, E.jsx)(pe, {}),
45133
- children: r("dataEditor.uploader.uploadFile.downloadExample")
45145
+ children: i("dataEditor.uploader.uploadFile.downloadExample")
45134
45146
  })
45135
45147
  })
45136
45148
  })] }), /* @__PURE__ */ (0, E.jsxs)(Hd, { children: [/* @__PURE__ */ (0, E.jsx)("div", {
45137
45149
  className: "updog__step-select-files__content",
45138
45150
  children: /* @__PURE__ */ (0, E.jsxs)("div", {
45139
- ...p(),
45140
- className: j("updog__step-select-files__dropzone", g && "updog__step-select-files__dropzone--disabled", !g && h && "updog__step-select-files__dropzone--active"),
45151
+ ...m(),
45152
+ className: j("updog__step-select-files__dropzone", v && "updog__step-select-files__dropzone--disabled", !v && g && "updog__step-select-files__dropzone--active"),
45141
45153
  children: [
45142
- /* @__PURE__ */ (0, E.jsx)("input", { ...m() }),
45154
+ /* @__PURE__ */ (0, E.jsx)("input", { ...h() }),
45143
45155
  /* @__PURE__ */ (0, E.jsx)("div", {
45144
45156
  className: "updog__step-select-files__icon-container",
45145
- children: g ? /* @__PURE__ */ (0, E.jsx)(re, {
45157
+ children: v ? /* @__PURE__ */ (0, E.jsx)(re, {
45146
45158
  size: "1rem",
45147
45159
  className: "updog__step-select-files__icon rtl-mirror"
45148
45160
  }) : /* @__PURE__ */ (0, E.jsx)(Ve, {
@@ -45150,19 +45162,19 @@ var pz = ({ source: e }) => e.icon.trimStart().startsWith("<") ? /* @__PURE__ */
45150
45162
  className: "updog__step-select-files__icon"
45151
45163
  })
45152
45164
  }),
45153
- !g && /* @__PURE__ */ (0, E.jsx)(hz, {}),
45154
- g && /* @__PURE__ */ (0, E.jsxs)("div", {
45165
+ !v && /* @__PURE__ */ (0, E.jsx)(hz, {}),
45166
+ v && /* @__PURE__ */ (0, E.jsxs)("div", {
45155
45167
  className: "updog__step-select-files__info",
45156
45168
  children: [/* @__PURE__ */ (0, E.jsx)(W, {
45157
45169
  as: "span",
45158
45170
  size: "sm",
45159
- children: v
45171
+ children: y
45160
45172
  }), /* @__PURE__ */ (0, E.jsx)(tt, {
45161
45173
  size: "xs",
45162
45174
  variant: "ghost",
45163
45175
  color: "danger",
45164
- onClick: y,
45165
- children: r("dataEditor.common.remove")
45176
+ onClick: b,
45177
+ children: i("dataEditor.common.remove")
45166
45178
  })]
45167
45179
  })
45168
45180
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@updog/data-editor-wc",
3
- "version": "0.1.15",
3
+ "version": "0.1.17",
4
4
  "description": "Client-side CSV importer and spreadsheet editor SDK as a Web Component. Drop into Vue, Angular, Svelte, or vanilla JS. Import CSV, Excel, JSON; edit 1M+ rows entirely in the browser.",
5
5
  "author": "Mikhail Kutateladze <admin@updog.tech>",
6
6
  "homepage": "https://updog.tech",