@teselagen/ui 0.5.23-beta.15 → 0.5.23-beta.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs.js CHANGED
@@ -19673,30 +19673,6 @@ var dayjs_min = { exports: {} };
19673
19673
  var dayjs_minExports = dayjs_min.exports;
19674
19674
  const dayjs = /* @__PURE__ */ getDefaultExportFromCjs(dayjs_minExports);
19675
19675
  const defaultPageSizes = [5, 10, 15, 25, 50, 100, 200, 400];
19676
- function getMergedOpts(topLevel = {}, instanceLevel = {}) {
19677
- const merged = __spreadValues(__spreadValues({}, topLevel), instanceLevel);
19678
- return __spreadProps(__spreadValues({
19679
- formName: "tgDataTable"
19680
- }, merged), {
19681
- pageSize: merged.controlled_pageSize || merged.pageSize,
19682
- defaults: __spreadValues(__spreadValues({
19683
- pageSize: merged.controlled_pageSize || 25,
19684
- order: [],
19685
- //[-name, statusCode] //an array of camelCase display names with - sign to denote reverse
19686
- searchTerm: "",
19687
- page: 1,
19688
- filters: [
19689
- //filters look like this:
19690
- // {
19691
- // selectedFilter: 'textContains', //camel case
19692
- // filterOn: ccDisplayName, //camel case display name if available and string, otherwise path
19693
- // filterValue: 'thomas',
19694
- // }
19695
- ]
19696
- }, topLevel.defaults || {}), instanceLevel.defaults || {})
19697
- });
19698
- }
19699
- __name(getMergedOpts, "getMergedOpts");
19700
19676
  function safeStringify(val) {
19701
19677
  if (val !== null && typeof val === "object") {
19702
19678
  return JSON.stringify(val);
@@ -47136,13 +47112,13 @@ const DropdownCell = /* @__PURE__ */ __name(({
47136
47112
  );
47137
47113
  }, "DropdownCell");
47138
47114
  const EditableCell = /* @__PURE__ */ __name(({
47139
- value,
47140
- setValue,
47141
47115
  cancelEdit,
47142
47116
  dataTest,
47143
47117
  finishEdit,
47144
- isNumeric
47118
+ isNumeric,
47119
+ initialValue
47145
47120
  }) => {
47121
+ const [value, setValue] = React$1.useState(initialValue);
47146
47122
  const inputRef = React$1.useRef(null);
47147
47123
  React$1.useEffect(() => {
47148
47124
  if (inputRef.current) {
@@ -47556,11 +47532,9 @@ const RenderCell = /* @__PURE__ */ __name(({
47556
47532
  isCellEditable,
47557
47533
  isEntityDisabled,
47558
47534
  finishCellEdit,
47535
+ formName,
47559
47536
  noEllipsis,
47560
- editingCell,
47561
47537
  cancelCellEdit,
47562
- editableCellValue,
47563
- setEditableCellValue,
47564
47538
  getCellHoverText,
47565
47539
  selectedCells,
47566
47540
  isSelectionARectangle,
@@ -47570,32 +47544,24 @@ const RenderCell = /* @__PURE__ */ __name(({
47570
47544
  args
47571
47545
  }) => {
47572
47546
  var _a;
47547
+ const editingCell = reactRedux.useSelector(
47548
+ (state) => {
47549
+ var _a2, _b, _c;
47550
+ return (_c = (_b = (_a2 = state.form) == null ? void 0 : _a2[formName]) == null ? void 0 : _b.values) == null ? void 0 : _c.editingCell;
47551
+ }
47552
+ );
47573
47553
  const [row] = args;
47574
47554
  const rowId = getIdOrCodeOrIndex(row.original, row.index);
47575
47555
  const cellId = `${rowId}:${row.column.path}`;
47556
+ const isEditingCell = editingCell === cellId;
47576
47557
  let val = oldFunc(...args);
47577
47558
  const oldVal = val;
47578
47559
  const text2 = getCopyTextForCell(val, row, column);
47579
- const isBool = column.type === "boolean";
47580
47560
  const dataTest = {
47581
47561
  "data-test": "tgCell_" + column.path
47582
47562
  };
47583
47563
  const fullValue = (_a = row.original) == null ? void 0 : _a[row.column.path];
47584
- if (isCellEditable && isBool) {
47585
- val = /* @__PURE__ */ React$1.createElement(
47586
- core.Checkbox,
47587
- {
47588
- disabled: isEntityDisabled(row.original),
47589
- className: "tg-cell-edit-boolean-checkbox",
47590
- checked: oldVal === "True",
47591
- onChange: (e2) => {
47592
- const checked = e2.target.checked;
47593
- finishCellEdit(cellId, checked);
47594
- }
47595
- }
47596
- );
47597
- noEllipsis = true;
47598
- } else if (editingCell === cellId) {
47564
+ if (isEditingCell) {
47599
47565
  if (column.type === "genericSelect") {
47600
47566
  const GenericSelectComp = column.GenericSelectComp;
47601
47567
  return /* @__PURE__ */ React$1.createElement(
@@ -47631,8 +47597,6 @@ const RenderCell = /* @__PURE__ */ __name(({
47631
47597
  return /* @__PURE__ */ React$1.createElement(
47632
47598
  EditableCell,
47633
47599
  {
47634
- value: editableCellValue,
47635
- setValue: setEditableCellValue,
47636
47600
  dataTest,
47637
47601
  cancelEdit: cancelCellEdit,
47638
47602
  isNumeric: column.type === "number",
@@ -47644,6 +47608,22 @@ const RenderCell = /* @__PURE__ */ __name(({
47644
47608
  );
47645
47609
  }
47646
47610
  }
47611
+ const isBool = column.type === "boolean";
47612
+ if (isCellEditable && isBool) {
47613
+ val = /* @__PURE__ */ React$1.createElement(
47614
+ core.Checkbox,
47615
+ {
47616
+ disabled: isEntityDisabled(row.original),
47617
+ className: "tg-cell-edit-boolean-checkbox",
47618
+ checked: oldVal === "True",
47619
+ onChange: (e2) => {
47620
+ const checked = e2.target.checked;
47621
+ finishCellEdit(cellId, checked);
47622
+ }
47623
+ }
47624
+ );
47625
+ noEllipsis = true;
47626
+ }
47647
47627
  let title = text2;
47648
47628
  if (getCellHoverText)
47649
47629
  title = getCellHoverText(...args);
@@ -47710,20 +47690,19 @@ const RenderCell = /* @__PURE__ */ __name(({
47710
47690
  }
47711
47691
  ));
47712
47692
  }, "RenderCell");
47713
- const RenderColumns = /* @__PURE__ */ __name(({
47693
+ const useColumns = /* @__PURE__ */ __name(({
47714
47694
  addFilters,
47715
47695
  cellRenderer,
47716
- change,
47717
47696
  columns,
47718
47697
  currentParams,
47719
47698
  compact: compact3,
47720
- editableCellValue,
47721
47699
  editingCell,
47722
47700
  editingCellSelectAll,
47723
47701
  entities,
47724
47702
  expandedEntityIdMap,
47725
47703
  extraCompact,
47726
47704
  filters,
47705
+ formName,
47727
47706
  getCellHoverText,
47728
47707
  isCellEditable,
47729
47708
  isEntityDisabled,
@@ -47747,7 +47726,6 @@ const RenderColumns = /* @__PURE__ */ __name(({
47747
47726
  removeSingleFilter = noop$3,
47748
47727
  schema,
47749
47728
  selectedCells,
47750
- setEditableCellValue,
47751
47729
  setEditingCell,
47752
47730
  setExpandedEntityIdMap,
47753
47731
  setNewParams,
@@ -47764,220 +47742,332 @@ const RenderColumns = /* @__PURE__ */ __name(({
47764
47742
  withFilter: _withFilter,
47765
47743
  withSort = true
47766
47744
  }) => {
47745
+ const dispatch = reactRedux.useDispatch();
47746
+ const change = React$1.useCallback(
47747
+ (...args) => dispatch(reduxForm.change(formName, ...args)),
47748
+ [dispatch, formName]
47749
+ );
47767
47750
  const withFilter = _withFilter === void 0 ? !isSimple : _withFilter;
47768
- const onDragEnd = /* @__PURE__ */ __name((cellsToSelect) => {
47769
- const [primaryRowId, primaryCellPath] = primarySelectedCellId.split(":");
47770
- const pathToField = getFieldPathToField(schema);
47771
- const { selectedPaths, selectionGrid } = isSelectionARectangle();
47772
- let allSelectedPaths = selectedPaths;
47773
- if (!allSelectedPaths) {
47774
- allSelectedPaths = [primaryCellPath];
47775
- }
47776
- updateEntitiesHelper(entities, (entities2) => {
47777
- var _a, _b;
47778
- let newSelectedCells;
47779
- if (selectedPaths) {
47780
- newSelectedCells = __spreadValues({}, selectedCells);
47781
- } else {
47782
- newSelectedCells = {
47783
- [primarySelectedCellId]: PRIMARY_SELECTED_VAL
47784
- };
47751
+ const onDragEnd = React$1.useCallback(
47752
+ (cellsToSelect) => {
47753
+ const [primaryRowId, primaryCellPath] = primarySelectedCellId.split(":");
47754
+ const pathToField = getFieldPathToField(schema);
47755
+ const { selectedPaths, selectionGrid } = isSelectionARectangle();
47756
+ let allSelectedPaths = selectedPaths;
47757
+ if (!allSelectedPaths) {
47758
+ allSelectedPaths = [primaryCellPath];
47785
47759
  }
47786
- const newCellValidate = __spreadValues({}, reduxFormCellValidation);
47787
- const entityMap = getEntityIdToEntity(entities2);
47788
- const { e: selectedEnt } = entityMap[primaryRowId];
47789
- const firstCellToSelectRowIndex = (_b = entityMap[(_a = cellsToSelect[0]) == null ? void 0 : _a.split(":")[0]]) == null ? void 0 : _b.i;
47790
- const pathToIndex = getFieldPathToIndex(schema);
47791
- allSelectedPaths.forEach((selectedPath) => {
47792
- const column = pathToField[selectedPath];
47793
- const selectedCellVal = getCellVal(selectedEnt, selectedPath, column);
47794
- const cellIndexOfSelectedPath = pathToIndex[selectedPath];
47795
- let incrementStart;
47796
- let incrementPrefix;
47797
- let incrementPad = 0;
47798
- if (column.type === "string" || column.type === "number") {
47799
- const cellNumStr = getNumberStrAtEnd(selectedCellVal);
47800
- const cellNum = Number(cellNumStr);
47801
- const entityAbovePrimaryCell = entities2[entityMap[primaryRowId].i - 1];
47802
- if (cellNumStr !== null && !isNaN(cellNum)) {
47803
- if (entityAbovePrimaryCell && (!selectionGrid || selectionGrid.length <= 1)) {
47804
- const cellAboveVal = get$5(
47805
- entityAbovePrimaryCell,
47806
- selectedPath,
47807
- ""
47808
- );
47809
- const cellAboveNumStr = getNumberStrAtEnd(cellAboveVal);
47810
- const cellAboveNum = Number(cellAboveNumStr);
47811
- if (!isNaN(cellAboveNum)) {
47812
- const isIncremental = cellNum - cellAboveNum === 1;
47813
- if (isIncremental) {
47814
- const cellTextNoNum = stripNumberAtEnd(selectedCellVal);
47815
- const sameText = stripNumberAtEnd(cellAboveVal) === cellTextNoNum;
47816
- if (sameText) {
47817
- incrementStart = cellNum + 1;
47818
- incrementPrefix = cellTextNoNum || "";
47819
- if (cellNumStr && cellNumStr.startsWith("0")) {
47820
- incrementPad = cellNumStr.length;
47760
+ updateEntitiesHelper(entities, (entities2) => {
47761
+ var _a, _b;
47762
+ let newSelectedCells;
47763
+ if (selectedPaths) {
47764
+ newSelectedCells = __spreadValues({}, selectedCells);
47765
+ } else {
47766
+ newSelectedCells = {
47767
+ [primarySelectedCellId]: PRIMARY_SELECTED_VAL
47768
+ };
47769
+ }
47770
+ const newCellValidate = __spreadValues({}, reduxFormCellValidation);
47771
+ const entityMap = getEntityIdToEntity(entities2);
47772
+ const { e: selectedEnt } = entityMap[primaryRowId];
47773
+ const firstCellToSelectRowIndex = (_b = entityMap[(_a = cellsToSelect[0]) == null ? void 0 : _a.split(":")[0]]) == null ? void 0 : _b.i;
47774
+ const pathToIndex = getFieldPathToIndex(schema);
47775
+ allSelectedPaths.forEach((selectedPath) => {
47776
+ const column = pathToField[selectedPath];
47777
+ const selectedCellVal = getCellVal(selectedEnt, selectedPath, column);
47778
+ const cellIndexOfSelectedPath = pathToIndex[selectedPath];
47779
+ let incrementStart;
47780
+ let incrementPrefix;
47781
+ let incrementPad = 0;
47782
+ if (column.type === "string" || column.type === "number") {
47783
+ const cellNumStr = getNumberStrAtEnd(selectedCellVal);
47784
+ const cellNum = Number(cellNumStr);
47785
+ const entityAbovePrimaryCell = entities2[entityMap[primaryRowId].i - 1];
47786
+ if (cellNumStr !== null && !isNaN(cellNum)) {
47787
+ if (entityAbovePrimaryCell && (!selectionGrid || selectionGrid.length <= 1)) {
47788
+ const cellAboveVal = get$5(
47789
+ entityAbovePrimaryCell,
47790
+ selectedPath,
47791
+ ""
47792
+ );
47793
+ const cellAboveNumStr = getNumberStrAtEnd(cellAboveVal);
47794
+ const cellAboveNum = Number(cellAboveNumStr);
47795
+ if (!isNaN(cellAboveNum)) {
47796
+ const isIncremental = cellNum - cellAboveNum === 1;
47797
+ if (isIncremental) {
47798
+ const cellTextNoNum = stripNumberAtEnd(selectedCellVal);
47799
+ const sameText = stripNumberAtEnd(cellAboveVal) === cellTextNoNum;
47800
+ if (sameText) {
47801
+ incrementStart = cellNum + 1;
47802
+ incrementPrefix = cellTextNoNum || "";
47803
+ if (cellNumStr && cellNumStr.startsWith("0")) {
47804
+ incrementPad = cellNumStr.length;
47805
+ }
47821
47806
  }
47822
47807
  }
47823
47808
  }
47824
47809
  }
47825
- }
47826
- if (incrementStart === void 0) {
47827
- const draggingDown = firstCellToSelectRowIndex > (selectionGrid == null ? void 0 : selectionGrid[0][0].rowIndex);
47828
- if (selectedPaths && draggingDown) {
47829
- let checkIncrement;
47830
- let prefix;
47831
- let maybePad;
47832
- const allAreIncrementing = selectionGrid.every((row) => {
47833
- const cellInfo = row[cellIndexOfSelectedPath];
47834
- if (!cellInfo)
47835
- return false;
47836
- const { cellId } = cellInfo;
47837
- const [rowId] = cellId.split(":");
47838
- const cellVal = getCellVal(
47839
- entityMap[rowId].e,
47840
- selectedPath,
47841
- pathToField[selectedPath]
47842
- );
47843
- const cellNumStr2 = getNumberStrAtEnd(cellVal);
47844
- const cellNum2 = Number(cellNumStr2);
47845
- const cellTextNoNum = stripNumberAtEnd(cellVal);
47846
- if (cellNumStr2 == null ? void 0 : cellNumStr2.startsWith("0")) {
47847
- maybePad = cellNumStr2.length;
47848
- }
47849
- if (cellTextNoNum && !prefix) {
47850
- prefix = cellTextNoNum;
47851
- }
47852
- if (cellTextNoNum && prefix !== cellTextNoNum) {
47853
- return false;
47854
- }
47855
- if (!isNaN(cellNum2)) {
47856
- if (!checkIncrement) {
47857
- checkIncrement = cellNum2;
47858
- return true;
47810
+ if (incrementStart === void 0) {
47811
+ const draggingDown = firstCellToSelectRowIndex > (selectionGrid == null ? void 0 : selectionGrid[0][0].rowIndex);
47812
+ if (selectedPaths && draggingDown) {
47813
+ let checkIncrement;
47814
+ let prefix;
47815
+ let maybePad;
47816
+ const allAreIncrementing = selectionGrid.every((row) => {
47817
+ const cellInfo = row[cellIndexOfSelectedPath];
47818
+ if (!cellInfo)
47819
+ return false;
47820
+ const { cellId } = cellInfo;
47821
+ const [rowId] = cellId.split(":");
47822
+ const cellVal = getCellVal(
47823
+ entityMap[rowId].e,
47824
+ selectedPath,
47825
+ pathToField[selectedPath]
47826
+ );
47827
+ const cellNumStr2 = getNumberStrAtEnd(cellVal);
47828
+ const cellNum2 = Number(cellNumStr2);
47829
+ const cellTextNoNum = stripNumberAtEnd(cellVal);
47830
+ if (cellNumStr2 == null ? void 0 : cellNumStr2.startsWith("0")) {
47831
+ maybePad = cellNumStr2.length;
47832
+ }
47833
+ if (cellTextNoNum && !prefix) {
47834
+ prefix = cellTextNoNum;
47835
+ }
47836
+ if (cellTextNoNum && prefix !== cellTextNoNum) {
47837
+ return false;
47838
+ }
47839
+ if (!isNaN(cellNum2)) {
47840
+ if (!checkIncrement) {
47841
+ checkIncrement = cellNum2;
47842
+ return true;
47843
+ } else {
47844
+ return ++checkIncrement === cellNum2;
47845
+ }
47859
47846
  } else {
47860
- return ++checkIncrement === cellNum2;
47847
+ return false;
47861
47848
  }
47862
- } else {
47863
- return false;
47849
+ });
47850
+ if (allAreIncrementing) {
47851
+ incrementStart = checkIncrement + 1;
47852
+ incrementPrefix = prefix || "";
47853
+ incrementPad = maybePad;
47864
47854
  }
47865
- });
47866
- if (allAreIncrementing) {
47867
- incrementStart = checkIncrement + 1;
47868
- incrementPrefix = prefix || "";
47869
- incrementPad = maybePad;
47870
47855
  }
47871
47856
  }
47872
47857
  }
47873
47858
  }
47874
- }
47875
- let firstSelectedCellRowIndex;
47876
- if (selectionGrid) {
47877
- selectionGrid[0].some((cell) => {
47878
- if (cell) {
47879
- firstSelectedCellRowIndex = cell.rowIndex;
47880
- return true;
47881
- }
47882
- return false;
47883
- });
47884
- }
47885
- cellsToSelect.forEach((cellId) => {
47886
- const [rowId, cellPath] = cellId.split(":");
47887
- if (cellPath !== selectedPath)
47888
- return;
47889
- newSelectedCells[cellId] = true;
47890
- const { e: entityToUpdate, i: rowIndex } = entityMap[rowId] || {};
47891
- if (entityToUpdate) {
47892
- delete entityToUpdate._isClean;
47893
- let newVal;
47894
- if (incrementStart !== void 0) {
47895
- const num = incrementStart++;
47896
- newVal = incrementPrefix + padStart(num, incrementPad, "0");
47897
- } else {
47898
- if (selectionGrid && selectionGrid.length > 1) {
47899
- const draggingDown = rowIndex > firstSelectedCellRowIndex;
47900
- const cellIndex = pathToIndex[cellPath];
47901
- let cellIdToCopy;
47902
- if (draggingDown) {
47903
- const { cellId: cellId2 } = selectionGrid[(rowIndex - firstSelectedCellRowIndex) % selectionGrid.length].find((g2) => g2 && g2.cellIndex === cellIndex);
47904
- cellIdToCopy = cellId2;
47859
+ let firstSelectedCellRowIndex;
47860
+ if (selectionGrid) {
47861
+ selectionGrid[0].some((cell) => {
47862
+ if (cell) {
47863
+ firstSelectedCellRowIndex = cell.rowIndex;
47864
+ return true;
47865
+ }
47866
+ return false;
47867
+ });
47868
+ }
47869
+ cellsToSelect.forEach((cellId) => {
47870
+ const [rowId, cellPath] = cellId.split(":");
47871
+ if (cellPath !== selectedPath)
47872
+ return;
47873
+ newSelectedCells[cellId] = true;
47874
+ const { e: entityToUpdate, i: rowIndex } = entityMap[rowId] || {};
47875
+ if (entityToUpdate) {
47876
+ delete entityToUpdate._isClean;
47877
+ let newVal;
47878
+ if (incrementStart !== void 0) {
47879
+ const num = incrementStart++;
47880
+ newVal = incrementPrefix + padStart(num, incrementPad, "0");
47881
+ } else {
47882
+ if (selectionGrid && selectionGrid.length > 1) {
47883
+ const draggingDown = rowIndex > firstSelectedCellRowIndex;
47884
+ const cellIndex = pathToIndex[cellPath];
47885
+ let cellIdToCopy;
47886
+ if (draggingDown) {
47887
+ const { cellId: cellId2 } = selectionGrid[(rowIndex - firstSelectedCellRowIndex) % selectionGrid.length].find((g2) => g2 && g2.cellIndex === cellIndex);
47888
+ cellIdToCopy = cellId2;
47889
+ } else {
47890
+ const lastIndexInGrid = selectionGrid[selectionGrid.length - 1][0].rowIndex;
47891
+ const { cellId: cellId2 } = selectionGrid[(rowIndex + lastIndexInGrid + 1) % selectionGrid.length].find((g2) => g2.cellIndex === cellIndex);
47892
+ cellIdToCopy = cellId2;
47893
+ }
47894
+ const [rowIdToCopy, cellPathToCopy] = cellIdToCopy.split(":");
47895
+ newVal = getCellVal(
47896
+ entityMap[rowIdToCopy].e,
47897
+ cellPathToCopy,
47898
+ pathToField[cellPathToCopy]
47899
+ );
47905
47900
  } else {
47906
- const lastIndexInGrid = selectionGrid[selectionGrid.length - 1][0].rowIndex;
47907
- const { cellId: cellId2 } = selectionGrid[(rowIndex + lastIndexInGrid + 1) % selectionGrid.length].find((g2) => g2.cellIndex === cellIndex);
47908
- cellIdToCopy = cellId2;
47901
+ newVal = selectedCellVal;
47909
47902
  }
47910
- const [rowIdToCopy, cellPathToCopy] = cellIdToCopy.split(":");
47911
- newVal = getCellVal(
47912
- entityMap[rowIdToCopy].e,
47913
- cellPathToCopy,
47914
- pathToField[cellPathToCopy]
47915
- );
47916
- } else {
47917
- newVal = selectedCellVal;
47918
47903
  }
47904
+ const { error } = editCellHelper({
47905
+ entity: entityToUpdate,
47906
+ path: cellPath,
47907
+ schema,
47908
+ newVal
47909
+ });
47910
+ newCellValidate[cellId] = error;
47919
47911
  }
47920
- const { error } = editCellHelper({
47921
- entity: entityToUpdate,
47922
- path: cellPath,
47923
- schema,
47924
- newVal
47925
- });
47926
- newCellValidate[cellId] = error;
47927
- }
47912
+ });
47928
47913
  });
47914
+ updateValidation(entities2, newCellValidate);
47915
+ setSelectedCells(newSelectedCells);
47929
47916
  });
47930
- updateValidation(entities2, newCellValidate);
47931
- setSelectedCells(newSelectedCells);
47932
- });
47933
- }, "onDragEnd");
47934
- const getCopyTextForCell = /* @__PURE__ */ __name((val, row = {}, column = {}) => {
47935
- let text2 = typeof val !== "string" ? row.value : val;
47936
- const record = row.original;
47937
- if (column.getClipboardData) {
47938
- text2 = column.getClipboardData(row.value, record, row);
47939
- } else if (column.getValueToFilterOn) {
47940
- text2 = column.getValueToFilterOn(record);
47941
- } else if (column.render) {
47942
- text2 = column.render(row.value, record, row, {
47943
- currentParams,
47944
- setNewParams
47945
- });
47946
- } else if (cellRenderer && cellRenderer[column.path]) {
47947
- text2 = cellRenderer[column.path](row.value, row.original, row, {
47948
- currentParams,
47949
- setNewParams
47950
- });
47951
- } else if (text2) {
47952
- text2 = React$1.isValidElement(text2) ? text2 : String(text2);
47953
- }
47954
- const getTextFromElementOrLink = /* @__PURE__ */ __name((text22) => {
47955
- var _a, _b;
47956
- if (React$1.isValidElement(text22)) {
47957
- if ((_a = text22.props) == null ? void 0 : _a.to) {
47958
- return urljoin(
47959
- window.location.origin,
47960
- ((_b = window.frontEndConfig) == null ? void 0 : _b.clientBasePath) || "",
47961
- text22.props.to
47962
- );
47917
+ },
47918
+ [
47919
+ entities,
47920
+ isSelectionARectangle,
47921
+ primarySelectedCellId,
47922
+ reduxFormCellValidation,
47923
+ schema,
47924
+ selectedCells,
47925
+ setSelectedCells,
47926
+ updateEntitiesHelper,
47927
+ updateValidation
47928
+ ]
47929
+ );
47930
+ const getCopyTextForCell = React$1.useCallback(
47931
+ (val, row = {}, column = {}) => {
47932
+ let text2 = typeof val !== "string" ? row.value : val;
47933
+ const record = row.original;
47934
+ if (column.getClipboardData) {
47935
+ text2 = column.getClipboardData(row.value, record, row);
47936
+ } else if (column.getValueToFilterOn) {
47937
+ text2 = column.getValueToFilterOn(record);
47938
+ } else if (column.render) {
47939
+ text2 = column.render(row.value, record, row, {
47940
+ currentParams,
47941
+ setNewParams
47942
+ });
47943
+ } else if (cellRenderer && cellRenderer[column.path]) {
47944
+ text2 = cellRenderer[column.path](row.value, row.original, row, {
47945
+ currentParams,
47946
+ setNewParams
47947
+ });
47948
+ } else if (text2) {
47949
+ text2 = React$1.isValidElement(text2) ? text2 : String(text2);
47950
+ }
47951
+ const getTextFromElementOrLink = /* @__PURE__ */ __name((text22) => {
47952
+ var _a, _b;
47953
+ if (React$1.isValidElement(text22)) {
47954
+ if ((_a = text22.props) == null ? void 0 : _a.to) {
47955
+ return urljoin(
47956
+ window.location.origin,
47957
+ ((_b = window.frontEndConfig) == null ? void 0 : _b.clientBasePath) || "",
47958
+ text22.props.to
47959
+ );
47960
+ } else {
47961
+ return getTextFromEl(text22);
47962
+ }
47963
47963
  } else {
47964
- return getTextFromEl(text22);
47964
+ return text22;
47965
47965
  }
47966
- } else {
47967
- return text22;
47966
+ }, "getTextFromElementOrLink");
47967
+ text2 = getTextFromElementOrLink(text2);
47968
+ if (Array.isArray(text2)) {
47969
+ let arrText = text2.map(getTextFromElementOrLink).join(", ");
47970
+ arrText = arrText.replace(/, ,/g, ",");
47971
+ text2 = arrText;
47968
47972
  }
47969
- }, "getTextFromElementOrLink");
47970
- text2 = getTextFromElementOrLink(text2);
47971
- if (Array.isArray(text2)) {
47972
- let arrText = text2.map(getTextFromElementOrLink).join(", ");
47973
- arrText = arrText.replace(/, ,/g, ",");
47974
- text2 = arrText;
47975
- }
47976
- const stringText = toString$4(text2);
47977
- if (stringText === "[object Object]")
47978
- return "";
47979
- return stringText;
47980
- }, "getCopyTextForCell");
47973
+ const stringText = toString$4(text2);
47974
+ if (stringText === "[object Object]")
47975
+ return "";
47976
+ return stringText;
47977
+ },
47978
+ [cellRenderer, currentParams, setNewParams]
47979
+ );
47980
+ const renderCheckboxCell = React$1.useCallback(
47981
+ (row) => {
47982
+ const rowIndex = row.index;
47983
+ const checkedRows = getSelectedRowsFromEntities(
47984
+ entities,
47985
+ reduxFormSelectedEntityIdMap
47986
+ );
47987
+ const isSelected = checkedRows.some((rowNum) => {
47988
+ return rowNum === rowIndex;
47989
+ });
47990
+ if (rowIndex >= entities.length) {
47991
+ return /* @__PURE__ */ React$1.createElement("div", null);
47992
+ }
47993
+ const entity = entities[rowIndex];
47994
+ return /* @__PURE__ */ React$1.createElement(
47995
+ core.Checkbox,
47996
+ {
47997
+ name: `${getIdOrCodeOrIndex(entity, rowIndex)}-checkbox`,
47998
+ disabled: noSelect || noUserSelect || isEntityDisabled(entity),
47999
+ onClick: (e2) => {
48000
+ rowClick(e2, row, entities, {
48001
+ reduxFormSelectedEntityIdMap,
48002
+ isSingleSelect,
48003
+ noSelect,
48004
+ onRowClick,
48005
+ isEntityDisabled,
48006
+ withCheckboxes,
48007
+ onDeselect,
48008
+ onSingleRowSelect,
48009
+ onMultiRowSelect,
48010
+ noDeselectAll,
48011
+ onRowSelect,
48012
+ change
48013
+ });
48014
+ },
48015
+ checked: isSelected
48016
+ }
48017
+ );
48018
+ },
48019
+ [
48020
+ change,
48021
+ entities,
48022
+ isEntityDisabled,
48023
+ isSingleSelect,
48024
+ noDeselectAll,
48025
+ noSelect,
48026
+ noUserSelect,
48027
+ onDeselect,
48028
+ onMultiRowSelect,
48029
+ onRowClick,
48030
+ onRowSelect,
48031
+ onSingleRowSelect,
48032
+ reduxFormSelectedEntityIdMap,
48033
+ withCheckboxes
48034
+ ]
48035
+ );
48036
+ const finishCellEdit = React$1.useCallback(
48037
+ (cellId, newVal, doNotStopEditing) => {
48038
+ const [rowId, path2] = cellId.split(":");
48039
+ !doNotStopEditing && setEditingCell(null);
48040
+ updateEntitiesHelper(entities, (entities2) => {
48041
+ const entity = entities2.find((e2, i) => {
48042
+ return getIdOrCodeOrIndex(e2, i) === rowId;
48043
+ });
48044
+ delete entity._isClean;
48045
+ const { error } = editCellHelper({
48046
+ entity,
48047
+ path: path2,
48048
+ schema,
48049
+ newVal
48050
+ });
48051
+ updateValidation(entities2, __spreadProps(__spreadValues({}, reduxFormCellValidation), {
48052
+ [cellId]: error
48053
+ }));
48054
+ });
48055
+ !doNotStopEditing && refocusTable();
48056
+ },
48057
+ [
48058
+ entities,
48059
+ reduxFormCellValidation,
48060
+ refocusTable,
48061
+ schema,
48062
+ setEditingCell,
48063
+ updateEntitiesHelper,
48064
+ updateValidation
48065
+ ]
48066
+ );
48067
+ const cancelCellEdit = React$1.useCallback(() => {
48068
+ setEditingCell(null);
48069
+ refocusTable();
48070
+ }, [refocusTable, setEditingCell]);
47981
48071
  if (!columns.length) {
47982
48072
  return columns;
47983
48073
  }
@@ -48037,68 +48127,6 @@ const RenderColumns = /* @__PURE__ */ __name(({
48037
48127
  }
48038
48128
  }));
48039
48129
  }
48040
- const renderCheckboxCell = /* @__PURE__ */ __name((row) => {
48041
- const rowIndex = row.index;
48042
- const checkedRows = getSelectedRowsFromEntities(
48043
- entities,
48044
- reduxFormSelectedEntityIdMap
48045
- );
48046
- const isSelected = checkedRows.some((rowNum) => {
48047
- return rowNum === rowIndex;
48048
- });
48049
- if (rowIndex >= entities.length) {
48050
- return /* @__PURE__ */ React$1.createElement("div", null);
48051
- }
48052
- const entity = entities[rowIndex];
48053
- return /* @__PURE__ */ React$1.createElement(
48054
- core.Checkbox,
48055
- {
48056
- name: `${getIdOrCodeOrIndex(entity, rowIndex)}-checkbox`,
48057
- disabled: noSelect || noUserSelect || isEntityDisabled(entity),
48058
- onClick: (e2) => {
48059
- rowClick(e2, row, entities, {
48060
- reduxFormSelectedEntityIdMap,
48061
- isSingleSelect,
48062
- noSelect,
48063
- onRowClick,
48064
- isEntityDisabled,
48065
- withCheckboxes,
48066
- onDeselect,
48067
- onSingleRowSelect,
48068
- onMultiRowSelect,
48069
- noDeselectAll,
48070
- onRowSelect,
48071
- change
48072
- });
48073
- },
48074
- checked: isSelected
48075
- }
48076
- );
48077
- }, "renderCheckboxCell");
48078
- const finishCellEdit = /* @__PURE__ */ __name((cellId, newVal, doNotStopEditing) => {
48079
- const [rowId, path2] = cellId.split(":");
48080
- !doNotStopEditing && setEditingCell(null);
48081
- updateEntitiesHelper(entities, (entities2) => {
48082
- const entity = entities2.find((e2, i) => {
48083
- return getIdOrCodeOrIndex(e2, i) === rowId;
48084
- });
48085
- delete entity._isClean;
48086
- const { error } = editCellHelper({
48087
- entity,
48088
- path: path2,
48089
- schema,
48090
- newVal
48091
- });
48092
- updateValidation(entities2, __spreadProps(__spreadValues({}, reduxFormCellValidation), {
48093
- [cellId]: error
48094
- }));
48095
- });
48096
- !doNotStopEditing && refocusTable();
48097
- }, "finishCellEdit");
48098
- const cancelCellEdit = /* @__PURE__ */ __name(() => {
48099
- setEditingCell(null);
48100
- refocusTable();
48101
- }, "cancelCellEdit");
48102
48130
  if (withCheckboxes) {
48103
48131
  columnsToRender.push({
48104
48132
  Header: renderCheckboxHeader({
@@ -48131,7 +48159,7 @@ const RenderColumns = /* @__PURE__ */ __name(({
48131
48159
  }
48132
48160
  });
48133
48161
  }
48134
- columns.forEach((column) => {
48162
+ const tableColumns = columns.map((column) => {
48135
48163
  const tableColumn = __spreadProps(__spreadValues({}, column), {
48136
48164
  Header: RenderColumnHeader({
48137
48165
  column,
@@ -48230,8 +48258,6 @@ const RenderColumns = /* @__PURE__ */ __name(({
48230
48258
  noEllipsis,
48231
48259
  editingCell,
48232
48260
  cancelCellEdit,
48233
- editableCellValue,
48234
- setEditableCellValue,
48235
48261
  editingCellSelectAll,
48236
48262
  getCellHoverText,
48237
48263
  selectedCells,
@@ -48242,10 +48268,10 @@ const RenderColumns = /* @__PURE__ */ __name(({
48242
48268
  args
48243
48269
  }
48244
48270
  );
48245
- columnsToRender.push(tableColumn);
48271
+ return tableColumn;
48246
48272
  });
48247
- return columnsToRender;
48248
- }, "RenderColumns");
48273
+ return columnsToRender.concat(tableColumns);
48274
+ }, "useColumns");
48249
48275
  const throwFormError = /* @__PURE__ */ __name((error) => {
48250
48276
  if (error.message) {
48251
48277
  console.error("error:", error);
@@ -48314,10 +48340,13 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
48314
48340
  `No entities array detected in tableParams object (<DataTable {...tableParams}/>). You need to call withQuery() after withTableParams() like: compose(withTableParams(), withQuery(something)).`
48315
48341
  );
48316
48342
  }
48343
+ const dispatch = reactRedux.useDispatch();
48344
+ const change = React$1.useCallback(
48345
+ (...args) => dispatch(reduxForm.change(formName, ...args)),
48346
+ [dispatch, formName]
48347
+ );
48317
48348
  const tableRef = React$1.useRef();
48318
48349
  const alreadySelected = React$1.useRef(false);
48319
- const [editableCellValue, setEditableCellValue] = React$1.useState("");
48320
- const [editingCell, setEditingCell] = React$1.useState(null);
48321
48350
  const [onlyShowRowsWErrors, setOnlyShowRowsWErrors] = React$1.useState(false);
48322
48351
  const [entitiesUndoRedoStack, setEntitiesUndoRedoStack] = React$1.useState({
48323
48352
  currentVersion: 0
@@ -48339,6 +48368,7 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
48339
48368
  });
48340
48369
  const {
48341
48370
  reduxFormCellValidation: _reduxFormCellValidation,
48371
+ reduxFormEditingCell,
48342
48372
  reduxFormEntities: _reduxFormEntities,
48343
48373
  reduxFormQueryParams: _reduxFormQueryParams = {},
48344
48374
  reduxFormSearchInput: _reduxFormSearchInput = "",
@@ -48407,7 +48437,6 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
48407
48437
  }
48408
48438
  const { withPaging = !isSimple } = props;
48409
48439
  const {
48410
- change,
48411
48440
  doNotCoercePageSize,
48412
48441
  isInfinite = isSimple && !withPaging,
48413
48442
  syncDisplayOptionsToDb,
@@ -48428,6 +48457,7 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
48428
48457
  return tmp;
48429
48458
  }, [history, reduxFormQueryParams, reduxFormSearchInput, urlConnected]);
48430
48459
  const currentParams = useDeepEqualMemo(_currentParams);
48460
+ useTraceUpdate({ currentParams });
48431
48461
  const tableParams = React$1.useMemo(() => {
48432
48462
  if (!isTableParamsConnected) {
48433
48463
  const updateSearch = /* @__PURE__ */ __name((val) => {
@@ -48451,10 +48481,10 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
48451
48481
  };
48452
48482
  });
48453
48483
  const changeFormValue = /* @__PURE__ */ __name((...args) => change(...args), "changeFormValue");
48454
- return __spreadProps(__spreadValues(__spreadValues(__spreadValues({
48484
+ return __spreadProps(__spreadValues(__spreadValues({
48455
48485
  changeFormValue,
48456
48486
  selectedEntities
48457
- }, _tableParams), props), boundDispatchProps), {
48487
+ }, _tableParams), boundDispatchProps), {
48458
48488
  isTableParamsConnected: true
48459
48489
  //let the table know not to do local sorting/filtering etc.
48460
48490
  });
@@ -48464,9 +48494,10 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
48464
48494
  _tableParams,
48465
48495
  change,
48466
48496
  currentParams,
48467
- history,
48497
+ history == null ? void 0 : history.replace,
48468
48498
  isTableParamsConnected,
48469
- props,
48499
+ props.defaults,
48500
+ props.onlyOneFilter,
48470
48501
  selectedEntities,
48471
48502
  urlConnected
48472
48503
  ]);
@@ -48505,7 +48536,6 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
48505
48536
  isTableParamsConnected,
48506
48537
  urlConnected
48507
48538
  ]);
48508
- useTraceUpdate(__spreadValues({}, queryParams));
48509
48539
  props = __spreadValues(__spreadValues({}, props), queryParams);
48510
48540
  const {
48511
48541
  addFilters = noop$3,
@@ -48630,7 +48660,7 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
48630
48660
  change
48631
48661
  });
48632
48662
  }
48633
- }, [entitiesAcrossPages, reduxFormSelectedEntityIdMap]);
48663
+ }, [entitiesAcrossPages, reduxFormSelectedEntityIdMap, change]);
48634
48664
  const [tableConfig, setTableConfig] = React$1.useState({ fieldOptions: [] });
48635
48665
  React$1.useEffect(() => {
48636
48666
  let newTableConfig = {};
@@ -48730,6 +48760,7 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
48730
48760
  }
48731
48761
  return schema2;
48732
48762
  }, [
48763
+ cellRenderer,
48733
48764
  convertedSchema,
48734
48765
  currentParams,
48735
48766
  entities,
@@ -48739,7 +48770,7 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
48739
48770
  isSimple,
48740
48771
  isViewable,
48741
48772
  onDoubleClick,
48742
- // setNewParams,
48773
+ setNewParams,
48743
48774
  showForcedHiddenColumns,
48744
48775
  tableConfig.columnOrderings,
48745
48776
  tableConfig.fieldOptions,
@@ -48873,8 +48904,7 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
48873
48904
  });
48874
48905
  change("reduxFormCellValidation", tableWideErr);
48875
48906
  },
48876
- // eslint-disable-next-line react-hooks/exhaustive-deps
48877
- [schema]
48907
+ [schema, change]
48878
48908
  );
48879
48909
  const updateEntitiesHelper = React$1.useCallback(
48880
48910
  (ents, fn4) => {
@@ -49095,21 +49125,20 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
49095
49125
  }
49096
49126
  }, [selectedCells]);
49097
49127
  const startCellEdit = React$1.useCallback(
49098
- (cellId, { pressedKey } = {}) => {
49099
- if (editingCell === cellId)
49100
- return;
49101
- if (pressedKey) {
49102
- setEditableCellValue("");
49103
- } else {
49104
- const [rowId, path2] = cellId.split(":");
49105
- const entityIdToEntity = getEntityIdToEntity(entities);
49106
- const entity = entityIdToEntity[rowId].e;
49107
- setEditableCellValue(entity[path2]);
49108
- }
49109
- setSelectedCells((prev) => __spreadProps(__spreadValues({}, prev), { [cellId]: PRIMARY_SELECTED_VAL }));
49110
- setEditingCell(cellId);
49128
+ (cellId) => {
49129
+ change("reduxFormEditingCell", (prev) => {
49130
+ if (prev === cellId)
49131
+ return cellId;
49132
+ setSelectedCells((prev2) => {
49133
+ if (prev2[cellId] === PRIMARY_SELECTED_VAL) {
49134
+ return prev2;
49135
+ }
49136
+ return __spreadProps(__spreadValues({}, prev2), { [cellId]: PRIMARY_SELECTED_VAL });
49137
+ });
49138
+ return cellId;
49139
+ });
49111
49140
  },
49112
- [editingCell, entities]
49141
+ [change]
49113
49142
  );
49114
49143
  const handleEnterStartCellEdit = React$1.useCallback(
49115
49144
  (e2) => {
@@ -49469,7 +49498,14 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
49469
49498
  updateValidation(newEnts, __spreadValues(__spreadValues({}, toKeep), validationErrors));
49470
49499
  }, "formatAndValidateTableInitial");
49471
49500
  isCellEditable && formatAndValidateTableInitial();
49472
- }, [_origEntities, isCellEditable]);
49501
+ }, [
49502
+ _origEntities,
49503
+ isCellEditable,
49504
+ change,
49505
+ formatAndValidateEntities,
49506
+ reduxFormCellValidation,
49507
+ updateValidation
49508
+ ]);
49473
49509
  const handlePaste = React$1.useCallback(
49474
49510
  (e2) => {
49475
49511
  if (isCellEditable) {
@@ -49620,16 +49656,6 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
49620
49656
  document.removeEventListener("paste", handlePaste);
49621
49657
  };
49622
49658
  }, [handlePaste]);
49623
- React$1.useEffect(() => {
49624
- if (!entities.length && !isLoading && !showForcedHiddenColumns) {
49625
- setShowForcedHidden(true);
49626
- }
49627
- }, [
49628
- entities.length,
49629
- isLoading,
49630
- setShowForcedHidden,
49631
- showForcedHiddenColumns
49632
- ]);
49633
49659
  React$1.useEffect(() => {
49634
49660
  addFilters(additionalFilters);
49635
49661
  }, [additionalFilters]);
@@ -49863,7 +49889,7 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
49863
49889
  return;
49864
49890
  let newSelectedCells = __spreadValues({}, selectedCells);
49865
49891
  if (newSelectedCells[cellId] && !event.shiftKey) {
49866
- if (editingCell === cellId)
49892
+ if (reduxFormEditingCell === cellId)
49867
49893
  return;
49868
49894
  if (event.metaKey) {
49869
49895
  delete newSelectedCells[cellId];
@@ -49928,10 +49954,10 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
49928
49954
  setSelectedCells(newSelectedCells);
49929
49955
  },
49930
49956
  [
49931
- editingCell,
49932
49957
  entities,
49933
49958
  isEntityDisabled,
49934
49959
  primarySelectedCellId,
49960
+ reduxFormEditingCell,
49935
49961
  schema,
49936
49962
  selectedCells
49937
49963
  ]
@@ -50249,8 +50275,8 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
50249
50275
  }
50250
50276
  };
50251
50277
  },
50252
- // eslint-disable-next-line react-hooks/exhaustive-deps
50253
50278
  [
50279
+ change,
50254
50280
  entities,
50255
50281
  expandedEntityIdMap,
50256
50282
  getRowClassName,
@@ -50323,7 +50349,7 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
50323
50349
  noSelectedBottomBorder: !selectedBottomBorder,
50324
50350
  noSelectedLeftBorder: !selectedLeftBorder,
50325
50351
  isDropdownCell: column.type === "dropdown",
50326
- isEditingCell: editingCell === cellId,
50352
+ isEditingCell: reduxFormEditingCell === cellId,
50327
50353
  hasCellError: !!err,
50328
50354
  "no-data-tip": selectedCells[cellId]
50329
50355
  });
@@ -50362,13 +50388,13 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
50362
50388
  },
50363
50389
  [
50364
50390
  doNotValidateUntouchedRows,
50365
- editingCell,
50366
50391
  entities,
50367
50392
  handleCellClick,
50368
50393
  isCellEditable,
50369
50394
  isEntityDisabled,
50370
50395
  primarySelectedCellId,
50371
50396
  reduxFormCellValidation,
50397
+ reduxFormEditingCell,
50372
50398
  schema,
50373
50399
  selectedCells,
50374
50400
  showContextMenu2,
@@ -50565,107 +50591,56 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
50565
50591
  }
50566
50592
  return entities;
50567
50593
  }, [entities, onlyShowRowsWErrors, reduxFormCellValidation]);
50568
- const renderColumns = React$1.useMemo(
50569
- () => RenderColumns({
50570
- addFilters,
50571
- cellRenderer,
50572
- change,
50573
- columns,
50574
- currentParams,
50575
- compact: compact3,
50576
- editableCellValue,
50577
- editingCell,
50578
- editingCellSelectAll,
50579
- entities,
50580
- expandedEntityIdMap,
50581
- extraCompact,
50582
- filters,
50583
- getCellHoverText,
50584
- isCellEditable,
50585
- isEntityDisabled,
50586
- isLocalCall,
50587
- isSimple,
50588
- isSingleSelect,
50589
- isSelectionARectangle,
50590
- noDeselectAll,
50591
- noSelect,
50592
- noUserSelect,
50593
- onDeselect,
50594
- onMultiRowSelect,
50595
- onRowClick,
50596
- onRowSelect,
50597
- onSingleRowSelect,
50598
- order: order2,
50599
- primarySelectedCellId,
50600
- reduxFormCellValidation,
50601
- reduxFormSelectedEntityIdMap,
50602
- refocusTable,
50603
- removeSingleFilter,
50604
- schema,
50605
- selectedCells,
50606
- setEditableCellValue,
50607
- setEditingCell,
50608
- setExpandedEntityIdMap,
50609
- setNewParams,
50610
- setOrder,
50611
- setSelectedCells,
50612
- shouldShowSubComponent,
50613
- startCellEdit,
50614
- SubComponent,
50615
- tableRef,
50616
- updateEntitiesHelper,
50617
- updateValidation,
50618
- withCheckboxes,
50619
- withExpandAndCollapseAllButton,
50620
- withFilter,
50621
- withSort
50622
- }),
50623
- // eslint-disable-next-line react-hooks/exhaustive-deps
50624
- [
50625
- SubComponent,
50626
- columns,
50627
- compact3,
50628
- currentParams,
50629
- editableCellValue,
50630
- editingCell,
50631
- editingCellSelectAll,
50632
- entities,
50633
- expandedEntityIdMap,
50634
- extraCompact,
50635
- filters,
50636
- getCellHoverText,
50637
- isCellEditable,
50638
- isEntityDisabled,
50639
- isLocalCall,
50640
- isSelectionARectangle,
50641
- isSimple,
50642
- isSingleSelect,
50643
- noDeselectAll,
50644
- noSelect,
50645
- noUserSelect,
50646
- onDeselect,
50647
- onMultiRowSelect,
50648
- onRowClick,
50649
- onRowSelect,
50650
- onSingleRowSelect,
50651
- order2,
50652
- primarySelectedCellId,
50653
- reduxFormCellValidation,
50654
- reduxFormSelectedEntityIdMap,
50655
- removeSingleFilter,
50656
- schema,
50657
- selectedCells,
50658
- setOrder,
50659
- shouldShowSubComponent,
50660
- startCellEdit,
50661
- updateEntitiesHelper,
50662
- updateValidation,
50663
- withCheckboxes,
50664
- withExpandAndCollapseAllButton,
50665
- withFilter,
50666
- withSort
50667
- ]
50668
- );
50594
+ const renderColumns = useColumns({
50595
+ addFilters,
50596
+ cellRenderer,
50597
+ columns,
50598
+ currentParams,
50599
+ compact: compact3,
50600
+ editingCellSelectAll,
50601
+ entities,
50602
+ expandedEntityIdMap,
50603
+ extraCompact,
50604
+ filters,
50605
+ formName,
50606
+ getCellHoverText,
50607
+ isCellEditable,
50608
+ isEntityDisabled,
50609
+ isLocalCall,
50610
+ isSimple,
50611
+ isSingleSelect,
50612
+ isSelectionARectangle,
50613
+ noDeselectAll,
50614
+ noSelect,
50615
+ noUserSelect,
50616
+ onDeselect,
50617
+ onMultiRowSelect,
50618
+ onRowClick,
50619
+ onRowSelect,
50620
+ onSingleRowSelect,
50621
+ order: order2,
50622
+ primarySelectedCellId,
50623
+ reduxFormCellValidation,
50624
+ reduxFormSelectedEntityIdMap,
50625
+ refocusTable,
50626
+ removeSingleFilter,
50627
+ schema,
50628
+ selectedCells,
50629
+ setExpandedEntityIdMap,
50630
+ setNewParams,
50631
+ setOrder,
50632
+ setSelectedCells,
50633
+ shouldShowSubComponent,
50634
+ startCellEdit,
50635
+ SubComponent,
50636
+ tableRef,
50637
+ updateEntitiesHelper,
50638
+ updateValidation,
50639
+ withCheckboxes,
50640
+ withExpandAndCollapseAllButton,
50641
+ withFilter,
50642
+ withSort
50643
+ });
50669
50644
  const scrollToTop = React$1.useCallback(
50670
50645
  () => {
50671
50646
  var _a2, _b2, _c2, _d, _e, _f;
@@ -50856,9 +50831,7 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
50856
50831
  if (rowDisabled)
50857
50832
  return;
50858
50833
  e2.stopPropagation();
50859
- startCellEdit(primarySelectedCellId, {
50860
- pressedKey: e2.key
50861
- });
50834
+ startCellEdit(primarySelectedCellId);
50862
50835
  }
50863
50836
  }),
50864
50837
  isCellEditable && entities.length > 50 && // test for this!!
@@ -52901,19 +52874,19 @@ Fuse.config = Config;
52901
52874
  {
52902
52875
  register(ExtendedSearch);
52903
52876
  }
52904
- const getSchema$1 = /* @__PURE__ */ __name((data) => ({
52877
+ const getSchema = /* @__PURE__ */ __name((data) => ({
52905
52878
  fields: map$2(data[0], (val, path2) => {
52906
52879
  return { path: path2, type: "string" };
52907
52880
  }),
52908
52881
  userData: data
52909
- }), "getSchema$1");
52882
+ }), "getSchema");
52910
52883
  function tryToMatchSchemas(_0) {
52911
52884
  return __async(this, arguments, function* ({
52912
52885
  incomingData,
52913
52886
  validateAgainstSchema
52914
52887
  }) {
52915
52888
  yield resolveValidateAgainstSchema();
52916
- const userSchema = getSchema$1(incomingData);
52889
+ const userSchema = getSchema(incomingData);
52917
52890
  const { searchResults, csvValidationIssue, ignoredHeadersMsg } = yield matchSchemas({
52918
52891
  userSchema,
52919
52892
  officialSchema: validateAgainstSchema
@@ -64428,96 +64401,130 @@ const withStore = /* @__PURE__ */ __name((Component) => {
64428
64401
  return /* @__PURE__ */ React$1.createElement(Component, __spreadProps(__spreadValues({}, props), { store }));
64429
64402
  };
64430
64403
  }, "withStore");
64431
- const getSchema = /* @__PURE__ */ __name((options) => {
64432
- const { schema } = options;
64433
- if (isFunction$4(schema))
64434
- return schema(options);
64435
- else
64436
- return schema;
64437
- }, "getSchema");
64438
- function withTableParams(topLevelOptions) {
64439
- const { isLocalCall = false } = topLevelOptions;
64440
- const mapStateToProps = /* @__PURE__ */ __name((state, ownProps) => {
64441
- var _a, _b;
64442
- const mergedOpts = getMergedOpts(topLevelOptions, ownProps);
64443
- const {
64444
- additionalFilter = {},
64445
- additionalOrFilter = {},
64446
- cellRenderer,
64447
- defaults: defaults2,
64448
- doNotCoercePageSize,
64449
- formName,
64450
- history,
64451
- initialValues,
64452
- isCodeModel,
64453
- isInfinite,
64454
- isSimple,
64455
- model,
64456
- noForm,
64457
- noOrderError,
64458
- showEmptyColumnsByDefault,
64459
- syncDisplayOptionsToDb,
64460
- urlConnected,
64461
- withDisplayOptions,
64462
- withPaging,
64463
- withSelectedEntities: withSelectedEntities2
64464
- } = mergedOpts;
64465
- const schema = getSchema(mergedOpts);
64466
- const convertedSchema = convertSchema(schema);
64467
- if (isLocalCall) {
64468
- if (!noForm && (!formName || formName === "tgDataTable")) {
64469
- console.error(
64470
- "Please pass a unique 'formName' prop to the locally connected <DataTable/> component with schema: ",
64471
- schema
64472
- );
64473
- }
64474
- if (mergedOpts.orderByFirstColumn && !((_b = (_a = mergedOpts.defaults) == null ? void 0 : _a.order) == null ? void 0 : _b.length)) {
64475
- const r2 = [getCCDisplayName(convertedSchema.fields[0])];
64476
- set$1(mergedOpts, "defaults.order", r2);
64477
- }
64478
- } else {
64479
- if (!formName || formName === "tgDataTable") {
64480
- console.error(
64481
- "Please pass a unique 'formName' prop to the withTableParams() with schema: ",
64482
- schema
64483
- );
64484
- }
64404
+ const useTableParams = /* @__PURE__ */ __name((props) => {
64405
+ var _a;
64406
+ const {
64407
+ additionalFilter,
64408
+ additionalOrFilter,
64409
+ controlled_pageSize,
64410
+ defaults: _defaults,
64411
+ doNotCoercePageSize,
64412
+ entities,
64413
+ formName = "tgDataTable",
64414
+ history,
64415
+ isCodeModel,
64416
+ isInfinite,
64417
+ isLocalCall = false,
64418
+ isSimple,
64419
+ noForm,
64420
+ noOrderError,
64421
+ onlyOneFilter,
64422
+ orderByFirstColumn,
64423
+ pageSize,
64424
+ schema,
64425
+ syncDisplayOptionsToDb,
64426
+ tableParams: _tableParams,
64427
+ urlConnected,
64428
+ withPaging,
64429
+ withSelectedEntities: withSelectedEntities2
64430
+ } = props;
64431
+ const defaults2 = React$1.useMemo(
64432
+ () => __spreadValues({
64433
+ pageSize: controlled_pageSize || 25,
64434
+ order: [],
64435
+ //[-name, statusCode] //an array of camelCase display names with - sign to denote reverse
64436
+ searchTerm: "",
64437
+ page: 1,
64438
+ filters: [
64439
+ //filters look like this:
64440
+ // {
64441
+ // selectedFilter: 'textContains', //camel case
64442
+ // filterOn: ccDisplayName, //camel case display name if available and string, otherwise path
64443
+ // filterValue: 'thomas',
64444
+ // }
64445
+ ]
64446
+ }, _defaults),
64447
+ [_defaults, controlled_pageSize]
64448
+ );
64449
+ const convertedSchema = React$1.useMemo(() => convertSchema(schema), [schema]);
64450
+ if (isLocalCall) {
64451
+ if (!noForm && (!formName || formName === "tgDataTable")) {
64452
+ console.error(
64453
+ "Please pass a unique 'formName' prop to the locally connected <DataTable/> component with schema: ",
64454
+ schema
64455
+ );
64485
64456
  }
64486
- const tableConfig = getTableConfigFromStorage(formName);
64487
- const formSelector = reduxForm.formValueSelector(formName);
64488
- const currentParams = (urlConnected ? getCurrentParamsFromUrl(history.location) : formSelector(state, "reduxFormQueryParams")) || {};
64489
- const selectedEntities = withSelectedEntities2 ? getRecordsFromReduxForm(state, formName) : void 0;
64490
- const additionalFilterToUse = typeof additionalFilter === "function" ? additionalFilter.bind(this, ownProps) : () => additionalFilter;
64491
- const additionalOrFilterToUse = typeof additionalOrFilter === "function" ? additionalOrFilter.bind(this, ownProps) : () => additionalOrFilter;
64492
- let defaultsToUse = defaults2;
64493
- const userSetPageSize = (tableConfig == null ? void 0 : tableConfig.userSetPageSize) && parseInt(tableConfig.userSetPageSize, 10);
64494
- if (!syncDisplayOptionsToDb && userSetPageSize) {
64495
- defaultsToUse = defaultsToUse || {};
64496
- defaultsToUse.pageSize = userSetPageSize;
64457
+ if (orderByFirstColumn && !((_a = defaults2 == null ? void 0 : defaults2.order) == null ? void 0 : _a.length)) {
64458
+ defaults2.order = [getCCDisplayName(convertedSchema.fields[0])];
64497
64459
  }
64498
- const mapStateProps = __spreadProps(__spreadValues(__spreadProps(__spreadValues({
64499
- history,
64500
- urlConnected,
64501
- withSelectedEntities: withSelectedEntities2,
64502
- formName,
64503
- defaults: defaultsToUse,
64504
- isInfinite,
64505
- isSimple,
64506
- withPaging,
64507
- doNotCoercePageSize,
64508
- additionalFilter,
64509
- additionalOrFilter,
64510
- noOrderError,
64511
- withDisplayOptions,
64512
- cellRenderer,
64513
- isLocalCall,
64514
- model,
64515
- schema,
64516
- mergedOpts
64517
- }, getQueryParams({
64460
+ } else {
64461
+ if (!formName || formName === "tgDataTable") {
64462
+ console.error(
64463
+ "Please pass a unique 'formName' prop to the withTableParams() with schema: ",
64464
+ schema
64465
+ );
64466
+ }
64467
+ }
64468
+ const {
64469
+ reduxFormQueryParams: _reduxFormQueryParams = {},
64470
+ reduxFormSearchInput: _reduxFormSearchInput = "",
64471
+ reduxFormSelectedEntityIdMap: _reduxFormSelectedEntityIdMap = {}
64472
+ } = reactRedux.useSelector(
64473
+ (state) => reduxForm.formValueSelector(formName)(
64474
+ state,
64475
+ "reduxFormQueryParams",
64476
+ "reduxFormSearchInput",
64477
+ "reduxFormSelectedEntityIdMap"
64478
+ )
64479
+ );
64480
+ const reduxFormQueryParams = useDeepEqualMemo(_reduxFormQueryParams);
64481
+ const reduxFormSearchInput = useDeepEqualMemo(_reduxFormSearchInput);
64482
+ const reduxFormSelectedEntityIdMap = useDeepEqualMemo(
64483
+ _reduxFormSelectedEntityIdMap
64484
+ );
64485
+ const _currentParams = React$1.useMemo(() => {
64486
+ const tmp = (urlConnected ? getCurrentParamsFromUrl(history == null ? void 0 : history.location) : reduxFormQueryParams) || {};
64487
+ tmp.searchTerm = reduxFormSearchInput;
64488
+ return tmp;
64489
+ }, [
64490
+ history == null ? void 0 : history.location,
64491
+ reduxFormQueryParams,
64492
+ reduxFormSearchInput,
64493
+ urlConnected
64494
+ ]);
64495
+ const selectedEntities = React$1.useMemo(
64496
+ () => withSelectedEntities2 ? Object.values(reduxFormSelectedEntityIdMap).sort((a2, b2) => a2.rowIndex - b2.rowIndex).map((item) => item.entity) : void 0,
64497
+ [reduxFormSelectedEntityIdMap, withSelectedEntities2]
64498
+ );
64499
+ const currentParams = useDeepEqualMemo(_currentParams);
64500
+ const defaultsToUse = React$1.useMemo(() => {
64501
+ const _tableConfig = getTableConfigFromStorage(formName);
64502
+ const userSetPageSize = (_tableConfig == null ? void 0 : _tableConfig.userSetPageSize) && parseInt(_tableConfig.userSetPageSize, 10);
64503
+ let _defaultsToUse = defaults2;
64504
+ if (!syncDisplayOptionsToDb && userSetPageSize) {
64505
+ _defaultsToUse = _defaultsToUse || {};
64506
+ _defaultsToUse.pageSize = userSetPageSize;
64507
+ }
64508
+ return _defaultsToUse;
64509
+ }, [defaults2, formName, syncDisplayOptionsToDb]);
64510
+ const passingProps = React$1.useMemo(
64511
+ () => __spreadProps(__spreadValues({
64512
+ formName: "tgDataTable"
64513
+ }, props), {
64514
+ pageSize: controlled_pageSize || pageSize,
64515
+ defaults: defaultsToUse
64516
+ }),
64517
+ // We don't want to rerender this every time a prop changes
64518
+ // eslint-disable-next-line react-hooks/exhaustive-deps
64519
+ [controlled_pageSize, defaultsToUse, pageSize]
64520
+ );
64521
+ const queryParams = React$1.useMemo(() => {
64522
+ const additionalFilterToUse = typeof additionalFilter === "function" ? additionalFilter.bind(void 0, passingProps) : () => additionalFilter;
64523
+ const additionalOrFilterToUse = typeof additionalOrFilter === "function" ? additionalOrFilter.bind(void 0, passingProps) : () => additionalOrFilter;
64524
+ return getQueryParams({
64518
64525
  doNotCoercePageSize,
64519
64526
  currentParams,
64520
- entities: mergedOpts.entities,
64527
+ entities,
64521
64528
  // for local table
64522
64529
  urlConnected,
64523
64530
  defaults: defaultsToUse,
@@ -64528,93 +64535,96 @@ function withTableParams(topLevelOptions) {
64528
64535
  additionalOrFilter: additionalOrFilterToUse,
64529
64536
  noOrderError,
64530
64537
  isCodeModel,
64531
- ownProps: mergedOpts
64532
- })), {
64533
- currentParams,
64534
- selectedEntities
64535
- }), withSelectedEntities2 && typeof withSelectedEntities2 === "string" && {
64536
- [withSelectedEntities2]: selectedEntities
64537
- }), {
64538
- initialValues: __spreadProps(__spreadValues({}, initialValues), {
64539
- reduxFormSearchInput: currentParams.searchTerm
64540
- }),
64541
- showEmptyColumnsByDefault
64538
+ ownProps: passingProps
64542
64539
  });
64543
- return mapStateProps;
64544
- }, "mapStateToProps");
64545
- const mapDispatchToProps = /* @__PURE__ */ __name((dispatch, ownProps) => {
64546
- if (ownProps.isTableParamsConnected) {
64547
- return {};
64548
- }
64549
- const mergedOpts = getMergedOpts(topLevelOptions, ownProps);
64550
- const { formName, urlConnected, history, defaults: defaults2, onlyOneFilter } = mergedOpts;
64551
- function updateSearch(val) {
64552
- dispatch(reduxForm.change(formName, "reduxFormSearchInput", val || ""));
64553
- }
64554
- __name(updateSearch, "updateSearch");
64540
+ }, [
64541
+ additionalFilter,
64542
+ passingProps,
64543
+ additionalOrFilter,
64544
+ doNotCoercePageSize,
64545
+ currentParams,
64546
+ entities,
64547
+ urlConnected,
64548
+ defaultsToUse,
64549
+ convertedSchema,
64550
+ isInfinite,
64551
+ isSimple,
64552
+ withPaging,
64553
+ isLocalCall,
64554
+ noOrderError,
64555
+ isCodeModel
64556
+ ]);
64557
+ const dispatch = reactRedux.useDispatch();
64558
+ const tableParams = React$1.useMemo(() => {
64559
+ const change = /* @__PURE__ */ __name((...args) => dispatch(reduxForm.change(formName, ...args)), "change");
64560
+ const updateSearch = /* @__PURE__ */ __name((val) => {
64561
+ change("reduxFormSearchInput", val || "");
64562
+ }, "updateSearch");
64555
64563
  const setNewParams = /* @__PURE__ */ __name((newParams) => {
64556
- urlConnected && setCurrentParamsOnUrl(newParams, history.replace);
64557
- dispatch(reduxForm.change(formName, "reduxFormQueryParams", newParams));
64564
+ urlConnected && setCurrentParamsOnUrl(newParams, history == null ? void 0 : history.replace);
64565
+ change("reduxFormQueryParams", newParams);
64558
64566
  }, "setNewParams");
64559
- return {
64560
- bindThese: makeDataTableHandlers({
64561
- setNewParams,
64562
- updateSearch,
64563
- defaults: defaults2,
64564
- onlyOneFilter
64565
- }),
64566
- dispatch
64567
- };
64568
- }, "mapDispatchToProps");
64569
- function mergeProps(stateProps, dispatchProps, ownProps) {
64570
- if (ownProps.isTableParamsConnected) {
64571
- return ownProps;
64572
- }
64573
- const { currentParams, formName } = stateProps;
64567
+ const bindThese = makeDataTableHandlers({
64568
+ setNewParams,
64569
+ updateSearch,
64570
+ defaults: defaults2,
64571
+ onlyOneFilter
64572
+ });
64574
64573
  const boundDispatchProps = {};
64575
- Object.keys(dispatchProps.bindThese).forEach(function(key) {
64576
- const action = dispatchProps.bindThese[key];
64574
+ Object.keys(bindThese).forEach(function(key) {
64575
+ const action = bindThese[key];
64577
64576
  boundDispatchProps[key] = function(...args) {
64578
64577
  action(...args, currentParams);
64579
64578
  };
64580
64579
  });
64581
- const _a = stateProps, { variables, selectedEntities, mergedOpts } = _a, restStateProps = __objRest(_a, ["variables", "selectedEntities", "mergedOpts"]);
64582
- const changeFormValue = /* @__PURE__ */ __name((...args) => dispatchProps.dispatch(reduxForm.change(formName, ...args)), "changeFormValue");
64583
- const tableParams = __spreadProps(__spreadValues(__spreadValues(__spreadValues({
64580
+ const changeFormValue = /* @__PURE__ */ __name((...args) => change(...args), "changeFormValue");
64581
+ return __spreadProps(__spreadValues(__spreadValues(__spreadProps(__spreadValues({
64584
64582
  changeFormValue,
64585
64583
  selectedEntities
64586
- }, ownProps.tableParams), restStateProps), boundDispatchProps), {
64584
+ }, _tableParams), {
64585
+ formName,
64586
+ isLocalCall,
64587
+ schema,
64588
+ currentParams
64589
+ }), queryParams), boundDispatchProps), {
64587
64590
  form: formName,
64588
64591
  //this will override the default redux form name
64589
64592
  isTableParamsConnected: true
64590
64593
  //let the table know not to do local sorting/filtering etc.
64591
64594
  });
64592
- const allMergedProps = __spreadProps(__spreadValues(__spreadValues({}, ownProps), mergedOpts), {
64593
- variables: stateProps.variables,
64594
- selectedEntities: stateProps.selectedEntities,
64595
- tableParams
64596
- });
64597
- return allMergedProps;
64598
- }
64599
- __name(mergeProps, "mergeProps");
64600
- const toReturn = compose(
64601
- reactRedux.connect((state, ownProps) => {
64602
- if (ownProps.isTableParamsConnected) {
64603
- return {};
64604
- }
64605
- const { formName } = getMergedOpts(topLevelOptions, ownProps);
64606
- return {
64607
- unusedProp: reduxForm.formValueSelector(formName)(state, "reduxFormQueryParams") || {}
64608
- //tnr: we need this to trigger withRouter and force it to update if it is nested in a redux-connected container.. very ugly but necessary
64609
- };
64610
- }),
64611
- //don't use withRouter if noRouter is passed!
64612
- branch((props) => !props.noRouter, withRouter),
64613
- reactRedux.connect(mapStateToProps, mapDispatchToProps, mergeProps)
64614
- );
64615
- return toReturn;
64616
- }
64617
- __name(withTableParams, "withTableParams");
64595
+ }, [
64596
+ _tableParams,
64597
+ currentParams,
64598
+ defaults2,
64599
+ dispatch,
64600
+ formName,
64601
+ history == null ? void 0 : history.replace,
64602
+ isLocalCall,
64603
+ onlyOneFilter,
64604
+ queryParams,
64605
+ schema,
64606
+ selectedEntities,
64607
+ urlConnected
64608
+ ]);
64609
+ return __spreadProps(__spreadValues(__spreadValues({
64610
+ isLocalCall,
64611
+ schema
64612
+ }, queryParams), withSelectedEntities2 && typeof withSelectedEntities2 === "string" && {
64613
+ [withSelectedEntities2]: selectedEntities
64614
+ }), {
64615
+ currentParams,
64616
+ selectedEntities,
64617
+ tableParams
64618
+ });
64619
+ }, "useTableParams");
64620
+ const withTableParams = /* @__PURE__ */ __name((topLevelOptions) => compose(
64621
+ //don't use withRouter if noRouter is passed!
64622
+ branch(({ noRouter }) => !noRouter, withRouter),
64623
+ (Comp) => (props) => {
64624
+ const tableParams = useTableParams(__spreadValues(__spreadValues({}, topLevelOptions), props));
64625
+ return /* @__PURE__ */ React$1.createElement(Comp, __spreadValues(__spreadValues({}, props), tableParams));
64626
+ }
64627
+ ), "withTableParams");
64618
64628
  function showAppSpinner() {
64619
64629
  return renderOnDocSimple(
64620
64630
  /* @__PURE__ */ React$1.createElement(core.Overlay, { isOpen: true }, /* @__PURE__ */ React$1.createElement(Loading, { centeredInPage: true, loading: true }))
@@ -70743,6 +70753,7 @@ exports.tubeIcon = tubeIcon;
70743
70753
  exports.useDeepEqualMemo = useDeepEqualMemo;
70744
70754
  exports.useDialog = useDialog;
70745
70755
  exports.useTableEntities = useTableEntities;
70756
+ exports.useTableParams = useTableParams;
70746
70757
  exports.useTraceUpdate = useTraceUpdate;
70747
70758
  exports.withAbstractWrapper = withAbstractWrapper;
70748
70759
  exports.withCommand = withCommand;