@carbon/ibm-products 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +124 -40
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +1 -1
- package/css/index-without-carbon-released-only.css +124 -40
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +1 -1
- package/css/index-without-carbon.css +124 -40
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +1 -1
- package/css/index.css +124 -40
- package/css/index.css.map +1 -1
- package/css/index.min.css +1 -1
- package/es/components/ActionSet/ActionSet.js +22 -10
- package/es/components/ActionSet/actions.js +25 -17
- package/es/components/CreateFullPage/CreateFullPage.js +30 -5
- package/es/components/CreateFullPage/CreateFullPageStep.js +40 -32
- package/es/components/CreateInfluencer/CreateInfluencer.js +25 -3
- package/es/components/CreateTearsheet/CreateTearsheet.js +32 -6
- package/es/components/CreateTearsheet/CreateTearsheetStep.js +45 -38
- package/es/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +24 -4
- package/es/components/CreateTearsheet/preview-components/MultiStepWithIntro.js +8 -6
- package/es/components/ExportModal/ExportModal.js +39 -12
- package/es/components/SidePanel/SidePanel.js +1 -1
- package/es/components/Tearsheet/Tearsheet.js +1 -1
- package/es/components/Tearsheet/TearsheetNarrow.js +1 -1
- package/es/components/Tearsheet/TearsheetShell.js +1 -1
- package/es/global/js/hooks/index.js +1 -0
- package/es/global/js/hooks/useCreateComponentStepChange.js +31 -11
- package/es/global/js/hooks/useResetCreateComponent.js +7 -4
- package/es/global/js/hooks/useRetrieveStepData.js +51 -0
- package/es/global/js/utils/lastIndexInArray.js +26 -0
- package/lib/components/ActionSet/ActionSet.js +22 -10
- package/lib/components/ActionSet/actions.js +25 -17
- package/lib/components/CreateFullPage/CreateFullPage.js +29 -4
- package/lib/components/CreateFullPage/CreateFullPageStep.js +38 -30
- package/lib/components/CreateInfluencer/CreateInfluencer.js +25 -3
- package/lib/components/CreateTearsheet/CreateTearsheet.js +31 -5
- package/lib/components/CreateTearsheet/CreateTearsheetStep.js +43 -36
- package/lib/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +22 -2
- package/lib/components/CreateTearsheet/preview-components/MultiStepWithIntro.js +8 -6
- package/lib/components/ExportModal/ExportModal.js +36 -11
- package/lib/components/SidePanel/SidePanel.js +1 -1
- package/lib/components/Tearsheet/Tearsheet.js +1 -1
- package/lib/components/Tearsheet/TearsheetNarrow.js +1 -1
- package/lib/components/Tearsheet/TearsheetShell.js +1 -1
- package/lib/global/js/hooks/index.js +8 -0
- package/lib/global/js/hooks/useCreateComponentStepChange.js +31 -11
- package/lib/global/js/hooks/useResetCreateComponent.js +7 -4
- package/lib/global/js/hooks/useRetrieveStepData.js +62 -0
- package/lib/global/js/utils/lastIndexInArray.js +35 -0
- package/package.json +15 -15
- package/scss/components/StatusIcon/_status-icon.scss +2 -0
@@ -6,13 +6,13 @@ var _excluded = ["value1", "setValue1"];
|
|
6
6
|
/* eslint-disable react/prop-types */
|
7
7
|
|
8
8
|
/**
|
9
|
-
* Copyright IBM Corp. 2021,
|
9
|
+
* Copyright IBM Corp. 2021, 2022
|
10
10
|
*
|
11
11
|
* This source code is licensed under the Apache-2.0 license found in the
|
12
12
|
* LICENSE file in the root directory of this source tree.
|
13
13
|
*/
|
14
14
|
import React, { useState } from 'react';
|
15
|
-
import { Button, Column, InlineNotification, RadioButtonGroup, RadioButton, Row, TextInput, Toggle, NumberInput } from 'carbon-components-react';
|
15
|
+
import { Button, Column, InlineNotification, RadioButtonGroup, RadioButton, Row, TextInput, Toggle, NumberInput, Checkbox } from 'carbon-components-react';
|
16
16
|
import cx from 'classnames';
|
17
17
|
import { pkg } from '../../../settings';
|
18
18
|
import { CreateTearsheet } from '../CreateTearsheet';
|
@@ -107,6 +107,11 @@ export var MultiStepTearsheet = function MultiStepTearsheet(_ref2) {
|
|
107
107
|
isInvalid = _useState22[0],
|
108
108
|
setIsInvalid = _useState22[1];
|
109
109
|
|
110
|
+
var _useState23 = useState(false),
|
111
|
+
_useState24 = _slicedToArray(_useState23, 2),
|
112
|
+
shouldIncludeAdditionalStep = _useState24[0],
|
113
|
+
setShouldIncludeAdditionalStep = _useState24[1];
|
114
|
+
|
110
115
|
var clearCreateData = function clearCreateData() {
|
111
116
|
setStepOneTextInputValue('');
|
112
117
|
setTopicDescriptionValue('');
|
@@ -117,6 +122,7 @@ export var MultiStepTearsheet = function MultiStepTearsheet(_ref2) {
|
|
117
122
|
setIsInvalid(false);
|
118
123
|
setOpen(false);
|
119
124
|
setValue1('');
|
125
|
+
setShouldIncludeAdditionalStep(false);
|
120
126
|
};
|
121
127
|
|
122
128
|
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("style", null, ".".concat(blockClass, " { opacity: 0 }"), ";"), /*#__PURE__*/React.createElement(Button, {
|
@@ -219,12 +225,26 @@ export var MultiStepTearsheet = function MultiStepTearsheet(_ref2) {
|
|
219
225
|
onToggle: function onToggle(event) {
|
220
226
|
return setShouldReject(event);
|
221
227
|
}
|
222
|
-
})
|
228
|
+
}), /*#__PURE__*/React.createElement(Checkbox, {
|
229
|
+
labelText: "Include additional step",
|
230
|
+
id: "include-additional-step-checkbox",
|
231
|
+
onChange: function onChange(value) {
|
232
|
+
return setShouldIncludeAdditionalStep(value);
|
233
|
+
},
|
234
|
+
checked: shouldIncludeAdditionalStep
|
235
|
+
})))), /*#__PURE__*/React.createElement(CreateTearsheetStep, {
|
236
|
+
title: "Dynamic step",
|
237
|
+
subtitle: "Dynamic step subtitle",
|
238
|
+
description: "This is an example showing how to include a dynamic step into the CreateTearsheet",
|
239
|
+
hasFieldset: false,
|
240
|
+
includeStep: shouldIncludeAdditionalStep
|
241
|
+
}, "dynamic step content"), /*#__PURE__*/React.createElement(CustomStep, {
|
223
242
|
title: "Location",
|
224
243
|
subtitle: "Custom step subtitle",
|
225
244
|
description: "Custom step description (see storybook implementation for new custom step capability)",
|
226
245
|
value1: value1,
|
227
|
-
setValue1: setValue1
|
246
|
+
setValue1: setValue1,
|
247
|
+
hasFieldset: false
|
228
248
|
}), /*#__PURE__*/React.createElement(CreateTearsheetStep, {
|
229
249
|
title: "Partitions",
|
230
250
|
disableSubmit: !stepTwoTextInputValue,
|
@@ -3,7 +3,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
/* eslint-disable react/prop-types */
|
4
4
|
|
5
5
|
/**
|
6
|
-
* Copyright IBM Corp. 2021,
|
6
|
+
* Copyright IBM Corp. 2021, 2022
|
7
7
|
*
|
8
8
|
* This source code is licensed under the Apache-2.0 license found in the
|
9
9
|
* LICENSE file in the root directory of this source tree.
|
@@ -154,14 +154,16 @@ export var MultiStepWithIntro = function MultiStepWithIntro(_ref) {
|
|
154
154
|
size: "lg"
|
155
155
|
}), /*#__PURE__*/React.createElement("span", {
|
156
156
|
className: "".concat(pkg.prefix, "--tearsheet-create-multi-step--custom-tile-label")
|
157
|
-
}, "Plus")))),
|
157
|
+
}, "Plus")))), /*#__PURE__*/React.createElement(CreateTearsheetStep, {
|
158
158
|
title: "Conditional step",
|
159
159
|
subtitle: "This step will only show for plus category creation flows",
|
160
|
-
hasFieldset: false
|
161
|
-
|
160
|
+
hasFieldset: false,
|
161
|
+
includeStep: selectedCategory === 'plus'
|
162
|
+
}, "This step will only show for plus create flows"), /*#__PURE__*/React.createElement(CreateTearsheetStep, {
|
162
163
|
title: "Standard step only",
|
163
|
-
hasFieldset: false
|
164
|
-
|
164
|
+
hasFieldset: false,
|
165
|
+
includeStep: selectedCategory === 'standard'
|
166
|
+
}, "This step will only show for standard create flows"), /*#__PURE__*/React.createElement(CreateTearsheetStep, {
|
165
167
|
onNext: function onNext() {
|
166
168
|
return new Promise(function (resolve, reject) {
|
167
169
|
setTimeout(function () {
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
4
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
5
|
-
var _excluded = ["body", "className", "error", "errorMessage", "filename", "inputLabel", "invalidInputText", "loading", "loadingMessage", "onClose", "onRequestSubmit", "open", "preformattedExtensions", "preformattedExtensionsLabel", "primaryButtonText", "secondaryButtonText", "successMessage", "successful", "title", "validExtensions"];
|
5
|
+
var _excluded = ["body", "className", "error", "errorMessage", "filename", "hidePasswordLabel", "inputLabel", "inputType", "invalidInputText", "loading", "loadingMessage", "onClose", "onRequestSubmit", "open", "preformattedExtensions", "preformattedExtensionsLabel", "primaryButtonText", "secondaryButtonText", "showPasswordLabel", "successMessage", "successful", "title", "validExtensions"];
|
6
6
|
|
7
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
8
|
|
@@ -15,7 +15,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
15
15
|
// LICENSE file in the root directory of this source tree.
|
16
16
|
//
|
17
17
|
import React, { useState, useRef, forwardRef } from 'react';
|
18
|
-
import { Button, ComposedModal, ModalHeader, ModalFooter, ModalBody, TextInput, RadioButton, RadioButtonGroup, FormGroup, Loading } from 'carbon-components-react';
|
18
|
+
import { Button, ComposedModal, ModalHeader, ModalFooter, ModalBody, TextInput, RadioButton, RadioButtonGroup, FormGroup, Loading, PasswordInput } from 'carbon-components-react';
|
19
19
|
import cx from 'classnames';
|
20
20
|
import { ErrorFilled16, CheckmarkFilled16 } from '@carbon/icons-react';
|
21
21
|
import PropTypes from 'prop-types';
|
@@ -31,7 +31,9 @@ export var ExportModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
31
31
|
error = _ref.error,
|
32
32
|
errorMessage = _ref.errorMessage,
|
33
33
|
filename = _ref.filename,
|
34
|
+
hidePasswordLabel = _ref.hidePasswordLabel,
|
34
35
|
inputLabel = _ref.inputLabel,
|
36
|
+
inputType = _ref.inputType,
|
35
37
|
invalidInputText = _ref.invalidInputText,
|
36
38
|
loading = _ref.loading,
|
37
39
|
loadingMessage = _ref.loadingMessage,
|
@@ -42,6 +44,7 @@ export var ExportModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
42
44
|
preformattedExtensionsLabel = _ref.preformattedExtensionsLabel,
|
43
45
|
primaryButtonText = _ref.primaryButtonText,
|
44
46
|
secondaryButtonText = _ref.secondaryButtonText,
|
47
|
+
showPasswordLabel = _ref.showPasswordLabel,
|
45
48
|
successMessage = _ref.successMessage,
|
46
49
|
successful = _ref.successful,
|
47
50
|
title = _ref.title,
|
@@ -103,6 +106,17 @@ export var ExportModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
103
106
|
var internalId = useRef(uuidv4());
|
104
107
|
var primaryButtonDisabled = loading || !name || hasInvalidExtension();
|
105
108
|
var submitted = loading || error || successful;
|
109
|
+
|
110
|
+
var commonInputProps = _defineProperty({
|
111
|
+
id: "text-input--".concat(internalId.current),
|
112
|
+
value: name,
|
113
|
+
onChange: onNameChangeHandler,
|
114
|
+
labelText: inputLabel,
|
115
|
+
invalid: hasInvalidExtension(),
|
116
|
+
invalidText: invalidInputText,
|
117
|
+
onBlur: onBlurHandler
|
118
|
+
}, 'data-modal-primary-focus', true);
|
119
|
+
|
106
120
|
return /*#__PURE__*/React.createElement(ComposedModal, _extends({}, rest, {
|
107
121
|
className: cx(blockClass, className),
|
108
122
|
"aria-label": title,
|
@@ -134,16 +148,13 @@ export var ExportModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
134
148
|
labelText: "".concat(o.extension, " (").concat(o.description, ")"),
|
135
149
|
"data-modal-primary-focus": true
|
136
150
|
});
|
137
|
-
}))) : /*#__PURE__*/React.createElement(
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
onBlur: onBlurHandler,
|
145
|
-
"data-modal-primary-focus": true
|
146
|
-
})), /*#__PURE__*/React.createElement("div", {
|
151
|
+
}))) : /*#__PURE__*/React.createElement("div", {
|
152
|
+
className: "".concat(blockClass, "__input-container")
|
153
|
+
}, inputType === 'text' ? /*#__PURE__*/React.createElement(TextInput, commonInputProps) : /*#__PURE__*/React.createElement(PasswordInput, _extends({}, commonInputProps, {
|
154
|
+
showPasswordLabel: showPasswordLabel,
|
155
|
+
hidePasswordLabel: hidePasswordLabel,
|
156
|
+
tooltipPosition: "left"
|
157
|
+
})))), /*#__PURE__*/React.createElement("div", {
|
147
158
|
className: "".concat(blockClass, "__messaging")
|
148
159
|
}, loading && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Loading, {
|
149
160
|
small: true,
|
@@ -193,11 +204,21 @@ ExportModal.propTypes = {
|
|
193
204
|
*/
|
194
205
|
filename: PropTypes.string.isRequired,
|
195
206
|
|
207
|
+
/**
|
208
|
+
* label text that's displayed when hovering over visibility toggler to hide key
|
209
|
+
*/
|
210
|
+
hidePasswordLabel: PropTypes.string,
|
211
|
+
|
196
212
|
/**
|
197
213
|
* label for the text input
|
198
214
|
*/
|
199
215
|
inputLabel: PropTypes.string,
|
200
216
|
|
217
|
+
/**
|
218
|
+
* specify the type of text input
|
219
|
+
*/
|
220
|
+
inputType: PropTypes.oneOf(['text', 'password']),
|
221
|
+
|
201
222
|
/**
|
202
223
|
* text for an invalid input
|
203
224
|
*/
|
@@ -251,6 +272,11 @@ ExportModal.propTypes = {
|
|
251
272
|
*/
|
252
273
|
secondaryButtonText: PropTypes.string.isRequired,
|
253
274
|
|
275
|
+
/**
|
276
|
+
* label text that's displayed when hovering over visibility toggler to show key
|
277
|
+
*/
|
278
|
+
showPasswordLabel: PropTypes.string,
|
279
|
+
|
254
280
|
/**
|
255
281
|
* messaging to display if the export was successful
|
256
282
|
*/
|
@@ -272,6 +298,7 @@ ExportModal.propTypes = {
|
|
272
298
|
validExtensions: PropTypes.array
|
273
299
|
};
|
274
300
|
ExportModal.defaultProps = {
|
301
|
+
inputType: 'text',
|
275
302
|
preformattedExtensions: [],
|
276
303
|
validExtensions: []
|
277
304
|
};
|
@@ -508,7 +508,7 @@ SidePanel.propTypes = {
|
|
508
508
|
* See https://react.carbondesignsystem.com/?path=/docs/components-button--default#component-api
|
509
509
|
*/
|
510
510
|
actions: allPropTypes([ActionSet.validateActions(), PropTypes.arrayOf(PropTypes.shape(_objectSpread(_objectSpread({}, Button.propTypes), {}, {
|
511
|
-
kind: PropTypes.oneOf(['ghost', 'secondary', 'primary']),
|
511
|
+
kind: PropTypes.oneOf(['ghost', 'danger--ghost', 'secondary', 'danger', 'primary']),
|
512
512
|
label: PropTypes.string,
|
513
513
|
loading: PropTypes.bool,
|
514
514
|
// we duplicate this Button prop to improve the DocGen here
|
@@ -82,7 +82,7 @@ Tearsheet.propTypes = _objectSpread({
|
|
82
82
|
actions: allPropTypes([ActionSet.validateActions(function () {
|
83
83
|
return 'max';
|
84
84
|
}), PropTypes.arrayOf(PropTypes.shape(_objectSpread(_objectSpread({}, Button.propTypes), {}, {
|
85
|
-
kind: PropTypes.oneOf(['ghost', 'secondary', 'primary']),
|
85
|
+
kind: PropTypes.oneOf(['ghost', 'danger--ghost', 'secondary', 'danger', 'primary']),
|
86
86
|
label: PropTypes.string,
|
87
87
|
loading: PropTypes.bool,
|
88
88
|
// we duplicate this Button prop to improve the DocGen here
|
@@ -78,7 +78,7 @@ TearsheetNarrow.propTypes = _objectSpread({
|
|
78
78
|
actions: allPropTypes([ActionSet.validateActions(function () {
|
79
79
|
return 'lg';
|
80
80
|
}), PropTypes.arrayOf(PropTypes.shape(_objectSpread(_objectSpread({}, Button.propTypes), {}, {
|
81
|
-
kind: PropTypes.oneOf(['ghost', 'secondary', 'primary']),
|
81
|
+
kind: PropTypes.oneOf(['ghost', 'danger--ghost', 'secondary', 'danger', 'primary']),
|
82
82
|
label: PropTypes.string,
|
83
83
|
loading: PropTypes.bool,
|
84
84
|
// we duplicate this Button prop to improve the DocGen here
|
@@ -281,7 +281,7 @@ TearsheetShell.propTypes = _objectSpread({
|
|
281
281
|
actions: PropTypes.arrayOf( // NB we don't include the validator here, as the component wrapping this
|
282
282
|
// one should ensure appropriate validation is done.
|
283
283
|
PropTypes.shape(_objectSpread(_objectSpread({}, Button.propTypes), {}, {
|
284
|
-
kind: PropTypes.oneOf(['ghost', 'secondary', 'primary']),
|
284
|
+
kind: PropTypes.oneOf(['ghost', 'danger--ghost', 'secondary', 'danger', 'primary']),
|
285
285
|
label: PropTypes.string,
|
286
286
|
loading: PropTypes.bool,
|
287
287
|
// we duplicate this Button prop to improve the DocGen here
|
@@ -11,4 +11,5 @@ export { useCreateComponentFocus } from './useCreateComponentFocus';
|
|
11
11
|
export { useCreateComponentStepChange } from './useCreateComponentStepChange';
|
12
12
|
export { usePreviousValue } from './usePreviousValue';
|
13
13
|
export { useResetCreateComponent } from './useResetCreateComponent';
|
14
|
+
export { useRetrieveStepData } from './useRetrieveStepData';
|
14
15
|
export { useValidCreateStepCount } from './useValidCreateStepCount';
|
@@ -2,14 +2,16 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
3
3
|
|
4
4
|
/**
|
5
|
-
* Copyright IBM Corp. 2021,
|
5
|
+
* Copyright IBM Corp. 2021, 2022
|
6
6
|
*
|
7
7
|
* This source code is licensed under the Apache-2.0 license found in the
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
9
9
|
*/
|
10
10
|
import { useCallback, useEffect } from 'react';
|
11
11
|
export var useCreateComponentStepChange = function useCreateComponentStepChange(_ref) {
|
12
|
-
var
|
12
|
+
var firstIncludedStep = _ref.firstIncludedStep,
|
13
|
+
lastIncludedStep = _ref.lastIncludedStep,
|
14
|
+
stepData = _ref.stepData,
|
13
15
|
onNext = _ref.onNext,
|
14
16
|
isSubmitDisabled = _ref.isSubmitDisabled,
|
15
17
|
setCurrentStep = _ref.setCurrentStep,
|
@@ -174,20 +176,29 @@ export var useCreateComponentStepChange = function useCreateComponentStepChange(
|
|
174
176
|
};
|
175
177
|
}();
|
176
178
|
|
177
|
-
if (
|
179
|
+
if ((stepData === null || stepData === void 0 ? void 0 : stepData.length) > 0) {
|
178
180
|
var buttons = [];
|
179
181
|
|
180
|
-
if (
|
182
|
+
if ((stepData === null || stepData === void 0 ? void 0 : stepData.length) > 1 && !shouldViewAll) {
|
181
183
|
buttons.push({
|
182
184
|
key: 'create-action-button-back',
|
183
185
|
label: backButtonText,
|
184
186
|
onClick: function onClick() {
|
185
187
|
return setCurrentStep(function (prev) {
|
186
|
-
|
188
|
+
// Find previous included step to render
|
189
|
+
// There will always be a previous step otherwise we will
|
190
|
+
// have disabled the back button since we have reached the first visible step
|
191
|
+
do {
|
192
|
+
var _stepData;
|
193
|
+
|
194
|
+
prev--;
|
195
|
+
} while (!((_stepData = stepData[prev - 1]) !== null && _stepData !== void 0 && _stepData.shouldIncludeStep));
|
196
|
+
|
197
|
+
return prev;
|
187
198
|
});
|
188
199
|
},
|
189
200
|
kind: 'secondary',
|
190
|
-
disabled: currentStep ===
|
201
|
+
disabled: currentStep === firstIncludedStep
|
191
202
|
});
|
192
203
|
}
|
193
204
|
|
@@ -201,8 +212,8 @@ export var useCreateComponentStepChange = function useCreateComponentStepChange(
|
|
201
212
|
});
|
202
213
|
buttons.push({
|
203
214
|
key: 'create-action-button-submit',
|
204
|
-
label: shouldViewAll ? submitButtonText : currentStep <
|
205
|
-
onClick: shouldViewAll ? handleSubmit : currentStep <
|
215
|
+
label: shouldViewAll ? submitButtonText : currentStep < lastIncludedStep ? nextButtonText : submitButtonText,
|
216
|
+
onClick: shouldViewAll ? handleSubmit : currentStep < lastIncludedStep ? handleNext : handleSubmit,
|
206
217
|
disabled: isSubmitDisabled,
|
207
218
|
kind: 'primary',
|
208
219
|
loading: isSubmitting,
|
@@ -210,11 +221,20 @@ export var useCreateComponentStepChange = function useCreateComponentStepChange(
|
|
210
221
|
});
|
211
222
|
setCreateComponentActions(buttons);
|
212
223
|
}
|
213
|
-
}, [
|
224
|
+
}, [firstIncludedStep, lastIncludedStep, stepData, onNext, isSubmitDisabled, backButtonText, cancelButtonText, currentStep, onClose, nextButtonText, submitButtonText, onRequestSubmit, isSubmitting, shouldViewAll, componentBlockClass, componentName, continueToNextStep, setCurrentStep, setCreateComponentActions, setIsSubmitting, setShouldViewAll, setModalIsOpen]);
|
214
225
|
var continueToNextStep = useCallback(function () {
|
215
226
|
setIsSubmitting(false);
|
216
227
|
setCurrentStep(function (prev) {
|
217
|
-
|
228
|
+
// Find next included step to render
|
229
|
+
// There will always be a next step otherwise we will
|
230
|
+
// have reach the onSubmit
|
231
|
+
do {
|
232
|
+
var _stepData2;
|
233
|
+
|
234
|
+
prev++;
|
235
|
+
} while (!((_stepData2 = stepData[prev - 1]) !== null && _stepData2 !== void 0 && _stepData2.shouldIncludeStep));
|
236
|
+
|
237
|
+
return prev;
|
218
238
|
});
|
219
|
-
}, [setCurrentStep, setIsSubmitting]);
|
239
|
+
}, [setCurrentStep, setIsSubmitting, stepData]);
|
220
240
|
};
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/**
|
2
|
-
* Copyright IBM Corp. 2021,
|
2
|
+
* Copyright IBM Corp. 2021, 2022
|
3
3
|
*
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
@@ -8,6 +8,7 @@ import { useEffect } from 'react';
|
|
8
8
|
/**
|
9
9
|
* Resets the current step of the create component if it has been closed.
|
10
10
|
* @param {object} useResetCreateComponent - Create component that uses this custom hook
|
11
|
+
* @param {object} useResetCreateComponent.firstIncludedStep
|
11
12
|
* @param {object} useResetCreateComponent.previousState
|
12
13
|
* @param {boolean} useResetCreateComponent.open
|
13
14
|
* @param {Function} useResetCreateComponent.setCurrentStep
|
@@ -17,7 +18,8 @@ import { useEffect } from 'react';
|
|
17
18
|
*/
|
18
19
|
|
19
20
|
export var useResetCreateComponent = function useResetCreateComponent(_ref) {
|
20
|
-
var
|
21
|
+
var firstIncludedStep = _ref.firstIncludedStep,
|
22
|
+
previousState = _ref.previousState,
|
21
23
|
open = _ref.open,
|
22
24
|
setCurrentStep = _ref.setCurrentStep,
|
23
25
|
initialStep = _ref.initialStep,
|
@@ -28,7 +30,8 @@ export var useResetCreateComponent = function useResetCreateComponent(_ref) {
|
|
28
30
|
if (initialStep && totalSteps && Number(initialStep) <= Number(totalSteps) && Number(initialStep) > 0) {
|
29
31
|
setCurrentStep(Number(initialStep));
|
30
32
|
} else {
|
31
|
-
|
33
|
+
// default should be fist includedStep instead of just 1
|
34
|
+
setCurrentStep(firstIncludedStep);
|
32
35
|
} // An invalid initialStep value was provided, we'll default to rendering the first step in this scenario
|
33
36
|
|
34
37
|
|
@@ -36,5 +39,5 @@ export var useResetCreateComponent = function useResetCreateComponent(_ref) {
|
|
36
39
|
console.warn("".concat(componentName, ": An invalid `initialStep` prop was supplied. The `initialStep` prop should be a number that is greater than 0 or less than or equal to the number of steps your ").concat(componentName, " has."));
|
37
40
|
}
|
38
41
|
}
|
39
|
-
}, [open, previousState, setCurrentStep, initialStep, totalSteps, componentName]);
|
42
|
+
}, [firstIncludedStep, open, previousState, setCurrentStep, initialStep, totalSteps, componentName]);
|
40
43
|
};
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Copyright IBM Corp. 2022, 2022
|
5
|
+
*
|
6
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
8
|
+
*/
|
9
|
+
import { useEffect } from 'react';
|
10
|
+
/**
|
11
|
+
* This useEffect makes sure that every CreateTearsheetStep/CreateFullPageStep reports back it's
|
12
|
+
* title, secondaryLabel, introStep, and shouldIncludeStep data so that it can be sent to the CreateInfluencer.
|
13
|
+
* @param {object} useResetCreateComponent
|
14
|
+
* @param {object} useResetCreateComponent.stepsContext
|
15
|
+
* @param {number} useResetCreateComponent.stepNumber
|
16
|
+
* @param {boolean} useResetCreateComponent.introStep
|
17
|
+
* @param {boolean} useResetCreateComponent.shouldIncludeStep
|
18
|
+
* @param {string} useResetCreateComponent.secondaryLabel
|
19
|
+
* @param {string} useResetCreateComponent.title
|
20
|
+
*/
|
21
|
+
|
22
|
+
export var useRetrieveStepData = function useRetrieveStepData(_ref) {
|
23
|
+
var stepsContext = _ref.stepsContext,
|
24
|
+
stepNumber = _ref.stepNumber,
|
25
|
+
introStep = _ref.introStep,
|
26
|
+
shouldIncludeStep = _ref.shouldIncludeStep,
|
27
|
+
secondaryLabel = _ref.secondaryLabel,
|
28
|
+
title = _ref.title;
|
29
|
+
useEffect(function () {
|
30
|
+
if (stepsContext) {
|
31
|
+
stepsContext.setStepData(function (prev) {
|
32
|
+
var stepItem = {
|
33
|
+
title: title,
|
34
|
+
secondaryLabel: secondaryLabel,
|
35
|
+
introStep: introStep,
|
36
|
+
shouldIncludeStep: shouldIncludeStep
|
37
|
+
};
|
38
|
+
var previousItem = prev[stepNumber - 1];
|
39
|
+
|
40
|
+
if ((previousItem === null || previousItem === void 0 ? void 0 : previousItem.title) !== stepItem.title || (previousItem === null || previousItem === void 0 ? void 0 : previousItem.secondaryLabel) !== stepItem.secondaryLabel || (previousItem === null || previousItem === void 0 ? void 0 : previousItem.introStep) !== stepItem.introStep || (previousItem === null || previousItem === void 0 ? void 0 : previousItem.shouldIncludeStep) !== stepItem.shouldIncludeStep) {
|
41
|
+
var clone = _toConsumableArray(prev);
|
42
|
+
|
43
|
+
clone[stepNumber - 1] = stepItem;
|
44
|
+
return clone;
|
45
|
+
}
|
46
|
+
|
47
|
+
return prev;
|
48
|
+
});
|
49
|
+
}
|
50
|
+
}, [shouldIncludeStep, title, secondaryLabel, introStep, stepsContext, stepNumber]);
|
51
|
+
};
|
@@ -0,0 +1,26 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2022, 2022
|
3
|
+
*
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
7
|
+
|
8
|
+
/**
|
9
|
+
* This utility will return the index of the last instance of an
|
10
|
+
* item in the given array of objects whose key is equal to the value
|
11
|
+
* parameter. If there are no matches, -1 is returned as similar to findIndex
|
12
|
+
* @param {Array<Object.*>} array
|
13
|
+
* @param {string} key
|
14
|
+
* @param {string|boolean|number} value
|
15
|
+
*/
|
16
|
+
export var lastIndexInArray = function lastIndexInArray(array, key, value) {
|
17
|
+
for (var i = array.length - 1; i >= 0; i--) {
|
18
|
+
var _array$i;
|
19
|
+
|
20
|
+
if (((_array$i = array[i]) === null || _array$i === void 0 ? void 0 : _array$i[key]) === value) {
|
21
|
+
return i + 1;
|
22
|
+
}
|
23
|
+
}
|
24
|
+
|
25
|
+
return -1;
|
26
|
+
};
|
@@ -46,7 +46,7 @@ var ActionSetButton = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
46
46
|
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
47
47
|
return /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, (0, _extends2.default)({}, rest, {
|
48
48
|
isExpressive: true,
|
49
|
-
className: (0, _classnames.default)(className, ["".concat(blockClass, "__action-button"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__action-button--ghost"), kind === 'ghost')]),
|
49
|
+
className: (0, _classnames.default)(className, ["".concat(blockClass, "__action-button"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__action-button--ghost"), kind === 'ghost' || kind === 'danger--ghost')]),
|
50
50
|
disabled: disabled || loading || false,
|
51
51
|
kind: kind,
|
52
52
|
onClick: onClick,
|
@@ -57,7 +57,7 @@ var ActionSetButton = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
57
57
|
|
58
58
|
ActionSetButton.displayName = 'ActionSetButton';
|
59
59
|
ActionSetButton.propTypes = _objectSpread(_objectSpread({}, _carbonComponentsReact.Button.PropTypes), {}, {
|
60
|
-
kind: _propTypes.default.oneOf(['ghost', 'secondary', 'primary']),
|
60
|
+
kind: _propTypes.default.oneOf(['ghost', 'danger--ghost', 'secondary', 'danger', 'primary']),
|
61
61
|
label: _propTypes.default.string,
|
62
62
|
loading: _propTypes.default.bool
|
63
63
|
});
|
@@ -90,13 +90,24 @@ var ActionSet = /*#__PURE__*/_react.default.forwardRef(function (_ref3, ref) {
|
|
90
90
|
rest = (0, _objectWithoutProperties2.default)(_ref3, _excluded2);
|
91
91
|
var buttons = actions && ((_actions$slice = actions.slice) === null || _actions$slice === void 0 ? void 0 : _actions$slice.call(actions, 0)) || []; // We stack the buttons in a xs/sm set, or if there are three or more in a md set.
|
92
92
|
|
93
|
-
var stacking = willStack(size, buttons.length); //
|
94
|
-
//
|
93
|
+
var stacking = willStack(size, buttons.length); // Order of button kinds: ghost first, then danger--ghost, then most other types,
|
94
|
+
// then danger, and finally primary
|
95
|
+
|
96
|
+
var buttonOrder = function buttonOrder(kind) {
|
97
|
+
var _ghost$dangerGhost$;
|
98
|
+
|
99
|
+
return (_ghost$dangerGhost$ = {
|
100
|
+
ghost: 1,
|
101
|
+
'danger--ghost': 2,
|
102
|
+
danger: 4,
|
103
|
+
primary: 5
|
104
|
+
}[kind]) !== null && _ghost$dangerGhost$ !== void 0 ? _ghost$dangerGhost$ : 3;
|
105
|
+
}; // order the actions with ghost/ghost-danger buttons first and primary/danger buttons last
|
106
|
+
// (or the opposite way if we're stacking)
|
107
|
+
|
95
108
|
|
96
109
|
buttons.sort(function (action1, action2) {
|
97
|
-
|
98
|
-
var kind2 = action2.kind || defaultKind;
|
99
|
-
return kind1 === 'ghost' || kind2 === 'primary' ? stacking ? 1 : -1 : kind1 === 'primary' || kind2 === 'ghost' ? stacking ? -1 : 1 : 0;
|
110
|
+
return (buttonOrder(action1.kind || defaultKind) - buttonOrder(action2.kind || defaultKind)) * (stacking ? -1 : 1);
|
100
111
|
});
|
101
112
|
return /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.ButtonSet, (0, _extends2.default)({}, rest, {
|
102
113
|
className: (0, _classnames.default)(blockClass, className, (_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "--row-single"), !stacking && buttons.length === 1), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "--row-double"), !stacking && buttons.length === 2), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "--row-triple"), !stacking && buttons.length === 3), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "--row-quadruple"), !stacking && buttons.length >= 4), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "--stacking"), stacking), _cx), "".concat(blockClass, "--").concat(size)),
|
@@ -147,13 +158,14 @@ ActionSet.validateActions = function (sizeFn) {
|
|
147
158
|
|
148
159
|
var primaryActions = countActions('primary');
|
149
160
|
var secondaryActions = countActions('secondary');
|
150
|
-
var
|
161
|
+
var dangerActions = countActions('danger');
|
162
|
+
var ghostActions = countActions('ghost') + countActions('danger--ghost');
|
151
163
|
stacking && actions > 3 && problems.push("you cannot have more than three actions in this size of ".concat(componentName));
|
152
164
|
actions > 4 && problems.push("you cannot have more than four actions in a ".concat(componentName));
|
153
165
|
primaryActions > 1 && problems.push("you cannot have more than one 'primary' action in a ".concat(componentName));
|
154
166
|
ghostActions > 1 && problems.push("you cannot have more than one 'ghost' action in a ".concat(componentName));
|
155
167
|
stacking && actions > 1 && ghostActions > 0 && problems.push("you cannot have a 'ghost' button in conjunction with other action types in this size of ".concat(componentName));
|
156
|
-
actions > primaryActions + secondaryActions + ghostActions && problems.push("you can only have 'primary', 'secondary' and 'ghost' buttons in a ".concat(componentName));
|
168
|
+
actions > primaryActions + secondaryActions + dangerActions + ghostActions && problems.push("you can only have 'primary', 'danger', 'secondary', 'ghost' and 'danger--ghost' buttons in a ".concat(componentName));
|
157
169
|
}
|
158
170
|
|
159
171
|
return problems.length > 0 ? new Error("Invalid ".concat(location, " `").concat(name, "` supplied to `").concat(componentName, "`: ").concat(problems.join(', and '), ".")) : null;
|
@@ -174,7 +186,7 @@ ActionSet.propTypes = {
|
|
174
186
|
* See https://react.carbondesignsystem.com/?path=/docs/components-button--default#component-api
|
175
187
|
*/
|
176
188
|
actions: (0, _propsHelper.allPropTypes)([ActionSet.validateActions(), _propTypes.default.arrayOf(_propTypes.default.shape(_objectSpread(_objectSpread({}, _carbonComponentsReact.Button.propTypes), {}, {
|
177
|
-
kind: _propTypes.default.oneOf(['ghost', 'secondary', 'primary']),
|
189
|
+
kind: _propTypes.default.oneOf(['ghost', 'danger--ghost', 'secondary', 'danger', 'primary']),
|
178
190
|
label: _propTypes.default.string,
|
179
191
|
loading: _propTypes.default.bool,
|
180
192
|
// we duplicate this Button prop to improve the DocGen here
|
@@ -11,22 +11,25 @@ exports.actionsOptions = exports.actionsMapping = exports.actionsLabels = void 0
|
|
11
11
|
* This source code is licensed under the Apache-2.0 license found in the
|
12
12
|
* LICENSE file in the root directory of this source tree.
|
13
13
|
*/
|
14
|
-
var actionsOptions = [0, 1, 2, 3, 4, 5, 6, 7];
|
14
|
+
var actionsOptions = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
15
15
|
exports.actionsOptions = actionsOptions;
|
16
16
|
var actionsLabels = {
|
17
17
|
0: 'None',
|
18
18
|
1: 'One button',
|
19
|
-
2: '
|
20
|
-
3: '
|
21
|
-
4: 'Two buttons
|
22
|
-
5: '
|
23
|
-
6: 'Three buttons
|
24
|
-
7: '
|
19
|
+
2: 'A danger button',
|
20
|
+
3: 'A ghost button',
|
21
|
+
4: 'Two buttons',
|
22
|
+
5: 'Two buttons with one ghost',
|
23
|
+
6: 'Three buttons',
|
24
|
+
7: 'Three buttons with one ghost',
|
25
|
+
8: 'Three buttons with one danger',
|
26
|
+
9: 'Four buttons with one ghost',
|
27
|
+
10: 'Four buttons with two danger'
|
25
28
|
};
|
26
29
|
exports.actionsLabels = actionsLabels;
|
27
30
|
|
28
31
|
var actionsMapping = function actionsMapping(labels, action) {
|
29
|
-
var _labels$primary, _labels$secondary, _labels$secondary2, _labels$ghost;
|
32
|
+
var _labels$primary, _labels$danger, _labels$secondary, _labels$secondary2, _labels$dangerGhost, _labels$ghost;
|
30
33
|
|
31
34
|
var act = function act(label, kind, key) {
|
32
35
|
var actionCall = action && action("Click on '".concat(label, "'"));
|
@@ -42,18 +45,23 @@ var actionsMapping = function actionsMapping(labels, action) {
|
|
42
45
|
};
|
43
46
|
|
44
47
|
var primary = act((_labels$primary = labels === null || labels === void 0 ? void 0 : labels.primary) !== null && _labels$primary !== void 0 ? _labels$primary : 'Primary', 'primary', 1);
|
45
|
-
var
|
46
|
-
var
|
47
|
-
var
|
48
|
+
var danger = act((_labels$danger = labels === null || labels === void 0 ? void 0 : labels.danger) !== null && _labels$danger !== void 0 ? _labels$danger : 'Danger', 'danger', 2);
|
49
|
+
var secondary = act((_labels$secondary = labels === null || labels === void 0 ? void 0 : labels.secondary) !== null && _labels$secondary !== void 0 ? _labels$secondary : 'Secondary', 'secondary', 3);
|
50
|
+
var secondary2 = act((_labels$secondary2 = labels === null || labels === void 0 ? void 0 : labels.secondary2) !== null && _labels$secondary2 !== void 0 ? _labels$secondary2 : 'Secondary', 'secondary', 4);
|
51
|
+
var dangerGhost = act((_labels$dangerGhost = labels === null || labels === void 0 ? void 0 : labels.dangerGhost) !== null && _labels$dangerGhost !== void 0 ? _labels$dangerGhost : 'Danger-ghost', 'danger--ghost', 5);
|
52
|
+
var ghost = act((_labels$ghost = labels === null || labels === void 0 ? void 0 : labels.ghost) !== null && _labels$ghost !== void 0 ? _labels$ghost : 'Ghost', 'ghost', 6);
|
48
53
|
return {
|
49
54
|
0: [],
|
50
55
|
1: [primary],
|
51
|
-
2: [
|
52
|
-
3: [
|
53
|
-
4: [primary,
|
54
|
-
5: [primary,
|
55
|
-
6: [primary, secondary,
|
56
|
-
7: [primary, secondary,
|
56
|
+
2: [danger],
|
57
|
+
3: [ghost],
|
58
|
+
4: [primary, secondary],
|
59
|
+
5: [primary, ghost],
|
60
|
+
6: [primary, secondary, secondary2],
|
61
|
+
7: [primary, secondary, ghost],
|
62
|
+
8: [danger, secondary, ghost],
|
63
|
+
9: [primary, secondary, secondary2, ghost],
|
64
|
+
10: [danger, secondary, secondary2, dangerGhost]
|
57
65
|
};
|
58
66
|
};
|
59
67
|
|