@bento-core/table 1.0.1-ccdihub.117 → 1.0.1-ccdihub.119
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/ExtendedView.js +130 -4
- package/dist/TableView.js +7 -3
- package/dist/toolbar/DownloadButtonView.js +30 -4
- package/dist/toolbar/SearchBar.js +92 -0
- package/dist/toolbar/assets/Search_Icon.svg +3 -0
- package/package.json +1 -1
- package/src/ExtendedView.js +137 -1
- package/src/TableView.js +5 -1
- package/src/toolbar/DownloadButtonView.js +20 -4
- package/src/toolbar/SearchBar.js +90 -0
- package/src/toolbar/assets/Search_Icon.svg +3 -0
package/dist/ExtendedView.js
CHANGED
|
@@ -4,13 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _react =
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _core = require("@material-ui/core");
|
|
9
|
+
var _Close = _interopRequireDefault(require("@material-ui/icons/Close"));
|
|
9
10
|
var _CustomPagination = _interopRequireDefault(require("./pagination/CustomPagination"));
|
|
10
11
|
var _ManageColumnView = _interopRequireDefault(require("./toolbar/ManageColumnView"));
|
|
11
12
|
var _DefaultThemConfig = _interopRequireDefault(require("./DefaultThemConfig"));
|
|
12
13
|
var _DownloadButtonView = _interopRequireDefault(require("./toolbar/DownloadButtonView"));
|
|
13
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
16
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
14
17
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
18
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
16
19
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -18,8 +21,49 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typ
|
|
|
18
21
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
19
22
|
const downloadAreaStyle = {
|
|
20
23
|
display: 'flex',
|
|
24
|
+
justifyContent: 'space-between',
|
|
25
|
+
alignItems: 'center',
|
|
21
26
|
borderTop: '1px solid #8A7F7C',
|
|
22
|
-
paddingRight: '48px'
|
|
27
|
+
paddingRight: '48px',
|
|
28
|
+
paddingTop: '5px',
|
|
29
|
+
paddingBottom: '5px'
|
|
30
|
+
};
|
|
31
|
+
const searchBarContainerStyle = {
|
|
32
|
+
display: 'flex',
|
|
33
|
+
alignItems: 'center',
|
|
34
|
+
marginRight: 'auto',
|
|
35
|
+
paddingLeft: '18px'
|
|
36
|
+
};
|
|
37
|
+
const getSearchBarWrapperStyle = isFocused => ({
|
|
38
|
+
display: 'flex',
|
|
39
|
+
alignItems: 'center',
|
|
40
|
+
width: '337px',
|
|
41
|
+
height: '30px',
|
|
42
|
+
backgroundColor: '#EAF5F5',
|
|
43
|
+
borderRadius: '8px',
|
|
44
|
+
border: isFocused ? '2px solid #15968E' : '1px solid #CCCCCC',
|
|
45
|
+
paddingLeft: '12px',
|
|
46
|
+
paddingRight: '4px',
|
|
47
|
+
opacity: 1
|
|
48
|
+
});
|
|
49
|
+
const searchInputStyle = {
|
|
50
|
+
flex: 1,
|
|
51
|
+
fontSize: '14px',
|
|
52
|
+
'&::placeholder': {
|
|
53
|
+
color: '#757575',
|
|
54
|
+
opacity: 1
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const clearIconButtonStyle = {
|
|
58
|
+
padding: '4px',
|
|
59
|
+
cursor: 'pointer',
|
|
60
|
+
color: '#15968E'
|
|
61
|
+
};
|
|
62
|
+
const noMatchTextStyle = {
|
|
63
|
+
marginLeft: '16px',
|
|
64
|
+
fontSize: '14px',
|
|
65
|
+
color: '#000000',
|
|
66
|
+
fontWeight: 400
|
|
23
67
|
};
|
|
24
68
|
const ExtendedView = _ref => {
|
|
25
69
|
let {
|
|
@@ -29,8 +73,20 @@ const ExtendedView = _ref => {
|
|
|
29
73
|
onRowsPerPageChange,
|
|
30
74
|
onPageChange,
|
|
31
75
|
customTheme,
|
|
32
|
-
queryVariables
|
|
76
|
+
queryVariables,
|
|
77
|
+
onSearch,
|
|
78
|
+
initialSearchValue = ''
|
|
33
79
|
} = _ref;
|
|
80
|
+
const [searchValue, setSearchValue] = (0, _react.useState)(initialSearchValue);
|
|
81
|
+
const [isSearching, setIsSearching] = (0, _react.useState)(!!initialSearchValue);
|
|
82
|
+
const [hasResults, setHasResults] = (0, _react.useState)(true);
|
|
83
|
+
const [isFocused, setIsFocused] = (0, _react.useState)(false);
|
|
84
|
+
|
|
85
|
+
// Update searchValue when initialSearchValue changes
|
|
86
|
+
_react.default.useEffect(() => {
|
|
87
|
+
setSearchValue(initialSearchValue);
|
|
88
|
+
setIsSearching(!!initialSearchValue);
|
|
89
|
+
}, [initialSearchValue]);
|
|
34
90
|
const {
|
|
35
91
|
extendedViewConfig
|
|
36
92
|
} = table;
|
|
@@ -42,6 +98,50 @@ const ExtendedView = _ref => {
|
|
|
42
98
|
pagination = false,
|
|
43
99
|
hasExport = true
|
|
44
100
|
} = extendedViewConfig;
|
|
101
|
+
|
|
102
|
+
// Check if this is the Files tab
|
|
103
|
+
const isFilesTab = table.paginationAPIField === 'fileOverview' || table.paginationAPIField === 'getFilenames';
|
|
104
|
+
|
|
105
|
+
// Handler for search functionality
|
|
106
|
+
const handleSearch = () => {
|
|
107
|
+
if (searchValue.trim()) {
|
|
108
|
+
setIsSearching(true);
|
|
109
|
+
if (onSearch) {
|
|
110
|
+
onSearch(searchValue.trim());
|
|
111
|
+
}
|
|
112
|
+
} else {
|
|
113
|
+
// Clear search
|
|
114
|
+
setIsSearching(false);
|
|
115
|
+
setHasResults(true);
|
|
116
|
+
if (onSearch) {
|
|
117
|
+
onSearch('');
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
// Handler for Enter key press
|
|
123
|
+
const handleKeyPress = event => {
|
|
124
|
+
if (event.key === 'Enter') {
|
|
125
|
+
handleSearch();
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// Handler for clearing search
|
|
130
|
+
const handleClear = () => {
|
|
131
|
+
setSearchValue('');
|
|
132
|
+
setIsSearching(false);
|
|
133
|
+
setHasResults(true);
|
|
134
|
+
if (onSearch) {
|
|
135
|
+
onSearch('');
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
// Update hasResults based on table totalRowCount
|
|
140
|
+
_react.default.useEffect(() => {
|
|
141
|
+
if (isSearching && table.totalRowCount !== undefined) {
|
|
142
|
+
setHasResults(table.totalRowCount > 0);
|
|
143
|
+
}
|
|
144
|
+
}, [table.totalRowCount, isSearching]);
|
|
45
145
|
const themeConfig = (0, _core.createTheme)({
|
|
46
146
|
overrides: _objectSpread(_objectSpread({}, (0, _DefaultThemConfig.default)()), customTheme)
|
|
47
147
|
});
|
|
@@ -50,7 +150,33 @@ const ExtendedView = _ref => {
|
|
|
50
150
|
}, pagination && /*#__PURE__*/_react.default.createElement("div", {
|
|
51
151
|
className: "downloadArea",
|
|
52
152
|
style: downloadAreaStyle
|
|
53
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
153
|
+
}, isFilesTab && /*#__PURE__*/_react.default.createElement("div", {
|
|
154
|
+
style: searchBarContainerStyle
|
|
155
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
156
|
+
style: getSearchBarWrapperStyle(isFocused)
|
|
157
|
+
}, /*#__PURE__*/_react.default.createElement(_core.InputBase, {
|
|
158
|
+
placeholder: "Search Files",
|
|
159
|
+
value: searchValue,
|
|
160
|
+
onChange: e => setSearchValue(e.target.value),
|
|
161
|
+
onKeyPress: handleKeyPress,
|
|
162
|
+
onFocus: () => setIsFocused(true),
|
|
163
|
+
onBlur: () => setIsFocused(false),
|
|
164
|
+
style: searchInputStyle,
|
|
165
|
+
inputProps: {
|
|
166
|
+
'aria-label': 'search files'
|
|
167
|
+
}
|
|
168
|
+
}), searchValue && /*#__PURE__*/_react.default.createElement(_core.IconButton, {
|
|
169
|
+
onClick: handleClear,
|
|
170
|
+
style: clearIconButtonStyle,
|
|
171
|
+
size: "small",
|
|
172
|
+
"aria-label": "clear search"
|
|
173
|
+
}, /*#__PURE__*/_react.default.createElement(_Close.default, {
|
|
174
|
+
style: {
|
|
175
|
+
fontSize: '18px'
|
|
176
|
+
}
|
|
177
|
+
}))), isSearching && !hasResults && /*#__PURE__*/_react.default.createElement("span", {
|
|
178
|
+
style: noMatchTextStyle
|
|
179
|
+
}, "No Matching Records Found")), /*#__PURE__*/_react.default.createElement(_CustomPagination.default, {
|
|
54
180
|
customTheme: customTheme.tblTopPgn,
|
|
55
181
|
rowsPerPageOptions: table.rowsPerPageOptions || [10, 25, 50, 100],
|
|
56
182
|
component: "div",
|
package/dist/TableView.js
CHANGED
|
@@ -41,7 +41,7 @@ const downloadAreaStyle = {
|
|
|
41
41
|
display: 'flex',
|
|
42
42
|
borderTop: '1px solid #8A7F7C',
|
|
43
43
|
borderBottom: '1px solid #8A7F7C',
|
|
44
|
-
paddingRight: '
|
|
44
|
+
paddingRight: '48px'
|
|
45
45
|
};
|
|
46
46
|
const cartDownloadAreaStyle = {
|
|
47
47
|
display: 'flex',
|
|
@@ -84,7 +84,9 @@ const TableView = _ref => {
|
|
|
84
84
|
onAllColumnViewChange,
|
|
85
85
|
themeConfig = {},
|
|
86
86
|
queryVariables,
|
|
87
|
-
navigation
|
|
87
|
+
navigation,
|
|
88
|
+
onSearch,
|
|
89
|
+
searchValue
|
|
88
90
|
} = _ref;
|
|
89
91
|
(0, _react.useEffect)(() => {
|
|
90
92
|
const tableContainer = document.getElementById('tableContainer');
|
|
@@ -118,7 +120,9 @@ const TableView = _ref => {
|
|
|
118
120
|
onPageChange: onPageChange,
|
|
119
121
|
numSelected: (table === null || table === void 0 ? void 0 : (_table$selectedRows = table.selectedRows) === null || _table$selectedRows === void 0 ? void 0 : _table$selectedRows.length) || 0,
|
|
120
122
|
customTheme: themeConfig.extendedView,
|
|
121
|
-
queryVariables: queryVariables
|
|
123
|
+
queryVariables: queryVariables,
|
|
124
|
+
onSearch: onSearch,
|
|
125
|
+
initialSearchValue: searchValue
|
|
122
126
|
}), /*#__PURE__*/_react.default.createElement(_CustomToolbar.default, {
|
|
123
127
|
numSelected: (table === null || table === void 0 ? void 0 : (_table$selectedRows2 = table.selectedRows) === null || _table$selectedRows2 === void 0 ? void 0 : _table$selectedRows2.length) || 0,
|
|
124
128
|
table: table,
|
|
@@ -10,6 +10,8 @@ var _core = require("@material-ui/core");
|
|
|
10
10
|
var _KeyboardArrowDownOutlined = _interopRequireDefault(require("@material-ui/icons/KeyboardArrowDownOutlined"));
|
|
11
11
|
var _icons = require("@material-ui/icons");
|
|
12
12
|
var _downloadTable = require("../util/downloadTable");
|
|
13
|
+
const _excluded = ["filename"],
|
|
14
|
+
_excluded2 = ["filename"];
|
|
13
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
16
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
17
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -18,6 +20,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
18
20
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
19
21
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
20
22
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
23
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
24
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
21
25
|
// const downloadButtonStyle = {
|
|
22
26
|
// color: '#d1d2d3',
|
|
23
27
|
// marginTop: '7px',
|
|
@@ -58,9 +62,15 @@ const DownloadButton = _ref => {
|
|
|
58
62
|
query,
|
|
59
63
|
paginationAPIField
|
|
60
64
|
} = table;
|
|
65
|
+
|
|
66
|
+
// Remove filename parameter for download to only use facet filters
|
|
67
|
+
const {
|
|
68
|
+
filename
|
|
69
|
+
} = queryVariables,
|
|
70
|
+
filteredVariables = _objectWithoutProperties(queryVariables, _excluded);
|
|
61
71
|
const result = await client.query({
|
|
62
72
|
query,
|
|
63
|
-
variables: _objectSpread(_objectSpread({},
|
|
73
|
+
variables: _objectSpread(_objectSpread({}, filteredVariables), {}, {
|
|
64
74
|
page: 0,
|
|
65
75
|
first: 200000,
|
|
66
76
|
order_by: table.sortBy,
|
|
@@ -68,7 +78,12 @@ const DownloadButton = _ref => {
|
|
|
68
78
|
})
|
|
69
79
|
}).then(response => {
|
|
70
80
|
if (paginationAPIField && response && response.data) {
|
|
71
|
-
|
|
81
|
+
const apiResult = response.data[paginationAPIField];
|
|
82
|
+
// Handle getFilenames response structure which has files array nested
|
|
83
|
+
if (paginationAPIField === 'getFilenames' && apiResult && apiResult.files) {
|
|
84
|
+
return apiResult.files;
|
|
85
|
+
}
|
|
86
|
+
return apiResult;
|
|
72
87
|
}
|
|
73
88
|
return response.data;
|
|
74
89
|
});
|
|
@@ -79,9 +94,15 @@ const DownloadButton = _ref => {
|
|
|
79
94
|
query,
|
|
80
95
|
paginationAPIField
|
|
81
96
|
} = table;
|
|
97
|
+
|
|
98
|
+
// Remove filename parameter for download to only use facet filters
|
|
99
|
+
const {
|
|
100
|
+
filename
|
|
101
|
+
} = queryVariables,
|
|
102
|
+
filteredVariables = _objectWithoutProperties(queryVariables, _excluded2);
|
|
82
103
|
const result = await client.query({
|
|
83
104
|
query,
|
|
84
|
-
variables: _objectSpread(_objectSpread({},
|
|
105
|
+
variables: _objectSpread(_objectSpread({}, filteredVariables), {}, {
|
|
85
106
|
page: 0,
|
|
86
107
|
first: 200000,
|
|
87
108
|
order_by: table.sortBy,
|
|
@@ -89,7 +110,12 @@ const DownloadButton = _ref => {
|
|
|
89
110
|
})
|
|
90
111
|
}).then(response => {
|
|
91
112
|
if (paginationAPIField && response && response.data) {
|
|
92
|
-
|
|
113
|
+
const apiResult = response.data[paginationAPIField];
|
|
114
|
+
// Handle getFilenames response structure which has files array nested
|
|
115
|
+
if (paginationAPIField === 'getFilenames' && apiResult && apiResult.files) {
|
|
116
|
+
return apiResult.files;
|
|
117
|
+
}
|
|
118
|
+
return apiResult;
|
|
93
119
|
}
|
|
94
120
|
return response.data;
|
|
95
121
|
});
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _core = require("@material-ui/core");
|
|
9
|
+
var _Search_Icon = _interopRequireDefault(require("./assets/Search_Icon.svg"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
13
|
+
const SearchBar = _ref => {
|
|
14
|
+
let {
|
|
15
|
+
onSearch
|
|
16
|
+
} = _ref;
|
|
17
|
+
const [searchValue, setSearchValue] = (0, _react.useState)('');
|
|
18
|
+
const handleSearchClick = () => {
|
|
19
|
+
if (onSearch) {
|
|
20
|
+
onSearch(searchValue);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const handleKeyPress = event => {
|
|
24
|
+
if (event.key === 'Enter') {
|
|
25
|
+
handleSearchClick();
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const handleChange = event => {
|
|
29
|
+
setSearchValue(event.target.value);
|
|
30
|
+
};
|
|
31
|
+
const useStyles = (0, _core.makeStyles)({
|
|
32
|
+
searchContainer: {
|
|
33
|
+
display: 'flex',
|
|
34
|
+
alignItems: 'center',
|
|
35
|
+
border: '0.75px solid #606060',
|
|
36
|
+
borderRadius: '5px',
|
|
37
|
+
backgroundColor: '#ffffff',
|
|
38
|
+
height: '36px',
|
|
39
|
+
width: '300px',
|
|
40
|
+
paddingLeft: '12px',
|
|
41
|
+
paddingRight: '4px',
|
|
42
|
+
marginTop: '8px',
|
|
43
|
+
marginBottom: '8px',
|
|
44
|
+
marginLeft: '-28px',
|
|
45
|
+
float: 'left'
|
|
46
|
+
},
|
|
47
|
+
inputBase: {
|
|
48
|
+
flex: 1,
|
|
49
|
+
fontFamily: 'Poppins',
|
|
50
|
+
fontSize: '14px',
|
|
51
|
+
color: '#000000',
|
|
52
|
+
'& input::placeholder': {
|
|
53
|
+
color: '#9B9B9B',
|
|
54
|
+
opacity: 1
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
searchButton: {
|
|
58
|
+
padding: '6px',
|
|
59
|
+
backgroundColor: 'transparent',
|
|
60
|
+
'&:hover': {
|
|
61
|
+
backgroundColor: 'rgba(0, 0, 0, 0.04)'
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
searchIcon: {
|
|
65
|
+
width: '15px',
|
|
66
|
+
height: '15px'
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
const classes = useStyles();
|
|
70
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
71
|
+
className: classes.searchContainer
|
|
72
|
+
}, /*#__PURE__*/_react.default.createElement(_core.InputBase, {
|
|
73
|
+
className: classes.inputBase,
|
|
74
|
+
placeholder: "Search...",
|
|
75
|
+
value: searchValue,
|
|
76
|
+
onChange: handleChange,
|
|
77
|
+
onKeyPress: handleKeyPress,
|
|
78
|
+
inputProps: {
|
|
79
|
+
'aria-label': 'search'
|
|
80
|
+
}
|
|
81
|
+
}), /*#__PURE__*/_react.default.createElement(_core.IconButton, {
|
|
82
|
+
className: classes.searchButton,
|
|
83
|
+
onClick: handleSearchClick,
|
|
84
|
+
"aria-label": "search"
|
|
85
|
+
}, /*#__PURE__*/_react.default.createElement("img", {
|
|
86
|
+
src: _Search_Icon.default,
|
|
87
|
+
alt: "search",
|
|
88
|
+
className: classes.searchIcon
|
|
89
|
+
})));
|
|
90
|
+
};
|
|
91
|
+
var _default = SearchBar;
|
|
92
|
+
exports.default = _default;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M6.4134 1C3.43007 1 1 3.43007 1 6.4134C1 9.39672 3.43007 11.8268 6.4134 11.8268C7.71072 11.8268 8.90214 11.3661 9.83589 10.6014L13.0681 13.8336C13.118 13.8855 13.1777 13.927 13.2438 13.9556C13.3099 13.9841 13.3811 13.9992 13.4531 14C13.5251 14.0007 13.5966 13.9871 13.6632 13.9598C13.7299 13.9326 13.7905 13.8924 13.8414 13.8414C13.8924 13.7905 13.9326 13.7299 13.9598 13.6632C13.9871 13.5966 14.0007 13.5251 14 13.4531C13.9992 13.3811 13.9841 13.3099 13.9556 13.2438C13.927 13.1777 13.8855 13.118 13.8336 13.0681L10.6014 9.83589C11.3661 8.90214 11.8268 7.71072 11.8268 6.4134C11.8268 3.43007 9.39672 1 6.4134 1ZM6.4134 2.08268C8.8116 2.08268 10.7441 4.0152 10.7441 6.4134C10.7441 8.8116 8.8116 10.7441 6.4134 10.7441C4.0152 10.7441 2.08268 8.8116 2.08268 6.4134C2.08268 4.0152 4.0152 2.08268 6.4134 2.08268Z" fill="#4D889E" stroke="#4D889E"/>
|
|
3
|
+
</svg>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bento-core/table",
|
|
3
|
-
"version": "1.0.1-ccdihub.
|
|
3
|
+
"version": "1.0.1-ccdihub.119",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "npm run lint && cross-env-shell rm -rf dist && NODE_ENV=production BABEL_ENV=es babel src --out-dir dist --copy-files",
|
package/src/ExtendedView.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
ThemeProvider,
|
|
4
4
|
createTheme,
|
|
5
|
+
InputBase,
|
|
6
|
+
IconButton,
|
|
5
7
|
} from '@material-ui/core';
|
|
8
|
+
import CloseIcon from '@material-ui/icons/Close';
|
|
6
9
|
import CustomPagination from './pagination/CustomPagination';
|
|
7
10
|
import ManageColumnView from './toolbar/ManageColumnView';
|
|
8
11
|
import defaultTheme from './DefaultThemConfig';
|
|
@@ -10,8 +13,54 @@ import DownloadButton from './toolbar/DownloadButtonView';
|
|
|
10
13
|
|
|
11
14
|
const downloadAreaStyle = {
|
|
12
15
|
display: 'flex',
|
|
16
|
+
justifyContent: 'space-between',
|
|
17
|
+
alignItems: 'center',
|
|
13
18
|
borderTop: '1px solid #8A7F7C',
|
|
14
19
|
paddingRight: '48px',
|
|
20
|
+
paddingTop: '5px',
|
|
21
|
+
paddingBottom: '5px',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const searchBarContainerStyle = {
|
|
25
|
+
display: 'flex',
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
marginRight: 'auto',
|
|
28
|
+
paddingLeft: '18px',
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const getSearchBarWrapperStyle = (isFocused) => ({
|
|
32
|
+
display: 'flex',
|
|
33
|
+
alignItems: 'center',
|
|
34
|
+
width: '337px',
|
|
35
|
+
height: '30px',
|
|
36
|
+
backgroundColor: '#EAF5F5',
|
|
37
|
+
borderRadius: '8px',
|
|
38
|
+
border: isFocused ? '2px solid #15968E' : '1px solid #CCCCCC',
|
|
39
|
+
paddingLeft: '12px',
|
|
40
|
+
paddingRight: '4px',
|
|
41
|
+
opacity: 1,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const searchInputStyle = {
|
|
45
|
+
flex: 1,
|
|
46
|
+
fontSize: '14px',
|
|
47
|
+
'&::placeholder': {
|
|
48
|
+
color: '#757575',
|
|
49
|
+
opacity: 1,
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const clearIconButtonStyle = {
|
|
54
|
+
padding: '4px',
|
|
55
|
+
cursor: 'pointer',
|
|
56
|
+
color: '#15968E',
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const noMatchTextStyle = {
|
|
60
|
+
marginLeft: '16px',
|
|
61
|
+
fontSize: '14px',
|
|
62
|
+
color: '#000000',
|
|
63
|
+
fontWeight: 400,
|
|
15
64
|
};
|
|
16
65
|
|
|
17
66
|
const ExtendedView = ({
|
|
@@ -22,7 +71,20 @@ const ExtendedView = ({
|
|
|
22
71
|
onPageChange,
|
|
23
72
|
customTheme,
|
|
24
73
|
queryVariables,
|
|
74
|
+
onSearch,
|
|
75
|
+
initialSearchValue = '',
|
|
25
76
|
}) => {
|
|
77
|
+
const [searchValue, setSearchValue] = useState(initialSearchValue);
|
|
78
|
+
const [isSearching, setIsSearching] = useState(!!initialSearchValue);
|
|
79
|
+
const [hasResults, setHasResults] = useState(true);
|
|
80
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
81
|
+
|
|
82
|
+
// Update searchValue when initialSearchValue changes
|
|
83
|
+
React.useEffect(() => {
|
|
84
|
+
setSearchValue(initialSearchValue);
|
|
85
|
+
setIsSearching(!!initialSearchValue);
|
|
86
|
+
}, [initialSearchValue]);
|
|
87
|
+
|
|
26
88
|
const { extendedViewConfig } = table;
|
|
27
89
|
if (!extendedViewConfig) {
|
|
28
90
|
return null;
|
|
@@ -33,6 +95,50 @@ const ExtendedView = ({
|
|
|
33
95
|
hasExport = true,
|
|
34
96
|
} = extendedViewConfig;
|
|
35
97
|
|
|
98
|
+
// Check if this is the Files tab
|
|
99
|
+
const isFilesTab = table.paginationAPIField === 'fileOverview' || table.paginationAPIField === 'getFilenames';
|
|
100
|
+
|
|
101
|
+
// Handler for search functionality
|
|
102
|
+
const handleSearch = () => {
|
|
103
|
+
if (searchValue.trim()) {
|
|
104
|
+
setIsSearching(true);
|
|
105
|
+
if (onSearch) {
|
|
106
|
+
onSearch(searchValue.trim());
|
|
107
|
+
}
|
|
108
|
+
} else {
|
|
109
|
+
// Clear search
|
|
110
|
+
setIsSearching(false);
|
|
111
|
+
setHasResults(true);
|
|
112
|
+
if (onSearch) {
|
|
113
|
+
onSearch('');
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// Handler for Enter key press
|
|
119
|
+
const handleKeyPress = (event) => {
|
|
120
|
+
if (event.key === 'Enter') {
|
|
121
|
+
handleSearch();
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
// Handler for clearing search
|
|
126
|
+
const handleClear = () => {
|
|
127
|
+
setSearchValue('');
|
|
128
|
+
setIsSearching(false);
|
|
129
|
+
setHasResults(true);
|
|
130
|
+
if (onSearch) {
|
|
131
|
+
onSearch('');
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
// Update hasResults based on table totalRowCount
|
|
136
|
+
React.useEffect(() => {
|
|
137
|
+
if (isSearching && table.totalRowCount !== undefined) {
|
|
138
|
+
setHasResults(table.totalRowCount > 0);
|
|
139
|
+
}
|
|
140
|
+
}, [table.totalRowCount, isSearching]);
|
|
141
|
+
|
|
36
142
|
const themeConfig = createTheme({ overrides: { ...defaultTheme(), ...customTheme } });
|
|
37
143
|
return (
|
|
38
144
|
<ThemeProvider theme={themeConfig}>
|
|
@@ -46,6 +152,36 @@ const ExtendedView = ({
|
|
|
46
152
|
{
|
|
47
153
|
(pagination) && (
|
|
48
154
|
<div className="downloadArea" style={downloadAreaStyle}>
|
|
155
|
+
{/* Search bar - only show for Files tab */}
|
|
156
|
+
{isFilesTab && (
|
|
157
|
+
<div style={searchBarContainerStyle}>
|
|
158
|
+
<div style={getSearchBarWrapperStyle(isFocused)}>
|
|
159
|
+
<InputBase
|
|
160
|
+
placeholder="Search Files"
|
|
161
|
+
value={searchValue}
|
|
162
|
+
onChange={(e) => setSearchValue(e.target.value)}
|
|
163
|
+
onKeyPress={handleKeyPress}
|
|
164
|
+
onFocus={() => setIsFocused(true)}
|
|
165
|
+
onBlur={() => setIsFocused(false)}
|
|
166
|
+
style={searchInputStyle}
|
|
167
|
+
inputProps={{ 'aria-label': 'search files' }}
|
|
168
|
+
/>
|
|
169
|
+
{searchValue && (
|
|
170
|
+
<IconButton
|
|
171
|
+
onClick={handleClear}
|
|
172
|
+
style={clearIconButtonStyle}
|
|
173
|
+
size="small"
|
|
174
|
+
aria-label="clear search"
|
|
175
|
+
>
|
|
176
|
+
<CloseIcon style={{ fontSize: '18px' }} />
|
|
177
|
+
</IconButton>
|
|
178
|
+
)}
|
|
179
|
+
</div>
|
|
180
|
+
{isSearching && !hasResults && (
|
|
181
|
+
<span style={noMatchTextStyle}>No Matching Records Found</span>
|
|
182
|
+
)}
|
|
183
|
+
</div>
|
|
184
|
+
)}
|
|
49
185
|
<CustomPagination
|
|
50
186
|
customTheme={customTheme.tblTopPgn}
|
|
51
187
|
rowsPerPageOptions={table.rowsPerPageOptions || [10, 25, 50, 100]}
|
package/src/TableView.js
CHANGED
|
@@ -31,7 +31,7 @@ const downloadAreaStyle = {
|
|
|
31
31
|
display: 'flex',
|
|
32
32
|
borderTop: '1px solid #8A7F7C',
|
|
33
33
|
borderBottom: '1px solid #8A7F7C',
|
|
34
|
-
paddingRight: '
|
|
34
|
+
paddingRight: '48px',
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
const cartDownloadAreaStyle = {
|
|
@@ -78,6 +78,8 @@ const TableView = ({
|
|
|
78
78
|
themeConfig = {},
|
|
79
79
|
queryVariables,
|
|
80
80
|
navigation,
|
|
81
|
+
onSearch,
|
|
82
|
+
searchValue,
|
|
81
83
|
}) => {
|
|
82
84
|
useEffect(() => {
|
|
83
85
|
const tableContainer = document.getElementById('tableContainer');
|
|
@@ -112,6 +114,8 @@ const TableView = ({
|
|
|
112
114
|
numSelected={table?.selectedRows?.length || 0}
|
|
113
115
|
customTheme={themeConfig.extendedView}
|
|
114
116
|
queryVariables={queryVariables}
|
|
117
|
+
onSearch={onSearch}
|
|
118
|
+
initialSearchValue={searchValue}
|
|
115
119
|
/>
|
|
116
120
|
<CustomToolbar
|
|
117
121
|
numSelected={table?.selectedRows?.length || 0}
|
|
@@ -56,10 +56,13 @@ const DownloadButton = ({
|
|
|
56
56
|
paginationAPIField,
|
|
57
57
|
} = table;
|
|
58
58
|
|
|
59
|
+
// Remove filename parameter for download to only use facet filters
|
|
60
|
+
const { filename, ...filteredVariables } = queryVariables;
|
|
61
|
+
|
|
59
62
|
const result = await client.query({
|
|
60
63
|
query,
|
|
61
64
|
variables: {
|
|
62
|
-
...
|
|
65
|
+
...filteredVariables,
|
|
63
66
|
page: 0,
|
|
64
67
|
first: 200000,
|
|
65
68
|
order_by: table.sortBy,
|
|
@@ -68,7 +71,12 @@ const DownloadButton = ({
|
|
|
68
71
|
})
|
|
69
72
|
.then((response) => {
|
|
70
73
|
if (paginationAPIField && response && response.data) {
|
|
71
|
-
|
|
74
|
+
const apiResult = response.data[paginationAPIField];
|
|
75
|
+
// Handle getFilenames response structure which has files array nested
|
|
76
|
+
if (paginationAPIField === 'getFilenames' && apiResult && apiResult.files) {
|
|
77
|
+
return apiResult.files;
|
|
78
|
+
}
|
|
79
|
+
return apiResult;
|
|
72
80
|
}
|
|
73
81
|
return response.data;
|
|
74
82
|
});
|
|
@@ -81,10 +89,13 @@ const DownloadButton = ({
|
|
|
81
89
|
paginationAPIField,
|
|
82
90
|
} = table;
|
|
83
91
|
|
|
92
|
+
// Remove filename parameter for download to only use facet filters
|
|
93
|
+
const { filename, ...filteredVariables } = queryVariables;
|
|
94
|
+
|
|
84
95
|
const result = await client.query({
|
|
85
96
|
query,
|
|
86
97
|
variables: {
|
|
87
|
-
...
|
|
98
|
+
...filteredVariables,
|
|
88
99
|
page: 0,
|
|
89
100
|
first: 200000,
|
|
90
101
|
order_by: table.sortBy,
|
|
@@ -93,7 +104,12 @@ const DownloadButton = ({
|
|
|
93
104
|
})
|
|
94
105
|
.then((response) => {
|
|
95
106
|
if (paginationAPIField && response && response.data) {
|
|
96
|
-
|
|
107
|
+
const apiResult = response.data[paginationAPIField];
|
|
108
|
+
// Handle getFilenames response structure which has files array nested
|
|
109
|
+
if (paginationAPIField === 'getFilenames' && apiResult && apiResult.files) {
|
|
110
|
+
return apiResult.files;
|
|
111
|
+
}
|
|
112
|
+
return apiResult;
|
|
97
113
|
}
|
|
98
114
|
return response.data;
|
|
99
115
|
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
IconButton,
|
|
4
|
+
InputBase,
|
|
5
|
+
makeStyles,
|
|
6
|
+
} from '@material-ui/core';
|
|
7
|
+
import SearchIcon from './assets/Search_Icon.svg';
|
|
8
|
+
|
|
9
|
+
const SearchBar = ({ onSearch }) => {
|
|
10
|
+
const [searchValue, setSearchValue] = useState('');
|
|
11
|
+
|
|
12
|
+
const handleSearchClick = () => {
|
|
13
|
+
if (onSearch) {
|
|
14
|
+
onSearch(searchValue);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const handleKeyPress = (event) => {
|
|
19
|
+
if (event.key === 'Enter') {
|
|
20
|
+
handleSearchClick();
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const handleChange = (event) => {
|
|
25
|
+
setSearchValue(event.target.value);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const useStyles = makeStyles({
|
|
29
|
+
searchContainer: {
|
|
30
|
+
display: 'flex',
|
|
31
|
+
alignItems: 'center',
|
|
32
|
+
border: '0.75px solid #606060',
|
|
33
|
+
borderRadius: '5px',
|
|
34
|
+
backgroundColor: '#ffffff',
|
|
35
|
+
height: '36px',
|
|
36
|
+
width: '300px',
|
|
37
|
+
paddingLeft: '12px',
|
|
38
|
+
paddingRight: '4px',
|
|
39
|
+
marginTop: '8px',
|
|
40
|
+
marginBottom: '8px',
|
|
41
|
+
marginLeft: '-28px',
|
|
42
|
+
float: 'left',
|
|
43
|
+
},
|
|
44
|
+
inputBase: {
|
|
45
|
+
flex: 1,
|
|
46
|
+
fontFamily: 'Poppins',
|
|
47
|
+
fontSize: '14px',
|
|
48
|
+
color: '#000000',
|
|
49
|
+
'& input::placeholder': {
|
|
50
|
+
color: '#9B9B9B',
|
|
51
|
+
opacity: 1,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
searchButton: {
|
|
55
|
+
padding: '6px',
|
|
56
|
+
backgroundColor: 'transparent',
|
|
57
|
+
'&:hover': {
|
|
58
|
+
backgroundColor: 'rgba(0, 0, 0, 0.04)',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
searchIcon: {
|
|
62
|
+
width: '15px',
|
|
63
|
+
height: '15px',
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const classes = useStyles();
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<div className={classes.searchContainer}>
|
|
71
|
+
<InputBase
|
|
72
|
+
className={classes.inputBase}
|
|
73
|
+
placeholder="Search..."
|
|
74
|
+
value={searchValue}
|
|
75
|
+
onChange={handleChange}
|
|
76
|
+
onKeyPress={handleKeyPress}
|
|
77
|
+
inputProps={{ 'aria-label': 'search' }}
|
|
78
|
+
/>
|
|
79
|
+
<IconButton
|
|
80
|
+
className={classes.searchButton}
|
|
81
|
+
onClick={handleSearchClick}
|
|
82
|
+
aria-label="search"
|
|
83
|
+
>
|
|
84
|
+
<img src={SearchIcon} alt="search" className={classes.searchIcon} />
|
|
85
|
+
</IconButton>
|
|
86
|
+
</div>
|
|
87
|
+
);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export default SearchBar;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M6.4134 1C3.43007 1 1 3.43007 1 6.4134C1 9.39672 3.43007 11.8268 6.4134 11.8268C7.71072 11.8268 8.90214 11.3661 9.83589 10.6014L13.0681 13.8336C13.118 13.8855 13.1777 13.927 13.2438 13.9556C13.3099 13.9841 13.3811 13.9992 13.4531 14C13.5251 14.0007 13.5966 13.9871 13.6632 13.9598C13.7299 13.9326 13.7905 13.8924 13.8414 13.8414C13.8924 13.7905 13.9326 13.7299 13.9598 13.6632C13.9871 13.5966 14.0007 13.5251 14 13.4531C13.9992 13.3811 13.9841 13.3099 13.9556 13.2438C13.927 13.1777 13.8855 13.118 13.8336 13.0681L10.6014 9.83589C11.3661 8.90214 11.8268 7.71072 11.8268 6.4134C11.8268 3.43007 9.39672 1 6.4134 1ZM6.4134 2.08268C8.8116 2.08268 10.7441 4.0152 10.7441 6.4134C10.7441 8.8116 8.8116 10.7441 6.4134 10.7441C4.0152 10.7441 2.08268 8.8116 2.08268 6.4134C2.08268 4.0152 4.0152 2.08268 6.4134 2.08268Z" fill="#4D889E" stroke="#4D889E"/>
|
|
3
|
+
</svg>
|