@crystaldesign/diva-backoffice 25.6.2 → 25.6.3-rc.0

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.
@@ -34006,11 +34006,12 @@ function PriceFactorCellRenderer(props) {
34006
34006
  column = props.column,
34007
34007
  onSave = props.onSave,
34008
34008
  api = props.api,
34009
- singleClick = props.singleClick;
34009
+ isNotInAGGrid = props.isNotInAGGrid;
34010
34010
  var _useTranslation = useTranslation(),
34011
34011
  t = _useTranslation.t,
34012
34012
  i18n = _useTranslation.i18n;
34013
- var applySave = /*#__PURE__*/function () {
34013
+ var clickTimer = useRef(null);
34014
+ var applySave = useCallback(/*#__PURE__*/function () {
34014
34015
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(data, value) {
34015
34016
  return _regeneratorRuntime.wrap(function _callee$(_context) {
34016
34017
  while (1) switch (_context.prev = _context.next) {
@@ -34032,10 +34033,36 @@ function PriceFactorCellRenderer(props) {
34032
34033
  }
34033
34034
  }, _callee);
34034
34035
  }));
34035
- return function applySave(_x, _x2) {
34036
+ return function (_x, _x2) {
34036
34037
  return _ref.apply(this, arguments);
34037
34038
  };
34038
- }();
34039
+ }(), [onSave, node, colDef === null || colDef === void 0 ? void 0 : colDef.field]);
34040
+ var _usePriceFactor = usePriceFactor({
34041
+ data: data,
34042
+ initialValue: value,
34043
+ onSave: applySave,
34044
+ onRefreshCell: function onRefreshCell() {
34045
+ return api === null || api === void 0 ? void 0 : api.refreshCells({
34046
+ suppressFlash: true,
34047
+ rowNodes: node ? [node] : undefined,
34048
+ columns: column ? [column] : undefined
34049
+ });
34050
+ }
34051
+ }),
34052
+ type = _usePriceFactor.type,
34053
+ entries = _usePriceFactor.entries,
34054
+ isModalOpen = _usePriceFactor.isModalOpen,
34055
+ handleModalOpen = _usePriceFactor.handleModalOpen,
34056
+ handleModalClose = _usePriceFactor.handleModalClose,
34057
+ handleTypeChange = _usePriceFactor.handleTypeChange,
34058
+ handleAddEntry = _usePriceFactor.handleAddEntry,
34059
+ handleRemoveEntry = _usePriceFactor.handleRemoveEntry,
34060
+ handleEntryValueChange = _usePriceFactor.handleEntryValueChange,
34061
+ handleSave = _usePriceFactor.handleSave;
34062
+ var handleOpenModal = useCallback(function () {
34063
+ handleModalOpen();
34064
+ api === null || api === void 0 || api.stopEditing();
34065
+ }, [handleModalOpen, api]);
34039
34066
  useEffect(function () {
34040
34067
  //
34041
34068
  // This is a workaround to prevent the row to go into edit mode when the cell is clicked.
@@ -34051,47 +34078,44 @@ function PriceFactorCellRenderer(props) {
34051
34078
  if (rowElement && cellElement && rowElement.getAttribute('row-id') === (node === null || node === void 0 ? void 0 : node.id) && cellElement.getAttribute('col-id') === (colDef === null || colDef === void 0 ? void 0 : colDef.field)) {
34052
34079
  e.preventDefault();
34053
34080
  e.stopPropagation();
34054
- handleModalOpen();
34055
- api === null || api === void 0 || api.stopEditing();
34081
+ handleOpenModal();
34056
34082
  return false;
34057
34083
  }
34058
34084
  return true;
34059
34085
  };
34060
- if (singleClick) {
34061
- document.addEventListener('click', handleClick, true);
34062
- } else {
34086
+ if (!isNotInAGGrid) {
34063
34087
  document.addEventListener('dblclick', handleClick, true);
34064
34088
  }
34065
34089
  return function () {
34066
- if (singleClick) {
34067
- document.removeEventListener('click', handleClick, true);
34068
- } else {
34090
+ if (!isNotInAGGrid) {
34069
34091
  document.removeEventListener('dblclick', handleClick, true);
34070
34092
  }
34071
34093
  };
34072
- }, [api, node === null || node === void 0 ? void 0 : node.id, colDef === null || colDef === void 0 ? void 0 : colDef.field, singleClick]);
34073
- var _usePriceFactor = usePriceFactor({
34074
- data: data,
34075
- initialValue: value,
34076
- onSave: applySave,
34077
- onRefreshCell: function onRefreshCell() {
34078
- return api === null || api === void 0 ? void 0 : api.refreshCells({
34079
- suppressFlash: true,
34080
- rowNodes: node ? [node] : undefined,
34081
- columns: column ? [column] : undefined
34082
- });
34083
- }
34084
- }),
34085
- type = _usePriceFactor.type,
34086
- entries = _usePriceFactor.entries,
34087
- isModalOpen = _usePriceFactor.isModalOpen,
34088
- handleModalOpen = _usePriceFactor.handleModalOpen,
34089
- handleModalClose = _usePriceFactor.handleModalClose,
34090
- handleTypeChange = _usePriceFactor.handleTypeChange,
34091
- handleAddEntry = _usePriceFactor.handleAddEntry,
34092
- handleRemoveEntry = _usePriceFactor.handleRemoveEntry,
34093
- handleEntryValueChange = _usePriceFactor.handleEntryValueChange,
34094
- handleSave = _usePriceFactor.handleSave;
34094
+ }, [api, node === null || node === void 0 ? void 0 : node.id, colDef === null || colDef === void 0 ? void 0 : colDef.field, isNotInAGGrid, handleOpenModal]);
34095
+
34096
+ /*
34097
+ * if the component is used outside of an ag-grid cell, we have to handle the click event differently
34098
+ * we debounce the click event to prevent multiple clicks from opening and immediately closing the modal
34099
+ */
34100
+ var onClick = useCallback(function () {
34101
+ if (isNotInAGGrid) {
34102
+ if (clickTimer.current) clearTimeout(clickTimer.current);
34103
+ clickTimer.current = setTimeout(function () {
34104
+ handleOpenModal();
34105
+ }, 200);
34106
+ }
34107
+ }, [isNotInAGGrid, handleOpenModal]);
34108
+ var onDoubleClick = useCallback(function () {
34109
+ if (isNotInAGGrid) {
34110
+ if (clickTimer.current) clearTimeout(clickTimer.current);
34111
+ handleOpenModal();
34112
+ }
34113
+ }, [isNotInAGGrid, handleOpenModal]);
34114
+ useEffect(function () {
34115
+ return function () {
34116
+ if (clickTimer.current) clearTimeout(clickTimer.current);
34117
+ };
34118
+ }, []);
34095
34119
  var isDiscount = type === 'discount';
34096
34120
  var isSingleDefaultEntry = entries.length === 1 && isDefaultValue(entries[0].value, type);
34097
34121
  var hasInvalidEntries = entries.some(function (entry) {
@@ -34100,6 +34124,8 @@ function PriceFactorCellRenderer(props) {
34100
34124
  return /*#__PURE__*/jsxs(Fragment, {
34101
34125
  children: [/*#__PURE__*/jsx("div", {
34102
34126
  className: cell,
34127
+ onClick: onClick,
34128
+ onDoubleClick: onDoubleClick,
34103
34129
  children: formatListValue(value || [], type, i18n.language)
34104
34130
  }), /*#__PURE__*/jsxs(Modal$2, {
34105
34131
  title: colDef === null || colDef === void 0 ? void 0 : colDef.headerName,
@@ -34294,7 +34320,7 @@ function PriceFactorInput(props) {
34294
34320
  id: "price-factor-input",
34295
34321
  className: classnames(input, _defineProperty({}, disabled$1, props.disabled)),
34296
34322
  children: /*#__PURE__*/jsx(PriceFactorCellRenderer, _objectSpread$d(_objectSpread$d({}, props), {}, {
34297
- singleClick: true
34323
+ isNotInAGGrid: true
34298
34324
  }))
34299
34325
  })
34300
34326
  })]
@@ -11,6 +11,9 @@ export default function PriceFactorCellRenderer(props: Partial<CustomCellRendere
11
11
  manualPrices: string[];
12
12
  }, number[], DivaContext>> & {
13
13
  onSave?: (data: any, value: number[]) => Promise<void>;
14
- singleClick?: boolean;
14
+ /**
15
+ * if true, the component is used outside of an ag-grid cell, thus we have to handle the click event differently
16
+ */
17
+ isNotInAGGrid?: boolean;
15
18
  }): React.JSX.Element;
16
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../src/ui/IDMEnricherEditor/components/PriceFactorCellRenderer/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAQzD,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAC7C,KAAK,EAAE,OAAO,CACZ,uBAAuB,CACrB;IACE,MAAM,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAClC,UAAU,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACtC,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,EACD,MAAM,EAAE,EACR,WAAW,CACZ,CACF,GAAG;IACF,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,qBAuJF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../src/ui/IDMEnricherEditor/components/PriceFactorCellRenderer/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAQzD,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAC7C,KAAK,EAAE,OAAO,CACZ,uBAAuB,CACrB;IACE,MAAM,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAClC,UAAU,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACtC,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,EACD,MAAM,EAAE,EACR,WAAW,CACZ,CACF,GAAG;IACF,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,qBAqLF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crystaldesign/diva-backoffice",
3
- "version": "25.6.2",
3
+ "version": "25.6.3-rc.0",
4
4
  "license": "COMMERCIAL",
5
5
  "devDependencies": {
6
6
  "@testing-library/jest-dom": "^6.5.0",
@@ -15,13 +15,13 @@
15
15
  "dependencies": {
16
16
  "@ant-design/icons": "5.4.0",
17
17
  "@babel/runtime": "7.24.7",
18
- "@crystaldesign/content-box": "25.6.2",
19
- "@crystaldesign/content-item": "25.6.2",
20
- "@crystaldesign/diva-core": "25.6.2",
21
- "@crystaldesign/diva-utils": "25.6.2",
22
- "@crystaldesign/media-upload": "25.6.2",
23
- "@crystaldesign/rtf-editor": "25.6.2",
24
- "@crystaldesign/spreadsheet": "25.6.2",
18
+ "@crystaldesign/content-box": "25.6.3-rc.0",
19
+ "@crystaldesign/content-item": "25.6.3-rc.0",
20
+ "@crystaldesign/diva-core": "25.6.3-rc.0",
21
+ "@crystaldesign/diva-utils": "25.6.3-rc.0",
22
+ "@crystaldesign/media-upload": "25.6.3-rc.0",
23
+ "@crystaldesign/rtf-editor": "25.6.3-rc.0",
24
+ "@crystaldesign/spreadsheet": "25.6.3-rc.0",
25
25
  "@google/model-viewer": "3.5.0",
26
26
  "ag-charts-community": "^10.1.0",
27
27
  "ag-charts-react": "^10.1.0",
@@ -51,5 +51,5 @@
51
51
  },
52
52
  "module": "build/esm/index.js",
53
53
  "types": "./build/types/backoffice/src/index.d.ts",
54
- "gitHead": "7e549400affa0ab055500aa7b6ee02baf0a6b127"
54
+ "gitHead": "02c73808f37adbe9fb7b9925f49d5e5756913f2b"
55
55
  }