@carbon/ibm-products 1.2.4 → 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 +662 -313
- 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 +156 -81
- 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 +393 -81
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +2 -2
- package/css/index.css +615 -81
- 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/ActionSet/ActionSet.js +22 -10
- package/es/components/ActionSet/actions.js +25 -17
- package/es/components/AddSelect/AddSelect.js +157 -0
- package/es/components/AddSelect/index.js +7 -0
- package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +19 -15
- package/es/components/CancelableTextEdit/CancelableTextEdit.js +245 -0
- package/es/components/{CreateTearsheet/constants.js → CancelableTextEdit/index.js} +1 -2
- package/es/components/CreateFullPage/CreateFullPage.js +102 -258
- package/es/components/CreateFullPage/CreateFullPageStep.js +65 -13
- package/es/components/CreateFullPage/index.js +1 -2
- package/es/components/CreateInfluencer/CreateInfluencer.js +40 -220
- package/es/components/CreateTearsheet/CreateTearsheet.js +95 -146
- package/es/components/CreateTearsheet/CreateTearsheetStep.js +70 -20
- package/es/components/CreateTearsheet/index.js +0 -1
- package/es/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +87 -28
- package/es/components/CreateTearsheet/preview-components/MultiStepWithIntro.js +8 -6
- package/es/components/ExportModal/ExportModal.js +41 -12
- 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/SidePanel/SidePanel.js +1 -1
- 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/Tearsheet/Tearsheet.js +1 -1
- package/es/components/Tearsheet/TearsheetNarrow.js +1 -1
- package/es/components/Tearsheet/TearsheetShell.js +1 -1
- package/es/components/Toolbar/Toolbar.js +69 -8
- package/es/components/index.js +5 -1
- package/es/global/js/hooks/index.js +1 -0
- package/es/global/js/hooks/useCreateComponentFocus.js +15 -19
- package/es/global/js/hooks/useCreateComponentStepChange.js +69 -79
- package/es/global/js/hooks/useResetCreateComponent.js +7 -4
- package/es/global/js/hooks/useRetrieveStepData.js +51 -0
- package/es/global/js/hooks/useValidCreateStepCount.js +4 -7
- package/es/global/js/package-settings.js +5 -1
- package/es/global/js/utils/lastIndexInArray.js +26 -0
- package/es/global/js/utils/story-helper.js +1 -1
- package/lib/components/APIKeyModal/APIKeyModal.js +25 -29
- package/lib/components/ActionBar/ActionBar.js +4 -1
- package/lib/components/ActionSet/ActionSet.js +22 -10
- package/lib/components/ActionSet/actions.js +25 -17
- package/lib/components/AddSelect/AddSelect.js +178 -0
- package/lib/components/AddSelect/index.js +13 -0
- package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +18 -14
- package/lib/components/CancelableTextEdit/CancelableTextEdit.js +265 -0
- package/lib/components/CancelableTextEdit/index.js +13 -0
- package/lib/components/CreateFullPage/CreateFullPage.js +102 -258
- package/lib/components/CreateFullPage/CreateFullPageStep.js +68 -13
- package/lib/components/CreateFullPage/index.js +1 -9
- package/lib/components/CreateInfluencer/CreateInfluencer.js +38 -231
- package/lib/components/CreateTearsheet/CreateTearsheet.js +97 -148
- package/lib/components/CreateTearsheet/CreateTearsheetStep.js +72 -19
- package/lib/components/CreateTearsheet/index.js +0 -8
- package/lib/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +86 -34
- package/lib/components/CreateTearsheet/preview-components/MultiStepWithIntro.js +8 -6
- package/lib/components/ExportModal/ExportModal.js +38 -11
- 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/SidePanel/SidePanel.js +1 -1
- 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/Tearsheet/Tearsheet.js +1 -1
- package/lib/components/Tearsheet/TearsheetNarrow.js +1 -1
- package/lib/components/Tearsheet/TearsheetShell.js +1 -1
- package/lib/components/Toolbar/Toolbar.js +69 -6
- package/lib/components/index.js +33 -1
- package/lib/global/js/hooks/index.js +8 -0
- package/lib/global/js/hooks/useCreateComponentFocus.js +15 -19
- package/lib/global/js/hooks/useCreateComponentStepChange.js +69 -79
- package/lib/global/js/hooks/useResetCreateComponent.js +7 -4
- package/lib/global/js/hooks/useRetrieveStepData.js +62 -0
- package/lib/global/js/hooks/useValidCreateStepCount.js +4 -7
- package/lib/global/js/package-settings.js +5 -1
- package/lib/global/js/utils/lastIndexInArray.js +35 -0
- package/lib/global/js/utils/story-helper.js +1 -1
- package/package.json +22 -22
- package/scss/components/AddSelect/_add-select.scss +84 -0
- package/scss/components/AddSelect/_index.scss +10 -0
- package/scss/components/AddSelect/_storybook-styles.scss +6 -0
- package/scss/components/BreadcrumbWithOverflow/_breadcrumb-with-overflow.scss +19 -15
- package/scss/components/CancelableTextEdit/_cancelable-text-edit.scss +211 -0
- package/{es/components/CreateFullPage/constants.js → scss/components/CancelableTextEdit/_index.scss} +2 -2
- package/scss/components/CancelableTextEdit/_storybook-styles.scss +15 -0
- 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/StatusIcon/_status-icon.scss +2 -0
- package/scss/components/_index.scss +4 -0
- package/es/components/CreateFullPage/CreateFullPageSection.js +0 -53
- package/es/components/CreateTearsheet/CreateTearsheetSection.js +0 -83
- 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
@@ -2,20 +2,24 @@ 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,
|
15
|
+
onNext = _ref.onNext,
|
16
|
+
isSubmitDisabled = _ref.isSubmitDisabled,
|
17
|
+
setCurrentStep = _ref.setCurrentStep,
|
13
18
|
setIsSubmitting = _ref.setIsSubmitting,
|
14
19
|
setShouldViewAll = _ref.setShouldViewAll,
|
15
20
|
onClose = _ref.onClose,
|
16
21
|
onRequestSubmit = _ref.onRequestSubmit,
|
17
22
|
componentName = _ref.componentName,
|
18
|
-
getComponentSteps = _ref.getComponentSteps,
|
19
23
|
currentStep = _ref.currentStep,
|
20
24
|
shouldViewAll = _ref.shouldViewAll,
|
21
25
|
backButtonText = _ref.backButtonText,
|
@@ -28,8 +32,6 @@ export var useCreateComponentStepChange = function useCreateComponentStepChange(
|
|
28
32
|
setModalIsOpen = _ref.setModalIsOpen;
|
29
33
|
// useEffect to handle multi step logic
|
30
34
|
useEffect(function () {
|
31
|
-
var _getComponentSteps;
|
32
|
-
|
33
35
|
var onUnmount = function onUnmount() {
|
34
36
|
if (componentName !== 'CreateFullPage') {
|
35
37
|
setCurrentStep(0);
|
@@ -74,73 +76,47 @@ export var useCreateComponentStepChange = function useCreateComponentStepChange(
|
|
74
76
|
};
|
75
77
|
}();
|
76
78
|
|
77
|
-
var isSubmitDisabled = function isSubmitDisabled() {
|
78
|
-
var step = 0;
|
79
|
-
var submitDisabled = false;
|
80
|
-
var viewAllSubmitDisabled = false;
|
81
|
-
var createComponentSteps = getComponentSteps();
|
82
|
-
createComponentSteps.forEach(function (child) {
|
83
|
-
step++;
|
84
|
-
|
85
|
-
if (currentStep === step) {
|
86
|
-
submitDisabled = child.props.disableSubmit;
|
87
|
-
}
|
88
|
-
|
89
|
-
if (shouldViewAll && child.props.disableSubmit) {
|
90
|
-
viewAllSubmitDisabled = true;
|
91
|
-
}
|
92
|
-
});
|
93
|
-
|
94
|
-
if (!shouldViewAll) {
|
95
|
-
return submitDisabled;
|
96
|
-
}
|
97
|
-
|
98
|
-
return viewAllSubmitDisabled;
|
99
|
-
};
|
100
|
-
|
101
79
|
var handleNext = /*#__PURE__*/function () {
|
102
80
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
103
|
-
var createSteps;
|
104
81
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
105
82
|
while (1) {
|
106
83
|
switch (_context2.prev = _context2.next) {
|
107
84
|
case 0:
|
108
85
|
setIsSubmitting(true);
|
109
|
-
createSteps = getComponentSteps();
|
110
86
|
|
111
|
-
if (!
|
112
|
-
_context2.next =
|
87
|
+
if (!(typeof onNext === 'function')) {
|
88
|
+
_context2.next = 14;
|
113
89
|
break;
|
114
90
|
}
|
115
91
|
|
116
|
-
_context2.prev =
|
117
|
-
_context2.next =
|
118
|
-
return
|
92
|
+
_context2.prev = 2;
|
93
|
+
_context2.next = 5;
|
94
|
+
return onNext();
|
119
95
|
|
120
|
-
case
|
96
|
+
case 5:
|
121
97
|
continueToNextStep();
|
122
|
-
_context2.next =
|
98
|
+
_context2.next = 12;
|
123
99
|
break;
|
124
100
|
|
125
|
-
case
|
126
|
-
_context2.prev =
|
127
|
-
_context2.t0 = _context2["catch"](
|
101
|
+
case 8:
|
102
|
+
_context2.prev = 8;
|
103
|
+
_context2.t0 = _context2["catch"](2);
|
128
104
|
setIsSubmitting(false);
|
129
105
|
console.warn("".concat(componentName, " onNext error: ").concat(_context2.t0));
|
130
106
|
|
131
|
-
case
|
132
|
-
_context2.next =
|
107
|
+
case 12:
|
108
|
+
_context2.next = 15;
|
133
109
|
break;
|
134
110
|
|
135
|
-
case
|
111
|
+
case 14:
|
136
112
|
continueToNextStep();
|
137
113
|
|
138
|
-
case
|
114
|
+
case 15:
|
139
115
|
case "end":
|
140
116
|
return _context2.stop();
|
141
117
|
}
|
142
118
|
}
|
143
|
-
}, _callee2, null, [[
|
119
|
+
}, _callee2, null, [[2, 8]]);
|
144
120
|
}));
|
145
121
|
|
146
122
|
return function handleNext() {
|
@@ -150,51 +126,49 @@ export var useCreateComponentStepChange = function useCreateComponentStepChange(
|
|
150
126
|
|
151
127
|
var handleSubmit = /*#__PURE__*/function () {
|
152
128
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
153
|
-
var createSteps;
|
154
129
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
155
130
|
while (1) {
|
156
131
|
switch (_context3.prev = _context3.next) {
|
157
132
|
case 0:
|
158
|
-
setIsSubmitting(true);
|
159
|
-
createSteps = getComponentSteps(); // last step should have onNext as well
|
133
|
+
setIsSubmitting(true); // last step should have onNext as well
|
160
134
|
|
161
|
-
if (!
|
162
|
-
_context3.next =
|
135
|
+
if (!(typeof onNext === 'function')) {
|
136
|
+
_context3.next = 15;
|
163
137
|
break;
|
164
138
|
}
|
165
139
|
|
166
|
-
_context3.prev =
|
167
|
-
_context3.next =
|
168
|
-
return
|
140
|
+
_context3.prev = 2;
|
141
|
+
_context3.next = 5;
|
142
|
+
return onNext();
|
169
143
|
|
170
|
-
case
|
171
|
-
_context3.next =
|
144
|
+
case 5:
|
145
|
+
_context3.next = 7;
|
172
146
|
return handleOnRequestSubmit();
|
173
147
|
|
174
|
-
case
|
175
|
-
_context3.next =
|
148
|
+
case 7:
|
149
|
+
_context3.next = 13;
|
176
150
|
break;
|
177
151
|
|
178
|
-
case
|
179
|
-
_context3.prev =
|
180
|
-
_context3.t0 = _context3["catch"](
|
152
|
+
case 9:
|
153
|
+
_context3.prev = 9;
|
154
|
+
_context3.t0 = _context3["catch"](2);
|
181
155
|
setIsSubmitting(false);
|
182
156
|
console.warn("".concat(componentName, " onNext error: ").concat(_context3.t0));
|
183
157
|
|
184
|
-
case
|
185
|
-
_context3.next =
|
158
|
+
case 13:
|
159
|
+
_context3.next = 17;
|
186
160
|
break;
|
187
161
|
|
188
|
-
case
|
189
|
-
_context3.next =
|
162
|
+
case 15:
|
163
|
+
_context3.next = 17;
|
190
164
|
return handleOnRequestSubmit();
|
191
165
|
|
192
|
-
case
|
166
|
+
case 17:
|
193
167
|
case "end":
|
194
168
|
return _context3.stop();
|
195
169
|
}
|
196
170
|
}
|
197
|
-
}, _callee3, null, [[
|
171
|
+
}, _callee3, null, [[2, 9]]);
|
198
172
|
}));
|
199
173
|
|
200
174
|
return function handleSubmit() {
|
@@ -202,22 +176,29 @@ export var useCreateComponentStepChange = function useCreateComponentStepChange(
|
|
202
176
|
};
|
203
177
|
}();
|
204
178
|
|
205
|
-
if ((
|
206
|
-
var createSteps = getComponentSteps();
|
207
|
-
var total = createSteps.length;
|
179
|
+
if ((stepData === null || stepData === void 0 ? void 0 : stepData.length) > 0) {
|
208
180
|
var buttons = [];
|
209
181
|
|
210
|
-
if (
|
182
|
+
if ((stepData === null || stepData === void 0 ? void 0 : stepData.length) > 1 && !shouldViewAll) {
|
211
183
|
buttons.push({
|
212
184
|
key: 'create-action-button-back',
|
213
185
|
label: backButtonText,
|
214
186
|
onClick: function onClick() {
|
215
187
|
return setCurrentStep(function (prev) {
|
216
|
-
|
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;
|
217
198
|
});
|
218
199
|
},
|
219
200
|
kind: 'secondary',
|
220
|
-
disabled: currentStep ===
|
201
|
+
disabled: currentStep === firstIncludedStep
|
221
202
|
});
|
222
203
|
}
|
223
204
|
|
@@ -231,20 +212,29 @@ export var useCreateComponentStepChange = function useCreateComponentStepChange(
|
|
231
212
|
});
|
232
213
|
buttons.push({
|
233
214
|
key: 'create-action-button-submit',
|
234
|
-
label: shouldViewAll ? submitButtonText : currentStep <
|
235
|
-
onClick: shouldViewAll ? handleSubmit : currentStep <
|
236
|
-
disabled: isSubmitDisabled
|
215
|
+
label: shouldViewAll ? submitButtonText : currentStep < lastIncludedStep ? nextButtonText : submitButtonText,
|
216
|
+
onClick: shouldViewAll ? handleSubmit : currentStep < lastIncludedStep ? handleNext : handleSubmit,
|
217
|
+
disabled: isSubmitDisabled,
|
237
218
|
kind: 'primary',
|
238
219
|
loading: isSubmitting,
|
239
220
|
className: "".concat(componentBlockClass, "__create-button")
|
240
221
|
});
|
241
222
|
setCreateComponentActions(buttons);
|
242
223
|
}
|
243
|
-
}, [
|
224
|
+
}, [firstIncludedStep, lastIncludedStep, stepData, onNext, isSubmitDisabled, backButtonText, cancelButtonText, currentStep, onClose, nextButtonText, submitButtonText, onRequestSubmit, isSubmitting, shouldViewAll, componentBlockClass, componentName, continueToNextStep, setCurrentStep, setCreateComponentActions, setIsSubmitting, setShouldViewAll, setModalIsOpen]);
|
244
225
|
var continueToNextStep = useCallback(function () {
|
245
226
|
setIsSubmitting(false);
|
246
227
|
setCurrentStep(function (prev) {
|
247
|
-
|
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;
|
248
238
|
});
|
249
|
-
}, [setCurrentStep, setIsSubmitting]);
|
239
|
+
}, [setCurrentStep, setIsSubmitting, stepData]);
|
250
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
|
+
};
|
@@ -7,17 +7,14 @@
|
|
7
7
|
import { useEffect } from 'react';
|
8
8
|
/**
|
9
9
|
* Logs a warning to console if an invalid number of steps are used with the given CreateComponent
|
10
|
-
* @param {
|
10
|
+
* @param {number} stepCount
|
11
11
|
* @param {string} componentName
|
12
12
|
*/
|
13
13
|
|
14
|
-
export var useValidCreateStepCount = function useValidCreateStepCount(
|
14
|
+
export var useValidCreateStepCount = function useValidCreateStepCount(stepCount, componentName) {
|
15
15
|
useEffect(function () {
|
16
|
-
|
17
|
-
var total = createSteps.length;
|
18
|
-
|
19
|
-
if (total === 1) {
|
16
|
+
if (stepCount === 1) {
|
20
17
|
console.warn("".concat(componentName, ": ").concat(componentName, "s with one step are not permitted. If you require only one step, please use either the CreateTearsheetNarrow, CreateSidePanel, or CreateModal components."));
|
21
18
|
}
|
22
|
-
}, [
|
19
|
+
}, [stepCount, componentName]);
|
23
20
|
};
|
@@ -52,6 +52,8 @@ var defaults = {
|
|
52
52
|
UnauthorizedEmptyState: true,
|
53
53
|
UserProfileImage: true,
|
54
54
|
// other public components not yet reviewed and released:
|
55
|
+
MultiAddSelect: false,
|
56
|
+
SingleAddSelect: false,
|
55
57
|
LoadingBar: false,
|
56
58
|
ModifiedTabs: false,
|
57
59
|
Toolbar: false,
|
@@ -59,7 +61,9 @@ var defaults = {
|
|
59
61
|
ToolbarGroup: false,
|
60
62
|
WebTerminal: false,
|
61
63
|
EditSidePanel: false,
|
62
|
-
OptionsTile: false
|
64
|
+
OptionsTile: false,
|
65
|
+
CancelableTextEdit: false,
|
66
|
+
InlineEdit: false
|
63
67
|
/* new component flags here - comment used by generate CLI */
|
64
68
|
|
65
69
|
},
|
@@ -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
|
+
};
|
@@ -17,7 +17,7 @@ import { getPathForComponent } from '../../../../../core/story-structure';
|
|
17
17
|
|
18
18
|
export var getStoryTitle = function getStoryTitle(componentName) {
|
19
19
|
var title = // if the component isn't in the master structure, put it in a lost+found section
|
20
|
-
getPathForComponent('c', componentName) || "
|
20
|
+
getPathForComponent('c', componentName) || "Carbon for IBM Products/Lost + found/".concat(componentName); // add a canary tag if the component is public but not normally enabled
|
21
21
|
|
22
22
|
return !pkg.isComponentEnabled(componentName, true) && pkg.isComponentPublic(componentName, true) ? "".concat(title, "#canary") : title;
|
23
23
|
};
|
@@ -112,7 +112,6 @@ var APIKeyModal = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
112
112
|
currentStep = _useState6[0],
|
113
113
|
setCurrentStep = _useState6[1];
|
114
114
|
|
115
|
-
var inputRef = (0, _react.useRef)();
|
116
115
|
var copyRef = (0, _react.useRef)();
|
117
116
|
var apiKeyInputId = (0, _react.useRef)((0, _uuidv.default)());
|
118
117
|
var nameInputId = (0, _react.useRef)((0, _uuidv.default)());
|
@@ -126,11 +125,6 @@ var APIKeyModal = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
126
125
|
ref: copyRef
|
127
126
|
};
|
128
127
|
var blockClass = "".concat(_settings.pkg.prefix, "--apikey-modal");
|
129
|
-
(0, _react.useEffect)(function () {
|
130
|
-
if (inputRef.current && open) {
|
131
|
-
inputRef.current.focus();
|
132
|
-
}
|
133
|
-
}, [open]);
|
134
128
|
(0, _react.useEffect)(function () {
|
135
129
|
if (copyRef.current && open && apiKeyLoaded) {
|
136
130
|
copyRef.current.focus();
|
@@ -204,70 +198,72 @@ var APIKeyModal = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
204
198
|
};
|
205
199
|
|
206
200
|
var submitHandler = /*#__PURE__*/function () {
|
207
|
-
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
201
|
+
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(e) {
|
208
202
|
return _regenerator.default.wrap(function _callee$(_context) {
|
209
203
|
while (1) {
|
210
204
|
switch (_context.prev = _context.next) {
|
211
205
|
case 0:
|
206
|
+
e.preventDefault();
|
207
|
+
|
212
208
|
if (!hasNextStep) {
|
213
|
-
_context.next =
|
209
|
+
_context.next = 5;
|
214
210
|
break;
|
215
211
|
}
|
216
212
|
|
217
213
|
setCurrentStep(currentStep + 1);
|
218
|
-
_context.next =
|
214
|
+
_context.next = 22;
|
219
215
|
break;
|
220
216
|
|
221
|
-
case
|
217
|
+
case 5:
|
222
218
|
if (!apiKeyLoaded) {
|
223
|
-
_context.next =
|
219
|
+
_context.next = 21;
|
224
220
|
break;
|
225
221
|
}
|
226
222
|
|
227
223
|
if (!onCopy) {
|
228
|
-
_context.next =
|
224
|
+
_context.next = 10;
|
229
225
|
break;
|
230
226
|
}
|
231
227
|
|
232
228
|
onCopy(apiKey);
|
233
|
-
_context.next =
|
229
|
+
_context.next = 19;
|
234
230
|
break;
|
235
231
|
|
236
|
-
case
|
237
|
-
_context.prev =
|
238
|
-
_context.next =
|
232
|
+
case 10:
|
233
|
+
_context.prev = 10;
|
234
|
+
_context.next = 13;
|
239
235
|
return navigator.clipboard.writeText(apiKey);
|
240
236
|
|
241
|
-
case
|
242
|
-
_context.next =
|
237
|
+
case 13:
|
238
|
+
_context.next = 19;
|
243
239
|
break;
|
244
240
|
|
245
|
-
case
|
246
|
-
_context.prev =
|
247
|
-
_context.t0 = _context["catch"](
|
241
|
+
case 15:
|
242
|
+
_context.prev = 15;
|
243
|
+
_context.t0 = _context["catch"](10);
|
248
244
|
console.error(_context.t0);
|
249
245
|
setCopyError(true);
|
250
246
|
|
251
|
-
case
|
252
|
-
_context.next =
|
247
|
+
case 19:
|
248
|
+
_context.next = 22;
|
253
249
|
break;
|
254
250
|
|
255
|
-
case
|
251
|
+
case 21:
|
256
252
|
if (editing) {
|
257
253
|
onRequestEdit(name);
|
258
254
|
} else {
|
259
255
|
onRequestGenerate(name);
|
260
256
|
}
|
261
257
|
|
262
|
-
case
|
258
|
+
case 22:
|
263
259
|
case "end":
|
264
260
|
return _context.stop();
|
265
261
|
}
|
266
262
|
}
|
267
|
-
}, _callee, null, [[
|
263
|
+
}, _callee, null, [[10, 15]]);
|
268
264
|
}));
|
269
265
|
|
270
|
-
return function submitHandler() {
|
266
|
+
return function submitHandler(_x) {
|
271
267
|
return _ref2.apply(this, arguments);
|
272
268
|
};
|
273
269
|
}();
|
@@ -318,8 +314,8 @@ var APIKeyModal = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
318
314
|
value: name,
|
319
315
|
id: nameInputId.current,
|
320
316
|
disabled: loading,
|
321
|
-
|
322
|
-
|
317
|
+
required: nameRequired,
|
318
|
+
"data-modal-primary-focus": true
|
323
319
|
})), loading && /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.InlineLoading, {
|
324
320
|
description: loadingText,
|
325
321
|
className: "".concat(blockClass, "__loader")
|
@@ -38,7 +38,7 @@ var _ActionBarItem = require("./ActionBarItem");
|
|
38
38
|
var _ActionBarOverflowItems = require("./ActionBarOverflowItems");
|
39
39
|
|
40
40
|
var _excluded = ["actions", "className", "maxVisible", "menuOptionsClass", "onWidthChange", "overflowAriaLabel", "rightAlign"],
|
41
|
-
_excluded2 = ["key"],
|
41
|
+
_excluded2 = ["key", "id"],
|
42
42
|
_excluded3 = ["key"];
|
43
43
|
|
44
44
|
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); }
|
@@ -100,8 +100,11 @@ var ActionBar = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
100
100
|
key: "hidden-overflow-menu"
|
101
101
|
}), actions.map(function (_ref2) {
|
102
102
|
var key = _ref2.key,
|
103
|
+
id = _ref2.id,
|
103
104
|
rest = (0, _objectWithoutProperties2.default)(_ref2, _excluded2);
|
104
105
|
return /*#__PURE__*/_react.default.createElement(_ActionBarItem.ActionBarItem, (0, _extends2.default)({}, rest, {
|
106
|
+
// ensure id is not duplicated
|
107
|
+
"data-original-id": id,
|
105
108
|
key: "hidden-item-".concat(key),
|
106
109
|
className: "".concat(blockClass, "__hidden-sizing-item")
|
107
110
|
}));
|
@@ -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
|