rez-table-listing-mui 1.0.29 → 1.0.31
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/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/App.tsx +11 -11
- package/src/components/common/confirm-modal/index.tsx +4 -0
- package/src/components/filter/components/forms/components/Date.tsx +3 -1
- package/src/components/filter/components/forms/components/Filter-criteria.tsx +12 -1
- package/src/components/filter/components/forms/index.tsx +18 -7
- package/src/components/filter/components/search/index.tsx +6 -1
- package/src/components/filter/index.tsx +6 -2
- package/src/libs/hooks/useCraftTable.tsx +1 -1
- package/src/libs/utils/common.ts +1 -1
- package/src/libs/utils/debounce.ts +15 -0
package/src/App.tsx
CHANGED
|
@@ -24,7 +24,7 @@ function App() {
|
|
|
24
24
|
const [columns, setColumns] = useState<any[]>([]);
|
|
25
25
|
const [searchTerm, setSearchTerm] = useState("");
|
|
26
26
|
// const [data, setData] = useState<Person[]>(() => makeData(50, 3, 2));
|
|
27
|
-
// const [entity_type] = useState(ENTITY_TYPE); //OR
|
|
27
|
+
// const [entity_type] = useState(ENTITY_TYPE); //OR NTM BRD
|
|
28
28
|
|
|
29
29
|
const [selectedTab, setSelectedTab] = useState("ALL");
|
|
30
30
|
|
|
@@ -33,7 +33,7 @@ function App() {
|
|
|
33
33
|
|
|
34
34
|
const { defaultColumns } = useDefaultColumns();
|
|
35
35
|
|
|
36
|
-
const { metaQuery } = useFetchData("
|
|
36
|
+
const { metaQuery } = useFetchData("NTM");
|
|
37
37
|
const { detailsQuery } = useDetailsQueryAPI(
|
|
38
38
|
filterMaster?.saved_filters?.selectedId
|
|
39
39
|
? filterMaster?.saved_filters?.selectedId
|
|
@@ -58,7 +58,7 @@ function App() {
|
|
|
58
58
|
|
|
59
59
|
const fetchMeta = async () => {
|
|
60
60
|
try {
|
|
61
|
-
const { res } = await entityTableMetaMaster("
|
|
61
|
+
const { res } = await entityTableMetaMaster("NTM");
|
|
62
62
|
setColumns(res);
|
|
63
63
|
} catch (error) {
|
|
64
64
|
console.error("Failed to fetch metadata:", error);
|
|
@@ -77,7 +77,7 @@ function App() {
|
|
|
77
77
|
const { tableData, isTableDataPending } = useEntityTableAPI({
|
|
78
78
|
page: 0,
|
|
79
79
|
size: 50,
|
|
80
|
-
entity_type: "
|
|
80
|
+
entity_type: "NTM",
|
|
81
81
|
tabs: {
|
|
82
82
|
columnName: "status",
|
|
83
83
|
sortBy: "ASC",
|
|
@@ -156,7 +156,7 @@ function App() {
|
|
|
156
156
|
const payload = {
|
|
157
157
|
name,
|
|
158
158
|
is_default: false,
|
|
159
|
-
mapped_entity_type: "
|
|
159
|
+
mapped_entity_type: "NTM", // For that entity type
|
|
160
160
|
status: "ACTIVE",
|
|
161
161
|
entity_type: "SFM", // FIXED entity type
|
|
162
162
|
filterDetails: quickFilter,
|
|
@@ -171,7 +171,7 @@ function App() {
|
|
|
171
171
|
name: filterToDelete?.label,
|
|
172
172
|
id: filterToDelete?.value,
|
|
173
173
|
is_default: false,
|
|
174
|
-
mapped_entity_type: "
|
|
174
|
+
mapped_entity_type: "NTM",
|
|
175
175
|
status: "INACTIVE",
|
|
176
176
|
entity_type: "SFM",
|
|
177
177
|
};
|
|
@@ -192,7 +192,7 @@ function App() {
|
|
|
192
192
|
name: filterMaster?.saved_filters?.selectedName, // Name of the filter
|
|
193
193
|
is_default: false,
|
|
194
194
|
id: filterMaster?.saved_filters?.selectedId,
|
|
195
|
-
mapped_entity_type: "
|
|
195
|
+
mapped_entity_type: "NTM",
|
|
196
196
|
status: "ACTIVE",
|
|
197
197
|
entity_type: "SFM",
|
|
198
198
|
filterDetails: quickFilter,
|
|
@@ -218,10 +218,10 @@ function App() {
|
|
|
218
218
|
enableRowSelection: false,
|
|
219
219
|
enableServerSideSorting: enableServerSideSorting,
|
|
220
220
|
}}
|
|
221
|
-
loadingOptions={{
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}}
|
|
221
|
+
// loadingOptions={{
|
|
222
|
+
// isLoading: isTableDataPending || detailsQuery.isPending,
|
|
223
|
+
// // loaderText: "Loading, Please wait...",
|
|
224
|
+
// }}
|
|
225
225
|
topbarOptions={{
|
|
226
226
|
tableStates,
|
|
227
227
|
leftSideComponent: (
|
|
@@ -32,6 +32,7 @@ export interface InputField {
|
|
|
32
32
|
multiline?: boolean;
|
|
33
33
|
rows?: number;
|
|
34
34
|
defaultValue?: string;
|
|
35
|
+
labelClassName?: string;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
export interface ConfirmModalProps {
|
|
@@ -43,6 +44,7 @@ export interface ConfirmModalProps {
|
|
|
43
44
|
input?: InputField;
|
|
44
45
|
maxWidth?: "xs" | "sm" | "md" | "lg" | "xl";
|
|
45
46
|
fullWidth?: boolean;
|
|
47
|
+
className?: string;
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
const ConfirmModal: React.FC<ConfirmModalProps> = ({
|
|
@@ -130,6 +132,7 @@ const ConfirmModal: React.FC<ConfirmModalProps> = ({
|
|
|
130
132
|
<Typography
|
|
131
133
|
variant="body2"
|
|
132
134
|
component="label"
|
|
135
|
+
className={input.labelClassName}
|
|
133
136
|
sx={{
|
|
134
137
|
display: "block",
|
|
135
138
|
marginBottom: 1,
|
|
@@ -180,6 +183,7 @@ const ConfirmModal: React.FC<ConfirmModalProps> = ({
|
|
|
180
183
|
key={index}
|
|
181
184
|
variant={button.variant || "outlined"}
|
|
182
185
|
color={button.color || "primary"}
|
|
186
|
+
className="confirm-modal-button"
|
|
183
187
|
sx={button.sx}
|
|
184
188
|
onClick={() => handleButtonClick(button)}
|
|
185
189
|
disabled={
|
|
@@ -9,12 +9,14 @@ import { SxProps, Theme } from "@mui/material";
|
|
|
9
9
|
const FormDatePicker = ({
|
|
10
10
|
filter,
|
|
11
11
|
control,
|
|
12
|
-
sx,
|
|
13
12
|
}: {
|
|
14
13
|
filter: UpdatedFilterStateProps;
|
|
15
14
|
control: any;
|
|
16
15
|
sx?: SxProps<Theme>;
|
|
17
16
|
}) => {
|
|
17
|
+
const range = filter.filter_operator === "between";
|
|
18
|
+
console.log("range+++", range);
|
|
19
|
+
|
|
18
20
|
return (
|
|
19
21
|
<Controller
|
|
20
22
|
name={`${filter?.name}.value`} // or use a consistent structure like `filters.${index}.filter_value`
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
UpdatedFilterStateProps,
|
|
17
17
|
} from "../../../../../types/filter";
|
|
18
18
|
import { CraftTableOptionsProps } from "../../../../../types/table-options";
|
|
19
|
+
import CustomSearch from "../../search";
|
|
19
20
|
|
|
20
21
|
const FilterCriteria = ({
|
|
21
22
|
columnsData,
|
|
@@ -45,11 +46,20 @@ const FilterCriteria = ({
|
|
|
45
46
|
|
|
46
47
|
const handleAddFilter = (column: FilterColumnsListProps) => {
|
|
47
48
|
const dropdownOptions = columnsData.operation_list[column.data_type];
|
|
49
|
+
|
|
50
|
+
// console.log("dropdownOptionssssss", dropdownOptions);
|
|
51
|
+
|
|
48
52
|
const defaultValue = column.data_type === "multiselect" ? [] : "";
|
|
53
|
+
console.log("defaultValue", defaultValue);
|
|
54
|
+
|
|
49
55
|
const defaultOperator = dropdownOptions?.[0]?.value || "";
|
|
56
|
+
// console.log("defaultOperator", defaultOperator);
|
|
57
|
+
|
|
50
58
|
const matchingDropdownList =
|
|
51
59
|
columnsData.operation_list[column.data_type] || [];
|
|
52
60
|
|
|
61
|
+
// console.log("matchingDropdownList", matchingDropdownList);
|
|
62
|
+
|
|
53
63
|
const newFilter = {
|
|
54
64
|
filter_attribute: column.attribute_key,
|
|
55
65
|
filter_operator: defaultOperator,
|
|
@@ -129,7 +139,8 @@ const FilterCriteria = ({
|
|
|
129
139
|
borderRadius: "6px",
|
|
130
140
|
}}
|
|
131
141
|
>
|
|
132
|
-
Filter by...
|
|
142
|
+
{/* Filter by... */}
|
|
143
|
+
{/* <CustomSearch placeholder="Filter by..." /> */}
|
|
133
144
|
</ListSubheader>
|
|
134
145
|
}
|
|
135
146
|
>
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from "../../../../types/filter";
|
|
16
16
|
import { Controller, useForm } from "react-hook-form";
|
|
17
17
|
import FormTextfield from "./components/Textfield";
|
|
18
|
-
import React, { useEffect, useMemo } from "react";
|
|
18
|
+
import React, { useEffect, useMemo, useCallback } from "react";
|
|
19
19
|
import FormSelect from "./components/Select";
|
|
20
20
|
import FormDatePicker from "./components/Date";
|
|
21
21
|
import FormDropdown from "./components/Dropdown";
|
|
@@ -23,6 +23,7 @@ import FormMultiSelect from "./components/Multi-Select";
|
|
|
23
23
|
import { CraftTableOptionsProps } from "../../../../types/table-options";
|
|
24
24
|
import FilterCriteria from "./components/Filter-criteria";
|
|
25
25
|
import CustomSearch from "../search";
|
|
26
|
+
import { customDebounce } from "../../../../libs/utils/debounce";
|
|
26
27
|
|
|
27
28
|
interface FormValues {
|
|
28
29
|
filterName: string;
|
|
@@ -106,9 +107,18 @@ const FilterForm = ({
|
|
|
106
107
|
|
|
107
108
|
// Reset form when filters change
|
|
108
109
|
useEffect(() => {
|
|
109
|
-
reset(defaultValues);
|
|
110
|
+
if (!isDirty) reset(defaultValues);
|
|
110
111
|
}, [selectedFilters, filterName]);
|
|
111
112
|
|
|
113
|
+
// Create a debounced version of the filter update function
|
|
114
|
+
const debouncedUpdateFilters = useCallback(
|
|
115
|
+
customDebounce((updatedFilters: UpdatedFilterStateProps[]) => {
|
|
116
|
+
setSelectedFilters(updatedFilters);
|
|
117
|
+
setFilters(updatedFilters);
|
|
118
|
+
}, 1000), // 1000ms delay
|
|
119
|
+
[setSelectedFilters, setFilters]
|
|
120
|
+
);
|
|
121
|
+
|
|
112
122
|
// Effect to update filters when form values change
|
|
113
123
|
useEffect(() => {
|
|
114
124
|
if (isDirty) {
|
|
@@ -128,10 +138,10 @@ const FilterForm = ({
|
|
|
128
138
|
return filter;
|
|
129
139
|
});
|
|
130
140
|
|
|
131
|
-
|
|
132
|
-
|
|
141
|
+
// Use the debounced update function instead of direct updates
|
|
142
|
+
debouncedUpdateFilters(updatedFilters);
|
|
133
143
|
}
|
|
134
|
-
}, [formValues]);
|
|
144
|
+
}, [formValues, isDirty, selectedFilters, debouncedUpdateFilters]);
|
|
135
145
|
|
|
136
146
|
// Cleanup effect
|
|
137
147
|
useEffect(() => {
|
|
@@ -231,6 +241,8 @@ const FilterForm = ({
|
|
|
231
241
|
columnsData={columnsData}
|
|
232
242
|
tableStates={tableStates}
|
|
233
243
|
setSelectedFilters={setSelectedFilters}
|
|
244
|
+
// searchTerm={searchTerm}
|
|
245
|
+
// setSearchTerm={setSearchTerm}
|
|
234
246
|
/>
|
|
235
247
|
|
|
236
248
|
{/* Render search input */}
|
|
@@ -296,9 +308,8 @@ const FilterForm = ({
|
|
|
296
308
|
sx={{ marginLeft: "auto" }}
|
|
297
309
|
onClick={() => {
|
|
298
310
|
const fieldName = `${filter.name}.value`;
|
|
299
|
-
unregister(fieldName);
|
|
311
|
+
unregister(fieldName);
|
|
300
312
|
|
|
301
|
-
// ✅ Trigger dirty manually (optional, but safe fallback)
|
|
302
313
|
setValue("filterName", formValues.filterName, {
|
|
303
314
|
shouldDirty: true,
|
|
304
315
|
});
|
|
@@ -6,6 +6,7 @@ interface SearchInputProps {
|
|
|
6
6
|
value: string;
|
|
7
7
|
onChange: (value: string) => void;
|
|
8
8
|
placeholder?: string;
|
|
9
|
+
className?: string;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
const CustomSearch = ({
|
|
@@ -28,10 +29,14 @@ const CustomSearch = ({
|
|
|
28
29
|
value={search}
|
|
29
30
|
onChange={handleChange}
|
|
30
31
|
placeholder={placeholder}
|
|
32
|
+
className={"search-input"}
|
|
31
33
|
InputProps={{
|
|
32
34
|
startAdornment: (
|
|
33
35
|
<InputAdornment position="start">
|
|
34
|
-
<SearchIcon
|
|
36
|
+
<SearchIcon
|
|
37
|
+
sx={{ color: "#888888", fontSize: "20px" }}
|
|
38
|
+
className="search-icon-svg"
|
|
39
|
+
/>
|
|
35
40
|
</InputAdornment>
|
|
36
41
|
),
|
|
37
42
|
}}
|
|
@@ -241,14 +241,18 @@ const FilterDrawer = ({
|
|
|
241
241
|
},
|
|
242
242
|
{
|
|
243
243
|
label: "Delete",
|
|
244
|
+
|
|
244
245
|
onClick: () => {
|
|
245
246
|
onDeleteFilter && onDeleteFilter();
|
|
246
|
-
|
|
247
247
|
setDeleteFilterModalOpen(false);
|
|
248
248
|
setEditMode && setEditMode(false);
|
|
249
249
|
},
|
|
250
250
|
variant: "contained",
|
|
251
|
-
sx: {
|
|
251
|
+
sx: {
|
|
252
|
+
color: "white",
|
|
253
|
+
backgroundColor: "#f63d68",
|
|
254
|
+
"&:hover": { backgroundColor: "#f63d68" },
|
|
255
|
+
},
|
|
252
256
|
},
|
|
253
257
|
]}
|
|
254
258
|
maxWidth="xs"
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
|
|
15
15
|
export function useCraftTable(paginationPageSize: number = 25) {
|
|
16
16
|
const [pagination, setPagination] = useState<PaginationState>({
|
|
17
|
-
pageIndex:
|
|
17
|
+
pageIndex: 1,
|
|
18
18
|
pageSize: paginationPageSize,
|
|
19
19
|
});
|
|
20
20
|
const [sorting, setSorting] = useState<SortingState>([]);
|
package/src/libs/utils/common.ts
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const customDebounce = <T extends (...args: any[]) => any>(
|
|
2
|
+
func: T,
|
|
3
|
+
delay: number
|
|
4
|
+
) => {
|
|
5
|
+
let timerId: NodeJS.Timeout;
|
|
6
|
+
|
|
7
|
+
return function (this: any, ...args: Parameters<T>) {
|
|
8
|
+
const context = this;
|
|
9
|
+
|
|
10
|
+
clearTimeout(timerId);
|
|
11
|
+
timerId = setTimeout(() => {
|
|
12
|
+
func.apply(context, args);
|
|
13
|
+
}, delay);
|
|
14
|
+
};
|
|
15
|
+
};
|