@carbon/ibm-products 1.4.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. package/css/index-full-carbon.css +527 -90
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +9 -3
  4. package/css/index-full-carbon.min.css.map +1 -0
  5. package/css/index-without-carbon-released-only.css +157 -67
  6. package/css/index-without-carbon-released-only.css.map +1 -1
  7. package/css/index-without-carbon-released-only.min.css +3 -3
  8. package/css/index-without-carbon-released-only.min.css.map +1 -0
  9. package/css/index-without-carbon.css +468 -84
  10. package/css/index-without-carbon.css.map +1 -1
  11. package/css/index-without-carbon.min.css +9 -3
  12. package/css/index-without-carbon.min.css.map +1 -0
  13. package/css/index.css +470 -86
  14. package/css/index.css.map +1 -1
  15. package/css/index.min.css +9 -3
  16. package/css/index.min.css.map +1 -0
  17. package/es/components/ActionSet/ActionSet.js +23 -11
  18. package/es/components/ActionSet/actions.js +25 -17
  19. package/es/components/AddSelect/AddSelect.js +115 -67
  20. package/es/components/AddSelect/AddSelectBreadcrumbs.js +56 -0
  21. package/es/components/AddSelect/AddSelectList.js +94 -0
  22. package/es/components/AddSelect/AddSelectSidebar.js +110 -0
  23. package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +5 -2
  24. package/es/components/ButtonMenu/ButtonMenu.js +1 -1
  25. package/es/components/CancelableTextEdit/CancelableTextEdit.js +2 -2
  26. package/es/components/Card/Card.js +6 -4
  27. package/es/components/CreateFullPage/CreateFullPage.js +30 -5
  28. package/es/components/CreateFullPage/CreateFullPageStep.js +40 -32
  29. package/es/components/CreateInfluencer/CreateInfluencer.js +25 -3
  30. package/es/components/CreateTearsheet/CreateTearsheet.js +32 -6
  31. package/es/components/CreateTearsheet/CreateTearsheetStep.js +45 -38
  32. package/es/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +24 -4
  33. package/es/components/CreateTearsheet/preview-components/MultiStepWithIntro.js +8 -6
  34. package/es/components/DataSpreadsheet/DataSpreadsheet.js +154 -0
  35. package/es/components/DataSpreadsheet/generateData.js +47 -0
  36. package/es/components/DataSpreadsheet/index.js +7 -0
  37. package/es/components/EmptyStates/EmptyState.js +1 -1
  38. package/es/components/EmptyStates/EmptyStateContent.js +2 -2
  39. package/es/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +1 -1
  40. package/es/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +1 -1
  41. package/es/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +1 -1
  42. package/es/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +1 -1
  43. package/es/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +1 -1
  44. package/es/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +1 -1
  45. package/es/components/ExportModal/ExportModal.js +39 -12
  46. package/es/components/InlineEdit/InlineEdit.js +250 -80
  47. package/es/components/NotificationsPanel/NotificationsPanel.js +16 -3
  48. package/es/components/PageHeader/PageHeader.js +9 -6
  49. package/es/components/PageHeader/PageHeaderTitle.js +10 -6
  50. package/es/components/SidePanel/SidePanel.js +33 -16
  51. package/es/components/Tearsheet/Tearsheet.js +1 -1
  52. package/es/components/Tearsheet/TearsheetNarrow.js +1 -1
  53. package/es/components/Tearsheet/TearsheetShell.js +4 -5
  54. package/es/components/WebTerminal/WebTerminal.js +1 -1
  55. package/es/components/index.js +2 -1
  56. package/es/global/js/hooks/index.js +1 -0
  57. package/es/global/js/hooks/useCreateComponentStepChange.js +31 -11
  58. package/es/global/js/hooks/useResetCreateComponent.js +7 -4
  59. package/es/global/js/hooks/useRetrieveStepData.js +51 -0
  60. package/es/global/js/package-settings.js +2 -1
  61. package/es/global/js/utils/getScrollbarWidth.js +14 -0
  62. package/es/global/js/utils/lastIndexInArray.js +26 -0
  63. package/es/settings.js +0 -5
  64. package/lib/components/ActionSet/ActionSet.js +23 -11
  65. package/lib/components/ActionSet/actions.js +25 -17
  66. package/lib/components/AddSelect/AddSelect.js +119 -67
  67. package/lib/components/AddSelect/AddSelectBreadcrumbs.js +71 -0
  68. package/lib/components/AddSelect/AddSelectList.js +112 -0
  69. package/lib/components/AddSelect/AddSelectSidebar.js +122 -0
  70. package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +5 -2
  71. package/lib/components/ButtonMenu/ButtonMenu.js +1 -1
  72. package/lib/components/CancelableTextEdit/CancelableTextEdit.js +1 -1
  73. package/lib/components/Card/Card.js +6 -4
  74. package/lib/components/CreateFullPage/CreateFullPage.js +29 -4
  75. package/lib/components/CreateFullPage/CreateFullPageStep.js +38 -30
  76. package/lib/components/CreateInfluencer/CreateInfluencer.js +25 -3
  77. package/lib/components/CreateTearsheet/CreateTearsheet.js +31 -5
  78. package/lib/components/CreateTearsheet/CreateTearsheetStep.js +43 -36
  79. package/lib/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +22 -2
  80. package/lib/components/CreateTearsheet/preview-components/MultiStepWithIntro.js +8 -6
  81. package/lib/components/DataSpreadsheet/DataSpreadsheet.js +171 -0
  82. package/lib/components/DataSpreadsheet/generateData.js +58 -0
  83. package/lib/components/DataSpreadsheet/index.js +13 -0
  84. package/lib/components/EmptyStates/EmptyState.js +1 -1
  85. package/lib/components/EmptyStates/EmptyStateContent.js +2 -2
  86. package/lib/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +1 -1
  87. package/lib/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +1 -1
  88. package/lib/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +1 -1
  89. package/lib/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +1 -1
  90. package/lib/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +1 -1
  91. package/lib/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +1 -1
  92. package/lib/components/ExportModal/ExportModal.js +36 -11
  93. package/lib/components/InlineEdit/InlineEdit.js +247 -79
  94. package/lib/components/NotificationsPanel/NotificationsPanel.js +13 -1
  95. package/lib/components/PageHeader/PageHeader.js +9 -6
  96. package/lib/components/PageHeader/PageHeaderTitle.js +10 -6
  97. package/lib/components/SidePanel/SidePanel.js +33 -16
  98. package/lib/components/Tearsheet/Tearsheet.js +1 -1
  99. package/lib/components/Tearsheet/TearsheetNarrow.js +1 -1
  100. package/lib/components/Tearsheet/TearsheetShell.js +3 -4
  101. package/lib/components/WebTerminal/WebTerminal.js +1 -1
  102. package/lib/components/index.js +9 -1
  103. package/lib/global/js/hooks/index.js +8 -0
  104. package/lib/global/js/hooks/useCreateComponentStepChange.js +31 -11
  105. package/lib/global/js/hooks/useResetCreateComponent.js +7 -4
  106. package/lib/global/js/hooks/useRetrieveStepData.js +62 -0
  107. package/lib/global/js/package-settings.js +2 -1
  108. package/lib/global/js/utils/getScrollbarWidth.js +23 -0
  109. package/lib/global/js/utils/lastIndexInArray.js +35 -0
  110. package/lib/settings.js +0 -6
  111. package/package.json +27 -25
  112. package/scss/components/AddSelect/_add-select.scss +59 -5
  113. package/scss/components/BreadcrumbWithOverflow/_index.scss +1 -1
  114. package/scss/components/CancelableTextEdit/_cancelable-text-edit.scss +1 -0
  115. package/scss/components/CancelableTextEdit/_storybook-styles.scss +0 -7
  116. package/scss/components/CreateInfluencer/_create-influencer.scss +4 -4
  117. package/scss/components/CreateTearsheet/_create-tearsheet.scss +2 -2
  118. package/scss/components/CreateTearsheetNarrow/_storybook-styles.scss +0 -6
  119. package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +79 -0
  120. package/scss/components/DataSpreadsheet/_index.scss +8 -0
  121. package/scss/components/DataSpreadsheet/_storybook-styles.scss +6 -0
  122. package/scss/components/EditSidePanel/_storybook-styles.scss +0 -8
  123. package/scss/components/InlineEdit/_inline-edit.scss +288 -10
  124. package/scss/components/InlineEdit/_storybook-styles.scss +12 -6
  125. package/scss/components/LoadingBar/_storybook-styles.scss +0 -5
  126. package/scss/components/NotificationsPanel/_notifications-panel.scss +2 -2
  127. package/scss/components/OptionsTile/_storybook-styles.scss +0 -7
  128. package/scss/components/PageHeader/_index.scss +1 -1
  129. package/scss/components/PageHeader/_page-header.scss +4 -1
  130. package/scss/components/ProductiveCard/_productive-card.scss +0 -4
  131. package/scss/components/SidePanel/_side-panel.scss +15 -6
  132. package/scss/components/StatusIcon/_index.scss +1 -1
  133. package/scss/components/StatusIcon/_status-icon.scss +6 -4
  134. package/scss/components/TagSet/_index.scss +1 -1
  135. package/scss/components/UserProfileImage/_index.scss +1 -1
  136. package/scss/components/UserProfileImage/_user-profile-image.scss +2 -2
  137. package/scss/components/WebTerminal/_web-terminal.scss +2 -2
  138. package/scss/components/_index.scss +1 -0
  139. package/scss/global/styles/_project-settings.scss +5 -1
  140. package/es/generated/feature-flags/feature-flags.js +0 -15
  141. package/lib/generated/feature-flags/feature-flags.js +0 -22
  142. package/scss/generated/feature-flags/_feature-flags.scss +0 -19
@@ -9,7 +9,7 @@ var _excluded = ["backButtonText", "cancelButtonText", "children", "className",
9
9
  * This source code is licensed under the Apache-2.0 license found in the
10
10
  * LICENSE file in the root directory of this source tree.
11
11
  */
12
- import React, { forwardRef, useState, useRef, createContext } from 'react';
12
+ import React, { forwardRef, useState, useRef, createContext, useEffect } from 'react';
13
13
  import PropTypes from 'prop-types';
14
14
  import cx from 'classnames';
15
15
  import { Grid, Form } from 'carbon-components-react';
@@ -19,6 +19,7 @@ import { CreateInfluencer } from '../CreateInfluencer';
19
19
  import { pkg } from '../../settings';
20
20
  import { usePreviousValue, useValidCreateStepCount, useResetCreateComponent, useCreateComponentFocus, useCreateComponentStepChange } from '../../global/js/hooks';
21
21
  import { getDevtoolsProps } from '../../global/js/utils/devtools';
22
+ import { lastIndexInArray } from '../../global/js/utils/lastIndexInArray';
22
23
  var componentName = 'CreateTearsheet';
23
24
  var blockClass = "".concat(pkg.prefix, "--tearsheet-create"); // This is a general context for the steps container
24
25
  // containing information about the state of the container
@@ -86,12 +87,35 @@ export var CreateTearsheet = /*#__PURE__*/forwardRef(function (_ref, ref) {
86
87
  stepData = _useState16[0],
87
88
  setStepData = _useState16[1];
88
89
 
89
- var totalStepCount = React.Children.count(children);
90
+ var _useState17 = useState(1),
91
+ _useState18 = _slicedToArray(_useState17, 2),
92
+ firstIncludedStep = _useState18[0],
93
+ setFirstIncludedStep = _useState18[1];
94
+
95
+ var _useState19 = useState(null),
96
+ _useState20 = _slicedToArray(_useState19, 2),
97
+ lastIncludedStep = _useState20[0],
98
+ setLastIncludedStep = _useState20[1];
99
+
90
100
  var previousState = usePreviousValue({
91
101
  currentStep: currentStep,
92
102
  open: open
93
103
  });
94
104
  var contentRef = useRef();
105
+ useEffect(function () {
106
+ var firstItem = stepData.findIndex(function (item) {
107
+ return item === null || item === void 0 ? void 0 : item.shouldIncludeStep;
108
+ }) + 1;
109
+ var lastItem = lastIndexInArray(stepData, 'shouldIncludeStep', true);
110
+
111
+ if (firstItem !== firstIncludedStep) {
112
+ setFirstIncludedStep(firstItem);
113
+ }
114
+
115
+ if (lastItem !== lastIncludedStep) {
116
+ setLastIncludedStep(lastItem);
117
+ }
118
+ }, [stepData, firstIncludedStep, lastIncludedStep]);
95
119
  useCreateComponentFocus({
96
120
  previousState: previousState,
97
121
  currentStep: currentStep,
@@ -100,15 +124,18 @@ export var CreateTearsheet = /*#__PURE__*/forwardRef(function (_ref, ref) {
100
124
  });
101
125
  useValidCreateStepCount(stepData.length, componentName);
102
126
  useResetCreateComponent({
127
+ firstIncludedStep: firstIncludedStep,
103
128
  previousState: previousState,
104
129
  open: open,
105
130
  setCurrentStep: setCurrentStep,
106
131
  initialStep: initialStep,
107
- totalSteps: totalStepCount,
132
+ totalSteps: stepData === null || stepData === void 0 ? void 0 : stepData.length,
108
133
  componentName: componentName
109
134
  });
110
135
  useCreateComponentStepChange({
111
- totalStepCount: totalStepCount,
136
+ firstIncludedStep: firstIncludedStep,
137
+ lastIncludedStep: lastIncludedStep,
138
+ stepData: stepData,
112
139
  onNext: onNext,
113
140
  isSubmitDisabled: isDisabled,
114
141
  setCurrentStep: setCurrentStep,
@@ -181,8 +208,7 @@ export var CreateTearsheet = /*#__PURE__*/forwardRef(function (_ref, ref) {
181
208
  });
182
209
  },
183
210
  setStepData: setStepData,
184
- stepData: stepData,
185
- totalStepCount: totalStepCount
211
+ stepData: stepData
186
212
  }
187
213
  }, React.Children.map(children, function (child, index) {
188
214
  return /*#__PURE__*/React.createElement(StepNumberContext.Provider, {
@@ -1,20 +1,20 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
 
4
4
  /**
5
- * Copyright IBM Corp. 2021, 2021
5
+ * Copyright IBM Corp. 2021, 2022
6
6
  *
7
7
  * This source code is licensed under the Apache-2.0 license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
9
  */
10
- import React, { forwardRef, useContext, useEffect } from 'react';
10
+ import React, { forwardRef, useContext, useEffect, useState } from 'react';
11
11
  import PropTypes from 'prop-types';
12
12
  import cx from 'classnames';
13
13
  import { Column, FormGroup, Row } from 'carbon-components-react';
14
14
  import { StepsContext, StepNumberContext } from './CreateTearsheet';
15
15
  import { pkg } from '../../settings';
16
16
  import pconsole from '../../global/js/utils/pconsole';
17
- import { usePreviousValue } from '../../global/js/hooks';
17
+ import { usePreviousValue, useRetrieveStepData } from '../../global/js/hooks';
18
18
  var componentName = 'CreateTearsheetStep';
19
19
  var blockClass = "".concat(pkg.prefix, "--tearsheet-create__step");
20
20
  export var CreateTearsheetStep = /*#__PURE__*/forwardRef(function (_ref, ref) {
@@ -22,57 +22,57 @@ export var CreateTearsheetStep = /*#__PURE__*/forwardRef(function (_ref, ref) {
22
22
 
23
23
  var children = _ref.children,
24
24
  className = _ref.className,
25
- subtitle = _ref.subtitle,
26
25
  description = _ref.description,
27
26
  disableSubmit = _ref.disableSubmit,
28
- introStep = _ref.introStep,
29
- title = _ref.title,
30
- hasFieldset = _ref.hasFieldset,
31
27
  fieldsetLegendText = _ref.fieldsetLegendText,
28
+ hasFieldset = _ref.hasFieldset,
29
+ includeStep = _ref.includeStep,
30
+ introStep = _ref.introStep,
32
31
  onNext = _ref.onNext,
33
32
  onMount = _ref.onMount,
34
- secondaryLabel = _ref.secondaryLabel;
35
- var steps = useContext(StepsContext);
33
+ secondaryLabel = _ref.secondaryLabel,
34
+ subtitle = _ref.subtitle,
35
+ title = _ref.title;
36
+ var stepsContext = useContext(StepsContext);
36
37
  var stepNumber = useContext(StepNumberContext);
38
+
39
+ var _useState = useState(),
40
+ _useState2 = _slicedToArray(_useState, 2),
41
+ shouldIncludeStep = _useState2[0],
42
+ setShouldIncludeStep = _useState2[1];
43
+
37
44
  var previousState = usePreviousValue({
38
- currentStep: steps === null || steps === void 0 ? void 0 : steps.currentStep
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
39
54
  }); // This useEffect reports back the onNext and onMount values so that they can be used
40
55
  // in the appropriate custom hooks.
41
56
 
42
57
  useEffect(function () {
43
- 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)) {
44
- steps === null || steps === void 0 ? void 0 : steps.setOnNext(onNext);
45
- steps === null || steps === void 0 ? void 0 : steps.setOnMount(onMount);
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);
46
61
  }
47
- }, [onMount, onNext, steps, stepNumber, previousState === null || previousState === void 0 ? void 0 : previousState.currentStep]); // This useEffect makes sure that every CreateTearsheetStep reports back it's
48
- // title, secondaryLabel, and introStep props so that it can be sent to the CreateInfluencer.
62
+ }, [onMount, onNext, stepsContext, stepNumber, previousState === null || previousState === void 0 ? void 0 : previousState.currentStep]); // Used to take the `includeStep` prop and use it as a local state value
49
63
 
50
64
  useEffect(function () {
51
- var _steps$stepData, _steps$stepData2;
52
-
53
- 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) {
54
- return item.title === title;
55
- });
56
-
57
- 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)) {
58
- steps === null || steps === void 0 ? void 0 : steps.setStepData(function (prev) {
59
- return [].concat(_toConsumableArray(prev), [{
60
- title: title,
61
- secondaryLabel: secondaryLabel,
62
- introStep: introStep
63
- }]);
64
- });
65
- }
66
- }, [steps, title, secondaryLabel, introStep]); // Whenever we are the current step, supply our disableSubmit value to the
65
+ setShouldIncludeStep(includeStep);
66
+ }, [includeStep, stepsContext, title]); // Whenever we are the current step, supply our disableSubmit value to the
67
67
  // steps container context so that it can manage the 'Next' button appropriately.
68
68
 
69
69
  useEffect(function () {
70
- if (stepNumber === (steps === null || steps === void 0 ? void 0 : steps.currentStep)) {
71
- steps.setIsDisabled(disableSubmit);
70
+ if (stepNumber === (stepsContext === null || stepsContext === void 0 ? void 0 : stepsContext.currentStep)) {
71
+ stepsContext.setIsDisabled(disableSubmit);
72
72
  }
73
- }, [steps, stepNumber, disableSubmit, onNext]);
74
- return steps ? /*#__PURE__*/React.createElement("div", {
75
- className: cx(blockClass, className, (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__step--hidden-step"), stepNumber !== (steps === null || steps === void 0 ? void 0 : steps.currentStep)), _defineProperty(_cx, "".concat(blockClass, "__step--visible-step"), stepNumber === (steps === null || steps === void 0 ? void 0 : steps.currentStep)), _cx)),
73
+ }, [stepsContext, stepNumber, disableSubmit, onNext]);
74
+ return stepsContext ? /*#__PURE__*/React.createElement("div", {
75
+ 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)),
76
76
  ref: ref
77
77
  }, /*#__PURE__*/React.createElement(Row, null, /*#__PURE__*/React.createElement(Column, {
78
78
  xlg: 12,
@@ -130,6 +130,12 @@ CreateTearsheetStep.propTypes = {
130
130
  */
131
131
  hasFieldset: PropTypes.bool,
132
132
 
133
+ /**
134
+ * 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
135
+ * 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
136
+ */
137
+ includeStep: PropTypes.bool,
138
+
133
139
  /**
134
140
  * This prop can be used on the first step to mark it as an intro step, which will not render the progress indicator steps
135
141
  */
@@ -168,5 +174,6 @@ CreateTearsheetStep.propTypes = {
168
174
  // component needs to make a choice or assumption when a prop is not supplied.
169
175
 
170
176
  CreateTearsheetStep.defaultProps = {
171
- hasFieldset: true
177
+ hasFieldset: true,
178
+ includeStep: true
172
179
  };
@@ -6,13 +6,13 @@ var _excluded = ["value1", "setValue1"];
6
6
  /* eslint-disable react/prop-types */
7
7
 
8
8
  /**
9
- * Copyright IBM Corp. 2021, 2021
9
+ * Copyright IBM Corp. 2021, 2022
10
10
  *
11
11
  * This source code is licensed under the Apache-2.0 license found in the
12
12
  * LICENSE file in the root directory of this source tree.
13
13
  */
14
14
  import React, { useState } from 'react';
15
- import { Button, Column, InlineNotification, RadioButtonGroup, RadioButton, Row, TextInput, Toggle, NumberInput } from 'carbon-components-react';
15
+ import { Button, Column, InlineNotification, RadioButtonGroup, RadioButton, Row, TextInput, Toggle, NumberInput, Checkbox } from 'carbon-components-react';
16
16
  import cx from 'classnames';
17
17
  import { pkg } from '../../../settings';
18
18
  import { CreateTearsheet } from '../CreateTearsheet';
@@ -107,6 +107,11 @@ export var MultiStepTearsheet = function MultiStepTearsheet(_ref2) {
107
107
  isInvalid = _useState22[0],
108
108
  setIsInvalid = _useState22[1];
109
109
 
110
+ var _useState23 = useState(false),
111
+ _useState24 = _slicedToArray(_useState23, 2),
112
+ shouldIncludeAdditionalStep = _useState24[0],
113
+ setShouldIncludeAdditionalStep = _useState24[1];
114
+
110
115
  var clearCreateData = function clearCreateData() {
111
116
  setStepOneTextInputValue('');
112
117
  setTopicDescriptionValue('');
@@ -117,6 +122,7 @@ export var MultiStepTearsheet = function MultiStepTearsheet(_ref2) {
117
122
  setIsInvalid(false);
118
123
  setOpen(false);
119
124
  setValue1('');
125
+ setShouldIncludeAdditionalStep(false);
120
126
  };
121
127
 
122
128
  return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("style", null, ".".concat(blockClass, " { opacity: 0 }"), ";"), /*#__PURE__*/React.createElement(Button, {
@@ -219,12 +225,26 @@ export var MultiStepTearsheet = function MultiStepTearsheet(_ref2) {
219
225
  onToggle: function onToggle(event) {
220
226
  return setShouldReject(event);
221
227
  }
222
- })))), /*#__PURE__*/React.createElement(CustomStep, {
228
+ }), /*#__PURE__*/React.createElement(Checkbox, {
229
+ labelText: "Include additional step",
230
+ id: "include-additional-step-checkbox",
231
+ onChange: function onChange(value) {
232
+ return setShouldIncludeAdditionalStep(value);
233
+ },
234
+ checked: shouldIncludeAdditionalStep
235
+ })))), /*#__PURE__*/React.createElement(CreateTearsheetStep, {
236
+ title: "Dynamic step",
237
+ subtitle: "Dynamic step subtitle",
238
+ description: "This is an example showing how to include a dynamic step into the CreateTearsheet",
239
+ hasFieldset: false,
240
+ includeStep: shouldIncludeAdditionalStep
241
+ }, "dynamic step content"), /*#__PURE__*/React.createElement(CustomStep, {
223
242
  title: "Location",
224
243
  subtitle: "Custom step subtitle",
225
244
  description: "Custom step description (see storybook implementation for new custom step capability)",
226
245
  value1: value1,
227
- setValue1: setValue1
246
+ setValue1: setValue1,
247
+ hasFieldset: false
228
248
  }), /*#__PURE__*/React.createElement(CreateTearsheetStep, {
229
249
  title: "Partitions",
230
250
  disableSubmit: !stepTwoTextInputValue,
@@ -3,7 +3,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  /* eslint-disable react/prop-types */
4
4
 
5
5
  /**
6
- * Copyright IBM Corp. 2021, 2021
6
+ * Copyright IBM Corp. 2021, 2022
7
7
  *
8
8
  * This source code is licensed under the Apache-2.0 license found in the
9
9
  * LICENSE file in the root directory of this source tree.
@@ -154,14 +154,16 @@ export var MultiStepWithIntro = function MultiStepWithIntro(_ref) {
154
154
  size: "lg"
155
155
  }), /*#__PURE__*/React.createElement("span", {
156
156
  className: "".concat(pkg.prefix, "--tearsheet-create-multi-step--custom-tile-label")
157
- }, "Plus")))), selectedCategory === 'plus' && /*#__PURE__*/React.createElement(CreateTearsheetStep, {
157
+ }, "Plus")))), /*#__PURE__*/React.createElement(CreateTearsheetStep, {
158
158
  title: "Conditional step",
159
159
  subtitle: "This step will only show for plus category creation flows",
160
- hasFieldset: false
161
- }, "conditional step content"), selectedCategory === 'standard' && /*#__PURE__*/React.createElement(CreateTearsheetStep, {
160
+ hasFieldset: false,
161
+ includeStep: selectedCategory === 'plus'
162
+ }, "This step will only show for plus create flows"), /*#__PURE__*/React.createElement(CreateTearsheetStep, {
162
163
  title: "Standard step only",
163
- hasFieldset: false
164
- }, "This step will only show for standard flows"), /*#__PURE__*/React.createElement(CreateTearsheetStep, {
164
+ hasFieldset: false,
165
+ includeStep: selectedCategory === 'standard'
166
+ }, "This step will only show for standard create flows"), /*#__PURE__*/React.createElement(CreateTearsheetStep, {
165
167
  onNext: function onNext() {
166
168
  return new Promise(function (resolve, reject) {
167
169
  setTimeout(function () {
@@ -0,0 +1,154 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["className", "columns", "data"];
4
+
5
+ /**
6
+ * Copyright IBM Corp. 2022, 2022
7
+ *
8
+ * This source code is licensed under the Apache-2.0 license found in the
9
+ * LICENSE file in the root directory of this source tree.
10
+ */
11
+ // Import portions of React that are needed.
12
+ import React, { useMemo } from 'react';
13
+ import { useBlockLayout, useTable } from 'react-table';
14
+ import { FixedSizeList } from 'react-window'; // Other standard imports.
15
+
16
+ import PropTypes from 'prop-types';
17
+ import cx from 'classnames';
18
+ import { getDevtoolsProps } from '../../global/js/utils/devtools';
19
+ import { pkg
20
+ /*, carbon */
21
+ } from '../../settings';
22
+ import { getScrollbarWidth } from '../../global/js/utils/getScrollbarWidth'; // The block part of our conventional BEM class names (blockClass__E--M).
23
+
24
+ var blockClass = "".concat(pkg.prefix, "--data-spreadsheet");
25
+ var componentName = 'DataSpreadsheet';
26
+ /**
27
+ * DataSpreadsheet: used to organize and display large amounts of structured data, separated by columns and rows in a grid-like format.
28
+ */
29
+
30
+ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
31
+ var className = _ref.className,
32
+ columns = _ref.columns,
33
+ data = _ref.data,
34
+ rest = _objectWithoutProperties(_ref, _excluded);
35
+
36
+ var defaultColumn = useMemo(function () {
37
+ return {
38
+ width: 150,
39
+ rowHeaderWidth: 64
40
+ };
41
+ }, []);
42
+ var scrollBarSize = useMemo(function () {
43
+ return getScrollbarWidth();
44
+ }, []);
45
+
46
+ var _useTable = useTable({
47
+ columns: columns,
48
+ data: data,
49
+ defaultColumn: defaultColumn
50
+ }, useBlockLayout),
51
+ getTableProps = _useTable.getTableProps,
52
+ getTableBodyProps = _useTable.getTableBodyProps,
53
+ headerGroups = _useTable.headerGroups,
54
+ rows = _useTable.rows,
55
+ totalColumnsWidth = _useTable.totalColumnsWidth,
56
+ prepareRow = _useTable.prepareRow;
57
+
58
+ var RenderRow = React.useCallback(function (_ref2) {
59
+ var index = _ref2.index,
60
+ style = _ref2.style;
61
+ var row = rows[index];
62
+ prepareRow(row);
63
+ return /*#__PURE__*/React.createElement("div", _extends({}, row.getRowProps({
64
+ style: style
65
+ }), {
66
+ className: "tr",
67
+ "data-row-index": index
68
+ }), /*#__PURE__*/React.createElement("button", {
69
+ type: "button",
70
+ className: cx("".concat(blockClass, "__td"), "".concat(blockClass, "__td-th")),
71
+ style: {
72
+ width: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeaderWidth,
73
+ display: 'flex',
74
+ justifyContent: 'flex-end',
75
+ alignItems: 'center'
76
+ }
77
+ }, index + 1), row.cells.map(function (cell, index) {
78
+ return /*#__PURE__*/React.createElement("button", _extends({
79
+ key: "cell_".concat(index)
80
+ }, cell.getCellProps(), {
81
+ type: "button",
82
+ className: "".concat(blockClass, "__td")
83
+ }), cell.render('Cell'));
84
+ }));
85
+ }, [prepareRow, rows, defaultColumn.rowHeaderWidth]);
86
+ return /*#__PURE__*/React.createElement("div", _extends({}, rest, getTableProps(), getDevtoolsProps(componentName), {
87
+ className: cx(blockClass, className),
88
+ ref: ref,
89
+ role: "grid"
90
+ }), /*#__PURE__*/React.createElement("div", null, headerGroups.map(function (headerGroup, index) {
91
+ return /*#__PURE__*/React.createElement("div", _extends({
92
+ key: "header_".concat(index)
93
+ }, headerGroup.getHeaderGroupProps(), {
94
+ className: "".concat(blockClass, "__tr")
95
+ }), /*#__PURE__*/React.createElement("button", {
96
+ type: "button",
97
+ className: "".concat(blockClass, "__th"),
98
+ style: {
99
+ width: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeaderWidth
100
+ }
101
+ }, "\xA0"), headerGroup.headers.map(function (column, index) {
102
+ return /*#__PURE__*/React.createElement("button", _extends({
103
+ key: "column_".concat(index)
104
+ }, column.getHeaderProps(), {
105
+ type: "button",
106
+ className: "".concat(blockClass, "__th")
107
+ }), column.render('Header'));
108
+ }));
109
+ })), /*#__PURE__*/React.createElement("div", getTableBodyProps(), /*#__PURE__*/React.createElement(FixedSizeList, {
110
+ height: 400,
111
+ itemCount: rows.length,
112
+ itemSize: 36,
113
+ width: totalColumnsWidth + scrollBarSize
114
+ }, RenderRow)));
115
+ }); // Return a placeholder if not released and not enabled by feature flag
116
+
117
+ DataSpreadsheet = pkg.checkComponentEnabled(DataSpreadsheet, componentName); // The display name of the component, used by React. Note that displayName
118
+ // is used in preference to relying on function.name.
119
+
120
+ DataSpreadsheet.displayName = componentName; // The types and DocGen commentary for the component props,
121
+ // in alphabetical order (for consistency).
122
+ // See https://www.npmjs.com/package/prop-types#usage.
123
+
124
+ DataSpreadsheet.propTypes = {
125
+ /**
126
+ * Provide an optional class to be applied to the containing node.
127
+ */
128
+ className: PropTypes.string,
129
+
130
+ /**
131
+ * The data that will build the column headers
132
+ */
133
+ columns: PropTypes.arrayOf(PropTypes.shape({
134
+ Header: PropTypes.string,
135
+ accessor: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
136
+ Cell: PropTypes.func // optional cell formatter
137
+
138
+ })),
139
+
140
+ /**
141
+ * The spreadsheet data that will be rendered in the body of the spreadsheet component
142
+ */
143
+ data: PropTypes.arrayOf(PropTypes.shape)
144
+ /* TODO: add types and DocGen for all props. */
145
+
146
+ }; // Default values for component props. Default values are not required for
147
+ // props that are required, nor for props where the component can apply
148
+ // 'undefined' values reasonably. Default values should be provided when the
149
+ // component needs to make a choice or assumption when a prop is not supplied.
150
+
151
+ DataSpreadsheet.defaultProps = {
152
+ data: [],
153
+ columns: []
154
+ };
@@ -0,0 +1,47 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
+
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
+
7
+ // cspell:disable
8
+ var pets = ['dog', 'cat', 'bird', 'lizard', 'frog', 'hamster', 'fish', 'rabbit', 'snake'];
9
+ var petNames = ['Bruno', 'Willow', 'Kona', 'Heidi', 'Rusty', 'Bonnie', 'Cash', 'Gucci', 'Brody', 'Emma', 'Loki', 'Angel', 'Astro', 'Sherman', 'Layla', 'Peanut', 'Grace', 'Mickey', 'Sasha', 'Finn', 'Tucker', 'Bear', 'Mocha', 'Roscoe']; // cspell:enable
10
+
11
+ var range = function range(len) {
12
+ var arr = [];
13
+
14
+ for (var i = 0; i < len; i++) {
15
+ arr.push(i);
16
+ }
17
+
18
+ return arr;
19
+ };
20
+
21
+ var newPet = function newPet() {
22
+ return {
23
+ petType: pets[Math.floor(Math.random() * pets.length)],
24
+ firstName: petNames[Math.floor(Math.random() * petNames.length)],
25
+ age: Math.floor(Math.random() * 30),
26
+ visits: Math.floor(Math.random() * 40),
27
+ health: Math.floor(Math.random() * 100)
28
+ };
29
+ };
30
+
31
+ export var generateData = function generateData() {
32
+ for (var _len = arguments.length, lens = new Array(_len), _key = 0; _key < _len; _key++) {
33
+ lens[_key] = arguments[_key];
34
+ }
35
+
36
+ var makeDataLevel = function makeDataLevel() {
37
+ var depth = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
38
+ var len = lens[depth];
39
+ return range(len).map(function () {
40
+ return _objectSpread(_objectSpread({}, newPet()), {}, {
41
+ subRows: lens[depth + 1] ? makeDataLevel(depth + 1) : undefined
42
+ });
43
+ });
44
+ };
45
+
46
+ return makeDataLevel();
47
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2022
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ export { DataSpreadsheet } from './DataSpreadsheet';
@@ -107,7 +107,7 @@ EmptyState.propTypes = {
107
107
  /**
108
108
  * Empty state subtext
109
109
  */
110
- subtitle: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired,
110
+ subtitle: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
111
111
 
112
112
  /**
113
113
  * Empty state heading
@@ -30,7 +30,7 @@ export var EmptyStateContent = function EmptyStateContent(_ref) {
30
30
  title = _ref.title;
31
31
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("h3", {
32
32
  className: cx("".concat(blockClass, "__header"), _defineProperty({}, "".concat(blockClass, "__header--small"), size === 'sm'))
33
- }, title), /*#__PURE__*/React.createElement("p", {
33
+ }, title), subtitle && /*#__PURE__*/React.createElement("p", {
34
34
  className: cx("".concat(blockClass, "__subtitle"), _defineProperty({}, "".concat(blockClass, "__subtitle--small"), size === 'sm'))
35
35
  }, subtitle), (action === null || action === void 0 ? void 0 : action.text) && (action === null || action === void 0 ? void 0 : action.onClick) && /*#__PURE__*/React.createElement(Button, _extends({}, action, {
36
36
  className: "".concat(blockClass, "__action-button"),
@@ -76,7 +76,7 @@ EmptyStateContent.propTypes = {
76
76
  /**
77
77
  * Empty state subtitle
78
78
  */
79
- subtitle: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired,
79
+ subtitle: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
80
80
 
81
81
  /**
82
82
  * Empty state title
@@ -99,7 +99,7 @@ ErrorEmptyState.propTypes = {
99
99
  /**
100
100
  * Empty state subtitle
101
101
  */
102
- subtitle: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired,
102
+ subtitle: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
103
103
 
104
104
  /**
105
105
  * Empty state title
@@ -99,7 +99,7 @@ NoDataEmptyState.propTypes = {
99
99
  /**
100
100
  * Empty state subtitle
101
101
  */
102
- subtitle: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired,
102
+ subtitle: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
103
103
 
104
104
  /**
105
105
  * Empty state title
@@ -99,7 +99,7 @@ NoTagsEmptyState.propTypes = {
99
99
  /**
100
100
  * Empty state subtitle
101
101
  */
102
- subtitle: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired,
102
+ subtitle: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
103
103
 
104
104
  /**
105
105
  * Empty state title
@@ -99,7 +99,7 @@ NotFoundEmptyState.propTypes = {
99
99
  /**
100
100
  * Empty state subtitle
101
101
  */
102
- subtitle: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired,
102
+ subtitle: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
103
103
 
104
104
  /**
105
105
  * Empty state title
@@ -99,7 +99,7 @@ NotificationsEmptyState.propTypes = {
99
99
  /**
100
100
  * Empty state subtitle
101
101
  */
102
- subtitle: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired,
102
+ subtitle: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
103
103
 
104
104
  /**
105
105
  * Empty state title
@@ -99,7 +99,7 @@ UnauthorizedEmptyState.propTypes = {
99
99
  /**
100
100
  * Empty state subtitle
101
101
  */
102
- subtitle: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired,
102
+ subtitle: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
103
103
 
104
104
  /**
105
105
  * Empty state title