@azrico/reactgrid 1.3.9 → 1.3.11
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/CHANGELOG.md +30 -0
- package/dist/src/views/DataGrid.js +8 -4
- package/package.json +1 -1
- package/src/views/DataGrid.tsx +18 -10
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,36 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [1.3.11](https://github.com/Azrideus/azrico-reactgrid/compare/v1.2.10...v1.3.11) (2023-08-19)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* DataGridSearchWrapper ([ebf3acf](https://github.com/Azrideus/azrico-reactgrid/commit/ebf3acff5f90c45090fad86be8e83e28744dd9dd))
|
|
11
|
+
* editable can be a function ([6ea857e](https://github.com/Azrideus/azrico-reactgrid/commit/6ea857e4f403d2a334dc5e74065f6b8033277ca4))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* DataGridDelayedSizeWrapper actual delayed ([2ddfd2f](https://github.com/Azrideus/azrico-reactgrid/commit/2ddfd2fb58c90bd906e1330f22f0ef7468d34afb))
|
|
17
|
+
* onCellSelectionChange ([95c8f54](https://github.com/Azrideus/azrico-reactgrid/commit/95c8f540e94dde0c7e245fb29fb6afc7172957ec))
|
|
18
|
+
* styling ([9018f75](https://github.com/Azrideus/azrico-reactgrid/commit/9018f7593e253720f751f52855a2d956dfc578ed))
|
|
19
|
+
|
|
20
|
+
### [1.3.10](https://github.com/Azrideus/azrico-reactgrid/compare/v1.2.10...v1.3.10) (2023-08-19)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Features
|
|
24
|
+
|
|
25
|
+
* DataGridSearchWrapper ([ebf3acf](https://github.com/Azrideus/azrico-reactgrid/commit/ebf3acff5f90c45090fad86be8e83e28744dd9dd))
|
|
26
|
+
* editable can be a function ([6ea857e](https://github.com/Azrideus/azrico-reactgrid/commit/6ea857e4f403d2a334dc5e74065f6b8033277ca4))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Bug Fixes
|
|
30
|
+
|
|
31
|
+
* DataGridDelayedSizeWrapper actual delayed ([2ddfd2f](https://github.com/Azrideus/azrico-reactgrid/commit/2ddfd2fb58c90bd906e1330f22f0ef7468d34afb))
|
|
32
|
+
* onCellSelectionChange ([95c8f54](https://github.com/Azrideus/azrico-reactgrid/commit/95c8f540e94dde0c7e245fb29fb6afc7172957ec))
|
|
33
|
+
* styling ([9018f75](https://github.com/Azrideus/azrico-reactgrid/commit/9018f7593e253720f751f52855a2d956dfc578ed))
|
|
34
|
+
|
|
5
35
|
### [1.3.9](https://github.com/Azrideus/azrico-reactgrid/compare/v1.2.10...v1.3.9) (2023-08-19)
|
|
6
36
|
|
|
7
37
|
|
|
@@ -279,30 +279,34 @@ function DataGridDelayedSizeWrapper(props) {
|
|
|
279
279
|
}
|
|
280
280
|
function DataGridSearchWrapper(props) {
|
|
281
281
|
const [search, set_search] = _react.default.useState('');
|
|
282
|
-
const [filteredData, set_filteredData] = _react.default.useState([]);
|
|
283
282
|
const [evaluatedDataSource, set_evaluatedDataSource] = _react.default.useState([]);
|
|
283
|
+
const [filteredData, set_filteredData] = _react.default.useState([]);
|
|
284
284
|
const try_search = _react.default.useCallback((0, _lodash.default)((ds, v) => {
|
|
285
285
|
if (!Array.isArray(ds)) return;
|
|
286
286
|
const visibleColumns = props.gridRef.current.visibleColumns;
|
|
287
287
|
const columns_to_search = (0, _object.array_intersection)(props.advancedFilterFields || [], visibleColumns.map(r => r.id));
|
|
288
288
|
const lowerSearchText = v && v.toLowerCase();
|
|
289
|
-
|
|
289
|
+
let newData = [];
|
|
290
|
+
if (!lowerSearchText) newData = ds;else newData = ds.filter(p => {
|
|
290
291
|
for (let index = 0; index < columns_to_search.length; index++) {
|
|
291
292
|
const col = columns_to_search[index];
|
|
292
293
|
const v = (p[col] + '').toLowerCase(); // get string value
|
|
293
|
-
if (v.indexOf(lowerSearchText) == -1) return false;
|
|
294
|
+
if (v && v.indexOf(lowerSearchText) == -1) return false;
|
|
294
295
|
}
|
|
295
296
|
return true;
|
|
296
297
|
});
|
|
297
298
|
set_filteredData(newData);
|
|
298
299
|
}, 1000), []);
|
|
299
300
|
_react.default.useEffect(() => {
|
|
301
|
+
set_search('');
|
|
300
302
|
(0, _object.fn_eval)(props.dataSource).then(({
|
|
301
303
|
data
|
|
302
304
|
}) => set_evaluatedDataSource(data));
|
|
303
305
|
}, [props.dataSource]);
|
|
304
306
|
_react.default.useEffect(() => {
|
|
305
|
-
|
|
307
|
+
if (!search) {
|
|
308
|
+
set_filteredData(evaluatedDataSource);
|
|
309
|
+
} else try_search(evaluatedDataSource, search);
|
|
306
310
|
}, [search, evaluatedDataSource]);
|
|
307
311
|
return _react.default.createElement("div", {
|
|
308
312
|
className: 'azgrid-flexed azgrid-flexlayout azgrid-nooverflow'
|
package/package.json
CHANGED
package/src/views/DataGrid.tsx
CHANGED
|
@@ -438,8 +438,8 @@ function DataGridDelayedSizeWrapper(props: DataGridWrapperProps) {
|
|
|
438
438
|
}
|
|
439
439
|
function DataGridSearchWrapper(props: DataGridWrapperProps) {
|
|
440
440
|
const [search, set_search] = React.useState('');
|
|
441
|
-
const [filteredData, set_filteredData] = React.useState<any[]>([]);
|
|
442
441
|
const [evaluatedDataSource, set_evaluatedDataSource] = React.useState<any[]>([]);
|
|
442
|
+
const [filteredData, set_filteredData] = React.useState<any[]>([]);
|
|
443
443
|
|
|
444
444
|
const try_search = React.useCallback(
|
|
445
445
|
debounce((ds, v) => {
|
|
@@ -450,23 +450,31 @@ function DataGridSearchWrapper(props: DataGridWrapperProps) {
|
|
|
450
450
|
visibleColumns.map((r) => r.id)
|
|
451
451
|
);
|
|
452
452
|
const lowerSearchText = v && v.toLowerCase();
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
453
|
+
let newData: any[] = [];
|
|
454
|
+
|
|
455
|
+
if (!lowerSearchText) newData = ds;
|
|
456
|
+
else
|
|
457
|
+
newData = ds.filter((p) => {
|
|
458
|
+
for (let index = 0; index < columns_to_search.length; index++) {
|
|
459
|
+
const col = columns_to_search[index];
|
|
460
|
+
const v = (p[col] + '').toLowerCase(); // get string value
|
|
461
|
+
|
|
462
|
+
if (v && v.indexOf(lowerSearchText) == -1) return false;
|
|
463
|
+
}
|
|
464
|
+
return true;
|
|
465
|
+
});
|
|
461
466
|
set_filteredData(newData);
|
|
462
467
|
}, 1000),
|
|
463
468
|
[]
|
|
464
469
|
);
|
|
465
470
|
React.useEffect(() => {
|
|
471
|
+
set_search('');
|
|
466
472
|
fn_eval(props.dataSource).then(({ data }) => set_evaluatedDataSource(data));
|
|
467
473
|
}, [props.dataSource]);
|
|
468
474
|
React.useEffect(() => {
|
|
469
|
-
|
|
475
|
+
if (!search) {
|
|
476
|
+
set_filteredData(evaluatedDataSource);
|
|
477
|
+
} else try_search(evaluatedDataSource, search);
|
|
470
478
|
}, [search, evaluatedDataSource]);
|
|
471
479
|
|
|
472
480
|
return (
|