sccoreui 6.1.90 → 6.1.91

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.
@@ -10,6 +10,7 @@ const drag_and_drop_icon_png_1 = tslib_1.__importDefault(require("../../../asset
10
10
  const checkbox_1 = require("primereact/checkbox");
11
11
  const button_1 = require("primereact/button");
12
12
  const context_provider_1 = require("../context-provider");
13
+ const helper_1 = require("../helper");
13
14
  // import { ColumnDef } from "../Types";
14
15
  const ColumnGroup = (props) => {
15
16
  var _a, _b, _c, _d;
@@ -17,7 +18,9 @@ const ColumnGroup = (props) => {
17
18
  const columnGroupRef = (0, react_1.useRef)(null);
18
19
  const btnRef = (0, react_1.useRef)(null);
19
20
  const [inpVlaue, setInpValue] = (0, react_1.useState)("");
20
- const { gridApi, setGridData, setSelectedGroup, setFeatureDetails, featureDetails, initialCheckBoxData, intialColumns, setIntialColumns, } = (0, react_1.useContext)(context_provider_1.FeatureContext);
21
+ const { gridApi, setGridData, setSelectedGroup, setFeatureDetails, featureDetails, initialCheckBoxData, intialColumns,
22
+ // setIntialColumns,
23
+ } = (0, react_1.useContext)(context_provider_1.FeatureContext);
21
24
  const [columns, setColumns] = (0, react_1.useState)([]);
22
25
  const [renderColumns, setRenderColumns] = (0, react_1.useState)([]);
23
26
  const [columnsSelectedForGroup, setColumnsSelectedForGroup] = (0, react_1.useState)([]);
@@ -111,7 +114,8 @@ const ColumnGroup = (props) => {
111
114
  setSelectedGroup([]);
112
115
  if (gridApi) {
113
116
  // Use deep copy of `intialColumns` to ensure no unintended mutation
114
- const clonedInitialColumns = JSON.parse(JSON.stringify(intialColumns));
117
+ const clonedInitialColumns = (0, helper_1.deepClone)(intialColumns);
118
+ console.log("clonedInitialColumns", clonedInitialColumns);
115
119
  // Update grid's column definitions
116
120
  gridApi.current.api.setColumnDefs(clonedInitialColumns);
117
121
  gridApi.current.columnApi.setRowGroupColumns([]);
@@ -127,6 +131,7 @@ const ColumnGroup = (props) => {
127
131
  }
128
132
  }
129
133
  };
134
+ console.log("intialllllll columns", intialColumns);
130
135
  const handleHide = () => {
131
136
  var _a, _b, _c;
132
137
  // Reset the renderColumns when the OverlayPanel is hidden
@@ -147,12 +152,6 @@ const ColumnGroup = (props) => {
147
152
  // Update state with the cloned columns
148
153
  setColumns(columnsFromGrid);
149
154
  setRenderColumns(columnsFromGrid);
150
- // Initialize `intialColumns` only if it hasn't been set yet
151
- if (!intialColumns) {
152
- // Perform a deep copy of the columns array using `JSON.parse(JSON.stringify())`
153
- const deepCopyOfColumns = JSON.parse(JSON.stringify(columnsFromGrid));
154
- setIntialColumns(deepCopyOfColumns);
155
- }
156
155
  }
157
156
  }, [(_d = (_c = (_b = (_a = gridApi === null || gridApi === void 0 ? void 0 : gridApi.current) === null || _a === void 0 ? void 0 : _a.api) === null || _b === void 0 ? void 0 : _b.columnModel) === null || _c === void 0 ? void 0 : _c.columnDefs) === null || _d === void 0 ? void 0 : _d.length]);
158
157
  return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: `${(columnsSelectedForGroup === null || columnsSelectedForGroup === void 0 ? void 0 : columnsSelectedForGroup.length) > 0 ? "bg-primary-50" : "bg-white"} hover:bg-primary-25 br-8 cursor-pointer pd-9 flex align-items-cente gap-1 zoom_animate`, ref: btnRef, onClick: showColumnOptions }, { children: [(0, jsx_runtime_1.jsx)(svg_component_1.default, { icon: "grid-01", size: 18, color: (columnsSelectedForGroup === null || columnsSelectedForGroup === void 0 ? void 0 : columnsSelectedForGroup.length) > 0
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.handleCheckboxClick = exports.getGroupIds = exports.handleUncheckedState = exports.handleCheckedState = exports.updateGroupState = exports.determineConditions = exports.updateRecords = exports.autoGroupColumnDef = exports.fillOperation = exports.updateCells = exports.getCheckedStatus = exports.sortColumns = exports.parseIfNeeded = exports.applyDefaultFilters = exports.initialCheckBoxData = void 0;
3
+ exports.deepClone = exports.handleCheckboxClick = exports.getGroupIds = exports.handleUncheckedState = exports.handleCheckedState = exports.updateGroupState = exports.determineConditions = exports.updateRecords = exports.autoGroupColumnDef = exports.fillOperation = exports.updateCells = exports.getCheckedStatus = exports.sortColumns = exports.parseIfNeeded = exports.applyDefaultFilters = exports.initialCheckBoxData = void 0;
4
4
  const tslib_1 = require("tslib");
5
+ const react_1 = tslib_1.__importDefault(require("react"));
5
6
  const constants_1 = require("./constants");
6
7
  // initial checkbox data
7
8
  exports.initialCheckBoxData = {
@@ -549,3 +550,48 @@ const handleCheckboxClick = (e, params, featureDetails, gridData, setFeatureDeta
549
550
  (0, exports.updateGroupState)(groupingColumns, (_j = (_h = params === null || params === void 0 ? void 0 : params.node) === null || _h === void 0 ? void 0 : _h.parent) === null || _j === void 0 ? void 0 : _j.id, (_m = (_l = (_k = params === null || params === void 0 ? void 0 : params.node) === null || _k === void 0 ? void 0 : _k.parent) === null || _l === void 0 ? void 0 : _l.parent) === null || _m === void 0 ? void 0 : _m.id, conditions, setSelectedGroup);
550
551
  };
551
552
  exports.handleCheckboxClick = handleCheckboxClick;
553
+ const deepClone = (obj) => {
554
+ var _a, _b, _c;
555
+ // If the input is not an object or is null, return the value itself (primitive types are returned directly)
556
+ if (obj === null || typeof obj !== 'object') {
557
+ return obj;
558
+ }
559
+ // Handle Date objects by creating a new Date instance with the same value
560
+ if (obj instanceof Date) {
561
+ return new Date(obj);
562
+ }
563
+ // Handle RegExp objects by creating a new RegExp instance with the same pattern and flags
564
+ if (obj instanceof RegExp) {
565
+ return new RegExp(obj);
566
+ }
567
+ // Handle React JSX elements
568
+ // If the object is a valid React element, clone it along with its props and children
569
+ if (react_1.default.isValidElement(obj)) {
570
+ const element = obj; // Explicitly assert type to ReactElement
571
+ // Recursively clone all child elements, if any
572
+ const clonedChildren = ((_a = element === null || element === void 0 ? void 0 : element.props) === null || _a === void 0 ? void 0 : _a.children)
573
+ ? (_b = react_1.default.Children) === null || _b === void 0 ? void 0 : _b.map((_c = element === null || element === void 0 ? void 0 : element.props) === null || _c === void 0 ? void 0 : _c.children, (child) => (0, exports.deepClone)(child))
574
+ : undefined; // Set to undefined if no children exist
575
+ // Return a cloned React element with its props and recursively cloned children
576
+ return react_1.default.cloneElement(element, Object.assign({}, element === null || element === void 0 ? void 0 : element.props), // Spread the existing props
577
+ clonedChildren // Include cloned children
578
+ );
579
+ }
580
+ // Handle Arrays
581
+ // Recursively clone each element in the array
582
+ if (Array.isArray(obj)) {
583
+ return obj === null || obj === void 0 ? void 0 : obj.map(exports.deepClone);
584
+ }
585
+ // Handle Objects
586
+ // Recursively clone each property in the object
587
+ const clonedObj = {}; // Create a new empty object to hold cloned properties
588
+ for (const key in obj) {
589
+ // Use hasOwnProperty to avoid cloning inherited properties
590
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
591
+ clonedObj[key] = (0, exports.deepClone)(obj[key]); // Recursively clone each property
592
+ }
593
+ }
594
+ // Return the fully cloned object
595
+ return clonedObj;
596
+ };
597
+ exports.deepClone = deepClone;
@@ -261,7 +261,7 @@ function ParentForGrid(props) {
261
261
  return (0, helper_1.autoGroupColumnDef)((props === null || props === void 0 ? void 0 : props.enableTree) ? true : false, // If tree enable
262
262
  props === null || props === void 0 ? void 0 : props.treeHeaderName, // Tree header name
263
263
  props === null || props === void 0 ? void 0 : props.groupField, // Group field
264
- props === null || props === void 0 ? void 0 : props.GroupHeaderComponent, // Header component
264
+ (0, utilComponents_1.GridHeaderComponent)(props), // Header component
265
265
  headerCheckBoxRenderer, //
266
266
  props === null || props === void 0 ? void 0 : props.enableCheckboxForGroupHeader, props.conditionsToDisplay.displayGroupCount, cellRendererConditionally, GroupHeaderRenderer // Custom component for group header
267
267
  );
@@ -270,12 +270,20 @@ function ParentForGrid(props) {
270
270
  return (0, helper_1.autoGroupColumnDef)((props === null || props === void 0 ? void 0 : props.enableTree) ? true : false, // If tree enable
271
271
  props === null || props === void 0 ? void 0 : props.treeHeaderName, // Tree header name
272
272
  props === null || props === void 0 ? void 0 : props.groupField, // Group field
273
- props === null || props === void 0 ? void 0 : props.GroupHeaderComponent, // Header component
273
+ (0, utilComponents_1.GridHeaderComponent)(props), // Header component
274
274
  headerCheckBoxRenderer, //
275
275
  props === null || props === void 0 ? void 0 : props.enableCheckboxForGroupHeader, props.conditionsToDisplay.displayGroupCount, GroupHeaderRenderer // Custom component for group header
276
276
  );
277
277
  }
278
278
  };
279
+ (0, react_1.useEffect)(() => {
280
+ // Initialize `intialColumns` only if it hasn't been set yet
281
+ if (!intialColumns) {
282
+ // Perform a deep copy of the columns array using `JSON.parse(JSON.stringify())`
283
+ const deepCopyOfColumns = (0, helper_1.deepClone)(gridData === null || gridData === void 0 ? void 0 : gridData.columnData);
284
+ setIntialColumns(deepCopyOfColumns);
285
+ }
286
+ }, [intialColumns]);
279
287
  // Options that grid should have
280
288
  const gridOptions = {
281
289
  columnDefs: (_c = gridData === null || gridData === void 0 ? void 0 : gridData.columnData) === null || _c === void 0 ? void 0 : _c.map((column) => {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GroupHeader = exports.dataCellRenderer = void 0;
3
+ exports.GridHeaderComponent = exports.GroupHeader = exports.dataCellRenderer = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  // import Checkbox from "./grid-checkbox";
6
6
  // Render checkbox as well as initial component/data from props
@@ -16,3 +16,9 @@ const GroupHeader = (params) => {
16
16
  return (0, jsx_runtime_1.jsx)("p", { children: "My Custom Group" });
17
17
  };
18
18
  exports.GroupHeader = GroupHeader;
19
+ const GridHeaderComponent = (props) => {
20
+ if (props === null || props === void 0 ? void 0 : props.GroupHeaderComponent)
21
+ return props === null || props === void 0 ? void 0 : props.GroupHeaderComponent;
22
+ return (0, jsx_runtime_1.jsx)("span", { children: "Group" });
23
+ };
24
+ exports.GridHeaderComponent = GridHeaderComponent;
@@ -51,3 +51,4 @@ export declare const getGroupIds: (gridRef: any) => {
51
51
  secondGroupIds: string[];
52
52
  };
53
53
  export declare const handleCheckboxClick: (e: any, params: any, featureDetails: any, gridData: any, setFeatureDetails: any, groupingColumns: any, setSelectedGroup: any) => void;
54
+ export declare const deepClone: (obj: any) => any;
@@ -1,2 +1,3 @@
1
1
  export declare const dataCellRenderer: (cellRendererParams: any, column: any, props: any) => import("react/jsx-runtime").JSX.Element;
2
2
  export declare const GroupHeader: (params: any) => import("react/jsx-runtime").JSX.Element;
3
+ export declare const GridHeaderComponent: (props: any) => any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sccoreui",
3
- "version": "6.1.90",
3
+ "version": "6.1.91",
4
4
  "description": "ui-sccore",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",