@carbon/ibm-products 2.43.2-canary.145 → 2.43.2-canary.146
Sign up to get free protection for your applications and to get access to all the features.
@@ -7,9 +7,18 @@
|
|
7
7
|
|
8
8
|
import { defineProperty as _defineProperty, slicedToArray as _slicedToArray, typeof as _typeof, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
9
9
|
import { useMemo } from 'react';
|
10
|
-
import {
|
10
|
+
import { RADIO, DATE, NUMBER, CHECKBOX, MULTISELECT, BATCH } from './Datagrid/addons/Filtering/constants.js';
|
11
11
|
import FilterFlyout from './Datagrid/addons/Filtering/FilterFlyout.js';
|
12
12
|
|
13
|
+
// This function was taken from https://github.com/TanStack/table/blob/v7/src/filterTypes.js
|
14
|
+
var exactText = function exactText(rows, ids, filterValue) {
|
15
|
+
return rows.filter(function (row) {
|
16
|
+
return ids.some(function (id) {
|
17
|
+
var rowValue = row.values[id];
|
18
|
+
return rowValue !== undefined ? String(rowValue).toLowerCase() === String(filterValue).toLowerCase() : true;
|
19
|
+
});
|
20
|
+
});
|
21
|
+
};
|
13
22
|
var handleMultiFilter = function handleMultiFilter(rows, id, value) {
|
14
23
|
// gets all the items that are selected and returns their value
|
15
24
|
var selectedItems = value.filter(function (item) {
|
@@ -30,7 +39,7 @@ var handleMultiFilter = function handleMultiFilter(rows, id, value) {
|
|
30
39
|
var useFiltering = function useFiltering(hooks) {
|
31
40
|
/* istanbul ignore next */
|
32
41
|
var filterTypes = useMemo(function () {
|
33
|
-
return _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, DATE, function (rows, id, _ref) {
|
42
|
+
return _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, DATE, function (rows, id, _ref) {
|
34
43
|
var _ref2 = _slicedToArray(_ref, 2),
|
35
44
|
startDate = _ref2[0],
|
36
45
|
endDate = _ref2[1];
|
@@ -60,6 +69,8 @@ var useFiltering = function useFiltering(hooks) {
|
|
60
69
|
return handleMultiFilter(rows, id, value);
|
61
70
|
}), MULTISELECT, function (rows, id, value) {
|
62
71
|
return handleMultiFilter(rows, id, value);
|
72
|
+
}), RADIO, function (rows, id, value) {
|
73
|
+
return exactText(rows, id, value);
|
63
74
|
});
|
64
75
|
}, []);
|
65
76
|
hooks.useInstance.push(function (instance) {
|
@@ -94,4 +105,4 @@ var useFiltering = function useFiltering(hooks) {
|
|
94
105
|
};
|
95
106
|
var useFiltering$1 = useFiltering;
|
96
107
|
|
97
|
-
export { useFiltering$1 as default };
|
108
|
+
export { useFiltering$1 as default, exactText };
|
@@ -14,6 +14,15 @@ var React = require('react');
|
|
14
14
|
var constants = require('./Datagrid/addons/Filtering/constants.js');
|
15
15
|
var FilterFlyout = require('./Datagrid/addons/Filtering/FilterFlyout.js');
|
16
16
|
|
17
|
+
// This function was taken from https://github.com/TanStack/table/blob/v7/src/filterTypes.js
|
18
|
+
var exactText = function exactText(rows, ids, filterValue) {
|
19
|
+
return rows.filter(function (row) {
|
20
|
+
return ids.some(function (id) {
|
21
|
+
var rowValue = row.values[id];
|
22
|
+
return rowValue !== undefined ? String(rowValue).toLowerCase() === String(filterValue).toLowerCase() : true;
|
23
|
+
});
|
24
|
+
});
|
25
|
+
};
|
17
26
|
var handleMultiFilter = function handleMultiFilter(rows, id, value) {
|
18
27
|
// gets all the items that are selected and returns their value
|
19
28
|
var selectedItems = value.filter(function (item) {
|
@@ -34,7 +43,7 @@ var handleMultiFilter = function handleMultiFilter(rows, id, value) {
|
|
34
43
|
var useFiltering = function useFiltering(hooks) {
|
35
44
|
/* istanbul ignore next */
|
36
45
|
var filterTypes = React.useMemo(function () {
|
37
|
-
return _rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty({}, constants.DATE, function (rows, id, _ref) {
|
46
|
+
return _rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty({}, constants.DATE, function (rows, id, _ref) {
|
38
47
|
var _ref2 = _rollupPluginBabelHelpers.slicedToArray(_ref, 2),
|
39
48
|
startDate = _ref2[0],
|
40
49
|
endDate = _ref2[1];
|
@@ -64,6 +73,8 @@ var useFiltering = function useFiltering(hooks) {
|
|
64
73
|
return handleMultiFilter(rows, id, value);
|
65
74
|
}), constants.MULTISELECT, function (rows, id, value) {
|
66
75
|
return handleMultiFilter(rows, id, value);
|
76
|
+
}), constants.RADIO, function (rows, id, value) {
|
77
|
+
return exactText(rows, id, value);
|
67
78
|
});
|
68
79
|
}, []);
|
69
80
|
hooks.useInstance.push(function (instance) {
|
@@ -99,3 +110,4 @@ var useFiltering = function useFiltering(hooks) {
|
|
99
110
|
var useFiltering$1 = useFiltering;
|
100
111
|
|
101
112
|
exports["default"] = useFiltering$1;
|
113
|
+
exports.exactText = exactText;
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@carbon/ibm-products",
|
3
3
|
"description": "Carbon for IBM Products",
|
4
|
-
"version": "2.43.2-canary.
|
4
|
+
"version": "2.43.2-canary.146+12667e838",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"main": "lib/index.js",
|
7
7
|
"module": "es/index.js",
|
@@ -120,5 +120,5 @@
|
|
120
120
|
"react": "^16.8.6 || ^17.0.1 || ^18.2.0",
|
121
121
|
"react-dom": "^16.8.6 || ^17.0.1 || ^18.2.0"
|
122
122
|
},
|
123
|
-
"gitHead": "
|
123
|
+
"gitHead": "12667e8387afc97c8a81a791c72f7ad323d7be6b"
|
124
124
|
}
|