@carbon/ibm-products 1.19.0 → 1.20.1
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/draggableElement.css +57 -0
- package/css/components/Datagrid/styles/draggableElement.css.map +1 -0
- package/css/components/Datagrid/styles/index.css +100 -1
- package/css/components/Datagrid/styles/index.css.map +1 -1
- package/css/index-full-carbon.css +108 -2
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +2 -2
- 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 +108 -2
- 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 +108 -2
- package/css/index.css.map +1 -1
- package/css/index.min.css +2 -2
- 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 +3 -5
- package/es/components/CreateSidePanel/CreateSidePanel.js +4 -10
- package/es/components/Datagrid/Datagrid/DraggableElement.js +9 -12
- 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 +5 -8
- package/lib/components/CreateSidePanel/CreateSidePanel.js +3 -10
- package/lib/components/Datagrid/Datagrid/DraggableElement.js +11 -12
- 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/ComboButton/_combo-button.scss +2 -1
- package/scss/components/Datagrid/_datagrid.scss +1 -10
- package/scss/components/Datagrid/styles/datagrid.scss +17 -1
- package/scss/components/Datagrid/styles/draggableElement.scss +58 -0
- package/scss/components/Datagrid/styles/index.scss +2 -1
- package/scss/components/_index-released-only.scss +1 -0
@@ -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,
|
@@ -18,13 +18,11 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
18
18
|
* LICENSE file in the root directory of this source tree.
|
19
19
|
*/
|
20
20
|
import { ChevronDown16, ChevronUp16 } from '@carbon/icons-react';
|
21
|
-
import { Button, OverflowMenuItem } from 'carbon-components-react';
|
22
|
-
import { OverflowMenu } from 'carbon-components-react/lib/components/OverflowMenu/OverflowMenu';
|
23
|
-
import setupGetInstanceId from 'carbon-components-react/lib/tools/setupGetInstanceId';
|
21
|
+
import { Button, OverflowMenuItem, OverflowMenu } from 'carbon-components-react';
|
24
22
|
import classnames from 'classnames';
|
25
23
|
import { node, shape, string } from 'prop-types';
|
24
|
+
import uuidv4 from '../../global/js/utils/uuidv4';
|
26
25
|
import React, { Children, createElement, useRef, useState } from 'react';
|
27
|
-
var getInstanceId = setupGetInstanceId();
|
28
26
|
var blockClass = 'security--combo-button';
|
29
27
|
/**
|
30
28
|
* The combo button consolidates similar actions, while exposing the most commonly used one.
|
@@ -36,7 +34,7 @@ var ComboButton = function ComboButton(_ref) {
|
|
36
34
|
overflowMenu = _ref.overflowMenu,
|
37
35
|
rest = _objectWithoutProperties(_ref, _excluded);
|
38
36
|
|
39
|
-
var _useRef = useRef(
|
37
|
+
var _useRef = useRef(uuidv4()),
|
40
38
|
instanceId = _useRef.current;
|
41
39
|
|
42
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;
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
1
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
2
3
|
// @flow
|
3
4
|
|
@@ -13,10 +14,12 @@ import PropTypes from 'prop-types';
|
|
13
14
|
import { Draggable16 } from '@carbon/icons-react';
|
14
15
|
import { useDrag, useDrop } from 'react-dnd';
|
15
16
|
import cx from 'classnames';
|
17
|
+
import { pkg } from '../../../settings';
|
16
18
|
var useEffect = React.useEffect,
|
17
19
|
useRef = React.useRef,
|
18
20
|
useState = React.useState;
|
19
|
-
var
|
21
|
+
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
22
|
+
var DRAG_TYPE = "".concat(blockClass, "__shared-ui-draggable-element");
|
20
23
|
|
21
24
|
var DraggableElement = function DraggableElement(_ref) {
|
22
25
|
var id = _ref.id,
|
@@ -113,14 +116,10 @@ var DraggableElement = function DraggableElement(_ref) {
|
|
113
116
|
var content = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
114
117
|
className: cx({
|
115
118
|
disabled: disabled
|
116
|
-
},
|
119
|
+
}, "".concat(blockClass, "__draggable-handleStyle"))
|
117
120
|
}, /*#__PURE__*/React.createElement(Draggable16, null)), children);
|
118
121
|
return /*#__PURE__*/React.createElement("li", {
|
119
|
-
className: cx({
|
120
|
-
'wkc-draggable-handleHolder-isOver': isOver && !disabled
|
121
|
-
}, {
|
122
|
-
'wkc-draggable-handleHolder--grabbed': isGrabbed
|
123
|
-
}, 'wkc-draggable-handleHolder'),
|
122
|
+
className: cx(_defineProperty({}, "".concat(blockClass, "__draggable-handleHolder-isOver"), isOver && !disabled), _defineProperty({}, "".concat(blockClass, "__wkc-draggable-handleHolder--grabbed"), isGrabbed), "".concat(blockClass, "__draggable-handleHolder")),
|
124
123
|
ref: ref,
|
125
124
|
"aria-selected": isFocused,
|
126
125
|
role: "option",
|
@@ -148,17 +147,15 @@ var DraggableElement = function DraggableElement(_ref) {
|
|
148
147
|
setIsFocusedOnItem(e.currentTarget === e.target);
|
149
148
|
}
|
150
149
|
}, /*#__PURE__*/React.createElement("span", {
|
151
|
-
className: "
|
150
|
+
className: "".concat(blockClass, "__shared-ui--assistive-text")
|
152
151
|
}, ariaLabel), isDragging && !isOver ? /*#__PURE__*/React.createElement("div", {
|
153
152
|
ref: preview,
|
154
|
-
className: "
|
153
|
+
className: "${blockClass}__draggable-handleHolder-droppable"
|
155
154
|
}, content) : /*#__PURE__*/React.createElement("div", {
|
156
155
|
ref: drag,
|
157
156
|
"aria-hidden": isFocused && isFocusedOnItem // if focus on li, hide the children from aria
|
158
157
|
,
|
159
|
-
className: cx({
|
160
|
-
'wkc-draggable-handleStyle': !disabled
|
161
|
-
}, 'wkc-draggable-handleHolder-droppable')
|
158
|
+
className: cx(_defineProperty({}, "".concat(blockClass, "__draggable-handleStyle"), !disabled), ["".concat(blockClass, "__draggable-handleHolder-droppable")])
|
162
159
|
}, (!isOver || disabled) && content));
|
163
160
|
};
|
164
161
|
|
@@ -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,
|
@@ -27,11 +27,15 @@ var _excluded = ["meta", "icon", "avatar"];
|
|
27
27
|
var componentName = 'AddSelectSidebar';
|
28
28
|
|
29
29
|
var AddSelectSidebar = function AddSelectSidebar(_ref) {
|
30
|
-
var
|
30
|
+
var _modifiers$options;
|
31
|
+
|
32
|
+
var appliedModifiers = _ref.appliedModifiers,
|
33
|
+
closeIconDescription = _ref.closeIconDescription,
|
31
34
|
displayMetalPanel = _ref.displayMetalPanel,
|
32
35
|
influencerTitle = _ref.influencerTitle,
|
33
36
|
items = _ref.items,
|
34
37
|
metaPanelTitle = _ref.metaPanelTitle,
|
38
|
+
modifiers = _ref.modifiers,
|
35
39
|
multiSelection = _ref.multiSelection,
|
36
40
|
noSelectionDescription = _ref.noSelectionDescription,
|
37
41
|
noSelectionTitle = _ref.noSelectionTitle,
|
@@ -39,6 +43,8 @@ var AddSelectSidebar = function AddSelectSidebar(_ref) {
|
|
39
43
|
setDisplayMetaPanel = _ref.setDisplayMetaPanel,
|
40
44
|
setMultiSelection = _ref.setMultiSelection;
|
41
45
|
var blockClass = "".concat(_settings.pkg.prefix, "--add-select__sidebar");
|
46
|
+
var hasModifiers = (modifiers === null || modifiers === void 0 ? void 0 : (_modifiers$options = modifiers.options) === null || _modifiers$options === void 0 ? void 0 : _modifiers$options.length) > 0;
|
47
|
+
var hasSelections = multiSelection.length > 0;
|
42
48
|
|
43
49
|
var handleItemRemove = function handleItemRemove(id) {
|
44
50
|
var newSelections = multiSelection.filter(function (v) {
|
@@ -61,24 +67,23 @@ var AddSelectSidebar = function AddSelectSidebar(_ref) {
|
|
61
67
|
return acc;
|
62
68
|
}, []);
|
63
69
|
|
64
|
-
var getTitle = function getTitle(
|
65
|
-
var title = _ref2.title,
|
66
|
-
subtitle = _ref2.subtitle,
|
67
|
-
id = _ref2.id;
|
70
|
+
var getTitle = function getTitle(item) {
|
68
71
|
return /*#__PURE__*/_react.default.createElement("div", {
|
69
72
|
className: "".concat(blockClass, "-accordion-title")
|
70
73
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
71
74
|
className: "".concat(blockClass, "-selected-item")
|
72
75
|
}, /*#__PURE__*/_react.default.createElement("p", {
|
73
76
|
className: "".concat(blockClass, "-selected-item-title")
|
74
|
-
}, title), /*#__PURE__*/_react.default.createElement("p", {
|
77
|
+
}, item.title), /*#__PURE__*/_react.default.createElement("p", {
|
75
78
|
className: "".concat(blockClass, "-selected-item-subtitle")
|
76
|
-
}, subtitle)), /*#__PURE__*/_react.default.createElement(
|
79
|
+
}, item.subtitle)), hasModifiers && /*#__PURE__*/_react.default.createElement("div", null, appliedModifiers.find(function (modifier) {
|
80
|
+
return modifier.id === item.id;
|
81
|
+
})[modifiers.id]), /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, {
|
77
82
|
renderIcon: _iconsReact.SubtractAlt32,
|
78
83
|
iconDescription: removeIconDescription,
|
79
84
|
hasIconOnly: true,
|
80
85
|
onClick: function onClick() {
|
81
|
-
return handleItemRemove(id);
|
86
|
+
return handleItemRemove(item.id);
|
82
87
|
},
|
83
88
|
kind: "ghost",
|
84
89
|
className: "".concat(blockClass, "-item-remove-button"),
|
@@ -104,7 +109,7 @@ var AddSelectSidebar = function AddSelectSidebar(_ref) {
|
|
104
109
|
}, influencerTitle), /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Tag, {
|
105
110
|
type: "gray",
|
106
111
|
size: "sm"
|
107
|
-
}, multiSelection.length)),
|
112
|
+
}, multiSelection.length)), hasSelections ? /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Accordion, {
|
108
113
|
align: "start"
|
109
114
|
}, sidebarItems.map(function (item) {
|
110
115
|
return /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.AccordionItem, {
|
@@ -131,11 +136,13 @@ var AddSelectSidebar = function AddSelectSidebar(_ref) {
|
|
131
136
|
|
132
137
|
exports.AddSelectSidebar = AddSelectSidebar;
|
133
138
|
AddSelectSidebar.propTypes = {
|
139
|
+
appliedModifiers: _propTypes.default.array,
|
134
140
|
closeIconDescription: _propTypes.default.string,
|
135
141
|
displayMetalPanel: _propTypes.default.object,
|
136
142
|
influencerTitle: _propTypes.default.string,
|
137
143
|
items: _propTypes.default.array,
|
138
144
|
metaPanelTitle: _propTypes.default.string,
|
145
|
+
modifiers: _propTypes.default.object,
|
139
146
|
multiSelection: _propTypes.default.array,
|
140
147
|
noSelectionDescription: _propTypes.default.string,
|
141
148
|
noSelectionTitle: _propTypes.default.string,
|
@@ -23,14 +23,12 @@ var _iconsReact = require("@carbon/icons-react");
|
|
23
23
|
|
24
24
|
var _carbonComponentsReact = require("carbon-components-react");
|
25
25
|
|
26
|
-
var _OverflowMenu = require("carbon-components-react/lib/components/OverflowMenu/OverflowMenu");
|
27
|
-
|
28
|
-
var _setupGetInstanceId = _interopRequireDefault(require("carbon-components-react/lib/tools/setupGetInstanceId"));
|
29
|
-
|
30
26
|
var _classnames = _interopRequireDefault(require("classnames"));
|
31
27
|
|
32
28
|
var _propTypes = require("prop-types");
|
33
29
|
|
30
|
+
var _uuidv = _interopRequireDefault(require("../../global/js/utils/uuidv4"));
|
31
|
+
|
34
32
|
var _react = _interopRequireWildcard(require("react"));
|
35
33
|
|
36
34
|
var _excluded = ["children", "className", "overflowMenu"],
|
@@ -45,7 +43,6 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
45
43
|
|
46
44
|
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) { (0, _defineProperty2.default)(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; }
|
47
45
|
|
48
|
-
var getInstanceId = (0, _setupGetInstanceId.default)();
|
49
46
|
var blockClass = 'security--combo-button';
|
50
47
|
/**
|
51
48
|
* The combo button consolidates similar actions, while exposing the most commonly used one.
|
@@ -57,7 +54,7 @@ var ComboButton = function ComboButton(_ref) {
|
|
57
54
|
overflowMenu = _ref.overflowMenu,
|
58
55
|
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
59
56
|
|
60
|
-
var _useRef = (0, _react.useRef)(
|
57
|
+
var _useRef = (0, _react.useRef)((0, _uuidv.default)()),
|
61
58
|
instanceId = _useRef.current;
|
62
59
|
|
63
60
|
var _useState = (0, _react.useState)(false),
|
@@ -83,7 +80,7 @@ var ComboButton = function ComboButton(_ref) {
|
|
83
80
|
return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, rest, {
|
84
81
|
className: (0, _classnames.default)(blockClass, className),
|
85
82
|
"data-floating-menu-container": true
|
86
|
-
}), /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, primaryAction), restActions.length > 0 && /*#__PURE__*/_react.default.createElement(
|
83
|
+
}), /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, primaryAction), restActions.length > 0 && /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.OverflowMenu, (0, _extends2.default)({}, overflowMenu, {
|
87
84
|
className: "".concat(blockClass, "__overflow-menu"),
|
88
85
|
menuOptionsClass: "".concat(blockClass, "__overflow-menu__list"),
|
89
86
|
onClick: function onClick() {
|
@@ -121,5 +118,5 @@ ComboButton.propTypes = {
|
|
121
118
|
className: _propTypes.string,
|
122
119
|
|
123
120
|
/** Provide the [props of the `OverflowMenu`](https://react.carbondesignsystem.com/?path=/docs/overflowmenu) */
|
124
|
-
overflowMenu: (0, _propTypes.shape)(
|
121
|
+
overflowMenu: (0, _propTypes.shape)(_carbonComponentsReact.OverflowMenu.propTypes)
|
125
122
|
};
|
@@ -27,8 +27,6 @@ var _carbonComponentsReact = require("carbon-components-react");
|
|
27
27
|
|
28
28
|
var _SidePanel = require("../SidePanel");
|
29
29
|
|
30
|
-
var _ActionSet = require("../ActionSet");
|
31
|
-
|
32
30
|
var _excluded = ["className", "children", "disableSubmit", "formTitle", "formDescription", "onRequestClose", "onRequestSubmit", "open", "primaryButtonText", "secondaryButtonText", "selectorPageContent", "selectorPrimaryFocus", "subtitle", "title"];
|
33
31
|
|
34
32
|
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; }
|
@@ -37,7 +35,6 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
37
35
|
|
38
36
|
// The block part of our conventional BEM class names (blockClass__E--M).
|
39
37
|
var blockClass = "".concat(_settings.pkg.prefix, "--create-side-panel");
|
40
|
-
var sidePanelBlockClass = "".concat(_settings.pkg.prefix, "--side-panel");
|
41
38
|
var componentName = 'CreateSidePanel'; // NOTE: the component SCSS is not imported here: it is rolled up separately.
|
42
39
|
|
43
40
|
/**
|
@@ -74,7 +71,6 @@ var CreateSidePanel = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
74
71
|
onClick: onRequestClose,
|
75
72
|
kind: 'secondary'
|
76
73
|
}];
|
77
|
-
var actionContainerClassNames = (0, _classnames.default)(["".concat(blockClass, "__actions-container"), "".concat(sidePanelBlockClass, "__actions-container")]);
|
78
74
|
return selectorPageContent && /*#__PURE__*/_react.default.createElement(_SidePanel.SidePanel, (0, _extends2.default)({}, rest, _objectSpread({
|
79
75
|
open: open,
|
80
76
|
ref: ref,
|
@@ -88,18 +84,15 @@ var CreateSidePanel = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
88
84
|
slideIn: true,
|
89
85
|
animateTitle: false,
|
90
86
|
className: (0, _classnames.default)(blockClass, className),
|
91
|
-
size: "md"
|
87
|
+
size: "md",
|
88
|
+
actions: actions
|
92
89
|
}), /*#__PURE__*/_react.default.createElement("h3", {
|
93
90
|
className: "".concat(blockClass, "__form-title-text ").concat(blockClass, "__content-text")
|
94
91
|
}, formTitle), /*#__PURE__*/_react.default.createElement("p", {
|
95
92
|
className: "".concat(blockClass, "__form-description-text ").concat(blockClass, "__content-text")
|
96
93
|
}, formDescription), /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Form, {
|
97
94
|
className: "".concat(blockClass, "__form")
|
98
|
-
}, children
|
99
|
-
actions: actions,
|
100
|
-
className: actionContainerClassNames,
|
101
|
-
size: "md"
|
102
|
-
})));
|
95
|
+
}, children));
|
103
96
|
});
|
104
97
|
|
105
98
|
exports.CreateSidePanel = CreateSidePanel;
|