@carbon/ibm-products 1.22.0 → 1.24.0
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/css/components/Datagrid/styles/datagrid.css +87 -11
- package/css/components/Datagrid/styles/datagrid.css.map +1 -1
- package/css/components/Datagrid/styles/index.css +94 -11
- package/css/components/Datagrid/styles/index.css.map +1 -1
- package/css/components/Datagrid/styles/useExpandedRow.css +9 -0
- package/css/components/Datagrid/styles/useExpandedRow.css.map +1 -0
- package/css/index-full-carbon.css +276 -181
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +2 -8
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +37 -41
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +1 -7
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +271 -54
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +1 -7
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +274 -177
- package/css/index.css.map +1 -1
- package/css/index.min.css +2 -8
- package/css/index.min.css.map +1 -1
- package/es/components/AddSelect/AddSelect.js +56 -423
- package/es/components/AddSelect/AddSelectBody.js +345 -0
- package/es/components/AddSelect/AddSelectBreadcrumbs.js +11 -31
- package/es/components/AddSelect/AddSelectColumn.js +95 -42
- package/es/components/AddSelect/AddSelectFilter.js +2 -3
- package/es/components/AddSelect/AddSelectList.js +11 -62
- package/es/components/AddSelect/AddSelectMetaPanel.js +9 -8
- package/es/components/AddSelect/AddSelectSidebar.js +24 -39
- 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 +17 -12
- package/es/components/Datagrid/Datagrid/DatagridRow.js +4 -2
- package/es/components/Datagrid/useExpandedRow.js +1 -0
- package/es/components/Datagrid/useOnRowClick.js +10 -3
- package/es/components/EditFullPage/EditFullPage.js +79 -0
- package/es/components/EditFullPage/index.js +7 -0
- package/es/components/EditTearsheet/EditTearsheet.js +205 -0
- package/es/components/EditTearsheet/EditTearsheetForm.js +103 -0
- package/es/components/EditTearsheet/index.js +8 -0
- package/es/components/EditTearsheet/preview-components/MultiFormEditTearsheet.js +230 -0
- package/es/components/EditTearsheetNarrow/EditTearsheetNarrow.js +79 -0
- package/es/components/EditTearsheetNarrow/index.js +7 -0
- 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/es/components/index.js +4 -1
- package/es/global/js/package-settings.js +4 -1
- package/lib/components/AddSelect/AddSelect.js +53 -431
- package/lib/components/AddSelect/AddSelectBody.js +380 -0
- package/lib/components/AddSelect/AddSelectBreadcrumbs.js +11 -30
- package/lib/components/AddSelect/AddSelectColumn.js +93 -40
- package/lib/components/AddSelect/AddSelectFilter.js +2 -3
- package/lib/components/AddSelect/AddSelectList.js +12 -61
- package/lib/components/AddSelect/AddSelectMetaPanel.js +9 -8
- package/lib/components/AddSelect/AddSelectSidebar.js +22 -38
- 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 +17 -12
- package/lib/components/Datagrid/Datagrid/DatagridRow.js +3 -1
- package/lib/components/Datagrid/useExpandedRow.js +1 -0
- package/lib/components/Datagrid/useOnRowClick.js +10 -3
- package/lib/components/EditFullPage/EditFullPage.js +85 -0
- package/lib/components/EditFullPage/index.js +13 -0
- package/lib/components/EditTearsheet/EditTearsheet.js +229 -0
- package/lib/components/EditTearsheet/EditTearsheetForm.js +122 -0
- package/lib/components/EditTearsheet/index.js +21 -0
- package/lib/components/EditTearsheet/preview-components/MultiFormEditTearsheet.js +254 -0
- package/lib/components/EditTearsheetNarrow/EditTearsheetNarrow.js +85 -0
- package/lib/components/EditTearsheetNarrow/index.js +13 -0
- 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/lib/components/index.js +25 -1
- package/lib/global/js/package-settings.js +4 -1
- package/package.json +16 -16
- package/scss/components/Cascade/_cascade.scss +2 -1
- package/scss/components/CreateInfluencer/_create-influencer.scss +2 -2
- package/scss/components/CreateTearsheet/_create-tearsheet.scss +1 -1
- package/scss/components/Datagrid/_datagrid.scss +0 -1
- package/scss/components/Datagrid/_storybook-styles.scss +57 -0
- package/scss/components/Datagrid/styles/datagrid.scss +97 -12
- package/scss/components/Datagrid/styles/index.scss +1 -0
- package/scss/components/Datagrid/styles/useExpandedRow.scss +7 -0
- package/scss/components/EditFullPage/_edit-full-page.scss +34 -0
- package/scss/components/EditFullPage/_index.scss +8 -0
- package/scss/components/EditFullPage/_storybook-styles.scss +10 -0
- package/scss/components/EditTearsheet/_edit-tearsheet.scss +132 -0
- package/scss/components/EditTearsheet/_index.scss +8 -0
- package/scss/components/EditTearsheet/_storybook-styles.scss +55 -0
- package/scss/components/EditTearsheetNarrow/_edit-tearsheet-narrow.scss +34 -0
- package/scss/components/EditTearsheetNarrow/_index.scss +8 -0
- package/scss/components/EditTearsheetNarrow/_storybook-styles.scss +10 -0
- package/scss/components/InlineEdit/_inline-edit.scss +10 -21
- package/scss/components/NotificationsPanel/_notifications-panel.scss +1 -0
- package/scss/components/OptionsTile/_options-tile.scss +1 -0
- package/scss/components/PageHeader/_page-header.scss +11 -4
- package/scss/components/SidePanel/_side-panel.scss +1 -2
- package/scss/components/StatusIcon/_status-icon.scss +1 -1
- package/scss/components/TagSet/_tag-set.scss +4 -0
- package/scss/components/Tearsheet/_tearsheet.scss +2 -2
- package/scss/components/WebTerminal/_web-terminal.scss +2 -1
- package/scss/components/_index.scss +3 -0
|
@@ -11,8 +11,9 @@ import { Button, Checkbox, RadioButton, StructuredListRow, StructuredListWrapper
|
|
|
11
11
|
import { ChevronRight16, View16 } from '@carbon/icons-react';
|
|
12
12
|
import PropTypes from 'prop-types';
|
|
13
13
|
import cx from 'classnames';
|
|
14
|
-
import { UserProfileImage } from '../UserProfileImage';
|
|
15
14
|
import { pkg } from '../../settings';
|
|
15
|
+
import { UserProfileImage } from '../UserProfileImage';
|
|
16
|
+
var blockClass = "".concat(pkg.prefix, "--add-select__selections");
|
|
16
17
|
var componentName = 'AddSelectList';
|
|
17
18
|
export var AddSelectList = function AddSelectList(_ref) {
|
|
18
19
|
var _modifiers$options;
|
|
@@ -24,14 +25,13 @@ export var AddSelectList = function AddSelectList(_ref) {
|
|
|
24
25
|
multi = _ref.multi,
|
|
25
26
|
multiSelection = _ref.multiSelection,
|
|
26
27
|
navIconDescription = _ref.navIconDescription,
|
|
27
|
-
|
|
28
|
+
parentId = _ref.parentId,
|
|
28
29
|
setAppliedModifiers = _ref.setAppliedModifiers,
|
|
29
30
|
setDisplayMetaPanel = _ref.setDisplayMetaPanel,
|
|
30
31
|
setMultiSelection = _ref.setMultiSelection,
|
|
31
|
-
|
|
32
|
+
setParentSelected = _ref.setParentSelected,
|
|
32
33
|
setSingleSelection = _ref.setSingleSelection,
|
|
33
34
|
singleSelection = _ref.singleSelection;
|
|
34
|
-
var blockClass = "".concat(pkg.prefix, "--add-select__selections");
|
|
35
35
|
var hasModifiers = (modifiers === null || modifiers === void 0 ? void 0 : (_modifiers$options = modifiers.options) === null || _modifiers$options === void 0 ? void 0 : _modifiers$options.length) > 0;
|
|
36
36
|
|
|
37
37
|
var handleSingleSelection = function handleSingleSelection(value) {
|
|
@@ -53,61 +53,8 @@ export var AddSelectList = function AddSelectList(_ref) {
|
|
|
53
53
|
|
|
54
54
|
var onNavigateItem = function onNavigateItem(_ref2) {
|
|
55
55
|
var id = _ref2.id,
|
|
56
|
-
title = _ref2.title
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
// if multi select
|
|
60
|
-
if (multi) {
|
|
61
|
-
// if top level reset the path
|
|
62
|
-
if (!parent) {
|
|
63
|
-
setPath([{
|
|
64
|
-
id: id,
|
|
65
|
-
title: title
|
|
66
|
-
}]);
|
|
67
|
-
} else {
|
|
68
|
-
var pathIds = path.map(function (p) {
|
|
69
|
-
return p.id;
|
|
70
|
-
}); // if item is already selected somewhere go back to that item
|
|
71
|
-
|
|
72
|
-
if (pathIds.includes(id)) {
|
|
73
|
-
var pathIdx = pathIds.findIndex(function (pathId) {
|
|
74
|
-
return pathId === id;
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
var newPath = _toConsumableArray(path).splice(0, pathIdx + 1);
|
|
78
|
-
|
|
79
|
-
setPath(_toConsumableArray(newPath));
|
|
80
|
-
} else {
|
|
81
|
-
// if the item is on the same level as another selected item start from the parent level
|
|
82
|
-
if (path.find(function (p) {
|
|
83
|
-
return p.parent === parent;
|
|
84
|
-
})) {
|
|
85
|
-
var parentIdx = path.findIndex(function (p) {
|
|
86
|
-
return p.id === parent;
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
var _newPath = _toConsumableArray(path).splice(0, parentIdx + 1);
|
|
90
|
-
|
|
91
|
-
setPath([].concat(_toConsumableArray(_newPath), [{
|
|
92
|
-
id: id,
|
|
93
|
-
title: title,
|
|
94
|
-
parent: parent
|
|
95
|
-
}]));
|
|
96
|
-
} else {
|
|
97
|
-
setPath([].concat(_toConsumableArray(path), [{
|
|
98
|
-
id: id,
|
|
99
|
-
title: title,
|
|
100
|
-
parent: parent
|
|
101
|
-
}]));
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
} else {
|
|
106
|
-
setPath([].concat(_toConsumableArray(path), [{
|
|
107
|
-
id: id,
|
|
108
|
-
title: title
|
|
109
|
-
}]));
|
|
110
|
-
}
|
|
56
|
+
title = _ref2.title;
|
|
57
|
+
setParentSelected(id, title, parentId);
|
|
111
58
|
};
|
|
112
59
|
|
|
113
60
|
var isSelected = function isSelected(id) {
|
|
@@ -181,7 +128,7 @@ export var AddSelectList = function AddSelectList(_ref) {
|
|
|
181
128
|
}, item.title), item.subtitle && /*#__PURE__*/React.createElement("span", {
|
|
182
129
|
className: "".concat(blockClass, "-cell-subtitle")
|
|
183
130
|
}, item.subtitle)))), hasModifiers && /*#__PURE__*/React.createElement(Dropdown, {
|
|
184
|
-
id: "".concat(item.id
|
|
131
|
+
id: "add-select-modifier-".concat(item.id),
|
|
185
132
|
type: "inline",
|
|
186
133
|
items: modifiers.options,
|
|
187
134
|
light: true,
|
|
@@ -204,6 +151,7 @@ export var AddSelectList = function AddSelectList(_ref) {
|
|
|
204
151
|
},
|
|
205
152
|
selected: item.id === singleSelection
|
|
206
153
|
}), item.children && /*#__PURE__*/React.createElement(Button, {
|
|
154
|
+
className: "".concat(blockClass, "-view-children"),
|
|
207
155
|
renderIcon: ChevronRight16,
|
|
208
156
|
iconDescription: navIconDescription,
|
|
209
157
|
tooltipPosition: "left",
|
|
@@ -217,6 +165,7 @@ export var AddSelectList = function AddSelectList(_ref) {
|
|
|
217
165
|
}), item.meta && /*#__PURE__*/React.createElement("div", {
|
|
218
166
|
className: "".concat(blockClass, "-hidden-hover")
|
|
219
167
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
168
|
+
className: "".concat(blockClass, "-view-meta"),
|
|
220
169
|
renderIcon: View16,
|
|
221
170
|
iconDescription: metaIconDescription,
|
|
222
171
|
tooltipPosition: "left",
|
|
@@ -238,11 +187,11 @@ AddSelectList.propTypes = {
|
|
|
238
187
|
multi: PropTypes.bool,
|
|
239
188
|
multiSelection: PropTypes.array,
|
|
240
189
|
navIconDescription: PropTypes.string,
|
|
241
|
-
|
|
190
|
+
parentId: PropTypes.string,
|
|
242
191
|
setAppliedModifiers: PropTypes.func,
|
|
243
192
|
setDisplayMetaPanel: PropTypes.func,
|
|
244
193
|
setMultiSelection: PropTypes.func,
|
|
245
|
-
|
|
194
|
+
setParentSelected: PropTypes.func,
|
|
246
195
|
setSingleSelection: PropTypes.func,
|
|
247
196
|
singleSelection: PropTypes.string
|
|
248
197
|
};
|
|
@@ -3,13 +3,13 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import { Close16 } from '@carbon/icons-react';
|
|
4
4
|
import { Button } from 'carbon-components-react';
|
|
5
5
|
import { pkg } from '../../settings';
|
|
6
|
+
var blockClass = "".concat(pkg.prefix, "--add-select__meta-panel");
|
|
6
7
|
var componentName = 'AddSelectMetaPanel';
|
|
7
8
|
export var AddSelectMetaPanel = function AddSelectMetaPanel(_ref) {
|
|
8
9
|
var closeIconDescription = _ref.closeIconDescription,
|
|
9
10
|
meta = _ref.meta,
|
|
10
11
|
setDisplayMetaPanel = _ref.setDisplayMetaPanel,
|
|
11
12
|
title = _ref.title;
|
|
12
|
-
var blockClass = "".concat(pkg.prefix, "--add-select__meta-panel");
|
|
13
13
|
|
|
14
14
|
var onCloseHandler = function onCloseHandler() {
|
|
15
15
|
setDisplayMetaPanel({});
|
|
@@ -22,6 +22,7 @@ export var AddSelectMetaPanel = function AddSelectMetaPanel(_ref) {
|
|
|
22
22
|
}, /*#__PURE__*/React.createElement("p", {
|
|
23
23
|
className: "".concat(blockClass, "-title")
|
|
24
24
|
}, title), /*#__PURE__*/React.createElement(Button, {
|
|
25
|
+
className: "".concat(blockClass, "-close"),
|
|
25
26
|
renderIcon: Close16,
|
|
26
27
|
iconDescription: closeIconDescription,
|
|
27
28
|
tooltipPosition: "left",
|
|
@@ -32,23 +33,23 @@ export var AddSelectMetaPanel = function AddSelectMetaPanel(_ref) {
|
|
|
32
33
|
size: "sm"
|
|
33
34
|
})), /*#__PURE__*/isValidElement(meta) ? meta : meta.map(function (entry) {
|
|
34
35
|
return /*#__PURE__*/React.createElement("div", {
|
|
35
|
-
key: entry.id,
|
|
36
|
+
key: entry === null || entry === void 0 ? void 0 : entry.id,
|
|
36
37
|
className: "".concat(blockClass, "-entry")
|
|
37
38
|
}, /*#__PURE__*/React.createElement("p", {
|
|
38
39
|
className: "".concat(blockClass, "-entry-title")
|
|
39
|
-
}, entry.title), /*#__PURE__*/React.createElement("p", {
|
|
40
|
+
}, entry === null || entry === void 0 ? void 0 : entry.title), /*#__PURE__*/React.createElement("p", {
|
|
40
41
|
className: "".concat(blockClass, "-entry-body")
|
|
41
|
-
}, entry.value));
|
|
42
|
+
}, entry === null || entry === void 0 ? void 0 : entry.value));
|
|
42
43
|
}));
|
|
43
44
|
};
|
|
44
45
|
AddSelectMetaPanel.propTypes = {
|
|
45
|
-
closeIconDescription: PropTypes.string,
|
|
46
|
+
closeIconDescription: PropTypes.string.isRequired,
|
|
46
47
|
meta: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.shape({
|
|
47
48
|
id: PropTypes.string,
|
|
48
49
|
title: PropTypes.string,
|
|
49
50
|
value: PropTypes.string
|
|
50
|
-
})), PropTypes.node]),
|
|
51
|
-
setDisplayMetaPanel: PropTypes.func,
|
|
52
|
-
title: PropTypes.string
|
|
51
|
+
})), PropTypes.node]).isRequired,
|
|
52
|
+
setDisplayMetaPanel: PropTypes.func.isRequired,
|
|
53
|
+
title: PropTypes.string.isRequired
|
|
53
54
|
};
|
|
54
55
|
AddSelectMetaPanel.displayName = componentName;
|
|
@@ -7,12 +7,12 @@ var _excluded = ["meta", "icon", "avatar"];
|
|
|
7
7
|
// LICENSE file in the root directory of this source tree.
|
|
8
8
|
//
|
|
9
9
|
import React from 'react';
|
|
10
|
-
import { Tag, Accordion, AccordionItem
|
|
11
|
-
import { SubtractAlt32 } from '@carbon/icons-react';
|
|
10
|
+
import { Tag, Accordion, AccordionItem } from 'carbon-components-react';
|
|
12
11
|
import PropTypes from 'prop-types';
|
|
13
12
|
import { NoDataEmptyState } from '../../components/EmptyStates/NoDataEmptyState';
|
|
14
13
|
import { pkg } from '../../settings';
|
|
15
14
|
import { AddSelectMetaPanel } from './AddSelectMetaPanel';
|
|
15
|
+
var blockClass = "".concat(pkg.prefix, "--add-select__sidebar");
|
|
16
16
|
var componentName = 'AddSelectSidebar';
|
|
17
17
|
export var AddSelectSidebar = function AddSelectSidebar(_ref) {
|
|
18
18
|
var _modifiers$options;
|
|
@@ -27,34 +27,31 @@ export var AddSelectSidebar = function AddSelectSidebar(_ref) {
|
|
|
27
27
|
multiSelection = _ref.multiSelection,
|
|
28
28
|
noSelectionDescription = _ref.noSelectionDescription,
|
|
29
29
|
noSelectionTitle = _ref.noSelectionTitle,
|
|
30
|
-
|
|
31
|
-
setDisplayMetaPanel = _ref.setDisplayMetaPanel,
|
|
32
|
-
setMultiSelection = _ref.setMultiSelection;
|
|
33
|
-
var blockClass = "".concat(pkg.prefix, "--add-select__sidebar");
|
|
30
|
+
setDisplayMetaPanel = _ref.setDisplayMetaPanel;
|
|
34
31
|
var hasModifiers = (modifiers === null || modifiers === void 0 ? void 0 : (_modifiers$options = modifiers.options) === null || _modifiers$options === void 0 ? void 0 : _modifiers$options.length) > 0;
|
|
35
32
|
var hasSelections = multiSelection.length > 0;
|
|
36
33
|
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
return v !== id;
|
|
40
|
-
});
|
|
41
|
-
setMultiSelection(newSelections);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
var sidebarItems = multiSelection.reduce(function (acc, cur) {
|
|
45
|
-
var selectedItem = items.find(function (item) {
|
|
46
|
-
return item.id === cur;
|
|
47
|
-
}); // certain properties should not be displayed in the sidebar
|
|
34
|
+
var getNewItem = function getNewItem(item) {
|
|
35
|
+
// certain properties should not be displayed in the sidebar
|
|
48
36
|
// eslint-disable-next-line no-unused-vars
|
|
37
|
+
var meta = item.meta,
|
|
38
|
+
icon = item.icon,
|
|
39
|
+
avatar = item.avatar,
|
|
40
|
+
newItem = _objectWithoutProperties(item, _excluded);
|
|
49
41
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
42
|
+
return newItem;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
var sidebarItems = multiSelection.map(function (selectionId) {
|
|
46
|
+
if (Array.isArray(items)) {
|
|
47
|
+
var selectedItem = items.find(function (item) {
|
|
48
|
+
return item.id === selectionId;
|
|
49
|
+
});
|
|
50
|
+
return getNewItem(selectedItem);
|
|
51
|
+
}
|
|
54
52
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}, []);
|
|
53
|
+
return getNewItem(items[selectionId]);
|
|
54
|
+
});
|
|
58
55
|
|
|
59
56
|
var getTitle = function getTitle(item) {
|
|
60
57
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -67,17 +64,7 @@ export var AddSelectSidebar = function AddSelectSidebar(_ref) {
|
|
|
67
64
|
className: "".concat(blockClass, "-selected-item-subtitle")
|
|
68
65
|
}, item.subtitle)), hasModifiers && /*#__PURE__*/React.createElement("div", null, appliedModifiers.find(function (modifier) {
|
|
69
66
|
return modifier.id === item.id;
|
|
70
|
-
})[modifiers.id])
|
|
71
|
-
renderIcon: SubtractAlt32,
|
|
72
|
-
iconDescription: removeIconDescription,
|
|
73
|
-
hasIconOnly: true,
|
|
74
|
-
onClick: function onClick() {
|
|
75
|
-
return handleItemRemove(item.id);
|
|
76
|
-
},
|
|
77
|
-
kind: "ghost",
|
|
78
|
-
className: "".concat(blockClass, "-item-remove-button"),
|
|
79
|
-
size: "sm"
|
|
80
|
-
}));
|
|
67
|
+
})[modifiers.id]));
|
|
81
68
|
};
|
|
82
69
|
|
|
83
70
|
if (Object.keys(displayMetalPanel).length !== 0) {
|
|
@@ -127,14 +114,12 @@ AddSelectSidebar.propTypes = {
|
|
|
127
114
|
closeIconDescription: PropTypes.string,
|
|
128
115
|
displayMetalPanel: PropTypes.object,
|
|
129
116
|
influencerTitle: PropTypes.string,
|
|
130
|
-
items: PropTypes.array,
|
|
117
|
+
items: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
|
|
131
118
|
metaPanelTitle: PropTypes.string,
|
|
132
119
|
modifiers: PropTypes.object,
|
|
133
120
|
multiSelection: PropTypes.array,
|
|
134
121
|
noSelectionDescription: PropTypes.string,
|
|
135
122
|
noSelectionTitle: PropTypes.string,
|
|
136
|
-
|
|
137
|
-
setDisplayMetaPanel: PropTypes.func,
|
|
138
|
-
setMultiSelection: PropTypes.func
|
|
123
|
+
setDisplayMetaPanel: PropTypes.func
|
|
139
124
|
};
|
|
140
125
|
AddSelectSidebar.displayName = componentName;
|
|
@@ -10,12 +10,12 @@ import PropTypes from 'prop-types';
|
|
|
10
10
|
import { OverflowMenu, OverflowMenuItem } from 'carbon-components-react';
|
|
11
11
|
import { ArrowsVertical32, ArrowUp16, ArrowDown16 } from '@carbon/icons-react';
|
|
12
12
|
import { pkg } from '../../settings';
|
|
13
|
-
var
|
|
13
|
+
var blockClass = "".concat(pkg.prefix, "--add-select-sort");
|
|
14
|
+
var componentName = 'AddSelectSort';
|
|
14
15
|
export var AddSelectSort = function AddSelectSort(_ref) {
|
|
15
16
|
var setSortAttribute = _ref.setSortAttribute,
|
|
16
17
|
setSortDirection = _ref.setSortDirection,
|
|
17
18
|
sortBy = _ref.sortBy;
|
|
18
|
-
var blockClass = "".concat(pkg.prefix, "--add-select-sort");
|
|
19
19
|
var sortByOpts = sortBy ? sortBy.reduce(function (acc, cur) {
|
|
20
20
|
var opts = [{
|
|
21
21
|
id: "".concat(cur, "-asc"),
|
|
@@ -41,10 +41,12 @@ export var AddSelectSort = function AddSelectSort(_ref) {
|
|
|
41
41
|
return /*#__PURE__*/React.createElement("div", {
|
|
42
42
|
className: blockClass
|
|
43
43
|
}, sortByOpts.length > 0 && /*#__PURE__*/React.createElement(OverflowMenu, {
|
|
44
|
+
className: "".concat(blockClass, "_overflow"),
|
|
44
45
|
renderIcon: ArrowsVertical32,
|
|
45
46
|
flipped: true
|
|
46
47
|
}, sortByOpts.map(function (opt) {
|
|
47
48
|
return /*#__PURE__*/React.createElement(OverflowMenuItem, {
|
|
49
|
+
className: "".concat(blockClass, "_overflow-item"),
|
|
48
50
|
key: opt.id,
|
|
49
51
|
itemText: opt.itemText,
|
|
50
52
|
onClick: function onClick() {
|
|
@@ -1,66 +1,33 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["children"]
|
|
4
|
-
_excluded2 = ["children"];
|
|
3
|
+
var _excluded = ["children"];
|
|
5
4
|
|
|
6
5
|
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; }
|
|
7
6
|
|
|
8
7
|
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; }
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* to be able to more easily and efficiently the child entries the data needs to be
|
|
11
|
+
* normalized. this function recursively goes through the data array to build a single
|
|
12
|
+
* object who's keys are the id's of every single entry
|
|
13
|
+
* @param {object} data
|
|
14
|
+
* @returns an object of normalized data
|
|
14
15
|
*/
|
|
15
|
-
export var normalize = function normalize(
|
|
16
|
-
var
|
|
17
|
-
parentId = items.parentId,
|
|
18
|
-
sortBy = items.sortBy,
|
|
19
|
-
filterBy = items.filterBy;
|
|
20
|
-
return entries.reduce(function (acc, cur) {
|
|
16
|
+
export var normalize = function normalize(data) {
|
|
17
|
+
var items = data.entries.reduce(function (prev, cur) {
|
|
21
18
|
var children = cur.children,
|
|
22
|
-
|
|
19
|
+
item = _objectWithoutProperties(cur, _excluded);
|
|
23
20
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (parentId) {
|
|
27
|
-
acc[cur.id].parent = parentId;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (sortBy !== null && sortBy !== void 0 && sortBy.length) {
|
|
31
|
-
acc[cur.id].sortBy = sortBy;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (filterBy) {
|
|
35
|
-
acc[cur.id].filterBy = filterBy;
|
|
36
|
-
}
|
|
21
|
+
prev[item.id] = item;
|
|
37
22
|
|
|
38
23
|
if (children) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
});
|
|
42
|
-
var child = normalize(_objectSpread(_objectSpread({}, children), {}, {
|
|
43
|
-
parentId: cur.id
|
|
44
|
-
}));
|
|
45
|
-
return _objectSpread(_objectSpread({}, acc), child);
|
|
24
|
+
var childItems = normalize(children);
|
|
25
|
+
return _objectSpread(_objectSpread({}, prev), childItems);
|
|
46
26
|
}
|
|
47
27
|
|
|
48
|
-
return
|
|
28
|
+
return prev;
|
|
49
29
|
}, {});
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* used to create a single searchable array of nested items
|
|
53
|
-
* @param {Array} entries - list of entries
|
|
54
|
-
* @returns an array of items
|
|
55
|
-
*/
|
|
56
|
-
|
|
57
|
-
export var flatten = function flatten(entries) {
|
|
58
|
-
return entries.reduce(function (prev, cur) {
|
|
59
|
-
var children = cur.children,
|
|
60
|
-
item = _objectWithoutProperties(cur, _excluded2);
|
|
61
|
-
|
|
62
|
-
return prev.concat(item).concat(children ? flatten(children.entries) : []);
|
|
63
|
-
}, []);
|
|
30
|
+
return items;
|
|
64
31
|
};
|
|
65
32
|
/**
|
|
66
33
|
* takes in a global filters array and a flat list of items
|
|
@@ -74,23 +41,25 @@ export var flatten = function flatten(entries) {
|
|
|
74
41
|
*/
|
|
75
42
|
|
|
76
43
|
export var getGlobalFilterValues = function getGlobalFilterValues(globalFilters, items) {
|
|
77
|
-
var
|
|
44
|
+
var itemIds = Object.keys(items);
|
|
45
|
+
var results = globalFilters.reduce(function (prevFilter, curFilter) {
|
|
78
46
|
var filterId = curFilter.id;
|
|
79
|
-
var
|
|
47
|
+
var filterOpts = itemIds.reduce(function (prevId, curId) {
|
|
48
|
+
var curItem = items[curId];
|
|
80
49
|
var value = curItem[filterId];
|
|
81
50
|
|
|
82
|
-
if (value && !
|
|
83
|
-
|
|
51
|
+
if (value && !prevId.includes(value)) {
|
|
52
|
+
prevId.push(value);
|
|
84
53
|
}
|
|
85
54
|
|
|
86
|
-
return
|
|
55
|
+
return prevId;
|
|
87
56
|
}, []);
|
|
88
57
|
prevFilter.push(_objectSpread({
|
|
89
|
-
opts:
|
|
58
|
+
opts: filterOpts
|
|
90
59
|
}, curFilter));
|
|
91
60
|
return prevFilter;
|
|
92
61
|
}, []);
|
|
93
|
-
return
|
|
62
|
+
return results;
|
|
94
63
|
};
|
|
95
64
|
export var sortItems = function sortItems(attribute, direction) {
|
|
96
65
|
return function (a, b) {
|
|
@@ -106,10 +75,67 @@ export var sortItems = function sortItems(attribute, direction) {
|
|
|
106
75
|
return valueA < valueB ? -1 : 1;
|
|
107
76
|
};
|
|
108
77
|
};
|
|
109
|
-
export var
|
|
110
|
-
|
|
78
|
+
export var getFilteredItems = function getFilteredItems(useNormalizedItems, normalizedItems, searchTerm, globalFiltersApplied, globalFilterKeys, appliedGlobalFilters, sortFn, multi, items, path) {
|
|
79
|
+
/**
|
|
80
|
+
* useNormalizedItems just specifies if the data is hierarchical. the data structure
|
|
81
|
+
* is an object and not an array.
|
|
82
|
+
*/
|
|
83
|
+
if (useNormalizedItems) {
|
|
84
|
+
var itemIds = Object.keys(normalizedItems);
|
|
85
|
+
|
|
86
|
+
if (searchTerm || globalFiltersApplied) {
|
|
87
|
+
var results = itemIds.reduce(function (prev, cur) {
|
|
88
|
+
if (normalizedItems[cur].title.toLowerCase().includes(searchTerm)) {
|
|
89
|
+
prev.push(normalizedItems[cur]);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return prev;
|
|
93
|
+
}, []).filter(function (item) {
|
|
94
|
+
return globalFilterKeys.every(function (filter) {
|
|
95
|
+
return item[filter] === appliedGlobalFilters[filter];
|
|
96
|
+
});
|
|
97
|
+
}).sort(sortFn);
|
|
98
|
+
return results;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* multi select with hierarchy requires special consideration because columns
|
|
102
|
+
* are built recursively, so the items are just returned
|
|
103
|
+
*/
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
if (multi) {
|
|
107
|
+
return items;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* because single add select with hierarchy isn't recursively built the data
|
|
111
|
+
* structure has to be built around the path to maintain the folder structure
|
|
112
|
+
*/
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
if (path.length > 1) {
|
|
116
|
+
return path.reduce(function (prev, cur, curIdx) {
|
|
117
|
+
var _prev$find, _prev$find$children;
|
|
118
|
+
|
|
119
|
+
// because the root of the path never changes we can skip it
|
|
120
|
+
if (curIdx === 0) {
|
|
121
|
+
return prev;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
var item = (_prev$find = prev.find(function (item) {
|
|
125
|
+
return item.id === cur.id;
|
|
126
|
+
})) === 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;
|
|
127
|
+
return item;
|
|
128
|
+
}, items.entries);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return items.entries;
|
|
132
|
+
} else {
|
|
133
|
+
if (searchTerm) {
|
|
134
|
+
return items.entries.filter(function (item) {
|
|
135
|
+
return item.title.toLowerCase().includes(searchTerm);
|
|
136
|
+
});
|
|
137
|
+
}
|
|
111
138
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
})) === null || _items$find === void 0 ? void 0 : _items$find.sortBy;
|
|
139
|
+
return items.entries;
|
|
140
|
+
}
|
|
115
141
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
|
|
4
|
+
var useParentSelect = function useParentSelect() {
|
|
5
|
+
var _useState = useState(null),
|
|
6
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
7
|
+
parentSelected = _useState2[0],
|
|
8
|
+
setParentSelected = _useState2[1];
|
|
9
|
+
|
|
10
|
+
return {
|
|
11
|
+
parentSelected: parentSelected,
|
|
12
|
+
setParentSelected: setParentSelected
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default useParentSelect;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
|
+
|
|
5
|
+
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; }
|
|
6
|
+
|
|
7
|
+
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; }
|
|
8
|
+
|
|
9
|
+
import { useState } from 'react';
|
|
10
|
+
|
|
11
|
+
var usePath = function usePath() {
|
|
12
|
+
var itemsLabel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
13
|
+
|
|
14
|
+
var _useState = useState([{
|
|
15
|
+
id: 'base_of_path',
|
|
16
|
+
title: itemsLabel
|
|
17
|
+
}]),
|
|
18
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
19
|
+
path = _useState2[0],
|
|
20
|
+
setPath = _useState2[1];
|
|
21
|
+
|
|
22
|
+
var handler = function handler(id, title, parentId) {
|
|
23
|
+
if (path.find(function (entry) {
|
|
24
|
+
return entry.id === id;
|
|
25
|
+
})) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
var pathEntry = _objectSpread({
|
|
30
|
+
id: id,
|
|
31
|
+
title: title
|
|
32
|
+
}, parentId && {
|
|
33
|
+
parentId: parentId
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
if (path.find(function (entry) {
|
|
37
|
+
return entry.parentId === parentId;
|
|
38
|
+
})) {
|
|
39
|
+
var parentIdx = path.findIndex(function (entry) {
|
|
40
|
+
return entry.id === parentId;
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
var pathCopy = _toConsumableArray(path);
|
|
44
|
+
|
|
45
|
+
pathCopy.length = parentIdx + 1;
|
|
46
|
+
setPath([].concat(_toConsumableArray(pathCopy), [pathEntry]));
|
|
47
|
+
} else {
|
|
48
|
+
setPath([].concat(_toConsumableArray(path), [pathEntry]));
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
var pathClickHandler = function pathClickHandler(idx) {
|
|
53
|
+
var pathCopy = _toConsumableArray(path);
|
|
54
|
+
|
|
55
|
+
pathCopy.length = idx + 1;
|
|
56
|
+
setPath(_toConsumableArray(pathCopy));
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
path: path,
|
|
61
|
+
setPath: handler,
|
|
62
|
+
pathOnclick: pathClickHandler
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export default usePath;
|
|
@@ -89,7 +89,7 @@ export var Card = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
89
89
|
var getActions = function getActions() {
|
|
90
90
|
if (overflowActions.length > 0) {
|
|
91
91
|
var pos = actionsPlacement === 'top' ? 'bottom' : 'top';
|
|
92
|
-
var size = actionsPlacement === 'top' ? 'sm' : '
|
|
92
|
+
var size = actionsPlacement === 'top' ? 'sm' : 'md';
|
|
93
93
|
return /*#__PURE__*/React.createElement(OverflowMenu, {
|
|
94
94
|
size: size,
|
|
95
95
|
direction: pos,
|
|
@@ -189,11 +189,7 @@ export var MultiStepTearsheet = function MultiStepTearsheet(_ref2) {
|
|
|
189
189
|
},
|
|
190
190
|
invalid: isInvalid,
|
|
191
191
|
invalidText: "This is a required field",
|
|
192
|
-
onBlur: function onBlur() {
|
|
193
|
-
if (!stepOneTextInputValue.length) {
|
|
194
|
-
setIsInvalid(true);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
192
|
+
onBlur: function onBlur() {}
|
|
197
193
|
}), /*#__PURE__*/React.createElement(TextInput, {
|
|
198
194
|
labelText: "Topic description (optional)",
|
|
199
195
|
id: "tearsheet-multi-step-story-text-input-multi-step-1-input-2",
|
|
@@ -203,11 +203,7 @@ export var MultiStepWithIntro = function MultiStepWithIntro(_ref) {
|
|
|
203
203
|
},
|
|
204
204
|
invalid: isInvalid,
|
|
205
205
|
invalidText: "This is a required field",
|
|
206
|
-
onBlur: function onBlur() {
|
|
207
|
-
if (!stepOneTextInputValue.length) {
|
|
208
|
-
setIsInvalid(true);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
206
|
+
onBlur: function onBlur() {}
|
|
211
207
|
}), /*#__PURE__*/React.createElement(TextInput, {
|
|
212
208
|
labelText: "Topic description (optional)",
|
|
213
209
|
id: "tearsheet-multi-step-story-text-input-multi-step-1-input-2",
|