@carbon/ibm-products 1.19.1 → 1.20.2
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 +20 -1
- package/css/components/Datagrid/styles/datagrid.css.map +1 -1
- package/css/components/Datagrid/styles/index.css +20 -1
- package/css/components/Datagrid/styles/index.css.map +1 -1
- package/css/index-full-carbon.css +20 -1
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +1 -1
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +241 -0
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +7 -1
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +20 -1
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +1 -1
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +20 -1
- package/css/index.css.map +1 -1
- package/css/index.min.css +1 -1
- package/css/index.min.css.map +1 -1
- package/es/components/AddSelect/AddSelect.js +34 -3
- package/es/components/AddSelect/AddSelectList.js +33 -9
- package/es/components/AddSelect/AddSelectSidebar.js +16 -9
- package/es/components/ComboButton/ComboButton.js +2 -3
- package/es/components/CreateSidePanel/CreateSidePanel.js +4 -10
- package/es/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +2 -3
- package/es/components/EditSidePanel/EditSidePanel.js +3 -9
- package/es/components/SidePanel/SidePanel.js +2 -2
- package/es/components/index.js +1 -1
- package/es/global/js/package-settings.js +1 -1
- package/lib/components/AddSelect/AddSelect.js +34 -3
- package/lib/components/AddSelect/AddSelectList.js +32 -9
- package/lib/components/AddSelect/AddSelectSidebar.js +16 -9
- package/lib/components/ComboButton/ComboButton.js +3 -4
- package/lib/components/CreateSidePanel/CreateSidePanel.js +3 -10
- package/lib/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +1 -3
- package/lib/components/EditSidePanel/EditSidePanel.js +3 -10
- package/lib/components/SidePanel/SidePanel.js +2 -2
- package/lib/components/index.js +84 -0
- package/lib/global/js/package-settings.js +1 -1
- package/package.json +2 -2
- package/scss/components/Datagrid/styles/datagrid.scss +17 -1
- package/scss/components/_index-released-only.scss +1 -0
@@ -122,6 +122,11 @@ export var AddSelect = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
122
122
|
sortAttribute = _useItemSort.sortAttribute,
|
123
123
|
setSortAttribute = _useItemSort.setSortAttribute;
|
124
124
|
|
125
|
+
var _useState21 = useState([]),
|
126
|
+
_useState22 = _slicedToArray(_useState21, 2),
|
127
|
+
appliedModifiers = _useState22[0],
|
128
|
+
setAppliedModifiers = _useState22[1];
|
129
|
+
|
125
130
|
useEffect(function () {
|
126
131
|
var entries = items.entries; // flatItems is just a single array of all entries including children
|
127
132
|
|
@@ -131,6 +136,16 @@ export var AddSelect = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
131
136
|
if (globalFilters !== null && globalFilters !== void 0 && globalFilters.length) {
|
132
137
|
var globalFilterValues = getGlobalFilterValues(globalFilters, flattenedItems);
|
133
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);
|
134
149
|
} // multi select with nested data needs to be normalized
|
135
150
|
|
136
151
|
|
@@ -259,7 +274,18 @@ export var AddSelect = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
259
274
|
};
|
260
275
|
|
261
276
|
var submitHandler = function submitHandler() {
|
262
|
-
|
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
|
+
}
|
263
289
|
};
|
264
290
|
|
265
291
|
var classNames = cx(className, blockClass, (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__single"), !multi), _defineProperty(_cx, "".concat(blockClass, "__multi"), multi), _cx));
|
@@ -292,7 +318,9 @@ export var AddSelect = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
292
318
|
removeIconDescription: removeIconDescription,
|
293
319
|
setMultiSelection: setMultiSelection,
|
294
320
|
displayMetalPanel: displayMetalPanel,
|
295
|
-
setDisplayMetaPanel: setDisplayMetaPanel
|
321
|
+
setDisplayMetaPanel: setDisplayMetaPanel,
|
322
|
+
modifiers: items.modifiers,
|
323
|
+
appliedModifiers: appliedModifiers
|
296
324
|
};
|
297
325
|
|
298
326
|
var setShowBreadsCrumbs = function setShowBreadsCrumbs() {
|
@@ -375,7 +403,9 @@ export var AddSelect = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
375
403
|
}));
|
376
404
|
})) : /*#__PURE__*/React.createElement("div", null, hasResults ? /*#__PURE__*/React.createElement(AddSelectList, _extends({}, commonListProps, {
|
377
405
|
filteredItems: itemsToDisplay,
|
378
|
-
modifiers: items
|
406
|
+
modifiers: items.modifiers,
|
407
|
+
appliedModifiers: appliedModifiers,
|
408
|
+
setAppliedModifiers: setAppliedModifiers
|
379
409
|
})) : /*#__PURE__*/React.createElement("div", {
|
380
410
|
className: "".concat(blockClass, "__body")
|
381
411
|
}, /*#__PURE__*/React.createElement(NoDataEmptyState, {
|
@@ -409,6 +439,7 @@ AddSelect.propTypes = {
|
|
409
439
|
influencerTitle: PropTypes.string,
|
410
440
|
items: PropTypes.shape({
|
411
441
|
modifiers: PropTypes.shape({
|
442
|
+
id: PropTypes.string,
|
412
443
|
label: PropTypes.string,
|
413
444
|
options: PropTypes.array
|
414
445
|
}),
|
@@ -15,19 +15,24 @@ import { UserProfileImage } from '../UserProfileImage';
|
|
15
15
|
import { pkg } from '../../settings';
|
16
16
|
var componentName = 'AddSelectList';
|
17
17
|
export var AddSelectList = function AddSelectList(_ref) {
|
18
|
-
var
|
18
|
+
var _modifiers$options;
|
19
|
+
|
20
|
+
var appliedModifiers = _ref.appliedModifiers,
|
21
|
+
filteredItems = _ref.filteredItems,
|
19
22
|
metaIconDescription = _ref.metaIconDescription,
|
20
23
|
modifiers = _ref.modifiers,
|
21
24
|
multi = _ref.multi,
|
22
25
|
multiSelection = _ref.multiSelection,
|
23
26
|
navIconDescription = _ref.navIconDescription,
|
24
27
|
path = _ref.path,
|
28
|
+
setAppliedModifiers = _ref.setAppliedModifiers,
|
25
29
|
setDisplayMetaPanel = _ref.setDisplayMetaPanel,
|
26
30
|
setMultiSelection = _ref.setMultiSelection,
|
27
31
|
setPath = _ref.setPath,
|
28
32
|
setSingleSelection = _ref.setSingleSelection,
|
29
33
|
singleSelection = _ref.singleSelection;
|
30
34
|
var blockClass = "".concat(pkg.prefix, "--add-select__selections");
|
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;
|
31
36
|
|
32
37
|
var handleSingleSelection = function handleSingleSelection(value) {
|
33
38
|
setSingleSelection(value);
|
@@ -130,14 +135,24 @@ export var AddSelectList = function AddSelectList(_ref) {
|
|
130
135
|
return /*#__PURE__*/React.createElement(Icon, null);
|
131
136
|
};
|
132
137
|
|
138
|
+
var modifierHandler = function modifierHandler(id, selectedItem) {
|
139
|
+
var modifiersClone = _toConsumableArray(appliedModifiers);
|
140
|
+
|
141
|
+
var modifierIdx = modifiersClone.findIndex(function (item) {
|
142
|
+
return item.id === id;
|
143
|
+
});
|
144
|
+
modifiersClone[modifierIdx] = _defineProperty({
|
145
|
+
id: id
|
146
|
+
}, modifiers.id, selectedItem);
|
147
|
+
setAppliedModifiers(modifiersClone);
|
148
|
+
};
|
149
|
+
|
133
150
|
return /*#__PURE__*/React.createElement("div", {
|
134
151
|
className: "".concat(blockClass, "-wrapper")
|
135
152
|
}, /*#__PURE__*/React.createElement(StructuredListWrapper, {
|
136
153
|
selection: true,
|
137
154
|
className: "".concat(blockClass)
|
138
155
|
}, /*#__PURE__*/React.createElement(StructuredListBody, null, filteredItems.map(function (item) {
|
139
|
-
var _modifiers$options;
|
140
|
-
|
141
156
|
return /*#__PURE__*/React.createElement(StructuredListRow, {
|
142
157
|
key: item.id,
|
143
158
|
className: cx("".concat(blockClass, "-row"), _defineProperty({}, "".concat(blockClass, "-row-selected"), isSelected(item.id)))
|
@@ -165,22 +180,29 @@ export var AddSelectList = function AddSelectList(_ref) {
|
|
165
180
|
className: "".concat(blockClass, "-cell-title")
|
166
181
|
}, item.title), item.subtitle && /*#__PURE__*/React.createElement("span", {
|
167
182
|
className: "".concat(blockClass, "-cell-subtitle")
|
168
|
-
}, item.subtitle)))),
|
183
|
+
}, item.subtitle)))), hasModifiers && /*#__PURE__*/React.createElement(Dropdown, {
|
169
184
|
id: "".concat(item.id, "-modifier"),
|
170
185
|
type: "inline",
|
171
|
-
items: modifiers
|
186
|
+
items: modifiers.options,
|
172
187
|
light: true,
|
173
|
-
label: modifiers
|
188
|
+
label: modifiers.label,
|
174
189
|
disabled: !isSelected(item.id),
|
175
|
-
className: "".concat(blockClass, "-dropdown ").concat(blockClass, "-hidden-hover")
|
190
|
+
className: "".concat(blockClass, "-dropdown ").concat(blockClass, "-hidden-hover"),
|
191
|
+
initialSelectedItem: item[modifiers.id],
|
192
|
+
onChange: function onChange(_ref5) {
|
193
|
+
var selectedItem = _ref5.selectedItem;
|
194
|
+
return modifierHandler(item.id, selectedItem);
|
195
|
+
}
|
176
196
|
})) : /*#__PURE__*/React.createElement(RadioButton, {
|
177
197
|
className: "".concat(blockClass, "-radio"),
|
178
198
|
name: "add-select-selections",
|
179
199
|
id: item.id,
|
180
200
|
value: item.value,
|
181
201
|
labelText: item.title,
|
182
|
-
onChange:
|
183
|
-
|
202
|
+
onChange: function onChange() {
|
203
|
+
return handleSingleSelection(item.id);
|
204
|
+
},
|
205
|
+
selected: item.id === singleSelection
|
184
206
|
}), item.children && /*#__PURE__*/React.createElement(Button, {
|
185
207
|
renderIcon: ChevronRight16,
|
186
208
|
iconDescription: navIconDescription,
|
@@ -209,6 +231,7 @@ export var AddSelectList = function AddSelectList(_ref) {
|
|
209
231
|
}))));
|
210
232
|
};
|
211
233
|
AddSelectList.propTypes = {
|
234
|
+
appliedModifiers: PropTypes.array,
|
212
235
|
filteredItems: PropTypes.array,
|
213
236
|
metaIconDescription: PropTypes.string,
|
214
237
|
modifiers: PropTypes.object,
|
@@ -216,6 +239,7 @@ AddSelectList.propTypes = {
|
|
216
239
|
multiSelection: PropTypes.array,
|
217
240
|
navIconDescription: PropTypes.string,
|
218
241
|
path: PropTypes.array,
|
242
|
+
setAppliedModifiers: PropTypes.func,
|
219
243
|
setDisplayMetaPanel: PropTypes.func,
|
220
244
|
setMultiSelection: PropTypes.func,
|
221
245
|
setPath: PropTypes.func,
|
@@ -15,11 +15,15 @@ import { pkg } from '../../settings';
|
|
15
15
|
import { AddSelectMetaPanel } from './AddSelectMetaPanel';
|
16
16
|
var componentName = 'AddSelectSidebar';
|
17
17
|
export var AddSelectSidebar = function AddSelectSidebar(_ref) {
|
18
|
-
var
|
18
|
+
var _modifiers$options;
|
19
|
+
|
20
|
+
var appliedModifiers = _ref.appliedModifiers,
|
21
|
+
closeIconDescription = _ref.closeIconDescription,
|
19
22
|
displayMetalPanel = _ref.displayMetalPanel,
|
20
23
|
influencerTitle = _ref.influencerTitle,
|
21
24
|
items = _ref.items,
|
22
25
|
metaPanelTitle = _ref.metaPanelTitle,
|
26
|
+
modifiers = _ref.modifiers,
|
23
27
|
multiSelection = _ref.multiSelection,
|
24
28
|
noSelectionDescription = _ref.noSelectionDescription,
|
25
29
|
noSelectionTitle = _ref.noSelectionTitle,
|
@@ -27,6 +31,8 @@ export var AddSelectSidebar = function AddSelectSidebar(_ref) {
|
|
27
31
|
setDisplayMetaPanel = _ref.setDisplayMetaPanel,
|
28
32
|
setMultiSelection = _ref.setMultiSelection;
|
29
33
|
var blockClass = "".concat(pkg.prefix, "--add-select__sidebar");
|
34
|
+
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
|
+
var hasSelections = multiSelection.length > 0;
|
30
36
|
|
31
37
|
var handleItemRemove = function handleItemRemove(id) {
|
32
38
|
var newSelections = multiSelection.filter(function (v) {
|
@@ -50,24 +56,23 @@ export var AddSelectSidebar = function AddSelectSidebar(_ref) {
|
|
50
56
|
return acc;
|
51
57
|
}, []);
|
52
58
|
|
53
|
-
var getTitle = function getTitle(
|
54
|
-
var title = _ref2.title,
|
55
|
-
subtitle = _ref2.subtitle,
|
56
|
-
id = _ref2.id;
|
59
|
+
var getTitle = function getTitle(item) {
|
57
60
|
return /*#__PURE__*/React.createElement("div", {
|
58
61
|
className: "".concat(blockClass, "-accordion-title")
|
59
62
|
}, /*#__PURE__*/React.createElement("div", {
|
60
63
|
className: "".concat(blockClass, "-selected-item")
|
61
64
|
}, /*#__PURE__*/React.createElement("p", {
|
62
65
|
className: "".concat(blockClass, "-selected-item-title")
|
63
|
-
}, title), /*#__PURE__*/React.createElement("p", {
|
66
|
+
}, item.title), /*#__PURE__*/React.createElement("p", {
|
64
67
|
className: "".concat(blockClass, "-selected-item-subtitle")
|
65
|
-
}, subtitle)), /*#__PURE__*/React.createElement(
|
68
|
+
}, item.subtitle)), hasModifiers && /*#__PURE__*/React.createElement("div", null, appliedModifiers.find(function (modifier) {
|
69
|
+
return modifier.id === item.id;
|
70
|
+
})[modifiers.id]), /*#__PURE__*/React.createElement(Button, {
|
66
71
|
renderIcon: SubtractAlt32,
|
67
72
|
iconDescription: removeIconDescription,
|
68
73
|
hasIconOnly: true,
|
69
74
|
onClick: function onClick() {
|
70
|
-
return handleItemRemove(id);
|
75
|
+
return handleItemRemove(item.id);
|
71
76
|
},
|
72
77
|
kind: "ghost",
|
73
78
|
className: "".concat(blockClass, "-item-remove-button"),
|
@@ -93,7 +98,7 @@ export var AddSelectSidebar = function AddSelectSidebar(_ref) {
|
|
93
98
|
}, influencerTitle), /*#__PURE__*/React.createElement(Tag, {
|
94
99
|
type: "gray",
|
95
100
|
size: "sm"
|
96
|
-
}, multiSelection.length)),
|
101
|
+
}, multiSelection.length)), hasSelections ? /*#__PURE__*/React.createElement(Accordion, {
|
97
102
|
align: "start"
|
98
103
|
}, sidebarItems.map(function (item) {
|
99
104
|
return /*#__PURE__*/React.createElement(AccordionItem, {
|
@@ -118,11 +123,13 @@ export var AddSelectSidebar = function AddSelectSidebar(_ref) {
|
|
118
123
|
})));
|
119
124
|
};
|
120
125
|
AddSelectSidebar.propTypes = {
|
126
|
+
appliedModifiers: PropTypes.array,
|
121
127
|
closeIconDescription: PropTypes.string,
|
122
128
|
displayMetalPanel: PropTypes.object,
|
123
129
|
influencerTitle: PropTypes.string,
|
124
130
|
items: PropTypes.array,
|
125
131
|
metaPanelTitle: PropTypes.string,
|
132
|
+
modifiers: PropTypes.object,
|
126
133
|
multiSelection: PropTypes.array,
|
127
134
|
noSelectionDescription: PropTypes.string,
|
128
135
|
noSelectionTitle: PropTypes.string,
|
@@ -19,11 +19,10 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
19
19
|
*/
|
20
20
|
import { ChevronDown16, ChevronUp16 } from '@carbon/icons-react';
|
21
21
|
import { Button, OverflowMenuItem, OverflowMenu } from 'carbon-components-react';
|
22
|
-
import setupGetInstanceId from 'carbon-components-react/lib/tools/setupGetInstanceId';
|
23
22
|
import classnames from 'classnames';
|
24
23
|
import { node, shape, string } from 'prop-types';
|
24
|
+
import uuidv4 from '../../global/js/utils/uuidv4';
|
25
25
|
import React, { Children, createElement, useRef, useState } from 'react';
|
26
|
-
var getInstanceId = setupGetInstanceId();
|
27
26
|
var blockClass = 'security--combo-button';
|
28
27
|
/**
|
29
28
|
* The combo button consolidates similar actions, while exposing the most commonly used one.
|
@@ -35,7 +34,7 @@ var ComboButton = function ComboButton(_ref) {
|
|
35
34
|
overflowMenu = _ref.overflowMenu,
|
36
35
|
rest = _objectWithoutProperties(_ref, _excluded);
|
37
36
|
|
38
|
-
var _useRef = useRef(
|
37
|
+
var _useRef = useRef(uuidv4()),
|
39
38
|
instanceId = _useRef.current;
|
40
39
|
|
41
40
|
var _useState = useState(false),
|
@@ -22,11 +22,9 @@ import { pkg } from '../../settings';
|
|
22
22
|
import { getDevtoolsProps } from '../../global/js/utils/devtools'; // Carbon and package components we use.
|
23
23
|
|
24
24
|
import { Form } from 'carbon-components-react';
|
25
|
-
import { SidePanel } from '../SidePanel';
|
26
|
-
import { ActionSet } from '../ActionSet'; // The block part of our conventional BEM class names (blockClass__E--M).
|
25
|
+
import { SidePanel } from '../SidePanel'; // The block part of our conventional BEM class names (blockClass__E--M).
|
27
26
|
|
28
27
|
var blockClass = "".concat(pkg.prefix, "--create-side-panel");
|
29
|
-
var sidePanelBlockClass = "".concat(pkg.prefix, "--side-panel");
|
30
28
|
var componentName = 'CreateSidePanel'; // NOTE: the component SCSS is not imported here: it is rolled up separately.
|
31
29
|
|
32
30
|
/**
|
@@ -64,7 +62,6 @@ export var CreateSidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
64
62
|
onClick: onRequestClose,
|
65
63
|
kind: 'secondary'
|
66
64
|
}];
|
67
|
-
var actionContainerClassNames = cx(["".concat(blockClass, "__actions-container"), "".concat(sidePanelBlockClass, "__actions-container")]);
|
68
65
|
return selectorPageContent && /*#__PURE__*/React.createElement(SidePanel, _extends({}, rest, _objectSpread({
|
69
66
|
open: open,
|
70
67
|
ref: ref,
|
@@ -78,18 +75,15 @@ export var CreateSidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
78
75
|
slideIn: true,
|
79
76
|
animateTitle: false,
|
80
77
|
className: cx(blockClass, className),
|
81
|
-
size: "md"
|
78
|
+
size: "md",
|
79
|
+
actions: actions
|
82
80
|
}), /*#__PURE__*/React.createElement("h3", {
|
83
81
|
className: "".concat(blockClass, "__form-title-text ").concat(blockClass, "__content-text")
|
84
82
|
}, formTitle), /*#__PURE__*/React.createElement("p", {
|
85
83
|
className: "".concat(blockClass, "__form-description-text ").concat(blockClass, "__content-text")
|
86
84
|
}, formDescription), /*#__PURE__*/React.createElement(Form, {
|
87
85
|
className: "".concat(blockClass, "__form")
|
88
|
-
}, children
|
89
|
-
actions: actions,
|
90
|
-
className: actionContainerClassNames,
|
91
|
-
size: "md"
|
92
|
-
})));
|
86
|
+
}, children));
|
93
87
|
});
|
94
88
|
CreateSidePanel = pkg.checkComponentEnabled(CreateSidePanel, componentName);
|
95
89
|
CreateSidePanel.displayName = componentName;
|
@@ -13,8 +13,7 @@ var _excluded = ["onChange"];
|
|
13
13
|
// @flow
|
14
14
|
import React, { useEffect, useState } from 'react';
|
15
15
|
import PropTypes from 'prop-types';
|
16
|
-
import
|
17
|
-
import { OverflowMenu, OverflowMenuItem } from 'carbon-components-react';
|
16
|
+
import { OverflowMenu, OverflowMenuItem, Checkbox } from 'carbon-components-react';
|
18
17
|
import { CaretDown16 } from '@carbon/icons-react';
|
19
18
|
import { pkg } from '../../../settings'; // cspell:words columnheader
|
20
19
|
|
@@ -65,7 +64,7 @@ var SelectAllWithToggle = function SelectAllWithToggle(_ref) {
|
|
65
64
|
role: "columnheader",
|
66
65
|
scope: "col",
|
67
66
|
className: "".concat(blockClass, "__select-all-toggle-on")
|
68
|
-
}, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(
|
67
|
+
}, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(Checkbox, _extends({}, selectProps, {
|
69
68
|
name: "".concat(tableId, "-select-all-checkbox-name"),
|
70
69
|
onClick: function onClick(e) {
|
71
70
|
onChange(e);
|
@@ -25,11 +25,9 @@ import { pkg
|
|
25
25
|
|
26
26
|
import { Form } from 'carbon-components-react';
|
27
27
|
import { SidePanel } from '../SidePanel';
|
28
|
-
import { ActionSet } from '../ActionSet';
|
29
28
|
import '../../global/js/utils/props-helper'; // The block part of our conventional BEM class names (blockClass__E--M).
|
30
29
|
|
31
30
|
var blockClass = "".concat(pkg.prefix, "--edit-side-panel");
|
32
|
-
var sidePanelBlockClass = "".concat(pkg.prefix, "--side-panel");
|
33
31
|
var componentName = 'EditSidePanel'; // NOTE: the component SCSS is not imported here: it is rolled up separately.
|
34
32
|
// Default values for props
|
35
33
|
|
@@ -77,7 +75,6 @@ export var EditSidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
77
75
|
onClick: onRequestClose,
|
78
76
|
kind: 'secondary'
|
79
77
|
}];
|
80
|
-
var actionContainerClassNames = cx(["".concat(blockClass, "__actions-container"), "".concat(sidePanelBlockClass, "__actions-container")]);
|
81
78
|
return /*#__PURE__*/React.createElement(SidePanel, _extends({}, rest, _objectSpread({
|
82
79
|
open: open,
|
83
80
|
ref: ref,
|
@@ -92,18 +89,15 @@ export var EditSidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
92
89
|
animateTitle: false,
|
93
90
|
className: cx(blockClass, className),
|
94
91
|
size: size,
|
95
|
-
preventCloseOnClickOutside: true
|
92
|
+
preventCloseOnClickOutside: true,
|
93
|
+
actions: actions
|
96
94
|
}), formTitle && /*#__PURE__*/React.createElement("h3", {
|
97
95
|
className: "".concat(blockClass, "__form-title-text ").concat(blockClass, "__content-text")
|
98
96
|
}, formTitle), formDescription && /*#__PURE__*/React.createElement("p", {
|
99
97
|
className: "".concat(blockClass, "__form-description-text ").concat(blockClass, "__content-text")
|
100
98
|
}, formDescription), /*#__PURE__*/React.createElement(Form, {
|
101
99
|
className: "".concat(blockClass, "__form")
|
102
|
-
}, children
|
103
|
-
actions: actions,
|
104
|
-
className: actionContainerClassNames,
|
105
|
-
size: size
|
106
|
-
})));
|
100
|
+
}, children));
|
107
101
|
}); // Return a placeholder if not released and not enabled by feature flag
|
108
102
|
|
109
103
|
EditSidePanel = pkg.checkComponentEnabled(EditSidePanel, componentName); // The display name of the component, used by React. Note that displayName
|
@@ -49,7 +49,7 @@ var defaults = {
|
|
49
49
|
*/
|
50
50
|
|
51
51
|
export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
52
|
-
var _ref4, _cx4;
|
52
|
+
var _window, _ref4, _cx4;
|
53
53
|
|
54
54
|
var actionToolbarButtons = _ref.actionToolbarButtons,
|
55
55
|
actions = _ref.actions,
|
@@ -107,7 +107,7 @@ export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
107
107
|
size: size,
|
108
108
|
open: open
|
109
109
|
});
|
110
|
-
var reducedMotion = window && window.matchMedia ? window.matchMedia('(prefers-reduced-motion: reduce)') : {
|
110
|
+
var reducedMotion = typeof window !== 'undefined' && (_window = window) !== null && _window !== void 0 && _window.matchMedia ? window.matchMedia('(prefers-reduced-motion: reduce)') : {
|
111
111
|
matches: true
|
112
112
|
}; // scroll panel to top going between steps
|
113
113
|
|
package/es/components/index.js
CHANGED
@@ -37,4 +37,4 @@ export { EditSidePanel } from './EditSidePanel';
|
|
37
37
|
export { OptionsTile } from './OptionsTile';
|
38
38
|
export { InlineEdit } from './InlineEdit';
|
39
39
|
export { DataSpreadsheet } from './DataSpreadsheet';
|
40
|
-
export { Datagrid } from './Datagrid';
|
40
|
+
export { Datagrid, useDatagrid, useInfiniteScroll, useNestedRows, useSelectRows, useExpandedRow, useOnRowClick, useSortableColumns, useRowIsMouseOver, useColumnRightAlign, useDisableSelectRows, useStickyColumn, useActionsColumn, useCustomizeColumns, useSelectAllWithToggle } from './Datagrid';
|
@@ -35,6 +35,7 @@ var defaults = {
|
|
35
35
|
HTTPError404: true,
|
36
36
|
HTTPErrorOther: true,
|
37
37
|
ImportModal: true,
|
38
|
+
InlineEdit: true,
|
38
39
|
NotificationsPanel: true,
|
39
40
|
NoDataEmptyState: true,
|
40
41
|
NoTagsEmptyState: true,
|
@@ -63,7 +64,6 @@ var defaults = {
|
|
63
64
|
WebTerminalContentWrapper: false,
|
64
65
|
EditSidePanel: false,
|
65
66
|
CancelableTextEdit: false,
|
66
|
-
InlineEdit: false,
|
67
67
|
DataSpreadsheet: false,
|
68
68
|
Datagrid: false
|
69
69
|
/* new component flags here - comment used by generate CLI */
|
@@ -149,6 +149,11 @@ var AddSelect = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
149
149
|
sortAttribute = _useItemSort.sortAttribute,
|
150
150
|
setSortAttribute = _useItemSort.setSortAttribute;
|
151
151
|
|
152
|
+
var _useState21 = (0, _react.useState)([]),
|
153
|
+
_useState22 = (0, _slicedToArray2.default)(_useState21, 2),
|
154
|
+
appliedModifiers = _useState22[0],
|
155
|
+
setAppliedModifiers = _useState22[1];
|
156
|
+
|
152
157
|
(0, _react.useEffect)(function () {
|
153
158
|
var entries = items.entries; // flatItems is just a single array of all entries including children
|
154
159
|
|
@@ -158,6 +163,16 @@ var AddSelect = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
158
163
|
if (globalFilters !== null && globalFilters !== void 0 && globalFilters.length) {
|
159
164
|
var globalFilterValues = (0, _addSelectUtils.getGlobalFilterValues)(globalFilters, flattenedItems);
|
160
165
|
setGlobalFilterOpts(globalFilterValues);
|
166
|
+
}
|
167
|
+
|
168
|
+
if (items.modifiers) {
|
169
|
+
var modifiersToApply = flattenedItems.map(function (item) {
|
170
|
+
var modifierAttribute = items.modifiers.id;
|
171
|
+
return (0, _defineProperty2.default)({
|
172
|
+
id: item.id
|
173
|
+
}, modifierAttribute, item[modifierAttribute]);
|
174
|
+
});
|
175
|
+
setAppliedModifiers(modifiersToApply);
|
161
176
|
} // multi select with nested data needs to be normalized
|
162
177
|
|
163
178
|
|
@@ -286,7 +301,18 @@ var AddSelect = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
286
301
|
};
|
287
302
|
|
288
303
|
var submitHandler = function submitHandler() {
|
289
|
-
|
304
|
+
if (multi && appliedModifiers.length > 0) {
|
305
|
+
var selections = multiSelection.map(function (item) {
|
306
|
+
return appliedModifiers.find(function (mod) {
|
307
|
+
return mod.id === item;
|
308
|
+
});
|
309
|
+
});
|
310
|
+
onSubmit(selections);
|
311
|
+
} else if (multi && appliedModifiers.length === 0) {
|
312
|
+
onSubmit(multiSelection);
|
313
|
+
} else {
|
314
|
+
onSubmit(singleSelection);
|
315
|
+
}
|
290
316
|
};
|
291
317
|
|
292
318
|
var classNames = (0, _classnames.default)(className, blockClass, (_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__single"), !multi), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__multi"), multi), _cx));
|
@@ -319,7 +345,9 @@ var AddSelect = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
319
345
|
removeIconDescription: removeIconDescription,
|
320
346
|
setMultiSelection: setMultiSelection,
|
321
347
|
displayMetalPanel: displayMetalPanel,
|
322
|
-
setDisplayMetaPanel: setDisplayMetaPanel
|
348
|
+
setDisplayMetaPanel: setDisplayMetaPanel,
|
349
|
+
modifiers: items.modifiers,
|
350
|
+
appliedModifiers: appliedModifiers
|
323
351
|
};
|
324
352
|
|
325
353
|
var setShowBreadsCrumbs = function setShowBreadsCrumbs() {
|
@@ -402,7 +430,9 @@ var AddSelect = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
402
430
|
}));
|
403
431
|
})) : /*#__PURE__*/_react.default.createElement("div", null, hasResults ? /*#__PURE__*/_react.default.createElement(_AddSelectList.AddSelectList, (0, _extends2.default)({}, commonListProps, {
|
404
432
|
filteredItems: itemsToDisplay,
|
405
|
-
modifiers: items
|
433
|
+
modifiers: items.modifiers,
|
434
|
+
appliedModifiers: appliedModifiers,
|
435
|
+
setAppliedModifiers: setAppliedModifiers
|
406
436
|
})) : /*#__PURE__*/_react.default.createElement("div", {
|
407
437
|
className: "".concat(blockClass, "__body")
|
408
438
|
}, /*#__PURE__*/_react.default.createElement(_NoDataEmptyState.NoDataEmptyState, {
|
@@ -438,6 +468,7 @@ AddSelect.propTypes = {
|
|
438
468
|
influencerTitle: _propTypes.default.string,
|
439
469
|
items: _propTypes.default.shape({
|
440
470
|
modifiers: _propTypes.default.shape({
|
471
|
+
id: _propTypes.default.string,
|
441
472
|
label: _propTypes.default.string,
|
442
473
|
options: _propTypes.default.array
|
443
474
|
}),
|
@@ -34,19 +34,24 @@ var _settings = require("../../settings");
|
|
34
34
|
var componentName = 'AddSelectList';
|
35
35
|
|
36
36
|
var AddSelectList = function AddSelectList(_ref) {
|
37
|
-
var
|
37
|
+
var _modifiers$options;
|
38
|
+
|
39
|
+
var appliedModifiers = _ref.appliedModifiers,
|
40
|
+
filteredItems = _ref.filteredItems,
|
38
41
|
metaIconDescription = _ref.metaIconDescription,
|
39
42
|
modifiers = _ref.modifiers,
|
40
43
|
multi = _ref.multi,
|
41
44
|
multiSelection = _ref.multiSelection,
|
42
45
|
navIconDescription = _ref.navIconDescription,
|
43
46
|
path = _ref.path,
|
47
|
+
setAppliedModifiers = _ref.setAppliedModifiers,
|
44
48
|
setDisplayMetaPanel = _ref.setDisplayMetaPanel,
|
45
49
|
setMultiSelection = _ref.setMultiSelection,
|
46
50
|
setPath = _ref.setPath,
|
47
51
|
setSingleSelection = _ref.setSingleSelection,
|
48
52
|
singleSelection = _ref.singleSelection;
|
49
53
|
var blockClass = "".concat(_settings.pkg.prefix, "--add-select__selections");
|
54
|
+
var hasModifiers = (modifiers === null || modifiers === void 0 ? void 0 : (_modifiers$options = modifiers.options) === null || _modifiers$options === void 0 ? void 0 : _modifiers$options.length) > 0;
|
50
55
|
|
51
56
|
var handleSingleSelection = function handleSingleSelection(value) {
|
52
57
|
setSingleSelection(value);
|
@@ -147,14 +152,23 @@ var AddSelectList = function AddSelectList(_ref) {
|
|
147
152
|
return /*#__PURE__*/_react.default.createElement(Icon, null);
|
148
153
|
};
|
149
154
|
|
155
|
+
var modifierHandler = function modifierHandler(id, selectedItem) {
|
156
|
+
var modifiersClone = (0, _toConsumableArray2.default)(appliedModifiers);
|
157
|
+
var modifierIdx = modifiersClone.findIndex(function (item) {
|
158
|
+
return item.id === id;
|
159
|
+
});
|
160
|
+
modifiersClone[modifierIdx] = (0, _defineProperty2.default)({
|
161
|
+
id: id
|
162
|
+
}, modifiers.id, selectedItem);
|
163
|
+
setAppliedModifiers(modifiersClone);
|
164
|
+
};
|
165
|
+
|
150
166
|
return /*#__PURE__*/_react.default.createElement("div", {
|
151
167
|
className: "".concat(blockClass, "-wrapper")
|
152
168
|
}, /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.StructuredListWrapper, {
|
153
169
|
selection: true,
|
154
170
|
className: "".concat(blockClass)
|
155
171
|
}, /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.StructuredListBody, null, filteredItems.map(function (item) {
|
156
|
-
var _modifiers$options;
|
157
|
-
|
158
172
|
return /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.StructuredListRow, {
|
159
173
|
key: item.id,
|
160
174
|
className: (0, _classnames.default)("".concat(blockClass, "-row"), (0, _defineProperty2.default)({}, "".concat(blockClass, "-row-selected"), isSelected(item.id)))
|
@@ -182,22 +196,29 @@ var AddSelectList = function AddSelectList(_ref) {
|
|
182
196
|
className: "".concat(blockClass, "-cell-title")
|
183
197
|
}, item.title), item.subtitle && /*#__PURE__*/_react.default.createElement("span", {
|
184
198
|
className: "".concat(blockClass, "-cell-subtitle")
|
185
|
-
}, item.subtitle)))),
|
199
|
+
}, item.subtitle)))), hasModifiers && /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Dropdown, {
|
186
200
|
id: "".concat(item.id, "-modifier"),
|
187
201
|
type: "inline",
|
188
|
-
items: modifiers
|
202
|
+
items: modifiers.options,
|
189
203
|
light: true,
|
190
|
-
label: modifiers
|
204
|
+
label: modifiers.label,
|
191
205
|
disabled: !isSelected(item.id),
|
192
|
-
className: "".concat(blockClass, "-dropdown ").concat(blockClass, "-hidden-hover")
|
206
|
+
className: "".concat(blockClass, "-dropdown ").concat(blockClass, "-hidden-hover"),
|
207
|
+
initialSelectedItem: item[modifiers.id],
|
208
|
+
onChange: function onChange(_ref5) {
|
209
|
+
var selectedItem = _ref5.selectedItem;
|
210
|
+
return modifierHandler(item.id, selectedItem);
|
211
|
+
}
|
193
212
|
})) : /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.RadioButton, {
|
194
213
|
className: "".concat(blockClass, "-radio"),
|
195
214
|
name: "add-select-selections",
|
196
215
|
id: item.id,
|
197
216
|
value: item.value,
|
198
217
|
labelText: item.title,
|
199
|
-
onChange:
|
200
|
-
|
218
|
+
onChange: function onChange() {
|
219
|
+
return handleSingleSelection(item.id);
|
220
|
+
},
|
221
|
+
selected: item.id === singleSelection
|
201
222
|
}), item.children && /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, {
|
202
223
|
renderIcon: _iconsReact.ChevronRight16,
|
203
224
|
iconDescription: navIconDescription,
|
@@ -228,6 +249,7 @@ var AddSelectList = function AddSelectList(_ref) {
|
|
228
249
|
|
229
250
|
exports.AddSelectList = AddSelectList;
|
230
251
|
AddSelectList.propTypes = {
|
252
|
+
appliedModifiers: _propTypes.default.array,
|
231
253
|
filteredItems: _propTypes.default.array,
|
232
254
|
metaIconDescription: _propTypes.default.string,
|
233
255
|
modifiers: _propTypes.default.object,
|
@@ -235,6 +257,7 @@ AddSelectList.propTypes = {
|
|
235
257
|
multiSelection: _propTypes.default.array,
|
236
258
|
navIconDescription: _propTypes.default.string,
|
237
259
|
path: _propTypes.default.array,
|
260
|
+
setAppliedModifiers: _propTypes.default.func,
|
238
261
|
setDisplayMetaPanel: _propTypes.default.func,
|
239
262
|
setMultiSelection: _propTypes.default.func,
|
240
263
|
setPath: _propTypes.default.func,
|