@updog/data-editor 0.1.45 → 0.1.47

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 (3) hide show
  1. package/index.d.ts +21 -1
  2. package/index.js +212 -158
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -111,6 +111,7 @@ declare var export_default = {
111
111
  modal: {
112
112
  importTitle: "Import Data",
113
113
  editTitle: "Edit Data",
114
+ viewTitle: "View Data",
114
115
  },
115
116
  confirmClose: {
116
117
  title: "Discard changes?",
@@ -2533,6 +2534,9 @@ declare class DataStore<TRow extends DataEditorRow = DataEditorRow> {
2533
2534
  };
2534
2535
  getValidRows(): TRow[];
2535
2536
  getInvalidRows(): TRow[];
2537
+ private learnedSynonyms;
2538
+ private learnedSynonymKeys;
2539
+ recordLearnedSynonyms(delta: LearnedSynonyms): void;
2536
2540
  getResultBySource(): DataEditorResult<TRow>;
2537
2541
  private isRowVisible;
2538
2542
  applyFormula(formulaOrName: string | CellFormula, params: Record<string, unknown>, rects: SelectionRect[], options?: ApplyFormulaOptions): Promise<void>;
@@ -2701,6 +2705,16 @@ type DataEditorSourceResult<TRow extends DataEditorRow = DataEditorRow> = {
2701
2705
  * }}
2702
2706
  * ```
2703
2707
  */
2708
+ /** A user-confirmed import mapping: `source` (imported) → `target` (canonical). */
2709
+ type LearnedSynonym = {
2710
+ source: string;
2711
+ target: string;
2712
+ };
2713
+ /** User-confirmed import mappings, split by where they were matched. */
2714
+ type LearnedSynonyms = {
2715
+ columns: LearnedSynonym[];
2716
+ values: LearnedSynonym[];
2717
+ };
2704
2718
  type DataEditorResult<TRow extends DataEditorRow = DataEditorRow> = {
2705
2719
  sources: DataEditorSourceResult<TRow>[];
2706
2720
  counts: {
@@ -2709,6 +2723,12 @@ type DataEditorResult<TRow extends DataEditorRow = DataEditorRow> = {
2709
2723
  deleted: number;
2710
2724
  invalid: number;
2711
2725
  };
2726
+ /**
2727
+ * Import mappings the user confirmed that weren't already known, split into
2728
+ * `columns` and `values`. Persist and feed back through `synonyms` so repeat
2729
+ * imports auto-match. Each list is `[]` when nothing new was learned.
2730
+ */
2731
+ learnedSynonyms: LearnedSynonyms;
2712
2732
  };
2713
2733
  /**
2714
2734
  * Describes the change state of a single row within a chunk, used to seed
@@ -2873,7 +2893,7 @@ type RemoteSource = {
2873
2893
  * - `"editor"` — opens directly into the spreadsheet grid.
2874
2894
  * - `"uploader"` — opens the file import wizard first, then transitions to the grid.
2875
2895
  */
2876
- type DataEditorVariant = "editor" | "uploader";
2896
+ type DataEditorVariant = "editor" | "uploader" | "viewer";
2877
2897
  /** Base configuration shared by the public `DataEditorProps` and the internal provider. */
2878
2898
  type DataEditorBaseProps<TRow extends DataEditorRow = DataEditorRow> = {
2879
2899
  /** Column definitions. Each entry describes one column in the grid. */
package/index.js CHANGED
@@ -97,7 +97,8 @@ var Hr = {
97
97
  dataEditor: {
98
98
  modal: {
99
99
  importTitle: "Import Data",
100
- editTitle: "Edit Data"
100
+ editTitle: "Edit Data",
101
+ viewTitle: "View Data"
101
102
  },
102
103
  confirmClose: {
103
104
  title: "Discard changes?",
@@ -8045,7 +8046,10 @@ var tl = (e) => {
8045
8046
  t && this.serverCounts?.setCounts(t), this.snapshotManager.markCountsDirty(), this.notify();
8046
8047
  }
8047
8048
  clear() {
8048
- this.rowStore.clear(), this.sourceManager.clear(), this.filterEngine.clear(), this.validationStore.clear(), this.dirtyTracker.clear(), this.snapshotManager.clear(), this._isLoading = !0, this._editedCells.clear(), this.server?.clear(), this.history.clear(), this.editParamsHistory.clear(), this.notify();
8049
+ this.rowStore.clear(), this.sourceManager.clear(), this.filterEngine.clear(), this.validationStore.clear(), this.dirtyTracker.clear(), this.snapshotManager.clear(), this._isLoading = !0, this._editedCells.clear(), this.server?.clear(), this.history.clear(), this.editParamsHistory.clear(), this.learnedSynonyms = {
8050
+ columns: [],
8051
+ values: []
8052
+ }, this.learnedSynonymKeys.columns.clear(), this.learnedSynonymKeys.values.clear(), this.notify();
8049
8053
  }
8050
8054
  destroy() {
8051
8055
  this.filterEngine.destroy(), this.server?.destroy(), this.transformWorker?.terminate(), this.transformWorker = null, this.clear(), this.serverCounts?.clear(), this.clearViewportRange(), this.snapshotManager.clearListeners();
@@ -8280,6 +8284,20 @@ var tl = (e) => {
8280
8284
  }
8281
8285
  return e;
8282
8286
  }
8287
+ learnedSynonyms = {
8288
+ columns: [],
8289
+ values: []
8290
+ };
8291
+ learnedSynonymKeys = {
8292
+ columns: /* @__PURE__ */ new Set(),
8293
+ values: /* @__PURE__ */ new Set()
8294
+ };
8295
+ recordLearnedSynonyms(e) {
8296
+ for (let t of ["columns", "values"]) for (let n of e[t]) {
8297
+ let e = `${n.source} ${n.target}`;
8298
+ this.learnedSynonymKeys[t].has(e) || (this.learnedSynonymKeys[t].add(e), this.learnedSynonyms[t].push(n));
8299
+ }
8300
+ }
8283
8301
  getResultBySource() {
8284
8302
  let e = /* @__PURE__ */ new Map();
8285
8303
  for (let t of this.sourceManager.values()) e.set(t.id, {
@@ -8322,7 +8340,8 @@ var tl = (e) => {
8322
8340
  }
8323
8341
  return {
8324
8342
  sources: Array.from(e.values()),
8325
- counts: t
8343
+ counts: t,
8344
+ learnedSynonyms: this.learnedSynonyms
8326
8345
  };
8327
8346
  }
8328
8347
  isRowVisible(e) {
@@ -10296,6 +10315,7 @@ function Bl({ columns: e, primaryKey: t, loadData: n, scaleClient: r, onComplete
10296
10315
  setPendingImportFile: xe,
10297
10316
  openUploaderWithFile: Se,
10298
10317
  variant: a ?? "editor",
10318
+ isViewer: a === "viewer",
10299
10319
  search: ie,
10300
10320
  setSearch: ae,
10301
10321
  matchCase: oe,
@@ -10311,7 +10331,7 @@ function Bl({ columns: e, primaryKey: t, loadData: n, scaleClient: r, onComplete
10311
10331
  resetScrollRef: ee,
10312
10332
  scrollToGridTop: te,
10313
10333
  portalRef: _e,
10314
- readonly: y ?? !1,
10334
+ readonly: a === "viewer" ? !0 : y ?? !1,
10315
10335
  filtersResetKey: me,
10316
10336
  resetFilters: he,
10317
10337
  originalColumns: e,
@@ -11584,7 +11604,7 @@ var Hu = 9, Uu = 3, Wu = [3, 2], Gu = 1, Ku = 6, qu = .8, Ju = .5, Yu = 4, Xu =
11584
11604
  paintHeaderCell(e, t, n) {
11585
11605
  let { ctx: r, theme: i, layout: a, textCache: o, columns: s, controller: c, sortState: l } = e, u = c.selection, d = a.pinnedCount, f = a.rtl, p = a.getColumnX(t, n), m = a.getColumnWidth(t), h = a.contentToCanvasX(p, m);
11586
11606
  u.isColumnSelected(t) ? (r.fillStyle = i.headerBgSelected, vu(r, h, 0, m, 36)) : u.isColumnHighlighted(t) && (r.fillStyle = i.headerBgActive, vu(r, h, 0, m, 36));
11587
- let g = s[t], _ = t < d, v = l?.columnId === g.id, y = e.store.isColumnLocked(g.id), b = 0;
11607
+ let g = s[t], _ = t < d, v = l?.columnId === g.id, y = !c.readonly && e.store.isColumnLocked(g.id), b = 0;
11588
11608
  y && b++, _ && b++, v && b++;
11589
11609
  let x = b > 0 ? b * 14 + (b - 1) * Ku + Ku : 0, S = m - Hu * 2 - x;
11590
11610
  r.font = i.headerFont, r.fillStyle = i.headerContentIdle;
@@ -20585,39 +20605,39 @@ var Z_ = ({ text: e, onSelect: t }) => /* @__PURE__ */ C(J, {
20585
20605
  /* @__PURE__ */ C(rv, {})
20586
20606
  ]
20587
20607
  }) }), ov = () => {
20588
- let { store: e, columns: t, chat: n, enableAddRow: r, readonly: i, navigateToCell: a, importFormats: o, openUploaderWithFile: s } = X(), { rowCount: c, filteredCount: l, isLoading: u } = Bo(e), { t: d } = K(), p = !u && l === 0, m = r && !i && c === 0, h = o !== !1 && o.length > 0, g = f(async () => {
20589
- a(await Xl(e, t, d("dataEditor.dataSources.manuallyAdded")), t[0].id);
20608
+ let { store: e, columns: t, chat: n, enableAddRow: r, readonly: i, isViewer: a, navigateToCell: o, importFormats: s, openUploaderWithFile: c } = X(), { rowCount: l, filteredCount: u, isLoading: d } = Bo(e), { t: p } = K(), m = !d && u === 0, h = r && !i && l === 0, g = s !== !1 && s.length > 0, _ = f(async () => {
20609
+ o(await Xl(e, t, p("dataEditor.dataSources.manuallyAdded")), t[0].id);
20590
20610
  }, [
20591
20611
  e,
20592
20612
  t,
20593
- a,
20594
- d
20595
- ]), _ = v(() => {
20596
- if (m) return {
20597
- content: d("dataEditor.dataSources.addRow"),
20613
+ o,
20614
+ p
20615
+ ]), y = v(() => {
20616
+ if (h) return {
20617
+ content: p("dataEditor.dataSources.addRow"),
20598
20618
  startIcon: /* @__PURE__ */ C(Ce, { size: "1rem" }),
20599
20619
  variant: "filled",
20600
- onClick: g
20620
+ onClick: _
20601
20621
  };
20602
20622
  }, [
20603
- m,
20604
- g,
20605
- d
20606
- ]), y = v(() => Wl(o === !1 ? [] : o), [o]), b = f((e) => {
20623
+ h,
20624
+ _,
20625
+ p
20626
+ ]), b = v(() => Wl(s === !1 ? [] : s), [s]), x = f((e) => {
20607
20627
  let t = e[0];
20608
- t && s(t);
20609
- }, [s]), { getRootProps: x, isDragActive: S } = ft({
20610
- accept: y,
20628
+ t && c(t);
20629
+ }, [c]), { getRootProps: S, isDragActive: T } = ft({
20630
+ accept: b,
20611
20631
  maxFiles: 1,
20612
20632
  noClick: !0,
20613
20633
  noKeyboard: !0,
20614
- disabled: i || !h,
20615
- onDrop: b
20634
+ disabled: i || !g,
20635
+ onDrop: x
20616
20636
  });
20617
20637
  return /* @__PURE__ */ C(Jl, { children: /* @__PURE__ */ w("div", {
20618
- ...x({ className: "updog__data-editor-inner" }),
20638
+ ...S({ className: "updog__data-editor-inner" }),
20619
20639
  children: [
20620
- /* @__PURE__ */ C(Gl, { children: /* @__PURE__ */ C("div", {
20640
+ !a && /* @__PURE__ */ C(Gl, { children: /* @__PURE__ */ C("div", {
20621
20641
  className: "updog__data-editor-aside",
20622
20642
  children: /* @__PURE__ */ w("div", {
20623
20643
  className: "updog__data-editor-aside__content updog__scrollbar",
@@ -20631,18 +20651,18 @@ var Z_ = ({ text: e, onSelect: t }) => /* @__PURE__ */ C(J, {
20631
20651
  /* @__PURE__ */ w(Kl, { children: [
20632
20652
  /* @__PURE__ */ w("div", {
20633
20653
  className: "updog__data-editor-grid-area",
20634
- children: [/* @__PURE__ */ C(h_, {}), p && /* @__PURE__ */ C(Oa, {
20654
+ children: [/* @__PURE__ */ C(h_, {}), m && /* @__PURE__ */ C(Oa, {
20635
20655
  className: "updog-grid__empty-state",
20636
- title: d("dataEditor.grid.emptyTitle"),
20637
- text: d("dataEditor.grid.emptyText"),
20638
- buttonProps: _
20656
+ title: p("dataEditor.grid.emptyTitle"),
20657
+ text: p("dataEditor.grid.emptyText"),
20658
+ buttonProps: y
20639
20659
  })]
20640
20660
  }),
20641
20661
  /* @__PURE__ */ C(Yl, {}),
20642
- /* @__PURE__ */ C(cu, {})
20662
+ !a && /* @__PURE__ */ C(cu, {})
20643
20663
  ] }),
20644
- S && /* @__PURE__ */ C(ql, {}),
20645
- n && /* @__PURE__ */ C(av, {})
20664
+ T && /* @__PURE__ */ C(ql, {}),
20665
+ n && !a && /* @__PURE__ */ C(av, {})
20646
20666
  ]
20647
20667
  }) });
20648
20668
  }, sv = "RENDER_ERROR", cv = (e) => {
@@ -20679,7 +20699,7 @@ var Z_ = ({ text: e, onSelect: t }) => /* @__PURE__ */ C(J, {
20679
20699
  return this.state.hasError ? /* @__PURE__ */ C(cv, { error: lv }) : this.props.children;
20680
20700
  }
20681
20701
  }, dv = ({ leftSlot: e }) => {
20682
- let { variant: t, setShowUploader: n } = X(), { t: r } = K(), { isFirstStep: i, isLastStep: a, nextStep: o, prevStep: s, onImport: c, parsedCsv: l, xlsxFile: u, isParsing: d, isImporting: p, steps: m, activeStepIndex: h, selectedSheet: g, handleSheetConfirmed: _, remoteSourceLoading: v } = Dy(), y = i && t === "editor", b = f(() => {
20702
+ let { variant: t, setShowUploader: n } = X(), { t: r } = K(), { isFirstStep: i, isLastStep: a, nextStep: o, prevStep: s, onImport: c, parsedCsv: l, xlsxFile: u, isParsing: d, isImporting: p, steps: m, activeStepIndex: h, selectedSheet: g, handleSheetConfirmed: _, remoteSourceLoading: v } = ky(), y = i && t === "editor", b = f(() => {
20683
20703
  n(!1);
20684
20704
  }, [n]), x = m[h]?.id === "sheet-selection", S = f(() => {
20685
20705
  a ? c() : x ? _() : o();
@@ -21507,7 +21527,7 @@ var Z_ = ({ text: e, onSelect: t }) => /* @__PURE__ */ C(J, {
21507
21527
  ]
21508
21528
  });
21509
21529
  }), Pv = () => {
21510
- let { columns: e, enableCreateColumn: t, synonyms: n } = X(), { t: r } = K(), { parsedCsv: i, columnMapping: a, updateColumnMapping: o, pendingColumns: s, setPendingColumns: c } = Dy(), [l, u] = b(null), d = y(null), p = f((e, t) => {
21530
+ let { columns: e, enableCreateColumn: t, synonyms: n } = X(), { t: r } = K(), { parsedCsv: i, columnMapping: a, updateColumnMapping: o, pendingColumns: s, setPendingColumns: c } = ky(), [l, u] = b(null), d = y(null), p = f((e, t) => {
21511
21531
  if (t === "action:create") {
21512
21532
  d.current = e, u({ title: e });
21513
21533
  return;
@@ -21620,7 +21640,7 @@ var Z_ = ({ text: e, onSelect: t }) => /* @__PURE__ */ C(J, {
21620
21640
  ]
21621
21641
  });
21622
21642
  }, Fv = () => {
21623
- let { parsedCsv: e } = Dy();
21643
+ let { parsedCsv: e } = ky();
21624
21644
  return e ? /* @__PURE__ */ C(Jl, { children: /* @__PURE__ */ w(Kl, { children: [/* @__PURE__ */ C("div", {
21625
21645
  className: "updog__step-column-matching__content updog__scrollbar",
21626
21646
  children: /* @__PURE__ */ C(Pv, {})
@@ -21639,7 +21659,7 @@ var Z_ = ({ text: e, onSelect: t }) => /* @__PURE__ */ C(J, {
21639
21659
  })
21640
21660
  });
21641
21661
  }, Lv = () => {
21642
- let { columns: e } = X(), { t } = K(), { parsedCsv: n, columnMapping: r, valueMapping: i, autoValueMapping: a, updateValueMapping: o, pendingOptions: s, addPendingOption: c } = Dy(), [l, u] = b({}), [d, p] = b({}), [h, g] = b(null), _ = y(!1), x = f((e) => {
21662
+ let { columns: e } = X(), { t } = K(), { parsedCsv: n, columnMapping: r, valueMapping: i, autoValueMapping: a, updateValueMapping: o, pendingOptions: s, addPendingOption: c } = ky(), [l, u] = b({}), [d, p] = b({}), [h, g] = b(null), _ = y(!1), x = f((e) => {
21643
21663
  p((t) => ({
21644
21664
  ...t,
21645
21665
  [e]: !t[e]
@@ -21875,7 +21895,7 @@ var Z_ = ({ text: e, onSelect: t }) => /* @__PURE__ */ C(J, {
21875
21895
  className: "updog__step-match-values__content updog__scrollbar",
21876
21896
  children: /* @__PURE__ */ C(Lv, {})
21877
21897
  }), /* @__PURE__ */ C(dv, {})] }) }), zv = 20, Bv = () => {
21878
- let { columns: e, store: t } = X(), { t: n } = K(), { primaryKey: r, onPrimaryKeyChange: i, parsedCsv: a, columnMapping: o } = Dy(), s = t.isClient(), c = f(() => i(null), [i]), l = e.filter((e) => e.unique), u = v(() => {
21898
+ let { columns: e, store: t } = X(), { t: n } = K(), { primaryKey: r, onPrimaryKeyChange: i, parsedCsv: a, columnMapping: o } = ky(), s = t.isClient(), c = f(() => i(null), [i]), l = e.filter((e) => e.unique), u = v(() => {
21879
21899
  let e = {};
21880
21900
  for (let [t, n] of Object.entries(o)) n && (e[n] = t);
21881
21901
  return e;
@@ -21950,7 +21970,7 @@ var Z_ = ({ text: e, onSelect: t }) => /* @__PURE__ */ C(J, {
21950
21970
  title: e.description,
21951
21971
  children: e.label
21952
21972
  }), Wv = () => {
21953
- let { importFormats: e, remoteSources: t } = X(), n = e === !1 ? [] : e, { t: r } = K(), { remoteSourceLoading: i, remoteSourceError: a, handleRemoteSourceSelect: o } = Dy();
21973
+ let { importFormats: e, remoteSources: t } = X(), n = e === !1 ? [] : e, { t: r } = K(), { remoteSourceLoading: i, remoteSourceError: a, handleRemoteSourceSelect: o } = ky();
21954
21974
  return /* @__PURE__ */ w("div", {
21955
21975
  className: "updog__source-picker",
21956
21976
  children: [
@@ -22005,7 +22025,7 @@ var Z_ = ({ text: e, onSelect: t }) => /* @__PURE__ */ C(J, {
22005
22025
  })]
22006
22026
  });
22007
22027
  }, Kv = () => {
22008
- let { columns: e, importFormats: t, sampleData: n } = X(), r = t === !1 ? [] : t, { t: i } = K(), { parsedCsv: a, xlsxFile: o, handleFileRemoved: s, parseFile: c, isParsing: l, remoteSourceLoading: u } = Dy(), d = [
22028
+ let { columns: e, importFormats: t, sampleData: n } = X(), r = t === !1 ? [] : t, { t: i } = K(), { parsedCsv: a, xlsxFile: o, handleFileRemoved: s, parseFile: c, isParsing: l, remoteSourceLoading: u } = ky(), d = [
22009
22029
  {
22010
22030
  id: "csv",
22011
22031
  format: "csv",
@@ -22095,7 +22115,7 @@ var Z_ = ({ text: e, onSelect: t }) => /* @__PURE__ */ C(J, {
22095
22115
  ]
22096
22116
  }) });
22097
22117
  }, qv = ({ preview: e }) => {
22098
- let { selectedSheet: t, setSelectedSheet: n } = Dy(), { t: r } = K(), i = Math.max(0, e.totalRows), a = t === e.name, o = v(() => {
22118
+ let { selectedSheet: t, setSelectedSheet: n } = ky(), { t: r } = K(), i = Math.max(0, e.totalRows), a = t === e.name, o = v(() => {
22099
22119
  let { headers: t, rows: n } = e;
22100
22120
  return n.map((e) => t.map((t) => e[t] ?? ""));
22101
22121
  }, [e]);
@@ -22133,7 +22153,7 @@ var Z_ = ({ text: e, onSelect: t }) => /* @__PURE__ */ C(J, {
22133
22153
  })
22134
22154
  });
22135
22155
  }, Jv = () => {
22136
- let { sheetPreviews: e } = Dy();
22156
+ let { sheetPreviews: e } = ky();
22137
22157
  return /* @__PURE__ */ C(Jl, { children: /* @__PURE__ */ w(Kl, { children: [/* @__PURE__ */ C("div", {
22138
22158
  className: "updog__sheet-preview-wrapper updog__scrollbar",
22139
22159
  children: /* @__PURE__ */ C("div", {
@@ -22241,16 +22261,47 @@ function cy(e) {
22241
22261
  rawCells: i
22242
22262
  };
22243
22263
  }
22244
- function ly(e, t, n) {
22264
+ //#endregion
22265
+ //#region src/components/DataUploader/utils/learnedSynonyms.ts
22266
+ var ly = (e) => {
22267
+ let t = /* @__PURE__ */ new Map();
22268
+ for (let [n, r] of Object.entries(e)) {
22269
+ let e = hv(n), i = t.get(e) ?? /* @__PURE__ */ new Set();
22270
+ for (let e of r) i.add(hv(e));
22271
+ t.set(e, i);
22272
+ }
22273
+ return t;
22274
+ }, uy = (e, t, n, r) => {
22275
+ let i = ly(r), a = (e, t) => i.get(hv(e))?.has(hv(t)) ?? !1, o = new Map(n.map((e) => [e.id, e])), s = (e, t) => (n, r) => {
22276
+ if (hv(n) === hv(r) || a(r, n)) return;
22277
+ let i = `${n} ${r}`;
22278
+ t.has(i) || (t.add(i), e.push({
22279
+ source: n,
22280
+ target: r
22281
+ }));
22282
+ }, c = {
22283
+ columns: [],
22284
+ values: []
22285
+ }, l = s(c.columns, /* @__PURE__ */ new Set());
22286
+ for (let [t, n] of Object.entries(e)) {
22287
+ if (!n) continue;
22288
+ let e = o.get(n);
22289
+ e && l(t, e.title);
22290
+ }
22291
+ let u = s(c.values, /* @__PURE__ */ new Set());
22292
+ for (let e of Object.values(t)) for (let [t, n] of Object.entries(e)) n && u(t, n);
22293
+ return c;
22294
+ };
22295
+ function dy(e, t, n) {
22245
22296
  let r = e.length, i = t;
22246
- return i <= 0 ? [] : r === i ? [{ cells: [...e] }] : (r < i ? uy(i, i - r) : uy(r - 1, i - 1)) > 1e3 ? [] : r < i ? dy(e, i) : fy(e, i, n);
22297
+ return i <= 0 ? [] : r === i ? [{ cells: [...e] }] : (r < i ? fy(i, i - r) : fy(r - 1, i - 1)) > 1e3 ? [] : r < i ? py(e, i) : my(e, i, n);
22247
22298
  }
22248
- function uy(e, t) {
22299
+ function fy(e, t) {
22249
22300
  let n = Math.min(t, e - t), r = 1;
22250
22301
  for (let t = 1; t <= n; t++) if (r = r * (e - n + t) / t, r > 1e3) return r;
22251
22302
  return r;
22252
22303
  }
22253
- function dy(e, t) {
22304
+ function py(e, t) {
22254
22305
  let n = e.length, r = [], i = [], a = (o) => {
22255
22306
  if (i.length === n) {
22256
22307
  let a = Array(t).fill("");
@@ -22262,7 +22313,7 @@ function dy(e, t) {
22262
22313
  };
22263
22314
  return a(0), r;
22264
22315
  }
22265
- function fy(e, t, n) {
22316
+ function my(e, t, n) {
22266
22317
  let r = e.length, i = [], a = [], o = (s) => {
22267
22318
  if (a.length === t - 1) {
22268
22319
  let o = [
@@ -22280,27 +22331,27 @@ function fy(e, t, n) {
22280
22331
  }
22281
22332
  //#endregion
22282
22333
  //#region src/components/DataUploader/utils/raggedRows/pruneByValidators.ts
22283
- var py = {};
22284
- function my(e, t) {
22334
+ var hy = {};
22335
+ function gy(e, t) {
22285
22336
  for (let n of t.validators ?? []) if (n.type !== "expression") {
22286
22337
  if (n.type === "function") {
22287
- if (n.fn(e, py) != null) return !1;
22338
+ if (n.fn(e, hy) != null) return !1;
22288
22339
  continue;
22289
22340
  }
22290
- if (Ol(n, e, py) != null) return !1;
22341
+ if (Ol(n, e, hy) != null) return !1;
22291
22342
  }
22292
22343
  return !0;
22293
22344
  }
22294
- function hy(e, t) {
22295
- for (let n = 0; n < t.length; n++) if (!my(e.cells[n] ?? "", t[n])) return !1;
22345
+ function _y(e, t) {
22346
+ for (let n = 0; n < t.length; n++) if (!gy(e.cells[n] ?? "", t[n])) return !1;
22296
22347
  return !0;
22297
22348
  }
22298
- function gy(e, t) {
22299
- return e.filter((e) => hy(e, t));
22349
+ function vy(e, t) {
22350
+ return e.filter((e) => _y(e, t));
22300
22351
  }
22301
22352
  //#endregion
22302
22353
  //#region src/components/DataUploader/utils/raggedRows/computeDisputeSpans.ts
22303
- function _y(e) {
22354
+ function yy(e) {
22304
22355
  if (e.length <= 1) return [];
22305
22356
  let t = e[0].cells.length, n = [], r = -1;
22306
22357
  for (let i = 0; i < t; i++) {
@@ -22317,25 +22368,25 @@ function _y(e) {
22317
22368
  }
22318
22369
  //#endregion
22319
22370
  //#region src/components/DataUploader/utils/raggedRows/alignRow.ts
22320
- function vy(e, t, n) {
22321
- let r = ly(e, t.length, n), i = gy(r, t);
22371
+ function by(e, t, n) {
22372
+ let r = dy(e, t.length, n), i = vy(r, t);
22322
22373
  return i.length === 1 ? {
22323
22374
  kind: "confident",
22324
22375
  alignment: i[0]
22325
22376
  } : i.length > 1 ? {
22326
22377
  kind: "ambiguous",
22327
22378
  candidates: i,
22328
- disputeSpans: _y(i)
22379
+ disputeSpans: yy(i)
22329
22380
  } : {
22330
22381
  kind: "invalid",
22331
22382
  candidates: r,
22332
- disputeSpans: _y(r)
22383
+ disputeSpans: yy(r)
22333
22384
  };
22334
22385
  }
22335
22386
  //#endregion
22336
22387
  //#region src/components/DataUploader/utils/raggedRows/resolveRaggedRow.ts
22337
- function yy(e, t, n) {
22338
- let r = vy(e, t, n);
22388
+ function xy(e, t, n) {
22389
+ let r = by(e, t, n);
22339
22390
  if (r.kind === "confident") return {
22340
22391
  cells: r.alignment.cells,
22341
22392
  conflictColumns: []
@@ -22354,13 +22405,13 @@ function yy(e, t, n) {
22354
22405
  }
22355
22406
  //#endregion
22356
22407
  //#region src/components/DataUploader/context/useViewModel.tsx
22357
- var by = 5e3, xy = 15, Sy = 20, Cy = new Set([
22408
+ var Sy = 5e3, Cy = 15, wy = 20, Ty = new Set([
22358
22409
  "xlsx",
22359
22410
  "xls",
22360
22411
  "xlsb",
22361
22412
  "ods"
22362
22413
  ]);
22363
- function wy() {
22414
+ function Ey() {
22364
22415
  let { store: e, validator: t, columns: n, primaryKey: r, setShowUploader: i, pendingImportFile: a, setPendingImportFile: o, onColumnMatch: s, onValueMatch: c, synonyms: l, addDynamicColumns: u, scaleClient: d } = X(), { t: p } = K(), [h, g] = b(0), [_, x] = b(0), [S, w] = b(null), [T, E] = b({}), D = n.filter((e) => e.unique), [O, k] = b(() => r), [A, j] = b(!1), [M, N] = b(!1), [P, F] = b(null), [I, L] = b([]), [R, z] = b(null), [B, V] = b([]), [ee, te] = b({}), [H, ne] = b([]), [re, ie] = b({}), ae = y(null), [oe, se] = b(0), ce = f((e) => {
22365
22416
  M || k(e);
22366
22417
  }, [M]), le = y(null);
@@ -22518,7 +22569,7 @@ function wy() {
22518
22569
  return {
22519
22570
  name: e.name,
22520
22571
  headers: t,
22521
- rows: n.slice(0, xy),
22572
+ rows: n.slice(0, Cy),
22522
22573
  totalRows: e.totalRows - 1
22523
22574
  };
22524
22575
  });
@@ -22552,7 +22603,7 @@ function wy() {
22552
22603
  ]), De = f((e) => {
22553
22604
  j(!0), ae.current = e;
22554
22605
  let t = e.name.split(".").pop()?.toLowerCase();
22555
- t && Cy.has(t) ? Ee(e) : t === "json" ? we(e) : t === "xml" ? Te(e) : Ce(e);
22606
+ t && Ty.has(t) ? Ee(e) : t === "json" ? we(e) : t === "xml" ? Te(e) : Ce(e);
22556
22607
  }, [
22557
22608
  Ce,
22558
22609
  we,
@@ -22618,6 +22669,7 @@ function wy() {
22618
22669
  Ie({});
22619
22670
  return;
22620
22671
  }
22672
+ if (M) return;
22621
22673
  let e = {};
22622
22674
  for (let [t, r] of Object.entries(T)) {
22623
22675
  if (!r) continue;
@@ -22646,7 +22698,8 @@ function wy() {
22646
22698
  T,
22647
22699
  n,
22648
22700
  c,
22649
- l
22701
+ l,
22702
+ M
22650
22703
  ]);
22651
22704
  let Re = v(() => {
22652
22705
  let e = {};
@@ -22715,7 +22768,7 @@ function wy() {
22715
22768
  if (!S || !d?.onRowsImport) return;
22716
22769
  let t = S;
22717
22770
  w(null);
22718
- let r = crypto.randomUUID(), i = He(), a = new AbortController(), o = d.importChunkSize ?? by, s = Yv(T, n, new Set(H.map((e) => e.id))), c = {
22771
+ let r = crypto.randomUUID(), i = He(), a = new AbortController(), o = d.importChunkSize ?? Sy, s = Yv(T, n, new Set(H.map((e) => e.id))), c = {
22719
22772
  numberFormat: i.numberFormat,
22720
22773
  dateFormat: i.dateFormat,
22721
22774
  monthTable: nc(p),
@@ -22760,49 +22813,49 @@ function wy() {
22760
22813
  H.length > 0 && u(H);
22761
22814
  for (let [t, n] of Object.entries(re)) e.addColumnOptions(t, n);
22762
22815
  let o = e.registerSource({ name: i.fileName });
22763
- e.setSourceLoading(o, !0);
22816
+ e.setSourceLoading(o, !0), e.recordLearnedSynonyms(uy(T, Re, [...n, ...H], pv(fv, l)));
22764
22817
  let s = Yv(T, n, a), c = {
22765
22818
  numberFormat: $s(i.rows, Xv(s)),
22766
22819
  dateFormat: ic(i.rows, Ve(a)),
22767
22820
  monthTable: nc(p),
22768
22821
  valueMapping: Re
22769
- }, l = i.rows, d = i.rawCells ?? [], f = i.delimiter ?? ",", m = i.headers, h = m.map((e) => {
22822
+ }, d = i.rows, f = i.rawCells ?? [], m = i.delimiter ?? ",", h = i.headers, g = h.map((e) => {
22770
22823
  let t = T[e];
22771
22824
  return (t ? n.find((e) => e.id === t) : void 0) ?? {
22772
22825
  id: e,
22773
22826
  title: e
22774
22827
  };
22775
- }), g = 0, _ = () => {
22776
- let n = Math.min(g + by, l.length), i = [], a = [];
22777
- for (let e = g; e < n; e++) {
22778
- let t = l[e], n = d[e];
22828
+ }), _ = 0, v = () => {
22829
+ let n = Math.min(_ + Sy, d.length), i = [], a = [];
22830
+ for (let e = _; e < n; e++) {
22831
+ let t = d[e], n = f[e];
22779
22832
  if (n) {
22780
- let { cells: r, conflictColumns: i } = yy(n, h, f);
22833
+ let { cells: r, conflictColumns: i } = xy(n, g, m);
22781
22834
  if (r.length) {
22782
22835
  let e = {};
22783
- for (let t = 0; t < m.length; t++) e[m[t]] = r[t] ?? "";
22836
+ for (let t = 0; t < h.length; t++) e[h[t]] = r[t] ?? "";
22784
22837
  t = e;
22785
22838
  }
22786
22839
  if (i.length) {
22787
22840
  let t = [];
22788
22841
  for (let e of i) {
22789
- let n = T[m[e]];
22842
+ let n = T[h[e]];
22790
22843
  n && t.push(n);
22791
22844
  }
22792
22845
  t.length && a.push({
22793
- localIndex: e - g,
22846
+ localIndex: e - _,
22794
22847
  columnIds: t
22795
22848
  });
22796
22849
  }
22797
22850
  }
22798
22851
  i.push(Zv(t, s, c));
22799
22852
  }
22800
- let { rows: u, rowIds: v } = e.upsertRows(o, i, { anchorKey: O ?? void 0 });
22801
- for (let e = g; e < n; e++) e < Sy || (l[e] = null, e < d.length && (d[e] = null));
22802
- g = n, setTimeout(() => {
22803
- t.validateRows(u, v);
22853
+ let { rows: l, rowIds: u } = e.upsertRows(o, i, { anchorKey: O ?? void 0 });
22854
+ for (let e = _; e < n; e++) e < wy || (d[e] = null, e < f.length && (f[e] = null));
22855
+ _ = n, setTimeout(() => {
22856
+ t.validateRows(l, u);
22804
22857
  for (let { localIndex: t, columnIds: n } of a) {
22805
- let r = v[t];
22858
+ let r = u[t];
22806
22859
  for (let t of n) {
22807
22860
  let n = e.getCellValidation(r, t) ?? [];
22808
22861
  e.setCellValidation(r, t, [...n, {
@@ -22812,11 +22865,11 @@ function wy() {
22812
22865
  }
22813
22866
  }
22814
22867
  a.length > 0 && e.notify();
22815
- }, 0), g < l.length ? setTimeout(_, 0) : e.finalizeSource(o).then(() => {
22868
+ }, 0), _ < d.length ? setTimeout(v, 0) : e.finalizeSource(o).then(() => {
22816
22869
  t.validateUniqueness(), r();
22817
22870
  });
22818
22871
  };
22819
- _();
22872
+ v();
22820
22873
  }, 0);
22821
22874
  }), [
22822
22875
  S,
@@ -22829,6 +22882,7 @@ function wy() {
22829
22882
  n,
22830
22883
  u,
22831
22884
  Re,
22885
+ l,
22832
22886
  Ve,
22833
22887
  p
22834
22888
  ]);
@@ -22894,20 +22948,20 @@ function wy() {
22894
22948
  }
22895
22949
  //#endregion
22896
22950
  //#region src/components/DataUploader/context/index.tsx
22897
- var Ty = s(null);
22898
- function Ey({ children: e }) {
22899
- let t = wy();
22900
- return /* @__PURE__ */ C(Ty.Provider, {
22951
+ var Dy = s(null);
22952
+ function Oy({ children: e }) {
22953
+ let t = Ey();
22954
+ return /* @__PURE__ */ C(Dy.Provider, {
22901
22955
  value: t,
22902
22956
  children: e
22903
22957
  });
22904
22958
  }
22905
- var Dy = () => {
22906
- let e = p(Ty);
22959
+ var ky = () => {
22960
+ let e = p(Dy);
22907
22961
  if (!e) throw Error("useDataUploaderContext must be used within DataUploaderProvider");
22908
22962
  return e;
22909
- }, Oy = () => {
22910
- let { steps: e, activeStepIndex: t, currentStepIndex: n, goToStep: r } = Dy();
22963
+ }, Ay = () => {
22964
+ let { steps: e, activeStepIndex: t, currentStepIndex: n, goToStep: r } = ky();
22911
22965
  return /* @__PURE__ */ C(so, {
22912
22966
  steps: e,
22913
22967
  activeStepIndex: t,
@@ -22915,79 +22969,79 @@ var Dy = () => {
22915
22969
  onStepChange: r,
22916
22970
  isProgressive: !0
22917
22971
  });
22918
- }, ky = () => /* @__PURE__ */ C(Ey, { children: /* @__PURE__ */ C(Oy, {}) }), Ay = {
22972
+ }, jy = () => /* @__PURE__ */ C(Oy, { children: /* @__PURE__ */ C(Ay, {}) }), My = {
22919
22973
  kty: "EC",
22920
22974
  crv: "P-256",
22921
22975
  x: "wZO1Jxr21FEBDsVMzbTbF8blU2CP17c_eQY7gorO13U",
22922
22976
  y: "Nwr-tXatJZ3DxZqpUG_gOWzmpU6szTqrEL7Gnh5UGwo"
22923
- }, jy = "updog_license_grant", My = new Set([
22977
+ }, Ny = "updog_license_grant", Py = new Set([
22924
22978
  "updog.tech",
22925
22979
  "landing.updog.tech",
22926
22980
  "demo.updog.tech"
22927
22981
  ]);
22928
- function Ny() {
22929
- return My.has(window.location.hostname);
22982
+ function Fy() {
22983
+ return Py.has(window.location.hostname);
22930
22984
  }
22931
- function Py() {
22985
+ function Iy() {
22932
22986
  return !1;
22933
22987
  }
22934
- function Fy() {
22988
+ function Ly() {
22935
22989
  return "https://api.updog.tech";
22936
22990
  }
22937
- function Iy(e) {
22991
+ function Ry(e) {
22938
22992
  let t = e.replace(/-/g, "+").replace(/_/g, "/"), n = t + "=".repeat((4 - t.length % 4) % 4), r = atob(n), i = new Uint8Array(r.length);
22939
22993
  for (let e = 0; e < r.length; e++) i[e] = r.charCodeAt(e);
22940
22994
  return i;
22941
22995
  }
22942
- async function Ly(e) {
22996
+ async function zy(e) {
22943
22997
  let t = new TextEncoder().encode(e), n = await crypto.subtle.digest("SHA-256", t);
22944
22998
  return Array.from(new Uint8Array(n)).map((e) => e.toString(16).padStart(2, "0")).join("");
22945
22999
  }
22946
- var Ry = null;
22947
- async function zy() {
22948
- return Ry || (Ry = await crypto.subtle.importKey("jwk", Ay, {
23000
+ var By = null;
23001
+ async function Vy() {
23002
+ return By || (By = await crypto.subtle.importKey("jwk", My, {
22949
23003
  name: "ECDSA",
22950
23004
  namedCurve: "P-256"
22951
- }, !1, ["verify"]), Ry);
23005
+ }, !1, ["verify"]), By);
22952
23006
  }
22953
- function By() {
23007
+ function Hy() {
22954
23008
  try {
22955
- return localStorage.getItem(jy);
23009
+ return localStorage.getItem(Ny);
22956
23010
  } catch {
22957
23011
  return null;
22958
23012
  }
22959
23013
  }
22960
- function Vy(e) {
23014
+ function Uy(e) {
22961
23015
  try {
22962
- localStorage.setItem(jy, e);
23016
+ localStorage.setItem(Ny, e);
22963
23017
  } catch {}
22964
23018
  }
22965
- function Hy() {
23019
+ function Wy() {
22966
23020
  try {
22967
- localStorage.removeItem(jy);
23021
+ localStorage.removeItem(Ny);
22968
23022
  } catch {}
22969
23023
  }
22970
- async function Uy(e, t, n) {
23024
+ async function Gy(e, t, n) {
22971
23025
  let r = e.indexOf(".");
22972
23026
  if (r === -1) return !1;
22973
- let i = e.slice(0, r), a = e.slice(r + 1), o = Iy(i), s = Iy(a), c = await zy();
23027
+ let i = e.slice(0, r), a = e.slice(r + 1), o = Ry(i), s = Ry(a), c = await Vy();
22974
23028
  if (!await crypto.subtle.verify({
22975
23029
  name: "ECDSA",
22976
23030
  hash: "SHA-256"
22977
23031
  }, c, new Uint8Array(s), new Uint8Array(o))) return !1;
22978
23032
  let l = JSON.parse(new TextDecoder().decode(o));
22979
23033
  if (l.exp <= Math.floor(Date.now() / 1e3)) return !1;
22980
- let u = await Ly(t);
23034
+ let u = await zy(t);
22981
23035
  return !(l.key !== u || l.domain !== n);
22982
23036
  }
22983
- async function Wy(e) {
22984
- let t = By();
23037
+ async function Ky(e) {
23038
+ let t = Hy();
22985
23039
  if (!t) return {
22986
23040
  valid: !1,
22987
23041
  errorCode: "license.invalid"
22988
23042
  };
22989
23043
  try {
22990
- if (await Uy(t, e, window.location.hostname.toLowerCase().trim())) return {
23044
+ if (await Gy(t, e, window.location.hostname.toLowerCase().trim())) return {
22991
23045
  valid: !0,
22992
23046
  errorCode: null
22993
23047
  };
@@ -22997,23 +23051,23 @@ async function Wy(e) {
22997
23051
  errorCode: "license.invalid"
22998
23052
  };
22999
23053
  }
23000
- async function Gy(e, t = !0) {
23001
- if (Ny() || Py()) return {
23054
+ async function qy(e, t = !0) {
23055
+ if (Fy() || Iy()) return {
23002
23056
  valid: !0,
23003
23057
  errorCode: null
23004
23058
  };
23005
- let n = Fy();
23059
+ let n = Ly();
23006
23060
  try {
23007
23061
  let r = await fetch(`${n}/v1/validate`, { headers: { "X-API-Key": e } });
23008
23062
  if (r.ok) {
23009
23063
  let e = await r.json();
23010
- return t && e.grant && Vy(e.grant), {
23064
+ return t && e.grant && Uy(e.grant), {
23011
23065
  valid: !0,
23012
23066
  errorCode: null
23013
23067
  };
23014
23068
  }
23015
23069
  if (r.status >= 400 && r.status < 500) {
23016
- t && Hy();
23070
+ t && Wy();
23017
23071
  try {
23018
23072
  return await r.json();
23019
23073
  } catch {
@@ -23025,7 +23079,7 @@ async function Gy(e, t = !0) {
23025
23079
  }
23026
23080
  throw Error(`Server error: ${r.status}`);
23027
23081
  } catch {
23028
- return t ? Wy(e) : {
23082
+ return t ? Ky(e) : {
23029
23083
  valid: !1,
23030
23084
  errorCode: "license.invalid"
23031
23085
  };
@@ -23033,7 +23087,7 @@ async function Gy(e, t = !0) {
23033
23087
  }
23034
23088
  //#endregion
23035
23089
  //#region src/hooks/useLicenseValidation.ts
23036
- function Ky(e, t, n = !0) {
23090
+ function Jy(e, t, n = !0) {
23037
23091
  let [r, i] = b({
23038
23092
  isValidating: t,
23039
23093
  isValid: !1,
@@ -23053,7 +23107,7 @@ function Ky(e, t, n = !0) {
23053
23107
  isValidating: !0,
23054
23108
  isValid: !1,
23055
23109
  errorCode: null
23056
- }), Gy(e, n).then((e) => {
23110
+ }), qy(e, n).then((e) => {
23057
23111
  r || i({
23058
23112
  isValidating: !1,
23059
23113
  isValid: e.valid,
@@ -23076,7 +23130,7 @@ function Ky(e, t, n = !0) {
23076
23130
  }
23077
23131
  //#endregion
23078
23132
  //#region src/server/auth/AuthState.ts
23079
- var qy = class {
23133
+ var Yy = class {
23080
23134
  token = null;
23081
23135
  get() {
23082
23136
  return this.token;
@@ -23087,13 +23141,13 @@ var qy = class {
23087
23141
  clear() {
23088
23142
  this.token = null;
23089
23143
  }
23090
- }, Jy = class extends Error {
23144
+ }, Xy = class extends Error {
23091
23145
  status;
23092
23146
  code;
23093
23147
  constructor(e) {
23094
23148
  super(e.message), this.name = "ScaleHttpError", this.status = e.status, this.code = e.code;
23095
23149
  }
23096
- }, Yy = class {
23150
+ }, Zy = class {
23097
23151
  baseUrl;
23098
23152
  apiKey;
23099
23153
  auth;
@@ -23123,7 +23177,7 @@ var qy = class {
23123
23177
  signal: r?.signal
23124
23178
  });
23125
23179
  } catch (e) {
23126
- this.notify(new Jy({
23180
+ this.notify(new Xy({
23127
23181
  status: 0,
23128
23182
  code: "network",
23129
23183
  message: e instanceof Error ? e.message : String(e)
@@ -23134,7 +23188,7 @@ var qy = class {
23134
23188
  try {
23135
23189
  e = await s.json();
23136
23190
  } catch {}
23137
- this.notify(new Jy({
23191
+ this.notify(new Xy({
23138
23192
  status: s.status,
23139
23193
  code: e.error ?? `http_${s.status}`,
23140
23194
  message: e.message ?? s.statusText
@@ -23145,23 +23199,23 @@ var qy = class {
23145
23199
  };
23146
23200
  //#endregion
23147
23201
  //#region src/server/endpoints/workspaces.ts
23148
- async function Xy(e, t) {
23202
+ async function Qy(e, t) {
23149
23203
  return e.post("/workspaces", {
23150
23204
  primaryKey: t.primaryKey,
23151
23205
  columns: t.columns
23152
23206
  }, { signal: t.signal });
23153
23207
  }
23154
- async function Zy(e) {
23208
+ async function $y(e) {
23155
23209
  try {
23156
23210
  await e.http.delete(`/workspaces/${e.workspaceId}`, { signal: e.signal });
23157
23211
  } catch (e) {
23158
- if (e instanceof Jy && e.status === 404) return;
23212
+ if (e instanceof Xy && e.status === 404) return;
23159
23213
  throw e;
23160
23214
  }
23161
23215
  }
23162
23216
  //#endregion
23163
23217
  //#region src/server/endpoints/query.ts
23164
- async function Qy(e, t) {
23218
+ async function eb(e, t) {
23165
23219
  let n = await e.http.post(`/workspaces/${e.workspaceId}/query`, {
23166
23220
  page: {
23167
23221
  limit: t.limit,
@@ -23179,12 +23233,12 @@ async function Qy(e, t) {
23179
23233
  }
23180
23234
  //#endregion
23181
23235
  //#region src/server/ScaleClient.ts
23182
- var $y = class {
23236
+ var tb = class {
23183
23237
  disposed = !1;
23184
23238
  constructor(e) {
23185
23239
  this.deps = e;
23186
23240
  }
23187
- onQuery = (e) => Qy(this.deps, e);
23241
+ onQuery = (e) => eb(this.deps, e);
23188
23242
  onEdit = async (e) => ({
23189
23243
  rejected: !0,
23190
23244
  reason: "Edits are not yet supported in server mode (v0)."
@@ -23201,7 +23255,7 @@ var $y = class {
23201
23255
  pageSize = void 0;
23202
23256
  scrollSensitivity = void 0;
23203
23257
  dispose = async () => {
23204
- this.disposed || (this.disposed = !0, await Zy({
23258
+ this.disposed || (this.disposed = !0, await $y({
23205
23259
  http: this.deps.http,
23206
23260
  workspaceId: this.deps.workspaceId
23207
23261
  }));
@@ -23209,25 +23263,25 @@ var $y = class {
23209
23263
  };
23210
23264
  //#endregion
23211
23265
  //#region src/server/createScaleClient.ts
23212
- async function eb(e) {
23213
- let t = new qy(), n = new Yy({
23266
+ async function nb(e) {
23267
+ let t = new Yy(), n = new Zy({
23214
23268
  baseUrl: e.url,
23215
23269
  apiKey: e.apiKey,
23216
23270
  auth: t,
23217
23271
  onDegraded: e.onDegraded
23218
- }), { workspaceId: r, accessToken: i } = await Xy(n, {
23272
+ }), { workspaceId: r, accessToken: i } = await Qy(n, {
23219
23273
  primaryKey: e.primaryKey,
23220
23274
  columns: e.columns,
23221
23275
  signal: e.signal
23222
23276
  });
23223
- return t.set(i), new $y({
23277
+ return t.set(i), new tb({
23224
23278
  workspaceId: r,
23225
23279
  http: n
23226
23280
  });
23227
23281
  }
23228
23282
  //#endregion
23229
23283
  //#region src/server/errors.ts
23230
- function tb(e, t, n) {
23284
+ function rb(e, t, n) {
23231
23285
  return {
23232
23286
  code: e,
23233
23287
  message: t,
@@ -23237,7 +23291,7 @@ function tb(e, t, n) {
23237
23291
  }
23238
23292
  //#endregion
23239
23293
  //#region src/hooks/useScaleClient.ts
23240
- function nb(e) {
23294
+ function ib(e) {
23241
23295
  let [t, n] = b({ status: "idle" }), r = y(e.columns), i = y(e.primaryKey);
23242
23296
  return m(() => {
23243
23297
  if (!e.enabled) {
@@ -23246,7 +23300,7 @@ function nb(e) {
23246
23300
  }
23247
23301
  n({ status: "bootstrapping" });
23248
23302
  let t = new AbortController(), a = null;
23249
- return eb({
23303
+ return nb({
23250
23304
  url: e.url,
23251
23305
  apiKey: e.apiKey,
23252
23306
  primaryKey: i.current,
@@ -23255,7 +23309,7 @@ function nb(e) {
23255
23309
  onDegraded: (e) => {
23256
23310
  t.signal.aborted || n({
23257
23311
  status: "failed",
23258
- error: ib(e)
23312
+ error: ob(e)
23259
23313
  });
23260
23314
  }
23261
23315
  }).then((e) => {
@@ -23270,7 +23324,7 @@ function nb(e) {
23270
23324
  }).catch((e) => {
23271
23325
  t.signal.aborted || n({
23272
23326
  status: "failed",
23273
- error: rb(e)
23327
+ error: ab(e)
23274
23328
  });
23275
23329
  }), () => {
23276
23330
  t.abort(), a?.dispose().catch(() => {});
@@ -23281,30 +23335,30 @@ function nb(e) {
23281
23335
  e.apiKey
23282
23336
  ]), t;
23283
23337
  }
23284
- function rb(e) {
23285
- return e instanceof Jy ? e.status === 401 ? tb(e.code.startsWith("license.") ? e.code : "license.invalid", e.message, e) : e.status === 0 ? tb("scale.unreachable", e.message, e) : e.status >= 500 ? tb("scale.server_error", e.message, e) : tb("scale.bootstrap_failed", e.message, e) : tb("scale.bootstrap_failed", e instanceof Error ? e.message : String(e), e);
23338
+ function ab(e) {
23339
+ return e instanceof Xy ? e.status === 401 ? rb(e.code.startsWith("license.") ? e.code : "license.invalid", e.message, e) : e.status === 0 ? rb("scale.unreachable", e.message, e) : e.status >= 500 ? rb("scale.server_error", e.message, e) : rb("scale.bootstrap_failed", e.message, e) : rb("scale.bootstrap_failed", e instanceof Error ? e.message : String(e), e);
23286
23340
  }
23287
- function ib(e) {
23288
- return e.status === 0 ? tb("scale.unreachable", e.message, e) : e.status === 404 ? tb("scale.workspace_lost", e.message, e) : tb("scale.server_error", e.message, e);
23341
+ function ob(e) {
23342
+ return e.status === 0 ? rb("scale.unreachable", e.message, e) : e.status === 404 ? rb("scale.workspace_lost", e.message, e) : rb("scale.server_error", e.message, e);
23289
23343
  }
23290
23344
  //#endregion
23291
23345
  //#region src/index.tsx
23292
- function ab(e) {
23346
+ function sb(e) {
23293
23347
  return e === !1 ? { licenseGrant: !1 } : { licenseGrant: e?.licenseGrant ?? !0 };
23294
23348
  }
23295
- function ob(e) {
23349
+ function cb(e) {
23296
23350
  let t = v(() => new zo(e.onError), [e.onError]);
23297
23351
  return /* @__PURE__ */ C(uv, {
23298
23352
  errorHandler: t,
23299
23353
  children: /* @__PURE__ */ C(Hl, {
23300
23354
  ...e,
23301
23355
  errorHandler: t,
23302
- children: e.showUploader ? /* @__PURE__ */ C(ky, {}) : /* @__PURE__ */ C(ov, {})
23356
+ children: e.showUploader ? /* @__PURE__ */ C(jy, {}) : /* @__PURE__ */ C(ov, {})
23303
23357
  })
23304
23358
  });
23305
23359
  }
23306
- function sb(e) {
23307
- let t = e.mode ?? "modal", { t: n, rtl: r } = K(), i = r ? "rtl" : "ltr", a = ab(e.localStorage), o = t === "modal" ? e.open : !0, { isValidating: s, isValid: c, errorCode: l } = Ky(e.apiKey, t === "modal" ? o : !0, a.licenseGrant), u = e.__server != null, d = nb({
23360
+ function lb(e) {
23361
+ let t = e.mode ?? "modal", { t: n, rtl: r } = K(), i = r ? "rtl" : "ltr", a = sb(e.localStorage), o = t === "modal" ? e.open : !0, { isValidating: s, isValid: c, errorCode: l } = Jy(e.apiKey, t === "modal" ? o : !0, a.licenseGrant), u = e.__server != null, d = ib({
23308
23362
  enabled: !s && c && u,
23309
23363
  url: e.__server?.url ?? "",
23310
23364
  apiKey: e.apiKey,
@@ -23317,7 +23371,7 @@ function sb(e) {
23317
23371
  v,
23318
23372
  T,
23319
23373
  e.readonly
23320
- ]), D = f(() => T?.(), [T]), O = n(p ? "dataEditor.modal.importTitle" : "dataEditor.modal.editTitle");
23374
+ ]), D = f(() => T?.(), [T]), O = p ? n("dataEditor.modal.importTitle") : e.variant === "viewer" ? n("dataEditor.modal.viewTitle") : n("dataEditor.modal.editTitle");
23321
23375
  m(() => {
23322
23376
  t === "modal" && !o && h(e.variant === "uploader");
23323
23377
  }, [
@@ -23359,7 +23413,7 @@ function sb(e) {
23359
23413
  code: e,
23360
23414
  message: "License validation failed",
23361
23415
  source: "license"
23362
- } }), M = () => s ? A(n("dataEditor.license.loading")) : c ? u && d.status === "bootstrapping" ? A(n("dataEditor.connecting.label")) : u && d.status === "failed" ? /* @__PURE__ */ C(cv, { error: d.error }) : /* @__PURE__ */ C(ob, { ...k }) : j(l ?? "license.invalid");
23416
+ } }), M = () => s ? A(n("dataEditor.license.loading")) : c ? u && d.status === "bootstrapping" ? A(n("dataEditor.connecting.label")) : u && d.status === "failed" ? /* @__PURE__ */ C(cv, { error: d.error }) : /* @__PURE__ */ C(cb, { ...k }) : j(l ?? "license.invalid");
23363
23417
  return t === "inline" ? /* @__PURE__ */ C("div", {
23364
23418
  className: "updog__data-editor updog__data-editor-inline",
23365
23419
  dir: i,
@@ -23379,14 +23433,14 @@ function sb(e) {
23379
23433
  submitText: n("dataEditor.confirmClose.action")
23380
23434
  })] });
23381
23435
  }
23382
- function cb(e) {
23436
+ function ub(e) {
23383
23437
  let { translations: t, rtl: n = !1, locale: r = "en", className: i, ...a } = e;
23384
23438
  return /* @__PURE__ */ C(Xr, {
23385
23439
  translations: t,
23386
23440
  rtl: n,
23387
23441
  locale: r,
23388
- children: /* @__PURE__ */ C(sb, { ...a })
23442
+ children: /* @__PURE__ */ C(lb, { ...a })
23389
23443
  });
23390
23444
  }
23391
23445
  //#endregion
23392
- export { cb as DataEditor, iu as downloadExampleFile, au as exportDataEditor };
23446
+ export { ub as DataEditor, iu as downloadExampleFile, au as exportDataEditor };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@updog/data-editor",
3
- "version": "0.1.45",
3
+ "version": "0.1.47",
4
4
  "description": "Client-side CSV importer and spreadsheet editor for React. Import CSV, Excel, JSON, TSV, and XML, match columns, validate, and edit 1M+ rows entirely in the browser.",
5
5
  "author": "Mikhail Kutateladze <admin@updog.tech>",
6
6
  "homepage": "https://updog.tech",