rez-table-listing-mui 1.3.18 → 1.3.20
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 +133 -0
- package/src/listing/components/filter/components/forms/index.tsx +538 -66
- package/src/listing/components/filter/components/forms/utils/filter-date-input-resolver.tsx +123 -0
- package/src/listing/components/login/index.tsx +1 -1
package/package.json
CHANGED
|
@@ -16,6 +16,22 @@ 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_before",
|
|
28
|
+
"is_after",
|
|
29
|
+
"is_on_or_before",
|
|
30
|
+
"is_on_or_after",
|
|
31
|
+
"empty",
|
|
32
|
+
"not_empty",
|
|
33
|
+
];
|
|
34
|
+
|
|
19
35
|
const FormDropdown = ({
|
|
20
36
|
filter,
|
|
21
37
|
control,
|
|
@@ -56,6 +72,19 @@ const FormDropdown = ({
|
|
|
56
72
|
|
|
57
73
|
field.onChange(e);
|
|
58
74
|
|
|
75
|
+
// Reset value if operator switches date → non-date or non-date → date
|
|
76
|
+
if (filter.filter_attribute_data_type === "date") {
|
|
77
|
+
const wasDateOp = DATE_ALLOWED_OPERATORS.includes(oldOperator);
|
|
78
|
+
const isDateOpNow =
|
|
79
|
+
DATE_ALLOWED_OPERATORS.includes(newOperator);
|
|
80
|
+
|
|
81
|
+
if (wasDateOp !== isDateOpNow) {
|
|
82
|
+
setValue(`${filter?.filter_attribute_name}.value`, "", {
|
|
83
|
+
shouldDirty: true,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
59
88
|
if (
|
|
60
89
|
(filter?.filter_attribute_data_type === "date" ||
|
|
61
90
|
filter?.filter_attribute_data_type === "year") &&
|
|
@@ -99,3 +128,107 @@ const FormDropdown = ({
|
|
|
99
128
|
};
|
|
100
129
|
|
|
101
130
|
export default FormDropdown;
|
|
131
|
+
|
|
132
|
+
// !! DON'T DELETE THIS OLD CODE !! //
|
|
133
|
+
|
|
134
|
+
// import { FormControl, MenuItem, Select, SxProps, Theme } from "@mui/material";
|
|
135
|
+
// import { Controller, UseFormSetValue } from "react-hook-form";
|
|
136
|
+
// import { FilterStateProps } from "../../../../../types/filter";
|
|
137
|
+
// import moment from "moment";
|
|
138
|
+
|
|
139
|
+
// interface FormDropdownProps {
|
|
140
|
+
// filter: FilterStateProps;
|
|
141
|
+
// control: any;
|
|
142
|
+
// setValue: UseFormSetValue<any>;
|
|
143
|
+
// dropdownList: {
|
|
144
|
+
// label?: string;
|
|
145
|
+
// value?: string;
|
|
146
|
+
// }[];
|
|
147
|
+
// isLoading?: boolean;
|
|
148
|
+
// sx?: SxProps<Theme>;
|
|
149
|
+
// onValueChange?: () => void;
|
|
150
|
+
// }
|
|
151
|
+
|
|
152
|
+
// const FormDropdown = ({
|
|
153
|
+
// filter,
|
|
154
|
+
// control,
|
|
155
|
+
// setValue,
|
|
156
|
+
// dropdownList,
|
|
157
|
+
// isLoading = false,
|
|
158
|
+
// sx,
|
|
159
|
+
// onValueChange,
|
|
160
|
+
// }: FormDropdownProps) => {
|
|
161
|
+
// return (
|
|
162
|
+
// <Controller
|
|
163
|
+
// name={`${filter?.filter_attribute_name}.operator`}
|
|
164
|
+
// control={control}
|
|
165
|
+
// defaultValue={filter?.filter_operator || dropdownList?.[0]?.value || ""}
|
|
166
|
+
// render={({ field }) => (
|
|
167
|
+
// <FormControl sx={sx} size="small">
|
|
168
|
+
// <Select
|
|
169
|
+
// {...field}
|
|
170
|
+
// variant="standard"
|
|
171
|
+
// sx={{
|
|
172
|
+
// fontSize: "0.875rem",
|
|
173
|
+
// minWidth: 50,
|
|
174
|
+
// border: "none",
|
|
175
|
+
// boxShadow: "none",
|
|
176
|
+
// "& .MuiSelect-icon": {
|
|
177
|
+
// top: "45%",
|
|
178
|
+
// transform: "translateY(-50%)",
|
|
179
|
+
// "& .MuiOutlinedInput-input": {
|
|
180
|
+
// padding: "12px 20px",
|
|
181
|
+
// },
|
|
182
|
+
// },
|
|
183
|
+
// }}
|
|
184
|
+
// disabled={isLoading}
|
|
185
|
+
// disableUnderline
|
|
186
|
+
// onChange={(e) => {
|
|
187
|
+
// const newOperator = e.target.value;
|
|
188
|
+
// const oldOperator = field.value;
|
|
189
|
+
|
|
190
|
+
// field.onChange(e);
|
|
191
|
+
|
|
192
|
+
// if (
|
|
193
|
+
// (filter?.filter_attribute_data_type === "date" ||
|
|
194
|
+
// filter?.filter_attribute_data_type === "year") &&
|
|
195
|
+
// newOperator !== oldOperator
|
|
196
|
+
// ) {
|
|
197
|
+
// if (newOperator === "today") {
|
|
198
|
+
// setValue(
|
|
199
|
+
// `${filter?.filter_attribute_name}.value`,
|
|
200
|
+
// moment().format("YYYY-MM-DD"),
|
|
201
|
+
// {
|
|
202
|
+
// shouldDirty: true,
|
|
203
|
+
// }
|
|
204
|
+
// );
|
|
205
|
+
// } else if (newOperator === "between") {
|
|
206
|
+
// setValue(`${filter?.filter_attribute_name}.value`, ["", ""], {
|
|
207
|
+
// shouldDirty: true,
|
|
208
|
+
// });
|
|
209
|
+
// } else if (
|
|
210
|
+
// oldOperator === "between" ||
|
|
211
|
+
// oldOperator === "today"
|
|
212
|
+
// ) {
|
|
213
|
+
// setValue(`${filter?.filter_attribute_name}.value`, "", {
|
|
214
|
+
// shouldDirty: true,
|
|
215
|
+
// });
|
|
216
|
+
// }
|
|
217
|
+
// }
|
|
218
|
+
|
|
219
|
+
// onValueChange?.();
|
|
220
|
+
// }}
|
|
221
|
+
// >
|
|
222
|
+
// {dropdownList?.map((item, idx) => (
|
|
223
|
+
// <MenuItem key={idx} value={item.value}>
|
|
224
|
+
// {item.label}
|
|
225
|
+
// </MenuItem>
|
|
226
|
+
// ))}
|
|
227
|
+
// </Select>
|
|
228
|
+
// </FormControl>
|
|
229
|
+
// )}
|
|
230
|
+
// />
|
|
231
|
+
// );
|
|
232
|
+
// };
|
|
233
|
+
|
|
234
|
+
// export default FormDropdown;
|