@carbon/ibm-products 1.2.5 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +386 -186
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +2 -2
- package/css/index-without-carbon.css +163 -0
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +2 -2
- package/css/index.css +385 -0
- package/css/index.css.map +1 -1
- package/css/index.min.css +2 -2
- package/es/components/AddSelect/AddSelect.js +111 -0
- package/es/components/AddSelect/index.js +7 -0
- package/es/components/CancelableTextEdit/CancelableTextEdit.js +207 -0
- package/es/components/CancelableTextEdit/index.js +7 -0
- package/es/components/index.js +3 -1
- package/es/global/js/package-settings.js +3 -1
- package/lib/components/AddSelect/AddSelect.js +133 -0
- package/lib/components/AddSelect/index.js +13 -0
- package/lib/components/CancelableTextEdit/CancelableTextEdit.js +226 -0
- package/lib/components/CancelableTextEdit/index.js +13 -0
- package/lib/components/index.js +17 -1
- package/lib/global/js/package-settings.js +3 -1
- package/package.json +2 -2
- package/scss/components/AddSelect/_add-select.scss +73 -0
- package/scss/components/AddSelect/_index.scss +10 -0
- package/scss/components/AddSelect/_storybook-styles.scss +6 -0
- package/scss/components/CancelableTextEdit/_cancelable-text-edit.scss +140 -0
- package/scss/components/CancelableTextEdit/_index.scss +8 -0
- package/scss/components/CancelableTextEdit/_storybook-styles.scss +15 -0
- package/scss/components/_index.scss +2 -0
@@ -0,0 +1,111 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
4
|
+
var _excluded = ["actions", "className", "description", "influencerTitle", "inputPlaceholder", "items", "itemsLabel", "multiSelect", "noSelectionDescription", "noSelectionTitle", "open", "title"];
|
5
|
+
//
|
6
|
+
// Copyright IBM Corp. 2021
|
7
|
+
//
|
8
|
+
// This source code is licensed under the Apache-2.0 license found in the
|
9
|
+
// LICENSE file in the root directory of this source tree.
|
10
|
+
//
|
11
|
+
import React, { forwardRef, useState } from 'react';
|
12
|
+
import PropTypes from 'prop-types';
|
13
|
+
import cx from 'classnames';
|
14
|
+
import { StructuredListRow, StructuredListWrapper, StructuredListBody, StructuredListCell, // StructuredListInput,
|
15
|
+
TextInput, Tag } from 'carbon-components-react';
|
16
|
+
import { Tearsheet, TearsheetNarrow } from '../../components/Tearsheet';
|
17
|
+
import { NoDataEmptyState } from '../../components/EmptyStates/NoDataEmptyState';
|
18
|
+
import { pkg } from '../../settings';
|
19
|
+
var componentName = 'AddSelect';
|
20
|
+
export var AddSelect = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
21
|
+
var actions = _ref.actions,
|
22
|
+
className = _ref.className,
|
23
|
+
description = _ref.description,
|
24
|
+
influencerTitle = _ref.influencerTitle,
|
25
|
+
inputPlaceholder = _ref.inputPlaceholder,
|
26
|
+
items = _ref.items,
|
27
|
+
itemsLabel = _ref.itemsLabel,
|
28
|
+
multiSelect = _ref.multiSelect,
|
29
|
+
noSelectionDescription = _ref.noSelectionDescription,
|
30
|
+
noSelectionTitle = _ref.noSelectionTitle,
|
31
|
+
open = _ref.open,
|
32
|
+
title = _ref.title,
|
33
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
34
|
+
|
35
|
+
var blockClass = "".concat(pkg.prefix, "--add-select");
|
36
|
+
|
37
|
+
var _useState = useState(0),
|
38
|
+
_useState2 = _slicedToArray(_useState, 1),
|
39
|
+
selected = _useState2[0];
|
40
|
+
|
41
|
+
var commonTearsheetProps = {
|
42
|
+
open: open,
|
43
|
+
title: title,
|
44
|
+
actions: actions,
|
45
|
+
description: description,
|
46
|
+
closeIconDescription: 'temp description'
|
47
|
+
};
|
48
|
+
var influencer = /*#__PURE__*/React.createElement("div", {
|
49
|
+
className: "".concat(blockClass, "__influencer")
|
50
|
+
}, /*#__PURE__*/React.createElement("div", {
|
51
|
+
className: "".concat(blockClass, "__influencer-header")
|
52
|
+
}, /*#__PURE__*/React.createElement("p", {
|
53
|
+
className: "".concat(blockClass, "__influencer-title")
|
54
|
+
}, influencerTitle), /*#__PURE__*/React.createElement(Tag, {
|
55
|
+
type: "gray",
|
56
|
+
size: "sm"
|
57
|
+
}, selected)), /*#__PURE__*/React.createElement("div", {
|
58
|
+
className: "".concat(blockClass, "__influencer-body")
|
59
|
+
}, selected > 0 ? /*#__PURE__*/React.createElement("p", null, "content") : /*#__PURE__*/React.createElement(NoDataEmptyState, {
|
60
|
+
subtitle: noSelectionDescription,
|
61
|
+
title: noSelectionTitle,
|
62
|
+
size: "sm"
|
63
|
+
})));
|
64
|
+
var body = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
65
|
+
className: "".concat(blockClass, "__header")
|
66
|
+
}, /*#__PURE__*/React.createElement(TextInput, {
|
67
|
+
id: "temp-id",
|
68
|
+
labelText: "temp label",
|
69
|
+
placeholder: inputPlaceholder
|
70
|
+
}), /*#__PURE__*/React.createElement("div", {
|
71
|
+
className: "".concat(blockClass, "__items-label-container")
|
72
|
+
}, /*#__PURE__*/React.createElement("p", {
|
73
|
+
className: "".concat(blockClass, "__items-label")
|
74
|
+
}, itemsLabel), /*#__PURE__*/React.createElement(Tag, {
|
75
|
+
type: "gray",
|
76
|
+
size: "sm"
|
77
|
+
}, items.length))), /*#__PURE__*/React.createElement(StructuredListWrapper, {
|
78
|
+
selection: true,
|
79
|
+
className: "".concat(blockClass, "__selections")
|
80
|
+
}, /*#__PURE__*/React.createElement(StructuredListBody, null, items.map(function (item) {
|
81
|
+
return /*#__PURE__*/React.createElement(StructuredListRow, {
|
82
|
+
key: item.id
|
83
|
+
}, /*#__PURE__*/React.createElement(StructuredListCell, null, /*#__PURE__*/React.createElement("p", null, item.label)));
|
84
|
+
}))));
|
85
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
86
|
+
ref: ref,
|
87
|
+
className: cx(className, blockClass)
|
88
|
+
}, rest), multiSelect ? /*#__PURE__*/React.createElement(Tearsheet, _extends({}, commonTearsheetProps, {
|
89
|
+
influencer: multiSelect && influencer,
|
90
|
+
influencerPosition: "right"
|
91
|
+
}), body) : /*#__PURE__*/React.createElement(TearsheetNarrow, commonTearsheetProps, body));
|
92
|
+
});
|
93
|
+
AddSelect = pkg.checkComponentEnabled(AddSelect, componentName);
|
94
|
+
AddSelect.displayName = componentName;
|
95
|
+
AddSelect.propTypes = {
|
96
|
+
actions: PropTypes.array,
|
97
|
+
className: PropTypes.string,
|
98
|
+
description: PropTypes.string,
|
99
|
+
influencerTitle: PropTypes.string,
|
100
|
+
inputPlaceholder: PropTypes.string,
|
101
|
+
items: PropTypes.array,
|
102
|
+
itemsLabel: PropTypes.string,
|
103
|
+
multiSelect: PropTypes.bool,
|
104
|
+
noSelectionDescription: PropTypes.string,
|
105
|
+
noSelectionTitle: PropTypes.string,
|
106
|
+
open: PropTypes.bool,
|
107
|
+
title: PropTypes.string
|
108
|
+
};
|
109
|
+
AddSelect.defaultProps = {
|
110
|
+
items: []
|
111
|
+
};
|
@@ -0,0 +1,207 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
4
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
5
|
+
var _excluded = ["className", "inline", "invalid", "invalidText", "labelText", "onChange", "onInput", "revertLabel", "saveLabel", "value", "warn", "warnText"];
|
6
|
+
|
7
|
+
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; }
|
8
|
+
|
9
|
+
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; }
|
10
|
+
|
11
|
+
/**
|
12
|
+
* Copyright IBM Corp. 2021, 2021
|
13
|
+
*
|
14
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
15
|
+
* LICENSE file in the root directory of this source tree.
|
16
|
+
*/
|
17
|
+
// Import portions of React that are needed.
|
18
|
+
import React, { useEffect, useState } from 'react'; // Other standard imports.
|
19
|
+
|
20
|
+
import PropTypes from 'prop-types';
|
21
|
+
import cx from 'classnames';
|
22
|
+
import { Button, TextInput } from 'carbon-components-react';
|
23
|
+
import { prepareProps } from '../../global/js/utils/props-helper';
|
24
|
+
import { pkg, carbon } from '../../settings';
|
25
|
+
import { Checkmark16, Reset16 } from '@carbon/icons-react'; // Carbon and package components we use.
|
26
|
+
|
27
|
+
/* TODO: @import(s) of carbon components and other package components. */
|
28
|
+
// The block part of our conventional BEM class names (blockClass__E--M).
|
29
|
+
|
30
|
+
var blockClass = "".concat(pkg.prefix, "--cancelable-text-edit");
|
31
|
+
var componentName = 'CancelableTextEdit'; // NOTE: the component SCSS is not imported here: it is rolled up separately.
|
32
|
+
|
33
|
+
/**
|
34
|
+
* TODO: A description of the component.
|
35
|
+
*/
|
36
|
+
|
37
|
+
export var CancelableTextEdit = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
38
|
+
var _cx;
|
39
|
+
|
40
|
+
var className = _ref.className,
|
41
|
+
inline = _ref.inline,
|
42
|
+
invalid = _ref.invalid,
|
43
|
+
invalidText = _ref.invalidText,
|
44
|
+
labelText = _ref.labelText,
|
45
|
+
onChange = _ref.onChange,
|
46
|
+
onInput = _ref.onInput,
|
47
|
+
revertLabel = _ref.revertLabel,
|
48
|
+
saveLabel = _ref.saveLabel,
|
49
|
+
value = _ref.value,
|
50
|
+
warn = _ref.warn,
|
51
|
+
warnText = _ref.warnText,
|
52
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
53
|
+
|
54
|
+
// remove these props later
|
55
|
+
var removeProps = ['children', 'onInput', 'onChange', 'value'];
|
56
|
+
var showWarn = inline && warn && !invalid;
|
57
|
+
var showInvalid = inline && invalid;
|
58
|
+
|
59
|
+
var _useState = useState(value !== null && value !== void 0 ? value : ''),
|
60
|
+
_useState2 = _slicedToArray(_useState, 2),
|
61
|
+
liveValue = _useState2[0],
|
62
|
+
setLiveValue = _useState2[1];
|
63
|
+
|
64
|
+
useEffect(function () {
|
65
|
+
if (value !== liveValue) {
|
66
|
+
setLiveValue(value);
|
67
|
+
} // Do not care if liveValue changes here
|
68
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
69
|
+
|
70
|
+
}, [value]);
|
71
|
+
|
72
|
+
var doInput = function doInput(newValue) {
|
73
|
+
setLiveValue(newValue);
|
74
|
+
|
75
|
+
if (onInput) {
|
76
|
+
onInput(newValue);
|
77
|
+
}
|
78
|
+
};
|
79
|
+
|
80
|
+
var handleInput = function handleInput(ev) {
|
81
|
+
doInput(ev.target.value);
|
82
|
+
};
|
83
|
+
|
84
|
+
var handleRevert = function handleRevert() {
|
85
|
+
doInput(value);
|
86
|
+
};
|
87
|
+
|
88
|
+
var handleSave = function handleSave() {
|
89
|
+
if (onChange && !invalid) {
|
90
|
+
onChange(liveValue);
|
91
|
+
}
|
92
|
+
};
|
93
|
+
|
94
|
+
return /*#__PURE__*/React.createElement("div", {
|
95
|
+
className: cx(className, "".concat(blockClass), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "--invalid"), invalid), _defineProperty(_cx, "".concat(blockClass, "--warn"), warn), _cx))
|
96
|
+
}, /*#__PURE__*/React.createElement(TextInput, _extends({}, prepareProps(rest, removeProps), {
|
97
|
+
// it is not permitted to pass children down to TextInput guard against this
|
98
|
+
className: "".concat(blockClass, "__input"),
|
99
|
+
ref: ref,
|
100
|
+
onInput: handleInput,
|
101
|
+
value: liveValue !== null && liveValue !== void 0 ? liveValue : '' // ?? '' prevents controlled components test failure https://reactjs.org/docs/forms.html#controlled-components
|
102
|
+
,
|
103
|
+
inline: inline,
|
104
|
+
invalid: invalid,
|
105
|
+
invalidText: invalidText,
|
106
|
+
labelText: labelText,
|
107
|
+
warn: warn,
|
108
|
+
warnText: warnText
|
109
|
+
})), /*#__PURE__*/React.createElement("div", {
|
110
|
+
className: "".concat(blockClass, "__buttons")
|
111
|
+
}, !inline && labelText && /*#__PURE__*/React.createElement("div", {
|
112
|
+
className: "".concat(blockClass, "__label-spacer ").concat(carbon.prefix, "--label")
|
113
|
+
}, "\xA0"), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Button, {
|
114
|
+
className: "".concat(blockClass, "__revert ").concat(carbon.prefix, "--search-close"),
|
115
|
+
kind: "ghost",
|
116
|
+
hasIconOnly: true,
|
117
|
+
iconDescription: revertLabel,
|
118
|
+
onClick: handleRevert,
|
119
|
+
renderIcon: Reset16
|
120
|
+
}), /*#__PURE__*/React.createElement(Button, {
|
121
|
+
className: "".concat(blockClass, "__save ").concat(carbon.prefix, "--search-close"),
|
122
|
+
kind: "ghost",
|
123
|
+
hasIconOnly: true,
|
124
|
+
iconDescription: saveLabel,
|
125
|
+
onClick: handleSave,
|
126
|
+
renderIcon: Checkmark16,
|
127
|
+
disabled: invalid
|
128
|
+
}))), inline && (showInvalid || showWarn) && /*#__PURE__*/React.createElement("div", {
|
129
|
+
className: "".concat(carbon.prefix, "--form-requirement")
|
130
|
+
}, showInvalid ? invalidText : warnText));
|
131
|
+
}); // Return a placeholder if not released and not enabled by feature flag
|
132
|
+
|
133
|
+
CancelableTextEdit = pkg.checkComponentEnabled(CancelableTextEdit, componentName); // The display name of the component, used by React. Note that displayName
|
134
|
+
// is used in preference to relying on function.name.
|
135
|
+
|
136
|
+
CancelableTextEdit.displayName = componentName; // The types and DocGen commentary for the component props,
|
137
|
+
// in alphabetical order (for consistency).
|
138
|
+
// See https://www.npmjs.com/package/prop-types#usage.
|
139
|
+
|
140
|
+
CancelableTextEdit.propTypes = _objectSpread(_objectSpread({}, prepareProps(TextInput.propTypes, ['inline', 'invalid', 'invalidText', 'labelText', 'onChange', 'onInput', 'value', 'warn', 'warnText'])), {}, {
|
141
|
+
/**
|
142
|
+
* Provide an optional class to be applied to the containing node.
|
143
|
+
*/
|
144
|
+
className: PropTypes.string,
|
145
|
+
|
146
|
+
/**
|
147
|
+
* inline variant
|
148
|
+
*/
|
149
|
+
inline: PropTypes.bool,
|
150
|
+
|
151
|
+
/**
|
152
|
+
* show invalid for current value
|
153
|
+
*/
|
154
|
+
invalid: PropTypes.bool,
|
155
|
+
|
156
|
+
/**
|
157
|
+
* invalid text
|
158
|
+
*/
|
159
|
+
invalidText: PropTypes.string,
|
160
|
+
|
161
|
+
/**
|
162
|
+
* labelText for text input
|
163
|
+
*/
|
164
|
+
labelText: PropTypes.string,
|
165
|
+
|
166
|
+
/**
|
167
|
+
* method called on change event
|
168
|
+
*/
|
169
|
+
onChange: PropTypes.func,
|
170
|
+
|
171
|
+
/**
|
172
|
+
* method called on input event
|
173
|
+
*/
|
174
|
+
onInput: PropTypes.func,
|
175
|
+
|
176
|
+
/**
|
177
|
+
* label for revert button
|
178
|
+
*/
|
179
|
+
revertLabel: PropTypes.string.isRequired,
|
180
|
+
|
181
|
+
/**
|
182
|
+
* label for save button
|
183
|
+
*/
|
184
|
+
saveLabel: PropTypes.string.isRequired,
|
185
|
+
|
186
|
+
/**
|
187
|
+
* unedited value
|
188
|
+
*/
|
189
|
+
value: PropTypes.string,
|
190
|
+
|
191
|
+
/**
|
192
|
+
* show warning for current value
|
193
|
+
*/
|
194
|
+
warn: PropTypes.bool,
|
195
|
+
|
196
|
+
/**
|
197
|
+
* warn text
|
198
|
+
*/
|
199
|
+
warnText: PropTypes.string
|
200
|
+
}); // Default values for component props. Default values are not required for
|
201
|
+
// props that are required, nor for props where the component can apply
|
202
|
+
// 'undefined' values reasonably. Default values should be provided when the
|
203
|
+
// component needs to make a choice or assumption when a prop is not supplied.
|
204
|
+
|
205
|
+
CancelableTextEdit.defaultProps = {
|
206
|
+
/* TODO: add defaults for relevant props. */
|
207
|
+
};
|
package/es/components/index.js
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
// LICENSE file in the root directory of this source tree.
|
6
6
|
//
|
7
7
|
export { AboutModal } from './AboutModal';
|
8
|
+
export { AddSelect } from './AddSelect';
|
8
9
|
export { APIKeyModal } from './APIKeyModal';
|
9
10
|
export { Cascade } from './Cascade';
|
10
11
|
export { ComboButton, ComboButtonItem } from './ComboButton';
|
@@ -33,4 +34,5 @@ export { Toolbar, ToolbarButton, ToolbarGroup } from './Toolbar';
|
|
33
34
|
export { UserProfileImage } from './UserProfileImage';
|
34
35
|
export { WebTerminal } from './WebTerminal';
|
35
36
|
export { EditSidePanel } from './EditSidePanel';
|
36
|
-
export { OptionsTile } from './OptionsTile';
|
37
|
+
export { OptionsTile } from './OptionsTile';
|
38
|
+
export { CancelableTextEdit } from './CancelableTextEdit';
|
@@ -52,6 +52,7 @@ var defaults = {
|
|
52
52
|
UnauthorizedEmptyState: true,
|
53
53
|
UserProfileImage: true,
|
54
54
|
// other public components not yet reviewed and released:
|
55
|
+
AddSelect: false,
|
55
56
|
LoadingBar: false,
|
56
57
|
ModifiedTabs: false,
|
57
58
|
Toolbar: false,
|
@@ -59,7 +60,8 @@ var defaults = {
|
|
59
60
|
ToolbarGroup: false,
|
60
61
|
WebTerminal: false,
|
61
62
|
EditSidePanel: false,
|
62
|
-
OptionsTile: false
|
63
|
+
OptionsTile: false,
|
64
|
+
CancelableTextEdit: false
|
63
65
|
/* new component flags here - comment used by generate CLI */
|
64
66
|
|
65
67
|
},
|
@@ -0,0 +1,133 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
6
|
+
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
8
|
+
value: true
|
9
|
+
});
|
10
|
+
exports.AddSelect = void 0;
|
11
|
+
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
13
|
+
|
14
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
15
|
+
|
16
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
17
|
+
|
18
|
+
var _react = _interopRequireWildcard(require("react"));
|
19
|
+
|
20
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
21
|
+
|
22
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
23
|
+
|
24
|
+
var _carbonComponentsReact = require("carbon-components-react");
|
25
|
+
|
26
|
+
var _Tearsheet = require("../../components/Tearsheet");
|
27
|
+
|
28
|
+
var _NoDataEmptyState = require("../../components/EmptyStates/NoDataEmptyState");
|
29
|
+
|
30
|
+
var _settings = require("../../settings");
|
31
|
+
|
32
|
+
var _excluded = ["actions", "className", "description", "influencerTitle", "inputPlaceholder", "items", "itemsLabel", "multiSelect", "noSelectionDescription", "noSelectionTitle", "open", "title"];
|
33
|
+
|
34
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
35
|
+
|
36
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
37
|
+
|
38
|
+
var componentName = 'AddSelect';
|
39
|
+
var AddSelect = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
40
|
+
var actions = _ref.actions,
|
41
|
+
className = _ref.className,
|
42
|
+
description = _ref.description,
|
43
|
+
influencerTitle = _ref.influencerTitle,
|
44
|
+
inputPlaceholder = _ref.inputPlaceholder,
|
45
|
+
items = _ref.items,
|
46
|
+
itemsLabel = _ref.itemsLabel,
|
47
|
+
multiSelect = _ref.multiSelect,
|
48
|
+
noSelectionDescription = _ref.noSelectionDescription,
|
49
|
+
noSelectionTitle = _ref.noSelectionTitle,
|
50
|
+
open = _ref.open,
|
51
|
+
title = _ref.title,
|
52
|
+
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
53
|
+
var blockClass = "".concat(_settings.pkg.prefix, "--add-select");
|
54
|
+
|
55
|
+
var _useState = (0, _react.useState)(0),
|
56
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 1),
|
57
|
+
selected = _useState2[0];
|
58
|
+
|
59
|
+
var commonTearsheetProps = {
|
60
|
+
open: open,
|
61
|
+
title: title,
|
62
|
+
actions: actions,
|
63
|
+
description: description,
|
64
|
+
closeIconDescription: 'temp description'
|
65
|
+
};
|
66
|
+
|
67
|
+
var influencer = /*#__PURE__*/_react.default.createElement("div", {
|
68
|
+
className: "".concat(blockClass, "__influencer")
|
69
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
70
|
+
className: "".concat(blockClass, "__influencer-header")
|
71
|
+
}, /*#__PURE__*/_react.default.createElement("p", {
|
72
|
+
className: "".concat(blockClass, "__influencer-title")
|
73
|
+
}, influencerTitle), /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Tag, {
|
74
|
+
type: "gray",
|
75
|
+
size: "sm"
|
76
|
+
}, selected)), /*#__PURE__*/_react.default.createElement("div", {
|
77
|
+
className: "".concat(blockClass, "__influencer-body")
|
78
|
+
}, selected > 0 ? /*#__PURE__*/_react.default.createElement("p", null, "content") : /*#__PURE__*/_react.default.createElement(_NoDataEmptyState.NoDataEmptyState, {
|
79
|
+
subtitle: noSelectionDescription,
|
80
|
+
title: noSelectionTitle,
|
81
|
+
size: "sm"
|
82
|
+
})));
|
83
|
+
|
84
|
+
var body = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
85
|
+
className: "".concat(blockClass, "__header")
|
86
|
+
}, /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.TextInput, {
|
87
|
+
id: "temp-id",
|
88
|
+
labelText: "temp label",
|
89
|
+
placeholder: inputPlaceholder
|
90
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
91
|
+
className: "".concat(blockClass, "__items-label-container")
|
92
|
+
}, /*#__PURE__*/_react.default.createElement("p", {
|
93
|
+
className: "".concat(blockClass, "__items-label")
|
94
|
+
}, itemsLabel), /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Tag, {
|
95
|
+
type: "gray",
|
96
|
+
size: "sm"
|
97
|
+
}, items.length))), /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.StructuredListWrapper, {
|
98
|
+
selection: true,
|
99
|
+
className: "".concat(blockClass, "__selections")
|
100
|
+
}, /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.StructuredListBody, null, items.map(function (item) {
|
101
|
+
return /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.StructuredListRow, {
|
102
|
+
key: item.id
|
103
|
+
}, /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.StructuredListCell, null, /*#__PURE__*/_react.default.createElement("p", null, item.label)));
|
104
|
+
}))));
|
105
|
+
|
106
|
+
return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
|
107
|
+
ref: ref,
|
108
|
+
className: (0, _classnames.default)(className, blockClass)
|
109
|
+
}, rest), multiSelect ? /*#__PURE__*/_react.default.createElement(_Tearsheet.Tearsheet, (0, _extends2.default)({}, commonTearsheetProps, {
|
110
|
+
influencer: multiSelect && influencer,
|
111
|
+
influencerPosition: "right"
|
112
|
+
}), body) : /*#__PURE__*/_react.default.createElement(_Tearsheet.TearsheetNarrow, commonTearsheetProps, body));
|
113
|
+
});
|
114
|
+
exports.AddSelect = AddSelect;
|
115
|
+
exports.AddSelect = AddSelect = _settings.pkg.checkComponentEnabled(AddSelect, componentName);
|
116
|
+
AddSelect.displayName = componentName;
|
117
|
+
AddSelect.propTypes = {
|
118
|
+
actions: _propTypes.default.array,
|
119
|
+
className: _propTypes.default.string,
|
120
|
+
description: _propTypes.default.string,
|
121
|
+
influencerTitle: _propTypes.default.string,
|
122
|
+
inputPlaceholder: _propTypes.default.string,
|
123
|
+
items: _propTypes.default.array,
|
124
|
+
itemsLabel: _propTypes.default.string,
|
125
|
+
multiSelect: _propTypes.default.bool,
|
126
|
+
noSelectionDescription: _propTypes.default.string,
|
127
|
+
noSelectionTitle: _propTypes.default.string,
|
128
|
+
open: _propTypes.default.bool,
|
129
|
+
title: _propTypes.default.string
|
130
|
+
};
|
131
|
+
AddSelect.defaultProps = {
|
132
|
+
items: []
|
133
|
+
};
|
@@ -0,0 +1,13 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
Object.defineProperty(exports, "AddSelect", {
|
7
|
+
enumerable: true,
|
8
|
+
get: function get() {
|
9
|
+
return _AddSelect.AddSelect;
|
10
|
+
}
|
11
|
+
});
|
12
|
+
|
13
|
+
var _AddSelect = require("./AddSelect");
|