@updog/data-editor-wc 0.1.72 → 0.1.73

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 +2 -0
  2. package/index.js +60 -20
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -166,6 +166,8 @@ declare var export_default = {
166
166
  filteredRows_other: "{{filtered}} of {{total}} rows",
167
167
  },
168
168
  toast: {
169
+ clipboardWriteFailed:
170
+ "The browser blocked the copy to the clipboard. You can paste inside this table.",
169
171
  dismiss: "Dismiss",
170
172
  rowMayNotBeVisible:
171
173
  "Row has been added but may not be visible due to active filters or sorting",
package/index.js CHANGED
@@ -8157,6 +8157,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
8157
8157
  filteredRows_other: "{{filtered}} of {{total}} rows"
8158
8158
  },
8159
8159
  toast: {
8160
+ clipboardWriteFailed: "The browser blocked the copy to the clipboard. You can paste inside this table.",
8160
8161
  dismiss: "Dismiss",
8161
8162
  rowMayNotBeVisible: "Row has been added but may not be visible due to active filters or sorting"
8162
8163
  },
@@ -33036,14 +33037,14 @@ var pv = class {
33036
33037
  return;
33037
33038
  }
33038
33039
  let s = nv(e);
33039
- t.fillStyle = n.cellBgIdle, D_(t, 0, 0, a, o), this.paintBodyPane(s, s.panes.scrollable), this.selectionPainter.paintSelectionOutlines(s, null), this.selectionPainter.paintFocusBorder(s, null), this.lastFillHandleRect = this.selectionPainter.paintFillHandle(s, null), this.overlayPainter.paintClipboardOverlay(s), this.overlayPainter.paintFillOverlay(s);
33040
+ t.fillStyle = n.cellBgIdle, D_(t, 0, 0, a, o), this.paintBodyPane(s, s.panes.scrollable), this.selectionPainter.paintSelectionOutlines(s, null), this.selectionPainter.paintFocusBorder(s, null), this.overlayPainter.paintClipboardOverlay(s), this.overlayPainter.paintFillOverlay(s), this.lastFillHandleRect = this.selectionPainter.paintFillHandle(s, null);
33040
33041
  let c = s.panes.pinned;
33041
33042
  if (c?.clip) {
33042
33043
  t.fillStyle = n.cellBgIdle, D_(t, c.clip.x, c.clip.y, c.clip.w, c.clip.h), t.save(), t.beginPath(), t.rect(c.clip.x, c.clip.y, c.clip.w, c.clip.h), t.clip(), this.paintBodyPane(s, c), t.restore(), t.save(), t.beginPath();
33043
33044
  let e = Math.min(s.totalRows * 34, o - 36);
33044
- t.rect(c.clip.x, 36, c.clip.w, e), t.clip(), this.selectionPainter.paintSelectionOutlines(s, c), this.selectionPainter.paintFocusBorder(s, c);
33045
+ t.rect(c.clip.x, 36, c.clip.w, e), t.clip(), this.selectionPainter.paintSelectionOutlines(s, c), this.selectionPainter.paintFocusBorder(s, c), this.overlayPainter.paintClipboardOverlay(s);
33045
33046
  let r = this.selectionPainter.paintFillHandle(s, c);
33046
- r && (this.lastFillHandleRect = r), this.overlayPainter.paintClipboardOverlay(s), t.restore();
33047
+ r && (this.lastFillHandleRect = r), t.restore();
33047
33048
  }
33048
33049
  this.markerPainter.paint(s), this.headerPainter.paintHeaderRow(s), this.headerPainter.paintCornerCell(s), s.resizeGuideX >= 0 && this.overlayPainter.paintResizeGuide(s), this.hasSkeletons = s.hasSkeletons, this.hasPendingCells = s.hasPendingCells;
33049
33050
  }
@@ -43918,12 +43919,17 @@ function Tj(e, t, n) {
43918
43919
  }
43919
43920
  o.push(r.map((e) => String(t[e.id] ?? "")).join(" "));
43920
43921
  }
43921
- navigator.clipboard.writeText(o.join("\n"));
43922
+ let s = o.join("\n");
43923
+ return {
43924
+ text: s,
43925
+ written: navigator.clipboard.writeText(s).then(() => !0).catch(() => !1)
43926
+ };
43922
43927
  }
43923
43928
  //#endregion
43924
43929
  //#region src/components/DataEditor/DataEditorGrid/controller/ClipboardManager.ts
43925
43930
  var Ej = {
43926
43931
  clipboard: null,
43932
+ marqueeVisible: !1,
43927
43933
  version: 0
43928
43934
  }, Dj = class {
43929
43935
  _store;
@@ -43940,6 +43946,9 @@ var Ej = {
43940
43946
  _clipboardMaxRow = -1;
43941
43947
  _sourceMinRowIndex = -1;
43942
43948
  _sourceMaxRowIndex = -1;
43949
+ _marqueeVisible = !1;
43950
+ _osText = null;
43951
+ _osWrite = null;
43943
43952
  _sortState = null;
43944
43953
  _t = (e) => e;
43945
43954
  _version = 0;
@@ -43967,7 +43976,7 @@ var Ej = {
43967
43976
  operation: "copy",
43968
43977
  columnIds: e.columnIds,
43969
43978
  rowIds: e.rowIds
43970
- }, this.precomputeLookup(), this.notify(), Tj(this._clipboard, this._columns, this._store));
43979
+ }, this._marqueeVisible = !0, this.precomputeLookup(), this.notify(), this.writeToOs(this._clipboard));
43971
43980
  }
43972
43981
  cut() {
43973
43982
  let e = this.buildClipboardFromSnapshot();
@@ -43975,10 +43984,11 @@ var Ej = {
43975
43984
  operation: "cut",
43976
43985
  columnIds: e.columnIds,
43977
43986
  rowIds: e.rowIds
43978
- }, this.precomputeLookup(), this.notify(), Tj(this._clipboard, this._columns, this._store));
43987
+ }, this._marqueeVisible = !0, this.precomputeLookup(), this.notify(), this.writeToOs(this._clipboard));
43979
43988
  }
43980
43989
  async paste() {
43981
- if (this._clipboard) {
43990
+ let e = await this.readOsClipboard();
43991
+ if (this._clipboard && (!e.ok || e.ours)) {
43982
43992
  let e = this.resolveTargetFromSnapshot();
43983
43993
  if (!e) return;
43984
43994
  let t = this._clipboard, n = this._store, r = Dm(t.columnIds, e.columnIds, t.rowIds ?? null, e.rowIds, this._columns, (e) => n.getRowId(e), n.getSnapshot().filteredCount, t.operation === "cut"), i = await n.pasteInternal(r, e.rowIds, {
@@ -43988,27 +43998,28 @@ var Ej = {
43988
43998
  i && (this.syncInternalPasteToServer(i, t, e), this._sortState && Xd.info(this._t("dataEditor.toast.rowMayNotBeVisible")), this.clear());
43989
43999
  return;
43990
44000
  }
43991
- let e;
43992
- try {
43993
- e = await navigator.clipboard.readText();
43994
- } catch (e) {
44001
+ if (!e.ok) {
43995
44002
  this._store.errorHandler.handleError({
43996
44003
  code: "OPERATION_ERROR",
43997
44004
  message: "Failed to read clipboard",
43998
44005
  source: "clipboard-manager",
43999
- originalError: e
44006
+ originalError: e.error
44000
44007
  });
44001
44008
  return;
44002
44009
  }
44003
- if (!e) return;
44004
- let { row: t, col: n } = this.resolveAnchor(), r = await this._store.pasteFromText(e, t, n, this._validator);
44005
- r && this.syncExternalPasteToServer(r, t, n, e);
44010
+ let t = e.text;
44011
+ if (!t) return;
44012
+ let { row: n, col: r } = this.resolveAnchor(), i = await this._store.pasteFromText(t, n, r, this._validator);
44013
+ i && this.syncExternalPasteToServer(i, n, r, t);
44006
44014
  }
44007
44015
  clear() {
44008
- this._clipboard && (this._clipboard = null, this._clipboardColIndices = null, this._clipboardRowSet = null, this._clipboardIsWholeColumn = !1, this._clipboardMinCol = -1, this._clipboardMaxCol = -1, this._clipboardMinRow = -1, this._clipboardMaxRow = -1, this._sourceMinRowIndex = -1, this._sourceMaxRowIndex = -1, this.notify());
44016
+ this._clipboard && (this._clipboard = null, this._clipboardColIndices = null, this._clipboardRowSet = null, this._clipboardIsWholeColumn = !1, this._clipboardMinCol = -1, this._clipboardMaxCol = -1, this._clipboardMinRow = -1, this._clipboardMaxRow = -1, this._sourceMinRowIndex = -1, this._sourceMaxRowIndex = -1, this._marqueeVisible = !1, this._osText = null, this._osWrite = null, this.notify());
44017
+ }
44018
+ hideMarquee() {
44019
+ this._marqueeVisible && (this._marqueeVisible = !1, this.notify());
44009
44020
  }
44010
44021
  isCellInClipboard(e, t) {
44011
- if (!this._clipboard || !this._clipboardColIndices || !this._clipboardColIndices.has(e)) return !1;
44022
+ if (!this._marqueeVisible || !this._clipboard || !this._clipboardColIndices || !this._clipboardColIndices.has(e)) return !1;
44012
44023
  if (this._clipboardIsWholeColumn) return !0;
44013
44024
  if (!this._clipboardRowSet) return !1;
44014
44025
  let n = this._store.getRowId(t);
@@ -44018,7 +44029,7 @@ var Ej = {
44018
44029
  return this._clipboard?.operation ?? null;
44019
44030
  }
44020
44031
  getClipboardBounds() {
44021
- if (!this._clipboard) return null;
44032
+ if (!this._clipboard || !this._marqueeVisible) return null;
44022
44033
  let e = this._clipboardIsWholeColumn ? this._store.getSnapshot().filteredCount - 1 : this._clipboardMaxRow;
44023
44034
  return {
44024
44035
  minCol: this._clipboardMinCol,
@@ -44027,6 +44038,32 @@ var Ej = {
44027
44038
  maxRow: e
44028
44039
  };
44029
44040
  }
44041
+ writeToOs(e) {
44042
+ let t = Tj(e, this._columns, this._store);
44043
+ this._osText = t.text, this._osWrite = t.written, t.written.then((e) => {
44044
+ e || (this._store.errorHandler.handleError({
44045
+ code: "OPERATION_ERROR",
44046
+ message: "Failed to write clipboard",
44047
+ source: "clipboard-manager"
44048
+ }), Xd.error(this._t("dataEditor.toast.clipboardWriteFailed")));
44049
+ });
44050
+ }
44051
+ async readOsClipboard() {
44052
+ let e = this._osWrite ? await this._osWrite : !0;
44053
+ try {
44054
+ let t = await navigator.clipboard.readText();
44055
+ return {
44056
+ ok: !0,
44057
+ text: t,
44058
+ ours: !e || t === this._osText
44059
+ };
44060
+ } catch (e) {
44061
+ return {
44062
+ ok: !1,
44063
+ error: e
44064
+ };
44065
+ }
44066
+ }
44030
44067
  buildClipboardFromSnapshot() {
44031
44068
  let e = f_(this._selection.getSelection(), this.resolveContext());
44032
44069
  return e === null ? null : {
@@ -44129,6 +44166,7 @@ var Ej = {
44129
44166
  notify() {
44130
44167
  this._version++, this._snapshot = {
44131
44168
  clipboard: this._clipboard,
44169
+ marqueeVisible: this._marqueeVisible,
44132
44170
  version: this._version
44133
44171
  };
44134
44172
  for (let e of this._listeners) e();
@@ -44516,8 +44554,8 @@ var Bj = class {
44516
44554
  return;
44517
44555
  }
44518
44556
  if (e.key === "Escape") {
44519
- if (this._clipboard.getSnapshot().clipboard) {
44520
- this._clipboard.clear();
44557
+ if (this._clipboard.getSnapshot().marqueeVisible) {
44558
+ this._clipboard.hideMarquee();
44521
44559
  return;
44522
44560
  }
44523
44561
  this._selection.clear();
@@ -45330,6 +45368,8 @@ var Qj = {
45330
45368
  }, [b]), (0, y.useEffect)(() => {
45331
45369
  R.clipboard.setSortState(m);
45332
45370
  }, [R, m]), (0, y.useEffect)(() => {
45371
+ R.clipboard.hideMarquee();
45372
+ }, [R, b]), (0, y.useEffect)(() => {
45333
45373
  R.clipboard.setTranslate(S);
45334
45374
  }, [R, S]), (0, y.useEffect)(() => {
45335
45375
  R.setBounds(p, B.columns.length);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@updog/data-editor-wc",
3
- "version": "0.1.72",
3
+ "version": "0.1.73",
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",