@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
@@ -0,0 +1,56 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ //
3
+ // Copyright IBM Corp. 2022
4
+ //
5
+ // This source code is licensed under the Apache-2.0 license found in the
6
+ // LICENSE file in the root directory of this source tree.
7
+ //
8
+ import React from 'react';
9
+ import { Breadcrumb, BreadcrumbItem } from 'carbon-components-react';
10
+ import PropTypes from 'prop-types';
11
+ var componentName = 'AddSelectBreadcrumbs';
12
+ export var AddSelectBreadcrumbs = function AddSelectBreadcrumbs(_ref) {
13
+ var itemsLabel = _ref.itemsLabel,
14
+ path = _ref.path,
15
+ setPath = _ref.setPath;
16
+
17
+ var clickHandler = function clickHandler(id) {
18
+ var newPath = _toConsumableArray(path);
19
+
20
+ var pathIdx = newPath.findIndex(function (entry) {
21
+ return entry.id === id;
22
+ });
23
+ var finalPath = newPath.splice(0, pathIdx + 1);
24
+ setPath(finalPath);
25
+ };
26
+
27
+ var resetPath = function resetPath() {
28
+ setPath([]);
29
+ };
30
+
31
+ return /*#__PURE__*/React.createElement(Breadcrumb, {
32
+ noTrailingSlash: true
33
+ }, /*#__PURE__*/React.createElement(BreadcrumbItem, {
34
+ onClick: resetPath
35
+ }, itemsLabel), path.map(function (entry, idx, arr) {
36
+ var isCurrentPage = idx === arr.length - 1;
37
+
38
+ var crumbHandler = function crumbHandler() {
39
+ if (!isCurrentPage) {
40
+ clickHandler(entry.id);
41
+ }
42
+ };
43
+
44
+ return /*#__PURE__*/React.createElement(BreadcrumbItem, {
45
+ key: entry.id,
46
+ isCurrentPage: isCurrentPage,
47
+ onClick: crumbHandler
48
+ }, entry.title);
49
+ }));
50
+ };
51
+ AddSelectBreadcrumbs.propTypes = {
52
+ itemsLabel: PropTypes.string,
53
+ path: PropTypes.array,
54
+ setPath: PropTypes.func
55
+ };
56
+ AddSelectBreadcrumbs.displayName = componentName;
@@ -0,0 +1,94 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ //
3
+ // Copyright IBM Corp. 2022
4
+ //
5
+ // This source code is licensed under the Apache-2.0 license found in the
6
+ // LICENSE file in the root directory of this source tree.
7
+ //
8
+ import React from 'react';
9
+ import { Checkbox, RadioButton, StructuredListRow, StructuredListWrapper, StructuredListBody, StructuredListCell } from 'carbon-components-react';
10
+ import { ChevronRight16 } from '@carbon/icons-react';
11
+ import PropTypes from 'prop-types';
12
+ import { pkg } from '../../settings';
13
+ var componentName = 'AddSelectList';
14
+ export var AddSelectList = function AddSelectList(_ref) {
15
+ var filteredItems = _ref.filteredItems,
16
+ multi = _ref.multi,
17
+ multiSelection = _ref.multiSelection,
18
+ path = _ref.path,
19
+ setMultiSelection = _ref.setMultiSelection,
20
+ setPath = _ref.setPath,
21
+ setSingleSelection = _ref.setSingleSelection,
22
+ singleSelection = _ref.singleSelection;
23
+ var blockClass = "".concat(pkg.prefix, "--add-select__selections");
24
+
25
+ var handleSingleSelection = function handleSingleSelection(value) {
26
+ setSingleSelection(value);
27
+ };
28
+
29
+ var handleMultiSelection = function handleMultiSelection(value, checked) {
30
+ if (checked) {
31
+ var newValues = [].concat(_toConsumableArray(multiSelection), [value]);
32
+ setMultiSelection(newValues);
33
+ } else {
34
+ var _newValues = multiSelection.filter(function (v) {
35
+ return v !== value;
36
+ });
37
+
38
+ setMultiSelection(_newValues);
39
+ }
40
+ };
41
+
42
+ var onNavigateItem = function onNavigateItem(_ref2) {
43
+ var id = _ref2.id,
44
+ title = _ref2.title;
45
+ setPath([].concat(_toConsumableArray(path), [{
46
+ id: id,
47
+ title: title
48
+ }]));
49
+ };
50
+
51
+ return /*#__PURE__*/React.createElement("div", {
52
+ className: "".concat(blockClass, "-wrapper")
53
+ }, /*#__PURE__*/React.createElement(StructuredListWrapper, {
54
+ selection: true,
55
+ className: "".concat(blockClass)
56
+ }, /*#__PURE__*/React.createElement(StructuredListBody, null, filteredItems.map(function (item) {
57
+ return /*#__PURE__*/React.createElement(StructuredListRow, {
58
+ key: item.id
59
+ }, /*#__PURE__*/React.createElement(StructuredListCell, null, /*#__PURE__*/React.createElement("div", {
60
+ className: "".concat(blockClass, "-cell-wrapper")
61
+ }, multi ? /*#__PURE__*/React.createElement(Checkbox, {
62
+ className: "".concat(blockClass, "-checkbox"),
63
+ onChange: function onChange(value) {
64
+ return handleMultiSelection(item.id, value);
65
+ },
66
+ labelText: item.title,
67
+ id: item.id,
68
+ checked: multiSelection.includes(item.id)
69
+ }) : /*#__PURE__*/React.createElement(RadioButton, {
70
+ className: "".concat(blockClass, "-radio"),
71
+ name: "add-select-selections",
72
+ id: item.id,
73
+ value: item.value,
74
+ labelText: item.title,
75
+ onChange: handleSingleSelection,
76
+ selected: item.value === singleSelection
77
+ }), item.children && /*#__PURE__*/React.createElement(ChevronRight16, {
78
+ onClick: function onClick() {
79
+ return onNavigateItem(item);
80
+ }
81
+ }))));
82
+ }))));
83
+ };
84
+ AddSelectList.propTypes = {
85
+ filteredItems: PropTypes.array,
86
+ multi: PropTypes.bool,
87
+ multiSelection: PropTypes.array,
88
+ path: PropTypes.array,
89
+ setMultiSelection: PropTypes.func,
90
+ setPath: PropTypes.func,
91
+ setSingleSelection: PropTypes.func,
92
+ singleSelection: PropTypes.string
93
+ };
94
+ AddSelectList.displayName = componentName;
@@ -0,0 +1,110 @@
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
2
+ var _excluded = ["children"];
3
+ //
4
+ // Copyright IBM Corp. 2022
5
+ //
6
+ // This source code is licensed under the Apache-2.0 license found in the
7
+ // LICENSE file in the root directory of this source tree.
8
+ //
9
+ import React from 'react';
10
+ import { Tag, Accordion, AccordionItem, Button } from 'carbon-components-react';
11
+ import { SubtractAlt32 } from '@carbon/icons-react';
12
+ import PropTypes from 'prop-types';
13
+ import { NoDataEmptyState } from '../../components/EmptyStates/NoDataEmptyState';
14
+ import { pkg } from '../../settings';
15
+ var componentName = 'AddSelectSidebar';
16
+ export var AddSelectSidebar = function AddSelectSidebar(_ref) {
17
+ var influencerTitle = _ref.influencerTitle,
18
+ items = _ref.items,
19
+ multiSelection = _ref.multiSelection,
20
+ noSelectionDescription = _ref.noSelectionDescription,
21
+ noSelectionTitle = _ref.noSelectionTitle,
22
+ removeIconDescription = _ref.removeIconDescription,
23
+ setMultiSelection = _ref.setMultiSelection;
24
+ var blockClass = "".concat(pkg.prefix, "--add-select__sidebar");
25
+
26
+ var handleItemRemove = function handleItemRemove(id) {
27
+ var newSelections = multiSelection.filter(function (v) {
28
+ return v !== id;
29
+ });
30
+ setMultiSelection(newSelections);
31
+ }; // utility to flatten the list of items and their children into a single searchable array
32
+
33
+
34
+ var flattenItems = function flattenItems(arr) {
35
+ return arr.reduce(function (prev, cur) {
36
+ var children = cur.children,
37
+ item = _objectWithoutProperties(cur, _excluded);
38
+
39
+ return prev.concat(item).concat(children ? flattenItems(children) : []);
40
+ }, []);
41
+ };
42
+
43
+ var flattenedItems = flattenItems(items);
44
+ var sidebarItems = multiSelection.map(function (selectedId) {
45
+ return flattenedItems.find(function (item) {
46
+ return item.id === selectedId;
47
+ });
48
+ });
49
+
50
+ var getTitle = function getTitle(_ref2) {
51
+ var title = _ref2.title,
52
+ subtitle = _ref2.subtitle,
53
+ id = _ref2.id;
54
+ return /*#__PURE__*/React.createElement("div", {
55
+ className: "".concat(blockClass, "-accordion-title")
56
+ }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("p", null, title), /*#__PURE__*/React.createElement("p", null, subtitle)), /*#__PURE__*/React.createElement(Button, {
57
+ renderIcon: SubtractAlt32,
58
+ iconDescription: removeIconDescription,
59
+ hasIconOnly: true,
60
+ onClick: function onClick() {
61
+ return handleItemRemove(id);
62
+ },
63
+ kind: "ghost",
64
+ className: "".concat(blockClass, "-item-remove-button")
65
+ }));
66
+ };
67
+
68
+ return /*#__PURE__*/React.createElement("div", {
69
+ className: blockClass
70
+ }, /*#__PURE__*/React.createElement("div", {
71
+ className: "".concat(blockClass, "-header")
72
+ }, /*#__PURE__*/React.createElement("p", {
73
+ className: "".concat(blockClass, "-title")
74
+ }, influencerTitle), /*#__PURE__*/React.createElement(Tag, {
75
+ type: "gray",
76
+ size: "sm"
77
+ }, multiSelection.length)), multiSelection.length > 0 ? /*#__PURE__*/React.createElement(Accordion, {
78
+ align: "start"
79
+ }, sidebarItems.map(function (item) {
80
+ return /*#__PURE__*/React.createElement(AccordionItem, {
81
+ title: getTitle(item),
82
+ key: item.id
83
+ }, Object.keys(item).map(function (key) {
84
+ return /*#__PURE__*/React.createElement("div", {
85
+ className: "".concat(blockClass, "-item"),
86
+ key: key
87
+ }, /*#__PURE__*/React.createElement("p", {
88
+ className: "".concat(blockClass, "-item-header")
89
+ }, key), /*#__PURE__*/React.createElement("p", {
90
+ className: "".concat(blockClass, "-item-body")
91
+ }, item[key]));
92
+ }));
93
+ })) : /*#__PURE__*/React.createElement("div", {
94
+ className: "".concat(blockClass, "-body")
95
+ }, /*#__PURE__*/React.createElement(NoDataEmptyState, {
96
+ subtitle: noSelectionDescription,
97
+ title: noSelectionTitle,
98
+ size: "sm"
99
+ })));
100
+ };
101
+ AddSelectSidebar.propTypes = {
102
+ influencerTitle: PropTypes.string,
103
+ items: PropTypes.array,
104
+ multiSelection: PropTypes.array,
105
+ noSelectionDescription: PropTypes.string,
106
+ noSelectionTitle: PropTypes.string,
107
+ removeIconDescription: PropTypes.string,
108
+ setMultiSelection: PropTypes.func
109
+ };
110
+ AddSelectSidebar.displayName = componentName;
@@ -343,9 +343,12 @@ BreadcrumbWithOverflow.propTypes = {
343
343
  noTrailingSlash: PropTypes.bool,
344
344
 
345
345
  /**
346
- * overflowAriaLabel label for open close button overflow used for action bar items that do nto fit.
346
+ * overflowAriaLabel label for open close button overflow used for breadcrumb items that do not fit.
347
347
  */
348
- overflowAriaLabel: PropTypes.string.isRequired
348
+ overflowAriaLabel: PropTypes.string.isRequired.if(function (_ref6) {
349
+ var breadcrumbs = _ref6.breadcrumbs;
350
+ return breadcrumbs.length > 1;
351
+ })
349
352
  };
350
353
  BreadcrumbWithOverflow.defaultProps = {
351
354
  noTrailingSlash: false
@@ -104,5 +104,5 @@ ButtonMenu.propTypes = {
104
104
  size: Button.propTypes.size
105
105
  };
106
106
  ButtonMenu.defaultProps = {
107
- size: Button.defaultProps.size
107
+ size: 'default'
108
108
  };
@@ -23,7 +23,7 @@ import { Button, TextInput } from 'carbon-components-react';
23
23
  import { prepareProps } from '../../global/js/utils/props-helper';
24
24
  import { pkg, carbon } from '../../settings';
25
25
  import { getDevtoolsProps } from '../../global/js/utils/devtools';
26
- import { Checkmark16, Reset16 } from '@carbon/icons-react'; // Carbon and package components we use.
26
+ import { Checkmark16, Close16 } from '@carbon/icons-react'; // Carbon and package components we use.
27
27
 
28
28
  /* TODO: @import(s) of carbon components and other package components. */
29
29
  // The block part of our conventional BEM class names (blockClass__E--M).
@@ -131,7 +131,7 @@ export var CancelableTextEdit = /*#__PURE__*/React.forwardRef(function (_ref, re
131
131
  hasIconOnly: true,
132
132
  iconDescription: revertDescription,
133
133
  onClick: handleRevert,
134
- renderIcon: Reset16
134
+ renderIcon: Close16
135
135
  }), /*#__PURE__*/React.createElement(Button, {
136
136
  className: "".concat(blockClass, "__save"),
137
137
  kind: "ghost",
@@ -2,7 +2,8 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
4
  var _excluded = ["actionIcons", "actionsPlacement", "children", "className", "clickZone", "description", "label", "media", "mediaPosition", "onClick", "onKeyDown", "onPrimaryButtonClick", "overflowActions", "onSecondaryButtonClick", "pictogram", "primaryButtonHref", "primaryButtonIcon", "primaryButtonKind", "primaryButtonText", "productive", "secondaryButtonHref", "secondaryButtonIcon", "secondaryButtonKind", "secondaryButtonText", "title", "titleSize"],
5
- _excluded2 = ["id"];
5
+ _excluded2 = ["id"],
6
+ _excluded3 = ["id", "icon", "onClick", "iconDescription", "onKeyDown", "href"];
6
7
 
7
8
  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; }
8
9
 
@@ -88,10 +89,11 @@ export var Card = /*#__PURE__*/forwardRef(function (_ref, ref) {
88
89
  onClick = _ref3.onClick,
89
90
  iconDescription = _ref3.iconDescription,
90
91
  onKeyDown = _ref3.onKeyDown,
91
- href = _ref3.href;
92
+ href = _ref3.href,
93
+ rest = _objectWithoutProperties(_ref3, _excluded3);
92
94
 
93
95
  if (productive) {
94
- return /*#__PURE__*/React.createElement(Button, {
96
+ return /*#__PURE__*/React.createElement(Button, _extends({}, rest, {
95
97
  key: id,
96
98
  renderIcon: Icon,
97
99
  hasIconOnly: true,
@@ -100,7 +102,7 @@ export var Card = /*#__PURE__*/forwardRef(function (_ref, ref) {
100
102
  iconDescription: iconDescription,
101
103
  kind: "ghost",
102
104
  href: href
103
- });
105
+ }));
104
106
  }
105
107
 
106
108
  if (href) {
@@ -10,7 +10,7 @@ var _excluded = ["backButtonText", "cancelButtonText", "children", "className",
10
10
  * LICENSE file in the root directory of this source tree.
11
11
  */
12
12
  // Import portions of React that are needed.
13
- import React, { useState, createContext } from 'react'; // Other standard imports.
13
+ import React, { useEffect, useState, createContext } from 'react'; // Other standard imports.
14
14
 
15
15
  import PropTypes from 'prop-types';
16
16
  import cx from 'classnames';
@@ -21,6 +21,7 @@ import { Grid, ModalFooter, ComposedModal, ModalHeader, ModalBody, Button, Form
21
21
  import { CreateInfluencer } from '../CreateInfluencer';
22
22
  import { ActionSet } from '../ActionSet';
23
23
  import { usePreviousValue, useValidCreateStepCount, useCreateComponentFocus, useCreateComponentStepChange } from '../../global/js/hooks';
24
+ import { lastIndexInArray } from '../../global/js/utils/lastIndexInArray';
24
25
  var blockClass = "".concat(pkg.prefix, "--create-full-page");
25
26
  var componentName = 'CreateFullPage'; // This is a general context for the steps container
26
27
  // containing information about the state of the container
@@ -95,7 +96,30 @@ export var CreateFullPage = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
95
96
  stepData = _useState18[0],
96
97
  setStepData = _useState18[1];
97
98
 
98
- var totalStepCount = React.Children.count(children);
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];
108
+
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]);
99
123
  useCreateComponentFocus({
100
124
  previousState: previousState,
101
125
  currentStep: currentStep,
@@ -104,7 +128,9 @@ export var CreateFullPage = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
104
128
  });
105
129
  useValidCreateStepCount(stepData.length, componentName);
106
130
  useCreateComponentStepChange({
107
- totalStepCount: totalStepCount,
131
+ firstIncludedStep: firstIncludedStep,
132
+ lastIncludedStep: lastIncludedStep,
133
+ stepData: stepData,
108
134
  onNext: onNext,
109
135
  isSubmitDisabled: isDisabled,
110
136
  setCurrentStep: setCurrentStep,
@@ -158,8 +184,7 @@ export var CreateFullPage = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
158
184
  });
159
185
  },
160
186
  setStepData: setStepData,
161
- stepData: stepData,
162
- totalStepCount: totalStepCount
187
+ stepData: stepData
163
188
  }
164
189
  }, React.Children.map(children, function (child, index) {
165
190
  return /*#__PURE__*/React.createElement(StepNumberContext.Provider, {
@@ -1,5 +1,5 @@
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
5
  * Copyright IBM Corp. 2021, 2022
@@ -7,13 +7,13 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
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 { pkg } from '../../settings';
14
14
  import { FormGroup } from 'carbon-components-react';
15
15
  import { StepsContext, StepNumberContext } from './CreateFullPage';
16
- import { usePreviousValue } from '../../global/js/hooks';
16
+ import { usePreviousValue, useRetrieveStepData } from '../../global/js/hooks';
17
17
  import pconsole from '../../global/js/utils/pconsole';
18
18
  var componentName = 'CreateFullPageStep';
19
19
  var blockClass = "".concat(pkg.prefix, "--create-full-page__step");
@@ -25,6 +25,7 @@ export var CreateFullPageStep = /*#__PURE__*/forwardRef(function (_ref, ref) {
25
25
  subtitle = _ref.subtitle,
26
26
  description = _ref.description,
27
27
  disableSubmit = _ref.disableSubmit,
28
+ includeStep = _ref.includeStep,
28
29
  introStep = _ref.introStep,
29
30
  title = _ref.title,
30
31
  hasFieldset = _ref.hasFieldset,
@@ -32,47 +33,45 @@ export var CreateFullPageStep = /*#__PURE__*/forwardRef(function (_ref, ref) {
32
33
  onNext = _ref.onNext,
33
34
  onMount = _ref.onMount,
34
35
  secondaryLabel = _ref.secondaryLabel;
35
- var steps = useContext(StepsContext);
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.
49
-
62
+ }, [onMount, onNext, stepsContext, stepNumber, previousState === null || previousState === void 0 ? void 0 : previousState.currentStep]);
50
63
  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
64
+ setShouldIncludeStep(includeStep);
65
+ }, [includeStep, stepsContext, title]); // Whenever we are the current step, supply our disableSubmit value to the
67
66
  // steps container context so that it can manage the 'Next' button appropriately.
68
67
 
69
68
  useEffect(function () {
70
- if (stepNumber === (steps === null || steps === void 0 ? void 0 : steps.currentStep)) {
71
- steps.setIsDisabled(disableSubmit);
69
+ if (stepNumber === (stepsContext === null || stepsContext === void 0 ? void 0 : stepsContext.currentStep)) {
70
+ stepsContext.setIsDisabled(disableSubmit);
72
71
  }
73
- }, [steps, stepNumber, disableSubmit, onNext]);
74
- return steps ? /*#__PURE__*/React.createElement("section", {
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)),
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)),
76
75
  ref: ref
77
76
  }, /*#__PURE__*/React.createElement("h5", {
78
77
  className: "".concat(blockClass, "-title")
@@ -121,6 +120,12 @@ CreateFullPageStep.propTypes = {
121
120
  */
122
121
  hasFieldset: PropTypes.bool,
123
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
+
124
129
  /**
125
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
126
131
  */
@@ -153,4 +158,7 @@ CreateFullPageStep.propTypes = {
153
158
  * Sets the title text for a create full page step
154
159
  */
155
160
  title: PropTypes.node.isRequired
161
+ };
162
+ CreateFullPageStep.defaultProps = {
163
+ includeStep: true
156
164
  };
@@ -19,21 +19,42 @@ export var CreateInfluencer = function CreateInfluencer(_ref) {
19
19
  currentStep = _ref.currentStep,
20
20
  stepData = _ref.stepData;
21
21
 
22
- // renders the step progression components in the left influencer area
22
+ var getNumberOfDynamicStepsBeforeCurrentStep = function getNumberOfDynamicStepsBeforeCurrentStep(array, key) {
23
+ var dynamicSteps = [];
24
+ array.forEach(function (item, index) {
25
+ var _array$index;
26
+
27
+ if (((_array$index = array[index]) === null || _array$index === void 0 ? void 0 : _array$index[key]) === false && index <= currentStep - 1) {
28
+ dynamicSteps.push(item);
29
+ }
30
+ });
31
+ return dynamicSteps.length;
32
+ }; // renders the step progression components in the left influencer area
33
+
34
+
23
35
  var renderProgressSteps = function renderProgressSteps() {
24
36
  var _stepData$, _stepData$2;
25
37
 
26
38
  var extractedSteps = stepData === null || stepData === void 0 ? void 0 : stepData.filter(function (item) {
27
39
  return !(item !== null && item !== void 0 && item.introStep);
28
40
  });
41
+ var progressSteps = extractedSteps === null || extractedSteps === void 0 ? void 0 : extractedSteps.filter(function (item) {
42
+ return item === null || item === void 0 ? void 0 : item.shouldIncludeStep;
43
+ }); // To get the ProgressIndicator's `currentIndex`, accounting for dynamic steps,
44
+ // we need to subtract the number of !shouldIncludeStep/s before the current step
45
+ // which we get from `getNumberOfDynamicStepsBeforeCurrentStep()`
46
+
47
+ var totalDynamicSteps = getNumberOfDynamicStepsBeforeCurrentStep(stepData, 'shouldIncludeStep') || 0;
29
48
  return /*#__PURE__*/React.createElement("div", {
30
49
  className: "".concat(blockClass, "__left-nav")
31
50
  }, currentStep === 1 && (_stepData$ = stepData[0]) !== null && _stepData$ !== void 0 && _stepData$.introStep ? null : /*#__PURE__*/React.createElement(ProgressIndicator, {
32
- currentIndex: (_stepData$2 = stepData[0]) !== null && _stepData$2 !== void 0 && _stepData$2.introStep ? currentStep - 2 : currentStep - 1,
51
+ currentIndex: (_stepData$2 = stepData[0]) !== null && _stepData$2 !== void 0 && _stepData$2.introStep ? currentStep - totalDynamicSteps - 2 // minus 2 because we need to account for the intro step in addition to `currentIndex` being 0 index based and our steps being 1 index based
52
+ : currentStep - totalDynamicSteps - 1 // minus 1 because ProgressIndicator currentIndex prop is 0 index based, but our steps are 1 index based
53
+ ,
33
54
  spaceEqually: true,
34
55
  vertical: true,
35
56
  className: cx("".concat(blockClass, "__progress-indicator"))
36
- }, extractedSteps.map(function (step, stepIndex) {
57
+ }, progressSteps.map(function (step, stepIndex) {
37
58
  return /*#__PURE__*/React.createElement(ProgressStep, {
38
59
  label: step.title,
39
60
  key: stepIndex,
@@ -66,6 +87,7 @@ CreateInfluencer.propTypes = {
66
87
  stepData: PropTypes.arrayOf(PropTypes.shape({
67
88
  introStep: PropTypes.bool,
68
89
  secondaryLabel: PropTypes.string,
90
+ shouldIncludeStep: PropTypes.bool,
69
91
  title: PropTypes.node
70
92
  }))
71
93
  };