sccoreui 5.8.8 → 5.8.9
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/dist/components/ag-grid/MyProvider.js +4 -12
- package/dist/components/ag-grid/ParentForGrid.js +51 -25
- package/dist/components/ag-grid/advancedFeature/advanced-feature.js +2 -1
- package/dist/components/ag-grid/advancedFeature/filter/filter.js +0 -1
- package/dist/components/ag-grid/advancedFeature/remove-items.js +15 -0
- package/dist/types/components/ag-grid/MyProvider.d.ts +1 -0
- package/dist/types/components/ag-grid/Types.d.ts +13 -4
- package/dist/types/components/ag-grid/advancedFeature/remove-items.d.ts +2 -0
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
exports.FeatureContext = (0, react_1.createContext)(null);
|
|
7
7
|
function MyProvider({ children, value }) {
|
|
8
|
-
const { featureDetails, setFeatureDetails, gridData, callGrid, totalRecords } = value;
|
|
8
|
+
const { featureDetails, setFeatureDetails, gridData, callGrid, totalRecords, initialFeature } = value;
|
|
9
9
|
// States for sort
|
|
10
10
|
const [columnData] = (0, react_1.useState)(gridData === null || gridData === void 0 ? void 0 : gridData.columnData);
|
|
11
11
|
const [sortValue, setSortValue] = (0, react_1.useState)({});
|
|
@@ -18,17 +18,9 @@ function MyProvider({ children, value }) {
|
|
|
18
18
|
// Returns based on length of filterQueries present
|
|
19
19
|
return length === 0 ? [0] : Array.from({ length }, (_, index) => index);
|
|
20
20
|
});
|
|
21
|
-
// Function call on click to
|
|
21
|
+
// Function call on click to refresh
|
|
22
22
|
const removeFeaturesAndRefresh = () => {
|
|
23
|
-
const emptyFeatures =
|
|
24
|
-
searchedText: "",
|
|
25
|
-
filterQueries: [],
|
|
26
|
-
sort: {
|
|
27
|
-
isSortable: false,
|
|
28
|
-
columnToSort: {},
|
|
29
|
-
orderToSort: {},
|
|
30
|
-
},
|
|
31
|
-
};
|
|
23
|
+
const emptyFeatures = initialFeature;
|
|
32
24
|
// Remove stored features
|
|
33
25
|
setFeatureDetails(emptyFeatures);
|
|
34
26
|
// Remove filter
|
|
@@ -52,7 +44,7 @@ function MyProvider({ children, value }) {
|
|
|
52
44
|
columnData,
|
|
53
45
|
callGrid,
|
|
54
46
|
removeFeaturesAndRefresh,
|
|
55
|
-
totalRecords
|
|
47
|
+
totalRecords,
|
|
56
48
|
} }, { children: children })));
|
|
57
49
|
}
|
|
58
50
|
exports.default = MyProvider;
|
|
@@ -24,12 +24,23 @@ function ParentForGrid(props) {
|
|
|
24
24
|
rowData: [],
|
|
25
25
|
});
|
|
26
26
|
const [isLoading, setIsLoading] = (0, react_1.useState)(false);
|
|
27
|
-
const [
|
|
27
|
+
const [initialCheckBoxData] = (0, react_1.useState)({
|
|
28
28
|
allBoxChecked: false,
|
|
29
29
|
isInterminate: false,
|
|
30
30
|
selectedCheckboxData: [],
|
|
31
31
|
unselectedCheckboxData: [],
|
|
32
32
|
});
|
|
33
|
+
const initialFeature = {
|
|
34
|
+
searchedText: "",
|
|
35
|
+
filterQueries: [],
|
|
36
|
+
sort: {
|
|
37
|
+
isSortable: false,
|
|
38
|
+
columnToSort: {},
|
|
39
|
+
orderToSort: {},
|
|
40
|
+
},
|
|
41
|
+
checkBoxSelection: initialCheckBoxData,
|
|
42
|
+
isRemoveClicked: false
|
|
43
|
+
};
|
|
33
44
|
const [featureDetails, setFeatureDetails] = (0, react_1.useState)({
|
|
34
45
|
searchedText: "",
|
|
35
46
|
filterQueries: [],
|
|
@@ -38,6 +49,8 @@ function ParentForGrid(props) {
|
|
|
38
49
|
columnToSort: {},
|
|
39
50
|
orderToSort: {},
|
|
40
51
|
},
|
|
52
|
+
checkBoxSelection: initialCheckBoxData,
|
|
53
|
+
isRemoveClicked: false
|
|
41
54
|
});
|
|
42
55
|
// Default column specification
|
|
43
56
|
const defaultColDef = (0, react_1.useMemo)(() => {
|
|
@@ -51,36 +64,41 @@ function ParentForGrid(props) {
|
|
|
51
64
|
}, []);
|
|
52
65
|
// Function to handle checkbox click events
|
|
53
66
|
const handleCheckboxClick = (rowData) => {
|
|
54
|
-
const { unselectedCheckboxData, selectedCheckboxData, allBoxChecked } = checkBoxSelection;
|
|
67
|
+
const { unselectedCheckboxData, selectedCheckboxData, allBoxChecked } = featureDetails.checkBoxSelection;
|
|
55
68
|
if (allBoxChecked && unselectedCheckboxData.includes(rowData)) {
|
|
56
|
-
|
|
69
|
+
const checkboxData = Object.assign(Object.assign({}, featureDetails.checkBoxSelection), { unselectedCheckboxData: unselectedCheckboxData.filter((item) => item !== rowData) });
|
|
70
|
+
setFeatureDetails(Object.assign(Object.assign({}, featureDetails), { checkBoxSelection: checkboxData }));
|
|
57
71
|
return;
|
|
58
72
|
}
|
|
59
73
|
else if (allBoxChecked) {
|
|
60
|
-
|
|
74
|
+
const checkboxData = Object.assign(Object.assign({}, featureDetails.checkBoxSelection), { unselectedCheckboxData: [...unselectedCheckboxData, rowData], isInterminate: true });
|
|
75
|
+
setFeatureDetails(Object.assign(Object.assign({}, featureDetails), { checkBoxSelection: checkboxData }));
|
|
61
76
|
return;
|
|
62
77
|
}
|
|
63
78
|
// Logic to handle checkbox click events
|
|
64
79
|
if (selectedCheckboxData.includes(rowData)) {
|
|
65
|
-
|
|
80
|
+
const checkboxData = Object.assign(Object.assign({}, featureDetails.checkBoxSelection), { selectedCheckboxData: selectedCheckboxData.filter((item) => item !== rowData) });
|
|
81
|
+
setFeatureDetails(Object.assign(Object.assign({}, featureDetails), { checkBoxSelection: checkboxData }));
|
|
66
82
|
}
|
|
67
83
|
else {
|
|
68
|
-
|
|
84
|
+
const checkboxData = Object.assign(Object.assign({}, featureDetails.checkBoxSelection), { selectedCheckboxData: [...selectedCheckboxData, rowData] });
|
|
85
|
+
setFeatureDetails(Object.assign(Object.assign({}, featureDetails), { checkBoxSelection: checkboxData }));
|
|
69
86
|
}
|
|
70
87
|
};
|
|
71
88
|
const handleHeaderCheckbox = () => {
|
|
72
|
-
const { allBoxChecked } = checkBoxSelection;
|
|
73
|
-
|
|
89
|
+
const { allBoxChecked } = featureDetails.checkBoxSelection;
|
|
90
|
+
const checkboxData = Object.assign(Object.assign({}, featureDetails.checkBoxSelection), { allBoxChecked: !allBoxChecked, isInterminate: false, selectedCheckboxData: [], unselectedCheckboxData: [] });
|
|
91
|
+
setFeatureDetails(Object.assign(Object.assign({}, featureDetails), { checkBoxSelection: checkboxData }));
|
|
74
92
|
};
|
|
75
93
|
// JSX for rendering checkbox in header
|
|
76
94
|
const headerCheckBoxRenderer = (params) => {
|
|
77
95
|
const displayName = params === null || params === void 0 ? void 0 : params.displayName;
|
|
78
|
-
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "flex" }, { children: [(0, jsx_runtime_1.jsx)(grid_checkbox_1.default, { checked: checkBoxSelection.allBoxChecked, onChange: handleHeaderCheckbox, isInterminate: checkBoxSelection.isInterminate }), (0, jsx_runtime_1.jsx)("p", Object.assign({ className: "px-3" }, { children: displayName }))] })));
|
|
96
|
+
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "flex" }, { children: [(0, jsx_runtime_1.jsx)(grid_checkbox_1.default, { checked: featureDetails.checkBoxSelection.allBoxChecked, onChange: handleHeaderCheckbox, isInterminate: featureDetails.checkBoxSelection.isInterminate }), (0, jsx_runtime_1.jsx)("p", Object.assign({ className: "px-3" }, { children: displayName }))] })));
|
|
79
97
|
};
|
|
80
98
|
// JSX for rendering checkbox in cells
|
|
81
99
|
const cellCheckBoxRenderer = (params) => {
|
|
82
100
|
const { data } = params;
|
|
83
|
-
const { allBoxChecked, unselectedCheckboxData, selectedCheckboxData } = checkBoxSelection;
|
|
101
|
+
const { allBoxChecked, unselectedCheckboxData, selectedCheckboxData } = featureDetails.checkBoxSelection;
|
|
84
102
|
return ((0, jsx_runtime_1.jsx)(grid_checkbox_1.default, { checked: allBoxChecked
|
|
85
103
|
? !unselectedCheckboxData.includes(data)
|
|
86
104
|
: selectedCheckboxData.includes(data), onChange: () => handleCheckboxClick(data), isInterminate: false }));
|
|
@@ -97,14 +115,20 @@ function ParentForGrid(props) {
|
|
|
97
115
|
return emptyResponse; // If callback function to get row data is not provided
|
|
98
116
|
}
|
|
99
117
|
const response = yield props.getRowData(startRow, endRow, currentFeatures);
|
|
118
|
+
setGridData(Object.assign(Object.assign({}, gridData), { rowData: [] }));
|
|
119
|
+
setFeatureDetails(Object.assign(Object.assign({}, featureDetails), { checkBoxSelection: initialCheckBoxData }));
|
|
100
120
|
// To identify when to stop the callBack
|
|
101
121
|
// const actualEndRow = startRow + (response?.rowData?.length ?? 0);
|
|
102
122
|
const actualEndRow = response === null || response === void 0 ? void 0 : response.totalRecords;
|
|
103
123
|
if (response === null || response === void 0 ? void 0 : response.rowData) {
|
|
124
|
+
const result = {
|
|
125
|
+
rowData: response.rowData,
|
|
126
|
+
actualEndRow: actualEndRow,
|
|
127
|
+
totalRecords: response.totalRecords
|
|
128
|
+
};
|
|
104
129
|
setTotalRecords(response === null || response === void 0 ? void 0 : response.totalRecords);
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return response;
|
|
130
|
+
// response.actualEndRow = actualEndRow;
|
|
131
|
+
return result;
|
|
108
132
|
}
|
|
109
133
|
return emptyResponse;
|
|
110
134
|
});
|
|
@@ -120,6 +144,8 @@ function ParentForGrid(props) {
|
|
|
120
144
|
if (props.rowModelType === constants_1.ROWMODELTYPE.CLIENT_SIDE) {
|
|
121
145
|
const result = yield getData(0, 0, currentFeatures);
|
|
122
146
|
if (result.rowData) {
|
|
147
|
+
setGridData(Object.assign(Object.assign({}, gridData), { rowData: result.rowData }));
|
|
148
|
+
params.api.setGridOption("rowData", []);
|
|
123
149
|
params.api.applyTransaction({ add: result.rowData });
|
|
124
150
|
}
|
|
125
151
|
}
|
|
@@ -145,10 +171,9 @@ function ParentForGrid(props) {
|
|
|
145
171
|
// Get values when cell edited
|
|
146
172
|
const getEditedColumn = (params) => {
|
|
147
173
|
var _a;
|
|
148
|
-
console.log(params, 'edited column');
|
|
149
174
|
const editedColumn = (_a = params === null || params === void 0 ? void 0 : params.colDef) === null || _a === void 0 ? void 0 : _a.field;
|
|
150
175
|
const editedRow = params === null || params === void 0 ? void 0 : params.data;
|
|
151
|
-
console.log(editedRow, editedColumn,
|
|
176
|
+
console.log(editedRow, editedColumn, "edited row ");
|
|
152
177
|
};
|
|
153
178
|
// Options that grid should have
|
|
154
179
|
const gridOptions = {
|
|
@@ -188,21 +213,22 @@ function ParentForGrid(props) {
|
|
|
188
213
|
}
|
|
189
214
|
}, [featureDetails.searchedText]);
|
|
190
215
|
// Remove all checkbox selection if any feature added
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}, [featureDetails]);
|
|
199
|
-
console.log(isLoading, gridOptions, props === null || props === void 0 ? void 0 : props.pinnedTopRowData,
|
|
216
|
+
// useEffect(() => {
|
|
217
|
+
// setCheckBoxSelection({
|
|
218
|
+
// allBoxChecked: false,
|
|
219
|
+
// isInterminate: false,
|
|
220
|
+
// selectedCheckboxData: [],
|
|
221
|
+
// unselectedCheckboxData: [],
|
|
222
|
+
// });
|
|
223
|
+
// }, [featureDetails]);
|
|
224
|
+
console.log(isLoading, gridOptions, props === null || props === void 0 ? void 0 : props.pinnedTopRowData, "is loading state");
|
|
200
225
|
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(error_ui_1.default, { children: (0, jsx_runtime_1.jsx)("div", Object.assign({ style: { height: "100%", width: style.width }, className: "ag-grid-container border-1 border-gray-200 border-round" }, { children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(MyProvider_1.default, Object.assign({ value: {
|
|
201
226
|
featureDetails,
|
|
202
227
|
setFeatureDetails,
|
|
203
228
|
gridData,
|
|
204
229
|
callGrid,
|
|
205
|
-
totalRecords
|
|
230
|
+
totalRecords,
|
|
231
|
+
initialFeature
|
|
206
232
|
} }, { children: (0, jsx_runtime_1.jsx)(advanced_feature_1.default, { props: props }) })), (0, jsx_runtime_1.jsx)(AgGrid_1.default, { style: style, gridOptions: gridOptions, onGridReady: onGridReady })] }) })) }) }));
|
|
207
233
|
}
|
|
208
234
|
exports.default = ParentForGrid;
|
|
@@ -7,12 +7,13 @@ const custom_sort_1 = tslib_1.__importDefault(require("./custom-sort"));
|
|
|
7
7
|
const record_detail_1 = tslib_1.__importDefault(require("./record-detail"));
|
|
8
8
|
const filter_1 = tslib_1.__importDefault(require("./filter/filter"));
|
|
9
9
|
const refresh_grid_1 = tslib_1.__importDefault(require("./refresh-grid"));
|
|
10
|
+
const remove_items_1 = tslib_1.__importDefault(require("./remove-items"));
|
|
10
11
|
// import HideColumn from "./hide-column"
|
|
11
12
|
// import Grouping from "./grouping"
|
|
12
13
|
// import { ConditionsToDisplay } from "../Types"
|
|
13
14
|
function AdvancedFeatures({ props }) {
|
|
14
15
|
const conditionsToDisplay = props === null || props === void 0 ? void 0 : props.conditionsToDisplay;
|
|
15
16
|
// const {displayFilter,displaySearch,displayRefresh,displaySort} = conditionsToDisplay
|
|
16
|
-
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "flex align-items-center justify-content-between py-3 px-4" }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "flex align-items-center" }, { children: [(conditionsToDisplay === null || conditionsToDisplay === void 0 ? void 0 : conditionsToDisplay.displaySearch) && (0, jsx_runtime_1.jsx)(global_search_1.default, { searchPlaceHolder: props === null || props === void 0 ? void 0 : props.placeholder }), (conditionsToDisplay === null || conditionsToDisplay === void 0 ? void 0 : conditionsToDisplay.displayFilter) && (0, jsx_runtime_1.jsx)(filter_1.default, { callBackForSelect: props === null || props === void 0 ? void 0 : props.myInputData })] })), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "flex align-items-center" }, { children: [(conditionsToDisplay === null || conditionsToDisplay === void 0 ? void 0 : conditionsToDisplay.displayRefresh) && (0, jsx_runtime_1.jsx)(refresh_grid_1.default, {}), (conditionsToDisplay === null || conditionsToDisplay === void 0 ? void 0 : conditionsToDisplay.displaySort) && (0, jsx_runtime_1.jsx)(custom_sort_1.default, {}), (0, jsx_runtime_1.jsx)(record_detail_1.default, {})] }))] })));
|
|
17
|
+
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "flex align-items-center justify-content-between py-3 px-4" }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "flex align-items-center" }, { children: [(conditionsToDisplay === null || conditionsToDisplay === void 0 ? void 0 : conditionsToDisplay.displaySearch) && (0, jsx_runtime_1.jsx)(global_search_1.default, { searchPlaceHolder: props === null || props === void 0 ? void 0 : props.placeholder }), (conditionsToDisplay === null || conditionsToDisplay === void 0 ? void 0 : conditionsToDisplay.displayFilter) && (0, jsx_runtime_1.jsx)(filter_1.default, { callBackForSelect: props === null || props === void 0 ? void 0 : props.myInputData })] })), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "flex align-items-center" }, { children: [(conditionsToDisplay === null || conditionsToDisplay === void 0 ? void 0 : conditionsToDisplay.displayRemoveItems) && (0, jsx_runtime_1.jsx)(remove_items_1.default, {}), (conditionsToDisplay === null || conditionsToDisplay === void 0 ? void 0 : conditionsToDisplay.displayRefresh) && (0, jsx_runtime_1.jsx)(refresh_grid_1.default, {}), (conditionsToDisplay === null || conditionsToDisplay === void 0 ? void 0 : conditionsToDisplay.displaySort) && (0, jsx_runtime_1.jsx)(custom_sort_1.default, {}), (0, jsx_runtime_1.jsx)(record_detail_1.default, {})] }))] })));
|
|
17
18
|
}
|
|
18
19
|
exports.default = AdvancedFeatures;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const MyProvider_1 = require("../MyProvider");
|
|
6
|
+
function RemoveItems() {
|
|
7
|
+
const { featureDetails, callGrid } = (0, react_1.useContext)(MyProvider_1.FeatureContext);
|
|
8
|
+
const removeItemsCallBack = () => {
|
|
9
|
+
const currentFeature = Object.assign({}, featureDetails);
|
|
10
|
+
currentFeature.isRemoveClicked = true;
|
|
11
|
+
callGrid(currentFeature);
|
|
12
|
+
};
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)("button", Object.assign({ onClick: removeItemsCallBack }, { children: "-" })) }));
|
|
14
|
+
}
|
|
15
|
+
exports.default = RemoveItems;
|
|
@@ -8,6 +8,7 @@ interface MyProviderProps {
|
|
|
8
8
|
gridData: GridData;
|
|
9
9
|
callGrid: (featureDetails: Features) => void;
|
|
10
10
|
totalRecords: number;
|
|
11
|
+
initialFeature: Features;
|
|
11
12
|
};
|
|
12
13
|
}
|
|
13
14
|
declare function MyProvider({ children, value }: MyProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -57,6 +57,8 @@ export interface Features {
|
|
|
57
57
|
searchedText: string;
|
|
58
58
|
filterQueries: Filter[] | [];
|
|
59
59
|
sort: Sort;
|
|
60
|
+
checkBoxSelection: CheckBoxSelection;
|
|
61
|
+
isRemoveClicked: boolean;
|
|
60
62
|
}
|
|
61
63
|
export interface ParentProp {
|
|
62
64
|
}
|
|
@@ -84,10 +86,13 @@ export interface GridData {
|
|
|
84
86
|
columnData: ColumnDef[];
|
|
85
87
|
}
|
|
86
88
|
export interface ConditionsToDisplay {
|
|
87
|
-
displayFilter
|
|
88
|
-
displaySort
|
|
89
|
-
displaySearch
|
|
90
|
-
displayRefresh
|
|
89
|
+
displayFilter?: boolean;
|
|
90
|
+
displaySort?: boolean;
|
|
91
|
+
displaySearch?: boolean;
|
|
92
|
+
displayRefresh?: boolean;
|
|
93
|
+
displayRemoveItems?: boolean;
|
|
94
|
+
displayGrouping?: boolean;
|
|
95
|
+
displayColumnHide?: boolean;
|
|
91
96
|
}
|
|
92
97
|
export interface PropsFromProduct {
|
|
93
98
|
columnData: ColumnDef[];
|
|
@@ -99,5 +104,9 @@ export interface PropsFromProduct {
|
|
|
99
104
|
export interface ResoponseFromCallback {
|
|
100
105
|
totalRecords: number;
|
|
101
106
|
rowData: any[];
|
|
107
|
+
}
|
|
108
|
+
export interface ResponseFromApi {
|
|
109
|
+
totalRecords: number;
|
|
110
|
+
rowData: any[];
|
|
102
111
|
actualEndRow?: number;
|
|
103
112
|
}
|