@banch0u/core-project-test-repository 2.3.26 → 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,13 +77,35 @@ 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
+ };
80
85
  var getFieldName = function getFieldName(col) {
81
86
  return col.queryName ? col.queryName : col.dataIndex;
82
87
  };
83
88
 
84
89
  // ✅ dependent selects: a column with `dependsOn: "<parent field name>"`
85
90
  // stays disabled until the parent has a value, and is cleared when it changes
86
- var formValues = Form.useWatch([], filterForm) || {};
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]);
87
109
  var isEmptyValue = function isEmptyValue(v) {
88
110
  return v === undefined || v === null || v === "" || Array.isArray(v) && v.length === 0;
89
111
  };
@@ -133,25 +155,26 @@ var Filter = function Filter(_ref) {
133
155
  },
134
156
  disabled: !!col.dependsOn && isEmptyValue(formValues[col.dependsOn]),
135
157
  onChange: function onChange(value) {
136
- var _col$onFilterChange;
137
158
  if (col.dataIndex === "topic" || col.dataIndex === "contractTypeId" || col.dataIndex === "contractType") {
138
159
  setSelectedTopic(value);
139
160
  }
140
161
  _clearDependents(getFieldName(col));
141
- (_col$onFilterChange = col.onFilterChange) === null || _col$onFilterChange === void 0 || _col$onFilterChange.call(col, value);
142
162
  },
143
163
  mode: col.selectType === "multiple" ? "multiple" : "single",
144
164
  optionFilterProp: "label"
145
165
  }, /*#__PURE__*/React.createElement(Option, {
146
166
  value: ""
147
167
  }), ((col === null || col === void 0 ? void 0 : col.selectData) || []).map(function (option, i) {
148
- var _option$brandId, _option$modelId, _option$brandId2, _option$modelId2;
168
+ var _option$brandId, _option$modelId, _option$name, _option$surname, _option$text;
149
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();
150
173
  return /*#__PURE__*/React.createElement(Option, {
151
174
  key: i,
152
175
  value: isIdArray ? JSON.stringify(option.id) : option.id,
153
- label: option.name
154
- }, option.name, " ", option.surname, " ", option.text, (option === null || option === void 0 ? void 0 : option.registrationNumber) && (option === null || option === void 0 || (_option$brandId = option.brandId) === null || _option$brandId === void 0 ? void 0 : _option$brandId.text) && (option === null || option === void 0 || (_option$modelId = option.modelId) === null || _option$modelId === void 0 ? void 0 : _option$modelId.text) && " [".concat(option.registrationNumber, "] ").concat((_option$brandId2 = option.brandId) === null || _option$brandId2 === void 0 ? void 0 : _option$brandId2.text, " ").concat((_option$modelId2 = option.modelId) === null || _option$modelId2 === void 0 ? void 0 : _option$modelId2.text));
176
+ label: optionText
177
+ }, optionText);
155
178
  })));
156
179
  }
157
180
  if (col.type === "date") {
@@ -173,6 +196,10 @@ var Filter = function Filter(_ref) {
173
196
  className: gridSpanClass
174
197
  }, /*#__PURE__*/React.createElement(TreeSelect, {
175
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
+ },
176
203
  popupMatchSelectWidth: false,
177
204
  allowClear: true,
178
205
  treeDefaultExpandAll: true,
@@ -191,11 +218,7 @@ var Filter = function Filter(_ref) {
191
218
  className: style.buttons
192
219
  }, /*#__PURE__*/React.createElement(Button, {
193
220
  onClick: function onClick() {
194
- filterForm.resetFields();
195
- columns.forEach(function (col) {
196
- var _col$onFilterChange2;
197
- return (_col$onFilterChange2 = col.onFilterChange) === null || _col$onFilterChange2 === void 0 ? void 0 : _col$onFilterChange2.call(col, undefined);
198
- });
221
+ return filterForm.resetFields();
199
222
  },
200
223
  color: "white"
201
224
  }, c === null || c === void 0 ? void 0 : c.clear), /*#__PURE__*/React.createElement(Button, {
@@ -34,7 +34,7 @@
34
34
 
35
35
  .doubleGrid {
36
36
  grid-column: span 2; // Double grid item takes two columns
37
- width: 334px; // Ensure double items are 334px wide
37
+ width: 354px; // Ensure double items are 334px wide
38
38
  }
39
39
 
40
40
  label {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@banch0u/core-project-test-repository",
3
- "version": "2.3.26",
3
+ "version": "2.3.27",
4
4
  "description": "Shared core features for all projects",
5
5
  "main": "dist/index.js",
6
6
  "files": [