@carbon/ibm-products 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/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
@@ -90,7 +90,7 @@ TearsheetNarrow.propTypes = _objectSpread({
|
|
90
90
|
actions: (0, _propsHelper.allPropTypes)([_ActionSet.ActionSet.validateActions(function () {
|
91
91
|
return 'lg';
|
92
92
|
}), _propTypes.default.arrayOf(_propTypes.default.shape(_objectSpread(_objectSpread({}, _carbonComponentsReact.Button.propTypes), {}, {
|
93
|
-
kind: _propTypes.default.oneOf(['ghost', 'secondary', 'primary']),
|
93
|
+
kind: _propTypes.default.oneOf(['ghost', 'danger--ghost', 'secondary', 'danger', 'primary']),
|
94
94
|
label: _propTypes.default.string,
|
95
95
|
loading: _propTypes.default.bool,
|
96
96
|
// we duplicate this Button prop to improve the DocGen here
|
@@ -311,7 +311,7 @@ TearsheetShell.propTypes = _objectSpread({
|
|
311
311
|
actions: _propTypes.default.arrayOf( // NB we don't include the validator here, as the component wrapping this
|
312
312
|
// one should ensure appropriate validation is done.
|
313
313
|
_propTypes.default.shape(_objectSpread(_objectSpread({}, _carbonComponentsReact.Button.propTypes), {}, {
|
314
|
-
kind: _propTypes.default.oneOf(['ghost', 'secondary', 'primary']),
|
314
|
+
kind: _propTypes.default.oneOf(['ghost', 'danger--ghost', 'secondary', 'danger', 'primary']),
|
315
315
|
label: _propTypes.default.string,
|
316
316
|
loading: _propTypes.default.bool,
|
317
317
|
// we duplicate this Button prop to improve the DocGen here
|
@@ -39,6 +39,12 @@ Object.defineProperty(exports, "useResetCreateComponent", {
|
|
39
39
|
return _useResetCreateComponent.useResetCreateComponent;
|
40
40
|
}
|
41
41
|
});
|
42
|
+
Object.defineProperty(exports, "useRetrieveStepData", {
|
43
|
+
enumerable: true,
|
44
|
+
get: function get() {
|
45
|
+
return _useRetrieveStepData.useRetrieveStepData;
|
46
|
+
}
|
47
|
+
});
|
42
48
|
Object.defineProperty(exports, "useValidCreateStepCount", {
|
43
49
|
enumerable: true,
|
44
50
|
get: function get() {
|
@@ -72,4 +78,6 @@ var _usePreviousValue = require("./usePreviousValue");
|
|
72
78
|
|
73
79
|
var _useResetCreateComponent = require("./useResetCreateComponent");
|
74
80
|
|
81
|
+
var _useRetrieveStepData = require("./useRetrieveStepData");
|
82
|
+
|
75
83
|
var _useValidCreateStepCount = require("./useValidCreateStepCount");
|
@@ -14,13 +14,15 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
|
|
14
14
|
var _react = require("react");
|
15
15
|
|
16
16
|
/**
|
17
|
-
* Copyright IBM Corp. 2021,
|
17
|
+
* Copyright IBM Corp. 2021, 2022
|
18
18
|
*
|
19
19
|
* This source code is licensed under the Apache-2.0 license found in the
|
20
20
|
* LICENSE file in the root directory of this source tree.
|
21
21
|
*/
|
22
22
|
var useCreateComponentStepChange = function useCreateComponentStepChange(_ref) {
|
23
|
-
var
|
23
|
+
var firstIncludedStep = _ref.firstIncludedStep,
|
24
|
+
lastIncludedStep = _ref.lastIncludedStep,
|
25
|
+
stepData = _ref.stepData,
|
24
26
|
onNext = _ref.onNext,
|
25
27
|
isSubmitDisabled = _ref.isSubmitDisabled,
|
26
28
|
setCurrentStep = _ref.setCurrentStep,
|
@@ -185,20 +187,29 @@ var useCreateComponentStepChange = function useCreateComponentStepChange(_ref) {
|
|
185
187
|
};
|
186
188
|
}();
|
187
189
|
|
188
|
-
if (
|
190
|
+
if ((stepData === null || stepData === void 0 ? void 0 : stepData.length) > 0) {
|
189
191
|
var buttons = [];
|
190
192
|
|
191
|
-
if (
|
193
|
+
if ((stepData === null || stepData === void 0 ? void 0 : stepData.length) > 1 && !shouldViewAll) {
|
192
194
|
buttons.push({
|
193
195
|
key: 'create-action-button-back',
|
194
196
|
label: backButtonText,
|
195
197
|
onClick: function onClick() {
|
196
198
|
return setCurrentStep(function (prev) {
|
197
|
-
|
199
|
+
// Find previous included step to render
|
200
|
+
// There will always be a previous step otherwise we will
|
201
|
+
// have disabled the back button since we have reached the first visible step
|
202
|
+
do {
|
203
|
+
var _stepData;
|
204
|
+
|
205
|
+
prev--;
|
206
|
+
} while (!((_stepData = stepData[prev - 1]) !== null && _stepData !== void 0 && _stepData.shouldIncludeStep));
|
207
|
+
|
208
|
+
return prev;
|
198
209
|
});
|
199
210
|
},
|
200
211
|
kind: 'secondary',
|
201
|
-
disabled: currentStep ===
|
212
|
+
disabled: currentStep === firstIncludedStep
|
202
213
|
});
|
203
214
|
}
|
204
215
|
|
@@ -212,8 +223,8 @@ var useCreateComponentStepChange = function useCreateComponentStepChange(_ref) {
|
|
212
223
|
});
|
213
224
|
buttons.push({
|
214
225
|
key: 'create-action-button-submit',
|
215
|
-
label: shouldViewAll ? submitButtonText : currentStep <
|
216
|
-
onClick: shouldViewAll ? handleSubmit : currentStep <
|
226
|
+
label: shouldViewAll ? submitButtonText : currentStep < lastIncludedStep ? nextButtonText : submitButtonText,
|
227
|
+
onClick: shouldViewAll ? handleSubmit : currentStep < lastIncludedStep ? handleNext : handleSubmit,
|
217
228
|
disabled: isSubmitDisabled,
|
218
229
|
kind: 'primary',
|
219
230
|
loading: isSubmitting,
|
@@ -221,13 +232,22 @@ var useCreateComponentStepChange = function useCreateComponentStepChange(_ref) {
|
|
221
232
|
});
|
222
233
|
setCreateComponentActions(buttons);
|
223
234
|
}
|
224
|
-
}, [
|
235
|
+
}, [firstIncludedStep, lastIncludedStep, stepData, onNext, isSubmitDisabled, backButtonText, cancelButtonText, currentStep, onClose, nextButtonText, submitButtonText, onRequestSubmit, isSubmitting, shouldViewAll, componentBlockClass, componentName, continueToNextStep, setCurrentStep, setCreateComponentActions, setIsSubmitting, setShouldViewAll, setModalIsOpen]);
|
225
236
|
var continueToNextStep = (0, _react.useCallback)(function () {
|
226
237
|
setIsSubmitting(false);
|
227
238
|
setCurrentStep(function (prev) {
|
228
|
-
|
239
|
+
// Find next included step to render
|
240
|
+
// There will always be a next step otherwise we will
|
241
|
+
// have reach the onSubmit
|
242
|
+
do {
|
243
|
+
var _stepData2;
|
244
|
+
|
245
|
+
prev++;
|
246
|
+
} while (!((_stepData2 = stepData[prev - 1]) !== null && _stepData2 !== void 0 && _stepData2.shouldIncludeStep));
|
247
|
+
|
248
|
+
return prev;
|
229
249
|
});
|
230
|
-
}, [setCurrentStep, setIsSubmitting]);
|
250
|
+
}, [setCurrentStep, setIsSubmitting, stepData]);
|
231
251
|
};
|
232
252
|
|
233
253
|
exports.useCreateComponentStepChange = useCreateComponentStepChange;
|
@@ -8,7 +8,7 @@ exports.useResetCreateComponent = void 0;
|
|
8
8
|
var _react = require("react");
|
9
9
|
|
10
10
|
/**
|
11
|
-
* Copyright IBM Corp. 2021,
|
11
|
+
* Copyright IBM Corp. 2021, 2022
|
12
12
|
*
|
13
13
|
* This source code is licensed under the Apache-2.0 license found in the
|
14
14
|
* LICENSE file in the root directory of this source tree.
|
@@ -17,6 +17,7 @@ var _react = require("react");
|
|
17
17
|
/**
|
18
18
|
* Resets the current step of the create component if it has been closed.
|
19
19
|
* @param {object} useResetCreateComponent - Create component that uses this custom hook
|
20
|
+
* @param {object} useResetCreateComponent.firstIncludedStep
|
20
21
|
* @param {object} useResetCreateComponent.previousState
|
21
22
|
* @param {boolean} useResetCreateComponent.open
|
22
23
|
* @param {Function} useResetCreateComponent.setCurrentStep
|
@@ -25,7 +26,8 @@ var _react = require("react");
|
|
25
26
|
* @param {string} useResetCreateComponent.componentName
|
26
27
|
*/
|
27
28
|
var useResetCreateComponent = function useResetCreateComponent(_ref) {
|
28
|
-
var
|
29
|
+
var firstIncludedStep = _ref.firstIncludedStep,
|
30
|
+
previousState = _ref.previousState,
|
29
31
|
open = _ref.open,
|
30
32
|
setCurrentStep = _ref.setCurrentStep,
|
31
33
|
initialStep = _ref.initialStep,
|
@@ -36,7 +38,8 @@ var useResetCreateComponent = function useResetCreateComponent(_ref) {
|
|
36
38
|
if (initialStep && totalSteps && Number(initialStep) <= Number(totalSteps) && Number(initialStep) > 0) {
|
37
39
|
setCurrentStep(Number(initialStep));
|
38
40
|
} else {
|
39
|
-
|
41
|
+
// default should be fist includedStep instead of just 1
|
42
|
+
setCurrentStep(firstIncludedStep);
|
40
43
|
} // An invalid initialStep value was provided, we'll default to rendering the first step in this scenario
|
41
44
|
|
42
45
|
|
@@ -44,7 +47,7 @@ var useResetCreateComponent = function useResetCreateComponent(_ref) {
|
|
44
47
|
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."));
|
45
48
|
}
|
46
49
|
}
|
47
|
-
}, [open, previousState, setCurrentStep, initialStep, totalSteps, componentName]);
|
50
|
+
}, [firstIncludedStep, open, previousState, setCurrentStep, initialStep, totalSteps, componentName]);
|
48
51
|
};
|
49
52
|
|
50
53
|
exports.useResetCreateComponent = useResetCreateComponent;
|
@@ -0,0 +1,62 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
6
|
+
value: true
|
7
|
+
});
|
8
|
+
exports.useRetrieveStepData = void 0;
|
9
|
+
|
10
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
11
|
+
|
12
|
+
var _react = require("react");
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Copyright IBM Corp. 2022, 2022
|
16
|
+
*
|
17
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
18
|
+
* LICENSE file in the root directory of this source tree.
|
19
|
+
*/
|
20
|
+
|
21
|
+
/**
|
22
|
+
* This useEffect makes sure that every CreateTearsheetStep/CreateFullPageStep reports back it's
|
23
|
+
* title, secondaryLabel, introStep, and shouldIncludeStep data so that it can be sent to the CreateInfluencer.
|
24
|
+
* @param {object} useResetCreateComponent
|
25
|
+
* @param {object} useResetCreateComponent.stepsContext
|
26
|
+
* @param {number} useResetCreateComponent.stepNumber
|
27
|
+
* @param {boolean} useResetCreateComponent.introStep
|
28
|
+
* @param {boolean} useResetCreateComponent.shouldIncludeStep
|
29
|
+
* @param {string} useResetCreateComponent.secondaryLabel
|
30
|
+
* @param {string} useResetCreateComponent.title
|
31
|
+
*/
|
32
|
+
var useRetrieveStepData = function useRetrieveStepData(_ref) {
|
33
|
+
var stepsContext = _ref.stepsContext,
|
34
|
+
stepNumber = _ref.stepNumber,
|
35
|
+
introStep = _ref.introStep,
|
36
|
+
shouldIncludeStep = _ref.shouldIncludeStep,
|
37
|
+
secondaryLabel = _ref.secondaryLabel,
|
38
|
+
title = _ref.title;
|
39
|
+
(0, _react.useEffect)(function () {
|
40
|
+
if (stepsContext) {
|
41
|
+
stepsContext.setStepData(function (prev) {
|
42
|
+
var stepItem = {
|
43
|
+
title: title,
|
44
|
+
secondaryLabel: secondaryLabel,
|
45
|
+
introStep: introStep,
|
46
|
+
shouldIncludeStep: shouldIncludeStep
|
47
|
+
};
|
48
|
+
var previousItem = prev[stepNumber - 1];
|
49
|
+
|
50
|
+
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) {
|
51
|
+
var clone = (0, _toConsumableArray2.default)(prev);
|
52
|
+
clone[stepNumber - 1] = stepItem;
|
53
|
+
return clone;
|
54
|
+
}
|
55
|
+
|
56
|
+
return prev;
|
57
|
+
});
|
58
|
+
}
|
59
|
+
}, [shouldIncludeStep, title, secondaryLabel, introStep, stepsContext, stepNumber]);
|
60
|
+
};
|
61
|
+
|
62
|
+
exports.useRetrieveStepData = useRetrieveStepData;
|
@@ -0,0 +1,35 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.lastIndexInArray = void 0;
|
7
|
+
|
8
|
+
/**
|
9
|
+
* Copyright IBM Corp. 2022, 2022
|
10
|
+
*
|
11
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
12
|
+
* LICENSE file in the root directory of this source tree.
|
13
|
+
*/
|
14
|
+
|
15
|
+
/**
|
16
|
+
* This utility will return the index of the last instance of an
|
17
|
+
* item in the given array of objects whose key is equal to the value
|
18
|
+
* parameter. If there are no matches, -1 is returned as similar to findIndex
|
19
|
+
* @param {Array<Object.*>} array
|
20
|
+
* @param {string} key
|
21
|
+
* @param {string|boolean|number} value
|
22
|
+
*/
|
23
|
+
var lastIndexInArray = function lastIndexInArray(array, key, value) {
|
24
|
+
for (var i = array.length - 1; i >= 0; i--) {
|
25
|
+
var _array$i;
|
26
|
+
|
27
|
+
if (((_array$i = array[i]) === null || _array$i === void 0 ? void 0 : _array$i[key]) === value) {
|
28
|
+
return i + 1;
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
return -1;
|
33
|
+
};
|
34
|
+
|
35
|
+
exports.lastIndexInArray = lastIndexInArray;
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@carbon/ibm-products",
|
3
3
|
"description": "Carbon for IBM Products",
|
4
|
-
"version": "1.
|
4
|
+
"version": "1.5.0",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"main": "lib/index.js",
|
7
7
|
"module": "es/index.js",
|
@@ -47,12 +47,12 @@
|
|
47
47
|
"postinstall": "carbon-telemetry collect --install",
|
48
48
|
"test": "jest --colors",
|
49
49
|
"//upgrade-dependencies": "# don't upgrade carbon (done globally), react/react-dom (explicit range peer dependency) or chalk (until we can load it as ESM)",
|
50
|
-
"upgrade-dependencies": "npm-check-updates -u --color --reject '/(carbon|^react$|^react-dom$|^chalk$)/'"
|
50
|
+
"upgrade-dependencies": "npm-check-updates -u --dep dev,peer,prod --color --reject '/(carbon|^react$|^react-dom$|^chalk$)/'"
|
51
51
|
},
|
52
52
|
"devDependencies": {
|
53
53
|
"@babel/cli": "^7.16.8",
|
54
|
-
"@babel/core": "^7.16.
|
55
|
-
"babel-preset-ibm-cloud-cognitive": "^0.14.
|
54
|
+
"@babel/core": "^7.16.12",
|
55
|
+
"babel-preset-ibm-cloud-cognitive": "^0.14.5",
|
56
56
|
"chalk": "^4.1.2",
|
57
57
|
"change-case": "^4.1.2",
|
58
58
|
"copyfiles": "^2.4.1",
|
@@ -60,8 +60,8 @@
|
|
60
60
|
"fs-extra": "^10.0.0",
|
61
61
|
"glob": "^7.2.0",
|
62
62
|
"jest": "^27.4.7",
|
63
|
-
"jest-config-ibm-cloud-cognitive": "^0.23.
|
64
|
-
"npm-check-updates": "^12.2.
|
63
|
+
"jest-config-ibm-cloud-cognitive": "^0.23.6",
|
64
|
+
"npm-check-updates": "^12.2.1",
|
65
65
|
"npm-run-all": "^4.1.5",
|
66
66
|
"rimraf": "^3.0.2",
|
67
67
|
"sass": "^1.49.0",
|
@@ -73,18 +73,18 @@
|
|
73
73
|
"react-resize-detector": "^7.0.0"
|
74
74
|
},
|
75
75
|
"peerDependencies": {
|
76
|
-
"@carbon/colors": "^10.
|
77
|
-
"@carbon/icons-react": "^10.
|
76
|
+
"@carbon/colors": "^10.35.0",
|
77
|
+
"@carbon/icons-react": "^10.45.0",
|
78
78
|
"@carbon/import-once": "^10.5.0",
|
79
|
-
"@carbon/layout": "^10.
|
80
|
-
"@carbon/motion": "^10.
|
81
|
-
"@carbon/themes": "^10.
|
82
|
-
"@carbon/type": "^10.
|
83
|
-
"carbon-components": "^10.
|
84
|
-
"carbon-components-react": "^7.
|
79
|
+
"@carbon/layout": "^10.35.0",
|
80
|
+
"@carbon/motion": "^10.27.0",
|
81
|
+
"@carbon/themes": "^10.49.0",
|
82
|
+
"@carbon/type": "^10.40.0",
|
83
|
+
"carbon-components": "^10.51.0",
|
84
|
+
"carbon-components-react": "^7.51.0",
|
85
85
|
"carbon-icons": "^7.0.7",
|
86
86
|
"react": "^16.8.6 || ^17.0.1",
|
87
87
|
"react-dom": "^16.8.6 || ^17.0.1"
|
88
88
|
},
|
89
|
-
"gitHead": "
|
89
|
+
"gitHead": "c87d8a538026632249a4f6e907b008efb1d50250"
|
90
90
|
}
|
@@ -111,6 +111,8 @@ $block-class: #{$pkg-prefix}--status-icon;
|
|
111
111
|
@each $theme in $themes {
|
112
112
|
@each $icon in $icons {
|
113
113
|
@each $theme-key in $themes {
|
114
|
+
.#{$prefix}--btn.#{$prefix}--btn--icon-only.#{$prefix}--tooltip__trigger
|
115
|
+
.#{$block-class}--#{$theme}.#{$block-class}--#{$theme-key}-#{$icon},
|
114
116
|
.#{$block-class}--#{$theme}.#{$block-class}--#{$theme-key}-#{$icon} {
|
115
117
|
@if $icon == in-progress {
|
116
118
|
@media (prefers-reduced-motion: reduce) {
|