@updog/data-editor-wc 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 +18 -1
  2. package/index.js +219 -165
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -109,6 +109,7 @@ declare var export_default = {
109
109
  modal: {
110
110
  importTitle: "Import Data",
111
111
  editTitle: "Edit Data",
112
+ viewTitle: "View Data",
112
113
  },
113
114
  confirmClose: {
114
115
  title: "Discard changes?",
@@ -1030,6 +1031,16 @@ type DataEditorSourceResult<TRow extends DataEditorRow = DataEditorRow> = {
1030
1031
  * }}
1031
1032
  * ```
1032
1033
  */
1034
+ /** A user-confirmed import mapping: `source` (imported) → `target` (canonical). */
1035
+ type LearnedSynonym = {
1036
+ source: string;
1037
+ target: string;
1038
+ };
1039
+ /** User-confirmed import mappings, split by where they were matched. */
1040
+ type LearnedSynonyms = {
1041
+ columns: LearnedSynonym[];
1042
+ values: LearnedSynonym[];
1043
+ };
1033
1044
  type DataEditorResult<TRow extends DataEditorRow = DataEditorRow> = {
1034
1045
  sources: DataEditorSourceResult<TRow>[];
1035
1046
  counts: {
@@ -1038,6 +1049,12 @@ type DataEditorResult<TRow extends DataEditorRow = DataEditorRow> = {
1038
1049
  deleted: number;
1039
1050
  invalid: number;
1040
1051
  };
1052
+ /**
1053
+ * Import mappings the user confirmed that weren't already known, split into
1054
+ * `columns` and `values`. Persist and feed back through `synonyms` so repeat
1055
+ * imports auto-match. Each list is `[]` when nothing new was learned.
1056
+ */
1057
+ learnedSynonyms: LearnedSynonyms;
1041
1058
  };
1042
1059
  /**
1043
1060
  * Describes the change state of a single row within a chunk, used to seed
@@ -1148,7 +1165,7 @@ type RemoteSource = {
1148
1165
  * - `"editor"` — opens directly into the spreadsheet grid.
1149
1166
  * - `"uploader"` — opens the file import wizard first, then transitions to the grid.
1150
1167
  */
1151
- type DataEditorVariant = "editor" | "uploader";
1168
+ type DataEditorVariant = "editor" | "uploader" | "viewer";
1152
1169
  /** Base configuration shared by the public `DataEditorProps` and the internal provider. */
1153
1170
  type DataEditorBaseProps<TRow extends DataEditorRow = DataEditorRow> = {
1154
1171
  /** Column definitions. Each entry describes one column in the grid. */
package/index.js CHANGED
@@ -8097,7 +8097,8 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
8097
8097
  dataEditor: {
8098
8098
  modal: {
8099
8099
  importTitle: "Import Data",
8100
- editTitle: "Edit Data"
8100
+ editTitle: "Edit Data",
8101
+ viewTitle: "View Data"
8101
8102
  },
8102
8103
  confirmClose: {
8103
8104
  title: "Discard changes?",
@@ -27617,7 +27618,10 @@ var dm = (e) => {
27617
27618
  t && this.serverCounts?.setCounts(t), this.snapshotManager.markCountsDirty(), this.notify();
27618
27619
  }
27619
27620
  clear() {
27620
- 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();
27621
+ 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 = {
27622
+ columns: [],
27623
+ values: []
27624
+ }, this.learnedSynonymKeys.columns.clear(), this.learnedSynonymKeys.values.clear(), this.notify();
27621
27625
  }
27622
27626
  destroy() {
27623
27627
  this.filterEngine.destroy(), this.server?.destroy(), this.transformWorker?.terminate(), this.transformWorker = null, this.clear(), this.serverCounts?.clear(), this.clearViewportRange(), this.snapshotManager.clearListeners();
@@ -27852,6 +27856,20 @@ var dm = (e) => {
27852
27856
  }
27853
27857
  return e;
27854
27858
  }
27859
+ learnedSynonyms = {
27860
+ columns: [],
27861
+ values: []
27862
+ };
27863
+ learnedSynonymKeys = {
27864
+ columns: /* @__PURE__ */ new Set(),
27865
+ values: /* @__PURE__ */ new Set()
27866
+ };
27867
+ recordLearnedSynonyms(e) {
27868
+ for (let t of ["columns", "values"]) for (let n of e[t]) {
27869
+ let e = `${n.source} ${n.target}`;
27870
+ this.learnedSynonymKeys[t].has(e) || (this.learnedSynonymKeys[t].add(e), this.learnedSynonyms[t].push(n));
27871
+ }
27872
+ }
27855
27873
  getResultBySource() {
27856
27874
  let e = /* @__PURE__ */ new Map();
27857
27875
  for (let t of this.sourceManager.values()) e.set(t.id, {
@@ -27894,7 +27912,8 @@ var dm = (e) => {
27894
27912
  }
27895
27913
  return {
27896
27914
  sources: Array.from(e.values()),
27897
- counts: t
27915
+ counts: t,
27916
+ learnedSynonyms: this.learnedSynonyms
27898
27917
  };
27899
27918
  }
27900
27919
  isRowVisible(e) {
@@ -29868,6 +29887,7 @@ function Xm({ columns: e, primaryKey: t, loadData: n, scaleClient: r, onComplete
29868
29887
  setPendingImportFile: ve,
29869
29888
  openUploaderWithFile: ye,
29870
29889
  variant: a ?? "editor",
29890
+ isViewer: a === "viewer",
29871
29891
  search: ne,
29872
29892
  setSearch: re,
29873
29893
  matchCase: ie,
@@ -29883,7 +29903,7 @@ function Xm({ columns: e, primaryKey: t, loadData: n, scaleClient: r, onComplete
29883
29903
  resetScrollRef: z,
29884
29904
  scrollToGridTop: B,
29885
29905
  portalRef: me,
29886
- readonly: _ ?? !1,
29906
+ readonly: a === "viewer" ? !0 : _ ?? !1,
29887
29907
  filtersResetKey: de,
29888
29908
  resetFilters: fe,
29889
29909
  originalColumns: e,
@@ -31766,7 +31786,7 @@ var kg = 9, Ag = 3, jg = [3, 2], Mg = 1, Ng = 6, Pg = .8, Fg = .5, Ig = 4, Lg =
31766
31786
  paintHeaderCell(e, t, n) {
31767
31787
  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);
31768
31788
  u.isColumnSelected(t) ? (r.fillStyle = i.headerBgSelected, ag(r, h, 0, m, 36)) : u.isColumnHighlighted(t) && (r.fillStyle = i.headerBgActive, ag(r, h, 0, m, 36));
31769
- let g = s[t], _ = t < d, v = l?.columnId === g.id, y = e.store.isColumnLocked(g.id), b = 0;
31789
+ let g = s[t], _ = t < d, v = l?.columnId === g.id, y = !c.readonly && e.store.isColumnLocked(g.id), b = 0;
31770
31790
  y && b++, _ && b++, v && b++;
31771
31791
  let x = b > 0 ? b * 14 + (b - 1) * Ng + Ng : 0, S = m - kg * 2 - x;
31772
31792
  r.font = i.headerFont, r.fillStyle = i.headerContentIdle;
@@ -45475,39 +45495,39 @@ var sj = ({ text: e, onSelect: t }) => /* @__PURE__ */ (0, O.jsx)(at, {
45475
45495
  /* @__PURE__ */ (0, O.jsx)(pj, {})
45476
45496
  ]
45477
45497
  }) }), gj = () => {
45478
- let { store: e, columns: t, chat: n, enableAddRow: r, readonly: i, navigateToCell: a, importFormats: o, openUploaderWithFile: s } = $m(), { rowCount: c, filteredCount: l, isLoading: u } = ed(e), { t: d } = j(), f = !u && l === 0, p = r && !i && c === 0, m = o !== !1 && o.length > 0, h = (0, y.useCallback)(async () => {
45479
- a(await sh(e, t, d("dataEditor.dataSources.manuallyAdded")), t[0].id);
45498
+ let { store: e, columns: t, chat: n, enableAddRow: r, readonly: i, isViewer: a, navigateToCell: o, importFormats: s, openUploaderWithFile: c } = $m(), { rowCount: l, filteredCount: u, isLoading: d } = ed(e), { t: f } = j(), p = !d && u === 0, m = r && !i && l === 0, h = s !== !1 && s.length > 0, g = (0, y.useCallback)(async () => {
45499
+ o(await sh(e, t, f("dataEditor.dataSources.manuallyAdded")), t[0].id);
45480
45500
  }, [
45481
45501
  e,
45482
45502
  t,
45483
- a,
45484
- d
45485
- ]), g = (0, y.useMemo)(() => {
45486
- if (p) return {
45487
- content: d("dataEditor.dataSources.addRow"),
45503
+ o,
45504
+ f
45505
+ ]), _ = (0, y.useMemo)(() => {
45506
+ if (m) return {
45507
+ content: f("dataEditor.dataSources.addRow"),
45488
45508
  startIcon: /* @__PURE__ */ (0, O.jsx)(Ae, { size: "1rem" }),
45489
45509
  variant: "filled",
45490
- onClick: h
45510
+ onClick: g
45491
45511
  };
45492
45512
  }, [
45493
- p,
45494
- h,
45495
- d
45496
- ]), _ = (0, y.useMemo)(() => th(o === !1 ? [] : o), [o]), v = (0, y.useCallback)((e) => {
45513
+ m,
45514
+ g,
45515
+ f
45516
+ ]), v = (0, y.useMemo)(() => th(s === !1 ? [] : s), [s]), b = (0, y.useCallback)((e) => {
45497
45517
  let t = e[0];
45498
- t && s(t);
45499
- }, [s]), { getRootProps: b, isDragActive: x } = Xu({
45500
- accept: _,
45518
+ t && c(t);
45519
+ }, [c]), { getRootProps: x, isDragActive: S } = Xu({
45520
+ accept: v,
45501
45521
  maxFiles: 1,
45502
45522
  noClick: !0,
45503
45523
  noKeyboard: !0,
45504
- disabled: i || !m,
45505
- onDrop: v
45524
+ disabled: i || !h,
45525
+ onDrop: b
45506
45526
  });
45507
45527
  return /* @__PURE__ */ (0, O.jsx)(ah, { children: /* @__PURE__ */ (0, O.jsxs)("div", {
45508
- ...b({ className: "updog__data-editor-inner" }),
45528
+ ...x({ className: "updog__data-editor-inner" }),
45509
45529
  children: [
45510
- /* @__PURE__ */ (0, O.jsx)(nh, { children: /* @__PURE__ */ (0, O.jsx)("div", {
45530
+ !a && /* @__PURE__ */ (0, O.jsx)(nh, { children: /* @__PURE__ */ (0, O.jsx)("div", {
45511
45531
  className: "updog__data-editor-aside",
45512
45532
  children: /* @__PURE__ */ (0, O.jsxs)("div", {
45513
45533
  className: "updog__data-editor-aside__content updog__scrollbar",
@@ -45521,18 +45541,18 @@ var sj = ({ text: e, onSelect: t }) => /* @__PURE__ */ (0, O.jsx)(at, {
45521
45541
  /* @__PURE__ */ (0, O.jsxs)(rh, { children: [
45522
45542
  /* @__PURE__ */ (0, O.jsxs)("div", {
45523
45543
  className: "updog__data-editor-grid-area",
45524
- children: [/* @__PURE__ */ (0, O.jsx)(TA, {}), f && /* @__PURE__ */ (0, O.jsx)(ac, {
45544
+ children: [/* @__PURE__ */ (0, O.jsx)(TA, {}), p && /* @__PURE__ */ (0, O.jsx)(ac, {
45525
45545
  className: "updog-grid__empty-state",
45526
- title: d("dataEditor.grid.emptyTitle"),
45527
- text: d("dataEditor.grid.emptyText"),
45528
- buttonProps: g
45546
+ title: f("dataEditor.grid.emptyTitle"),
45547
+ text: f("dataEditor.grid.emptyText"),
45548
+ buttonProps: _
45529
45549
  })]
45530
45550
  }),
45531
45551
  /* @__PURE__ */ (0, O.jsx)(oh, {}),
45532
- /* @__PURE__ */ (0, O.jsx)(Yh, {})
45552
+ !a && /* @__PURE__ */ (0, O.jsx)(Yh, {})
45533
45553
  ] }),
45534
- x && /* @__PURE__ */ (0, O.jsx)(ih, {}),
45535
- n && /* @__PURE__ */ (0, O.jsx)(hj, {})
45554
+ S && /* @__PURE__ */ (0, O.jsx)(ih, {}),
45555
+ n && !a && /* @__PURE__ */ (0, O.jsx)(hj, {})
45536
45556
  ]
45537
45557
  }) });
45538
45558
  }, _j = "RENDER_ERROR", vj = (e) => {
@@ -45569,7 +45589,7 @@ var sj = ({ text: e, onSelect: t }) => /* @__PURE__ */ (0, O.jsx)(at, {
45569
45589
  return this.state.hasError ? /* @__PURE__ */ (0, O.jsx)(vj, { error: yj }) : this.props.children;
45570
45590
  }
45571
45591
  }, xj = ({ leftSlot: e }) => {
45572
- let { variant: t, setShowUploader: n } = $m(), { t: r } = j(), { isFirstStep: i, isLastStep: a, nextStep: o, prevStep: s, onImport: c, parsedCsv: l, xlsxFile: u, isParsing: d, isImporting: f, steps: p, activeStepIndex: m, selectedSheet: h, handleSheetConfirmed: g, remoteSourceLoading: _ } = LM(), v = i && t === "editor", b = (0, y.useCallback)(() => {
45592
+ let { variant: t, setShowUploader: n } = $m(), { t: r } = j(), { isFirstStep: i, isLastStep: a, nextStep: o, prevStep: s, onImport: c, parsedCsv: l, xlsxFile: u, isParsing: d, isImporting: f, steps: p, activeStepIndex: m, selectedSheet: h, handleSheetConfirmed: g, remoteSourceLoading: _ } = zM(), v = i && t === "editor", b = (0, y.useCallback)(() => {
45573
45593
  n(!1);
45574
45594
  }, [n]), x = p[m]?.id === "sheet-selection", S = (0, y.useCallback)(() => {
45575
45595
  a ? c() : x ? g() : o();
@@ -46397,7 +46417,7 @@ var sj = ({ text: e, onSelect: t }) => /* @__PURE__ */ (0, O.jsx)(at, {
46397
46417
  ]
46398
46418
  });
46399
46419
  }), Wj = () => {
46400
- let { columns: e, enableCreateColumn: t, synonyms: n } = $m(), { t: r } = j(), { parsedCsv: i, columnMapping: a, updateColumnMapping: o, pendingColumns: s, setPendingColumns: c } = LM(), [l, u] = (0, y.useState)(null), d = (0, y.useRef)(null), f = (0, y.useCallback)((e, t) => {
46420
+ let { columns: e, enableCreateColumn: t, synonyms: n } = $m(), { t: r } = j(), { parsedCsv: i, columnMapping: a, updateColumnMapping: o, pendingColumns: s, setPendingColumns: c } = zM(), [l, u] = (0, y.useState)(null), d = (0, y.useRef)(null), f = (0, y.useCallback)((e, t) => {
46401
46421
  if (t === "action:create") {
46402
46422
  d.current = e, u({ title: e });
46403
46423
  return;
@@ -46510,7 +46530,7 @@ var sj = ({ text: e, onSelect: t }) => /* @__PURE__ */ (0, O.jsx)(at, {
46510
46530
  ]
46511
46531
  });
46512
46532
  }, Gj = () => {
46513
- let { parsedCsv: e } = LM();
46533
+ let { parsedCsv: e } = zM();
46514
46534
  return e ? /* @__PURE__ */ (0, O.jsx)(ah, { children: /* @__PURE__ */ (0, O.jsxs)(rh, { children: [/* @__PURE__ */ (0, O.jsx)("div", {
46515
46535
  className: "updog__step-column-matching__content updog__scrollbar",
46516
46536
  children: /* @__PURE__ */ (0, O.jsx)(Wj, {})
@@ -46529,7 +46549,7 @@ var sj = ({ text: e, onSelect: t }) => /* @__PURE__ */ (0, O.jsx)(at, {
46529
46549
  })
46530
46550
  });
46531
46551
  }, qj = () => {
46532
- let { columns: e } = $m(), { t } = j(), { parsedCsv: n, columnMapping: r, valueMapping: i, autoValueMapping: a, updateValueMapping: o, pendingOptions: s, addPendingOption: c } = LM(), [l, u] = (0, y.useState)({}), [d, f] = (0, y.useState)({}), [p, m] = (0, y.useState)(null), h = (0, y.useRef)(!1), g = (0, y.useCallback)((e) => {
46552
+ let { columns: e } = $m(), { t } = j(), { parsedCsv: n, columnMapping: r, valueMapping: i, autoValueMapping: a, updateValueMapping: o, pendingOptions: s, addPendingOption: c } = zM(), [l, u] = (0, y.useState)({}), [d, f] = (0, y.useState)({}), [p, m] = (0, y.useState)(null), h = (0, y.useRef)(!1), g = (0, y.useCallback)((e) => {
46533
46553
  f((t) => ({
46534
46554
  ...t,
46535
46555
  [e]: !t[e]
@@ -46765,7 +46785,7 @@ var sj = ({ text: e, onSelect: t }) => /* @__PURE__ */ (0, O.jsx)(at, {
46765
46785
  className: "updog__step-match-values__content updog__scrollbar",
46766
46786
  children: /* @__PURE__ */ (0, O.jsx)(qj, {})
46767
46787
  }), /* @__PURE__ */ (0, O.jsx)(xj, {})] }) }), Yj = 20, Xj = () => {
46768
- let { columns: e, store: t } = $m(), { t: n } = j(), { primaryKey: r, onPrimaryKeyChange: i, parsedCsv: a, columnMapping: o } = LM(), s = t.isClient(), c = (0, y.useCallback)(() => i(null), [i]), l = e.filter((e) => e.unique), u = (0, y.useMemo)(() => {
46788
+ let { columns: e, store: t } = $m(), { t: n } = j(), { primaryKey: r, onPrimaryKeyChange: i, parsedCsv: a, columnMapping: o } = zM(), s = t.isClient(), c = (0, y.useCallback)(() => i(null), [i]), l = e.filter((e) => e.unique), u = (0, y.useMemo)(() => {
46769
46789
  let e = {};
46770
46790
  for (let [t, n] of Object.entries(o)) n && (e[n] = t);
46771
46791
  return e;
@@ -46840,7 +46860,7 @@ var sj = ({ text: e, onSelect: t }) => /* @__PURE__ */ (0, O.jsx)(at, {
46840
46860
  title: e.description,
46841
46861
  children: e.label
46842
46862
  }), eM = () => {
46843
- let { importFormats: e, remoteSources: t } = $m(), n = e === !1 ? [] : e, { t: r } = j(), { remoteSourceLoading: i, remoteSourceError: a, handleRemoteSourceSelect: o } = LM();
46863
+ let { importFormats: e, remoteSources: t } = $m(), n = e === !1 ? [] : e, { t: r } = j(), { remoteSourceLoading: i, remoteSourceError: a, handleRemoteSourceSelect: o } = zM();
46844
46864
  return /* @__PURE__ */ (0, O.jsxs)("div", {
46845
46865
  className: "updog__source-picker",
46846
46866
  children: [
@@ -46895,7 +46915,7 @@ var sj = ({ text: e, onSelect: t }) => /* @__PURE__ */ (0, O.jsx)(at, {
46895
46915
  })]
46896
46916
  });
46897
46917
  }, nM = () => {
46898
- let { columns: e, importFormats: t, sampleData: n } = $m(), r = t === !1 ? [] : t, { t: i } = j(), { parsedCsv: a, xlsxFile: o, handleFileRemoved: s, parseFile: c, isParsing: l, remoteSourceLoading: u } = LM(), d = [
46918
+ let { columns: e, importFormats: t, sampleData: n } = $m(), r = t === !1 ? [] : t, { t: i } = j(), { parsedCsv: a, xlsxFile: o, handleFileRemoved: s, parseFile: c, isParsing: l, remoteSourceLoading: u } = zM(), d = [
46899
46919
  {
46900
46920
  id: "csv",
46901
46921
  format: "csv",
@@ -46985,7 +47005,7 @@ var sj = ({ text: e, onSelect: t }) => /* @__PURE__ */ (0, O.jsx)(at, {
46985
47005
  ]
46986
47006
  }) });
46987
47007
  }, rM = ({ preview: e }) => {
46988
- let { selectedSheet: t, setSelectedSheet: n } = LM(), { t: r } = j(), i = Math.max(0, e.totalRows), a = t === e.name, o = (0, y.useMemo)(() => {
47008
+ let { selectedSheet: t, setSelectedSheet: n } = zM(), { t: r } = j(), i = Math.max(0, e.totalRows), a = t === e.name, o = (0, y.useMemo)(() => {
46989
47009
  let { headers: t, rows: n } = e;
46990
47010
  return n.map((e) => t.map((t) => e[t] ?? ""));
46991
47011
  }, [e]);
@@ -47023,7 +47043,7 @@ var sj = ({ text: e, onSelect: t }) => /* @__PURE__ */ (0, O.jsx)(at, {
47023
47043
  })
47024
47044
  });
47025
47045
  }, iM = () => {
47026
- let { sheetPreviews: e } = LM();
47046
+ let { sheetPreviews: e } = zM();
47027
47047
  return /* @__PURE__ */ (0, O.jsx)(ah, { children: /* @__PURE__ */ (0, O.jsxs)(rh, { children: [/* @__PURE__ */ (0, O.jsx)("div", {
47028
47048
  className: "updog__sheet-preview-wrapper updog__scrollbar",
47029
47049
  children: /* @__PURE__ */ (0, O.jsx)("div", {
@@ -47131,16 +47151,47 @@ function vM(e) {
47131
47151
  rawCells: i
47132
47152
  };
47133
47153
  }
47134
- function yM(e, t, n) {
47154
+ //#endregion
47155
+ //#region src/components/DataUploader/utils/learnedSynonyms.ts
47156
+ var yM = (e) => {
47157
+ let t = /* @__PURE__ */ new Map();
47158
+ for (let [n, r] of Object.entries(e)) {
47159
+ let e = Tj(n), i = t.get(e) ?? /* @__PURE__ */ new Set();
47160
+ for (let e of r) i.add(Tj(e));
47161
+ t.set(e, i);
47162
+ }
47163
+ return t;
47164
+ }, bM = (e, t, n, r) => {
47165
+ let i = yM(r), a = (e, t) => i.get(Tj(e))?.has(Tj(t)) ?? !1, o = new Map(n.map((e) => [e.id, e])), s = (e, t) => (n, r) => {
47166
+ if (Tj(n) === Tj(r) || a(r, n)) return;
47167
+ let i = `${n} ${r}`;
47168
+ t.has(i) || (t.add(i), e.push({
47169
+ source: n,
47170
+ target: r
47171
+ }));
47172
+ }, c = {
47173
+ columns: [],
47174
+ values: []
47175
+ }, l = s(c.columns, /* @__PURE__ */ new Set());
47176
+ for (let [t, n] of Object.entries(e)) {
47177
+ if (!n) continue;
47178
+ let e = o.get(n);
47179
+ e && l(t, e.title);
47180
+ }
47181
+ let u = s(c.values, /* @__PURE__ */ new Set());
47182
+ for (let e of Object.values(t)) for (let [t, n] of Object.entries(e)) n && u(t, n);
47183
+ return c;
47184
+ };
47185
+ function xM(e, t, n) {
47135
47186
  let r = e.length, i = t;
47136
- return i <= 0 ? [] : r === i ? [{ cells: [...e] }] : (r < i ? bM(i, i - r) : bM(r - 1, i - 1)) > 1e3 ? [] : r < i ? xM(e, i) : SM(e, i, n);
47187
+ return i <= 0 ? [] : r === i ? [{ cells: [...e] }] : (r < i ? SM(i, i - r) : SM(r - 1, i - 1)) > 1e3 ? [] : r < i ? CM(e, i) : wM(e, i, n);
47137
47188
  }
47138
- function bM(e, t) {
47189
+ function SM(e, t) {
47139
47190
  let n = Math.min(t, e - t), r = 1;
47140
47191
  for (let t = 1; t <= n; t++) if (r = r * (e - n + t) / t, r > 1e3) return r;
47141
47192
  return r;
47142
47193
  }
47143
- function xM(e, t) {
47194
+ function CM(e, t) {
47144
47195
  let n = e.length, r = [], i = [], a = (o) => {
47145
47196
  if (i.length === n) {
47146
47197
  let a = Array(t).fill("");
@@ -47152,7 +47203,7 @@ function xM(e, t) {
47152
47203
  };
47153
47204
  return a(0), r;
47154
47205
  }
47155
- function SM(e, t, n) {
47206
+ function wM(e, t, n) {
47156
47207
  let r = e.length, i = [], a = [], o = (s) => {
47157
47208
  if (a.length === t - 1) {
47158
47209
  let o = [
@@ -47170,27 +47221,27 @@ function SM(e, t, n) {
47170
47221
  }
47171
47222
  //#endregion
47172
47223
  //#region src/components/DataUploader/utils/raggedRows/pruneByValidators.ts
47173
- var CM = {};
47174
- function wM(e, t) {
47224
+ var TM = {};
47225
+ function EM(e, t) {
47175
47226
  for (let n of t.validators ?? []) if (n.type !== "expression") {
47176
47227
  if (n.type === "function") {
47177
- if (n.fn(e, CM) != null) return !1;
47228
+ if (n.fn(e, TM) != null) return !1;
47178
47229
  continue;
47179
47230
  }
47180
- if (Rm(n, e, CM) != null) return !1;
47231
+ if (Rm(n, e, TM) != null) return !1;
47181
47232
  }
47182
47233
  return !0;
47183
47234
  }
47184
- function TM(e, t) {
47185
- for (let n = 0; n < t.length; n++) if (!wM(e.cells[n] ?? "", t[n])) return !1;
47235
+ function DM(e, t) {
47236
+ for (let n = 0; n < t.length; n++) if (!EM(e.cells[n] ?? "", t[n])) return !1;
47186
47237
  return !0;
47187
47238
  }
47188
- function EM(e, t) {
47189
- return e.filter((e) => TM(e, t));
47239
+ function OM(e, t) {
47240
+ return e.filter((e) => DM(e, t));
47190
47241
  }
47191
47242
  //#endregion
47192
47243
  //#region src/components/DataUploader/utils/raggedRows/computeDisputeSpans.ts
47193
- function DM(e) {
47244
+ function kM(e) {
47194
47245
  if (e.length <= 1) return [];
47195
47246
  let t = e[0].cells.length, n = [], r = -1;
47196
47247
  for (let i = 0; i < t; i++) {
@@ -47207,25 +47258,25 @@ function DM(e) {
47207
47258
  }
47208
47259
  //#endregion
47209
47260
  //#region src/components/DataUploader/utils/raggedRows/alignRow.ts
47210
- function OM(e, t, n) {
47211
- let r = yM(e, t.length, n), i = EM(r, t);
47261
+ function AM(e, t, n) {
47262
+ let r = xM(e, t.length, n), i = OM(r, t);
47212
47263
  return i.length === 1 ? {
47213
47264
  kind: "confident",
47214
47265
  alignment: i[0]
47215
47266
  } : i.length > 1 ? {
47216
47267
  kind: "ambiguous",
47217
47268
  candidates: i,
47218
- disputeSpans: DM(i)
47269
+ disputeSpans: kM(i)
47219
47270
  } : {
47220
47271
  kind: "invalid",
47221
47272
  candidates: r,
47222
- disputeSpans: DM(r)
47273
+ disputeSpans: kM(r)
47223
47274
  };
47224
47275
  }
47225
47276
  //#endregion
47226
47277
  //#region src/components/DataUploader/utils/raggedRows/resolveRaggedRow.ts
47227
- function kM(e, t, n) {
47228
- let r = OM(e, t, n);
47278
+ function jM(e, t, n) {
47279
+ let r = AM(e, t, n);
47229
47280
  if (r.kind === "confident") return {
47230
47281
  cells: r.alignment.cells,
47231
47282
  conflictColumns: []
@@ -47244,13 +47295,13 @@ function kM(e, t, n) {
47244
47295
  }
47245
47296
  //#endregion
47246
47297
  //#region src/components/DataUploader/context/useViewModel.tsx
47247
- var AM = 5e3, jM = 15, MM = 20, NM = new Set([
47298
+ var MM = 5e3, NM = 15, PM = 20, FM = new Set([
47248
47299
  "xlsx",
47249
47300
  "xls",
47250
47301
  "xlsb",
47251
47302
  "ods"
47252
47303
  ]);
47253
- function PM() {
47304
+ function IM() {
47254
47305
  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 } = $m(), { t: f } = j(), [p, m] = (0, y.useState)(0), [h, g] = (0, y.useState)(0), [_, v] = (0, y.useState)(null), [b, x] = (0, y.useState)({}), S = n.filter((e) => e.unique), [C, w] = (0, y.useState)(() => r), [T, E] = (0, y.useState)(!1), [D, k] = (0, y.useState)(!1), [A, M] = (0, y.useState)(null), [N, P] = (0, y.useState)([]), [F, I] = (0, y.useState)(null), [L, R] = (0, y.useState)([]), [ee, z] = (0, y.useState)({}), [B, V] = (0, y.useState)([]), [H, te] = (0, y.useState)({}), ne = (0, y.useRef)(null), [re, ie] = (0, y.useState)(0), ae = (0, y.useCallback)((e) => {
47255
47306
  D || w(e);
47256
47307
  }, [D]), oe = (0, y.useRef)(null);
@@ -47408,7 +47459,7 @@ function PM() {
47408
47459
  return {
47409
47460
  name: e.name,
47410
47461
  headers: t,
47411
- rows: n.slice(0, jM),
47462
+ rows: n.slice(0, NM),
47412
47463
  totalRows: e.totalRows - 1
47413
47464
  };
47414
47465
  });
@@ -47442,7 +47493,7 @@ function PM() {
47442
47493
  ]), Ce = (0, y.useCallback)((e) => {
47443
47494
  E(!0), ne.current = e;
47444
47495
  let t = e.name.split(".").pop()?.toLowerCase();
47445
- t && NM.has(t) ? Se(e) : t === "json" ? be(e) : t === "xml" ? xe(e) : ye(e);
47496
+ t && FM.has(t) ? Se(e) : t === "json" ? be(e) : t === "xml" ? xe(e) : ye(e);
47446
47497
  }, [
47447
47498
  ye,
47448
47499
  be,
@@ -47508,6 +47559,7 @@ function PM() {
47508
47559
  Me({});
47509
47560
  return;
47510
47561
  }
47562
+ if (D) return;
47511
47563
  let e = {};
47512
47564
  for (let [t, r] of Object.entries(b)) {
47513
47565
  if (!r) continue;
@@ -47536,7 +47588,8 @@ function PM() {
47536
47588
  b,
47537
47589
  n,
47538
47590
  c,
47539
- l
47591
+ l,
47592
+ D
47540
47593
  ]);
47541
47594
  let Pe = (0, y.useMemo)(() => {
47542
47595
  let e = {};
@@ -47605,7 +47658,7 @@ function PM() {
47605
47658
  if (!_ || !d?.onRowsImport) return;
47606
47659
  let t = _;
47607
47660
  v(null);
47608
- let r = crypto.randomUUID(), i = Re(), a = new AbortController(), o = d.importChunkSize ?? AM, s = aM(b, n, new Set(B.map((e) => e.id))), c = {
47661
+ let r = crypto.randomUUID(), i = Re(), a = new AbortController(), o = d.importChunkSize ?? MM, s = aM(b, n, new Set(B.map((e) => e.id))), c = {
47609
47662
  numberFormat: i.numberFormat,
47610
47663
  dateFormat: i.dateFormat,
47611
47664
  monthTable: ip(f),
@@ -47650,49 +47703,49 @@ function PM() {
47650
47703
  B.length > 0 && u(B);
47651
47704
  for (let [t, n] of Object.entries(H)) e.addColumnOptions(t, n);
47652
47705
  let o = e.registerSource({ name: i.fileName });
47653
- e.setSourceLoading(o, !0);
47706
+ e.setSourceLoading(o, !0), e.recordLearnedSynonyms(bM(b, Pe, [...n, ...B], Cj(Sj, l)));
47654
47707
  let s = aM(b, n, a), c = {
47655
47708
  numberFormat: tp(i.rows, oM(s)),
47656
47709
  dateFormat: op(i.rows, Le(a)),
47657
47710
  monthTable: ip(f),
47658
47711
  valueMapping: Pe
47659
- }, l = i.rows, d = i.rawCells ?? [], p = i.delimiter ?? ",", m = i.headers, h = m.map((e) => {
47712
+ }, d = i.rows, p = i.rawCells ?? [], m = i.delimiter ?? ",", h = i.headers, g = h.map((e) => {
47660
47713
  let t = b[e];
47661
47714
  return (t ? n.find((e) => e.id === t) : void 0) ?? {
47662
47715
  id: e,
47663
47716
  title: e
47664
47717
  };
47665
- }), g = 0, _ = () => {
47666
- let n = Math.min(g + AM, l.length), i = [], a = [];
47667
- for (let e = g; e < n; e++) {
47668
- let t = l[e], n = d[e];
47718
+ }), _ = 0, v = () => {
47719
+ let n = Math.min(_ + MM, d.length), i = [], a = [];
47720
+ for (let e = _; e < n; e++) {
47721
+ let t = d[e], n = p[e];
47669
47722
  if (n) {
47670
- let { cells: r, conflictColumns: i } = kM(n, h, p);
47723
+ let { cells: r, conflictColumns: i } = jM(n, g, m);
47671
47724
  if (r.length) {
47672
47725
  let e = {};
47673
- for (let t = 0; t < m.length; t++) e[m[t]] = r[t] ?? "";
47726
+ for (let t = 0; t < h.length; t++) e[h[t]] = r[t] ?? "";
47674
47727
  t = e;
47675
47728
  }
47676
47729
  if (i.length) {
47677
47730
  let t = [];
47678
47731
  for (let e of i) {
47679
- let n = b[m[e]];
47732
+ let n = b[h[e]];
47680
47733
  n && t.push(n);
47681
47734
  }
47682
47735
  t.length && a.push({
47683
- localIndex: e - g,
47736
+ localIndex: e - _,
47684
47737
  columnIds: t
47685
47738
  });
47686
47739
  }
47687
47740
  }
47688
47741
  i.push(sM(t, s, c));
47689
47742
  }
47690
- let { rows: u, rowIds: v } = e.upsertRows(o, i, { anchorKey: C ?? void 0 });
47691
- for (let e = g; e < n; e++) e < MM || (l[e] = null, e < d.length && (d[e] = null));
47692
- g = n, setTimeout(() => {
47693
- t.validateRows(u, v);
47743
+ let { rows: l, rowIds: u } = e.upsertRows(o, i, { anchorKey: C ?? void 0 });
47744
+ for (let e = _; e < n; e++) e < PM || (d[e] = null, e < p.length && (p[e] = null));
47745
+ _ = n, setTimeout(() => {
47746
+ t.validateRows(l, u);
47694
47747
  for (let { localIndex: t, columnIds: n } of a) {
47695
- let r = v[t];
47748
+ let r = u[t];
47696
47749
  for (let t of n) {
47697
47750
  let n = e.getCellValidation(r, t) ?? [];
47698
47751
  e.setCellValidation(r, t, [...n, {
@@ -47702,11 +47755,11 @@ function PM() {
47702
47755
  }
47703
47756
  }
47704
47757
  a.length > 0 && e.notify();
47705
- }, 0), g < l.length ? setTimeout(_, 0) : e.finalizeSource(o).then(() => {
47758
+ }, 0), _ < d.length ? setTimeout(v, 0) : e.finalizeSource(o).then(() => {
47706
47759
  t.validateUniqueness(), r();
47707
47760
  });
47708
47761
  };
47709
- _();
47762
+ v();
47710
47763
  }, 0);
47711
47764
  }), [
47712
47765
  _,
@@ -47719,6 +47772,7 @@ function PM() {
47719
47772
  n,
47720
47773
  u,
47721
47774
  Pe,
47775
+ l,
47722
47776
  Le,
47723
47777
  f
47724
47778
  ]);
@@ -47784,20 +47838,20 @@ function PM() {
47784
47838
  }
47785
47839
  //#endregion
47786
47840
  //#region src/components/DataUploader/context/index.tsx
47787
- var FM = (0, y.createContext)(null);
47788
- function IM({ children: e }) {
47789
- let t = PM();
47790
- return /* @__PURE__ */ (0, O.jsx)(FM.Provider, {
47841
+ var LM = (0, y.createContext)(null);
47842
+ function RM({ children: e }) {
47843
+ let t = IM();
47844
+ return /* @__PURE__ */ (0, O.jsx)(LM.Provider, {
47791
47845
  value: t,
47792
47846
  children: e
47793
47847
  });
47794
47848
  }
47795
- var LM = () => {
47796
- let e = (0, y.useContext)(FM);
47849
+ var zM = () => {
47850
+ let e = (0, y.useContext)(LM);
47797
47851
  if (!e) throw Error("useDataUploaderContext must be used within DataUploaderProvider");
47798
47852
  return e;
47799
- }, RM = () => {
47800
- let { steps: e, activeStepIndex: t, currentStepIndex: n, goToStep: r } = LM();
47853
+ }, BM = () => {
47854
+ let { steps: e, activeStepIndex: t, currentStepIndex: n, goToStep: r } = zM();
47801
47855
  return /* @__PURE__ */ (0, O.jsx)(Rc, {
47802
47856
  steps: e,
47803
47857
  activeStepIndex: t,
@@ -47805,79 +47859,79 @@ var LM = () => {
47805
47859
  onStepChange: r,
47806
47860
  isProgressive: !0
47807
47861
  });
47808
- }, zM = () => /* @__PURE__ */ (0, O.jsx)(IM, { children: /* @__PURE__ */ (0, O.jsx)(RM, {}) }), BM = {
47862
+ }, VM = () => /* @__PURE__ */ (0, O.jsx)(RM, { children: /* @__PURE__ */ (0, O.jsx)(BM, {}) }), HM = {
47809
47863
  kty: "EC",
47810
47864
  crv: "P-256",
47811
47865
  x: "wZO1Jxr21FEBDsVMzbTbF8blU2CP17c_eQY7gorO13U",
47812
47866
  y: "Nwr-tXatJZ3DxZqpUG_gOWzmpU6szTqrEL7Gnh5UGwo"
47813
- }, VM = "updog_license_grant", HM = new Set([
47867
+ }, UM = "updog_license_grant", WM = new Set([
47814
47868
  "updog.tech",
47815
47869
  "landing.updog.tech",
47816
47870
  "demo.updog.tech"
47817
47871
  ]);
47818
- function UM() {
47819
- return HM.has(window.location.hostname);
47872
+ function GM() {
47873
+ return WM.has(window.location.hostname);
47820
47874
  }
47821
- function WM() {
47875
+ function KM() {
47822
47876
  return !1;
47823
47877
  }
47824
- function GM() {
47878
+ function qM() {
47825
47879
  return "https://api.updog.tech";
47826
47880
  }
47827
- function KM(e) {
47881
+ function JM(e) {
47828
47882
  let t = e.replace(/-/g, "+").replace(/_/g, "/"), n = t + "=".repeat((4 - t.length % 4) % 4), r = atob(n), i = new Uint8Array(r.length);
47829
47883
  for (let e = 0; e < r.length; e++) i[e] = r.charCodeAt(e);
47830
47884
  return i;
47831
47885
  }
47832
- async function qM(e) {
47886
+ async function YM(e) {
47833
47887
  let t = new TextEncoder().encode(e), n = await crypto.subtle.digest("SHA-256", t);
47834
47888
  return Array.from(new Uint8Array(n)).map((e) => e.toString(16).padStart(2, "0")).join("");
47835
47889
  }
47836
- var JM = null;
47837
- async function YM() {
47838
- return JM || (JM = await crypto.subtle.importKey("jwk", BM, {
47890
+ var XM = null;
47891
+ async function ZM() {
47892
+ return XM || (XM = await crypto.subtle.importKey("jwk", HM, {
47839
47893
  name: "ECDSA",
47840
47894
  namedCurve: "P-256"
47841
- }, !1, ["verify"]), JM);
47895
+ }, !1, ["verify"]), XM);
47842
47896
  }
47843
- function XM() {
47897
+ function QM() {
47844
47898
  try {
47845
- return localStorage.getItem(VM);
47899
+ return localStorage.getItem(UM);
47846
47900
  } catch {
47847
47901
  return null;
47848
47902
  }
47849
47903
  }
47850
- function ZM(e) {
47904
+ function $M(e) {
47851
47905
  try {
47852
- localStorage.setItem(VM, e);
47906
+ localStorage.setItem(UM, e);
47853
47907
  } catch {}
47854
47908
  }
47855
- function QM() {
47909
+ function eN() {
47856
47910
  try {
47857
- localStorage.removeItem(VM);
47911
+ localStorage.removeItem(UM);
47858
47912
  } catch {}
47859
47913
  }
47860
- async function $M(e, t, n) {
47914
+ async function tN(e, t, n) {
47861
47915
  let r = e.indexOf(".");
47862
47916
  if (r === -1) return !1;
47863
- let i = e.slice(0, r), a = e.slice(r + 1), o = KM(i), s = KM(a), c = await YM();
47917
+ let i = e.slice(0, r), a = e.slice(r + 1), o = JM(i), s = JM(a), c = await ZM();
47864
47918
  if (!await crypto.subtle.verify({
47865
47919
  name: "ECDSA",
47866
47920
  hash: "SHA-256"
47867
47921
  }, c, new Uint8Array(s), new Uint8Array(o))) return !1;
47868
47922
  let l = JSON.parse(new TextDecoder().decode(o));
47869
47923
  if (l.exp <= Math.floor(Date.now() / 1e3)) return !1;
47870
- let u = await qM(t);
47924
+ let u = await YM(t);
47871
47925
  return !(l.key !== u || l.domain !== n);
47872
47926
  }
47873
- async function eN(e) {
47874
- let t = XM();
47927
+ async function nN(e) {
47928
+ let t = QM();
47875
47929
  if (!t) return {
47876
47930
  valid: !1,
47877
47931
  errorCode: "license.invalid"
47878
47932
  };
47879
47933
  try {
47880
- if (await $M(t, e, window.location.hostname.toLowerCase().trim())) return {
47934
+ if (await tN(t, e, window.location.hostname.toLowerCase().trim())) return {
47881
47935
  valid: !0,
47882
47936
  errorCode: null
47883
47937
  };
@@ -47887,23 +47941,23 @@ async function eN(e) {
47887
47941
  errorCode: "license.invalid"
47888
47942
  };
47889
47943
  }
47890
- async function tN(e, t = !0) {
47891
- if (UM() || WM()) return {
47944
+ async function rN(e, t = !0) {
47945
+ if (GM() || KM()) return {
47892
47946
  valid: !0,
47893
47947
  errorCode: null
47894
47948
  };
47895
- let n = GM();
47949
+ let n = qM();
47896
47950
  try {
47897
47951
  let r = await fetch(`${n}/v1/validate`, { headers: { "X-API-Key": e } });
47898
47952
  if (r.ok) {
47899
47953
  let e = await r.json();
47900
- return t && e.grant && ZM(e.grant), {
47954
+ return t && e.grant && $M(e.grant), {
47901
47955
  valid: !0,
47902
47956
  errorCode: null
47903
47957
  };
47904
47958
  }
47905
47959
  if (r.status >= 400 && r.status < 500) {
47906
- t && QM();
47960
+ t && eN();
47907
47961
  try {
47908
47962
  return await r.json();
47909
47963
  } catch {
@@ -47915,7 +47969,7 @@ async function tN(e, t = !0) {
47915
47969
  }
47916
47970
  throw Error(`Server error: ${r.status}`);
47917
47971
  } catch {
47918
- return t ? eN(e) : {
47972
+ return t ? nN(e) : {
47919
47973
  valid: !1,
47920
47974
  errorCode: "license.invalid"
47921
47975
  };
@@ -47923,7 +47977,7 @@ async function tN(e, t = !0) {
47923
47977
  }
47924
47978
  //#endregion
47925
47979
  //#region src/hooks/useLicenseValidation.ts
47926
- function nN(e, t, n = !0) {
47980
+ function iN(e, t, n = !0) {
47927
47981
  let [r, i] = (0, y.useState)({
47928
47982
  isValidating: t,
47929
47983
  isValid: !1,
@@ -47943,7 +47997,7 @@ function nN(e, t, n = !0) {
47943
47997
  isValidating: !0,
47944
47998
  isValid: !1,
47945
47999
  errorCode: null
47946
- }), tN(e, n).then((e) => {
48000
+ }), rN(e, n).then((e) => {
47947
48001
  r || i({
47948
48002
  isValidating: !1,
47949
48003
  isValid: e.valid,
@@ -47966,7 +48020,7 @@ function nN(e, t, n = !0) {
47966
48020
  }
47967
48021
  //#endregion
47968
48022
  //#region src/server/auth/AuthState.ts
47969
- var rN = class {
48023
+ var aN = class {
47970
48024
  token = null;
47971
48025
  get() {
47972
48026
  return this.token;
@@ -47977,13 +48031,13 @@ var rN = class {
47977
48031
  clear() {
47978
48032
  this.token = null;
47979
48033
  }
47980
- }, iN = class extends Error {
48034
+ }, oN = class extends Error {
47981
48035
  status;
47982
48036
  code;
47983
48037
  constructor(e) {
47984
48038
  super(e.message), this.name = "ScaleHttpError", this.status = e.status, this.code = e.code;
47985
48039
  }
47986
- }, aN = class {
48040
+ }, sN = class {
47987
48041
  baseUrl;
47988
48042
  apiKey;
47989
48043
  auth;
@@ -48013,7 +48067,7 @@ var rN = class {
48013
48067
  signal: r?.signal
48014
48068
  });
48015
48069
  } catch (e) {
48016
- this.notify(new iN({
48070
+ this.notify(new oN({
48017
48071
  status: 0,
48018
48072
  code: "network",
48019
48073
  message: e instanceof Error ? e.message : String(e)
@@ -48024,7 +48078,7 @@ var rN = class {
48024
48078
  try {
48025
48079
  e = await s.json();
48026
48080
  } catch {}
48027
- this.notify(new iN({
48081
+ this.notify(new oN({
48028
48082
  status: s.status,
48029
48083
  code: e.error ?? `http_${s.status}`,
48030
48084
  message: e.message ?? s.statusText
@@ -48035,23 +48089,23 @@ var rN = class {
48035
48089
  };
48036
48090
  //#endregion
48037
48091
  //#region src/server/endpoints/workspaces.ts
48038
- async function oN(e, t) {
48092
+ async function cN(e, t) {
48039
48093
  return e.post("/workspaces", {
48040
48094
  primaryKey: t.primaryKey,
48041
48095
  columns: t.columns
48042
48096
  }, { signal: t.signal });
48043
48097
  }
48044
- async function sN(e) {
48098
+ async function lN(e) {
48045
48099
  try {
48046
48100
  await e.http.delete(`/workspaces/${e.workspaceId}`, { signal: e.signal });
48047
48101
  } catch (e) {
48048
- if (e instanceof iN && e.status === 404) return;
48102
+ if (e instanceof oN && e.status === 404) return;
48049
48103
  throw e;
48050
48104
  }
48051
48105
  }
48052
48106
  //#endregion
48053
48107
  //#region src/server/endpoints/query.ts
48054
- async function cN(e, t) {
48108
+ async function uN(e, t) {
48055
48109
  let n = await e.http.post(`/workspaces/${e.workspaceId}/query`, {
48056
48110
  page: {
48057
48111
  limit: t.limit,
@@ -48069,12 +48123,12 @@ async function cN(e, t) {
48069
48123
  }
48070
48124
  //#endregion
48071
48125
  //#region src/server/ScaleClient.ts
48072
- var lN = class {
48126
+ var dN = class {
48073
48127
  disposed = !1;
48074
48128
  constructor(e) {
48075
48129
  this.deps = e;
48076
48130
  }
48077
- onQuery = (e) => cN(this.deps, e);
48131
+ onQuery = (e) => uN(this.deps, e);
48078
48132
  onEdit = async (e) => ({
48079
48133
  rejected: !0,
48080
48134
  reason: "Edits are not yet supported in server mode (v0)."
@@ -48091,7 +48145,7 @@ var lN = class {
48091
48145
  pageSize = void 0;
48092
48146
  scrollSensitivity = void 0;
48093
48147
  dispose = async () => {
48094
- this.disposed || (this.disposed = !0, await sN({
48148
+ this.disposed || (this.disposed = !0, await lN({
48095
48149
  http: this.deps.http,
48096
48150
  workspaceId: this.deps.workspaceId
48097
48151
  }));
@@ -48099,25 +48153,25 @@ var lN = class {
48099
48153
  };
48100
48154
  //#endregion
48101
48155
  //#region src/server/createScaleClient.ts
48102
- async function uN(e) {
48103
- let t = new rN(), n = new aN({
48156
+ async function fN(e) {
48157
+ let t = new aN(), n = new sN({
48104
48158
  baseUrl: e.url,
48105
48159
  apiKey: e.apiKey,
48106
48160
  auth: t,
48107
48161
  onDegraded: e.onDegraded
48108
- }), { workspaceId: r, accessToken: i } = await oN(n, {
48162
+ }), { workspaceId: r, accessToken: i } = await cN(n, {
48109
48163
  primaryKey: e.primaryKey,
48110
48164
  columns: e.columns,
48111
48165
  signal: e.signal
48112
48166
  });
48113
- return t.set(i), new lN({
48167
+ return t.set(i), new dN({
48114
48168
  workspaceId: r,
48115
48169
  http: n
48116
48170
  });
48117
48171
  }
48118
48172
  //#endregion
48119
48173
  //#region src/server/errors.ts
48120
- function dN(e, t, n) {
48174
+ function pN(e, t, n) {
48121
48175
  return {
48122
48176
  code: e,
48123
48177
  message: t,
@@ -48127,7 +48181,7 @@ function dN(e, t, n) {
48127
48181
  }
48128
48182
  //#endregion
48129
48183
  //#region src/hooks/useScaleClient.ts
48130
- function fN(e) {
48184
+ function mN(e) {
48131
48185
  let [t, n] = (0, y.useState)({ status: "idle" }), r = (0, y.useRef)(e.columns), i = (0, y.useRef)(e.primaryKey);
48132
48186
  return (0, y.useEffect)(() => {
48133
48187
  if (!e.enabled) {
@@ -48136,7 +48190,7 @@ function fN(e) {
48136
48190
  }
48137
48191
  n({ status: "bootstrapping" });
48138
48192
  let t = new AbortController(), a = null;
48139
- return uN({
48193
+ return fN({
48140
48194
  url: e.url,
48141
48195
  apiKey: e.apiKey,
48142
48196
  primaryKey: i.current,
@@ -48145,7 +48199,7 @@ function fN(e) {
48145
48199
  onDegraded: (e) => {
48146
48200
  t.signal.aborted || n({
48147
48201
  status: "failed",
48148
- error: mN(e)
48202
+ error: gN(e)
48149
48203
  });
48150
48204
  }
48151
48205
  }).then((e) => {
@@ -48160,7 +48214,7 @@ function fN(e) {
48160
48214
  }).catch((e) => {
48161
48215
  t.signal.aborted || n({
48162
48216
  status: "failed",
48163
- error: pN(e)
48217
+ error: hN(e)
48164
48218
  });
48165
48219
  }), () => {
48166
48220
  t.abort(), a?.dispose().catch(() => {});
@@ -48171,30 +48225,30 @@ function fN(e) {
48171
48225
  e.apiKey
48172
48226
  ]), t;
48173
48227
  }
48174
- function pN(e) {
48175
- return e instanceof iN ? e.status === 401 ? dN(e.code.startsWith("license.") ? e.code : "license.invalid", e.message, e) : e.status === 0 ? dN("scale.unreachable", e.message, e) : e.status >= 500 ? dN("scale.server_error", e.message, e) : dN("scale.bootstrap_failed", e.message, e) : dN("scale.bootstrap_failed", e instanceof Error ? e.message : String(e), e);
48228
+ function hN(e) {
48229
+ return e instanceof oN ? e.status === 401 ? pN(e.code.startsWith("license.") ? e.code : "license.invalid", e.message, e) : e.status === 0 ? pN("scale.unreachable", e.message, e) : e.status >= 500 ? pN("scale.server_error", e.message, e) : pN("scale.bootstrap_failed", e.message, e) : pN("scale.bootstrap_failed", e instanceof Error ? e.message : String(e), e);
48176
48230
  }
48177
- function mN(e) {
48178
- return e.status === 0 ? dN("scale.unreachable", e.message, e) : e.status === 404 ? dN("scale.workspace_lost", e.message, e) : dN("scale.server_error", e.message, e);
48231
+ function gN(e) {
48232
+ return e.status === 0 ? pN("scale.unreachable", e.message, e) : e.status === 404 ? pN("scale.workspace_lost", e.message, e) : pN("scale.server_error", e.message, e);
48179
48233
  }
48180
48234
  //#endregion
48181
48235
  //#region src/index.tsx
48182
- function hN(e) {
48236
+ function _N(e) {
48183
48237
  return e === !1 ? { licenseGrant: !1 } : { licenseGrant: e?.licenseGrant ?? !0 };
48184
48238
  }
48185
- function gN(e) {
48239
+ function vN(e) {
48186
48240
  let t = (0, y.useMemo)(() => new $u(e.onError), [e.onError]);
48187
48241
  return /* @__PURE__ */ (0, O.jsx)(bj, {
48188
48242
  errorHandler: t,
48189
48243
  children: /* @__PURE__ */ (0, O.jsx)(Qm, {
48190
48244
  ...e,
48191
48245
  errorHandler: t,
48192
- children: e.showUploader ? /* @__PURE__ */ (0, O.jsx)(zM, {}) : /* @__PURE__ */ (0, O.jsx)(gj, {})
48246
+ children: e.showUploader ? /* @__PURE__ */ (0, O.jsx)(VM, {}) : /* @__PURE__ */ (0, O.jsx)(gj, {})
48193
48247
  })
48194
48248
  });
48195
48249
  }
48196
- function _N(e) {
48197
- let t = e.mode ?? "modal", { t: n, rtl: r } = j(), i = r ? "rtl" : "ltr", a = hN(e.localStorage), o = t === "modal" ? e.open : !0, { isValidating: s, isValid: c, errorCode: l } = nN(e.apiKey, t === "modal" ? o : !0, a.licenseGrant), u = e.__server != null, d = fN({
48250
+ function yN(e) {
48251
+ let t = e.mode ?? "modal", { t: n, rtl: r } = j(), i = r ? "rtl" : "ltr", a = _N(e.localStorage), o = t === "modal" ? e.open : !0, { isValidating: s, isValid: c, errorCode: l } = iN(e.apiKey, t === "modal" ? o : !0, a.licenseGrant), u = e.__server != null, d = mN({
48198
48252
  enabled: !s && c && u,
48199
48253
  url: e.__server?.url ?? "",
48200
48254
  apiKey: e.apiKey,
@@ -48207,7 +48261,7 @@ function _N(e) {
48207
48261
  g,
48208
48262
  v,
48209
48263
  e.readonly
48210
- ]), x = (0, y.useCallback)(() => v?.(), [v]), S = n(f ? "dataEditor.modal.importTitle" : "dataEditor.modal.editTitle");
48264
+ ]), x = (0, y.useCallback)(() => v?.(), [v]), S = f ? n("dataEditor.modal.importTitle") : e.variant === "viewer" ? n("dataEditor.modal.viewTitle") : n("dataEditor.modal.editTitle");
48211
48265
  (0, y.useEffect)(() => {
48212
48266
  t === "modal" && !o && p(e.variant === "uploader");
48213
48267
  }, [
@@ -48249,7 +48303,7 @@ function _N(e) {
48249
48303
  code: e,
48250
48304
  message: "License validation failed",
48251
48305
  source: "license"
48252
- } }), E = () => s ? w(n("dataEditor.license.loading")) : c ? u && d.status === "bootstrapping" ? w(n("dataEditor.connecting.label")) : u && d.status === "failed" ? /* @__PURE__ */ (0, O.jsx)(vj, { error: d.error }) : /* @__PURE__ */ (0, O.jsx)(gN, { ...C }) : T(l ?? "license.invalid");
48306
+ } }), E = () => s ? w(n("dataEditor.license.loading")) : c ? u && d.status === "bootstrapping" ? w(n("dataEditor.connecting.label")) : u && d.status === "failed" ? /* @__PURE__ */ (0, O.jsx)(vj, { error: d.error }) : /* @__PURE__ */ (0, O.jsx)(vN, { ...C }) : T(l ?? "license.invalid");
48253
48307
  return t === "inline" ? /* @__PURE__ */ (0, O.jsx)("div", {
48254
48308
  className: "updog__data-editor updog__data-editor-inline",
48255
48309
  dir: i,
@@ -48269,18 +48323,18 @@ function _N(e) {
48269
48323
  submitText: n("dataEditor.confirmClose.action")
48270
48324
  })] });
48271
48325
  }
48272
- function vN(e) {
48326
+ function bN(e) {
48273
48327
  let { translations: t, rtl: n = !1, locale: r = "en", className: i, ...a } = e;
48274
48328
  return /* @__PURE__ */ (0, O.jsx)(A, {
48275
48329
  translations: t,
48276
48330
  rtl: n,
48277
48331
  locale: r,
48278
- children: /* @__PURE__ */ (0, O.jsx)(_N, { ...a })
48332
+ children: /* @__PURE__ */ (0, O.jsx)(yN, { ...a })
48279
48333
  });
48280
48334
  }
48281
48335
  //#endregion
48282
48336
  //#region src/wc.ts
48283
- var yN = {
48337
+ var xN = {
48284
48338
  "api-key": {
48285
48339
  prop: "apiKey",
48286
48340
  type: "string"
@@ -48313,12 +48367,12 @@ var yN = {
48313
48367
  prop: "mode",
48314
48368
  type: "string"
48315
48369
  }
48316
- }, bN = class extends HTMLElement {
48370
+ }, SN = class extends HTMLElement {
48317
48371
  _root = null;
48318
48372
  _props = {};
48319
48373
  _renderScheduled = !1;
48320
48374
  static get observedAttributes() {
48321
- return Object.keys(yN);
48375
+ return Object.keys(xN);
48322
48376
  }
48323
48377
  connectedCallback() {
48324
48378
  this._root = (0, v.createRoot)(this), this._props.mode !== "inline" && (this._props.onClose = () => {
@@ -48329,7 +48383,7 @@ var yN = {
48329
48383
  this._root?.unmount(), this._root = null;
48330
48384
  }
48331
48385
  attributeChangedCallback(e, t, n) {
48332
- let r = yN[e];
48386
+ let r = xN[e];
48333
48387
  r && (this._props[r.prop] = r.type === "boolean" ? n !== null : n, e === "mode" && (n === "inline" ? delete this._props.onClose : this._props.onClose = () => {
48334
48388
  this.dispatchEvent(new CustomEvent("close", { bubbles: !0 }));
48335
48389
  }), this._scheduleRender());
@@ -48346,11 +48400,11 @@ var yN = {
48346
48400
  }
48347
48401
  _scheduleRender() {
48348
48402
  this._renderScheduled || (this._renderScheduled = !0, queueMicrotask(() => {
48349
- this._renderScheduled = !1, this._root && this._root.render((0, y.createElement)(vN, this._props));
48403
+ this._renderScheduled = !1, this._root && this._root.render((0, y.createElement)(bN, this._props));
48350
48404
  }));
48351
48405
  }
48352
48406
  };
48353
- for (let e of /* @__PURE__ */ "columns.primaryKey.apiKey.className.localStorage.loadData.__server.onComplete.translations.importFormats.exportFormats.remoteSources.enableDeleteRow.enableAddRow.enableCreateColumn.onColumnMatch.onValueMatch.synonyms.sampleData.rowHeight.headerHeight.locale.variant.rtl.readonly.mode.chat".split(".")) Object.defineProperty(bN.prototype, e, {
48407
+ for (let e of /* @__PURE__ */ "columns.primaryKey.apiKey.className.localStorage.loadData.__server.onComplete.translations.importFormats.exportFormats.remoteSources.enableDeleteRow.enableAddRow.enableCreateColumn.onColumnMatch.onValueMatch.synonyms.sampleData.rowHeight.headerHeight.locale.variant.rtl.readonly.mode.chat".split(".")) Object.defineProperty(SN.prototype, e, {
48354
48408
  get() {
48355
48409
  return this._props[e];
48356
48410
  },
@@ -48360,7 +48414,7 @@ for (let e of /* @__PURE__ */ "columns.primaryKey.apiKey.className.localStorage.
48360
48414
  enumerable: !0,
48361
48415
  configurable: !0
48362
48416
  });
48363
- Object.defineProperty(bN.prototype, "open", {
48417
+ Object.defineProperty(SN.prototype, "open", {
48364
48418
  get() {
48365
48419
  return this.hasAttribute("open");
48366
48420
  },
@@ -48369,5 +48423,5 @@ Object.defineProperty(bN.prototype, "open", {
48369
48423
  },
48370
48424
  enumerable: !0,
48371
48425
  configurable: !0
48372
- }), customElements.define("updog-editor", bN);
48426
+ }), customElements.define("updog-editor", SN);
48373
48427
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@updog/data-editor-wc",
3
- "version": "0.1.45",
3
+ "version": "0.1.47",
4
4
  "description": "Client-side CSV importer and spreadsheet editor 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",