sccoreui 6.1.9 → 6.1.11

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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULTS = exports.FILEEXTENSIONTYPE = exports.IMAGETYPES = exports.STATUSLIST = exports.SETUPPRICEOPTIONS = exports.PRICINGTYPE = exports.BUNDLETYPE = exports.BUNDLEQUANTITYTYPE = exports.DEFAULTGUID = exports.CATEGORYTYPE = exports.PRODUCTDISCOUNTTYPE = exports.GridCheckBoxStatus = exports.conditionsList = exports.PRODUCTTYPE = exports.ROW_HEIGHT = exports.DEBOUNCE_INTERVAL = exports.MAX_BLOCKS = exports.MAX_RECORDS_TO_LOAD = exports.BLOCK_SIZE = exports.ROWMODELTYPE = exports.COLUMN_SORT_OPTIONS = void 0;
3
+ exports.DEFAULTS = exports.FILEEXTENSIONTYPE = exports.IMAGETYPES = exports.STATUSLIST = exports.SETUPPRICEOPTIONS = exports.PRICINGTYPE = exports.BUNDLETYPE = exports.BUNDLEQUANTITYTYPE = exports.DEFAULTGUID = exports.CATEGORYTYPE = exports.PRODUCTDISCOUNTTYPE = exports.GRID_CHECKBOX_STATUS = exports.conditionsList = exports.PRODUCTTYPE = exports.ROW_HEIGHT = exports.DEBOUNCE_INTERVAL = exports.MAX_BLOCKS = exports.MAX_RECORDS_TO_LOAD = exports.BLOCK_SIZE = exports.ROWMODELTYPE = exports.COLUMN_SORT_OPTIONS = void 0;
4
4
  const Types_1 = require("./Types");
5
5
  exports.COLUMN_SORT_OPTIONS = [
6
6
  { id: 1, label: "Low - High", sortId: 1, dataType: Types_1.ATTRIBUTEDATATYPES.INTEGER },
@@ -288,10 +288,10 @@ const constants = {
288
288
  minSortInputLength,
289
289
  currencies
290
290
  };
291
- var GridCheckBoxStatus;
292
- (function (GridCheckBoxStatus) {
293
- GridCheckBoxStatus[GridCheckBoxStatus["NEUTRAL"] = 1] = "NEUTRAL";
294
- GridCheckBoxStatus[GridCheckBoxStatus["CHECKED"] = 2] = "CHECKED";
295
- GridCheckBoxStatus[GridCheckBoxStatus["UNCHECKED"] = 3] = "UNCHECKED";
296
- })(GridCheckBoxStatus = exports.GridCheckBoxStatus || (exports.GridCheckBoxStatus = {}));
291
+ var GRID_CHECKBOX_STATUS;
292
+ (function (GRID_CHECKBOX_STATUS) {
293
+ GRID_CHECKBOX_STATUS[GRID_CHECKBOX_STATUS["NEUTRAL"] = 1] = "NEUTRAL";
294
+ GRID_CHECKBOX_STATUS[GRID_CHECKBOX_STATUS["CHECKED"] = 2] = "CHECKED";
295
+ GRID_CHECKBOX_STATUS[GRID_CHECKBOX_STATUS["UNCHECKED"] = 3] = "UNCHECKED";
296
+ })(GRID_CHECKBOX_STATUS = exports.GRID_CHECKBOX_STATUS || (exports.GRID_CHECKBOX_STATUS = {}));
297
297
  exports.default = constants;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fillOperation = exports.updateCells = exports.sortColumns = exports.parseIfNeeded = exports.applyDefaultFilters = void 0;
3
+ exports.fillOperation = exports.updateCells = exports.getCheckedStatus = exports.sortColumns = exports.parseIfNeeded = exports.applyDefaultFilters = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const applyDefaultFilters = (defaultFilters) => {
6
6
  const filters = defaultFilters === null || defaultFilters === void 0 ? void 0 : defaultFilters.map((item) => {
@@ -44,6 +44,25 @@ const sortColumns = (columns) => {
44
44
  return sortedColumns;
45
45
  };
46
46
  exports.sortColumns = sortColumns;
47
+ // Give checkbox checked status
48
+ const getCheckedStatus = (row, featureDetails, GRID_CHECKBOX_STATUS, setFeatureDetails) => {
49
+ const { allBoxChecked, excludedRecords, includedRecords, headerCheckBoxStatus, } = featureDetails.checkBoxSelection;
50
+ if (allBoxChecked) {
51
+ return !excludedRecords.includes(row);
52
+ }
53
+ else {
54
+ if (headerCheckBoxStatus === GRID_CHECKBOX_STATUS.NEUTRAL &&
55
+ row.isSelected) {
56
+ if (!includedRecords.includes(row)) {
57
+ includedRecords.push(row);
58
+ setFeatureDetails((prev) => (Object.assign(Object.assign({}, prev), { checkBoxSelection: Object.assign(Object.assign({}, prev.checkBoxSelection), { includedRecords: [...includedRecords] }) })));
59
+ }
60
+ return true;
61
+ }
62
+ return includedRecords.includes(row);
63
+ }
64
+ };
65
+ exports.getCheckedStatus = getCheckedStatus;
47
66
  const updateCells = (updatedRowData, setUpdateRowData, api) => {
48
67
  if (!api)
49
68
  return;
@@ -22,7 +22,6 @@ function ParentForGrid(props) {
22
22
  const [api, setApi] = (0, react_1.useState)(null);
23
23
  const [totalRecords, setTotalRecords] = (0, react_1.useState)(0);
24
24
  const [gridReadyEvent, setGridReadyEvent] = (0, react_1.useState)();
25
- const [defaultSelectedRows, setDefaultSelectedRows] = (0, react_1.useState)([]);
26
25
  const [initalDragRowData, setInitialDragRowData] = (0, react_1.useState)();
27
26
  const [defaultFilters, setDefaultFilters] = (0, react_1.useState)((props === null || props === void 0 ? void 0 : props.defaultFilters) || []);
28
27
  const [emptyResponse] = (0, react_1.useState)({
@@ -34,7 +33,7 @@ function ParentForGrid(props) {
34
33
  isIndeterminate: false,
35
34
  includedRecords: [],
36
35
  excludedRecords: [],
37
- headerCheckBoxStatus: constants_1.GridCheckBoxStatus.NEUTRAL
36
+ headerCheckBoxStatus: constants_1.GRID_CHECKBOX_STATUS.NEUTRAL
38
37
  });
39
38
  const initialFeature = {
40
39
  searchedText: "",
@@ -82,14 +81,14 @@ function ParentForGrid(props) {
82
81
  setFeatureDetails(Object.assign(Object.assign({}, featureDetails), { checkBoxSelection: checkboxData }));
83
82
  return;
84
83
  }
85
- if (includedRecords.includes(rowData) && defaultSelectedRows.includes(rowData)) {
86
- const checkboxData = Object.assign(Object.assign({}, featureDetails.checkBoxSelection), { includedRecords: includedRecords.filter((item) => item !== rowData), excludedRecords: [...excludedRecords, rowData], isIndeterminate: true });
87
- setFeatureDetails(Object.assign(Object.assign({}, featureDetails), { checkBoxSelection: checkboxData }));
88
- return;
89
- }
90
84
  // Logic to handle checkbox click events
91
85
  if (includedRecords.includes(rowData)) {
92
- const checkboxData = Object.assign(Object.assign({}, featureDetails.checkBoxSelection), { includedRecords: includedRecords.filter((item) => item !== rowData) });
86
+ const checkboxData = Object.assign(Object.assign({}, featureDetails.checkBoxSelection), { includedRecords: includedRecords.filter((item) => {
87
+ if (item.id !== rowData.id) {
88
+ rowData.isSelected = false;
89
+ return item;
90
+ }
91
+ }) });
93
92
  setFeatureDetails(Object.assign(Object.assign({}, featureDetails), { checkBoxSelection: checkboxData }));
94
93
  }
95
94
  else {
@@ -101,7 +100,7 @@ function ParentForGrid(props) {
101
100
  const handleHeaderCheckbox = () => {
102
101
  const { allBoxChecked } = featureDetails.checkBoxSelection;
103
102
  const currentStatus = !allBoxChecked;
104
- const checkboxData = Object.assign(Object.assign({}, featureDetails.checkBoxSelection), { allBoxChecked: currentStatus, isIndeterminate: false, includedRecords: [], excludedRecords: [], headerCheckBoxStatus: currentStatus ? constants_1.GridCheckBoxStatus.CHECKED : constants_1.GridCheckBoxStatus.UNCHECKED });
103
+ const checkboxData = Object.assign(Object.assign({}, featureDetails.checkBoxSelection), { allBoxChecked: currentStatus, isIndeterminate: false, includedRecords: [], excludedRecords: [], headerCheckBoxStatus: currentStatus ? constants_1.GRID_CHECKBOX_STATUS.CHECKED : constants_1.GRID_CHECKBOX_STATUS.UNCHECKED });
105
104
  setFeatureDetails(Object.assign(Object.assign({}, featureDetails), { checkBoxSelection: checkboxData }));
106
105
  };
107
106
  // JSX for rendering checkbox in header
@@ -112,10 +111,9 @@ function ParentForGrid(props) {
112
111
  // JSX for rendering checkbox in cells
113
112
  const cellCheckBoxRenderer = (params) => {
114
113
  const { data } = params;
115
- const { allBoxChecked, excludedRecords, includedRecords } = featureDetails.checkBoxSelection;
116
- return ((0, jsx_runtime_1.jsx)(grid_checkbox_1.default, { checked: allBoxChecked
117
- ? !excludedRecords.includes(data)
118
- : includedRecords.includes(data), onChange: () => handleCheckboxClick(data), isIndeterminate: false }));
114
+ // const { allBoxChecked, excludedRecords, includedRecords } = featureDetails.checkBoxSelection;
115
+ const isChecked = (0, helper_1.getCheckedStatus)(data, featureDetails, constants_1.GRID_CHECKBOX_STATUS, setFeatureDetails);
116
+ return ((0, jsx_runtime_1.jsx)(grid_checkbox_1.default, { checked: isChecked, onChange: () => handleCheckboxClick(data), isIndeterminate: false }));
119
117
  };
120
118
  // Render checkbox as well as initial component/data from props
121
119
  const dataCellRenderer = (cellRendererParams, column) => {
@@ -133,8 +131,6 @@ function ParentForGrid(props) {
133
131
  }
134
132
  const response = yield (props === null || props === void 0 ? void 0 : props.getRowData(startRow, endRow, currentFeatures, params));
135
133
  setGridData(Object.assign(Object.assign({}, gridData), { rowData: [] }));
136
- // Clear selected checkbox
137
- // setFeatureDetails((prev: any) => ({ ...prev, checkBoxSelection: initialCheckBoxData }));
138
134
  // To identify when to stop the callBack
139
135
  const actualEndRow = (response === null || response === void 0 ? void 0 : response.totalRecords) < constants_1.MAX_RECORDS_TO_LOAD ? response === null || response === void 0 ? void 0 : response.totalRecords : constants_1.MAX_RECORDS_TO_LOAD;
140
136
  maxLength = actualEndRow;
@@ -145,12 +141,6 @@ function ParentForGrid(props) {
145
141
  totalRecords: response.totalRecords,
146
142
  };
147
143
  setTotalRecords(response === null || response === void 0 ? void 0 : response.totalRecords);
148
- // Add records to includedRecords if already selected
149
- const checkedRecords = result.rowData.filter((data) => data === null || data === void 0 ? void 0 : data.isSelected);
150
- setDefaultSelectedRows(checkedRecords);
151
- const checkboxData = Object.assign(Object.assign({}, featureDetails.checkBoxSelection), { includedRecords: checkedRecords });
152
- setFeatureDetails(Object.assign(Object.assign({}, currentFeatures), { checkBoxSelection: checkboxData }));
153
- // response.actualEndRow = actualEndRow;
154
144
  return result;
155
145
  }
156
146
  return emptyResponse;
@@ -236,6 +226,8 @@ function ParentForGrid(props) {
236
226
  const getRowId = (prams) => prams.data.id;
237
227
  // Get the direction of selected range
238
228
  const onCellMouseDown = (event) => {
229
+ if (event.colDef.suppressFillHandle)
230
+ return;
239
231
  setInitialDragRowData(event.node.data);
240
232
  };
241
233
  // Update cell from front end and give a call back to products
@@ -1,5 +1,5 @@
1
1
  import { ColDef } from "@ag-grid-community/core";
2
- import { GridCheckBoxStatus } from "./constants";
2
+ import { GRID_CHECKBOX_STATUS } from "./constants";
3
3
  export interface ColumnDef extends ColDef {
4
4
  id: string;
5
5
  dataType: any;
@@ -63,7 +63,7 @@ export interface CheckBoxSelection {
63
63
  isIndeterminate: boolean;
64
64
  includedRecords: any[];
65
65
  excludedRecords: any[];
66
- headerCheckBoxStatus: GridCheckBoxStatus;
66
+ headerCheckBoxStatus: GRID_CHECKBOX_STATUS;
67
67
  }
68
68
  export declare enum ATTRIBUTEDATATYPES {
69
69
  STRING = "string",
@@ -89,7 +89,7 @@ declare enum SETUPPRICEOPTIONS {
89
89
  }
90
90
  export declare const conditionsList: any;
91
91
  declare const constants: any;
92
- export declare enum GridCheckBoxStatus {
92
+ export declare enum GRID_CHECKBOX_STATUS {
93
93
  NEUTRAL = 1,
94
94
  CHECKED = 2,
95
95
  UNCHECKED = 3
@@ -1,5 +1,6 @@
1
1
  export declare const applyDefaultFilters: (defaultFilters: any) => any;
2
2
  export declare const parseIfNeeded: (value: any) => any;
3
3
  export declare const sortColumns: (columns: any) => any;
4
+ export declare const getCheckedStatus: (row: any, featureDetails: any, GRID_CHECKBOX_STATUS: any, setFeatureDetails: any) => any;
4
5
  export declare const updateCells: (updatedRowData: any, setUpdateRowData: any, api: any) => void;
5
6
  export declare const fillOperation: (params: any, api: any, callBack: any, parentRowData: any) => Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sccoreui",
3
- "version": "6.1.09",
3
+ "version": "6.1.11",
4
4
  "description": "ui-sccore",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",