@banch0u/core-project-test-repository 2.3.25 → 2.3.27
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.
|
@@ -3,7 +3,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
4
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
5
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
|
-
import React, { useState } from "react";
|
|
6
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
7
7
|
import { Dropdown, Menu, Form, Select as AntdSelect, DatePicker, TreeSelect } from "antd";
|
|
8
8
|
import style from "./index.module.scss";
|
|
9
9
|
import { FilterIcon } from "../../assets/icons";
|
|
@@ -77,6 +77,47 @@ var Filter = function Filter(_ref) {
|
|
|
77
77
|
var filteredColumns = columns.filter(function (col) {
|
|
78
78
|
return selectedColumns.includes(col.dataIndex) && col.filter !== false && col.filterDisable !== true || col.dataIndex === "filterOnly";
|
|
79
79
|
});
|
|
80
|
+
|
|
81
|
+
// ✅ same matching as Select's search (case/diacritic-insensitive, az letters)
|
|
82
|
+
var normalizeAz = function normalizeAz(str) {
|
|
83
|
+
return str.replace(/I/g, "i").toLocaleLowerCase("az").normalize("NFD").replace(/[̀-ͯ]/g, "").replace(/ç/g, "c").replace(/ş/g, "s").replace(/ğ/g, "g").replace(/ü/g, "u").replace(/ö/g, "o").replace(/ə/g, "e");
|
|
84
|
+
};
|
|
85
|
+
var getFieldName = function getFieldName(col) {
|
|
86
|
+
return col.queryName ? col.queryName : col.dataIndex;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// ✅ dependent selects: a column with `dependsOn: "<parent field name>"`
|
|
90
|
+
// stays disabled until the parent has a value, and is cleared when it changes
|
|
91
|
+
var watchedValues = Form.useWatch([], filterForm);
|
|
92
|
+
var formValues = watchedValues || {};
|
|
93
|
+
|
|
94
|
+
// ✅ `onFilterChange(value)` fires whenever a column's form value changes,
|
|
95
|
+
// whether by user input, Clear (resetFields) or setFieldsValue
|
|
96
|
+
var prevValuesRef = useRef({});
|
|
97
|
+
useEffect(function () {
|
|
98
|
+
var values = watchedValues || {};
|
|
99
|
+
columns.forEach(function (col) {
|
|
100
|
+
if (!col.onFilterChange) return;
|
|
101
|
+
var name = getFieldName(col);
|
|
102
|
+
if (values[name] !== prevValuesRef.current[name]) {
|
|
103
|
+
col.onFilterChange(values[name]);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
prevValuesRef.current = values;
|
|
107
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
108
|
+
}, [watchedValues]);
|
|
109
|
+
var isEmptyValue = function isEmptyValue(v) {
|
|
110
|
+
return v === undefined || v === null || v === "" || Array.isArray(v) && v.length === 0;
|
|
111
|
+
};
|
|
112
|
+
var _clearDependents = function clearDependents(parentName) {
|
|
113
|
+
columns.filter(function (dep) {
|
|
114
|
+
return dep.dependsOn === parentName;
|
|
115
|
+
}).forEach(function (dep) {
|
|
116
|
+
var depName = getFieldName(dep);
|
|
117
|
+
filterForm.setFieldValue(depName, undefined);
|
|
118
|
+
_clearDependents(depName);
|
|
119
|
+
});
|
|
120
|
+
};
|
|
80
121
|
var getGrid = function getGrid() {
|
|
81
122
|
var elementCount = selectedColumns.length - disabledElementCount;
|
|
82
123
|
if (elementCount >= 5) return style.grid5;
|
|
@@ -105,30 +146,35 @@ var Filter = function Filter(_ref) {
|
|
|
105
146
|
return /*#__PURE__*/React.createElement(Form.Item, {
|
|
106
147
|
key: col.dataIndex,
|
|
107
148
|
label: col.title,
|
|
108
|
-
name: col
|
|
149
|
+
name: getFieldName(col),
|
|
109
150
|
className: gridSpanClass
|
|
110
151
|
}, /*#__PURE__*/React.createElement(Select, {
|
|
111
152
|
size: "sm",
|
|
112
153
|
style: {
|
|
113
154
|
height: "32px"
|
|
114
155
|
},
|
|
156
|
+
disabled: !!col.dependsOn && isEmptyValue(formValues[col.dependsOn]),
|
|
115
157
|
onChange: function onChange(value) {
|
|
116
158
|
if (col.dataIndex === "topic" || col.dataIndex === "contractTypeId" || col.dataIndex === "contractType") {
|
|
117
159
|
setSelectedTopic(value);
|
|
118
160
|
}
|
|
161
|
+
_clearDependents(getFieldName(col));
|
|
119
162
|
},
|
|
120
163
|
mode: col.selectType === "multiple" ? "multiple" : "single",
|
|
121
164
|
optionFilterProp: "label"
|
|
122
165
|
}, /*#__PURE__*/React.createElement(Option, {
|
|
123
166
|
value: ""
|
|
124
167
|
}), ((col === null || col === void 0 ? void 0 : col.selectData) || []).map(function (option, i) {
|
|
125
|
-
var _option$brandId, _option$modelId, _option$
|
|
168
|
+
var _option$brandId, _option$modelId, _option$name, _option$surname, _option$text;
|
|
126
169
|
var isIdArray = Array.isArray(option.id);
|
|
170
|
+
// ✅ children must be a single string for Select's search filter
|
|
171
|
+
var vehicleInfo = option !== null && option !== void 0 && option.registrationNumber && option !== null && option !== void 0 && (_option$brandId = option.brandId) !== null && _option$brandId !== void 0 && _option$brandId.text && option !== null && option !== void 0 && (_option$modelId = option.modelId) !== null && _option$modelId !== void 0 && _option$modelId.text ? " [".concat(option.registrationNumber, "] ").concat(option.brandId.text, " ").concat(option.modelId.text) : "";
|
|
172
|
+
var optionText = "".concat((_option$name = option.name) !== null && _option$name !== void 0 ? _option$name : "", " ").concat((_option$surname = option.surname) !== null && _option$surname !== void 0 ? _option$surname : "", " ").concat((_option$text = option.text) !== null && _option$text !== void 0 ? _option$text : "").concat(vehicleInfo).replace(/\s+/g, " ").trim();
|
|
127
173
|
return /*#__PURE__*/React.createElement(Option, {
|
|
128
174
|
key: i,
|
|
129
175
|
value: isIdArray ? JSON.stringify(option.id) : option.id,
|
|
130
|
-
label:
|
|
131
|
-
},
|
|
176
|
+
label: optionText
|
|
177
|
+
}, optionText);
|
|
132
178
|
})));
|
|
133
179
|
}
|
|
134
180
|
if (col.type === "date") {
|
|
@@ -150,6 +196,10 @@ var Filter = function Filter(_ref) {
|
|
|
150
196
|
className: gridSpanClass
|
|
151
197
|
}, /*#__PURE__*/React.createElement(TreeSelect, {
|
|
152
198
|
showSearch: true,
|
|
199
|
+
treeNodeFilterProp: "title",
|
|
200
|
+
filterTreeNode: function filterTreeNode(input, node) {
|
|
201
|
+
return typeof (node === null || node === void 0 ? void 0 : node.title) === "string" && normalizeAz(node.title).includes(normalizeAz(input));
|
|
202
|
+
},
|
|
153
203
|
popupMatchSelectWidth: false,
|
|
154
204
|
allowClear: true,
|
|
155
205
|
treeDefaultExpandAll: true,
|