@teselagen/ui 0.3.41 → 0.3.43

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.
package/index.cjs.js CHANGED
@@ -18286,11 +18286,20 @@ function require_domCreate() {
18286
18286
  return _domCreate;
18287
18287
  }
18288
18288
  __name(require_domCreate, "require_domCreate");
18289
- var _ie8DomDefine = !require_descriptors() && !_fails(function() {
18290
- return Object.defineProperty(require_domCreate()("div"), "a", { get: function() {
18291
- return 7;
18292
- } }).a != 7;
18293
- });
18289
+ var _ie8DomDefine;
18290
+ var hasRequired_ie8DomDefine;
18291
+ function require_ie8DomDefine() {
18292
+ if (hasRequired_ie8DomDefine)
18293
+ return _ie8DomDefine;
18294
+ hasRequired_ie8DomDefine = 1;
18295
+ _ie8DomDefine = !require_descriptors() && !_fails(function() {
18296
+ return Object.defineProperty(require_domCreate()("div"), "a", { get: function() {
18297
+ return 7;
18298
+ } }).a != 7;
18299
+ });
18300
+ return _ie8DomDefine;
18301
+ }
18302
+ __name(require_ie8DomDefine, "require_ie8DomDefine");
18294
18303
  var isObject$d = _isObject;
18295
18304
  var _toPrimitive = /* @__PURE__ */ __name(function(it, S2) {
18296
18305
  if (!isObject$d(it))
@@ -18310,7 +18319,7 @@ function require_objectDp() {
18310
18319
  return _objectDp;
18311
18320
  hasRequired_objectDp = 1;
18312
18321
  var anObject2 = _anObject;
18313
- var IE8_DOM_DEFINE2 = _ie8DomDefine;
18322
+ var IE8_DOM_DEFINE2 = require_ie8DomDefine();
18314
18323
  var toPrimitive2 = _toPrimitive;
18315
18324
  var dP2 = Object.defineProperty;
18316
18325
  _objectDp.f = require_descriptors() ? Object.defineProperty : /* @__PURE__ */ __name(function defineProperty5(O2, P2, Attributes) {
@@ -18528,7 +18537,15 @@ var _objectKeys = Object.keys || /* @__PURE__ */ __name(function keys(O2) {
18528
18537
  var _objectGops = {};
18529
18538
  _objectGops.f = Object.getOwnPropertySymbols;
18530
18539
  var _objectPie = {};
18531
- _objectPie.f = {}.propertyIsEnumerable;
18540
+ var hasRequired_objectPie;
18541
+ function require_objectPie() {
18542
+ if (hasRequired_objectPie)
18543
+ return _objectPie;
18544
+ hasRequired_objectPie = 1;
18545
+ _objectPie.f = {}.propertyIsEnumerable;
18546
+ return _objectPie;
18547
+ }
18548
+ __name(require_objectPie, "require_objectPie");
18532
18549
  var defined$1 = _defined;
18533
18550
  var _toObject = /* @__PURE__ */ __name(function(it) {
18534
18551
  return Object(defined$1(it));
@@ -18542,7 +18559,7 @@ function require_objectAssign() {
18542
18559
  var DESCRIPTORS2 = require_descriptors();
18543
18560
  var getKeys2 = _objectKeys;
18544
18561
  var gOPS2 = _objectGops;
18545
- var pIE2 = _objectPie;
18562
+ var pIE2 = require_objectPie();
18546
18563
  var toObject2 = _toObject;
18547
18564
  var IObject2 = require_iobject();
18548
18565
  var $assign = Object.assign;
@@ -19197,7 +19214,7 @@ var _wksDefine = /* @__PURE__ */ __name(function(name) {
19197
19214
  }, "_wksDefine");
19198
19215
  var getKeys = _objectKeys;
19199
19216
  var gOPS$1 = _objectGops;
19200
- var pIE$1 = _objectPie;
19217
+ var pIE$1 = require_objectPie();
19201
19218
  var _enumKeys = /* @__PURE__ */ __name(function(it) {
19202
19219
  var result = getKeys(it);
19203
19220
  var getSymbols2 = gOPS$1.f;
@@ -19238,12 +19255,12 @@ _objectGopnExt.f = /* @__PURE__ */ __name(function getOwnPropertyNames2(it) {
19238
19255
  return windowNames && toString$5.call(it) == "[object Window]" ? getWindowNames(it) : gOPN$1(toIObject$2(it));
19239
19256
  }, "getOwnPropertyNames");
19240
19257
  var _objectGopd = {};
19241
- var pIE = _objectPie;
19258
+ var pIE = require_objectPie();
19242
19259
  var createDesc$1 = _propertyDesc;
19243
19260
  var toIObject$1 = _toIobject;
19244
19261
  var toPrimitive$1 = _toPrimitive;
19245
19262
  var has$6 = _has;
19246
- var IE8_DOM_DEFINE = _ie8DomDefine;
19263
+ var IE8_DOM_DEFINE = require_ie8DomDefine();
19247
19264
  var gOPD$2 = Object.getOwnPropertyDescriptor;
19248
19265
  _objectGopd.f = require_descriptors() ? gOPD$2 : /* @__PURE__ */ __name(function getOwnPropertyDescriptor(O2, P2) {
19249
19266
  O2 = toIObject$1(O2);
@@ -19418,7 +19435,7 @@ if (!USE_NATIVE) {
19418
19435
  $GOPD.f = $getOwnPropertyDescriptor;
19419
19436
  $DP.f = $defineProperty;
19420
19437
  _objectGopn.f = gOPNExt.f = $getOwnPropertyNames;
19421
- _objectPie.f = $propertyIsEnumerable;
19438
+ require_objectPie().f = $propertyIsEnumerable;
19422
19439
  $GOPS.f = $getOwnPropertySymbols;
19423
19440
  if (DESCRIPTORS && !_library) {
19424
19441
  redefine(ObjectProto, "propertyIsEnumerable", $propertyIsEnumerable);
@@ -55810,6 +55827,15 @@ const openColumn = __spreadProps(__spreadValues({}, viewColumn), {
55810
55827
  }
55811
55828
  });
55812
55829
  const dataTableEnhancer = compose(
55830
+ // maybe we need this in some cases?
55831
+ // tgFormValues("reduxFormEntities"),
55832
+ // withProps(props => {
55833
+ // const entities = props.reduxFormEntities || props.entities;
55834
+ // return {
55835
+ // _origEntities: props.entities,
55836
+ // entities
55837
+ // };
55838
+ // }),
55813
55839
  //connect to withTableParams here in the dataTable component so that, in the case that the table is not manually connected,
55814
55840
  withTableParams({
55815
55841
  isLocalCall: true
@@ -56668,13 +56694,14 @@ const _DataTable = class _DataTable extends React$1.Component {
56668
56694
  }, "formatAndValidateEntities"));
56669
56695
  __publicField(this, "formatAndValidateTableInitial", /* @__PURE__ */ __name(() => {
56670
56696
  const {
56671
- _origEntities: entities,
56697
+ _origEntities,
56698
+ entities,
56672
56699
  initialEntities,
56673
56700
  change,
56674
56701
  reduxFormCellValidation
56675
56702
  } = this.props;
56676
56703
  const { newEnts, validationErrors } = this.formatAndValidateEntities(
56677
- initialEntities || entities
56704
+ initialEntities || (entities && entities.length ? entities : _origEntities)
56678
56705
  );
56679
56706
  change("reduxFormEntities", newEnts);
56680
56707
  const toKeep = {};
@@ -56792,16 +56819,33 @@ const _DataTable = class _DataTable extends React$1.Component {
56792
56819
  } else if (e2.clipboardData && e2.clipboardData.getData) {
56793
56820
  toPaste = e2.clipboardData.getData("text/plain");
56794
56821
  }
56795
- if (toPaste.includes(",")) {
56796
- try {
56797
- const { data, errors } = papaparse.parse(toPaste, {
56798
- header: false
56822
+ const jsonToPaste = e2.clipboardData.getData("application/json");
56823
+ try {
56824
+ const pastedJson = [];
56825
+ JSON.parse(jsonToPaste).forEach((row) => {
56826
+ const newRow = [];
56827
+ Object.values(row).forEach((cell) => {
56828
+ const cellVal = JSON.parse(cell);
56829
+ newRow.push(cellVal);
56799
56830
  });
56800
- if ((data == null ? void 0 : data.length) && !(errors == null ? void 0 : errors.length)) {
56801
- pasteData = data;
56831
+ pastedJson.push(newRow);
56832
+ });
56833
+ pasteData = pastedJson;
56834
+ if (pasteData[0] && pasteData[0][0] && pasteData[0][0].__isHeaderCell) {
56835
+ pasteData = pasteData.slice(1);
56836
+ }
56837
+ } catch (e22) {
56838
+ if (toPaste.includes(",")) {
56839
+ try {
56840
+ const { data, errors } = papaparse.parse(toPaste, {
56841
+ header: false
56842
+ });
56843
+ if ((data == null ? void 0 : data.length) && !(errors == null ? void 0 : errors.length)) {
56844
+ pasteData = data;
56845
+ }
56846
+ } catch (error) {
56847
+ console.error(`error p982qhgpf9qh`, error);
56802
56848
  }
56803
- } catch (error) {
56804
- console.error(`error p982qhgpf9qh`, error);
56805
56849
  }
56806
56850
  }
56807
56851
  pasteData = pasteData.length ? pasteData : defaultParsePaste(toPaste);
@@ -56820,7 +56864,7 @@ const _DataTable = class _DataTable extends React$1.Component {
56820
56864
  entity,
56821
56865
  path: path2,
56822
56866
  schema,
56823
- newVal
56867
+ newVal: formatPasteData({ newVal, path: path2, schema })
56824
56868
  });
56825
56869
  if (error) {
56826
56870
  newCellValidate[cellId] = error;
@@ -56851,8 +56895,8 @@ const _DataTable = class _DataTable extends React$1.Component {
56851
56895
  const indexToPath = lodashExports.invert(pathToIndex);
56852
56896
  const startCellIndex = pathToIndex[primaryCellPath];
56853
56897
  pasteData.forEach((row, i) => {
56854
- row.forEach((cell, j) => {
56855
- if (cell) {
56898
+ row.forEach((newVal, j) => {
56899
+ if (newVal) {
56856
56900
  const cellIndexToChange = startCellIndex + j;
56857
56901
  const entity = entitiesToManipulate[i];
56858
56902
  if (entity) {
@@ -56863,7 +56907,11 @@ const _DataTable = class _DataTable extends React$1.Component {
56863
56907
  entity,
56864
56908
  path: path2,
56865
56909
  schema,
56866
- newVal: cell
56910
+ newVal: formatPasteData({
56911
+ newVal,
56912
+ path: path2,
56913
+ schema
56914
+ })
56867
56915
  });
56868
56916
  const cellId = `${getIdOrCodeOrIndex(entity)}:${path2}`;
56869
56917
  if (!newSelectedCells[cellId]) {
@@ -56973,17 +57021,11 @@ const _DataTable = class _DataTable extends React$1.Component {
56973
57021
  __publicField(this, "getCellCopyText", /* @__PURE__ */ __name((cellWrapper) => {
56974
57022
  const text2 = cellWrapper && cellWrapper.getAttribute("data-copy-text");
56975
57023
  const jsonText = cellWrapper && cellWrapper.getAttribute("data-copy-json");
56976
- const toRet = text2 || cellWrapper.textContent || "";
56977
- return [toRet, jsonText];
57024
+ const textContent = text2 || cellWrapper.textContent || "";
57025
+ return [textContent, jsonText];
56978
57026
  }, "getCellCopyText"));
56979
- __publicField(this, "handleCopyRow", /* @__PURE__ */ __name((rowEl) => {
56980
- const text2 = this.getRowCopyText(rowEl);
56981
- if (!text2)
56982
- return window.toastr.warning("No text to copy");
56983
- this.handleCopyHelper(text2, void 0, "Row Copied");
56984
- }, "handleCopyRow"));
56985
57027
  __publicField(this, "handleCopyColumn", /* @__PURE__ */ __name((e2, cellWrapper, selectedRecords) => {
56986
- const cellType = cellWrapper.getAttribute("data-test");
57028
+ const specificColumn = cellWrapper.getAttribute("data-test");
56987
57029
  let rowElsToCopy = getAllRows(e2);
56988
57030
  if (!rowElsToCopy)
56989
57031
  return;
@@ -57000,14 +57042,24 @@ const _DataTable = class _DataTable extends React$1.Component {
57000
57042
  }
57001
57043
  if (!rowElsToCopy)
57002
57044
  return;
57003
- const textToCopy = lodashExports.map(
57004
- rowElsToCopy,
57005
- (rowEl) => this.getRowCopyText(rowEl, { cellType })
57006
- ).filter((text2) => text2).join("\n");
57045
+ this.handleCopyRows(rowElsToCopy, {
57046
+ specificColumn,
57047
+ onFinishMsg: "Column Copied"
57048
+ });
57049
+ }, "handleCopyColumn"));
57050
+ __publicField(this, "handleCopyRows", /* @__PURE__ */ __name((rowElsToCopy, { specificColumn, onFinishMsg } = {}) => {
57051
+ let textToCopy = [];
57052
+ const jsonToCopy = [];
57053
+ lodashExports.forEach(rowElsToCopy, (rowEl) => {
57054
+ const [t2, j] = this.getRowCopyText(rowEl, { specificColumn });
57055
+ textToCopy.push(t2);
57056
+ jsonToCopy.push(j);
57057
+ });
57058
+ textToCopy = textToCopy.filter((text2) => text2).join("\n");
57007
57059
  if (!textToCopy)
57008
57060
  return window.toastr.warning("No text to copy");
57009
- this.handleCopyHelper(textToCopy, void 0, "Column copied");
57010
- }, "handleCopyColumn"));
57061
+ this.handleCopyHelper(textToCopy, jsonToCopy, onFinishMsg || "Row Copied");
57062
+ }, "handleCopyRows"));
57011
57063
  __publicField(this, "updateEntitiesHelper", /* @__PURE__ */ __name((ents, fn4) => {
57012
57064
  const { change, reduxFormEntitiesUndoRedoStack = { currentVersion: 0 } } = this.props;
57013
57065
  const [nextState, patches, inversePatches] = cn(ents, fn4);
@@ -57026,34 +57078,35 @@ const _DataTable = class _DataTable extends React$1.Component {
57026
57078
  }
57027
57079
  }));
57028
57080
  }, "updateEntitiesHelper"));
57029
- __publicField(this, "getRowCopyText", /* @__PURE__ */ __name((rowEl, { cellType } = {}) => {
57081
+ __publicField(this, "getRowCopyText", /* @__PURE__ */ __name((rowEl, { specificColumn } = {}) => {
57030
57082
  if (!rowEl)
57031
57083
  return;
57032
- return lodashExports.flatMap(rowEl.children, (cellEl) => {
57084
+ const textContent = [];
57085
+ const jsonText = [];
57086
+ lodashExports.forEach(rowEl.children, (cellEl) => {
57033
57087
  const cellChild = cellEl.querySelector(`[data-copy-text]`);
57034
57088
  if (!cellChild) {
57035
- if (cellType)
57089
+ if (specificColumn)
57036
57090
  return [];
57037
57091
  return;
57038
57092
  }
57039
- if (cellType && cellChild.getAttribute("data-test") !== cellType) {
57093
+ if (specificColumn && cellChild.getAttribute("data-test") !== specificColumn) {
57040
57094
  return [];
57041
57095
  }
57042
- return this.getCellCopyText(cellChild);
57043
- }).join(" ");
57096
+ const [t2, j] = this.getCellCopyText(cellChild);
57097
+ textContent.push(t2);
57098
+ jsonText.push(j);
57099
+ });
57100
+ return [lodashExports.flatMap(textContent).join(" "), jsonText];
57044
57101
  }, "getRowCopyText"));
57045
- __publicField(this, "handleCopyHelper", /* @__PURE__ */ __name((stringToCopy, objToCopy, message) => {
57046
- const copyHandler = /* @__PURE__ */ __name((e2) => {
57047
- e2.preventDefault();
57048
- e2.clipboardData.setData("application/json", JSON.stringify(objToCopy));
57049
- e2.clipboardData.setData("text/plain", stringToCopy);
57050
- }, "copyHandler");
57051
- document.addEventListener("copy", copyHandler);
57102
+ __publicField(this, "handleCopyHelper", /* @__PURE__ */ __name((stringToCopy, jsonToCopy, message) => {
57052
57103
  !window.Cypress && copy$1(stringToCopy, {
57104
+ onCopy: (clipboardData) => {
57105
+ clipboardData.setData("application/json", JSON.stringify(jsonToCopy));
57106
+ },
57053
57107
  // keep this so that pasting into spreadsheets works.
57054
57108
  format: "text/plain"
57055
57109
  });
57056
- document.removeEventListener("copy", copyHandler);
57057
57110
  window.toastr.success(message);
57058
57111
  }, "handleCopyHelper"));
57059
57112
  __publicField(this, "handleCopyTable", /* @__PURE__ */ __name((e2) => {
@@ -57061,10 +57114,9 @@ const _DataTable = class _DataTable extends React$1.Component {
57061
57114
  const allRowEls = getAllRows(e2);
57062
57115
  if (!allRowEls)
57063
57116
  return;
57064
- const textToCopy = lodashExports.map(allRowEls, (rowEl) => this.getRowCopyText(rowEl)).filter((text2) => text2).join("\n");
57065
- if (!textToCopy)
57066
- return window.toastr.warning("No text to copy");
57067
- this.handleCopyHelper(textToCopy, void 0, "Table copied");
57117
+ this.handleCopyRows(allRowEls, {
57118
+ onFinishMsg: "Table Copied"
57119
+ });
57068
57120
  } catch (error) {
57069
57121
  console.error(`error:`, error);
57070
57122
  window.toastr.error("Error copying rows.");
@@ -57104,6 +57156,7 @@ const _DataTable = class _DataTable extends React$1.Component {
57104
57156
  return;
57105
57157
  const allRows = getAllRows(e2);
57106
57158
  let fullCellText = "";
57159
+ const fullJson = [];
57107
57160
  lodashExports.times(selectionGrid.length, (i) => {
57108
57161
  const row = selectionGrid[i];
57109
57162
  if (fullCellText) {
@@ -57112,20 +57165,24 @@ const _DataTable = class _DataTable extends React$1.Component {
57112
57165
  if (!row) {
57113
57166
  return;
57114
57167
  } else {
57115
- const rowCopyText = this.getRowCopyText(allRows[i + 1]).split(" ");
57168
+ const jsonRow = [];
57169
+ let [rowCopyText, json] = this.getRowCopyText(allRows[i + 1]);
57170
+ rowCopyText = rowCopyText.split(" ");
57116
57171
  lodashExports.times(row.length, (i2) => {
57117
57172
  const cell = row[i2];
57118
57173
  if (cell) {
57119
57174
  fullCellText += rowCopyText[i2];
57175
+ jsonRow.push(json[i2]);
57120
57176
  }
57121
57177
  if (i2 !== row.length - 1 && i2 >= firstCellIndex)
57122
57178
  fullCellText += " ";
57123
57179
  });
57180
+ fullJson.push(jsonRow);
57124
57181
  }
57125
57182
  });
57126
57183
  if (!fullCellText)
57127
57184
  return window.toastr.warning("No text to copy");
57128
- this.handleCopyHelper(fullCellText, void 0, "Selected cells copied");
57185
+ this.handleCopyHelper(fullCellText, fullJson, "Selected cells copied");
57129
57186
  }, "handleCopySelectedCells"));
57130
57187
  __publicField(this, "handleCopySelectedRows", /* @__PURE__ */ __name((selectedRecords, e2) => {
57131
57188
  const { entities = [] } = computePresets(this.props);
@@ -57142,10 +57199,9 @@ const _DataTable = class _DataTable extends React$1.Component {
57142
57199
  if (!allRowEls)
57143
57200
  return;
57144
57201
  const rowEls = rowNumbersToCopy.map((i) => allRowEls[i]);
57145
- const textToCopy = lodashExports.map(rowEls, (rowEl) => this.getRowCopyText(rowEl)).filter((text2) => text2).join("\n");
57146
- if (!textToCopy)
57147
- return window.toastr.warning("No text to copy");
57148
- this.handleCopyHelper(textToCopy, void 0, "Selected rows copied");
57202
+ this.handleCopyRows(rowEls, {
57203
+ onFinishMsg: "Selected rows copied"
57204
+ });
57149
57205
  } catch (error) {
57150
57206
  console.error(`error:`, error);
57151
57207
  window.toastr.error("Error copying rows.");
@@ -57880,6 +57936,7 @@ const _DataTable = class _DataTable extends React$1.Component {
57880
57936
  }
57881
57937
  const oldFunc = tableColumn.Cell;
57882
57938
  tableColumn.Cell = (...args) => {
57939
+ var _a2;
57883
57940
  const [row] = args;
57884
57941
  const rowId = getIdOrCodeOrIndex(row.original, row.index);
57885
57942
  const cellId = `${rowId}:${row.column.path}`;
@@ -57890,6 +57947,7 @@ const _DataTable = class _DataTable extends React$1.Component {
57890
57947
  const dataTest = {
57891
57948
  "data-test": "tgCell_" + column.path
57892
57949
  };
57950
+ const fullValue = (_a2 = row.original) == null ? void 0 : _a2[row.column.path];
57893
57951
  if (isCellEditable && isBool) {
57894
57952
  val = /* @__PURE__ */ React$1.createElement(
57895
57953
  core$5.Checkbox,
@@ -57912,6 +57970,7 @@ const _DataTable = class _DataTable extends React$1.Component {
57912
57970
  GenericSelectComp,
57913
57971
  __spreadProps(__spreadValues({
57914
57972
  rowId,
57973
+ fullValue,
57915
57974
  initialValue: text2
57916
57975
  }, dataTest), {
57917
57976
  finishEdit: (newVal, doNotStopEditing) => {
@@ -57979,6 +58038,13 @@ const _DataTable = class _DataTable extends React$1.Component {
57979
58038
  }, dataTest), {
57980
58039
  className: "tg-cell-wrapper",
57981
58040
  "data-copy-text": text2,
58041
+ "data-copy-json": JSON.stringify(
58042
+ //tnw: eventually we'll parse these back out and use either the fullValue (for the generic selects) or the regular text vals for everything else
58043
+ column.type === "genericSelect" ? {
58044
+ __strVal: fullValue,
58045
+ __genSelCol: column.path
58046
+ } : { __strVal: text2 }
58047
+ ),
57982
58048
  title: title || void 0
57983
58049
  }),
57984
58050
  val
@@ -58325,8 +58391,13 @@ const _DataTable = class _DataTable extends React$1.Component {
58325
58391
  {
58326
58392
  key: "copyCell",
58327
58393
  onClick: () => {
58394
+ const specificColumn = cellWrapper.getAttribute("data-test");
58395
+ this.handleCopyRows([cellWrapper.closest(".rt-tr")], {
58396
+ specificColumn,
58397
+ onFinishMsg: "Cell copied"
58398
+ });
58328
58399
  const [text2, jsonText] = this.getCellCopyText(cellWrapper);
58329
- this.handleCopyHelper(text2, jsonText, "Cell copied");
58400
+ this.handleCopyHelper(text2, jsonText);
58330
58401
  },
58331
58402
  text: "Cell"
58332
58403
  }
@@ -58368,7 +58439,7 @@ const _DataTable = class _DataTable extends React$1.Component {
58368
58439
  {
58369
58440
  key: "copySelectedRows",
58370
58441
  onClick: () => {
58371
- this.handleCopyRow(row);
58442
+ this.handleCopyRows([row]);
58372
58443
  },
58373
58444
  text: "Row"
58374
58445
  }
@@ -58614,6 +58685,10 @@ const _DataTable = class _DataTable extends React$1.Component {
58614
58685
  "data-test": columnTitleTextified,
58615
58686
  "data-path": path2,
58616
58687
  "data-copy-text": columnTitleTextified,
58688
+ "data-copy-json": JSON.stringify({
58689
+ __strVal: columnTitleTextified,
58690
+ __isHeaderCell: true
58691
+ }),
58617
58692
  className: classNames("tg-react-table-column-header", {
58618
58693
  "sort-active": sortUp || sortDown
58619
58694
  })
@@ -59630,6 +59705,20 @@ function isEntityClean(e2) {
59630
59705
  return isClean;
59631
59706
  }
59632
59707
  __name(isEntityClean, "isEntityClean");
59708
+ const formatPasteData = /* @__PURE__ */ __name(({ schema, newVal, path: path2 }) => {
59709
+ const pathToField = getFieldPathToField(schema);
59710
+ const column = pathToField[path2];
59711
+ if (column.type === "genericSelect") {
59712
+ if ((newVal == null ? void 0 : newVal.__genSelCol) === path2) {
59713
+ newVal = newVal.__strVal;
59714
+ } else {
59715
+ newVal = void 0;
59716
+ }
59717
+ } else {
59718
+ newVal = Object.hasOwn(newVal, "__strVal") ? newVal.__strVal : newVal;
59719
+ }
59720
+ return newVal;
59721
+ }, "formatPasteData");
59633
59722
  const wrapDialog = /* @__PURE__ */ __name((topLevelDialogProps = {}) => (Component) => (props) => {
59634
59723
  const r2 = React$1.useRef();
59635
59724
  const memoedHotkeys = React$1.useMemo(
package/index.es.js CHANGED
@@ -18268,11 +18268,20 @@ function require_domCreate() {
18268
18268
  return _domCreate;
18269
18269
  }
18270
18270
  __name(require_domCreate, "require_domCreate");
18271
- var _ie8DomDefine = !require_descriptors() && !_fails(function() {
18272
- return Object.defineProperty(require_domCreate()("div"), "a", { get: function() {
18273
- return 7;
18274
- } }).a != 7;
18275
- });
18271
+ var _ie8DomDefine;
18272
+ var hasRequired_ie8DomDefine;
18273
+ function require_ie8DomDefine() {
18274
+ if (hasRequired_ie8DomDefine)
18275
+ return _ie8DomDefine;
18276
+ hasRequired_ie8DomDefine = 1;
18277
+ _ie8DomDefine = !require_descriptors() && !_fails(function() {
18278
+ return Object.defineProperty(require_domCreate()("div"), "a", { get: function() {
18279
+ return 7;
18280
+ } }).a != 7;
18281
+ });
18282
+ return _ie8DomDefine;
18283
+ }
18284
+ __name(require_ie8DomDefine, "require_ie8DomDefine");
18276
18285
  var isObject$d = _isObject;
18277
18286
  var _toPrimitive = /* @__PURE__ */ __name(function(it, S2) {
18278
18287
  if (!isObject$d(it))
@@ -18292,7 +18301,7 @@ function require_objectDp() {
18292
18301
  return _objectDp;
18293
18302
  hasRequired_objectDp = 1;
18294
18303
  var anObject2 = _anObject;
18295
- var IE8_DOM_DEFINE2 = _ie8DomDefine;
18304
+ var IE8_DOM_DEFINE2 = require_ie8DomDefine();
18296
18305
  var toPrimitive2 = _toPrimitive;
18297
18306
  var dP2 = Object.defineProperty;
18298
18307
  _objectDp.f = require_descriptors() ? Object.defineProperty : /* @__PURE__ */ __name(function defineProperty5(O2, P2, Attributes) {
@@ -18510,7 +18519,15 @@ var _objectKeys = Object.keys || /* @__PURE__ */ __name(function keys(O2) {
18510
18519
  var _objectGops = {};
18511
18520
  _objectGops.f = Object.getOwnPropertySymbols;
18512
18521
  var _objectPie = {};
18513
- _objectPie.f = {}.propertyIsEnumerable;
18522
+ var hasRequired_objectPie;
18523
+ function require_objectPie() {
18524
+ if (hasRequired_objectPie)
18525
+ return _objectPie;
18526
+ hasRequired_objectPie = 1;
18527
+ _objectPie.f = {}.propertyIsEnumerable;
18528
+ return _objectPie;
18529
+ }
18530
+ __name(require_objectPie, "require_objectPie");
18514
18531
  var defined$1 = _defined;
18515
18532
  var _toObject = /* @__PURE__ */ __name(function(it) {
18516
18533
  return Object(defined$1(it));
@@ -18524,7 +18541,7 @@ function require_objectAssign() {
18524
18541
  var DESCRIPTORS2 = require_descriptors();
18525
18542
  var getKeys2 = _objectKeys;
18526
18543
  var gOPS2 = _objectGops;
18527
- var pIE2 = _objectPie;
18544
+ var pIE2 = require_objectPie();
18528
18545
  var toObject2 = _toObject;
18529
18546
  var IObject2 = require_iobject();
18530
18547
  var $assign = Object.assign;
@@ -19179,7 +19196,7 @@ var _wksDefine = /* @__PURE__ */ __name(function(name) {
19179
19196
  }, "_wksDefine");
19180
19197
  var getKeys = _objectKeys;
19181
19198
  var gOPS$1 = _objectGops;
19182
- var pIE$1 = _objectPie;
19199
+ var pIE$1 = require_objectPie();
19183
19200
  var _enumKeys = /* @__PURE__ */ __name(function(it) {
19184
19201
  var result = getKeys(it);
19185
19202
  var getSymbols2 = gOPS$1.f;
@@ -19220,12 +19237,12 @@ _objectGopnExt.f = /* @__PURE__ */ __name(function getOwnPropertyNames2(it) {
19220
19237
  return windowNames && toString$5.call(it) == "[object Window]" ? getWindowNames(it) : gOPN$1(toIObject$2(it));
19221
19238
  }, "getOwnPropertyNames");
19222
19239
  var _objectGopd = {};
19223
- var pIE = _objectPie;
19240
+ var pIE = require_objectPie();
19224
19241
  var createDesc$1 = _propertyDesc;
19225
19242
  var toIObject$1 = _toIobject;
19226
19243
  var toPrimitive$1 = _toPrimitive;
19227
19244
  var has$6 = _has;
19228
- var IE8_DOM_DEFINE = _ie8DomDefine;
19245
+ var IE8_DOM_DEFINE = require_ie8DomDefine();
19229
19246
  var gOPD$2 = Object.getOwnPropertyDescriptor;
19230
19247
  _objectGopd.f = require_descriptors() ? gOPD$2 : /* @__PURE__ */ __name(function getOwnPropertyDescriptor(O2, P2) {
19231
19248
  O2 = toIObject$1(O2);
@@ -19400,7 +19417,7 @@ if (!USE_NATIVE) {
19400
19417
  $GOPD.f = $getOwnPropertyDescriptor;
19401
19418
  $DP.f = $defineProperty;
19402
19419
  _objectGopn.f = gOPNExt.f = $getOwnPropertyNames;
19403
- _objectPie.f = $propertyIsEnumerable;
19420
+ require_objectPie().f = $propertyIsEnumerable;
19404
19421
  $GOPS.f = $getOwnPropertySymbols;
19405
19422
  if (DESCRIPTORS && !_library) {
19406
19423
  redefine(ObjectProto, "propertyIsEnumerable", $propertyIsEnumerable);
@@ -55792,6 +55809,15 @@ const openColumn = __spreadProps(__spreadValues({}, viewColumn), {
55792
55809
  }
55793
55810
  });
55794
55811
  const dataTableEnhancer = compose(
55812
+ // maybe we need this in some cases?
55813
+ // tgFormValues("reduxFormEntities"),
55814
+ // withProps(props => {
55815
+ // const entities = props.reduxFormEntities || props.entities;
55816
+ // return {
55817
+ // _origEntities: props.entities,
55818
+ // entities
55819
+ // };
55820
+ // }),
55795
55821
  //connect to withTableParams here in the dataTable component so that, in the case that the table is not manually connected,
55796
55822
  withTableParams({
55797
55823
  isLocalCall: true
@@ -56650,13 +56676,14 @@ const _DataTable = class _DataTable extends React__default.Component {
56650
56676
  }, "formatAndValidateEntities"));
56651
56677
  __publicField(this, "formatAndValidateTableInitial", /* @__PURE__ */ __name(() => {
56652
56678
  const {
56653
- _origEntities: entities,
56679
+ _origEntities,
56680
+ entities,
56654
56681
  initialEntities,
56655
56682
  change: change2,
56656
56683
  reduxFormCellValidation
56657
56684
  } = this.props;
56658
56685
  const { newEnts, validationErrors } = this.formatAndValidateEntities(
56659
- initialEntities || entities
56686
+ initialEntities || (entities && entities.length ? entities : _origEntities)
56660
56687
  );
56661
56688
  change2("reduxFormEntities", newEnts);
56662
56689
  const toKeep = {};
@@ -56774,16 +56801,33 @@ const _DataTable = class _DataTable extends React__default.Component {
56774
56801
  } else if (e2.clipboardData && e2.clipboardData.getData) {
56775
56802
  toPaste = e2.clipboardData.getData("text/plain");
56776
56803
  }
56777
- if (toPaste.includes(",")) {
56778
- try {
56779
- const { data, errors } = papaparse.parse(toPaste, {
56780
- header: false
56804
+ const jsonToPaste = e2.clipboardData.getData("application/json");
56805
+ try {
56806
+ const pastedJson = [];
56807
+ JSON.parse(jsonToPaste).forEach((row) => {
56808
+ const newRow = [];
56809
+ Object.values(row).forEach((cell) => {
56810
+ const cellVal = JSON.parse(cell);
56811
+ newRow.push(cellVal);
56781
56812
  });
56782
- if ((data == null ? void 0 : data.length) && !(errors == null ? void 0 : errors.length)) {
56783
- pasteData = data;
56813
+ pastedJson.push(newRow);
56814
+ });
56815
+ pasteData = pastedJson;
56816
+ if (pasteData[0] && pasteData[0][0] && pasteData[0][0].__isHeaderCell) {
56817
+ pasteData = pasteData.slice(1);
56818
+ }
56819
+ } catch (e22) {
56820
+ if (toPaste.includes(",")) {
56821
+ try {
56822
+ const { data, errors } = papaparse.parse(toPaste, {
56823
+ header: false
56824
+ });
56825
+ if ((data == null ? void 0 : data.length) && !(errors == null ? void 0 : errors.length)) {
56826
+ pasteData = data;
56827
+ }
56828
+ } catch (error) {
56829
+ console.error(`error p982qhgpf9qh`, error);
56784
56830
  }
56785
- } catch (error) {
56786
- console.error(`error p982qhgpf9qh`, error);
56787
56831
  }
56788
56832
  }
56789
56833
  pasteData = pasteData.length ? pasteData : defaultParsePaste(toPaste);
@@ -56802,7 +56846,7 @@ const _DataTable = class _DataTable extends React__default.Component {
56802
56846
  entity,
56803
56847
  path: path2,
56804
56848
  schema,
56805
- newVal
56849
+ newVal: formatPasteData({ newVal, path: path2, schema })
56806
56850
  });
56807
56851
  if (error) {
56808
56852
  newCellValidate[cellId] = error;
@@ -56833,8 +56877,8 @@ const _DataTable = class _DataTable extends React__default.Component {
56833
56877
  const indexToPath = lodashExports.invert(pathToIndex);
56834
56878
  const startCellIndex = pathToIndex[primaryCellPath];
56835
56879
  pasteData.forEach((row, i) => {
56836
- row.forEach((cell, j) => {
56837
- if (cell) {
56880
+ row.forEach((newVal, j) => {
56881
+ if (newVal) {
56838
56882
  const cellIndexToChange = startCellIndex + j;
56839
56883
  const entity = entitiesToManipulate[i];
56840
56884
  if (entity) {
@@ -56845,7 +56889,11 @@ const _DataTable = class _DataTable extends React__default.Component {
56845
56889
  entity,
56846
56890
  path: path2,
56847
56891
  schema,
56848
- newVal: cell
56892
+ newVal: formatPasteData({
56893
+ newVal,
56894
+ path: path2,
56895
+ schema
56896
+ })
56849
56897
  });
56850
56898
  const cellId = `${getIdOrCodeOrIndex(entity)}:${path2}`;
56851
56899
  if (!newSelectedCells[cellId]) {
@@ -56955,17 +57003,11 @@ const _DataTable = class _DataTable extends React__default.Component {
56955
57003
  __publicField(this, "getCellCopyText", /* @__PURE__ */ __name((cellWrapper) => {
56956
57004
  const text2 = cellWrapper && cellWrapper.getAttribute("data-copy-text");
56957
57005
  const jsonText = cellWrapper && cellWrapper.getAttribute("data-copy-json");
56958
- const toRet = text2 || cellWrapper.textContent || "";
56959
- return [toRet, jsonText];
57006
+ const textContent = text2 || cellWrapper.textContent || "";
57007
+ return [textContent, jsonText];
56960
57008
  }, "getCellCopyText"));
56961
- __publicField(this, "handleCopyRow", /* @__PURE__ */ __name((rowEl) => {
56962
- const text2 = this.getRowCopyText(rowEl);
56963
- if (!text2)
56964
- return window.toastr.warning("No text to copy");
56965
- this.handleCopyHelper(text2, void 0, "Row Copied");
56966
- }, "handleCopyRow"));
56967
57009
  __publicField(this, "handleCopyColumn", /* @__PURE__ */ __name((e2, cellWrapper, selectedRecords) => {
56968
- const cellType = cellWrapper.getAttribute("data-test");
57010
+ const specificColumn = cellWrapper.getAttribute("data-test");
56969
57011
  let rowElsToCopy = getAllRows(e2);
56970
57012
  if (!rowElsToCopy)
56971
57013
  return;
@@ -56982,14 +57024,24 @@ const _DataTable = class _DataTable extends React__default.Component {
56982
57024
  }
56983
57025
  if (!rowElsToCopy)
56984
57026
  return;
56985
- const textToCopy = lodashExports.map(
56986
- rowElsToCopy,
56987
- (rowEl) => this.getRowCopyText(rowEl, { cellType })
56988
- ).filter((text2) => text2).join("\n");
57027
+ this.handleCopyRows(rowElsToCopy, {
57028
+ specificColumn,
57029
+ onFinishMsg: "Column Copied"
57030
+ });
57031
+ }, "handleCopyColumn"));
57032
+ __publicField(this, "handleCopyRows", /* @__PURE__ */ __name((rowElsToCopy, { specificColumn, onFinishMsg } = {}) => {
57033
+ let textToCopy = [];
57034
+ const jsonToCopy = [];
57035
+ lodashExports.forEach(rowElsToCopy, (rowEl) => {
57036
+ const [t2, j] = this.getRowCopyText(rowEl, { specificColumn });
57037
+ textToCopy.push(t2);
57038
+ jsonToCopy.push(j);
57039
+ });
57040
+ textToCopy = textToCopy.filter((text2) => text2).join("\n");
56989
57041
  if (!textToCopy)
56990
57042
  return window.toastr.warning("No text to copy");
56991
- this.handleCopyHelper(textToCopy, void 0, "Column copied");
56992
- }, "handleCopyColumn"));
57043
+ this.handleCopyHelper(textToCopy, jsonToCopy, onFinishMsg || "Row Copied");
57044
+ }, "handleCopyRows"));
56993
57045
  __publicField(this, "updateEntitiesHelper", /* @__PURE__ */ __name((ents, fn4) => {
56994
57046
  const { change: change2, reduxFormEntitiesUndoRedoStack = { currentVersion: 0 } } = this.props;
56995
57047
  const [nextState, patches, inversePatches] = cn(ents, fn4);
@@ -57008,34 +57060,35 @@ const _DataTable = class _DataTable extends React__default.Component {
57008
57060
  }
57009
57061
  }));
57010
57062
  }, "updateEntitiesHelper"));
57011
- __publicField(this, "getRowCopyText", /* @__PURE__ */ __name((rowEl, { cellType } = {}) => {
57063
+ __publicField(this, "getRowCopyText", /* @__PURE__ */ __name((rowEl, { specificColumn } = {}) => {
57012
57064
  if (!rowEl)
57013
57065
  return;
57014
- return lodashExports.flatMap(rowEl.children, (cellEl) => {
57066
+ const textContent = [];
57067
+ const jsonText = [];
57068
+ lodashExports.forEach(rowEl.children, (cellEl) => {
57015
57069
  const cellChild = cellEl.querySelector(`[data-copy-text]`);
57016
57070
  if (!cellChild) {
57017
- if (cellType)
57071
+ if (specificColumn)
57018
57072
  return [];
57019
57073
  return;
57020
57074
  }
57021
- if (cellType && cellChild.getAttribute("data-test") !== cellType) {
57075
+ if (specificColumn && cellChild.getAttribute("data-test") !== specificColumn) {
57022
57076
  return [];
57023
57077
  }
57024
- return this.getCellCopyText(cellChild);
57025
- }).join(" ");
57078
+ const [t2, j] = this.getCellCopyText(cellChild);
57079
+ textContent.push(t2);
57080
+ jsonText.push(j);
57081
+ });
57082
+ return [lodashExports.flatMap(textContent).join(" "), jsonText];
57026
57083
  }, "getRowCopyText"));
57027
- __publicField(this, "handleCopyHelper", /* @__PURE__ */ __name((stringToCopy, objToCopy, message) => {
57028
- const copyHandler = /* @__PURE__ */ __name((e2) => {
57029
- e2.preventDefault();
57030
- e2.clipboardData.setData("application/json", JSON.stringify(objToCopy));
57031
- e2.clipboardData.setData("text/plain", stringToCopy);
57032
- }, "copyHandler");
57033
- document.addEventListener("copy", copyHandler);
57084
+ __publicField(this, "handleCopyHelper", /* @__PURE__ */ __name((stringToCopy, jsonToCopy, message) => {
57034
57085
  !window.Cypress && copy$1(stringToCopy, {
57086
+ onCopy: (clipboardData) => {
57087
+ clipboardData.setData("application/json", JSON.stringify(jsonToCopy));
57088
+ },
57035
57089
  // keep this so that pasting into spreadsheets works.
57036
57090
  format: "text/plain"
57037
57091
  });
57038
- document.removeEventListener("copy", copyHandler);
57039
57092
  window.toastr.success(message);
57040
57093
  }, "handleCopyHelper"));
57041
57094
  __publicField(this, "handleCopyTable", /* @__PURE__ */ __name((e2) => {
@@ -57043,10 +57096,9 @@ const _DataTable = class _DataTable extends React__default.Component {
57043
57096
  const allRowEls = getAllRows(e2);
57044
57097
  if (!allRowEls)
57045
57098
  return;
57046
- const textToCopy = lodashExports.map(allRowEls, (rowEl) => this.getRowCopyText(rowEl)).filter((text2) => text2).join("\n");
57047
- if (!textToCopy)
57048
- return window.toastr.warning("No text to copy");
57049
- this.handleCopyHelper(textToCopy, void 0, "Table copied");
57099
+ this.handleCopyRows(allRowEls, {
57100
+ onFinishMsg: "Table Copied"
57101
+ });
57050
57102
  } catch (error) {
57051
57103
  console.error(`error:`, error);
57052
57104
  window.toastr.error("Error copying rows.");
@@ -57086,6 +57138,7 @@ const _DataTable = class _DataTable extends React__default.Component {
57086
57138
  return;
57087
57139
  const allRows = getAllRows(e2);
57088
57140
  let fullCellText = "";
57141
+ const fullJson = [];
57089
57142
  lodashExports.times(selectionGrid.length, (i) => {
57090
57143
  const row = selectionGrid[i];
57091
57144
  if (fullCellText) {
@@ -57094,20 +57147,24 @@ const _DataTable = class _DataTable extends React__default.Component {
57094
57147
  if (!row) {
57095
57148
  return;
57096
57149
  } else {
57097
- const rowCopyText = this.getRowCopyText(allRows[i + 1]).split(" ");
57150
+ const jsonRow = [];
57151
+ let [rowCopyText, json] = this.getRowCopyText(allRows[i + 1]);
57152
+ rowCopyText = rowCopyText.split(" ");
57098
57153
  lodashExports.times(row.length, (i2) => {
57099
57154
  const cell = row[i2];
57100
57155
  if (cell) {
57101
57156
  fullCellText += rowCopyText[i2];
57157
+ jsonRow.push(json[i2]);
57102
57158
  }
57103
57159
  if (i2 !== row.length - 1 && i2 >= firstCellIndex)
57104
57160
  fullCellText += " ";
57105
57161
  });
57162
+ fullJson.push(jsonRow);
57106
57163
  }
57107
57164
  });
57108
57165
  if (!fullCellText)
57109
57166
  return window.toastr.warning("No text to copy");
57110
- this.handleCopyHelper(fullCellText, void 0, "Selected cells copied");
57167
+ this.handleCopyHelper(fullCellText, fullJson, "Selected cells copied");
57111
57168
  }, "handleCopySelectedCells"));
57112
57169
  __publicField(this, "handleCopySelectedRows", /* @__PURE__ */ __name((selectedRecords, e2) => {
57113
57170
  const { entities = [] } = computePresets(this.props);
@@ -57124,10 +57181,9 @@ const _DataTable = class _DataTable extends React__default.Component {
57124
57181
  if (!allRowEls)
57125
57182
  return;
57126
57183
  const rowEls = rowNumbersToCopy.map((i) => allRowEls[i]);
57127
- const textToCopy = lodashExports.map(rowEls, (rowEl) => this.getRowCopyText(rowEl)).filter((text2) => text2).join("\n");
57128
- if (!textToCopy)
57129
- return window.toastr.warning("No text to copy");
57130
- this.handleCopyHelper(textToCopy, void 0, "Selected rows copied");
57184
+ this.handleCopyRows(rowEls, {
57185
+ onFinishMsg: "Selected rows copied"
57186
+ });
57131
57187
  } catch (error) {
57132
57188
  console.error(`error:`, error);
57133
57189
  window.toastr.error("Error copying rows.");
@@ -57862,6 +57918,7 @@ const _DataTable = class _DataTable extends React__default.Component {
57862
57918
  }
57863
57919
  const oldFunc = tableColumn.Cell;
57864
57920
  tableColumn.Cell = (...args) => {
57921
+ var _a2;
57865
57922
  const [row] = args;
57866
57923
  const rowId = getIdOrCodeOrIndex(row.original, row.index);
57867
57924
  const cellId = `${rowId}:${row.column.path}`;
@@ -57872,6 +57929,7 @@ const _DataTable = class _DataTable extends React__default.Component {
57872
57929
  const dataTest = {
57873
57930
  "data-test": "tgCell_" + column.path
57874
57931
  };
57932
+ const fullValue = (_a2 = row.original) == null ? void 0 : _a2[row.column.path];
57875
57933
  if (isCellEditable && isBool) {
57876
57934
  val = /* @__PURE__ */ React__default.createElement(
57877
57935
  Checkbox,
@@ -57894,6 +57952,7 @@ const _DataTable = class _DataTable extends React__default.Component {
57894
57952
  GenericSelectComp,
57895
57953
  __spreadProps(__spreadValues({
57896
57954
  rowId,
57955
+ fullValue,
57897
57956
  initialValue: text2
57898
57957
  }, dataTest), {
57899
57958
  finishEdit: (newVal, doNotStopEditing) => {
@@ -57961,6 +58020,13 @@ const _DataTable = class _DataTable extends React__default.Component {
57961
58020
  }, dataTest), {
57962
58021
  className: "tg-cell-wrapper",
57963
58022
  "data-copy-text": text2,
58023
+ "data-copy-json": JSON.stringify(
58024
+ //tnw: eventually we'll parse these back out and use either the fullValue (for the generic selects) or the regular text vals for everything else
58025
+ column.type === "genericSelect" ? {
58026
+ __strVal: fullValue,
58027
+ __genSelCol: column.path
58028
+ } : { __strVal: text2 }
58029
+ ),
57964
58030
  title: title || void 0
57965
58031
  }),
57966
58032
  val
@@ -58307,8 +58373,13 @@ const _DataTable = class _DataTable extends React__default.Component {
58307
58373
  {
58308
58374
  key: "copyCell",
58309
58375
  onClick: () => {
58376
+ const specificColumn = cellWrapper.getAttribute("data-test");
58377
+ this.handleCopyRows([cellWrapper.closest(".rt-tr")], {
58378
+ specificColumn,
58379
+ onFinishMsg: "Cell copied"
58380
+ });
58310
58381
  const [text2, jsonText] = this.getCellCopyText(cellWrapper);
58311
- this.handleCopyHelper(text2, jsonText, "Cell copied");
58382
+ this.handleCopyHelper(text2, jsonText);
58312
58383
  },
58313
58384
  text: "Cell"
58314
58385
  }
@@ -58350,7 +58421,7 @@ const _DataTable = class _DataTable extends React__default.Component {
58350
58421
  {
58351
58422
  key: "copySelectedRows",
58352
58423
  onClick: () => {
58353
- this.handleCopyRow(row);
58424
+ this.handleCopyRows([row]);
58354
58425
  },
58355
58426
  text: "Row"
58356
58427
  }
@@ -58596,6 +58667,10 @@ const _DataTable = class _DataTable extends React__default.Component {
58596
58667
  "data-test": columnTitleTextified,
58597
58668
  "data-path": path2,
58598
58669
  "data-copy-text": columnTitleTextified,
58670
+ "data-copy-json": JSON.stringify({
58671
+ __strVal: columnTitleTextified,
58672
+ __isHeaderCell: true
58673
+ }),
58599
58674
  className: classNames("tg-react-table-column-header", {
58600
58675
  "sort-active": sortUp || sortDown
58601
58676
  })
@@ -59612,6 +59687,20 @@ function isEntityClean(e2) {
59612
59687
  return isClean;
59613
59688
  }
59614
59689
  __name(isEntityClean, "isEntityClean");
59690
+ const formatPasteData = /* @__PURE__ */ __name(({ schema, newVal, path: path2 }) => {
59691
+ const pathToField = getFieldPathToField(schema);
59692
+ const column = pathToField[path2];
59693
+ if (column.type === "genericSelect") {
59694
+ if ((newVal == null ? void 0 : newVal.__genSelCol) === path2) {
59695
+ newVal = newVal.__strVal;
59696
+ } else {
59697
+ newVal = void 0;
59698
+ }
59699
+ } else {
59700
+ newVal = Object.hasOwn(newVal, "__strVal") ? newVal.__strVal : newVal;
59701
+ }
59702
+ return newVal;
59703
+ }, "formatPasteData");
59615
59704
  const wrapDialog = /* @__PURE__ */ __name((topLevelDialogProps = {}) => (Component2) => (props) => {
59616
59705
  const r2 = useRef();
59617
59706
  const memoedHotkeys = useMemo(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teselagen/ui",
3
- "version": "0.3.41",
3
+ "version": "0.3.43",
4
4
  "main": "./src/index.js",
5
5
  "exports": {
6
6
  ".": {
@@ -17,6 +17,15 @@ import tgFormValues from "../utils/tgFormValues";
17
17
  import getTableConfigFromStorage from "./utils/getTableConfigFromStorage";
18
18
 
19
19
  export default compose(
20
+ // maybe we need this in some cases?
21
+ // tgFormValues("reduxFormEntities"),
22
+ // withProps(props => {
23
+ // const entities = props.reduxFormEntities || props.entities;
24
+ // return {
25
+ // _origEntities: props.entities,
26
+ // entities
27
+ // };
28
+ // }),
20
29
  //connect to withTableParams here in the dataTable component so that, in the case that the table is not manually connected,
21
30
  withTableParams({
22
31
  isLocalCall: true
@@ -427,13 +427,15 @@ class DataTable extends React.Component {
427
427
  };
428
428
  formatAndValidateTableInitial = () => {
429
429
  const {
430
- _origEntities: entities,
430
+ _origEntities,
431
+ entities,
431
432
  initialEntities,
432
433
  change,
433
434
  reduxFormCellValidation
434
435
  } = this.props;
435
436
  const { newEnts, validationErrors } = this.formatAndValidateEntities(
436
- initialEntities || entities
437
+ initialEntities ||
438
+ (entities && entities.length ? entities : _origEntities)
437
439
  );
438
440
  change("reduxFormEntities", newEnts);
439
441
  const toKeep = {};
@@ -616,17 +618,39 @@ class DataTable extends React.Component {
616
618
  } else if (e.clipboardData && e.clipboardData.getData) {
617
619
  toPaste = e.clipboardData.getData("text/plain");
618
620
  }
619
- if (toPaste.includes(",")) {
620
- //try papaparsing it out as a csv if it contains commas
621
- try {
622
- const { data, errors } = papaparse.parse(toPaste, {
623
- header: false
621
+ const jsonToPaste = e.clipboardData.getData("application/json");
622
+ try {
623
+ const pastedJson = [];
624
+ JSON.parse(jsonToPaste).forEach(row => {
625
+ const newRow = [];
626
+ Object.values(row).forEach(cell => {
627
+ const cellVal = JSON.parse(cell);
628
+ newRow.push(cellVal);
624
629
  });
625
- if (data?.length && !errors?.length) {
626
- pasteData = data;
630
+ pastedJson.push(newRow);
631
+ });
632
+ pasteData = pastedJson;
633
+ // try to remove the header row if it exists
634
+ if (
635
+ pasteData[0] &&
636
+ pasteData[0][0] &&
637
+ pasteData[0][0].__isHeaderCell
638
+ ) {
639
+ pasteData = pasteData.slice(1);
640
+ }
641
+ } catch (e) {
642
+ if (toPaste.includes(",")) {
643
+ //try papaparsing it out as a csv if it contains commas
644
+ try {
645
+ const { data, errors } = papaparse.parse(toPaste, {
646
+ header: false
647
+ });
648
+ if (data?.length && !errors?.length) {
649
+ pasteData = data;
650
+ }
651
+ } catch (error) {
652
+ console.error(`error p982qhgpf9qh`, error);
627
653
  }
628
- } catch (error) {
629
- console.error(`error p982qhgpf9qh`, error);
630
654
  }
631
655
  }
632
656
  pasteData = pasteData.length ? pasteData : defaultParsePaste(toPaste);
@@ -643,13 +667,14 @@ class DataTable extends React.Component {
643
667
  const entityIdToEntity = getEntityIdToEntity(entities);
644
668
  Object.keys(reduxFormSelectedCells).forEach(cellId => {
645
669
  const [rowId, path] = cellId.split(":");
670
+
646
671
  const entity = entityIdToEntity[rowId].e;
647
672
  delete entity._isClean;
648
673
  const { error } = editCellHelper({
649
674
  entity,
650
675
  path,
651
676
  schema,
652
- newVal
677
+ newVal: formatPasteData({ newVal, path, schema })
653
678
  });
654
679
  if (error) {
655
680
  newCellValidate[cellId] = error;
@@ -684,8 +709,8 @@ class DataTable extends React.Component {
684
709
  const indexToPath = invert(pathToIndex);
685
710
  const startCellIndex = pathToIndex[primaryCellPath];
686
711
  pasteData.forEach((row, i) => {
687
- row.forEach((cell, j) => {
688
- if (cell) {
712
+ row.forEach((newVal, j) => {
713
+ if (newVal) {
689
714
  const cellIndexToChange = startCellIndex + j;
690
715
  const entity = entitiesToManipulate[i];
691
716
  if (entity) {
@@ -696,7 +721,11 @@ class DataTable extends React.Component {
696
721
  entity,
697
722
  path,
698
723
  schema,
699
- newVal: cell
724
+ newVal: formatPasteData({
725
+ newVal,
726
+ path,
727
+ schema
728
+ })
700
729
  });
701
730
  const cellId = `${getIdOrCodeOrIndex(entity)}:${path}`;
702
731
  if (!newSelectedCells[cellId]) {
@@ -812,18 +841,12 @@ class DataTable extends React.Component {
812
841
  const text = cellWrapper && cellWrapper.getAttribute("data-copy-text");
813
842
  const jsonText = cellWrapper && cellWrapper.getAttribute("data-copy-json");
814
843
 
815
- const toRet = text || cellWrapper.textContent || "";
816
- return [toRet, jsonText];
844
+ const textContent = text || cellWrapper.textContent || "";
845
+ return [textContent, jsonText];
817
846
  };
818
847
 
819
- handleCopyRow = rowEl => {
820
- //takes in a row element
821
- const text = this.getRowCopyText(rowEl);
822
- if (!text) return window.toastr.warning("No text to copy");
823
- this.handleCopyHelper(text, undefined, "Row Copied");
824
- };
825
848
  handleCopyColumn = (e, cellWrapper, selectedRecords) => {
826
- const cellType = cellWrapper.getAttribute("data-test");
849
+ const specificColumn = cellWrapper.getAttribute("data-test");
827
850
  let rowElsToCopy = getAllRows(e);
828
851
  if (!rowElsToCopy) return;
829
852
  if (selectedRecords) {
@@ -834,14 +857,23 @@ class DataTable extends React.Component {
834
857
  });
835
858
  }
836
859
  if (!rowElsToCopy) return;
837
- const textToCopy = map(rowElsToCopy, rowEl =>
838
- this.getRowCopyText(rowEl, { cellType })
839
- )
840
- .filter(text => text)
841
- .join("\n");
860
+ this.handleCopyRows(rowElsToCopy, {
861
+ specificColumn,
862
+ onFinishMsg: "Column Copied"
863
+ });
864
+ };
865
+ handleCopyRows = (rowElsToCopy, { specificColumn, onFinishMsg } = {}) => {
866
+ let textToCopy = [];
867
+ const jsonToCopy = [];
868
+ forEach(rowElsToCopy, rowEl => {
869
+ const [t, j] = this.getRowCopyText(rowEl, { specificColumn });
870
+ textToCopy.push(t);
871
+ jsonToCopy.push(j);
872
+ });
873
+ textToCopy = textToCopy.filter(text => text).join("\n");
842
874
  if (!textToCopy) return window.toastr.warning("No text to copy");
843
875
 
844
- this.handleCopyHelper(textToCopy, undefined, "Column copied");
876
+ this.handleCopyHelper(textToCopy, jsonToCopy, onFinishMsg || "Row Copied");
845
877
  };
846
878
  updateEntitiesHelper = (ents, fn) => {
847
879
  const { change, reduxFormEntitiesUndoRedoStack = { currentVersion: 0 } } =
@@ -863,36 +895,41 @@ class DataTable extends React.Component {
863
895
  });
864
896
  };
865
897
 
866
- getRowCopyText = (rowEl, { cellType } = {}) => {
898
+ getRowCopyText = (rowEl, { specificColumn } = {}) => {
867
899
  //takes in a row element
868
900
  if (!rowEl) return;
869
- return flatMap(rowEl.children, cellEl => {
901
+ const textContent = [];
902
+ const jsonText = [];
903
+
904
+ forEach(rowEl.children, cellEl => {
870
905
  const cellChild = cellEl.querySelector(`[data-copy-text]`);
871
906
  if (!cellChild) {
872
- if (cellType) return []; //strip it
907
+ if (specificColumn) return []; //strip it
873
908
  return; //just leave it blank
874
909
  }
875
- if (cellType && cellChild.getAttribute("data-test") !== cellType) {
910
+ if (
911
+ specificColumn &&
912
+ cellChild.getAttribute("data-test") !== specificColumn
913
+ ) {
876
914
  return [];
877
915
  }
878
- return this.getCellCopyText(cellChild);
879
- }).join("\t");
880
- };
916
+ const [t, j] = this.getCellCopyText(cellChild);
917
+ textContent.push(t);
918
+ jsonText.push(j);
919
+ });
881
920
 
882
- handleCopyHelper = (stringToCopy, objToCopy, message) => {
883
- const copyHandler = e => {
884
- e.preventDefault();
921
+ return [flatMap(textContent).join("\t"), jsonText];
922
+ };
885
923
 
886
- e.clipboardData.setData("application/json", JSON.stringify(objToCopy));
887
- e.clipboardData.setData("text/plain", stringToCopy);
888
- };
889
- document.addEventListener("copy", copyHandler);
924
+ handleCopyHelper = (stringToCopy, jsonToCopy, message) => {
890
925
  !window.Cypress &&
891
926
  copy(stringToCopy, {
927
+ onCopy: clipboardData => {
928
+ clipboardData.setData("application/json", JSON.stringify(jsonToCopy));
929
+ },
892
930
  // keep this so that pasting into spreadsheets works.
893
931
  format: "text/plain"
894
932
  });
895
- document.removeEventListener("copy", copyHandler);
896
933
  window.toastr.success(message);
897
934
  };
898
935
 
@@ -900,13 +937,9 @@ class DataTable extends React.Component {
900
937
  try {
901
938
  const allRowEls = getAllRows(e);
902
939
  if (!allRowEls) return;
903
- //get row elements and call this.handleCopyRow for each
904
- const textToCopy = map(allRowEls, rowEl => this.getRowCopyText(rowEl))
905
- .filter(text => text)
906
- .join("\n");
907
- if (!textToCopy) return window.toastr.warning("No text to copy");
908
-
909
- this.handleCopyHelper(textToCopy, undefined, "Table copied");
940
+ this.handleCopyRows(allRowEls, {
941
+ onFinishMsg: "Table Copied"
942
+ });
910
943
  } catch (error) {
911
944
  console.error(`error:`, error);
912
945
  window.toastr.error("Error copying rows.");
@@ -946,6 +979,7 @@ class DataTable extends React.Component {
946
979
  if (firstRowIndex === undefined) return;
947
980
  const allRows = getAllRows(e);
948
981
  let fullCellText = "";
982
+ const fullJson = [];
949
983
  times(selectionGrid.length, i => {
950
984
  const row = selectionGrid[i];
951
985
  if (fullCellText) {
@@ -954,20 +988,24 @@ class DataTable extends React.Component {
954
988
  if (!row) {
955
989
  return;
956
990
  } else {
991
+ const jsonRow = [];
957
992
  // ignore header
958
- const rowCopyText = this.getRowCopyText(allRows[i + 1]).split("\t");
993
+ let [rowCopyText, json] = this.getRowCopyText(allRows[i + 1]);
994
+ rowCopyText = rowCopyText.split("\t");
959
995
  times(row.length, i => {
960
996
  const cell = row[i];
961
997
  if (cell) {
962
998
  fullCellText += rowCopyText[i];
999
+ jsonRow.push(json[i]);
963
1000
  }
964
1001
  if (i !== row.length - 1 && i >= firstCellIndex) fullCellText += "\t";
965
1002
  });
1003
+ fullJson.push(jsonRow);
966
1004
  }
967
1005
  });
968
1006
  if (!fullCellText) return window.toastr.warning("No text to copy");
969
1007
 
970
- this.handleCopyHelper(fullCellText, undefined, "Selected cells copied");
1008
+ this.handleCopyHelper(fullCellText, fullJson, "Selected cells copied");
971
1009
  };
972
1010
 
973
1011
  handleCopySelectedRows = (selectedRecords, e) => {
@@ -990,13 +1028,9 @@ class DataTable extends React.Component {
990
1028
  if (!allRowEls) return;
991
1029
  const rowEls = rowNumbersToCopy.map(i => allRowEls[i]);
992
1030
 
993
- //get row elements and call this.handleCopyRow for each const rowEls = this.getRowEls(rowNumbersToCopy)
994
- const textToCopy = map(rowEls, rowEl => this.getRowCopyText(rowEl))
995
- .filter(text => text)
996
- .join("\n");
997
- if (!textToCopy) return window.toastr.warning("No text to copy");
998
-
999
- this.handleCopyHelper(textToCopy, undefined, "Selected rows copied");
1031
+ this.handleCopyRows(rowEls, {
1032
+ onFinishMsg: "Selected rows copied"
1033
+ });
1000
1034
  } catch (error) {
1001
1035
  console.error(`error:`, error);
1002
1036
  window.toastr.error("Error copying rows.");
@@ -2489,6 +2523,7 @@ class DataTable extends React.Component {
2489
2523
  const dataTest = {
2490
2524
  "data-test": "tgCell_" + column.path
2491
2525
  };
2526
+ const fullValue = row.original?.[row.column.path];
2492
2527
  if (isCellEditable && isBool) {
2493
2528
  val = (
2494
2529
  <Checkbox
@@ -2510,9 +2545,11 @@ class DataTable extends React.Component {
2510
2545
  if (reduxFormEditingCell === cellId) {
2511
2546
  if (column.type === "genericSelect") {
2512
2547
  const GenericSelectComp = column.GenericSelectComp;
2548
+
2513
2549
  return (
2514
2550
  <GenericSelectComp
2515
2551
  rowId={rowId}
2552
+ fullValue={fullValue}
2516
2553
  initialValue={text}
2517
2554
  {...dataTest}
2518
2555
  finishEdit={(newVal, doNotStopEditing) => {
@@ -2568,7 +2605,7 @@ class DataTable extends React.Component {
2568
2605
  // return getIdOrCodeOrIndex(e, i) === rowId2;
2569
2606
  // });
2570
2607
  // }
2571
-
2608
+ // if ()
2572
2609
  const {
2573
2610
  isRect,
2574
2611
  selectionGrid,
@@ -2577,6 +2614,7 @@ class DataTable extends React.Component {
2577
2614
  entityMap,
2578
2615
  pathToIndex
2579
2616
  } = this.isSelectionARectangle();
2617
+ // const __isHeaderCell =
2580
2618
  return (
2581
2619
  <>
2582
2620
  <div
@@ -2589,6 +2627,15 @@ class DataTable extends React.Component {
2589
2627
  {...dataTest}
2590
2628
  className="tg-cell-wrapper"
2591
2629
  data-copy-text={text}
2630
+ data-copy-json={JSON.stringify(
2631
+ //tnw: eventually we'll parse these back out and use either the fullValue (for the generic selects) or the regular text vals for everything else
2632
+ column.type === "genericSelect"
2633
+ ? {
2634
+ __strVal: fullValue,
2635
+ __genSelCol: column.path
2636
+ }
2637
+ : { __strVal: text }
2638
+ )}
2592
2639
  title={title || undefined}
2593
2640
  >
2594
2641
  {val}
@@ -2992,8 +3039,13 @@ class DataTable extends React.Component {
2992
3039
  onClick={() => {
2993
3040
  //TODOCOPY: we need to make sure that the cell copy is being used by the row copy.. right now we have 2 different things going on
2994
3041
  //do we need to be able to copy hidden cells? It seems like it should just copy what's on the page..?
3042
+ const specificColumn = cellWrapper.getAttribute("data-test");
3043
+ this.handleCopyRows([cellWrapper.closest(".rt-tr")], {
3044
+ specificColumn,
3045
+ onFinishMsg: "Cell copied"
3046
+ });
2995
3047
  const [text, jsonText] = this.getCellCopyText(cellWrapper);
2996
- this.handleCopyHelper(text, jsonText, "Cell copied");
3048
+ this.handleCopyHelper(text, jsonText);
2997
3049
  }}
2998
3050
  text="Cell"
2999
3051
  />
@@ -3031,7 +3083,7 @@ class DataTable extends React.Component {
3031
3083
  <MenuItem
3032
3084
  key="copySelectedRows"
3033
3085
  onClick={() => {
3034
- this.handleCopyRow(row);
3086
+ this.handleCopyRows([row]);
3035
3087
  // loop through each cell in the row
3036
3088
  }}
3037
3089
  text="Row"
@@ -3296,6 +3348,10 @@ class DataTable extends React.Component {
3296
3348
  data-test={columnTitleTextified}
3297
3349
  data-path={path}
3298
3350
  data-copy-text={columnTitleTextified}
3351
+ data-copy-json={JSON.stringify({
3352
+ __strVal: columnTitleTextified,
3353
+ __isHeaderCell: true
3354
+ })}
3299
3355
  className={classNames("tg-react-table-column-header", {
3300
3356
  "sort-active": sortUp || sortDown
3301
3357
  })}
@@ -3633,3 +3689,18 @@ export function isEntityClean(e) {
3633
3689
  });
3634
3690
  return isClean;
3635
3691
  }
3692
+
3693
+ const formatPasteData = ({ schema, newVal, path }) => {
3694
+ const pathToField = getFieldPathToField(schema);
3695
+ const column = pathToField[path];
3696
+ if (column.type === "genericSelect") {
3697
+ if (newVal?.__genSelCol === path) {
3698
+ newVal = newVal.__strVal;
3699
+ } else {
3700
+ newVal = undefined;
3701
+ }
3702
+ } else {
3703
+ newVal = Object.hasOwn(newVal, "__strVal") ? newVal.__strVal : newVal;
3704
+ }
3705
+ return newVal;
3706
+ };