@carbon/ibm-products 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +1766 -1701
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +2 -2
- package/css/index-without-carbon-released-only.css +32 -41
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +2 -2
- package/css/index-without-carbon.css +228 -163
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +2 -2
- package/css/index.css +1767 -1702
- package/css/index.css.map +1 -1
- package/css/index.min.css +2 -2
- package/es/components/APIKeyModal/APIKeyModal.js +25 -29
- package/es/components/ActionBar/ActionBar.js +4 -1
- package/es/components/AddSelect/AddSelect.js +65 -19
- package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +19 -15
- package/es/components/CancelableTextEdit/CancelableTextEdit.js +60 -22
- package/es/components/CreateFullPage/CreateFullPage.js +78 -259
- package/es/components/CreateFullPage/CreateFullPageStep.js +58 -14
- package/es/components/CreateFullPage/index.js +1 -2
- package/es/components/CreateInfluencer/CreateInfluencer.js +23 -225
- package/es/components/CreateTearsheet/CreateTearsheet.js +69 -146
- package/es/components/CreateTearsheet/CreateTearsheetStep.js +59 -16
- package/es/components/CreateTearsheet/index.js +0 -1
- package/es/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +66 -27
- package/es/components/ExportModal/ExportModal.js +4 -2
- package/es/components/ImportModal/ImportModal.js +2 -1
- package/es/components/InlineEdit/InlineEdit.js +224 -0
- package/es/components/InlineEdit/index.js +7 -0
- package/es/components/MultiAddSelect/MultiAddSelect.js +16 -0
- package/es/components/MultiAddSelect/index.js +1 -0
- package/es/components/OptionsTile/OptionsTile.js +36 -15
- package/es/components/PageHeader/PageHeader.js +54 -33
- package/es/components/PageHeader/PageHeaderTitle.js +78 -7
- package/es/components/PageHeader/PageHeaderUtils.js +21 -2
- package/es/components/RemoveModal/RemoveModal.js +4 -2
- package/es/components/SingleAddSelect/SingleAddSelect.js +15 -0
- package/es/components/SingleAddSelect/index.js +1 -0
- package/es/components/TagSet/TagSet.js +4 -1
- package/es/components/Toolbar/Toolbar.js +69 -8
- package/es/components/index.js +4 -2
- package/es/global/js/hooks/useCreateComponentFocus.js +15 -19
- package/es/global/js/hooks/useCreateComponentStepChange.js +44 -74
- package/es/global/js/hooks/useValidCreateStepCount.js +4 -7
- package/es/global/js/package-settings.js +4 -2
- package/lib/components/APIKeyModal/APIKeyModal.js +25 -29
- package/lib/components/ActionBar/ActionBar.js +4 -1
- package/lib/components/AddSelect/AddSelect.js +64 -19
- package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +18 -14
- package/lib/components/CancelableTextEdit/CancelableTextEdit.js +61 -22
- package/lib/components/CreateFullPage/CreateFullPage.js +78 -259
- package/lib/components/CreateFullPage/CreateFullPageStep.js +61 -14
- package/lib/components/CreateFullPage/index.js +1 -9
- package/lib/components/CreateInfluencer/CreateInfluencer.js +21 -236
- package/lib/components/CreateTearsheet/CreateTearsheet.js +71 -148
- package/lib/components/CreateTearsheet/CreateTearsheetStep.js +61 -15
- package/lib/components/CreateTearsheet/index.js +0 -8
- package/lib/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +67 -35
- package/lib/components/ExportModal/ExportModal.js +4 -2
- package/lib/components/ImportModal/ImportModal.js +2 -1
- package/lib/components/InlineEdit/InlineEdit.js +242 -0
- package/lib/components/InlineEdit/index.js +13 -0
- package/lib/components/MultiAddSelect/MultiAddSelect.js +37 -0
- package/lib/components/MultiAddSelect/index.js +13 -0
- package/lib/components/OptionsTile/OptionsTile.js +36 -15
- package/lib/components/PageHeader/PageHeader.js +54 -33
- package/lib/components/PageHeader/PageHeaderTitle.js +87 -9
- package/lib/components/PageHeader/PageHeaderUtils.js +21 -2
- package/lib/components/RemoveModal/RemoveModal.js +4 -2
- package/lib/components/SingleAddSelect/SingleAddSelect.js +36 -0
- package/lib/components/SingleAddSelect/index.js +13 -0
- package/lib/components/TagSet/TagSet.js +4 -1
- package/lib/components/Toolbar/Toolbar.js +69 -6
- package/lib/components/index.js +25 -9
- package/lib/global/js/hooks/useCreateComponentFocus.js +15 -19
- package/lib/global/js/hooks/useCreateComponentStepChange.js +44 -74
- package/lib/global/js/hooks/useValidCreateStepCount.js +4 -7
- package/lib/global/js/package-settings.js +4 -2
- package/package.json +8 -8
- package/scss/components/AddSelect/_add-select.scss +14 -3
- package/scss/components/BreadcrumbWithOverflow/_breadcrumb-with-overflow.scss +19 -15
- package/scss/components/CancelableTextEdit/_cancelable-text-edit.scss +141 -70
- package/scss/components/CreateFullPage/_create-full-page.scss +4 -11
- package/scss/components/CreateTearsheet/_create-tearsheet.scss +4 -8
- package/scss/components/InlineEdit/_index.scss +8 -0
- package/scss/components/InlineEdit/_inline-edit.scss +44 -0
- package/scss/components/InlineEdit/_storybook-styles.scss +15 -0
- package/scss/components/MultiAddSelect/_index.scss +1 -0
- package/scss/components/MultiAddSelect/_multi-add-select.scss +1 -0
- package/scss/components/MultiAddSelect/_storybook-styles.scss +6 -0
- package/scss/components/PageHeader/_page-header.scss +14 -4
- package/scss/components/SingleAddSelect/_index.scss +1 -0
- package/scss/components/SingleAddSelect/_single-add-select.scss +1 -0
- package/scss/components/SingleAddSelect/_storybook-styles.scss +6 -0
- package/scss/components/_index.scss +3 -1
- package/es/components/CreateFullPage/CreateFullPageSection.js +0 -53
- package/es/components/CreateFullPage/constants.js +0 -8
- package/es/components/CreateTearsheet/CreateTearsheetSection.js +0 -83
- package/es/components/CreateTearsheet/constants.js +0 -8
- package/es/components/CreateTearsheet/preview-components/MultiStepWithSectionsTearsheet.js +0 -327
- package/es/global/js/utils/hasValidType.js +0 -94
- package/lib/components/CreateFullPage/CreateFullPageSection.js +0 -74
- package/lib/components/CreateFullPage/constants.js +0 -16
- package/lib/components/CreateTearsheet/CreateTearsheetSection.js +0 -105
- package/lib/components/CreateTearsheet/constants.js +0 -17
- package/lib/components/CreateTearsheet/preview-components/MultiStepWithSectionsTearsheet.js +0 -354
- package/lib/global/js/utils/hasValidType.js +0 -110
@@ -1,44 +1,94 @@
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
3
|
+
|
1
4
|
/**
|
2
5
|
* Copyright IBM Corp. 2021, 2021
|
3
6
|
*
|
4
7
|
* This source code is licensed under the Apache-2.0 license found in the
|
5
8
|
* LICENSE file in the root directory of this source tree.
|
6
9
|
*/
|
7
|
-
import React, { forwardRef } from 'react';
|
10
|
+
import React, { forwardRef, useContext, useEffect } from 'react';
|
8
11
|
import PropTypes from 'prop-types';
|
9
12
|
import cx from 'classnames';
|
10
13
|
import { Column, FormGroup, Row } from 'carbon-components-react';
|
14
|
+
import { StepsContext, StepNumberContext } from './CreateTearsheet';
|
11
15
|
import { pkg } from '../../settings';
|
12
|
-
import
|
16
|
+
import pconsole from '../../global/js/utils/pconsole';
|
17
|
+
import { usePreviousValue } from '../../global/js/hooks';
|
13
18
|
var componentName = 'CreateTearsheetStep';
|
14
19
|
var blockClass = "".concat(pkg.prefix, "--tearsheet-create__step");
|
15
20
|
export var CreateTearsheetStep = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
21
|
+
var _cx;
|
22
|
+
|
16
23
|
var children = _ref.children,
|
17
24
|
className = _ref.className,
|
18
25
|
subtitle = _ref.subtitle,
|
19
26
|
description = _ref.description,
|
27
|
+
disableSubmit = _ref.disableSubmit,
|
28
|
+
introStep = _ref.introStep,
|
20
29
|
title = _ref.title,
|
21
30
|
hasFieldset = _ref.hasFieldset,
|
22
31
|
fieldsetLegendText = _ref.fieldsetLegendText,
|
23
|
-
|
24
|
-
|
25
|
-
|
32
|
+
onNext = _ref.onNext,
|
33
|
+
onMount = _ref.onMount,
|
34
|
+
secondaryLabel = _ref.secondaryLabel;
|
35
|
+
var steps = useContext(StepsContext);
|
36
|
+
var stepNumber = useContext(StepNumberContext);
|
37
|
+
var previousState = usePreviousValue({
|
38
|
+
currentStep: steps === null || steps === void 0 ? void 0 : steps.currentStep
|
39
|
+
}); // This useEffect reports back the onNext and onMount values so that they can be used
|
40
|
+
// in the appropriate custom hooks.
|
41
|
+
|
42
|
+
useEffect(function () {
|
43
|
+
if (stepNumber === (steps === null || steps === void 0 ? void 0 : steps.currentStep) && (previousState === null || previousState === void 0 ? void 0 : previousState.currentStep) !== (steps === null || steps === void 0 ? void 0 : steps.currentStep)) {
|
44
|
+
steps === null || steps === void 0 ? void 0 : steps.setOnNext(onNext);
|
45
|
+
steps === null || steps === void 0 ? void 0 : steps.setOnMount(onMount);
|
46
|
+
}
|
47
|
+
}, [onMount, onNext, steps, stepNumber, previousState === null || previousState === void 0 ? void 0 : previousState.currentStep]); // This useEffect makes sure that every CreateTearsheetStep reports back it's
|
48
|
+
// title, secondaryLabel, and introStep props so that it can be sent to the CreateInfluencer.
|
49
|
+
|
50
|
+
useEffect(function () {
|
51
|
+
var _steps$stepData, _steps$stepData2;
|
52
|
+
|
53
|
+
var stepHasReported = steps === null || steps === void 0 ? void 0 : (_steps$stepData = steps.stepData) === null || _steps$stepData === void 0 ? void 0 : _steps$stepData.includes(function (item) {
|
54
|
+
return item.title === title;
|
55
|
+
});
|
56
|
+
|
57
|
+
if (!stepHasReported && (steps === null || steps === void 0 ? void 0 : (_steps$stepData2 = steps.stepData) === null || _steps$stepData2 === void 0 ? void 0 : _steps$stepData2.length) < (steps === null || steps === void 0 ? void 0 : steps.totalStepCount)) {
|
58
|
+
steps === null || steps === void 0 ? void 0 : steps.setStepData(function (prev) {
|
59
|
+
return [].concat(_toConsumableArray(prev), [{
|
60
|
+
title: title,
|
61
|
+
secondaryLabel: secondaryLabel,
|
62
|
+
introStep: introStep
|
63
|
+
}]);
|
64
|
+
});
|
65
|
+
}
|
66
|
+
}, [steps, title, secondaryLabel, introStep]); // Whenever we are the current step, supply our disableSubmit value to the
|
67
|
+
// steps container context so that it can manage the 'Next' button appropriately.
|
68
|
+
|
69
|
+
useEffect(function () {
|
70
|
+
if (stepNumber === (steps === null || steps === void 0 ? void 0 : steps.currentStep)) {
|
71
|
+
steps.setIsDisabled(disableSubmit);
|
72
|
+
}
|
73
|
+
}, [steps, stepNumber, disableSubmit, onNext]);
|
74
|
+
return steps ? /*#__PURE__*/React.createElement("div", {
|
75
|
+
className: cx(blockClass, className, (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__step--hidden-step"), stepNumber !== (steps === null || steps === void 0 ? void 0 : steps.currentStep)), _defineProperty(_cx, "".concat(blockClass, "__step--visible-step"), stepNumber === (steps === null || steps === void 0 ? void 0 : steps.currentStep)), _cx)),
|
26
76
|
ref: ref
|
27
77
|
}, /*#__PURE__*/React.createElement(Row, null, /*#__PURE__*/React.createElement(Column, {
|
28
78
|
xlg: 12,
|
29
79
|
lg: 12,
|
30
80
|
md: 8,
|
31
81
|
sm: 8
|
32
|
-
},
|
82
|
+
}, /*#__PURE__*/React.createElement("h4", {
|
33
83
|
className: "".concat(blockClass, "--title")
|
34
|
-
}, title),
|
84
|
+
}, title), subtitle && /*#__PURE__*/React.createElement("h6", {
|
35
85
|
className: "".concat(blockClass, "--subtitle")
|
36
|
-
}, subtitle),
|
86
|
+
}, subtitle), description && /*#__PURE__*/React.createElement("p", {
|
37
87
|
className: "".concat(blockClass, "--description")
|
38
88
|
}, description))), hasFieldset ? /*#__PURE__*/React.createElement(FormGroup, {
|
39
89
|
legendText: fieldsetLegendText,
|
40
90
|
className: "".concat(blockClass, "--fieldset")
|
41
|
-
}, children) : children);
|
91
|
+
}, children) : children) : pconsole.warn("You have tried using a ".concat(componentName, " component outside of a CreateTearsheet. This is not allowed. ").concat(componentName, "s should always be children of the CreateTearsheet"));
|
42
92
|
}); // Return a placeholder if not released and not enabled by feature flag
|
43
93
|
|
44
94
|
CreateTearsheetStep = pkg.checkComponentEnabled(CreateTearsheetStep, componentName);
|
@@ -85,12 +135,6 @@ CreateTearsheetStep.propTypes = {
|
|
85
135
|
*/
|
86
136
|
introStep: PropTypes.bool,
|
87
137
|
|
88
|
-
/**
|
89
|
-
* @ignore
|
90
|
-
* The is an internal prop set in CreateTearsheet so the step knows when to render it's title
|
91
|
-
*/
|
92
|
-
isViewingAllStepsTogether: PropTypes.bool,
|
93
|
-
|
94
138
|
/**
|
95
139
|
* Optional function to be called on initial mount of a step.
|
96
140
|
* For example, this can be used to fetch data that is required on a particular step.
|
@@ -124,6 +168,5 @@ CreateTearsheetStep.propTypes = {
|
|
124
168
|
// component needs to make a choice or assumption when a prop is not supplied.
|
125
169
|
|
126
170
|
CreateTearsheetStep.defaultProps = {
|
127
|
-
type: CREATE_TEARSHEET_STEP,
|
128
171
|
hasFieldset: true
|
129
172
|
};
|
@@ -1,4 +1,7 @@
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
2
|
+
import _extends from "@babel/runtime/helpers/extends";
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
4
|
+
var _excluded = ["value1", "setValue1"];
|
2
5
|
|
3
6
|
/* eslint-disable react/prop-types */
|
4
7
|
|
@@ -15,16 +18,40 @@ import { pkg } from '../../../settings';
|
|
15
18
|
import { CreateTearsheet } from '../CreateTearsheet';
|
16
19
|
import { CreateTearsheetStep } from '../CreateTearsheetStep';
|
17
20
|
var blockClass = "".concat(pkg.prefix, "--tearsheet-create-multi-step");
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
21
|
+
|
22
|
+
var CustomStep = function CustomStep(_ref) {
|
23
|
+
var value1 = _ref.value1,
|
24
|
+
setValue1 = _ref.setValue1,
|
25
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
26
|
+
|
27
|
+
return /*#__PURE__*/React.createElement(CreateTearsheetStep, _extends({}, rest, {
|
28
|
+
disableSubmit: !value1
|
29
|
+
}), /*#__PURE__*/React.createElement(Row, null, /*#__PURE__*/React.createElement(Column, {
|
30
|
+
xlg: 8,
|
31
|
+
lg: 8,
|
32
|
+
md: 8,
|
33
|
+
sm: 8
|
34
|
+
}, /*#__PURE__*/React.createElement(TextInput, {
|
35
|
+
value: value1,
|
36
|
+
onChange: function onChange(event) {
|
37
|
+
return setValue1(event.target.value);
|
38
|
+
},
|
39
|
+
id: "custom-step-input",
|
40
|
+
labelText: "Location",
|
41
|
+
placeholder: "Enter location"
|
42
|
+
}))));
|
43
|
+
};
|
44
|
+
|
45
|
+
export var MultiStepTearsheet = function MultiStepTearsheet(_ref2) {
|
46
|
+
var backButtonText = _ref2.backButtonText,
|
47
|
+
cancelButtonText = _ref2.cancelButtonText,
|
48
|
+
className = _ref2.className,
|
49
|
+
description = _ref2.description,
|
50
|
+
influencerWidth = _ref2.influencerWidth,
|
51
|
+
label = _ref2.label,
|
52
|
+
nextButtonText = _ref2.nextButtonText,
|
53
|
+
submitButtonText = _ref2.submitButtonText,
|
54
|
+
title = _ref2.title;
|
28
55
|
|
29
56
|
var _useState = useState(750),
|
30
57
|
_useState2 = _slicedToArray(_useState, 1),
|
@@ -47,33 +74,38 @@ export var MultiStepTearsheet = function MultiStepTearsheet(_ref) {
|
|
47
74
|
|
48
75
|
var _useState9 = useState(''),
|
49
76
|
_useState10 = _slicedToArray(_useState9, 2),
|
50
|
-
|
51
|
-
|
77
|
+
value1 = _useState10[0],
|
78
|
+
setValue1 = _useState10[1];
|
52
79
|
|
53
80
|
var _useState11 = useState(''),
|
54
81
|
_useState12 = _slicedToArray(_useState11, 2),
|
55
|
-
|
56
|
-
|
82
|
+
stepOneTextInputValue = _useState12[0],
|
83
|
+
setStepOneTextInputValue = _useState12[1];
|
57
84
|
|
58
85
|
var _useState13 = useState(''),
|
59
86
|
_useState14 = _slicedToArray(_useState13, 2),
|
60
|
-
|
61
|
-
|
87
|
+
topicDescriptionValue = _useState14[0],
|
88
|
+
setTopicDescriptionValue = _useState14[1];
|
62
89
|
|
63
|
-
var _useState15 = useState(
|
90
|
+
var _useState15 = useState(''),
|
64
91
|
_useState16 = _slicedToArray(_useState15, 2),
|
65
|
-
|
66
|
-
|
92
|
+
topicVersionValue = _useState16[0],
|
93
|
+
setTopicVersionValue = _useState16[1];
|
67
94
|
|
68
|
-
var _useState17 = useState(
|
95
|
+
var _useState17 = useState(1),
|
69
96
|
_useState18 = _slicedToArray(_useState17, 2),
|
70
|
-
|
71
|
-
|
97
|
+
stepTwoTextInputValue = _useState18[0],
|
98
|
+
setStepTwoTextInputValue = _useState18[1];
|
72
99
|
|
73
|
-
var _useState19 = useState(
|
100
|
+
var _useState19 = useState('one-day'),
|
74
101
|
_useState20 = _slicedToArray(_useState19, 2),
|
75
|
-
|
76
|
-
|
102
|
+
stepThreeTextInputValue = _useState20[0],
|
103
|
+
setStepThreeTextInputValue = _useState20[1];
|
104
|
+
|
105
|
+
var _useState21 = useState(false),
|
106
|
+
_useState22 = _slicedToArray(_useState21, 2),
|
107
|
+
isInvalid = _useState22[0],
|
108
|
+
setIsInvalid = _useState22[1];
|
77
109
|
|
78
110
|
var clearCreateData = function clearCreateData() {
|
79
111
|
setStepOneTextInputValue('');
|
@@ -84,6 +116,7 @@ export var MultiStepTearsheet = function MultiStepTearsheet(_ref) {
|
|
84
116
|
setHasSubmitError(false);
|
85
117
|
setIsInvalid(false);
|
86
118
|
setOpen(false);
|
119
|
+
setValue1('');
|
87
120
|
};
|
88
121
|
|
89
122
|
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("style", null, ".".concat(blockClass, " { opacity: 0 }"), ";"), /*#__PURE__*/React.createElement(Button, {
|
@@ -138,9 +171,9 @@ export var MultiStepTearsheet = function MultiStepTearsheet(_ref) {
|
|
138
171
|
sm: 8
|
139
172
|
}, /*#__PURE__*/React.createElement(TextInput, {
|
140
173
|
labelText: "Topic name",
|
174
|
+
placeholder: "Enter topic name",
|
141
175
|
id: "tearsheet-multi-step-story-text-input-multi-step-1",
|
142
176
|
value: stepOneTextInputValue,
|
143
|
-
placeholder: "Enter topic name",
|
144
177
|
onChange: function onChange(event) {
|
145
178
|
if (event.target.value.length) {
|
146
179
|
setIsInvalid(false);
|
@@ -186,7 +219,13 @@ export var MultiStepTearsheet = function MultiStepTearsheet(_ref) {
|
|
186
219
|
onToggle: function onToggle(event) {
|
187
220
|
return setShouldReject(event);
|
188
221
|
}
|
189
|
-
})))), /*#__PURE__*/React.createElement(
|
222
|
+
})))), /*#__PURE__*/React.createElement(CustomStep, {
|
223
|
+
title: "Location",
|
224
|
+
subtitle: "Custom step subtitle",
|
225
|
+
description: "Custom step description (see storybook implementation for new custom step capability)",
|
226
|
+
value1: value1,
|
227
|
+
setValue1: setValue1
|
228
|
+
}), /*#__PURE__*/React.createElement(CreateTearsheetStep, {
|
190
229
|
title: "Partitions",
|
191
230
|
disableSubmit: !stepTwoTextInputValue,
|
192
231
|
subtitle: "One or more partitions make up a topic. A partition is an ordered list of messages.",
|
@@ -131,7 +131,8 @@ export var ExportModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
131
131
|
key: o.extension,
|
132
132
|
id: o.extension,
|
133
133
|
value: o.extension,
|
134
|
-
labelText: "".concat(o.extension, " (").concat(o.description, ")")
|
134
|
+
labelText: "".concat(o.extension, " (").concat(o.description, ")"),
|
135
|
+
"data-modal-primary-focus": true
|
135
136
|
});
|
136
137
|
}))) : /*#__PURE__*/React.createElement(TextInput, {
|
137
138
|
id: "text-input--".concat(internalId.current),
|
@@ -140,7 +141,8 @@ export var ExportModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
140
141
|
labelText: inputLabel,
|
141
142
|
invalid: hasInvalidExtension(),
|
142
143
|
invalidText: invalidInputText,
|
143
|
-
onBlur: onBlurHandler
|
144
|
+
onBlur: onBlurHandler,
|
145
|
+
"data-modal-primary-focus": true
|
144
146
|
})), /*#__PURE__*/React.createElement("div", {
|
145
147
|
className: "".concat(blockClass, "__messaging")
|
146
148
|
}, loading && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Loading, {
|
@@ -229,7 +229,8 @@ export var ImportModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
229
229
|
accept: accept,
|
230
230
|
labelText: fileDropLabel,
|
231
231
|
onAddFiles: onAddFile,
|
232
|
-
disabled: hasFiles
|
232
|
+
disabled: hasFiles,
|
233
|
+
"data-modal-primary-focus": true
|
233
234
|
}), inputLabel && /*#__PURE__*/React.createElement("p", {
|
234
235
|
className: "".concat(blockClass, "__label")
|
235
236
|
}, inputLabel), /*#__PURE__*/React.createElement("div", {
|
@@ -0,0 +1,224 @@
|
|
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", "disabled", "editDescription", "id", "inline", "invalid", "invalidText", "labelText", "onChange", "onInput", "onRevert", "revertDescription", "saveDescription", "saveDisabled", "size", "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. 2022, 2022
|
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, { useState } from 'react'; // Other standard imports.
|
19
|
+
|
20
|
+
import PropTypes from 'prop-types';
|
21
|
+
import cx from 'classnames';
|
22
|
+
import { getDevtoolsProps } from '../../global/js/utils/devtools';
|
23
|
+
import { pkg, carbon } from '../../settings'; // Carbon and package components we use.
|
24
|
+
|
25
|
+
/* TODO: @import(s) of carbon components and other package components. */
|
26
|
+
|
27
|
+
import { CancelableTextEdit } from '../';
|
28
|
+
import { Button } from 'carbon-components-react';
|
29
|
+
import { Edit16, EditOff16 } from '@carbon/icons-react'; // The block part of our conventional BEM class names (blockClass__E--M).
|
30
|
+
|
31
|
+
var blockClass = "".concat(pkg.prefix, "--inline-edit");
|
32
|
+
var componentName = 'InlineEdit'; // NOTE: the component SCSS is not imported here: it is rolled up separately.
|
33
|
+
|
34
|
+
/**
|
35
|
+
* TODO: A description of the component.
|
36
|
+
*/
|
37
|
+
|
38
|
+
export var InlineEdit = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
39
|
+
var className = _ref.className,
|
40
|
+
disabled = _ref.disabled,
|
41
|
+
editDescription = _ref.editDescription,
|
42
|
+
id = _ref.id,
|
43
|
+
inline = _ref.inline,
|
44
|
+
invalid = _ref.invalid,
|
45
|
+
invalidText = _ref.invalidText,
|
46
|
+
labelText = _ref.labelText,
|
47
|
+
onChange = _ref.onChange,
|
48
|
+
onInput = _ref.onInput,
|
49
|
+
onRevert = _ref.onRevert,
|
50
|
+
revertDescription = _ref.revertDescription,
|
51
|
+
saveDescription = _ref.saveDescription,
|
52
|
+
saveDisabled = _ref.saveDisabled,
|
53
|
+
size = _ref.size,
|
54
|
+
value = _ref.value,
|
55
|
+
warn = _ref.warn,
|
56
|
+
warnText = _ref.warnText,
|
57
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
58
|
+
|
59
|
+
var _useState = useState(false),
|
60
|
+
_useState2 = _slicedToArray(_useState, 2),
|
61
|
+
editing = _useState2[0],
|
62
|
+
setEditing = _useState2[1];
|
63
|
+
|
64
|
+
var handleEdit = function handleEdit() {
|
65
|
+
return setEditing(function (prev) {
|
66
|
+
return !prev;
|
67
|
+
});
|
68
|
+
};
|
69
|
+
|
70
|
+
var handleChange = function handleChange(val) {
|
71
|
+
setEditing(false);
|
72
|
+
onChange(val);
|
73
|
+
};
|
74
|
+
|
75
|
+
var handleRevert = function handleRevert() {
|
76
|
+
setEditing(false);
|
77
|
+
onRevert(value);
|
78
|
+
};
|
79
|
+
|
80
|
+
var stdProps = _objectSpread(_objectSpread({}, rest), {}, {
|
81
|
+
className: cx(blockClass, // Apply the block class to the main HTML element
|
82
|
+
className, // Apply any supplied class names to the main HTML element.
|
83
|
+
_defineProperty({}, "".concat(blockClass, "--editing"), editing)),
|
84
|
+
id: id,
|
85
|
+
size: size,
|
86
|
+
ref: ref
|
87
|
+
}, getDevtoolsProps(componentName));
|
88
|
+
|
89
|
+
return editing ? /*#__PURE__*/React.createElement(CancelableTextEdit, _extends({}, stdProps, {
|
90
|
+
hideLabel: true,
|
91
|
+
inline: inline,
|
92
|
+
invalid: invalid,
|
93
|
+
invalidText: invalidText,
|
94
|
+
labelText: labelText,
|
95
|
+
onChange: handleChange,
|
96
|
+
onInput: onInput,
|
97
|
+
onRevert: handleRevert,
|
98
|
+
revertDescription: revertDescription,
|
99
|
+
saveDescription: saveDescription,
|
100
|
+
saveDisabled: saveDisabled,
|
101
|
+
value: value,
|
102
|
+
warn: warn,
|
103
|
+
warnText: warnText
|
104
|
+
})) : /*#__PURE__*/React.createElement("div", stdProps, /*#__PURE__*/React.createElement("div", {
|
105
|
+
className: "".concat(blockClass, "__value")
|
106
|
+
}, value), /*#__PURE__*/React.createElement(Button, {
|
107
|
+
className: "".concat(blockClass, "__button ").concat(carbon.prefix, "--btn--md"),
|
108
|
+
kind: "ghost",
|
109
|
+
hasIconOnly: true,
|
110
|
+
iconDescription: editDescription,
|
111
|
+
onClick: handleEdit,
|
112
|
+
renderIcon: disabled ? EditOff16 : Edit16,
|
113
|
+
disabled: disabled
|
114
|
+
}));
|
115
|
+
}); // Return a placeholder if not released and not enabled by feature flag
|
116
|
+
|
117
|
+
InlineEdit = pkg.checkComponentEnabled(InlineEdit, componentName); // The display name of the component, used by React. Note that displayName
|
118
|
+
// is used in preference to relying on function.name.
|
119
|
+
|
120
|
+
InlineEdit.displayName = componentName; // The types and DocGen commentary for the component props,
|
121
|
+
// in alphabetical order (for consistency).
|
122
|
+
// See https://www.npmjs.com/package/prop-types#usage.
|
123
|
+
|
124
|
+
InlineEdit.propTypes = {
|
125
|
+
/**
|
126
|
+
* Provide an optional class to be applied to the containing node.
|
127
|
+
*/
|
128
|
+
className: PropTypes.string,
|
129
|
+
|
130
|
+
/**
|
131
|
+
* disable edit
|
132
|
+
*/
|
133
|
+
disabled: PropTypes.bool,
|
134
|
+
|
135
|
+
/**
|
136
|
+
* Label for the edit button
|
137
|
+
*/
|
138
|
+
editDescription: PropTypes.string.isRequired,
|
139
|
+
|
140
|
+
/**
|
141
|
+
* ID for inline edit
|
142
|
+
*/
|
143
|
+
id: PropTypes.string,
|
144
|
+
|
145
|
+
/* TODO: add types and DocGen for all props. */
|
146
|
+
|
147
|
+
/**
|
148
|
+
* inline variant
|
149
|
+
*/
|
150
|
+
inline: PropTypes.bool,
|
151
|
+
|
152
|
+
/**
|
153
|
+
* set invalid state for input
|
154
|
+
*/
|
155
|
+
invalid: PropTypes.bool,
|
156
|
+
|
157
|
+
/**
|
158
|
+
* text shown when invalid is true
|
159
|
+
*/
|
160
|
+
invalidText: PropTypes.string,
|
161
|
+
|
162
|
+
/**
|
163
|
+
* label for text input
|
164
|
+
*/
|
165
|
+
labelText: PropTypes.string,
|
166
|
+
|
167
|
+
/**
|
168
|
+
* method called on change event
|
169
|
+
*/
|
170
|
+
onChange: PropTypes.func,
|
171
|
+
|
172
|
+
/**
|
173
|
+
* method called on input event
|
174
|
+
*/
|
175
|
+
onInput: PropTypes.func,
|
176
|
+
|
177
|
+
/**
|
178
|
+
* method called on revert event
|
179
|
+
*/
|
180
|
+
onRevert: PropTypes.func,
|
181
|
+
|
182
|
+
/**
|
183
|
+
* label for revert button
|
184
|
+
*/
|
185
|
+
revertDescription: PropTypes.string.isRequired,
|
186
|
+
|
187
|
+
/**
|
188
|
+
* label for save button
|
189
|
+
*/
|
190
|
+
saveDescription: PropTypes.string.isRequired,
|
191
|
+
|
192
|
+
/**
|
193
|
+
* disabled state of the save button
|
194
|
+
*/
|
195
|
+
saveDisabled: PropTypes.bool,
|
196
|
+
|
197
|
+
/**
|
198
|
+
* vertical size of control
|
199
|
+
*/
|
200
|
+
size: PropTypes.oneOf(['sm', 'md', 'lg']),
|
201
|
+
|
202
|
+
/**
|
203
|
+
* initial/unedited value
|
204
|
+
*/
|
205
|
+
value: PropTypes.string,
|
206
|
+
|
207
|
+
/**
|
208
|
+
* set warn state for input
|
209
|
+
*/
|
210
|
+
warn: PropTypes.bool,
|
211
|
+
|
212
|
+
/**
|
213
|
+
* text shown when warn true
|
214
|
+
*/
|
215
|
+
warnText: PropTypes.string
|
216
|
+
}; // Default values for component props. Default values are not required for
|
217
|
+
// props that are required, nor for props where the component can apply
|
218
|
+
// 'undefined' values reasonably. Default values should be provided when the
|
219
|
+
// component needs to make a choice or assumption when a prop is not supplied.
|
220
|
+
|
221
|
+
InlineEdit.defaultProps = {
|
222
|
+
/* TODO: add defaults for relevant props. */
|
223
|
+
size: 'md'
|
224
|
+
};
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
import React, { forwardRef } from 'react'; // import PropTypes from 'prop-types';
|
3
|
+
|
4
|
+
import { AddSelect } from '../AddSelect';
|
5
|
+
import { getDevtoolsProps } from '../../global/js/utils/devtools';
|
6
|
+
import { pkg } from '../../settings';
|
7
|
+
var componentName = 'MultiAddSelect';
|
8
|
+
export var MultiAddSelect = /*#__PURE__*/forwardRef(function (props, ref) {
|
9
|
+
return /*#__PURE__*/React.createElement(AddSelect, _extends({}, props, {
|
10
|
+
multi: true,
|
11
|
+
ref: ref
|
12
|
+
}, getDevtoolsProps(componentName)));
|
13
|
+
});
|
14
|
+
MultiAddSelect = pkg.checkComponentEnabled(MultiAddSelect, componentName);
|
15
|
+
MultiAddSelect.propTypes = {};
|
16
|
+
MultiAddSelect.displayName = componentName;
|
@@ -0,0 +1 @@
|
|
1
|
+
export { MultiAddSelect } from './MultiAddSelect';
|