rez-table-listing-mui 1.3.19 → 1.3.21
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.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/listing/components/filter/components/forms/components/Dropdown.tsx +137 -32
- package/src/listing/components/filter/components/forms/utils/filter-date-input-resolver.tsx +5 -9
package/package.json
CHANGED
|
@@ -16,24 +16,6 @@ interface FormDropdownProps {
|
|
|
16
16
|
onValueChange?: () => void;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
// Allowed date-based operators
|
|
20
|
-
const DATE_ALLOWED_OPERATORS = [
|
|
21
|
-
"equal",
|
|
22
|
-
"before",
|
|
23
|
-
"after",
|
|
24
|
-
"between",
|
|
25
|
-
"is",
|
|
26
|
-
"today",
|
|
27
|
-
"is_day_before",
|
|
28
|
-
"is_day_after",
|
|
29
|
-
"is_month_before",
|
|
30
|
-
"is_month_after",
|
|
31
|
-
"is_before",
|
|
32
|
-
"is_after",
|
|
33
|
-
"is_on_or_before",
|
|
34
|
-
"is_on_or_after",
|
|
35
|
-
];
|
|
36
|
-
|
|
37
19
|
const FormDropdown = ({
|
|
38
20
|
filter,
|
|
39
21
|
control,
|
|
@@ -72,21 +54,10 @@ const FormDropdown = ({
|
|
|
72
54
|
const newOperator = e.target.value;
|
|
73
55
|
const oldOperator = field.value;
|
|
74
56
|
|
|
57
|
+
// Update RHF field
|
|
75
58
|
field.onChange(e);
|
|
76
59
|
|
|
77
|
-
//
|
|
78
|
-
if (filter.filter_attribute_data_type === "date") {
|
|
79
|
-
const wasDateOp = DATE_ALLOWED_OPERATORS.includes(oldOperator);
|
|
80
|
-
const isDateOpNow =
|
|
81
|
-
DATE_ALLOWED_OPERATORS.includes(newOperator);
|
|
82
|
-
|
|
83
|
-
if (wasDateOp !== isDateOpNow) {
|
|
84
|
-
setValue(`${filter?.filter_attribute_name}.value`, "", {
|
|
85
|
-
shouldDirty: true,
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
60
|
+
// Handle date/year specific operator-based value reset logic
|
|
90
61
|
if (
|
|
91
62
|
(filter?.filter_attribute_data_type === "date" ||
|
|
92
63
|
filter?.filter_attribute_data_type === "year") &&
|
|
@@ -114,7 +85,10 @@ const FormDropdown = ({
|
|
|
114
85
|
}
|
|
115
86
|
}
|
|
116
87
|
|
|
117
|
-
|
|
88
|
+
// ⭐ FIX: Ensure parent form re-evaluates AFTER RHF updates the operator
|
|
89
|
+
setTimeout(() => {
|
|
90
|
+
onValueChange?.();
|
|
91
|
+
}, 0);
|
|
118
92
|
}}
|
|
119
93
|
>
|
|
120
94
|
{dropdownList?.map((item, idx) => (
|
|
@@ -131,6 +105,137 @@ const FormDropdown = ({
|
|
|
131
105
|
|
|
132
106
|
export default FormDropdown;
|
|
133
107
|
|
|
108
|
+
// import { FormControl, MenuItem, Select, SxProps, Theme } from "@mui/material";
|
|
109
|
+
// import { Controller, UseFormSetValue } from "react-hook-form";
|
|
110
|
+
// import { FilterStateProps } from "../../../../../types/filter";
|
|
111
|
+
// import moment from "moment";
|
|
112
|
+
|
|
113
|
+
// interface FormDropdownProps {
|
|
114
|
+
// filter: FilterStateProps;
|
|
115
|
+
// control: any;
|
|
116
|
+
// setValue: UseFormSetValue<any>;
|
|
117
|
+
// dropdownList: {
|
|
118
|
+
// label?: string;
|
|
119
|
+
// value?: string;
|
|
120
|
+
// }[];
|
|
121
|
+
// isLoading?: boolean;
|
|
122
|
+
// sx?: SxProps<Theme>;
|
|
123
|
+
// onValueChange?: () => void;
|
|
124
|
+
// }
|
|
125
|
+
|
|
126
|
+
// // Allowed date-based operators
|
|
127
|
+
// const DATE_ALLOWED_OPERATORS = [
|
|
128
|
+
// "equal",
|
|
129
|
+
// "before",
|
|
130
|
+
// "after",
|
|
131
|
+
// "between",
|
|
132
|
+
// "is",
|
|
133
|
+
// "today",
|
|
134
|
+
// "is_before",
|
|
135
|
+
// "is_after",
|
|
136
|
+
// "is_on_or_before",
|
|
137
|
+
// "is_on_or_after",
|
|
138
|
+
// "empty",
|
|
139
|
+
// "not_empty",
|
|
140
|
+
// ];
|
|
141
|
+
|
|
142
|
+
// const FormDropdown = ({
|
|
143
|
+
// filter,
|
|
144
|
+
// control,
|
|
145
|
+
// setValue,
|
|
146
|
+
// dropdownList,
|
|
147
|
+
// isLoading = false,
|
|
148
|
+
// sx,
|
|
149
|
+
// onValueChange,
|
|
150
|
+
// }: FormDropdownProps) => {
|
|
151
|
+
// return (
|
|
152
|
+
// <Controller
|
|
153
|
+
// name={`${filter?.filter_attribute_name}.operator`}
|
|
154
|
+
// control={control}
|
|
155
|
+
// defaultValue={filter?.filter_operator || dropdownList?.[0]?.value || ""}
|
|
156
|
+
// render={({ field }) => (
|
|
157
|
+
// <FormControl sx={sx} size="small">
|
|
158
|
+
// <Select
|
|
159
|
+
// {...field}
|
|
160
|
+
// variant="standard"
|
|
161
|
+
// sx={{
|
|
162
|
+
// fontSize: "0.875rem",
|
|
163
|
+
// minWidth: 50,
|
|
164
|
+
// border: "none",
|
|
165
|
+
// boxShadow: "none",
|
|
166
|
+
// "& .MuiSelect-icon": {
|
|
167
|
+
// top: "45%",
|
|
168
|
+
// transform: "translateY(-50%)",
|
|
169
|
+
// "& .MuiOutlinedInput-input": {
|
|
170
|
+
// padding: "12px 20px",
|
|
171
|
+
// },
|
|
172
|
+
// },
|
|
173
|
+
// }}
|
|
174
|
+
// disabled={isLoading}
|
|
175
|
+
// disableUnderline
|
|
176
|
+
// onChange={(e) => {
|
|
177
|
+
// const newOperator = e.target.value;
|
|
178
|
+
// const oldOperator = field.value;
|
|
179
|
+
|
|
180
|
+
// field.onChange(e);
|
|
181
|
+
|
|
182
|
+
// // Reset value if operator switches date → non-date or non-date → date
|
|
183
|
+
// if (filter.filter_attribute_data_type === "date") {
|
|
184
|
+
// const wasDateOp = DATE_ALLOWED_OPERATORS.includes(oldOperator);
|
|
185
|
+
// const isDateOpNow =
|
|
186
|
+
// DATE_ALLOWED_OPERATORS.includes(newOperator);
|
|
187
|
+
|
|
188
|
+
// if (wasDateOp !== isDateOpNow) {
|
|
189
|
+
// setValue(`${filter?.filter_attribute_name}.value`, "", {
|
|
190
|
+
// shouldDirty: true,
|
|
191
|
+
// });
|
|
192
|
+
// }
|
|
193
|
+
// }
|
|
194
|
+
|
|
195
|
+
// if (
|
|
196
|
+
// (filter?.filter_attribute_data_type === "date" ||
|
|
197
|
+
// filter?.filter_attribute_data_type === "year") &&
|
|
198
|
+
// newOperator !== oldOperator
|
|
199
|
+
// ) {
|
|
200
|
+
// if (newOperator === "today") {
|
|
201
|
+
// setValue(
|
|
202
|
+
// `${filter?.filter_attribute_name}.value`,
|
|
203
|
+
// moment().format("YYYY-MM-DD"),
|
|
204
|
+
// {
|
|
205
|
+
// shouldDirty: true,
|
|
206
|
+
// }
|
|
207
|
+
// );
|
|
208
|
+
// } else if (newOperator === "between") {
|
|
209
|
+
// setValue(`${filter?.filter_attribute_name}.value`, ["", ""], {
|
|
210
|
+
// shouldDirty: true,
|
|
211
|
+
// });
|
|
212
|
+
// } else if (
|
|
213
|
+
// oldOperator === "between" ||
|
|
214
|
+
// oldOperator === "today"
|
|
215
|
+
// ) {
|
|
216
|
+
// setValue(`${filter?.filter_attribute_name}.value`, "", {
|
|
217
|
+
// shouldDirty: true,
|
|
218
|
+
// });
|
|
219
|
+
// }
|
|
220
|
+
// }
|
|
221
|
+
|
|
222
|
+
// onValueChange?.();
|
|
223
|
+
// }}
|
|
224
|
+
// >
|
|
225
|
+
// {dropdownList?.map((item, idx) => (
|
|
226
|
+
// <MenuItem key={idx} value={item.value}>
|
|
227
|
+
// {item.label}
|
|
228
|
+
// </MenuItem>
|
|
229
|
+
// ))}
|
|
230
|
+
// </Select>
|
|
231
|
+
// </FormControl>
|
|
232
|
+
// )}
|
|
233
|
+
// />
|
|
234
|
+
// );
|
|
235
|
+
// };
|
|
236
|
+
|
|
237
|
+
// export default FormDropdown;
|
|
238
|
+
|
|
134
239
|
// !! DON'T DELETE THIS OLD CODE !! //
|
|
135
240
|
|
|
136
241
|
// import { FormControl, MenuItem, Select, SxProps, Theme } from "@mui/material";
|
|
@@ -11,14 +11,12 @@ export type DateOperator =
|
|
|
11
11
|
| "between"
|
|
12
12
|
| "is"
|
|
13
13
|
| "today"
|
|
14
|
-
| "is_day_before"
|
|
15
|
-
| "is_day_after"
|
|
16
|
-
| "is_month_before"
|
|
17
|
-
| "is_month_after"
|
|
18
14
|
| "is_before"
|
|
19
15
|
| "is_after"
|
|
20
16
|
| "is_on_or_before"
|
|
21
|
-
| "is_on_or_after"
|
|
17
|
+
| "is_on_or_after"
|
|
18
|
+
| "empty"
|
|
19
|
+
| "not_empty";
|
|
22
20
|
|
|
23
21
|
export const DATE_ALLOWED_OPERATORS: DateOperator[] = [
|
|
24
22
|
"equal",
|
|
@@ -27,14 +25,12 @@ export const DATE_ALLOWED_OPERATORS: DateOperator[] = [
|
|
|
27
25
|
"between",
|
|
28
26
|
"is",
|
|
29
27
|
"today",
|
|
30
|
-
"is_day_before",
|
|
31
|
-
"is_day_after",
|
|
32
|
-
"is_month_before",
|
|
33
|
-
"is_month_after",
|
|
34
28
|
"is_before",
|
|
35
29
|
"is_after",
|
|
36
30
|
"is_on_or_before",
|
|
37
31
|
"is_on_or_after",
|
|
32
|
+
"empty",
|
|
33
|
+
"not_empty",
|
|
38
34
|
];
|
|
39
35
|
|
|
40
36
|
export const resolveFilterInput = ({
|