@carbon/ibm-products 1.21.0 → 1.23.1
Sign up to get free protection for your applications and to get access to all the features.
- package/css/components/Datagrid/styles/datagrid.css +4 -0
- package/css/components/Datagrid/styles/datagrid.css.map +1 -1
- package/css/components/Datagrid/styles/index.css +32 -0
- package/css/components/Datagrid/styles/index.css.map +1 -1
- package/css/components/Datagrid/styles/useColumnCenterAlign.css +18 -0
- package/css/components/Datagrid/styles/useColumnCenterAlign.css.map +1 -0
- package/css/components/Datagrid/styles/useExpandedRow.css +12 -0
- package/css/components/Datagrid/styles/useExpandedRow.css.map +1 -0
- package/css/index-full-carbon.css +65 -144
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +3 -3
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +25 -16
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +2 -2
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +60 -17
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +2 -2
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +63 -140
- package/css/index.css.map +1 -1
- package/css/index.min.css +3 -3
- package/css/index.min.css.map +1 -1
- package/es/components/AddSelect/AddSelect.js +56 -422
- package/es/components/AddSelect/AddSelectBody.js +349 -0
- package/es/components/AddSelect/AddSelectBreadcrumbs.js +11 -31
- package/es/components/AddSelect/AddSelectColumn.js +91 -41
- package/es/components/AddSelect/AddSelectFilter.js +2 -3
- package/es/components/AddSelect/AddSelectList.js +10 -61
- package/es/components/AddSelect/AddSelectMetaPanel.js +9 -8
- package/es/components/AddSelect/AddSelectSidebar.js +20 -13
- package/es/components/AddSelect/AddSelectSort.js +4 -2
- package/es/components/AddSelect/add-select-utils.js +85 -59
- package/es/components/AddSelect/hooks/useParentSelect.js +16 -0
- package/es/components/AddSelect/hooks/usePath.js +66 -0
- package/es/components/Card/Card.js +1 -1
- package/es/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +1 -5
- package/es/components/CreateTearsheet/preview-components/MultiStepWithIntro.js +1 -5
- package/es/components/Datagrid/Datagrid/Datagrid.js +1 -1
- package/es/components/Datagrid/index.js +2 -1
- package/es/components/Datagrid/useColumnCenterAlign.js +52 -0
- package/es/components/Datagrid/useExpandedRow.js +12 -4
- package/es/components/PageHeader/PageHeaderUtils.js +5 -0
- package/es/components/TagSet/TagSet.js +15 -5
- package/es/components/WebTerminal/WebTerminal.js +5 -3
- package/lib/components/AddSelect/AddSelect.js +53 -430
- package/lib/components/AddSelect/AddSelectBody.js +384 -0
- package/lib/components/AddSelect/AddSelectBreadcrumbs.js +11 -30
- package/lib/components/AddSelect/AddSelectColumn.js +90 -39
- package/lib/components/AddSelect/AddSelectFilter.js +2 -3
- package/lib/components/AddSelect/AddSelectList.js +11 -60
- package/lib/components/AddSelect/AddSelectMetaPanel.js +9 -8
- package/lib/components/AddSelect/AddSelectSidebar.js +20 -13
- package/lib/components/AddSelect/AddSelectSort.js +4 -2
- package/lib/components/AddSelect/add-select-utils.js +88 -64
- package/lib/components/AddSelect/hooks/useParentSelect.js +27 -0
- package/lib/components/AddSelect/hooks/usePath.js +75 -0
- package/lib/components/Card/Card.js +1 -1
- package/lib/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +1 -5
- package/lib/components/CreateTearsheet/preview-components/MultiStepWithIntro.js +1 -5
- package/lib/components/Datagrid/Datagrid/Datagrid.js +1 -1
- package/lib/components/Datagrid/index.js +9 -1
- package/lib/components/Datagrid/useColumnCenterAlign.js +59 -0
- package/lib/components/Datagrid/useExpandedRow.js +20 -4
- package/lib/components/PageHeader/PageHeaderUtils.js +5 -0
- package/lib/components/TagSet/TagSet.js +15 -5
- package/lib/components/WebTerminal/WebTerminal.js +5 -2
- package/package.json +16 -16
- package/scss/components/Cascade/_cascade.scss +2 -1
- package/scss/components/CreateInfluencer/_create-influencer.scss +0 -2
- package/scss/components/CreateTearsheet/_create-tearsheet.scss +1 -1
- package/scss/components/Datagrid/_storybook-styles.scss +4 -0
- package/scss/components/Datagrid/styles/datagrid.scss +4 -0
- package/scss/components/Datagrid/styles/index.scss +2 -0
- package/scss/components/Datagrid/styles/useColumnCenterAlign.scss +19 -0
- package/scss/components/Datagrid/styles/useExpandedRow.scss +13 -0
- package/scss/components/InlineEdit/_inline-edit.scss +2 -1
- package/scss/components/OptionsTile/_options-tile.scss +1 -0
- package/scss/components/PageHeader/_page-header.scss +9 -4
- package/scss/components/SidePanel/_side-panel.scss +1 -2
- package/scss/components/TagSet/_tag-set.scss +4 -0
- package/scss/components/WebTerminal/_web-terminal.scss +2 -1
@@ -1,430 +1,52 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
4
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
5
|
-
var _excluded = ["
|
4
|
+
var _excluded = ["items", "globalFilters"];
|
6
5
|
//
|
7
6
|
// Copyright IBM Corp. 2022
|
8
7
|
//
|
9
8
|
// This source code is licensed under the Apache-2.0 license found in the
|
10
9
|
// LICENSE file in the root directory of this source tree.
|
11
10
|
//
|
12
|
-
import React, { forwardRef
|
11
|
+
import React, { forwardRef } from 'react';
|
13
12
|
import PropTypes from 'prop-types';
|
14
|
-
import
|
15
|
-
import { Tag } from 'carbon-components-react';
|
16
|
-
import { Tearsheet, TearsheetNarrow } from '../../components/Tearsheet';
|
17
|
-
import { NoDataEmptyState } from '../../components/EmptyStates/NoDataEmptyState';
|
13
|
+
import { AddSelectBody } from './AddSelectBody';
|
18
14
|
import { pkg } from '../../settings';
|
19
|
-
import {
|
20
|
-
|
21
|
-
import { AddSelectList } from './AddSelectList';
|
22
|
-
import { AddSelectColumn } from './AddSelectColumn';
|
23
|
-
import { normalize, flatten, getGlobalFilterValues } from './add-select-utils';
|
24
|
-
import { AddSelectFilter } from './AddSelectFilter';
|
25
|
-
import { AddSelectSort } from './AddSelectSort';
|
26
|
-
import { sortItems } from './add-select-utils';
|
27
|
-
import { useItemSort } from './hooks/useItemSort';
|
15
|
+
import { normalize, getGlobalFilterValues } from './add-select-utils';
|
16
|
+
var blockClass = "".concat(pkg.prefix, "--add-select");
|
28
17
|
var componentName = 'AddSelect';
|
29
18
|
export var AddSelect = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
30
|
-
var
|
31
|
-
|
32
|
-
var className = _ref.className,
|
33
|
-
clearFiltersText = _ref.clearFiltersText,
|
34
|
-
closeIconDescription = _ref.closeIconDescription,
|
35
|
-
columnInputPlaceholder = _ref.columnInputPlaceholder,
|
36
|
-
description = _ref.description,
|
19
|
+
var items = _ref.items,
|
37
20
|
globalFilters = _ref.globalFilters,
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
open = _ref.open,
|
61
|
-
portalTarget = _ref.portalTarget,
|
62
|
-
removeIconDescription = _ref.removeIconDescription,
|
63
|
-
searchResultsLabel = _ref.searchResultsLabel,
|
64
|
-
title = _ref.title,
|
65
|
-
rest = _objectWithoutProperties(_ref, _excluded);
|
66
|
-
|
67
|
-
var blockClass = "".concat(pkg.prefix, "--add-select"); // hooks
|
68
|
-
|
69
|
-
var _useState = useState([]),
|
70
|
-
_useState2 = _slicedToArray(_useState, 2),
|
71
|
-
path = _useState2[0],
|
72
|
-
setPath = _useState2[1];
|
73
|
-
|
74
|
-
var _useState3 = useState(''),
|
75
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
76
|
-
singleSelection = _useState4[0],
|
77
|
-
setSingleSelection = _useState4[1];
|
78
|
-
|
79
|
-
var _useState5 = useState([]),
|
80
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
81
|
-
multiSelection = _useState6[0],
|
82
|
-
setMultiSelection = _useState6[1];
|
83
|
-
|
84
|
-
var _useState7 = useState(''),
|
85
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
86
|
-
searchTerm = _useState8[0],
|
87
|
-
setSearchTerm = _useState8[1];
|
88
|
-
|
89
|
-
var _useState9 = useState({}),
|
90
|
-
_useState10 = _slicedToArray(_useState9, 2),
|
91
|
-
normalizedItems = _useState10[0],
|
92
|
-
setNormalizedItems = _useState10[1];
|
93
|
-
|
94
|
-
var _useState11 = useState(false),
|
95
|
-
_useState12 = _slicedToArray(_useState11, 2),
|
96
|
-
useNormalizedItems = _useState12[0],
|
97
|
-
setUsedNormalizedItems = _useState12[1];
|
98
|
-
|
99
|
-
var _useState13 = useState([]),
|
100
|
-
_useState14 = _slicedToArray(_useState13, 2),
|
101
|
-
flatItems = _useState14[0],
|
102
|
-
setFlatItems = _useState14[1];
|
103
|
-
|
104
|
-
var _useState15 = useState([]),
|
105
|
-
_useState16 = _slicedToArray(_useState15, 2),
|
106
|
-
globalFilterOpts = _useState16[0],
|
107
|
-
setGlobalFilterOpts = _useState16[1];
|
108
|
-
|
109
|
-
var _useState17 = useState({}),
|
110
|
-
_useState18 = _slicedToArray(_useState17, 2),
|
111
|
-
appliedGlobalFilters = _useState18[0],
|
112
|
-
setAppliedGlobalFilters = _useState18[1];
|
113
|
-
|
114
|
-
var _useState19 = useState({}),
|
115
|
-
_useState20 = _slicedToArray(_useState19, 2),
|
116
|
-
displayMetalPanel = _useState20[0],
|
117
|
-
setDisplayMetaPanel = _useState20[1];
|
118
|
-
|
119
|
-
var _useItemSort = useItemSort(),
|
120
|
-
sortDirection = _useItemSort.sortDirection,
|
121
|
-
setSortDirection = _useItemSort.setSortDirection,
|
122
|
-
sortAttribute = _useItemSort.sortAttribute,
|
123
|
-
setSortAttribute = _useItemSort.setSortAttribute;
|
124
|
-
|
125
|
-
var _useState21 = useState([]),
|
126
|
-
_useState22 = _slicedToArray(_useState21, 2),
|
127
|
-
appliedModifiers = _useState22[0],
|
128
|
-
setAppliedModifiers = _useState22[1];
|
129
|
-
|
130
|
-
useEffect(function () {
|
131
|
-
var entries = items.entries; // flatItems is just a single array of all entries including children
|
132
|
-
|
133
|
-
var flattenedItems = flatten(entries);
|
134
|
-
|
135
|
-
if (multi) {
|
136
|
-
if (globalFilters !== null && globalFilters !== void 0 && globalFilters.length) {
|
137
|
-
var globalFilterValues = getGlobalFilterValues(globalFilters, flattenedItems);
|
138
|
-
setGlobalFilterOpts(globalFilterValues);
|
139
|
-
}
|
140
|
-
|
141
|
-
if (items.modifiers) {
|
142
|
-
var modifiersToApply = flattenedItems.map(function (item) {
|
143
|
-
var modifierAttribute = items.modifiers.id;
|
144
|
-
return _defineProperty({
|
145
|
-
id: item.id
|
146
|
-
}, modifierAttribute, item[modifierAttribute]);
|
147
|
-
});
|
148
|
-
setAppliedModifiers(modifiersToApply);
|
149
|
-
} // multi select with nested data needs to be normalized
|
150
|
-
|
151
|
-
|
152
|
-
if (entries.find(function (entry) {
|
153
|
-
return entry.children;
|
154
|
-
})) {
|
155
|
-
var newItems = normalize(items);
|
156
|
-
setNormalizedItems(newItems);
|
157
|
-
setUsedNormalizedItems(true);
|
158
|
-
}
|
159
|
-
}
|
160
|
-
|
161
|
-
setFlatItems(flattenedItems);
|
162
|
-
}, [items, multi, globalFilters]); // used to generate columns of results for multi select with hierarchy
|
163
|
-
|
164
|
-
var getPages = function getPages() {
|
165
|
-
var pages = [];
|
166
|
-
var itemIds = Object.keys(normalizedItems); // top level items are just items with no parents so they're the top results
|
167
|
-
|
168
|
-
var topLevelItems = [];
|
169
|
-
itemIds.forEach(function (itemId) {
|
170
|
-
if (!normalizedItems[itemId].parent) {
|
171
|
-
topLevelItems.push(normalizedItems[itemId]);
|
172
|
-
}
|
173
|
-
});
|
174
|
-
pages.push(topLevelItems);
|
175
|
-
|
176
|
-
if (path.length) {
|
177
|
-
/**
|
178
|
-
* the path is set when you initially traverse the child entries
|
179
|
-
* path is an array of item id's
|
180
|
-
* when a path is present the normalized items are searched
|
181
|
-
* any item who's has a matching parent id is added to the results
|
182
|
-
* in the end you have an array of arrays for each column of the hierarchy
|
183
|
-
*/
|
184
|
-
var pathIds = path.map(function (p) {
|
185
|
-
return p.id;
|
186
|
-
});
|
187
|
-
pathIds.forEach(function (pathId) {
|
188
|
-
var entries = [];
|
189
|
-
itemIds.forEach(function (itemId) {
|
190
|
-
if (normalizedItems[itemId].parent === pathId) {
|
191
|
-
entries.push(normalizedItems[itemId]);
|
192
|
-
}
|
193
|
-
});
|
194
|
-
pages.push(entries);
|
195
|
-
});
|
196
|
-
}
|
197
|
-
|
198
|
-
return pages;
|
199
|
-
}; // item filtering
|
200
|
-
|
201
|
-
|
202
|
-
var getFilteredItems = function getFilteredItems() {
|
203
|
-
var entries = items.entries;
|
204
|
-
var hasPath = path.length > 0;
|
205
|
-
/**
|
206
|
-
* how to traverse the levels of items-
|
207
|
-
* the path represents the ids of each level / item / breadcrumb
|
208
|
-
* using this path we can drill down into the items until we get to the last one the user selected
|
209
|
-
*/
|
210
|
-
|
211
|
-
var itemsToFilter = hasPath ? path.reduce(function (prev, cur) {
|
212
|
-
var _prev$find, _prev$find$children;
|
213
|
-
|
214
|
-
return (_prev$find = prev.find(function (item) {
|
215
|
-
return item.id === cur.id;
|
216
|
-
})) === null || _prev$find === void 0 ? void 0 : (_prev$find$children = _prev$find.children) === null || _prev$find$children === void 0 ? void 0 : _prev$find$children.entries;
|
217
|
-
}, entries) : entries;
|
218
|
-
var results = itemsToFilter.filter(function (item) {
|
219
|
-
if (!searchTerm) {
|
220
|
-
return item;
|
221
|
-
} // otherwise use the default label filter
|
222
|
-
|
223
|
-
|
224
|
-
return item.title.toLowerCase().includes(searchTerm);
|
225
|
-
});
|
226
|
-
return results;
|
227
|
-
};
|
228
|
-
|
229
|
-
var sortFn = sortItems(sortAttribute, sortDirection);
|
230
|
-
|
231
|
-
var getDisplayItems = function getDisplayItems() {
|
232
|
-
if (useNormalizedItems) {
|
233
|
-
// when global search or filter is in use the results are not in column format
|
234
|
-
var filters = Object.keys(appliedGlobalFilters);
|
235
|
-
|
236
|
-
if (searchTerm || filters.length) {
|
237
|
-
var results = flatItems.filter(function (item) {
|
238
|
-
return item.title.toLowerCase().includes(searchTerm);
|
239
|
-
}).filter(function (item) {
|
240
|
-
return filters.every(function (filter) {
|
241
|
-
return item[filter] === appliedGlobalFilters[filter];
|
242
|
-
});
|
243
|
-
}).sort(sortFn);
|
244
|
-
return results;
|
245
|
-
}
|
246
|
-
|
247
|
-
return getPages();
|
248
|
-
}
|
249
|
-
|
250
|
-
return getFilteredItems();
|
251
|
-
}; // only multi select with hierarchy requires the the normalized items
|
252
|
-
|
253
|
-
|
254
|
-
var itemsToDisplay = getDisplayItems();
|
255
|
-
var commonListProps = {
|
256
|
-
metaIconDescription: metaIconDescription,
|
257
|
-
multi: multi,
|
258
|
-
multiSelection: multiSelection,
|
259
|
-
navIconDescription: navIconDescription,
|
260
|
-
path: path,
|
261
|
-
setMultiSelection: setMultiSelection,
|
262
|
-
setPath: setPath,
|
263
|
-
setSingleSelection: setSingleSelection,
|
264
|
-
singleSelection: singleSelection,
|
265
|
-
setDisplayMetaPanel: setDisplayMetaPanel
|
266
|
-
}; // handlers
|
267
|
-
|
268
|
-
var handleSearch = function handleSearch(term) {
|
269
|
-
setSearchTerm(term);
|
270
|
-
};
|
271
|
-
|
272
|
-
var handleFilter = function handleFilter(filters) {
|
273
|
-
setAppliedGlobalFilters(filters);
|
274
|
-
};
|
275
|
-
|
276
|
-
var submitHandler = function submitHandler() {
|
277
|
-
if (multi && appliedModifiers.length > 0) {
|
278
|
-
var selections = multiSelection.map(function (item) {
|
279
|
-
return appliedModifiers.find(function (mod) {
|
280
|
-
return mod.id === item;
|
281
|
-
});
|
282
|
-
});
|
283
|
-
onSubmit(selections);
|
284
|
-
} else if (multi && appliedModifiers.length === 0) {
|
285
|
-
onSubmit(multiSelection);
|
286
|
-
} else {
|
287
|
-
onSubmit(singleSelection);
|
288
|
-
}
|
289
|
-
};
|
290
|
-
|
291
|
-
var classNames = cx(className, blockClass, (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__single"), !multi), _defineProperty(_cx, "".concat(blockClass, "__multi"), multi), _cx));
|
292
|
-
var commonTearsheetProps = {
|
293
|
-
className: classNames,
|
294
|
-
open: open,
|
295
|
-
title: title,
|
296
|
-
description: description,
|
297
|
-
closeIconDescription: 'temp description',
|
298
|
-
actions: [{
|
299
|
-
label: onCloseButtonText,
|
300
|
-
kind: 'secondary',
|
301
|
-
onClick: onClose
|
302
|
-
}, {
|
303
|
-
label: onSubmitButtonText,
|
304
|
-
kind: 'primary',
|
305
|
-
onClick: submitHandler,
|
306
|
-
disabled: multi ? multiSelection.length === 0 : !singleSelection
|
307
|
-
}],
|
308
|
-
portalTarget: portalTarget
|
309
|
-
};
|
310
|
-
var sidebarProps = {
|
311
|
-
closeIconDescription: closeIconDescription,
|
312
|
-
influencerTitle: influencerTitle,
|
313
|
-
items: flatItems,
|
314
|
-
metaPanelTitle: metaPanelTitle,
|
315
|
-
multiSelection: multiSelection,
|
316
|
-
noSelectionDescription: noSelectionDescription,
|
317
|
-
noSelectionTitle: noSelectionTitle,
|
318
|
-
removeIconDescription: removeIconDescription,
|
319
|
-
setMultiSelection: setMultiSelection,
|
320
|
-
displayMetalPanel: displayMetalPanel,
|
321
|
-
setDisplayMetaPanel: setDisplayMetaPanel,
|
322
|
-
modifiers: items.modifiers,
|
323
|
-
appliedModifiers: appliedModifiers
|
324
|
-
};
|
325
|
-
|
326
|
-
var setShowBreadsCrumbs = function setShowBreadsCrumbs() {
|
327
|
-
if (searchTerm) {
|
328
|
-
return false;
|
329
|
-
}
|
330
|
-
|
331
|
-
if (path.length) {
|
332
|
-
return true;
|
333
|
-
}
|
334
|
-
|
335
|
-
return false;
|
336
|
-
};
|
337
|
-
|
338
|
-
var setShowTags = function setShowTags() {
|
339
|
-
if (searchTerm) {
|
340
|
-
return true;
|
341
|
-
}
|
342
|
-
|
343
|
-
if (useNormalizedItems) {
|
344
|
-
return false;
|
345
|
-
}
|
346
|
-
|
347
|
-
return true;
|
348
|
-
};
|
349
|
-
|
350
|
-
var hasResults = itemsToDisplay.length > 0;
|
351
|
-
var globalFiltersApplied = Object.keys(appliedGlobalFilters).length > 0;
|
352
|
-
var showBreadsCrumbs = setShowBreadsCrumbs();
|
353
|
-
var showSort = (searchTerm || globalFiltersApplied) && hasResults;
|
354
|
-
var showTags = setShowTags(); // main content
|
355
|
-
|
356
|
-
var body = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
357
|
-
className: "".concat(blockClass, "__header")
|
358
|
-
}, /*#__PURE__*/React.createElement(AddSelectFilter, {
|
359
|
-
inputLabel: globalSearchLabel,
|
360
|
-
inputPlaceholder: globalSearchPlaceholder,
|
361
|
-
searchTerm: searchTerm,
|
362
|
-
handleSearch: handleSearch,
|
363
|
-
multi: multi,
|
364
|
-
filterOpts: globalFilterOpts,
|
365
|
-
handleFilter: handleFilter,
|
366
|
-
primaryButtonText: globalFiltersPrimaryButtonText,
|
367
|
-
secondaryButtonText: globalFiltersSecondaryButtonText,
|
368
|
-
placeholder: globalFiltersPlaceholderText,
|
369
|
-
iconDescription: globalFiltersIconDescription,
|
370
|
-
appliedFilters: appliedGlobalFilters,
|
371
|
-
hasFiltersApplied: globalFiltersApplied,
|
372
|
-
clearFiltersText: clearFiltersText
|
373
|
-
}), /*#__PURE__*/React.createElement("div", {
|
374
|
-
className: "".concat(blockClass, "__sub-header")
|
375
|
-
}, /*#__PURE__*/React.createElement("div", {
|
376
|
-
className: "".concat(blockClass, "__tag-container")
|
377
|
-
}, showBreadsCrumbs ? /*#__PURE__*/React.createElement(AddSelectBreadcrumbs, {
|
378
|
-
itemsLabel: itemsLabel,
|
379
|
-
path: path,
|
380
|
-
setPath: setPath
|
381
|
-
}) : /*#__PURE__*/React.createElement("p", {
|
382
|
-
className: "".concat(blockClass, "__tag-container-label")
|
383
|
-
}, searchTerm ? searchResultsLabel : itemsLabel), showTags && /*#__PURE__*/React.createElement(Tag, {
|
384
|
-
type: "gray",
|
385
|
-
size: "sm"
|
386
|
-
}, itemsToDisplay.length)), showSort && /*#__PURE__*/React.createElement(AddSelectSort, {
|
387
|
-
items: itemsToDisplay,
|
388
|
-
setSortAttribute: setSortAttribute,
|
389
|
-
setSortDirection: setSortDirection,
|
390
|
-
sortAttribute: sortAttribute,
|
391
|
-
sortDirection: sortDirection,
|
392
|
-
sortBy: globalSortBy
|
393
|
-
}))), useNormalizedItems && !searchTerm && !globalFiltersApplied ? /*#__PURE__*/React.createElement("div", {
|
394
|
-
className: "".concat(blockClass, "__columns")
|
395
|
-
}, itemsToDisplay.map(function (page, idx) {
|
396
|
-
var _path;
|
397
|
-
|
398
|
-
return /*#__PURE__*/React.createElement(AddSelectColumn, _extends({}, commonListProps, {
|
399
|
-
key: idx,
|
400
|
-
filteredItems: page,
|
401
|
-
header: idx === 0 ? itemsLabel : (_path = path[idx - 1]) === null || _path === void 0 ? void 0 : _path.title,
|
402
|
-
columnInputPlaceholder: columnInputPlaceholder
|
403
|
-
}));
|
404
|
-
})) : /*#__PURE__*/React.createElement("div", null, hasResults ? /*#__PURE__*/React.createElement(AddSelectList, _extends({}, commonListProps, {
|
405
|
-
filteredItems: itemsToDisplay,
|
406
|
-
modifiers: items.modifiers,
|
407
|
-
appliedModifiers: appliedModifiers,
|
408
|
-
setAppliedModifiers: setAppliedModifiers
|
409
|
-
})) : /*#__PURE__*/React.createElement("div", {
|
410
|
-
className: "".concat(blockClass, "__body")
|
411
|
-
}, /*#__PURE__*/React.createElement(NoDataEmptyState, {
|
412
|
-
subtitle: noResultsDescription,
|
413
|
-
title: noResultsTitle
|
414
|
-
}))));
|
415
|
-
return /*#__PURE__*/React.createElement("div", _extends({
|
416
|
-
ref: ref
|
417
|
-
}, rest), multi ? /*#__PURE__*/React.createElement(Tearsheet, _extends({}, commonTearsheetProps, {
|
418
|
-
influencer: multi && /*#__PURE__*/React.createElement(AddSelectSidebar, sidebarProps),
|
419
|
-
influencerPosition: "right"
|
420
|
-
}), body) : /*#__PURE__*/React.createElement(TearsheetNarrow, commonTearsheetProps, body));
|
21
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
22
|
+
|
23
|
+
var useNormalizedItems = !!items.entries.find(function (item) {
|
24
|
+
return item.children;
|
25
|
+
});
|
26
|
+
var normalizedItems = useNormalizedItems ? normalize(items) : null;
|
27
|
+
var globalFilterOpts = props.multi && globalFilters !== null && globalFilters !== void 0 && globalFilters.length ? getGlobalFilterValues(globalFilters, normalizedItems) : null;
|
28
|
+
var defaultModifiers = props.multi && items.modifiers ? items.entries.map(function (item) {
|
29
|
+
var modifierAttribute = items.modifiers.id;
|
30
|
+
return _defineProperty({
|
31
|
+
id: item.id
|
32
|
+
}, modifierAttribute, item[modifierAttribute]);
|
33
|
+
}) : null;
|
34
|
+
return /*#__PURE__*/React.createElement(AddSelectBody, _extends({}, props, {
|
35
|
+
className: blockClass,
|
36
|
+
ref: ref,
|
37
|
+
items: items,
|
38
|
+
normalizedItems: normalizedItems,
|
39
|
+
useNormalizedItems: useNormalizedItems,
|
40
|
+
globalFilterOpts: globalFilterOpts,
|
41
|
+
defaultModifiers: defaultModifiers
|
42
|
+
}));
|
421
43
|
});
|
422
44
|
AddSelect.propTypes = {
|
423
45
|
className: PropTypes.string,
|
424
46
|
clearFiltersText: PropTypes.string,
|
425
|
-
closeIconDescription: PropTypes.string,
|
47
|
+
closeIconDescription: PropTypes.string.isRequired,
|
426
48
|
columnInputPlaceholder: PropTypes.string,
|
427
|
-
description: PropTypes.string,
|
49
|
+
description: PropTypes.string.isRequired,
|
428
50
|
globalFilters: PropTypes.arrayOf(PropTypes.shape({
|
429
51
|
id: PropTypes.string,
|
430
52
|
label: PropTypes.string
|
@@ -433,7 +55,7 @@ AddSelect.propTypes = {
|
|
433
55
|
globalFiltersPlaceholderText: PropTypes.string,
|
434
56
|
globalFiltersPrimaryButtonText: PropTypes.string,
|
435
57
|
globalFiltersSecondaryButtonText: PropTypes.string,
|
436
|
-
globalSearchLabel: PropTypes.string,
|
58
|
+
globalSearchLabel: PropTypes.string.isRequired,
|
437
59
|
globalSearchPlaceholder: PropTypes.string,
|
438
60
|
globalSortBy: PropTypes.array,
|
439
61
|
influencerTitle: PropTypes.string,
|
@@ -462,22 +84,22 @@ AddSelect.propTypes = {
|
|
462
84
|
subtitle: PropTypes.string,
|
463
85
|
title: PropTypes.string.isRequired,
|
464
86
|
value: PropTypes.string.isRequired
|
465
|
-
}))
|
466
|
-
}),
|
467
|
-
itemsLabel: PropTypes.string,
|
87
|
+
})).isRequired
|
88
|
+
}).isRequired,
|
89
|
+
itemsLabel: PropTypes.string.isRequired,
|
468
90
|
metaIconDescription: PropTypes.string,
|
469
91
|
metaPanelTitle: PropTypes.string,
|
470
|
-
multi: PropTypes.bool,
|
92
|
+
multi: PropTypes.bool.isRequired,
|
471
93
|
navIconDescription: PropTypes.string,
|
472
|
-
noResultsDescription: PropTypes.string,
|
473
|
-
noResultsTitle: PropTypes.string,
|
94
|
+
noResultsDescription: PropTypes.string.isRequired,
|
95
|
+
noResultsTitle: PropTypes.string.isRequired,
|
474
96
|
noSelectionDescription: PropTypes.string,
|
475
97
|
noSelectionTitle: PropTypes.string,
|
476
|
-
onClose: PropTypes.func,
|
477
|
-
onCloseButtonText: PropTypes.string,
|
478
|
-
onSubmit: PropTypes.func,
|
479
|
-
onSubmitButtonText: PropTypes.string,
|
480
|
-
open: PropTypes.bool,
|
98
|
+
onClose: PropTypes.func.isRequired,
|
99
|
+
onCloseButtonText: PropTypes.string.isRequired,
|
100
|
+
onSubmit: PropTypes.func.isRequired,
|
101
|
+
onSubmitButtonText: PropTypes.string.isRequired,
|
102
|
+
open: PropTypes.bool.isRequired,
|
481
103
|
|
482
104
|
/**
|
483
105
|
* portal target for the all tags modal
|
@@ -485,11 +107,23 @@ AddSelect.propTypes = {
|
|
485
107
|
portalTarget: PropTypes.node,
|
486
108
|
removeIconDescription: PropTypes.string,
|
487
109
|
searchResultsLabel: PropTypes.string,
|
488
|
-
title: PropTypes.string
|
110
|
+
title: PropTypes.string.isRequired
|
489
111
|
};
|
490
112
|
AddSelect.defaultProps = {
|
113
|
+
closeIconDescription: '',
|
114
|
+
description: '',
|
115
|
+
itemsLabel: '',
|
491
116
|
items: {
|
492
117
|
entries: []
|
493
|
-
}
|
118
|
+
},
|
119
|
+
multi: false,
|
120
|
+
noResultsDescription: '',
|
121
|
+
noResultsTitle: '',
|
122
|
+
onClose: function onClose() {},
|
123
|
+
onCloseButtonText: '',
|
124
|
+
onSubmit: function onSubmit() {},
|
125
|
+
onSubmitButtonText: '',
|
126
|
+
open: false,
|
127
|
+
title: ''
|
494
128
|
};
|
495
129
|
AddSelect.displayName = componentName;
|