@carbon/ibm-products 1.3.0 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +5102 -4711
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +9 -3
- package/css/index-full-carbon.min.css.map +1 -0
- package/css/index-without-carbon-released-only.css +189 -108
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +3 -3
- package/css/index-without-carbon-released-only.min.css.map +1 -0
- package/css/index-without-carbon.css +619 -236
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +9 -3
- package/css/index-without-carbon.min.css.map +1 -0
- package/css/index.css +950 -567
- package/css/index.css.map +1 -1
- package/css/index.min.css +9 -3
- package/css/index.min.css.map +1 -0
- 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 +141 -53
- package/es/components/AddSelect/AddSelectBreadcrumbs.js +56 -0
- package/es/components/AddSelect/AddSelectList.js +94 -0
- package/es/components/AddSelect/AddSelectSidebar.js +78 -0
- package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +24 -17
- package/es/components/CancelableTextEdit/CancelableTextEdit.js +62 -24
- package/es/components/Card/Card.js +6 -4
- 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/EmptyStates/EmptyState.js +1 -1
- package/es/components/EmptyStates/EmptyStateContent.js +2 -2
- package/es/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +1 -1
- package/es/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +1 -1
- package/es/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +1 -1
- package/es/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +1 -1
- package/es/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +1 -1
- package/es/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +1 -1
- package/es/components/ExportModal/ExportModal.js +41 -12
- package/es/components/ImportModal/ImportModal.js +2 -1
- package/es/components/InlineEdit/InlineEdit.js +397 -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/NotificationsPanel/NotificationsPanel.js +16 -3
- package/es/components/OptionsTile/OptionsTile.js +36 -15
- package/es/components/PageHeader/PageHeader.js +59 -35
- package/es/components/PageHeader/PageHeaderTitle.js +82 -7
- package/es/components/PageHeader/PageHeaderUtils.js +21 -2
- package/es/components/RemoveModal/RemoveModal.js +4 -2
- package/es/components/SidePanel/SidePanel.js +33 -16
- 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/WebTerminal/WebTerminal.js +1 -1
- package/es/components/index.js +4 -2
- 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 +4 -2
- package/es/global/js/utils/lastIndexInArray.js +26 -0
- package/es/settings.js +0 -5
- 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 +141 -50
- package/lib/components/AddSelect/AddSelectBreadcrumbs.js +71 -0
- package/lib/components/AddSelect/AddSelectList.js +112 -0
- package/lib/components/AddSelect/AddSelectSidebar.js +89 -0
- package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +23 -16
- package/lib/components/CancelableTextEdit/CancelableTextEdit.js +62 -23
- package/lib/components/Card/Card.js +6 -4
- 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/EmptyStates/EmptyState.js +1 -1
- package/lib/components/EmptyStates/EmptyStateContent.js +2 -2
- package/lib/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +1 -1
- package/lib/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +1 -1
- package/lib/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +1 -1
- package/lib/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +1 -1
- package/lib/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +1 -1
- package/lib/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +1 -1
- package/lib/components/ExportModal/ExportModal.js +38 -11
- package/lib/components/ImportModal/ImportModal.js +2 -1
- package/lib/components/InlineEdit/InlineEdit.js +413 -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/NotificationsPanel/NotificationsPanel.js +13 -1
- package/lib/components/OptionsTile/OptionsTile.js +36 -15
- package/lib/components/PageHeader/PageHeader.js +59 -35
- package/lib/components/PageHeader/PageHeaderTitle.js +91 -9
- package/lib/components/PageHeader/PageHeaderUtils.js +21 -2
- package/lib/components/RemoveModal/RemoveModal.js +4 -2
- package/lib/components/SidePanel/SidePanel.js +33 -16
- 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/WebTerminal/WebTerminal.js +1 -1
- package/lib/components/index.js +25 -9
- 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 +4 -2
- package/lib/global/js/utils/lastIndexInArray.js +35 -0
- package/lib/settings.js +0 -6
- package/package.json +24 -24
- package/scss/components/AddSelect/_add-select.scss +53 -8
- package/scss/components/BreadcrumbWithOverflow/_breadcrumb-with-overflow.scss +19 -15
- package/scss/components/BreadcrumbWithOverflow/_index.scss +1 -1
- package/scss/components/CancelableTextEdit/_cancelable-text-edit.scss +142 -70
- package/scss/components/CancelableTextEdit/_storybook-styles.scss +0 -7
- package/scss/components/CreateFullPage/_create-full-page.scss +4 -11
- package/scss/components/CreateInfluencer/_create-influencer.scss +4 -4
- package/scss/components/CreateTearsheet/_create-tearsheet.scss +6 -10
- package/scss/components/CreateTearsheetNarrow/_storybook-styles.scss +0 -6
- package/scss/components/EditSidePanel/_storybook-styles.scss +0 -8
- package/scss/components/InlineEdit/_index.scss +8 -0
- package/scss/components/InlineEdit/_inline-edit.scss +320 -0
- package/scss/components/InlineEdit/_storybook-styles.scss +21 -0
- package/scss/components/LoadingBar/_storybook-styles.scss +0 -5
- 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/NotificationsPanel/_notifications-panel.scss +2 -2
- package/scss/components/OptionsTile/_storybook-styles.scss +0 -7
- package/scss/components/PageHeader/_index.scss +1 -1
- package/scss/components/PageHeader/_page-header.scss +18 -5
- package/scss/components/ProductiveCard/_productive-card.scss +0 -4
- package/scss/components/SidePanel/_side-panel.scss +15 -6
- 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/_index.scss +1 -1
- package/scss/components/StatusIcon/_status-icon.scss +6 -4
- package/scss/components/TagSet/_index.scss +1 -1
- package/scss/components/UserProfileImage/_index.scss +1 -1
- package/scss/components/UserProfileImage/_user-profile-image.scss +2 -2
- package/scss/components/WebTerminal/_web-terminal.scss +2 -2
- package/scss/components/_index.scss +3 -1
- package/scss/global/styles/_project-settings.scss +5 -1
- package/es/components/CreateFullPage/CreateFullPageSection.js +0 -53
- package/es/components/CreateFullPage/constants.js +0 -8
- package/es/components/CreateTearsheet/CreateTearsheetSection.js +0 -83
- package/es/components/CreateTearsheet/constants.js +0 -8
- package/es/components/CreateTearsheet/preview-components/MultiStepWithSectionsTearsheet.js +0 -327
- package/es/generated/feature-flags/feature-flags.js +0 -15
- 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/generated/feature-flags/feature-flags.js +0 -22
- package/lib/global/js/utils/hasValidType.js +0 -110
- package/scss/generated/feature-flags/_feature-flags.scss +0 -19
@@ -1,37 +1,41 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
4
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
5
|
-
var _excluded = ["backButtonText", "cancelButtonText", "children", "className", "
|
4
|
+
var _excluded = ["backButtonText", "cancelButtonText", "children", "className", "modalDangerButtonText", "modalDescription", "modalSecondaryButtonText", "modalTitle", "nextButtonText", "onClose", "onRequestSubmit", "submitButtonText"];
|
6
5
|
|
7
6
|
/**
|
8
|
-
* Copyright IBM Corp. 2021,
|
7
|
+
* Copyright IBM Corp. 2021, 2022
|
9
8
|
*
|
10
9
|
* This source code is licensed under the Apache-2.0 license found in the
|
11
10
|
* LICENSE file in the root directory of this source tree.
|
12
11
|
*/
|
13
12
|
// Import portions of React that are needed.
|
14
|
-
import React, { useEffect,
|
13
|
+
import React, { useEffect, useState, createContext } from 'react'; // Other standard imports.
|
15
14
|
|
16
15
|
import PropTypes from 'prop-types';
|
17
16
|
import cx from 'classnames';
|
18
17
|
import { getDevtoolsProps } from '../../global/js/utils/devtools';
|
19
|
-
import { pkg } from '../../settings';
|
20
|
-
import { CREATE_FULL_PAGE_SECTION, CREATE_FULL_PAGE_STEP } from './constants'; // Carbon and package components we use.
|
18
|
+
import { pkg } from '../../settings'; // Carbon and package components we use.
|
21
19
|
|
22
20
|
import { Grid, ModalFooter, ComposedModal, ModalHeader, ModalBody, Button, Form } from 'carbon-components-react';
|
23
21
|
import { CreateInfluencer } from '../CreateInfluencer';
|
24
22
|
import { ActionSet } from '../ActionSet';
|
25
23
|
import { usePreviousValue, useValidCreateStepCount, useCreateComponentFocus, useCreateComponentStepChange } from '../../global/js/hooks';
|
26
|
-
import {
|
24
|
+
import { lastIndexInArray } from '../../global/js/utils/lastIndexInArray';
|
27
25
|
var blockClass = "".concat(pkg.prefix, "--create-full-page");
|
28
|
-
var componentName = 'CreateFullPage';
|
26
|
+
var componentName = 'CreateFullPage'; // This is a general context for the steps container
|
27
|
+
// containing information about the state of the container
|
28
|
+
// and providing some callback methods for steps to use
|
29
|
+
|
30
|
+
export var StepsContext = /*#__PURE__*/createContext(null); // This is a context supplied separately to each step in the container
|
31
|
+
// to let it know what number it is in the sequence of steps
|
32
|
+
|
33
|
+
export var StepNumberContext = /*#__PURE__*/createContext(-1);
|
29
34
|
export var CreateFullPage = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
30
35
|
var backButtonText = _ref.backButtonText,
|
31
36
|
cancelButtonText = _ref.cancelButtonText,
|
32
37
|
children = _ref.children,
|
33
38
|
className = _ref.className,
|
34
|
-
includeViewAllToggle = _ref.includeViewAllToggle,
|
35
39
|
modalDangerButtonText = _ref.modalDangerButtonText,
|
36
40
|
modalDescription = _ref.modalDescription,
|
37
41
|
modalSecondaryButtonText = _ref.modalSecondaryButtonText,
|
@@ -39,11 +43,7 @@ export var CreateFullPage = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
39
43
|
nextButtonText = _ref.nextButtonText,
|
40
44
|
onClose = _ref.onClose,
|
41
45
|
onRequestSubmit = _ref.onRequestSubmit,
|
42
|
-
sideNavAriaLabel = _ref.sideNavAriaLabel,
|
43
46
|
submitButtonText = _ref.submitButtonText,
|
44
|
-
viewAllToggleLabelText = _ref.viewAllToggleLabelText,
|
45
|
-
viewAllToggleOffLabelText = _ref.viewAllToggleOffLabelText,
|
46
|
-
viewAllToggleOnLabelText = _ref.viewAllToggleOnLabelText,
|
47
47
|
rest = _objectWithoutProperties(_ref, _excluded);
|
48
48
|
|
49
49
|
var _useState = useState([]),
|
@@ -61,49 +61,84 @@ export var CreateFullPage = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
61
61
|
currentStep = _useState6[0],
|
62
62
|
setCurrentStep = _useState6[1];
|
63
63
|
|
64
|
-
var _useState7 = useState(
|
64
|
+
var _useState7 = useState(false),
|
65
65
|
_useState8 = _slicedToArray(_useState7, 2),
|
66
|
-
|
67
|
-
|
66
|
+
isSubmitting = _useState8[0],
|
67
|
+
setIsSubmitting = _useState8[1];
|
68
68
|
|
69
69
|
var _useState9 = useState(false),
|
70
70
|
_useState10 = _slicedToArray(_useState9, 2),
|
71
|
-
|
72
|
-
|
71
|
+
modalIsOpen = _useState10[0],
|
72
|
+
setModalIsOpen = _useState10[1];
|
73
|
+
|
74
|
+
var previousState = usePreviousValue({
|
75
|
+
currentStep: currentStep,
|
76
|
+
open: open
|
77
|
+
});
|
73
78
|
|
74
79
|
var _useState11 = useState(false),
|
75
80
|
_useState12 = _slicedToArray(_useState11, 2),
|
76
|
-
|
77
|
-
|
81
|
+
isDisabled = _useState12[0],
|
82
|
+
setIsDisabled = _useState12[1];
|
83
|
+
|
84
|
+
var _useState13 = useState(),
|
85
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
86
|
+
onNext = _useState14[0],
|
87
|
+
_setOnNext = _useState14[1];
|
88
|
+
|
89
|
+
var _useState15 = useState(),
|
90
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
91
|
+
onMount = _useState16[0],
|
92
|
+
_setOnMount = _useState16[1];
|
93
|
+
|
94
|
+
var _useState17 = useState([]),
|
95
|
+
_useState18 = _slicedToArray(_useState17, 2),
|
96
|
+
stepData = _useState18[0],
|
97
|
+
setStepData = _useState18[1];
|
98
|
+
|
99
|
+
var _useState19 = useState(1),
|
100
|
+
_useState20 = _slicedToArray(_useState19, 2),
|
101
|
+
firstIncludedStep = _useState20[0],
|
102
|
+
setFirstIncludedStep = _useState20[1];
|
103
|
+
|
104
|
+
var _useState21 = useState(null),
|
105
|
+
_useState22 = _slicedToArray(_useState21, 2),
|
106
|
+
lastIncludedStep = _useState22[0],
|
107
|
+
setLastIncludedStep = _useState22[1];
|
78
108
|
|
79
|
-
|
109
|
+
useEffect(function () {
|
110
|
+
var firstItem = stepData.findIndex(function (item) {
|
111
|
+
return item === null || item === void 0 ? void 0 : item.shouldIncludeStep;
|
112
|
+
}) + 1;
|
113
|
+
var lastItem = lastIndexInArray(stepData, 'shouldIncludeStep', true);
|
114
|
+
|
115
|
+
if (firstItem !== firstIncludedStep) {
|
116
|
+
setFirstIncludedStep(firstItem);
|
117
|
+
}
|
118
|
+
|
119
|
+
if (lastItem !== lastIncludedStep) {
|
120
|
+
setLastIncludedStep(lastItem);
|
121
|
+
}
|
122
|
+
}, [stepData, firstIncludedStep, lastIncludedStep]);
|
123
|
+
useCreateComponentFocus({
|
124
|
+
previousState: previousState,
|
80
125
|
currentStep: currentStep,
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
var _childrenArray$;
|
86
|
-
|
87
|
-
var steps = [];
|
88
|
-
var childrenArray = Array.isArray(children) ? children : [children];
|
89
|
-
var extractedChildren = childrenArray && ((_childrenArray$ = childrenArray[0]) === null || _childrenArray$ === void 0 ? void 0 : _childrenArray$.type) === React.Fragment ? childrenArray[0].props.children : childrenArray;
|
90
|
-
extractedChildren.forEach(function (child) {
|
91
|
-
if (isFullPageStep(child)) {
|
92
|
-
steps.push(child);
|
93
|
-
}
|
94
|
-
});
|
95
|
-
return steps;
|
96
|
-
}, [children]);
|
97
|
-
useCreateComponentFocus(previousState, currentStep, getFullPageSteps, blockClass);
|
98
|
-
useValidCreateStepCount(getFullPageSteps, componentName);
|
126
|
+
blockClass: blockClass,
|
127
|
+
onMount: onMount
|
128
|
+
});
|
129
|
+
useValidCreateStepCount(stepData.length, componentName);
|
99
130
|
useCreateComponentStepChange({
|
131
|
+
firstIncludedStep: firstIncludedStep,
|
132
|
+
lastIncludedStep: lastIncludedStep,
|
133
|
+
stepData: stepData,
|
134
|
+
onNext: onNext,
|
135
|
+
isSubmitDisabled: isDisabled,
|
100
136
|
setCurrentStep: setCurrentStep,
|
101
137
|
setIsSubmitting: setIsSubmitting,
|
102
138
|
setShouldViewAll: setShouldViewAll,
|
103
139
|
onClose: onClose,
|
104
140
|
onRequestSubmit: onRequestSubmit,
|
105
141
|
componentName: componentName,
|
106
|
-
getComponentSteps: getFullPageSteps,
|
107
142
|
currentStep: currentStep,
|
108
143
|
shouldViewAll: shouldViewAll,
|
109
144
|
backButtonText: backButtonText,
|
@@ -114,200 +149,18 @@ export var CreateFullPage = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
114
149
|
componentBlockClass: blockClass,
|
115
150
|
setCreateComponentActions: setCreateFullPageActions,
|
116
151
|
setModalIsOpen: setModalIsOpen
|
117
|
-
}); //
|
118
|
-
// inside of the CreateFullPageSteps when the viewAll toggle is provided and turned on.
|
119
|
-
// currently, we are not supporting the use of FullPageSections -- this may be a future feature
|
152
|
+
}); // currently, we are not supporting the use of 'view all' toggle state
|
120
153
|
|
121
154
|
/* istanbul ignore next */
|
122
155
|
|
123
|
-
useEffect(function () {
|
124
|
-
if (includeViewAllToggle && shouldViewAll) {
|
125
|
-
var childrenArray = Array.isArray(children) ? children : [children];
|
126
|
-
var fullPageStepComponents = childrenArray.filter(function (child) {
|
127
|
-
return isFullPageStep(child);
|
128
|
-
});
|
129
|
-
var fullPageSectionComponents = [];
|
130
|
-
fullPageStepComponents.forEach(function (child, index) {
|
131
|
-
// We have received children for a FullPageStep
|
132
|
-
if (shouldViewAll && typeof child.props.children !== 'undefined') {
|
133
|
-
// Only a string was provided as children of CreateFullPageStep, this is not permitted when using view all toggle
|
134
|
-
if (typeof child.props.children === 'string') {
|
135
|
-
console.warn("".concat(componentName, ": You must have at least one CreateFullPageSection component in a CreateFullPageStep when using the 'includeViewAllToggle' prop."));
|
136
|
-
} else {
|
137
|
-
// The FullPageStep has an array of children, lets check each one to see if it is a FullPageSection
|
138
|
-
if (child.props.children.length) {
|
139
|
-
child.props.children.forEach(function (stepChild) {
|
140
|
-
if (isFullPageSection(stepChild)) {
|
141
|
-
fullPageSectionComponents.push(stepChild);
|
142
|
-
}
|
143
|
-
});
|
144
|
-
} else {
|
145
|
-
// The FullPageStep only has a single React element as a child, lets check to see if it is a FullPageSection
|
146
|
-
if (isFullPageSection(child.props.children)) {
|
147
|
-
fullPageSectionComponents.push(child.props.children);
|
148
|
-
}
|
149
|
-
}
|
150
|
-
}
|
151
|
-
} // If there are fewer CreateFullPageSection components than CreateFullPageStep components
|
152
|
-
// it means that each CreateFullPageStep does not have at least one CreateFullPageSection
|
153
|
-
// this is not permitted when using view all toggle
|
154
|
-
|
155
|
-
|
156
|
-
if (fullPageSectionComponents.length < fullPageStepComponents.length && index === fullPageStepComponents.length - 1 // wait until we've finished checking each FullPageStep before giving a warning
|
157
|
-
) {
|
158
|
-
console.warn("".concat(componentName, ": You must have at least one CreateFullPageSection component in a CreateFullPageStep when using the 'includeViewAllToggle' prop."));
|
159
|
-
} // We have received a single child element, lets check to see that it is
|
160
|
-
// a CreateFullPageSection component, if it is not we should add a console
|
161
|
-
// warning, as each CreateFullPageStep required at least one CreateFullPageSection,
|
162
|
-
// when using the view all toggle
|
163
|
-
|
164
|
-
|
165
|
-
if (shouldViewAll && typeof child.props.children !== 'undefined' && !child.props.children.length) {
|
166
|
-
if (!isFullPageSection(child.props.children)) {
|
167
|
-
console.warn("".concat(componentName, ": You must have at least one CreateFullPageSection component in a CreateFullPageStep when using the 'includeViewAllToggle' prop."));
|
168
|
-
}
|
169
|
-
}
|
170
|
-
});
|
171
|
-
}
|
172
|
-
}, [includeViewAllToggle, shouldViewAll, children]); // check if child is a full page step component
|
173
|
-
|
174
|
-
var isFullPageStep = function isFullPageStep(child) {
|
175
|
-
if (child && child.props && child.props.type === CREATE_FULL_PAGE_STEP) {
|
176
|
-
return true;
|
177
|
-
}
|
178
|
-
|
179
|
-
return false;
|
180
|
-
}; // check if child is a full page section component
|
181
|
-
// currently, we are not supporting the use of FullPageSections -- this may be a future feature
|
182
|
-
|
183
|
-
/* istanbul ignore next */
|
184
|
-
|
185
|
-
|
186
|
-
var isFullPageSection = function isFullPageSection(child) {
|
187
|
-
if (child && child.props && child.props.type === CREATE_FULL_PAGE_SECTION) {
|
188
|
-
return true;
|
189
|
-
}
|
190
|
-
|
191
|
-
return false;
|
192
|
-
}; // renders the step progression components in the left influencer area
|
193
|
-
|
194
|
-
|
195
|
-
var getFullPageComponents = function getFullPageComponents(childrenElements) {
|
196
|
-
var childrenArray = Array.isArray(childrenElements) ? childrenElements : [childrenElements];
|
197
|
-
var fullPageStepComponents = childrenArray.filter(function (child) {
|
198
|
-
return isFullPageStep(child);
|
199
|
-
});
|
200
|
-
var sectionChildElements = [];
|
201
|
-
fullPageStepComponents.forEach(function (child) {
|
202
|
-
// we have received an array of children, lets check to see that each child is
|
203
|
-
// a FullPageSection component before adding it to sectionChildElements
|
204
|
-
// currently, we are not supporting the use of FullPageSections -- this may be a future feature
|
205
|
-
|
206
|
-
/* istanbul ignore next */
|
207
|
-
if (shouldViewAll && child.props.children.length) {
|
208
|
-
child.props.children.forEach(function (stepChild) {
|
209
|
-
if (isFullPageSection(stepChild)) {
|
210
|
-
sectionChildElements.push(stepChild);
|
211
|
-
}
|
212
|
-
});
|
213
|
-
} // we have received a single child element, lets check to see that it is
|
214
|
-
// a CreateFullPageSection component before adding it to sectionChildElements
|
215
|
-
|
216
|
-
|
217
|
-
if (shouldViewAll && typeof child.props.children !== 'undefined' && !child.props.children.length) {
|
218
|
-
// currently, we are not supporting the use of FullPageSections -- this may be a future feature
|
219
|
-
|
220
|
-
/* istanbul ignore next */
|
221
|
-
if (isFullPageSection(child.props.children)) {
|
222
|
-
sectionChildElements.push(child.props.children);
|
223
|
-
}
|
224
|
-
}
|
225
|
-
});
|
226
|
-
return {
|
227
|
-
sections: sectionChildElements,
|
228
|
-
steps: fullPageStepComponents
|
229
|
-
};
|
230
|
-
}; // renders all children (CreateFullPageSteps and regular children elements)
|
231
|
-
|
232
|
-
|
233
|
-
var renderChildren = function renderChildren(childrenElements) {
|
234
|
-
var step = 0;
|
235
|
-
var childrenArray = Array.isArray(childrenElements) ? childrenElements : [childrenElements];
|
236
|
-
var indexOfLastFullPageStep = childrenArray.map(function (el) {
|
237
|
-
var _el$props;
|
238
|
-
|
239
|
-
return el === null || el === void 0 ? void 0 : (_el$props = el.props) === null || _el$props === void 0 ? void 0 : _el$props.type;
|
240
|
-
}).lastIndexOf(CREATE_FULL_PAGE_STEP);
|
241
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, childrenArray.map(function (child, stepIndex) {
|
242
|
-
var _cx;
|
243
|
-
|
244
|
-
if (!isFullPageStep(child)) {
|
245
|
-
return child;
|
246
|
-
}
|
247
|
-
|
248
|
-
step++;
|
249
|
-
return /*#__PURE__*/React.cloneElement(child, {
|
250
|
-
className: cx(child.props.className, (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__step--hidden-step"), !shouldViewAll && currentStep !== step), _defineProperty(_cx, "".concat(blockClass, "__step--visible-step"), currentStep === step), _cx)),
|
251
|
-
key: "key_".concat(stepIndex)
|
252
|
-
}, /*#__PURE__*/React.createElement(React.Fragment, null, renderStepChildren(child.props.children, indexOfLastFullPageStep === step - 1)));
|
253
|
-
}));
|
254
|
-
};
|
255
|
-
|
256
|
-
var renderStepChildren = function renderStepChildren(fullPageStepComponent, isLastFullPageStep) {
|
257
|
-
var fullPageStepComponents = Array.isArray(fullPageStepComponent) ? fullPageStepComponent : [fullPageStepComponent];
|
258
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, fullPageStepComponents.map(function (child, index) {
|
259
|
-
var _cx2;
|
260
|
-
|
261
|
-
if (!isFullPageSection(child)) {
|
262
|
-
return child;
|
263
|
-
} // Needed to be able to not render the divider
|
264
|
-
// line on the last section of the last step
|
265
|
-
// currently, we are not supporting the use of FullPageSections -- this may be a future feature
|
266
|
-
|
267
|
-
/* istanbul ignore next */
|
268
|
-
|
269
|
-
|
270
|
-
var isLastSectionOfLastStep = isLastFullPageStep && fullPageStepComponents.length - 1 === index;
|
271
|
-
/* istanbul ignore next */
|
272
|
-
|
273
|
-
return /*#__PURE__*/React.cloneElement(child, {
|
274
|
-
className: cx(child.props.className, (_cx2 = {}, _defineProperty(_cx2, "".concat(blockClass, "__step--hidden-section"), child.props.viewAllOnly && !shouldViewAll), _defineProperty(_cx2, "".concat(blockClass, "__step--visible-section"), !child.props.viewAllOnly || child.props.viewAllOnly && shouldViewAll), _cx2)),
|
275
|
-
key: "key_".concat(index)
|
276
|
-
}, /*#__PURE__*/React.createElement(React.Fragment, null, shouldViewAll && /*#__PURE__*/React.createElement("h4", {
|
277
|
-
className: "".concat(blockClass, "__step-title")
|
278
|
-
}, child.props.title), child, shouldViewAll && !isLastSectionOfLastStep && /*#__PURE__*/React.createElement("span", {
|
279
|
-
className: "".concat(blockClass, "__section-divider")
|
280
|
-
})));
|
281
|
-
}));
|
282
|
-
}; // currently, we are not supporting the use of 'view all' toggle state or CreateFullPageSection -- this may be a future feature
|
283
|
-
|
284
|
-
/* istanbul ignore next */
|
285
|
-
|
286
|
-
|
287
156
|
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
288
157
|
ref: ref,
|
289
158
|
className: cx(blockClass, className)
|
290
159
|
}, getDevtoolsProps(componentName)), /*#__PURE__*/React.createElement("div", {
|
291
160
|
className: "".concat(blockClass, "__influencer")
|
292
161
|
}, /*#__PURE__*/React.createElement(CreateInfluencer, {
|
293
|
-
|
294
|
-
|
295
|
-
createComponentName: componentName,
|
296
|
-
currentStep: currentStep,
|
297
|
-
createComponents: getFullPageComponents(children),
|
298
|
-
includeViewAllToggle: includeViewAllToggle,
|
299
|
-
handleToggleState: function handleToggleState(toggleState) {
|
300
|
-
return setShouldViewAll(toggleState);
|
301
|
-
},
|
302
|
-
handleActiveSectionIndex: function handleActiveSectionIndex(index) {
|
303
|
-
return setActiveSectionIndex(index);
|
304
|
-
},
|
305
|
-
previousState: previousState,
|
306
|
-
sideNavAriaLabel: sideNavAriaLabel,
|
307
|
-
toggleState: shouldViewAll,
|
308
|
-
viewAllToggleLabelText: viewAllToggleLabelText,
|
309
|
-
viewAllToggleOffLabelText: viewAllToggleOffLabelText,
|
310
|
-
viewAllToggleOnLabelText: viewAllToggleOnLabelText
|
162
|
+
stepData: stepData,
|
163
|
+
currentStep: currentStep
|
311
164
|
})), /*#__PURE__*/React.createElement("div", {
|
312
165
|
className: "".concat(blockClass, "__body")
|
313
166
|
}, /*#__PURE__*/React.createElement("div", {
|
@@ -316,7 +169,28 @@ export var CreateFullPage = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
316
169
|
className: "".concat(blockClass, "__content")
|
317
170
|
}, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Form, {
|
318
171
|
className: "".concat(blockClass, "__form")
|
319
|
-
},
|
172
|
+
}, /*#__PURE__*/React.createElement(StepsContext.Provider, {
|
173
|
+
value: {
|
174
|
+
currentStep: currentStep,
|
175
|
+
setIsDisabled: setIsDisabled,
|
176
|
+
setOnNext: function setOnNext(fn) {
|
177
|
+
return _setOnNext(function () {
|
178
|
+
return fn;
|
179
|
+
});
|
180
|
+
},
|
181
|
+
setOnMount: function setOnMount(fn) {
|
182
|
+
return _setOnMount(function () {
|
183
|
+
return fn;
|
184
|
+
});
|
185
|
+
},
|
186
|
+
setStepData: setStepData,
|
187
|
+
stepData: stepData
|
188
|
+
}
|
189
|
+
}, React.Children.map(children, function (child, index) {
|
190
|
+
return /*#__PURE__*/React.createElement(StepNumberContext.Provider, {
|
191
|
+
value: index + 1
|
192
|
+
}, child);
|
193
|
+
}))))), /*#__PURE__*/React.createElement(ActionSet, {
|
320
194
|
className: "".concat(blockClass, "__buttons"),
|
321
195
|
actions: createFullPageActions,
|
322
196
|
size: "max"
|
@@ -361,22 +235,13 @@ CreateFullPage.propTypes = {
|
|
361
235
|
/**
|
362
236
|
* The main content of the full page
|
363
237
|
*/
|
364
|
-
children:
|
365
|
-
componentName: componentName,
|
366
|
-
childType: CREATE_FULL_PAGE_STEP
|
367
|
-
}),
|
238
|
+
children: PropTypes.node,
|
368
239
|
|
369
240
|
/**
|
370
241
|
* Provide an optional class to be applied to the containing node.
|
371
242
|
*/
|
372
243
|
className: PropTypes.string,
|
373
244
|
|
374
|
-
/**
|
375
|
-
* @ignore
|
376
|
-
* An optional prop that provides a toggle element in the left side influencer panel
|
377
|
-
*/
|
378
|
-
includeViewAllToggle: PropTypes.bool,
|
379
|
-
|
380
245
|
/**
|
381
246
|
* The primary 'danger' button text in the modal
|
382
247
|
*/
|
@@ -429,26 +294,5 @@ CreateFullPage.propTypes = {
|
|
429
294
|
/**
|
430
295
|
* The main title of the full page, displayed in the header area.
|
431
296
|
*/
|
432
|
-
title: PropTypes.node
|
433
|
-
|
434
|
-
/**
|
435
|
-
* @ignore
|
436
|
-
* Sets the label text for the view all toggle component
|
437
|
-
*/
|
438
|
-
viewAllToggleLabelText: PropTypes.string,
|
439
|
-
|
440
|
-
/**
|
441
|
-
* @ignore
|
442
|
-
* Sets the label text for the view all toggle `off` text
|
443
|
-
*/
|
444
|
-
viewAllToggleOffLabelText: PropTypes.string,
|
445
|
-
|
446
|
-
/**
|
447
|
-
* @ignore
|
448
|
-
* Sets the label text for the view all toggle `on` text
|
449
|
-
*/
|
450
|
-
viewAllToggleOnLabelText: PropTypes.string
|
451
|
-
};
|
452
|
-
CreateFullPage.defaultProps = {
|
453
|
-
includeViewAllToggle: false
|
297
|
+
title: PropTypes.node
|
454
298
|
};
|
@@ -1,27 +1,77 @@
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
3
|
+
|
1
4
|
/**
|
2
|
-
* Copyright IBM Corp. 2021,
|
5
|
+
* Copyright IBM Corp. 2021, 2022
|
3
6
|
*
|
4
7
|
* This source code is licensed under the Apache-2.0 license found in the
|
5
8
|
* LICENSE file in the root directory of this source tree.
|
6
9
|
*/
|
7
|
-
import React, { forwardRef } from 'react';
|
10
|
+
import React, { forwardRef, useContext, useEffect, useState } from 'react';
|
8
11
|
import PropTypes from 'prop-types';
|
9
12
|
import cx from 'classnames';
|
10
13
|
import { pkg } from '../../settings';
|
11
|
-
import { CREATE_FULL_PAGE_STEP } from './constants.js';
|
12
14
|
import { FormGroup } from 'carbon-components-react';
|
15
|
+
import { StepsContext, StepNumberContext } from './CreateFullPage';
|
16
|
+
import { usePreviousValue, useRetrieveStepData } from '../../global/js/hooks';
|
17
|
+
import pconsole from '../../global/js/utils/pconsole';
|
13
18
|
var componentName = 'CreateFullPageStep';
|
14
19
|
var blockClass = "".concat(pkg.prefix, "--create-full-page__step");
|
15
20
|
export var CreateFullPageStep = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
21
|
+
var _cx;
|
22
|
+
|
16
23
|
var children = _ref.children,
|
17
24
|
className = _ref.className,
|
18
25
|
subtitle = _ref.subtitle,
|
19
26
|
description = _ref.description,
|
27
|
+
disableSubmit = _ref.disableSubmit,
|
28
|
+
includeStep = _ref.includeStep,
|
29
|
+
introStep = _ref.introStep,
|
20
30
|
title = _ref.title,
|
21
31
|
hasFieldset = _ref.hasFieldset,
|
22
|
-
fieldsetLegendText = _ref.fieldsetLegendText
|
23
|
-
|
24
|
-
|
32
|
+
fieldsetLegendText = _ref.fieldsetLegendText,
|
33
|
+
onNext = _ref.onNext,
|
34
|
+
onMount = _ref.onMount,
|
35
|
+
secondaryLabel = _ref.secondaryLabel;
|
36
|
+
var stepsContext = useContext(StepsContext);
|
37
|
+
var stepNumber = useContext(StepNumberContext);
|
38
|
+
|
39
|
+
var _useState = useState(),
|
40
|
+
_useState2 = _slicedToArray(_useState, 2),
|
41
|
+
shouldIncludeStep = _useState2[0],
|
42
|
+
setShouldIncludeStep = _useState2[1];
|
43
|
+
|
44
|
+
var previousState = usePreviousValue({
|
45
|
+
currentStep: stepsContext === null || stepsContext === void 0 ? void 0 : stepsContext.currentStep
|
46
|
+
});
|
47
|
+
useRetrieveStepData({
|
48
|
+
stepsContext: stepsContext,
|
49
|
+
stepNumber: stepNumber,
|
50
|
+
introStep: introStep,
|
51
|
+
shouldIncludeStep: shouldIncludeStep,
|
52
|
+
secondaryLabel: secondaryLabel,
|
53
|
+
title: title
|
54
|
+
}); // This useEffect reports back the onNext and onMount values so that they can be used
|
55
|
+
// in the appropriate custom hooks.
|
56
|
+
|
57
|
+
useEffect(function () {
|
58
|
+
if (stepNumber === (stepsContext === null || stepsContext === void 0 ? void 0 : stepsContext.currentStep) && (previousState === null || previousState === void 0 ? void 0 : previousState.currentStep) !== (stepsContext === null || stepsContext === void 0 ? void 0 : stepsContext.currentStep)) {
|
59
|
+
stepsContext === null || stepsContext === void 0 ? void 0 : stepsContext.setOnNext(onNext);
|
60
|
+
stepsContext === null || stepsContext === void 0 ? void 0 : stepsContext.setOnMount(onMount);
|
61
|
+
}
|
62
|
+
}, [onMount, onNext, stepsContext, stepNumber, previousState === null || previousState === void 0 ? void 0 : previousState.currentStep]);
|
63
|
+
useEffect(function () {
|
64
|
+
setShouldIncludeStep(includeStep);
|
65
|
+
}, [includeStep, stepsContext, title]); // Whenever we are the current step, supply our disableSubmit value to the
|
66
|
+
// steps container context so that it can manage the 'Next' button appropriately.
|
67
|
+
|
68
|
+
useEffect(function () {
|
69
|
+
if (stepNumber === (stepsContext === null || stepsContext === void 0 ? void 0 : stepsContext.currentStep)) {
|
70
|
+
stepsContext.setIsDisabled(disableSubmit);
|
71
|
+
}
|
72
|
+
}, [stepsContext, stepNumber, disableSubmit, onNext]);
|
73
|
+
return stepsContext ? /*#__PURE__*/React.createElement("section", {
|
74
|
+
className: cx(blockClass, className, (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__step--hidden-step"), stepNumber !== (stepsContext === null || stepsContext === void 0 ? void 0 : stepsContext.currentStep)), _defineProperty(_cx, "".concat(blockClass, "__step--visible-step"), stepNumber === (stepsContext === null || stepsContext === void 0 ? void 0 : stepsContext.currentStep)), _cx)),
|
25
75
|
ref: ref
|
26
76
|
}, /*#__PURE__*/React.createElement("h5", {
|
27
77
|
className: "".concat(blockClass, "-title")
|
@@ -32,7 +82,7 @@ export var CreateFullPageStep = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
32
82
|
}, description), hasFieldset ? /*#__PURE__*/React.createElement(FormGroup, {
|
33
83
|
legendText: fieldsetLegendText,
|
34
84
|
className: "".concat(blockClass, "-fieldset")
|
35
|
-
}, children) : children);
|
85
|
+
}, children) : children) : pconsole.warn("You have tried using a ".concat(componentName, " component outside of a CreateFullPage. This is not allowed. ").concat(componentName, "s should always be children of the CreateFullPage"));
|
36
86
|
}); // Return a placeholder if not released and not enabled by feature flag
|
37
87
|
|
38
88
|
CreateFullPageStep = pkg.checkComponentEnabled(CreateFullPageStep, componentName);
|
@@ -70,6 +120,12 @@ CreateFullPageStep.propTypes = {
|
|
70
120
|
*/
|
71
121
|
hasFieldset: PropTypes.bool,
|
72
122
|
|
123
|
+
/**
|
124
|
+
* This prop is used to help track dynamic steps. If this value is `false` then the step is not included in the visible steps or the ProgressIndicator
|
125
|
+
* steps. If this value is `true` then the step will be included in the list of visible steps, as well as being included in the ProgressIndicator step list
|
126
|
+
*/
|
127
|
+
includeStep: PropTypes.bool,
|
128
|
+
|
73
129
|
/**
|
74
130
|
* This prop can be used on the first step to mark it as an intro step, which will not render the progress indicator steps
|
75
131
|
*/
|
@@ -102,11 +158,7 @@ CreateFullPageStep.propTypes = {
|
|
102
158
|
* Sets the title text for a create full page step
|
103
159
|
*/
|
104
160
|
title: PropTypes.node.isRequired
|
105
|
-
};
|
106
|
-
// props that are required, nor for props where the component can apply
|
107
|
-
// 'undefined' values reasonably. Default values should be provided when the
|
108
|
-
// component needs to make a choice or assumption when a prop is not supplied.
|
109
|
-
|
161
|
+
};
|
110
162
|
CreateFullPageStep.defaultProps = {
|
111
|
-
|
163
|
+
includeStep: true
|
112
164
|
};
|
@@ -5,5 +5,4 @@
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
6
6
|
*/
|
7
7
|
export { CreateFullPage } from './CreateFullPage';
|
8
|
-
export { CreateFullPageStep } from './CreateFullPageStep';
|
9
|
-
export { CreateFullPageSection } from './CreateFullPageSection';
|
8
|
+
export { CreateFullPageStep } from './CreateFullPageStep';
|