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

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.es.js CHANGED
@@ -47256,6 +47256,177 @@ const CellDragHandle = /* @__PURE__ */ __name(({
47256
47256
  }
47257
47257
  );
47258
47258
  }, "CellDragHandle");
47259
+ const RenderCell = /* @__PURE__ */ __name(({
47260
+ oldFunc,
47261
+ getCopyTextForCell,
47262
+ column,
47263
+ isCellEditable,
47264
+ isEntityDisabled,
47265
+ finishCellEdit,
47266
+ formName,
47267
+ noEllipsis,
47268
+ cancelCellEdit,
47269
+ getCellHoverText,
47270
+ selectedCells,
47271
+ isSelectionARectangle,
47272
+ startCellEdit,
47273
+ tableRef,
47274
+ onDragEnd,
47275
+ args
47276
+ }) => {
47277
+ var _a;
47278
+ const editingCell = useSelector(
47279
+ (state) => {
47280
+ var _a2, _b, _c;
47281
+ return (_c = (_b = (_a2 = state.form) == null ? void 0 : _a2[formName]) == null ? void 0 : _b.values) == null ? void 0 : _c.reduxFormEditingCell;
47282
+ }
47283
+ );
47284
+ const initialValue = useSelector(
47285
+ (state) => {
47286
+ var _a2, _b, _c;
47287
+ return (_c = (_b = (_a2 = state.form) == null ? void 0 : _a2[formName]) == null ? void 0 : _b.values) == null ? void 0 : _c.reduxFormInitialValue;
47288
+ }
47289
+ );
47290
+ const [row] = args;
47291
+ const rowId = getIdOrCodeOrIndex(row.original, row.index);
47292
+ const cellId = `${rowId}:${row.column.path}`;
47293
+ const isEditingCell = editingCell === cellId;
47294
+ let val = oldFunc(...args);
47295
+ const oldVal = val;
47296
+ const text2 = getCopyTextForCell(val, row, column);
47297
+ const dataTest = {
47298
+ "data-test": "tgCell_" + column.path
47299
+ };
47300
+ const fullValue = (_a = row.original) == null ? void 0 : _a[row.column.path];
47301
+ if (isEditingCell) {
47302
+ if (column.type === "genericSelect") {
47303
+ const GenericSelectComp = column.GenericSelectComp;
47304
+ return /* @__PURE__ */ React__default.createElement(
47305
+ GenericSelectComp,
47306
+ __spreadProps(__spreadValues({
47307
+ rowId,
47308
+ fullValue,
47309
+ initialValue: text2
47310
+ }, dataTest), {
47311
+ finishEdit: (newVal, doNotStopEditing) => {
47312
+ finishCellEdit(cellId, newVal, doNotStopEditing);
47313
+ },
47314
+ dataTest,
47315
+ cancelEdit: cancelCellEdit
47316
+ })
47317
+ );
47318
+ }
47319
+ if (column.type === "dropdown" || column.type === "dropdownMulti") {
47320
+ return /* @__PURE__ */ React__default.createElement(
47321
+ DropdownCell,
47322
+ {
47323
+ isMulti: dataTest.isMulti || column.type === "dropdownMulti",
47324
+ initialValue: dataTest.initialValue || text2,
47325
+ options: getVals(column.values),
47326
+ finishEdit: (newVal, doNotStopEditing) => {
47327
+ finishCellEdit(cellId, newVal, doNotStopEditing);
47328
+ },
47329
+ dataTest,
47330
+ cancelEdit: cancelCellEdit
47331
+ }
47332
+ );
47333
+ } else {
47334
+ return /* @__PURE__ */ React__default.createElement(
47335
+ EditableCell,
47336
+ {
47337
+ dataTest,
47338
+ cancelEdit: cancelCellEdit,
47339
+ isNumeric: column.type === "number",
47340
+ initialValue: initialValue || text2,
47341
+ finishEdit: (newVal) => {
47342
+ finishCellEdit(cellId, newVal);
47343
+ }
47344
+ }
47345
+ );
47346
+ }
47347
+ }
47348
+ const isBool = column.type === "boolean";
47349
+ if (isCellEditable && isBool) {
47350
+ val = /* @__PURE__ */ React__default.createElement(
47351
+ Checkbox,
47352
+ {
47353
+ disabled: isEntityDisabled(row.original),
47354
+ className: "tg-cell-edit-boolean-checkbox",
47355
+ checked: oldVal === "True",
47356
+ onChange: (e2) => {
47357
+ const checked = e2.target.checked;
47358
+ finishCellEdit(cellId, checked);
47359
+ }
47360
+ }
47361
+ );
47362
+ noEllipsis = true;
47363
+ }
47364
+ let title = text2;
47365
+ if (getCellHoverText)
47366
+ title = getCellHoverText(...args);
47367
+ else if (column.getTitleAttr)
47368
+ title = column.getTitleAttr(...args);
47369
+ const isSelectedCell = selectedCells == null ? void 0 : selectedCells[cellId];
47370
+ const {
47371
+ isRect,
47372
+ selectionGrid,
47373
+ lastRowIndex,
47374
+ lastCellIndex,
47375
+ entityMap,
47376
+ pathToIndex
47377
+ } = isSelectionARectangle();
47378
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(
47379
+ "div",
47380
+ __spreadProps(__spreadValues({
47381
+ style: __spreadValues({}, !noEllipsis && {
47382
+ textOverflow: "ellipsis",
47383
+ overflow: "hidden"
47384
+ })
47385
+ }, dataTest), {
47386
+ className: "tg-cell-wrapper",
47387
+ "data-copy-text": text2,
47388
+ "data-copy-json": JSON.stringify(
47389
+ //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
47390
+ column.type === "genericSelect" ? {
47391
+ __strVal: fullValue,
47392
+ __genSelCol: column.path
47393
+ } : { __strVal: text2 }
47394
+ ),
47395
+ title: title || void 0
47396
+ }),
47397
+ val
47398
+ ), isCellEditable && (column.type === "dropdown" || column.type === "dropdownMulti" || column.type === "genericSelect") && /* @__PURE__ */ React__default.createElement(
47399
+ Icon,
47400
+ {
47401
+ icon: "caret-down",
47402
+ style: {
47403
+ position: "absolute",
47404
+ right: 5,
47405
+ opacity: 0.3
47406
+ },
47407
+ className: "cell-edit-dropdown",
47408
+ onClick: () => {
47409
+ startCellEdit(cellId);
47410
+ }
47411
+ }
47412
+ ), isSelectedCell && (isRect ? isBottomRightCornerOfRectangle({
47413
+ cellId,
47414
+ selectionGrid,
47415
+ lastRowIndex,
47416
+ lastCellIndex,
47417
+ entityMap,
47418
+ pathToIndex
47419
+ }) : isSelectedCell === PRIMARY_SELECTED_VAL) && /* @__PURE__ */ React__default.createElement(
47420
+ CellDragHandle,
47421
+ {
47422
+ key: cellId,
47423
+ thisTable: tableRef.current.tableRef,
47424
+ cellId,
47425
+ isSelectionARectangle,
47426
+ onDragEnd
47427
+ }
47428
+ ));
47429
+ }, "RenderCell");
47259
47430
  dayjs.extend(localizedFormat);
47260
47431
  const RenderColumnHeader = /* @__PURE__ */ __name(({
47261
47432
  addFilters,
@@ -47507,171 +47678,6 @@ const renderCheckboxHeader = /* @__PURE__ */ __name(({
47507
47678
  }, checkboxProps)
47508
47679
  ) : null;
47509
47680
  }, "renderCheckboxHeader");
47510
- const RenderCell = /* @__PURE__ */ __name(({
47511
- oldFunc,
47512
- getCopyTextForCell,
47513
- column,
47514
- isCellEditable,
47515
- isEntityDisabled,
47516
- finishCellEdit,
47517
- formName,
47518
- noEllipsis,
47519
- cancelCellEdit,
47520
- getCellHoverText,
47521
- selectedCells,
47522
- isSelectionARectangle,
47523
- startCellEdit,
47524
- tableRef,
47525
- onDragEnd,
47526
- args
47527
- }) => {
47528
- var _a;
47529
- const editingCell = useSelector(
47530
- (state) => {
47531
- var _a2, _b, _c;
47532
- return (_c = (_b = (_a2 = state.form) == null ? void 0 : _a2[formName]) == null ? void 0 : _b.values) == null ? void 0 : _c.editingCell;
47533
- }
47534
- );
47535
- const [row] = args;
47536
- const rowId = getIdOrCodeOrIndex(row.original, row.index);
47537
- const cellId = `${rowId}:${row.column.path}`;
47538
- const isEditingCell = editingCell === cellId;
47539
- let val = oldFunc(...args);
47540
- const oldVal = val;
47541
- const text2 = getCopyTextForCell(val, row, column);
47542
- const dataTest = {
47543
- "data-test": "tgCell_" + column.path
47544
- };
47545
- const fullValue = (_a = row.original) == null ? void 0 : _a[row.column.path];
47546
- if (isEditingCell) {
47547
- if (column.type === "genericSelect") {
47548
- const GenericSelectComp = column.GenericSelectComp;
47549
- return /* @__PURE__ */ React__default.createElement(
47550
- GenericSelectComp,
47551
- __spreadProps(__spreadValues({
47552
- rowId,
47553
- fullValue,
47554
- initialValue: text2
47555
- }, dataTest), {
47556
- finishEdit: (newVal, doNotStopEditing) => {
47557
- finishCellEdit(cellId, newVal, doNotStopEditing);
47558
- },
47559
- dataTest,
47560
- cancelEdit: cancelCellEdit
47561
- })
47562
- );
47563
- }
47564
- if (column.type === "dropdown" || column.type === "dropdownMulti") {
47565
- return /* @__PURE__ */ React__default.createElement(
47566
- DropdownCell,
47567
- {
47568
- isMulti: dataTest.isMulti || column.type === "dropdownMulti",
47569
- initialValue: dataTest.initialValue || text2,
47570
- options: getVals(column.values),
47571
- finishEdit: (newVal, doNotStopEditing) => {
47572
- finishCellEdit(cellId, newVal, doNotStopEditing);
47573
- },
47574
- dataTest,
47575
- cancelEdit: cancelCellEdit
47576
- }
47577
- );
47578
- } else {
47579
- return /* @__PURE__ */ React__default.createElement(
47580
- EditableCell,
47581
- {
47582
- dataTest,
47583
- cancelEdit: cancelCellEdit,
47584
- isNumeric: column.type === "number",
47585
- initialValue: text2,
47586
- finishEdit: (newVal) => {
47587
- finishCellEdit(cellId, newVal);
47588
- }
47589
- }
47590
- );
47591
- }
47592
- }
47593
- const isBool = column.type === "boolean";
47594
- if (isCellEditable && isBool) {
47595
- val = /* @__PURE__ */ React__default.createElement(
47596
- Checkbox,
47597
- {
47598
- disabled: isEntityDisabled(row.original),
47599
- className: "tg-cell-edit-boolean-checkbox",
47600
- checked: oldVal === "True",
47601
- onChange: (e2) => {
47602
- const checked = e2.target.checked;
47603
- finishCellEdit(cellId, checked);
47604
- }
47605
- }
47606
- );
47607
- noEllipsis = true;
47608
- }
47609
- let title = text2;
47610
- if (getCellHoverText)
47611
- title = getCellHoverText(...args);
47612
- else if (column.getTitleAttr)
47613
- title = column.getTitleAttr(...args);
47614
- const isSelectedCell = selectedCells == null ? void 0 : selectedCells[cellId];
47615
- const {
47616
- isRect,
47617
- selectionGrid,
47618
- lastRowIndex,
47619
- lastCellIndex,
47620
- entityMap,
47621
- pathToIndex
47622
- } = isSelectionARectangle();
47623
- return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(
47624
- "div",
47625
- __spreadProps(__spreadValues({
47626
- style: __spreadValues({}, !noEllipsis && {
47627
- textOverflow: "ellipsis",
47628
- overflow: "hidden"
47629
- })
47630
- }, dataTest), {
47631
- className: "tg-cell-wrapper",
47632
- "data-copy-text": text2,
47633
- "data-copy-json": JSON.stringify(
47634
- //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
47635
- column.type === "genericSelect" ? {
47636
- __strVal: fullValue,
47637
- __genSelCol: column.path
47638
- } : { __strVal: text2 }
47639
- ),
47640
- title: title || void 0
47641
- }),
47642
- val
47643
- ), isCellEditable && (column.type === "dropdown" || column.type === "dropdownMulti" || column.type === "genericSelect") && /* @__PURE__ */ React__default.createElement(
47644
- Icon,
47645
- {
47646
- icon: "caret-down",
47647
- style: {
47648
- position: "absolute",
47649
- right: 5,
47650
- opacity: 0.3
47651
- },
47652
- className: "cell-edit-dropdown",
47653
- onClick: () => {
47654
- startCellEdit(cellId);
47655
- }
47656
- }
47657
- ), isSelectedCell && (isRect ? isBottomRightCornerOfRectangle({
47658
- cellId,
47659
- selectionGrid,
47660
- lastRowIndex,
47661
- lastCellIndex,
47662
- entityMap,
47663
- pathToIndex
47664
- }) : isSelectedCell === PRIMARY_SELECTED_VAL) && /* @__PURE__ */ React__default.createElement(
47665
- CellDragHandle,
47666
- {
47667
- key: cellId,
47668
- thisTable: tableRef.current.tableRef,
47669
- cellId,
47670
- isSelectionARectangle,
47671
- onDragEnd
47672
- }
47673
- ));
47674
- }, "RenderCell");
47675
47681
  const useColumns = /* @__PURE__ */ __name(({
47676
47682
  addFilters,
47677
47683
  cellRenderer,
@@ -47708,7 +47714,6 @@ const useColumns = /* @__PURE__ */ __name(({
47708
47714
  removeSingleFilter = noop$3,
47709
47715
  schema,
47710
47716
  selectedCells,
47711
- setEditingCell,
47712
47717
  setExpandedEntityIdMap,
47713
47718
  setNewParams,
47714
47719
  setOrder = noop$3,
@@ -48018,7 +48023,7 @@ const useColumns = /* @__PURE__ */ __name(({
48018
48023
  const finishCellEdit = useCallback(
48019
48024
  (cellId, newVal, doNotStopEditing) => {
48020
48025
  const [rowId, path2] = cellId.split(":");
48021
- !doNotStopEditing && setEditingCell(null);
48026
+ !doNotStopEditing && change$1("reduxFormEditingCell", null);
48022
48027
  updateEntitiesHelper(entities, (entities2) => {
48023
48028
  const entity = entities2.find((e2, i) => {
48024
48029
  return getIdOrCodeOrIndex(e2, i) === rowId;
@@ -48037,19 +48042,19 @@ const useColumns = /* @__PURE__ */ __name(({
48037
48042
  !doNotStopEditing && refocusTable();
48038
48043
  },
48039
48044
  [
48045
+ change$1,
48040
48046
  entities,
48041
48047
  reduxFormCellValidation,
48042
48048
  refocusTable,
48043
48049
  schema,
48044
- setEditingCell,
48045
48050
  updateEntitiesHelper,
48046
48051
  updateValidation
48047
48052
  ]
48048
48053
  );
48049
48054
  const cancelCellEdit = useCallback(() => {
48050
- setEditingCell(null);
48055
+ change$1("reduxFormEditingCell", null);
48051
48056
  refocusTable();
48052
- }, [refocusTable, setEditingCell]);
48057
+ }, [change$1, refocusTable]);
48053
48058
  if (!columns.length) {
48054
48059
  return columns;
48055
48060
  }
@@ -48232,6 +48237,7 @@ const useColumns = /* @__PURE__ */ __name(({
48232
48237
  RenderCell,
48233
48238
  {
48234
48239
  oldFunc,
48240
+ formName,
48235
48241
  getCopyTextForCell,
48236
48242
  column,
48237
48243
  isCellEditable,
@@ -48264,21 +48270,6 @@ const throwFormError = /* @__PURE__ */ __name((error) => {
48264
48270
  }
48265
48271
  throw new SubmissionError(errorToUse);
48266
48272
  }, "throwFormError");
48267
- const useTraceUpdate = /* @__PURE__ */ __name((props) => {
48268
- const prev = useRef(props);
48269
- useEffect(() => {
48270
- const changedProps = Object.entries(props).reduce((ps, [k2, v2]) => {
48271
- if (prev.current[k2] !== v2) {
48272
- ps[k2] = [prev.current[k2], v2];
48273
- }
48274
- return ps;
48275
- }, {});
48276
- if (Object.keys(changedProps).length > 0) {
48277
- console.log("Changed props:", changedProps);
48278
- }
48279
- prev.current = props;
48280
- });
48281
- }, "useTraceUpdate");
48282
48273
  T();
48283
48274
  const IS_LINUX = window.navigator.platform.toLowerCase().search("linux") > -1;
48284
48275
  const itemSizeEstimators = {
@@ -48439,7 +48430,6 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
48439
48430
  return tmp;
48440
48431
  }, [history, reduxFormQueryParams, reduxFormSearchInput, urlConnected]);
48441
48432
  const currentParams = useDeepEqualMemo(_currentParams);
48442
- useTraceUpdate({ currentParams });
48443
48433
  const tableParams = useMemo(() => {
48444
48434
  if (!isTableParamsConnected) {
48445
48435
  const updateSearch = /* @__PURE__ */ __name((val) => {
@@ -48645,20 +48635,28 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
48645
48635
  }, [entitiesAcrossPages, reduxFormSelectedEntityIdMap, change$1]);
48646
48636
  const [tableConfig, setTableConfig] = useState({ fieldOptions: [] });
48647
48637
  useEffect(() => {
48648
- let newTableConfig = {};
48649
48638
  if (withDisplayOptions) {
48639
+ let newTableConfig = {};
48650
48640
  if (syncDisplayOptionsToDb) {
48651
48641
  newTableConfig = tableConfigurations && tableConfigurations[0];
48652
48642
  } else {
48653
48643
  newTableConfig = getTableConfigFromStorage(formName);
48654
48644
  }
48655
- if (!newTableConfig) {
48656
- newTableConfig = {
48657
- fieldOptions: []
48658
- };
48659
- }
48645
+ setTableConfig((prev) => {
48646
+ if (!newTableConfig) {
48647
+ newTableConfig = {
48648
+ fieldOptions: []
48649
+ };
48650
+ if (isEqual(prev, newTableConfig)) {
48651
+ return prev;
48652
+ } else {
48653
+ return newTableConfig;
48654
+ }
48655
+ } else {
48656
+ return newTableConfig;
48657
+ }
48658
+ });
48660
48659
  }
48661
- setTableConfig(newTableConfig);
48662
48660
  }, [
48663
48661
  formName,
48664
48662
  syncDisplayOptionsToDb,
@@ -49107,7 +49105,8 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
49107
49105
  }
49108
49106
  }, [selectedCells]);
49109
49107
  const startCellEdit = useCallback(
49110
- (cellId) => {
49108
+ (cellId, initialValue) => {
49109
+ change$1("reduxFormInitialValue", initialValue);
49111
49110
  change$1("reduxFormEditingCell", (prev) => {
49112
49111
  if (prev === cellId)
49113
49112
  return cellId;
@@ -50813,7 +50812,7 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
50813
50812
  if (rowDisabled)
50814
50813
  return;
50815
50814
  e2.stopPropagation();
50816
- startCellEdit(primarySelectedCellId);
50815
+ startCellEdit(primarySelectedCellId, e2.key);
50817
50816
  }
50818
50817
  }),
50819
50818
  isCellEditable && entities.length > 50 && // test for this!!
@@ -64407,6 +64406,7 @@ const useTableParams = /* @__PURE__ */ __name((props) => {
64407
64406
  syncDisplayOptionsToDb,
64408
64407
  tableParams: _tableParams,
64409
64408
  urlConnected,
64409
+ withDisplayOptions,
64410
64410
  withPaging,
64411
64411
  withSelectedEntities: withSelectedEntities2
64412
64412
  } = props;
@@ -64567,7 +64567,8 @@ const useTableParams = /* @__PURE__ */ __name((props) => {
64567
64567
  formName,
64568
64568
  isLocalCall,
64569
64569
  schema,
64570
- currentParams
64570
+ currentParams,
64571
+ withDisplayOptions
64571
64572
  }), queryParams), boundDispatchProps), {
64572
64573
  form: formName,
64573
64574
  //this will override the default redux form name
@@ -64586,7 +64587,8 @@ const useTableParams = /* @__PURE__ */ __name((props) => {
64586
64587
  queryParams,
64587
64588
  schema,
64588
64589
  selectedEntities,
64589
- urlConnected
64590
+ urlConnected,
64591
+ withDisplayOptions
64590
64592
  ]);
64591
64593
  return __spreadProps(__spreadValues(__spreadValues({
64592
64594
  isLocalCall,
@@ -69557,6 +69559,21 @@ const CmdButton = withCommand({
69557
69559
  icon: "icon",
69558
69560
  disabled: "isDisabled"
69559
69561
  })(Button);
69562
+ const useTraceUpdate = /* @__PURE__ */ __name((props) => {
69563
+ const prev = useRef(props);
69564
+ useEffect(() => {
69565
+ const changedProps = Object.entries(props).reduce((ps, [k2, v2]) => {
69566
+ if (prev.current[k2] !== v2) {
69567
+ ps[k2] = [prev.current[k2], v2];
69568
+ }
69569
+ return ps;
69570
+ }, {});
69571
+ if (Object.keys(changedProps).length > 0) {
69572
+ console.log("Changed props:", changedProps);
69573
+ }
69574
+ prev.current = props;
69575
+ });
69576
+ }, "useTraceUpdate");
69560
69577
  const showProgressToast = /* @__PURE__ */ __name((message, value, key, opts) => {
69561
69578
  return window.toastr.default(
69562
69579
  /* @__PURE__ */ React__default.createElement("div", null, /* @__PURE__ */ React__default.createElement("div", { style: { marginBottom: 10 } }, message), /* @__PURE__ */ React__default.createElement(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teselagen/ui",
3
- "version": "0.5.23-beta.17",
3
+ "version": "0.5.23-beta.18",
4
4
  "main": "./src/index.js",
5
5
  "exports": {
6
6
  ".": {