@carbon/ibm-products 1.2.3 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. package/css/index-full-carbon.css +538 -273
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +2 -2
  4. package/css/index-without-carbon-released-only.css +32 -41
  5. package/css/index-without-carbon-released-only.css.map +1 -1
  6. package/css/index-without-carbon-released-only.min.css +2 -2
  7. package/css/index-without-carbon.css +269 -41
  8. package/css/index-without-carbon.css.map +1 -1
  9. package/css/index-without-carbon.min.css +2 -2
  10. package/css/index.css +491 -41
  11. package/css/index.css.map +1 -1
  12. package/css/index.min.css +2 -2
  13. package/es/components/APIKeyModal/APIKeyModal.js +25 -29
  14. package/es/components/ActionBar/ActionBar.js +4 -1
  15. package/es/components/AddSelect/AddSelect.js +157 -0
  16. package/es/components/AddSelect/index.js +7 -0
  17. package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +19 -15
  18. package/es/components/CancelableTextEdit/CancelableTextEdit.js +245 -0
  19. package/es/components/{CreateTearsheet/constants.js → CancelableTextEdit/index.js} +1 -2
  20. package/es/components/CreateFullPage/CreateFullPage.js +78 -259
  21. package/es/components/CreateFullPage/CreateFullPageStep.js +58 -14
  22. package/es/components/CreateFullPage/index.js +1 -2
  23. package/es/components/CreateInfluencer/CreateInfluencer.js +23 -225
  24. package/es/components/CreateTearsheet/CreateTearsheet.js +69 -146
  25. package/es/components/CreateTearsheet/CreateTearsheetStep.js +59 -16
  26. package/es/components/CreateTearsheet/index.js +0 -1
  27. package/es/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +66 -27
  28. package/es/components/ExportModal/ExportModal.js +4 -2
  29. package/es/components/ImportModal/ImportModal.js +2 -1
  30. package/es/components/InlineEdit/InlineEdit.js +224 -0
  31. package/es/components/InlineEdit/index.js +7 -0
  32. package/es/components/MultiAddSelect/MultiAddSelect.js +16 -0
  33. package/es/components/MultiAddSelect/index.js +1 -0
  34. package/es/components/OptionsTile/OptionsTile.js +36 -15
  35. package/es/components/PageHeader/PageHeader.js +54 -33
  36. package/es/components/PageHeader/PageHeaderTitle.js +78 -7
  37. package/es/components/PageHeader/PageHeaderUtils.js +21 -2
  38. package/es/components/RemoveModal/RemoveModal.js +4 -2
  39. package/es/components/SingleAddSelect/SingleAddSelect.js +15 -0
  40. package/es/components/SingleAddSelect/index.js +1 -0
  41. package/es/components/TagSet/TagSet.js +4 -1
  42. package/es/components/Toolbar/Toolbar.js +69 -8
  43. package/es/components/index.js +5 -1
  44. package/es/global/js/hooks/useCreateComponentFocus.js +15 -19
  45. package/es/global/js/hooks/useCreateComponentStepChange.js +44 -74
  46. package/es/global/js/hooks/useValidCreateStepCount.js +4 -7
  47. package/es/global/js/package-settings.js +5 -1
  48. package/es/global/js/utils/story-helper.js +1 -1
  49. package/lib/components/APIKeyModal/APIKeyModal.js +25 -29
  50. package/lib/components/ActionBar/ActionBar.js +4 -1
  51. package/lib/components/AddSelect/AddSelect.js +178 -0
  52. package/lib/components/AddSelect/index.js +13 -0
  53. package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +18 -14
  54. package/lib/components/CancelableTextEdit/CancelableTextEdit.js +265 -0
  55. package/lib/components/CancelableTextEdit/index.js +13 -0
  56. package/lib/components/CreateFullPage/CreateFullPage.js +78 -259
  57. package/lib/components/CreateFullPage/CreateFullPageStep.js +61 -14
  58. package/lib/components/CreateFullPage/index.js +1 -9
  59. package/lib/components/CreateInfluencer/CreateInfluencer.js +21 -236
  60. package/lib/components/CreateTearsheet/CreateTearsheet.js +71 -148
  61. package/lib/components/CreateTearsheet/CreateTearsheetStep.js +61 -15
  62. package/lib/components/CreateTearsheet/index.js +0 -8
  63. package/lib/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +67 -35
  64. package/lib/components/ExportModal/ExportModal.js +4 -2
  65. package/lib/components/ImportModal/ImportModal.js +2 -1
  66. package/lib/components/InlineEdit/InlineEdit.js +242 -0
  67. package/lib/components/InlineEdit/index.js +13 -0
  68. package/lib/components/MultiAddSelect/MultiAddSelect.js +37 -0
  69. package/lib/components/MultiAddSelect/index.js +13 -0
  70. package/lib/components/OptionsTile/OptionsTile.js +36 -15
  71. package/lib/components/PageHeader/PageHeader.js +54 -33
  72. package/lib/components/PageHeader/PageHeaderTitle.js +87 -9
  73. package/lib/components/PageHeader/PageHeaderUtils.js +21 -2
  74. package/lib/components/RemoveModal/RemoveModal.js +4 -2
  75. package/lib/components/SingleAddSelect/SingleAddSelect.js +36 -0
  76. package/lib/components/SingleAddSelect/index.js +13 -0
  77. package/lib/components/TagSet/TagSet.js +4 -1
  78. package/lib/components/Toolbar/Toolbar.js +69 -6
  79. package/lib/components/index.js +33 -1
  80. package/lib/global/js/hooks/useCreateComponentFocus.js +15 -19
  81. package/lib/global/js/hooks/useCreateComponentStepChange.js +44 -74
  82. package/lib/global/js/hooks/useValidCreateStepCount.js +4 -7
  83. package/lib/global/js/package-settings.js +5 -1
  84. package/lib/global/js/utils/story-helper.js +1 -1
  85. package/package.json +15 -15
  86. package/scss/components/AddSelect/_add-select.scss +84 -0
  87. package/scss/components/AddSelect/_index.scss +10 -0
  88. package/scss/components/AddSelect/_storybook-styles.scss +6 -0
  89. package/scss/components/BreadcrumbWithOverflow/_breadcrumb-with-overflow.scss +19 -15
  90. package/scss/components/CancelableTextEdit/_cancelable-text-edit.scss +211 -0
  91. package/{es/components/CreateFullPage/constants.js → scss/components/CancelableTextEdit/_index.scss} +2 -2
  92. package/scss/components/CancelableTextEdit/_storybook-styles.scss +15 -0
  93. package/scss/components/CreateFullPage/_create-full-page.scss +4 -11
  94. package/scss/components/CreateTearsheet/_create-tearsheet.scss +4 -8
  95. package/scss/components/InlineEdit/_index.scss +8 -0
  96. package/scss/components/InlineEdit/_inline-edit.scss +44 -0
  97. package/scss/components/InlineEdit/_storybook-styles.scss +15 -0
  98. package/scss/components/MultiAddSelect/_index.scss +1 -0
  99. package/scss/components/MultiAddSelect/_multi-add-select.scss +1 -0
  100. package/scss/components/MultiAddSelect/_storybook-styles.scss +6 -0
  101. package/scss/components/PageHeader/_page-header.scss +14 -4
  102. package/scss/components/SingleAddSelect/_index.scss +1 -0
  103. package/scss/components/SingleAddSelect/_single-add-select.scss +1 -0
  104. package/scss/components/SingleAddSelect/_storybook-styles.scss +6 -0
  105. package/scss/components/_index.scss +4 -0
  106. package/es/components/CreateFullPage/CreateFullPageSection.js +0 -53
  107. package/es/components/CreateTearsheet/CreateTearsheetSection.js +0 -83
  108. package/es/components/CreateTearsheet/preview-components/MultiStepWithSectionsTearsheet.js +0 -327
  109. package/es/global/js/utils/hasValidType.js +0 -94
  110. package/lib/components/CreateFullPage/CreateFullPageSection.js +0 -74
  111. package/lib/components/CreateFullPage/constants.js +0 -16
  112. package/lib/components/CreateTearsheet/CreateTearsheetSection.js +0 -105
  113. package/lib/components/CreateTearsheet/constants.js +0 -17
  114. package/lib/components/CreateTearsheet/preview-components/MultiStepWithSectionsTearsheet.js +0 -354
  115. package/lib/global/js/utils/hasValidType.js +0 -110
@@ -7,12 +7,10 @@ var _typeof = require("@babel/runtime/helpers/typeof");
7
7
  Object.defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
10
- exports.CreateFullPage = void 0;
10
+ exports.StepsContext = exports.StepNumberContext = exports.CreateFullPage = void 0;
11
11
 
12
12
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
13
 
14
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
-
16
14
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
17
15
 
18
16
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
@@ -27,8 +25,6 @@ var _devtools = require("../../global/js/utils/devtools");
27
25
 
28
26
  var _settings = require("../../settings");
29
27
 
30
- var _constants = require("./constants");
31
-
32
28
  var _carbonComponentsReact = require("carbon-components-react");
33
29
 
34
30
  var _CreateInfluencer = require("../CreateInfluencer");
@@ -37,23 +33,29 @@ var _ActionSet = require("../ActionSet");
37
33
 
38
34
  var _hooks = require("../../global/js/hooks");
39
35
 
40
- var _hasValidType = require("../../global/js/utils/hasValidType");
41
-
42
- var _excluded = ["backButtonText", "cancelButtonText", "children", "className", "includeViewAllToggle", "modalDangerButtonText", "modalDescription", "modalSecondaryButtonText", "modalTitle", "nextButtonText", "onClose", "onRequestSubmit", "sideNavAriaLabel", "submitButtonText", "viewAllToggleLabelText", "viewAllToggleOffLabelText", "viewAllToggleOnLabelText"];
36
+ var _excluded = ["backButtonText", "cancelButtonText", "children", "className", "modalDangerButtonText", "modalDescription", "modalSecondaryButtonText", "modalTitle", "nextButtonText", "onClose", "onRequestSubmit", "submitButtonText"];
43
37
 
44
38
  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); }
45
39
 
46
40
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
47
41
 
48
42
  var blockClass = "".concat(_settings.pkg.prefix, "--create-full-page");
49
- var componentName = 'CreateFullPage';
43
+ var componentName = 'CreateFullPage'; // This is a general context for the steps container
44
+ // containing information about the state of the container
45
+ // and providing some callback methods for steps to use
46
+
47
+ var StepsContext = /*#__PURE__*/(0, _react.createContext)(null); // This is a context supplied separately to each step in the container
48
+ // to let it know what number it is in the sequence of steps
49
+
50
+ exports.StepsContext = StepsContext;
51
+ var StepNumberContext = /*#__PURE__*/(0, _react.createContext)(-1);
52
+ exports.StepNumberContext = StepNumberContext;
50
53
 
51
54
  var CreateFullPage = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
52
55
  var backButtonText = _ref.backButtonText,
53
56
  cancelButtonText = _ref.cancelButtonText,
54
57
  children = _ref.children,
55
58
  className = _ref.className,
56
- includeViewAllToggle = _ref.includeViewAllToggle,
57
59
  modalDangerButtonText = _ref.modalDangerButtonText,
58
60
  modalDescription = _ref.modalDescription,
59
61
  modalSecondaryButtonText = _ref.modalSecondaryButtonText,
@@ -61,11 +63,7 @@ var CreateFullPage = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref)
61
63
  nextButtonText = _ref.nextButtonText,
62
64
  onClose = _ref.onClose,
63
65
  onRequestSubmit = _ref.onRequestSubmit,
64
- sideNavAriaLabel = _ref.sideNavAriaLabel,
65
66
  submitButtonText = _ref.submitButtonText,
66
- viewAllToggleLabelText = _ref.viewAllToggleLabelText,
67
- viewAllToggleOffLabelText = _ref.viewAllToggleOffLabelText,
68
- viewAllToggleOnLabelText = _ref.viewAllToggleOnLabelText,
69
67
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
70
68
 
71
69
  var _useState = (0, _react.useState)([]),
@@ -83,49 +81,60 @@ var CreateFullPage = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref)
83
81
  currentStep = _useState6[0],
84
82
  setCurrentStep = _useState6[1];
85
83
 
86
- var _useState7 = (0, _react.useState)(0),
84
+ var _useState7 = (0, _react.useState)(false),
87
85
  _useState8 = (0, _slicedToArray2.default)(_useState7, 2),
88
- activeSectionIndex = _useState8[0],
89
- setActiveSectionIndex = _useState8[1];
86
+ isSubmitting = _useState8[0],
87
+ setIsSubmitting = _useState8[1];
90
88
 
91
89
  var _useState9 = (0, _react.useState)(false),
92
90
  _useState10 = (0, _slicedToArray2.default)(_useState9, 2),
93
- isSubmitting = _useState10[0],
94
- setIsSubmitting = _useState10[1];
91
+ modalIsOpen = _useState10[0],
92
+ setModalIsOpen = _useState10[1];
93
+
94
+ var previousState = (0, _hooks.usePreviousValue)({
95
+ currentStep: currentStep,
96
+ open: open
97
+ });
95
98
 
96
99
  var _useState11 = (0, _react.useState)(false),
97
100
  _useState12 = (0, _slicedToArray2.default)(_useState11, 2),
98
- modalIsOpen = _useState12[0],
99
- setModalIsOpen = _useState12[1];
101
+ isDisabled = _useState12[0],
102
+ setIsDisabled = _useState12[1];
100
103
 
101
- var previousState = (0, _hooks.usePreviousValue)({
104
+ var _useState13 = (0, _react.useState)(),
105
+ _useState14 = (0, _slicedToArray2.default)(_useState13, 2),
106
+ onNext = _useState14[0],
107
+ _setOnNext = _useState14[1];
108
+
109
+ var _useState15 = (0, _react.useState)(),
110
+ _useState16 = (0, _slicedToArray2.default)(_useState15, 2),
111
+ onMount = _useState16[0],
112
+ _setOnMount = _useState16[1];
113
+
114
+ var _useState17 = (0, _react.useState)([]),
115
+ _useState18 = (0, _slicedToArray2.default)(_useState17, 2),
116
+ stepData = _useState18[0],
117
+ setStepData = _useState18[1];
118
+
119
+ var totalStepCount = _react.default.Children.count(children);
120
+
121
+ (0, _hooks.useCreateComponentFocus)({
122
+ previousState: previousState,
102
123
  currentStep: currentStep,
103
- open: open
104
- }); // returns an array of full page steps
105
-
106
- var getFullPageSteps = (0, _react.useCallback)(function () {
107
- var _childrenArray$;
108
-
109
- var steps = [];
110
- var childrenArray = Array.isArray(children) ? children : [children];
111
- var extractedChildren = childrenArray && ((_childrenArray$ = childrenArray[0]) === null || _childrenArray$ === void 0 ? void 0 : _childrenArray$.type) === _react.default.Fragment ? childrenArray[0].props.children : childrenArray;
112
- extractedChildren.forEach(function (child) {
113
- if (isFullPageStep(child)) {
114
- steps.push(child);
115
- }
116
- });
117
- return steps;
118
- }, [children]);
119
- (0, _hooks.useCreateComponentFocus)(previousState, currentStep, getFullPageSteps, blockClass);
120
- (0, _hooks.useValidCreateStepCount)(getFullPageSteps, componentName);
124
+ blockClass: blockClass,
125
+ onMount: onMount
126
+ });
127
+ (0, _hooks.useValidCreateStepCount)(stepData.length, componentName);
121
128
  (0, _hooks.useCreateComponentStepChange)({
129
+ totalStepCount: totalStepCount,
130
+ onNext: onNext,
131
+ isSubmitDisabled: isDisabled,
122
132
  setCurrentStep: setCurrentStep,
123
133
  setIsSubmitting: setIsSubmitting,
124
134
  setShouldViewAll: setShouldViewAll,
125
135
  onClose: onClose,
126
136
  onRequestSubmit: onRequestSubmit,
127
137
  componentName: componentName,
128
- getComponentSteps: getFullPageSteps,
129
138
  currentStep: currentStep,
130
139
  shouldViewAll: shouldViewAll,
131
140
  backButtonText: backButtonText,
@@ -136,200 +145,18 @@ var CreateFullPage = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref)
136
145
  componentBlockClass: blockClass,
137
146
  setCreateComponentActions: setCreateFullPageActions,
138
147
  setModalIsOpen: setModalIsOpen
139
- }); // Log a warning to the console in the event there are no CreateFullPageSection components
140
- // inside of the CreateFullPageSteps when the viewAll toggle is provided and turned on.
141
- // currently, we are not supporting the use of FullPageSections -- this may be a future feature
142
-
143
- /* istanbul ignore next */
144
-
145
- (0, _react.useEffect)(function () {
146
- if (includeViewAllToggle && shouldViewAll) {
147
- var childrenArray = Array.isArray(children) ? children : [children];
148
- var fullPageStepComponents = childrenArray.filter(function (child) {
149
- return isFullPageStep(child);
150
- });
151
- var fullPageSectionComponents = [];
152
- fullPageStepComponents.forEach(function (child, index) {
153
- // We have received children for a FullPageStep
154
- if (shouldViewAll && typeof child.props.children !== 'undefined') {
155
- // Only a string was provided as children of CreateFullPageStep, this is not permitted when using view all toggle
156
- if (typeof child.props.children === 'string') {
157
- console.warn("".concat(componentName, ": You must have at least one CreateFullPageSection component in a CreateFullPageStep when using the 'includeViewAllToggle' prop."));
158
- } else {
159
- // The FullPageStep has an array of children, lets check each one to see if it is a FullPageSection
160
- if (child.props.children.length) {
161
- child.props.children.forEach(function (stepChild) {
162
- if (isFullPageSection(stepChild)) {
163
- fullPageSectionComponents.push(stepChild);
164
- }
165
- });
166
- } else {
167
- // The FullPageStep only has a single React element as a child, lets check to see if it is a FullPageSection
168
- if (isFullPageSection(child.props.children)) {
169
- fullPageSectionComponents.push(child.props.children);
170
- }
171
- }
172
- }
173
- } // If there are fewer CreateFullPageSection components than CreateFullPageStep components
174
- // it means that each CreateFullPageStep does not have at least one CreateFullPageSection
175
- // this is not permitted when using view all toggle
176
-
177
-
178
- if (fullPageSectionComponents.length < fullPageStepComponents.length && index === fullPageStepComponents.length - 1 // wait until we've finished checking each FullPageStep before giving a warning
179
- ) {
180
- console.warn("".concat(componentName, ": You must have at least one CreateFullPageSection component in a CreateFullPageStep when using the 'includeViewAllToggle' prop."));
181
- } // We have received a single child element, lets check to see that it is
182
- // a CreateFullPageSection component, if it is not we should add a console
183
- // warning, as each CreateFullPageStep required at least one CreateFullPageSection,
184
- // when using the view all toggle
185
-
186
-
187
- if (shouldViewAll && typeof child.props.children !== 'undefined' && !child.props.children.length) {
188
- if (!isFullPageSection(child.props.children)) {
189
- console.warn("".concat(componentName, ": You must have at least one CreateFullPageSection component in a CreateFullPageStep when using the 'includeViewAllToggle' prop."));
190
- }
191
- }
192
- });
193
- }
194
- }, [includeViewAllToggle, shouldViewAll, children]); // check if child is a full page step component
195
-
196
- var isFullPageStep = function isFullPageStep(child) {
197
- if (child && child.props && child.props.type === _constants.CREATE_FULL_PAGE_STEP) {
198
- return true;
199
- }
200
-
201
- return false;
202
- }; // check if child is a full page section component
203
- // currently, we are not supporting the use of FullPageSections -- this may be a future feature
204
-
205
- /* istanbul ignore next */
206
-
207
-
208
- var isFullPageSection = function isFullPageSection(child) {
209
- if (child && child.props && child.props.type === _constants.CREATE_FULL_PAGE_SECTION) {
210
- return true;
211
- }
212
-
213
- return false;
214
- }; // renders the step progression components in the left influencer area
215
-
216
-
217
- var getFullPageComponents = function getFullPageComponents(childrenElements) {
218
- var childrenArray = Array.isArray(childrenElements) ? childrenElements : [childrenElements];
219
- var fullPageStepComponents = childrenArray.filter(function (child) {
220
- return isFullPageStep(child);
221
- });
222
- var sectionChildElements = [];
223
- fullPageStepComponents.forEach(function (child) {
224
- // we have received an array of children, lets check to see that each child is
225
- // a FullPageSection component before adding it to sectionChildElements
226
- // currently, we are not supporting the use of FullPageSections -- this may be a future feature
227
-
228
- /* istanbul ignore next */
229
- if (shouldViewAll && child.props.children.length) {
230
- child.props.children.forEach(function (stepChild) {
231
- if (isFullPageSection(stepChild)) {
232
- sectionChildElements.push(stepChild);
233
- }
234
- });
235
- } // we have received a single child element, lets check to see that it is
236
- // a CreateFullPageSection component before adding it to sectionChildElements
237
-
238
-
239
- if (shouldViewAll && typeof child.props.children !== 'undefined' && !child.props.children.length) {
240
- // currently, we are not supporting the use of FullPageSections -- this may be a future feature
241
-
242
- /* istanbul ignore next */
243
- if (isFullPageSection(child.props.children)) {
244
- sectionChildElements.push(child.props.children);
245
- }
246
- }
247
- });
248
- return {
249
- sections: sectionChildElements,
250
- steps: fullPageStepComponents
251
- };
252
- }; // renders all children (CreateFullPageSteps and regular children elements)
253
-
254
-
255
- var renderChildren = function renderChildren(childrenElements) {
256
- var step = 0;
257
- var childrenArray = Array.isArray(childrenElements) ? childrenElements : [childrenElements];
258
- var indexOfLastFullPageStep = childrenArray.map(function (el) {
259
- var _el$props;
260
-
261
- return el === null || el === void 0 ? void 0 : (_el$props = el.props) === null || _el$props === void 0 ? void 0 : _el$props.type;
262
- }).lastIndexOf(_constants.CREATE_FULL_PAGE_STEP);
263
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, childrenArray.map(function (child, stepIndex) {
264
- var _cx;
265
-
266
- if (!isFullPageStep(child)) {
267
- return child;
268
- }
269
-
270
- step++;
271
- return /*#__PURE__*/_react.default.cloneElement(child, {
272
- className: (0, _classnames.default)(child.props.className, (_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__step--hidden-step"), !shouldViewAll && currentStep !== step), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__step--visible-step"), currentStep === step), _cx)),
273
- key: "key_".concat(stepIndex)
274
- }, /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, renderStepChildren(child.props.children, indexOfLastFullPageStep === step - 1)));
275
- }));
276
- };
277
-
278
- var renderStepChildren = function renderStepChildren(fullPageStepComponent, isLastFullPageStep) {
279
- var fullPageStepComponents = Array.isArray(fullPageStepComponent) ? fullPageStepComponent : [fullPageStepComponent];
280
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, fullPageStepComponents.map(function (child, index) {
281
- var _cx2;
282
-
283
- if (!isFullPageSection(child)) {
284
- return child;
285
- } // Needed to be able to not render the divider
286
- // line on the last section of the last step
287
- // currently, we are not supporting the use of FullPageSections -- this may be a future feature
288
-
289
- /* istanbul ignore next */
290
-
291
-
292
- var isLastSectionOfLastStep = isLastFullPageStep && fullPageStepComponents.length - 1 === index;
293
- /* istanbul ignore next */
294
-
295
- return /*#__PURE__*/_react.default.cloneElement(child, {
296
- className: (0, _classnames.default)(child.props.className, (_cx2 = {}, (0, _defineProperty2.default)(_cx2, "".concat(blockClass, "__step--hidden-section"), child.props.viewAllOnly && !shouldViewAll), (0, _defineProperty2.default)(_cx2, "".concat(blockClass, "__step--visible-section"), !child.props.viewAllOnly || child.props.viewAllOnly && shouldViewAll), _cx2)),
297
- key: "key_".concat(index)
298
- }, /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, shouldViewAll && /*#__PURE__*/_react.default.createElement("h4", {
299
- className: "".concat(blockClass, "__step-title")
300
- }, child.props.title), child, shouldViewAll && !isLastSectionOfLastStep && /*#__PURE__*/_react.default.createElement("span", {
301
- className: "".concat(blockClass, "__section-divider")
302
- })));
303
- }));
304
- }; // currently, we are not supporting the use of 'view all' toggle state or CreateFullPageSection -- this may be a future feature
148
+ }); // currently, we are not supporting the use of 'view all' toggle state
305
149
 
306
150
  /* istanbul ignore next */
307
151
 
308
-
309
152
  return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, rest, {
310
153
  ref: ref,
311
154
  className: (0, _classnames.default)(blockClass, className)
312
155
  }, (0, _devtools.getDevtoolsProps)(componentName)), /*#__PURE__*/_react.default.createElement("div", {
313
156
  className: "".concat(blockClass, "__influencer")
314
157
  }, /*#__PURE__*/_react.default.createElement(_CreateInfluencer.CreateInfluencer, {
315
- activeSectionIndex: activeSectionIndex,
316
- componentBlockClass: blockClass,
317
- createComponentName: componentName,
318
- currentStep: currentStep,
319
- createComponents: getFullPageComponents(children),
320
- includeViewAllToggle: includeViewAllToggle,
321
- handleToggleState: function handleToggleState(toggleState) {
322
- return setShouldViewAll(toggleState);
323
- },
324
- handleActiveSectionIndex: function handleActiveSectionIndex(index) {
325
- return setActiveSectionIndex(index);
326
- },
327
- previousState: previousState,
328
- sideNavAriaLabel: sideNavAriaLabel,
329
- toggleState: shouldViewAll,
330
- viewAllToggleLabelText: viewAllToggleLabelText,
331
- viewAllToggleOffLabelText: viewAllToggleOffLabelText,
332
- viewAllToggleOnLabelText: viewAllToggleOnLabelText
158
+ stepData: stepData,
159
+ currentStep: currentStep
333
160
  })), /*#__PURE__*/_react.default.createElement("div", {
334
161
  className: "".concat(blockClass, "__body")
335
162
  }, /*#__PURE__*/_react.default.createElement("div", {
@@ -338,7 +165,29 @@ var CreateFullPage = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref)
338
165
  className: "".concat(blockClass, "__content")
339
166
  }, /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Grid, null, /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Form, {
340
167
  className: "".concat(blockClass, "__form")
341
- }, renderChildren(children)))), /*#__PURE__*/_react.default.createElement(_ActionSet.ActionSet, {
168
+ }, /*#__PURE__*/_react.default.createElement(StepsContext.Provider, {
169
+ value: {
170
+ currentStep: currentStep,
171
+ setIsDisabled: setIsDisabled,
172
+ setOnNext: function setOnNext(fn) {
173
+ return _setOnNext(function () {
174
+ return fn;
175
+ });
176
+ },
177
+ setOnMount: function setOnMount(fn) {
178
+ return _setOnMount(function () {
179
+ return fn;
180
+ });
181
+ },
182
+ setStepData: setStepData,
183
+ stepData: stepData,
184
+ totalStepCount: totalStepCount
185
+ }
186
+ }, _react.default.Children.map(children, function (child, index) {
187
+ return /*#__PURE__*/_react.default.createElement(StepNumberContext.Provider, {
188
+ value: index + 1
189
+ }, child);
190
+ }))))), /*#__PURE__*/_react.default.createElement(_ActionSet.ActionSet, {
342
191
  className: "".concat(blockClass, "__buttons"),
343
192
  actions: createFullPageActions,
344
193
  size: "max"
@@ -385,22 +234,13 @@ CreateFullPage.propTypes = {
385
234
  /**
386
235
  * The main content of the full page
387
236
  */
388
- children: (0, _hasValidType.hasValidChildrenType)({
389
- componentName: componentName,
390
- childType: _constants.CREATE_FULL_PAGE_STEP
391
- }),
237
+ children: _propTypes.default.node,
392
238
 
393
239
  /**
394
240
  * Provide an optional class to be applied to the containing node.
395
241
  */
396
242
  className: _propTypes.default.string,
397
243
 
398
- /**
399
- * @ignore
400
- * An optional prop that provides a toggle element in the left side influencer panel
401
- */
402
- includeViewAllToggle: _propTypes.default.bool,
403
-
404
244
  /**
405
245
  * The primary 'danger' button text in the modal
406
246
  */
@@ -453,26 +293,5 @@ CreateFullPage.propTypes = {
453
293
  /**
454
294
  * The main title of the full page, displayed in the header area.
455
295
  */
456
- title: _propTypes.default.node,
457
-
458
- /**
459
- * @ignore
460
- * Sets the label text for the view all toggle component
461
- */
462
- viewAllToggleLabelText: _propTypes.default.string,
463
-
464
- /**
465
- * @ignore
466
- * Sets the label text for the view all toggle `off` text
467
- */
468
- viewAllToggleOffLabelText: _propTypes.default.string,
469
-
470
- /**
471
- * @ignore
472
- * Sets the label text for the view all toggle `on` text
473
- */
474
- viewAllToggleOnLabelText: _propTypes.default.string
475
- };
476
- CreateFullPage.defaultProps = {
477
- includeViewAllToggle: false
296
+ title: _propTypes.default.node
478
297
  };
@@ -9,6 +9,10 @@ Object.defineProperty(exports, "__esModule", {
9
9
  });
10
10
  exports.CreateFullPageStep = void 0;
11
11
 
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+
14
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
15
+
12
16
  var _react = _interopRequireWildcard(require("react"));
13
17
 
14
18
  var _propTypes = _interopRequireDefault(require("prop-types"));
@@ -17,16 +21,20 @@ var _classnames = _interopRequireDefault(require("classnames"));
17
21
 
18
22
  var _settings = require("../../settings");
19
23
 
20
- var _constants = require("./constants.js");
21
-
22
24
  var _carbonComponentsReact = require("carbon-components-react");
23
25
 
26
+ var _CreateFullPage = require("./CreateFullPage");
27
+
28
+ var _hooks = require("../../global/js/hooks");
29
+
30
+ var _pconsole = _interopRequireDefault(require("../../global/js/utils/pconsole"));
31
+
24
32
  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); }
25
33
 
26
34
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
27
35
 
28
36
  /**
29
- * Copyright IBM Corp. 2021, 2021
37
+ * Copyright IBM Corp. 2021, 2022
30
38
  *
31
39
  * This source code is licensed under the Apache-2.0 license found in the
32
40
  * LICENSE file in the root directory of this source tree.
@@ -34,15 +42,61 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
34
42
  var componentName = 'CreateFullPageStep';
35
43
  var blockClass = "".concat(_settings.pkg.prefix, "--create-full-page__step");
36
44
  var CreateFullPageStep = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
45
+ var _cx;
46
+
37
47
  var children = _ref.children,
38
48
  className = _ref.className,
39
49
  subtitle = _ref.subtitle,
40
50
  description = _ref.description,
51
+ disableSubmit = _ref.disableSubmit,
52
+ introStep = _ref.introStep,
41
53
  title = _ref.title,
42
54
  hasFieldset = _ref.hasFieldset,
43
- fieldsetLegendText = _ref.fieldsetLegendText;
44
- return /*#__PURE__*/_react.default.createElement("section", {
45
- className: (0, _classnames.default)(blockClass, className),
55
+ fieldsetLegendText = _ref.fieldsetLegendText,
56
+ onNext = _ref.onNext,
57
+ onMount = _ref.onMount,
58
+ secondaryLabel = _ref.secondaryLabel;
59
+ var steps = (0, _react.useContext)(_CreateFullPage.StepsContext);
60
+ var stepNumber = (0, _react.useContext)(_CreateFullPage.StepNumberContext);
61
+ var previousState = (0, _hooks.usePreviousValue)({
62
+ currentStep: steps === null || steps === void 0 ? void 0 : steps.currentStep
63
+ }); // This useEffect reports back the onNext and onMount values so that they can be used
64
+ // in the appropriate custom hooks.
65
+
66
+ (0, _react.useEffect)(function () {
67
+ if (stepNumber === (steps === null || steps === void 0 ? void 0 : steps.currentStep) && (previousState === null || previousState === void 0 ? void 0 : previousState.currentStep) !== (steps === null || steps === void 0 ? void 0 : steps.currentStep)) {
68
+ steps === null || steps === void 0 ? void 0 : steps.setOnNext(onNext);
69
+ steps === null || steps === void 0 ? void 0 : steps.setOnMount(onMount);
70
+ }
71
+ }, [onMount, onNext, steps, stepNumber, previousState === null || previousState === void 0 ? void 0 : previousState.currentStep]); // This useEffect makes sure that every CreateTearsheetStep reports back it's
72
+ // title, secondaryLabel, and introStep props so that it can be sent to the CreateInfluencer.
73
+
74
+ (0, _react.useEffect)(function () {
75
+ var _steps$stepData, _steps$stepData2;
76
+
77
+ var stepHasReported = steps === null || steps === void 0 ? void 0 : (_steps$stepData = steps.stepData) === null || _steps$stepData === void 0 ? void 0 : _steps$stepData.includes(function (item) {
78
+ return item.title === title;
79
+ });
80
+
81
+ if (!stepHasReported && (steps === null || steps === void 0 ? void 0 : (_steps$stepData2 = steps.stepData) === null || _steps$stepData2 === void 0 ? void 0 : _steps$stepData2.length) < (steps === null || steps === void 0 ? void 0 : steps.totalStepCount)) {
82
+ steps === null || steps === void 0 ? void 0 : steps.setStepData(function (prev) {
83
+ return [].concat((0, _toConsumableArray2.default)(prev), [{
84
+ title: title,
85
+ secondaryLabel: secondaryLabel,
86
+ introStep: introStep
87
+ }]);
88
+ });
89
+ }
90
+ }, [steps, title, secondaryLabel, introStep]); // Whenever we are the current step, supply our disableSubmit value to the
91
+ // steps container context so that it can manage the 'Next' button appropriately.
92
+
93
+ (0, _react.useEffect)(function () {
94
+ if (stepNumber === (steps === null || steps === void 0 ? void 0 : steps.currentStep)) {
95
+ steps.setIsDisabled(disableSubmit);
96
+ }
97
+ }, [steps, stepNumber, disableSubmit, onNext]);
98
+ return steps ? /*#__PURE__*/_react.default.createElement("section", {
99
+ className: (0, _classnames.default)(blockClass, className, (_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__step--hidden-step"), stepNumber !== (steps === null || steps === void 0 ? void 0 : steps.currentStep)), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__step--visible-step"), stepNumber === (steps === null || steps === void 0 ? void 0 : steps.currentStep)), _cx)),
46
100
  ref: ref
47
101
  }, /*#__PURE__*/_react.default.createElement("h5", {
48
102
  className: "".concat(blockClass, "-title")
@@ -53,7 +107,7 @@ var CreateFullPageStep = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref
53
107
  }, description), hasFieldset ? /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.FormGroup, {
54
108
  legendText: fieldsetLegendText,
55
109
  className: "".concat(blockClass, "-fieldset")
56
- }, children) : children);
110
+ }, children) : children) : _pconsole.default.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"));
57
111
  }); // Return a placeholder if not released and not enabled by feature flag
58
112
 
59
113
  exports.CreateFullPageStep = CreateFullPageStep;
@@ -124,11 +178,4 @@ CreateFullPageStep.propTypes = {
124
178
  * Sets the title text for a create full page step
125
179
  */
126
180
  title: _propTypes.default.node.isRequired
127
- }; // Default values for component props. Default values are not required for
128
- // props that are required, nor for props where the component can apply
129
- // 'undefined' values reasonably. Default values should be provided when the
130
- // component needs to make a choice or assumption when a prop is not supplied.
131
-
132
- CreateFullPageStep.defaultProps = {
133
- type: _constants.CREATE_FULL_PAGE_STEP
134
181
  };
@@ -9,12 +9,6 @@ Object.defineProperty(exports, "CreateFullPage", {
9
9
  return _CreateFullPage.CreateFullPage;
10
10
  }
11
11
  });
12
- Object.defineProperty(exports, "CreateFullPageSection", {
13
- enumerable: true,
14
- get: function get() {
15
- return _CreateFullPageSection.CreateFullPageSection;
16
- }
17
- });
18
12
  Object.defineProperty(exports, "CreateFullPageStep", {
19
13
  enumerable: true,
20
14
  get: function get() {
@@ -24,6 +18,4 @@ Object.defineProperty(exports, "CreateFullPageStep", {
24
18
 
25
19
  var _CreateFullPage = require("./CreateFullPage");
26
20
 
27
- var _CreateFullPageStep = require("./CreateFullPageStep");
28
-
29
- var _CreateFullPageSection = require("./CreateFullPageSection");
21
+ var _CreateFullPageStep = require("./CreateFullPageStep");