rez-table-listing-mui 1.2.19 → 1.3.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.
- package/dist/index.d.ts +63 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -3
- package/src/listing/components/common/loader/loader.tsx +1 -0
- package/src/listing/components/filter/components/attributes-filter.tsx +3 -91
- package/src/listing/components/filter/components/forms/components/Date.tsx +2 -2
- package/src/listing/components/filter/components/forms/components/Dropdown.tsx +2 -2
- package/src/listing/components/filter/components/forms/components/Filter-criteria.tsx +31 -82
- package/src/listing/components/filter/components/forms/components/Multi-Select.tsx +2 -2
- package/src/listing/components/filter/components/forms/components/Select.tsx +2 -2
- package/src/listing/components/filter/components/forms/components/Textfield.tsx +2 -2
- package/src/listing/components/filter/components/forms/components/empty-list.tsx +17 -0
- package/src/listing/components/filter/components/forms/components/filter-criteria-entity-list.tsx +92 -0
- package/src/listing/components/filter/components/forms/components/filter-criteria-list.tsx +104 -0
- package/src/listing/components/filter/components/forms/components/styles.tsx +2 -1
- package/src/listing/components/filter/components/forms/index.tsx +238 -174
- package/src/listing/components/filter/components/main-filter.tsx +6 -14
- package/src/listing/components/filter/components/saved-edit-filter.tsx +0 -31
- package/src/listing/components/filter/components/saved-filter.tsx +0 -22
- package/src/listing/components/filter/index.tsx +162 -130
- package/src/listing/components/filter/style.ts +20 -3
- package/src/listing/libs/hooks/useCraftTable.tsx +9 -0
- package/src/listing/libs/hooks/useEntityTableAPI.tsx +25 -0
- package/src/listing/libs/utils/apiColumn.ts +27 -1
- package/src/listing/libs/utils/deep-merge-objects.ts +18 -0
- package/src/listing/types/common.ts +0 -2
- package/src/listing/types/filter.ts +54 -7
- package/src/listing/types/table-options.ts +8 -0
- package/src/view/FIlterWrapper.tsx +45 -6
|
@@ -62,6 +62,30 @@ export interface FilterDropdownDataProps {
|
|
|
62
62
|
[key: string]: FilterOperationListProps[];
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
export interface FilterComponentOptionsMainFilterOptions {
|
|
66
|
+
showSaveButton?: boolean;
|
|
67
|
+
showClearAllButton?: boolean;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export type FilterComponentOptions =
|
|
71
|
+
| {
|
|
72
|
+
showMainHeader?: boolean;
|
|
73
|
+
showTabs?: true; // when true → additional fields allowed
|
|
74
|
+
showMainFilter?: boolean;
|
|
75
|
+
showSavedFilter?: boolean;
|
|
76
|
+
showAttributesFilter?: boolean;
|
|
77
|
+
tabOptions?: {
|
|
78
|
+
mainFilter?: FilterComponentOptionsMainFilterOptions;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
| {
|
|
82
|
+
showMainHeader?: boolean;
|
|
83
|
+
showTabs?: false; // explicitly false or omitted
|
|
84
|
+
tabOptions?: {
|
|
85
|
+
mainFilter?: FilterComponentOptionsMainFilterOptions;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
|
|
65
89
|
export interface FilterDrawerProps {
|
|
66
90
|
tableStates: CraftTableOptionsProps;
|
|
67
91
|
open?: boolean;
|
|
@@ -84,6 +108,7 @@ export interface FilterDrawerProps {
|
|
|
84
108
|
updatedFilters,
|
|
85
109
|
filterMaster,
|
|
86
110
|
}: onFilterChangeFunctionProps) => void;
|
|
111
|
+
filterComponentOptions?: FilterComponentOptions;
|
|
87
112
|
}
|
|
88
113
|
|
|
89
114
|
export interface FilterCriteria {
|
|
@@ -107,9 +132,6 @@ export interface FilterStateProps {
|
|
|
107
132
|
filter_attribute: string;
|
|
108
133
|
filter_operator: string;
|
|
109
134
|
filter_value: string | string[];
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export interface UpdatedFilterStateProps extends FilterStateProps {
|
|
113
135
|
id: string | number;
|
|
114
136
|
name: string | undefined;
|
|
115
137
|
data_type: FilterInputDataTypes | undefined;
|
|
@@ -122,6 +144,8 @@ export interface UpdatedFilterStateProps extends FilterStateProps {
|
|
|
122
144
|
label?: string | undefined;
|
|
123
145
|
value?: string | undefined;
|
|
124
146
|
};
|
|
147
|
+
filter_entity_type?: string;
|
|
148
|
+
filter_entity_name?: string;
|
|
125
149
|
}
|
|
126
150
|
|
|
127
151
|
interface FilterDetail {
|
|
@@ -171,10 +195,6 @@ export interface FilterFormComponentProps {
|
|
|
171
195
|
columnsData: FilterColumnsDataProps;
|
|
172
196
|
dropdownData: FilterDropdownDataProps;
|
|
173
197
|
tableStates: CraftTableOptionsProps;
|
|
174
|
-
selectedFilters: UpdatedFilterStateProps[];
|
|
175
|
-
setSelectedFilters: React.Dispatch<
|
|
176
|
-
React.SetStateAction<UpdatedFilterStateProps[]>
|
|
177
|
-
>;
|
|
178
198
|
editMode?: boolean;
|
|
179
199
|
setEditMode?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
180
200
|
setDeleteFilterModalOpen?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
@@ -184,6 +204,7 @@ export interface FilterFormComponentProps {
|
|
|
184
204
|
updatedFilters,
|
|
185
205
|
filterMaster,
|
|
186
206
|
}: onFilterChangeFunctionProps) => void;
|
|
207
|
+
filterComponentOptions?: FilterComponentOptions;
|
|
187
208
|
}
|
|
188
209
|
|
|
189
210
|
export interface FilterMasterStateProps {
|
|
@@ -224,3 +245,29 @@ export interface viewSettingsPayload {
|
|
|
224
245
|
column: string;
|
|
225
246
|
sort_by: string;
|
|
226
247
|
}
|
|
248
|
+
|
|
249
|
+
export interface FilterDataMainFilterEntityListProps {
|
|
250
|
+
value: string;
|
|
251
|
+
id: string | number;
|
|
252
|
+
label: string;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export interface FilterDataMainFilterEntityWiseCriteriaProps {
|
|
256
|
+
id: string;
|
|
257
|
+
name: string;
|
|
258
|
+
attribute_key: string;
|
|
259
|
+
element_type: FilterInputDataTypes;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export interface FilterDataProps {
|
|
263
|
+
mainFilter?: {
|
|
264
|
+
entityList?: {
|
|
265
|
+
data?: FilterDataMainFilterEntityListProps[];
|
|
266
|
+
isPending?: boolean;
|
|
267
|
+
};
|
|
268
|
+
entityWiseCriteria?: {
|
|
269
|
+
data?: FilterDataMainFilterEntityWiseCriteriaProps[];
|
|
270
|
+
isPending?: boolean;
|
|
271
|
+
};
|
|
272
|
+
};
|
|
273
|
+
}
|
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
} from "@tanstack/react-table";
|
|
8
8
|
import { Dispatch, SetStateAction } from "react";
|
|
9
9
|
import {
|
|
10
|
+
FilterDataMainFilterEntityListProps,
|
|
11
|
+
FilterDataProps,
|
|
10
12
|
FilterMasterStateProps,
|
|
11
13
|
FilterOperationListProps,
|
|
12
14
|
FilterStateProps,
|
|
@@ -48,6 +50,12 @@ export interface CraftTableOptionsProps {
|
|
|
48
50
|
setShowFilterOption: Dispatch<SetStateAction<boolean>>;
|
|
49
51
|
columnPinning: ColumnPinningState;
|
|
50
52
|
setColumnPinning: Dispatch<SetStateAction<ColumnPinningState>>;
|
|
53
|
+
filterData: FilterDataProps | null;
|
|
54
|
+
setFilterData: Dispatch<SetStateAction<FilterDataProps | null>>;
|
|
55
|
+
selectedFilterEntity: FilterDataMainFilterEntityListProps | undefined;
|
|
56
|
+
setSelectedFilterEntity: Dispatch<
|
|
57
|
+
SetStateAction<FilterDataMainFilterEntityListProps | undefined>
|
|
58
|
+
>;
|
|
51
59
|
}
|
|
52
60
|
|
|
53
61
|
export interface craftTableFilterSettingsOptionsProps {
|
|
@@ -1,28 +1,66 @@
|
|
|
1
1
|
import { useEffect } from "react";
|
|
2
|
-
import { CraftTableFilter } from "..";
|
|
2
|
+
import { CraftTableFilter, CraftTableOptionsProps } from "..";
|
|
3
3
|
import { useGetNavigationLayoutAPI } from "../listing/libs/hooks/useGetNavigationLayoutAPI";
|
|
4
4
|
import { ENTITY_TYPE } from "../listing/libs/utils/common";
|
|
5
5
|
import {
|
|
6
6
|
useDeleteFilterAPI,
|
|
7
|
+
useGetFilterEntityList,
|
|
7
8
|
useSavedFilterAPI,
|
|
8
9
|
useUpdateFilterAPI,
|
|
9
10
|
} from "../listing/libs/hooks/useEntityTableAPI";
|
|
10
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
FilterColumnsDataProps,
|
|
13
|
+
FilterComponentOptions,
|
|
14
|
+
FilterDropdownDataProps,
|
|
15
|
+
FilterDataProps,
|
|
16
|
+
FilterMasterStateProps,
|
|
17
|
+
} from "../listing/types/filter";
|
|
18
|
+
import { onFilterChangeFunctionProps } from "../listing/types/common";
|
|
11
19
|
|
|
12
20
|
const CraftTableFilterWrapper = ({
|
|
13
21
|
tableStates,
|
|
14
22
|
dropdownData,
|
|
15
23
|
onChangeFunction,
|
|
16
24
|
columnsData,
|
|
17
|
-
|
|
25
|
+
filterComponentOptions,
|
|
26
|
+
}: {
|
|
27
|
+
tableStates: CraftTableOptionsProps;
|
|
28
|
+
columnsData: FilterColumnsDataProps;
|
|
29
|
+
dropdownData: FilterDropdownDataProps;
|
|
30
|
+
onChangeFunction: ({
|
|
31
|
+
updatedFilters,
|
|
32
|
+
filterMaster,
|
|
33
|
+
}: onFilterChangeFunctionProps) => void;
|
|
34
|
+
filterComponentOptions?: FilterComponentOptions;
|
|
35
|
+
}) => {
|
|
18
36
|
const getNavigationLayoutQuery = useGetNavigationLayoutAPI(ENTITY_TYPE);
|
|
19
37
|
|
|
20
|
-
const {
|
|
21
|
-
|
|
38
|
+
const {
|
|
39
|
+
filters,
|
|
40
|
+
filterMaster,
|
|
41
|
+
setFilterMaster,
|
|
42
|
+
filterToDelete,
|
|
43
|
+
setFilterData,
|
|
44
|
+
} = tableStates;
|
|
22
45
|
|
|
23
46
|
const { savedMutation } = useSavedFilterAPI(); //API CALL FOR SAVED FILTER
|
|
24
47
|
const { updateMutation } = useUpdateFilterAPI(); //API FOR UPDATE FILTER
|
|
25
48
|
const { deleteMutation } = useDeleteFilterAPI(tableStates); //API FOR DELETING FILTER
|
|
49
|
+
const filterEntityList: any = useGetFilterEntityList({
|
|
50
|
+
entity_type: ENTITY_TYPE,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (filterEntityList?.data) {
|
|
55
|
+
setFilterData((prev: FilterDataProps | null) => ({
|
|
56
|
+
...prev,
|
|
57
|
+
mainFilter: {
|
|
58
|
+
...prev?.mainFilter,
|
|
59
|
+
entityList: filterEntityList?.data,
|
|
60
|
+
},
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
}, [filterEntityList?.data, filterEntityList?.isPending]);
|
|
26
64
|
|
|
27
65
|
// API to handle saving a filter
|
|
28
66
|
const handleSaveFilter = (name: string) => {
|
|
@@ -48,7 +86,7 @@ const CraftTableFilterWrapper = ({
|
|
|
48
86
|
const newFilterId = response?.id;
|
|
49
87
|
if (newFilterId) {
|
|
50
88
|
setFilterMaster(
|
|
51
|
-
(prev: FilterMasterStateProps) =>
|
|
89
|
+
(prev: FilterMasterStateProps | null) =>
|
|
52
90
|
({
|
|
53
91
|
...prev,
|
|
54
92
|
saved_filters: {
|
|
@@ -123,6 +161,7 @@ const CraftTableFilterWrapper = ({
|
|
|
123
161
|
onDeleteFilter={handleRemoveFilter}
|
|
124
162
|
onSaveFilter={handleSaveFilter}
|
|
125
163
|
onChangeFunction={onChangeFunction}
|
|
164
|
+
filterComponentOptions={filterComponentOptions}
|
|
126
165
|
/>
|
|
127
166
|
);
|
|
128
167
|
};
|