@carbon/ibm-products 2.6.1 → 2.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. package/css/index-full-carbon.css +6368 -5849
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +3 -3
  4. package/css/index-full-carbon.min.css.map +1 -1
  5. package/css/index-without-carbon-released-only.css +24 -23
  6. package/css/index-without-carbon-released-only.css.map +1 -1
  7. package/css/index-without-carbon-released-only.min.css +2 -2
  8. package/css/index-without-carbon-released-only.min.css.map +1 -1
  9. package/css/index-without-carbon.css +1428 -278
  10. package/css/index-without-carbon.css.map +1 -1
  11. package/css/index-without-carbon.min.css +3 -3
  12. package/css/index-without-carbon.min.css.map +1 -1
  13. package/css/index.css +1902 -1767
  14. package/css/index.css.map +1 -1
  15. package/css/index.min.css +3 -3
  16. package/css/index.min.css.map +1 -1
  17. package/es/components/AddSelect/AddSelectRow.js +2 -1
  18. package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +6 -7
  19. package/es/components/ButtonMenu/ButtonMenu.js +4 -0
  20. package/es/components/ButtonSetWithOverflow/ButtonSetWithOverflow.js +21 -28
  21. package/es/components/ComboButton/ComboButton.js +5 -0
  22. package/es/components/CreateTearsheet/CreateTearsheet.js +30 -14
  23. package/es/components/CreateTearsheet/CreateTearsheetStep.js +10 -4
  24. package/es/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +3 -0
  25. package/es/components/DataSpreadsheet/DataSpreadsheet.js +1 -1
  26. package/es/components/Datagrid/Datagrid/Datagrid.js +12 -7
  27. package/es/components/Datagrid/Datagrid/DatagridContent.js +18 -14
  28. package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +128 -10
  29. package/es/components/Datagrid/Datagrid/DatagridToolbar.js +8 -14
  30. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +1 -23
  31. package/es/components/Datagrid/Datagrid/addons/stateReducer.js +111 -0
  32. package/es/components/Datagrid/Datagrid.docs-page.js +6 -0
  33. package/es/components/Datagrid/useDatagrid.js +5 -2
  34. package/es/components/Datagrid/utils/DatagridActions.js +9 -10
  35. package/es/components/Datagrid/utils/getColTitle.js +25 -0
  36. package/es/components/NotificationsPanel/NotificationsPanel.js +8 -10
  37. package/es/components/OptionsTile/OptionsTile.js +2 -4
  38. package/es/components/PageHeader/PageHeaderUtils.js +10 -3
  39. package/es/components/TooltipTrigger/TooltipTrigger.js +62 -0
  40. package/es/components/TooltipTrigger/index.js +8 -0
  41. package/es/components/TooltipTrigger/useExample.js +49 -0
  42. package/es/components/UserProfileImage/UserProfileImage.js +7 -6
  43. package/es/global/js/hooks/useCreateComponentStepChange.js +98 -49
  44. package/es/global/js/hooks/useResizeObserver.js +19 -3
  45. package/es/global/js/hooks/useRetrieveStepData.js +1 -1
  46. package/es/global/js/utils/StoryDocsPage.js +0 -1
  47. package/es/global/js/utils/test-helper.js +97 -43
  48. package/es/settings.js +8 -2
  49. package/lib/components/AddSelect/AddSelectRow.js +2 -1
  50. package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +5 -6
  51. package/lib/components/ButtonMenu/ButtonMenu.js +5 -1
  52. package/lib/components/ButtonSetWithOverflow/ButtonSetWithOverflow.js +20 -27
  53. package/lib/components/ComboButton/ComboButton.js +5 -0
  54. package/lib/components/CreateTearsheet/CreateTearsheet.js +30 -14
  55. package/lib/components/CreateTearsheet/CreateTearsheetStep.js +10 -4
  56. package/lib/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +3 -0
  57. package/lib/components/DataSpreadsheet/DataSpreadsheet.js +1 -1
  58. package/lib/components/Datagrid/Datagrid/Datagrid.js +12 -7
  59. package/lib/components/Datagrid/Datagrid/DatagridContent.js +17 -13
  60. package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +131 -10
  61. package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +7 -13
  62. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +4 -26
  63. package/lib/components/Datagrid/Datagrid/addons/stateReducer.js +122 -0
  64. package/lib/components/Datagrid/Datagrid.docs-page.js +6 -0
  65. package/lib/components/Datagrid/useDatagrid.js +5 -2
  66. package/lib/components/Datagrid/utils/DatagridActions.js +8 -9
  67. package/lib/components/Datagrid/utils/getColTitle.js +32 -0
  68. package/lib/components/NotificationsPanel/NotificationsPanel.js +8 -10
  69. package/lib/components/OptionsTile/OptionsTile.js +2 -4
  70. package/lib/components/PageHeader/PageHeaderUtils.js +10 -3
  71. package/lib/components/TooltipTrigger/TooltipTrigger.js +67 -0
  72. package/lib/components/TooltipTrigger/index.js +12 -0
  73. package/lib/components/TooltipTrigger/useExample.js +58 -0
  74. package/lib/components/UserProfileImage/UserProfileImage.js +6 -5
  75. package/lib/global/js/hooks/useCreateComponentStepChange.js +98 -49
  76. package/lib/global/js/hooks/useResizeObserver.js +19 -3
  77. package/lib/global/js/hooks/useRetrieveStepData.js +1 -1
  78. package/lib/global/js/utils/StoryDocsPage.js +0 -1
  79. package/lib/global/js/utils/test-helper.js +99 -44
  80. package/lib/settings.js +8 -2
  81. package/package.json +14 -14
  82. package/scss/components/APIKeyModal/_storybook-styles.scss +1 -1
  83. package/scss/components/AboutModal/_storybook-styles.scss +1 -1
  84. package/scss/components/ActionSet/_storybook-styles.scss +1 -1
  85. package/scss/components/CreateFullPage/_storybook-styles.scss +1 -1
  86. package/scss/components/CreateModal/_storybook-styles.scss +1 -1
  87. package/scss/components/CreateSidePanel/_storybook-styles.scss +1 -1
  88. package/scss/components/CreateTearsheet/_storybook-styles.scss +1 -1
  89. package/scss/components/CreateTearsheetNarrow/_storybook-styles.scss +1 -1
  90. package/scss/components/Datagrid/_storybook-styles.scss +1 -1
  91. package/scss/components/Datagrid/styles/_datagrid.scss +65 -0
  92. package/scss/components/EditSidePanel/_storybook-styles.scss +1 -1
  93. package/scss/components/EditTearsheet/_storybook-styles.scss +1 -1
  94. package/scss/components/EditTearsheetNarrow/_storybook-styles.scss +1 -1
  95. package/scss/components/EditUpdateCards/_storybook-styles.scss +1 -1
  96. package/scss/components/ExpressiveCard/_storybook-styles.scss +1 -1
  97. package/scss/components/NotificationsPanel/_storybook-styles.scss +1 -1
  98. package/scss/components/OptionsTile/_storybook-styles.scss +1 -1
  99. package/scss/components/PageHeader/_page-header.scss +8 -4
  100. package/scss/components/Tearsheet/_storybook-styles.scss +1 -1
  101. package/scss/components/TooltipTrigger/_index-with-carbon.scss +8 -0
  102. package/scss/components/TooltipTrigger/_index.scss +8 -0
  103. package/scss/components/TooltipTrigger/_storybook-styles.scss +6 -0
  104. package/scss/components/TooltipTrigger/_tooltip-trigger.scss +29 -0
  105. package/scss/components/WebTerminal/_storybook-styles.scss +1 -1
  106. package/scss/components/_index-with-carbon.scss +1 -0
  107. package/scss/components/_index.scss +1 -0
@@ -19,6 +19,7 @@ import useRowSize from './useRowSize';
19
19
  import useHeaderRow from './Datagrid/DatagridHeaderRow';
20
20
  import useFlexResize from './useFlexResize';
21
21
  import useFloatingScroll from './useFloatingScroll';
22
+ import { stateReducer } from './Datagrid/addons/stateReducer';
22
23
  var useDatagrid = function useDatagrid(params) {
23
24
  var defaultPlugins = [useFlexLayout, useHeaderRow, useSkeletonRows, useResizeColumns, useRowRenderer, useDefaultStringRenderer, useRowSize, useFilters, useGlobalFilter, useSortBy, useExpanded];
24
25
  var defaultEndPlugins = [usePagination, useRowSelect, useFlexResize, useFloatingScroll];
@@ -29,9 +30,11 @@ var useDatagrid = function useDatagrid(params) {
29
30
  for (var _len = arguments.length, plugins = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
30
31
  plugins[_key - 1] = arguments[_key];
31
32
  }
32
- var tableState = useTable.apply(void 0, [_objectSpread({
33
+ var tableState = useTable.apply(void 0, [_objectSpread(_objectSpread({
33
34
  tableId: tableId
34
- }, params)].concat(defaultPlugins, plugins, defaultEndPlugins, _toConsumableArray(clientEndPlugins)));
35
+ }, params), {}, {
36
+ stateReducer: stateReducer
37
+ })].concat(defaultPlugins, plugins, defaultEndPlugins, _toConsumableArray(clientEndPlugins)));
35
38
  return tableState;
36
39
  };
37
40
  export default useDatagrid;
@@ -7,8 +7,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
7
7
  */
8
8
 
9
9
  import { Add, ChevronDown, Download, Filter, Restart } from '@carbon/react/icons';
10
- import { Button, ComposedModal, Dropdown, IconButton, ModalBody, ModalFooter, ModalHeader, OverflowMenu, OverflowMenuItem, TableToolbarContent, TableToolbarSearch } from '@carbon/react';
11
- import { ButtonMenu, ButtonMenuItem } from '../../ButtonMenu';
10
+ import { Button, ComposedModal, Dropdown, IconButton, ModalBody, ModalFooter, ModalHeader, OverflowMenu, OverflowMenuItem, TableToolbarContent, TableToolbarSearch, MenuButton, MenuItem } from '@carbon/react';
12
11
  import React, { useLayoutEffect, useState } from 'react';
13
12
  import { action } from '@storybook/addon-actions';
14
13
  import { pkg } from '../../../settings';
@@ -151,18 +150,18 @@ export var DatagridActions = function DatagridActions(datagridState) {
151
150
  onClick: downloadCsv
152
151
  })), CustomizeColumnsButton && /*#__PURE__*/React.createElement("div", {
153
152
  style: style
154
- }, /*#__PURE__*/React.createElement(CustomizeColumnsButton, null)), /*#__PURE__*/React.createElement(RowSizeDropdown, rowSizeDropdownProps), /*#__PURE__*/React.createElement(ButtonMenu, {
153
+ }, /*#__PURE__*/React.createElement(CustomizeColumnsButton, null)), /*#__PURE__*/React.createElement(RowSizeDropdown, rowSizeDropdownProps), /*#__PURE__*/React.createElement(MenuButton, {
155
154
  label: "Primary button",
156
155
  renderIcon: ChevronDown,
157
- menuOptionsClass: "".concat(blockClass, "__toolbar-options")
158
- }, /*#__PURE__*/React.createElement(ButtonMenuItem, {
159
- itemText: "Option 1",
156
+ className: "".concat(blockClass, "__toolbar-options")
157
+ }, /*#__PURE__*/React.createElement(MenuItem, {
158
+ label: "Option 1",
160
159
  onClick: action("Click on ButtonMenu Option 1")
161
- }), /*#__PURE__*/React.createElement(ButtonMenuItem, {
162
- itemText: "Option 2",
160
+ }), /*#__PURE__*/React.createElement(MenuItem, {
161
+ label: "Option 2",
163
162
  onClick: action("Click on ButtonMenu Option 2")
164
- }), /*#__PURE__*/React.createElement(ButtonMenuItem, {
165
- itemText: "Option 3",
163
+ }), /*#__PURE__*/React.createElement(MenuItem, {
164
+ label: "Option 3",
166
165
  onClick: action("Click on ButtonMenu Option 3")
167
166
  }))) : /*#__PURE__*/React.createElement(TableToolbarContent, null, renderFilterPanelButton(), /*#__PURE__*/React.createElement(TableToolbarSearch, {
168
167
  size: "xl",
@@ -0,0 +1,25 @@
1
+ // This function recursively looks for the nested header element until we can find the key which contains the title.
2
+ // This can happen if multiple hooks are used together that manipulate the rendering of the column
3
+ // header, such as `useColumnCenterAlign` and `useSortableColumns`.
4
+ var getNestedTitle = function getNestedTitle(component) {
5
+ if (component && !component.key) {
6
+ return getNestedTitle(component.children);
7
+ }
8
+ if (component && component.key && typeof component.key === 'string') {
9
+ return component.key;
10
+ }
11
+ };
12
+ var getColTitle = function getColTitle(col) {
13
+ var _col$Header;
14
+ if (!col) {
15
+ return;
16
+ }
17
+ var checkTitle = function checkTitle() {
18
+ if (col.Header().props.children.props && col.Header().props.children.props.title) {
19
+ return col.Header().props.children.props.title;
20
+ }
21
+ return getNestedTitle(col.Header().props.children.props);
22
+ };
23
+ return typeof (col === null || col === void 0 ? void 0 : col.Header) === 'function' ? checkTitle() : col === null || col === void 0 || (_col$Header = col.Header) === null || _col$Header === void 0 || (_col$Header = _col$Header.props) === null || _col$Header === void 0 ? void 0 : _col$Header.title;
24
+ };
25
+ export default getColTitle;
@@ -20,6 +20,7 @@ import { getDevtoolsProps } from '../../global/js/utils/devtools';
20
20
  import { useClickOutside } from '../../global/js/hooks';
21
21
  import { pkg } from '../../settings';
22
22
  import { timeAgo } from './utils';
23
+ import { prepareProps } from '../../global/js/utils/props-helper';
23
24
  import { NotificationsEmptyState } from '../EmptyStates/NotificationsEmptyState';
24
25
 
25
26
  // Carbon and package components we use.
@@ -300,7 +301,7 @@ export var NotificationsPanel = /*#__PURE__*/React.forwardRef(function (_ref, re
300
301
  }, notification.title), notification.description && notification.description.length && renderDescription(notification.id), notification.link && notification.link.text && notification.link.url && /*#__PURE__*/React.createElement(Link, _extends({
301
302
  href: notification.link.url,
302
303
  className: "".concat(blockClass, "__notifications-link")
303
- }, notification.link.optional), notification.link.text)), /*#__PURE__*/React.createElement(IconButton, {
304
+ }, prepareProps({}, notification.link, ['text', 'url'])), notification.link.text)), /*#__PURE__*/React.createElement(IconButton, {
304
305
  align: "left",
305
306
  kind: "ghost",
306
307
  size: "sm",
@@ -331,7 +332,7 @@ export var NotificationsPanel = /*#__PURE__*/React.forwardRef(function (_ref, re
331
332
  className: "".concat(blockClass, "__header-container")
332
333
  }, /*#__PURE__*/React.createElement("div", {
333
334
  className: "".concat(blockClass, "__header-flex")
334
- }, /*#__PURE__*/React.createElement("h1", {
335
+ }, /*#__PURE__*/React.createElement("h2", {
335
336
  className: "".concat(blockClass, "__header")
336
337
  }, title), /*#__PURE__*/React.createElement(Button, {
337
338
  size: "sm",
@@ -340,7 +341,7 @@ export var NotificationsPanel = /*#__PURE__*/React.forwardRef(function (_ref, re
340
341
  onClick: function onClick() {
341
342
  return onDismissAllNotifications();
342
343
  }
343
- }, dismissAllLabel)), /*#__PURE__*/React.createElement(Toggle, {
344
+ }, dismissAllLabel)), onDoNotDisturbChange && /*#__PURE__*/React.createElement(Toggle, {
344
345
  size: "sm",
345
346
  className: "".concat(blockClass, "__do-not-disturb-toggle"),
346
347
  id: "".concat(blockClass, "__do-not-disturb-toggle-component"),
@@ -420,10 +421,7 @@ NotificationsPanel.propTypes = {
420
421
  description: PropTypes.string,
421
422
  link: PropTypes.shape({
422
423
  url: PropTypes.string,
423
- text: PropTypes.string,
424
- optional: PropTypes.shape({
425
- // Add optional props here
426
- })
424
+ text: PropTypes.string
427
425
  }),
428
426
  unread: PropTypes.bool,
429
427
  onNotificationClick: PropTypes.func
@@ -441,11 +439,11 @@ NotificationsPanel.propTypes = {
441
439
  */
442
440
  dismissSingleNotificationIconDescription: PropTypes.string,
443
441
  /**
444
- * Determines if the `Do not disturb` toggle is on or off when the component is rendered
442
+ * Optional: Determines if the `Do not disturb` toggle is on or off when the component is rendered
445
443
  */
446
444
  doNotDisturbDefaultToggled: PropTypes.bool,
447
445
  /**
448
- * Label for Do not disturb toggle
446
+ * Optional: Label for Do not disturb toggle
449
447
  */
450
448
  doNotDisturbLabel: PropTypes.string,
451
449
  /**
@@ -493,7 +491,7 @@ NotificationsPanel.propTypes = {
493
491
  */
494
492
  onDismissSingleNotification: PropTypes.func,
495
493
  /**
496
- * Function that returns the current selected value of the disable notification toggle
494
+ * Optional: function that returns the current selected value of the disable notification toggle
497
495
  */
498
496
  onDoNotDisturbChange: PropTypes.func,
499
497
  /**
@@ -217,13 +217,11 @@ export var OptionsTile = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
217
217
  id: "".concat(id, "-toggle"),
218
218
  className: "".concat(blockClass, "__toggle"),
219
219
  toggled: enabled,
220
- labelA: "",
221
- labelB: "",
222
220
  "aria-labelledby": titleId,
221
+ hideLabel: true,
223
222
  onToggle: onToggle,
224
223
  size: "sm",
225
- disabled: isLocked,
226
- labelText: title
224
+ disabled: isLocked
227
225
  })), isExpandable ? /*#__PURE__*/React.createElement("details", {
228
226
  open: isOpen,
229
227
  ref: detailsRef
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  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; }
3
3
  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; }
4
4
  /**
5
- * Copyright IBM Corp. 2020, 2021
5
+ * Copyright IBM Corp. 2020, 2023
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.
@@ -65,11 +65,14 @@ export var utilCheckUpdateVerticalSpace = function utilCheckUpdateVerticalSpace(
65
65
  var scrollableContainer = scrollableAncestor(headerRef.current);
66
66
 
67
67
  /* istanbul ignore next */
68
- var scrollableContainerTop = scrollableContainer ? scrollableContainer.scrollTop - scrollableContainer.getBoundingClientRect().top : 0;
68
+ var scrollableContainerTop = scrollableContainer ? scrollableContainer.getBoundingClientRect().top : 0;
69
+
70
+ /* istanbul ignore next */
71
+ var offsetMeasuringTop = offsetTopMeasuringRef.current ? offsetTopMeasuringRef.current.getBoundingClientRect().top : 0;
69
72
 
70
73
  // The header offset calculation is either going to work out at 0 if we have no gap between scrolling container
71
74
  // top and the measuring ref top, or the difference between. It does not change on scroll or resize.
72
- update.headerOffset = (offsetTopMeasuringRef.current ? offsetTopMeasuringRef.current.getBoundingClientRect().top : 0) + scrollableContainerTop;
75
+ update.headerOffset = offsetMeasuringTop - scrollableContainerTop;
73
76
 
74
77
  /* istanbul ignore next */
75
78
  update.breadcrumbRowHeight = breadcrumbRowEl ? breadcrumbRowEl.clientHeight : 0;
@@ -127,6 +130,10 @@ export var utilCheckUpdateVerticalSpace = function utilCheckUpdateVerticalSpace(
127
130
  update.pageActionsSpaceAbove = titleRowEl.clientHeight - pageActionsEl.clientHeight + update.titleRowSpaceAbove - (isNaN(val) ? 0 : val);
128
131
  }
129
132
  }
133
+ if (!hasActionBar && pageActionsEl) {
134
+ // adjust headerTopValue when there are no page actions or action bar items (margin above title row)
135
+ update.headerTopValue -= update.titleRowSpaceAbove;
136
+ }
130
137
  return _objectSpread(_objectSpread({}, previous), update);
131
138
  });
132
139
  };
@@ -0,0 +1,62 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["children", "className"];
4
+ /**
5
+ * Copyright IBM Corp. 2023, 2023
6
+ *
7
+ * This source code is licensed under the Apache-2.0 license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+
11
+ // Import portions of React that are needed.
12
+ import React from 'react';
13
+
14
+ // Other standard imports.
15
+ import PropTypes from 'prop-types';
16
+ import cx from 'classnames';
17
+ import { pkg } from '../../settings';
18
+
19
+ // The block part of our conventional BEM class names (blockClass__E--M).
20
+ var blockClass = "".concat(pkg.prefix, "--tooltip-trigger");
21
+ var componentName = 'TooltipTrigger';
22
+
23
+ // NOTE: the component SCSS is not imported here: it is rolled up separately.
24
+
25
+ /**
26
+ * This is an tooltip trigger as Carbon Tooltip requires an active element to work but provides
27
+ * no blanked button.
28
+ */
29
+ export var TooltipTrigger = function TooltipTrigger(_ref) {
30
+ var children = _ref.children,
31
+ className = _ref.className,
32
+ rest = _objectWithoutProperties(_ref, _excluded);
33
+ return /*#__PURE__*/React.createElement("button", _extends({
34
+ type: "button"
35
+ }, rest, {
36
+ className: cx(blockClass,
37
+ // Apply the block class to the main HTML element
38
+ className // Apply any supplied class names to the main HTML element.
39
+ )
40
+ }), children);
41
+ };
42
+
43
+ // Return a placeholder if not released and not enabled by feature flag.
44
+ TooltipTrigger = pkg.checkComponentEnabled(TooltipTrigger, componentName);
45
+
46
+ // The display name of the component, used by React. Note that displayName
47
+ // is used in preference to relying on function.name.
48
+ TooltipTrigger.displayName = componentName;
49
+
50
+ // The types and DocGen commentary for the component props,
51
+ // in alphabetical order (for consistency).
52
+ // See https://www.npmjs.com/package/prop-types#usage.
53
+ TooltipTrigger.propTypes = {
54
+ /**
55
+ * Child content of tooltip trigger
56
+ */
57
+ children: PropTypes.node,
58
+ /**
59
+ * Provide an optional class to be applied to the containing node.
60
+ */
61
+ className: PropTypes.string
62
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Copyright IBM Corp. 2023, 2023
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
+
8
+ export { TooltipTrigger } from './TooltipTrigger';
@@ -0,0 +1,49 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ /**
3
+ * Copyright IBM Corp. 2023, 2023
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 { useState, useEffect } from 'react';
9
+ import { pkg } from '../../settings';
10
+ var useExample = function useExample(initialTime) {
11
+ // NOTE: hooks cannot be called conditionally.
12
+ //
13
+ // ** If the hook uses other hooks then they must be called,
14
+ // ** this could lead to unexpected behavior.
15
+ // ** As some hooks may still be called even if the condition is false.
16
+
17
+ var _useState = useState(
18
+ // Disable hook in a safe way if possible, else use despite feature disabled.
19
+ // Either a console error or warning will be logged.
20
+ initialTime),
21
+ _useState2 = _slicedToArray(_useState, 2),
22
+ time = _useState2[0],
23
+ setTime = _useState2[1];
24
+
25
+ // Use of the feature flag to
26
+ var feature = 'ExampleComponent.useExample';
27
+ var tryFeature = initialTime !== undefined;
28
+ var featureEnabled = tryFeature && pkg.checkReportFeatureEnabled(feature);
29
+ if (tryFeature && !featureEnabled) {
30
+ // Output a useful message if the feature is disabled.
31
+ console.warn("Disabled feature \"".concat(feature, "\" does not change the initialTime."));
32
+ }
33
+
34
+ // Actual hook is code is below
35
+ useEffect(function () {
36
+ if (!featureEnabled) {
37
+ return;
38
+ }
39
+
40
+ // turn off all or part of the feature
41
+ if (time > 0) {
42
+ setTimeout(function () {
43
+ setTime(Math.max(0, time - 0.1));
44
+ }, 100);
45
+ }
46
+ }, [featureEnabled, time]);
47
+ return [time];
48
+ };
49
+ export default useExample;
@@ -20,7 +20,8 @@ import { pkg } from '../../settings';
20
20
 
21
21
  // Carbon and package components we use.
22
22
  import { User, Group } from '@carbon/react/icons';
23
- import { IconButton } from '@carbon/react';
23
+ import { Tooltip, usePrefix } from '@carbon/react';
24
+ import { TooltipTrigger } from '../TooltipTrigger';
24
25
 
25
26
  // The block part of our conventional BEM class names (blockClass__E--M).
26
27
  var blockClass = "".concat(pkg.prefix, "--user-profile-image");
@@ -49,6 +50,7 @@ export var UserProfileImage = /*#__PURE__*/React.forwardRef(function (_ref, ref)
49
50
  _ref$tooltipAlignment = _ref.tooltipAlignment,
50
51
  tooltipAlignment = _ref$tooltipAlignment === void 0 ? defaults.tooltipAlignment : _ref$tooltipAlignment,
51
52
  rest = _objectWithoutProperties(_ref, _excluded);
53
+ var carbonPrefix = usePrefix();
52
54
  var icons = {
53
55
  user: {
54
56
  md: function md(props) {
@@ -124,12 +126,11 @@ export var UserProfileImage = /*#__PURE__*/React.forwardRef(function (_ref, ref)
124
126
  className: cx([blockClass, className, "".concat(blockClass, "--").concat(size), "".concat(blockClass, "--").concat(theme), "".concat(blockClass, "--").concat(backgroundColor || getRandomColor())])
125
127
  }, getDevtoolsProps(componentName)), /*#__PURE__*/React.createElement(FillItem, null));
126
128
  };
127
- return FillItem && (tooltipText ? /*#__PURE__*/React.createElement(IconButton, {
129
+ return FillItem && (tooltipText ? /*#__PURE__*/React.createElement(Tooltip, {
130
+ align: tooltipAlignment,
128
131
  label: tooltipText,
129
- className: "".concat(blockClass, "__tooltip"),
130
- kind: "ghost",
131
- align: tooltipAlignment
132
- }, renderUserProfileImage()) : renderUserProfileImage());
132
+ className: "".concat(blockClass, "__tooltip ").concat(carbonPrefix, "--icon-tooltip")
133
+ }, /*#__PURE__*/React.createElement(TooltipTrigger, null, renderUserProfileImage())) : renderUserProfileImage());
133
134
  });
134
135
 
135
136
  // Return a placeholder if not released and not enabled by feature flag
@@ -1,7 +1,7 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
2
  import _regeneratorRuntime from "@babel/runtime/regenerator";
3
3
  /**
4
- * Copyright IBM Corp. 2021, 2022
4
+ * Copyright IBM Corp. 2021, 2023
5
5
  *
6
6
  * This source code is licensed under the Apache-2.0 license found in the
7
7
  * LICENSE file in the root directory of this source tree.
@@ -12,16 +12,19 @@ export var useCreateComponentStepChange = function useCreateComponentStepChange(
12
12
  var firstIncludedStep = _ref.firstIncludedStep,
13
13
  lastIncludedStep = _ref.lastIncludedStep,
14
14
  stepData = _ref.stepData,
15
+ onPrevious = _ref.onPrevious,
15
16
  onNext = _ref.onNext,
16
17
  isSubmitDisabled = _ref.isSubmitDisabled,
17
18
  setCurrentStep = _ref.setCurrentStep,
18
19
  setIsSubmitting = _ref.setIsSubmitting,
19
- setShouldViewAll = _ref.setShouldViewAll,
20
+ _ref$setLoadingPrevio = _ref.setLoadingPrevious,
21
+ setLoadingPrevious = _ref$setLoadingPrevio === void 0 ? null : _ref$setLoadingPrevio,
22
+ _ref$loadingPrevious = _ref.loadingPrevious,
23
+ loadingPrevious = _ref$loadingPrevious === void 0 ? false : _ref$loadingPrevious,
20
24
  onClose = _ref.onClose,
21
25
  onRequestSubmit = _ref.onRequestSubmit,
22
26
  componentName = _ref.componentName,
23
27
  currentStep = _ref.currentStep,
24
- shouldViewAll = _ref.shouldViewAll,
25
28
  backButtonText = _ref.backButtonText,
26
29
  cancelButtonText = _ref.cancelButtonText,
27
30
  submitButtonText = _ref.submitButtonText,
@@ -43,6 +46,21 @@ export var useCreateComponentStepChange = function useCreateComponentStepChange(
43
46
  return prev;
44
47
  });
45
48
  }, [setCurrentStep, setIsSubmitting, stepData]);
49
+ var moveToPreviousStep = useCallback(function () {
50
+ if (componentName !== 'CreateFullPage') {
51
+ setLoadingPrevious(false);
52
+ }
53
+ setCurrentStep(function (prev) {
54
+ // Find previous included step to render
55
+ // There will always be a previous step otherwise we will
56
+ // have disabled the back button since we have reached the first visible step
57
+ do {
58
+ var _stepData2;
59
+ prev--;
60
+ } while (!((_stepData2 = stepData[prev - 1]) !== null && _stepData2 !== void 0 && _stepData2.shouldIncludeStep));
61
+ return prev;
62
+ });
63
+ }, [setCurrentStep, stepData, setLoadingPrevious, componentName]);
46
64
 
47
65
  // useEffect to handle multi step logic
48
66
  useEffect(function () {
@@ -51,7 +69,6 @@ export var useCreateComponentStepChange = function useCreateComponentStepChange(
51
69
  setCurrentStep(0);
52
70
  }
53
71
  setIsSubmitting(false);
54
- setShouldViewAll(false);
55
72
  onClose();
56
73
  };
57
74
  var handleOnRequestSubmit = /*#__PURE__*/function () {
@@ -81,104 +98,136 @@ export var useCreateComponentStepChange = function useCreateComponentStepChange(
81
98
  return _ref2.apply(this, arguments);
82
99
  };
83
100
  }();
84
- var handleNext = /*#__PURE__*/function () {
101
+ var handlePrevious = /*#__PURE__*/function () {
85
102
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
86
103
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
87
104
  while (1) switch (_context2.prev = _context2.next) {
105
+ case 0:
106
+ if (!(componentName === 'CreateFullPage')) {
107
+ _context2.next = 2;
108
+ break;
109
+ }
110
+ return _context2.abrupt("return");
111
+ case 2:
112
+ setLoadingPrevious(true);
113
+ if (!(typeof onPrevious === 'function')) {
114
+ _context2.next = 15;
115
+ break;
116
+ }
117
+ _context2.prev = 4;
118
+ _context2.next = 7;
119
+ return onPrevious();
120
+ case 7:
121
+ moveToPreviousStep();
122
+ _context2.next = 13;
123
+ break;
124
+ case 10:
125
+ _context2.prev = 10;
126
+ _context2.t0 = _context2["catch"](4);
127
+ console.warn("".concat(componentName, " onBack error: ").concat(_context2.t0));
128
+ case 13:
129
+ _context2.next = 16;
130
+ break;
131
+ case 15:
132
+ moveToPreviousStep();
133
+ case 16:
134
+ case "end":
135
+ return _context2.stop();
136
+ }
137
+ }, _callee2, null, [[4, 10]]);
138
+ }));
139
+ return function handlePrevious() {
140
+ return _ref3.apply(this, arguments);
141
+ };
142
+ }();
143
+ var handleNext = /*#__PURE__*/function () {
144
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
145
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
146
+ while (1) switch (_context3.prev = _context3.next) {
88
147
  case 0:
89
148
  setIsSubmitting(true);
90
149
  if (!(typeof onNext === 'function')) {
91
- _context2.next = 14;
150
+ _context3.next = 14;
92
151
  break;
93
152
  }
94
- _context2.prev = 2;
95
- _context2.next = 5;
153
+ _context3.prev = 2;
154
+ _context3.next = 5;
96
155
  return onNext();
97
156
  case 5:
98
157
  continueToNextStep();
99
- _context2.next = 12;
158
+ _context3.next = 12;
100
159
  break;
101
160
  case 8:
102
- _context2.prev = 8;
103
- _context2.t0 = _context2["catch"](2);
161
+ _context3.prev = 8;
162
+ _context3.t0 = _context3["catch"](2);
104
163
  setIsSubmitting(false);
105
- console.warn("".concat(componentName, " onNext error: ").concat(_context2.t0));
164
+ console.warn("".concat(componentName, " onNext error: ").concat(_context3.t0));
106
165
  case 12:
107
- _context2.next = 15;
166
+ _context3.next = 15;
108
167
  break;
109
168
  case 14:
110
169
  continueToNextStep();
111
170
  case 15:
112
171
  case "end":
113
- return _context2.stop();
172
+ return _context3.stop();
114
173
  }
115
- }, _callee2, null, [[2, 8]]);
174
+ }, _callee3, null, [[2, 8]]);
116
175
  }));
117
176
  return function handleNext() {
118
- return _ref3.apply(this, arguments);
177
+ return _ref4.apply(this, arguments);
119
178
  };
120
179
  }();
121
180
  var handleSubmit = /*#__PURE__*/function () {
122
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
123
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
124
- while (1) switch (_context3.prev = _context3.next) {
181
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
182
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
183
+ while (1) switch (_context4.prev = _context4.next) {
125
184
  case 0:
126
185
  setIsSubmitting(true);
127
186
  // last step should have onNext as well
128
187
  if (!(typeof onNext === 'function')) {
129
- _context3.next = 15;
188
+ _context4.next = 15;
130
189
  break;
131
190
  }
132
- _context3.prev = 2;
133
- _context3.next = 5;
191
+ _context4.prev = 2;
192
+ _context4.next = 5;
134
193
  return onNext();
135
194
  case 5:
136
- _context3.next = 7;
195
+ _context4.next = 7;
137
196
  return handleOnRequestSubmit();
138
197
  case 7:
139
- _context3.next = 13;
198
+ _context4.next = 13;
140
199
  break;
141
200
  case 9:
142
- _context3.prev = 9;
143
- _context3.t0 = _context3["catch"](2);
201
+ _context4.prev = 9;
202
+ _context4.t0 = _context4["catch"](2);
144
203
  setIsSubmitting(false);
145
- console.warn("".concat(componentName, " onNext error: ").concat(_context3.t0));
204
+ console.warn("".concat(componentName, " onNext error: ").concat(_context4.t0));
146
205
  case 13:
147
- _context3.next = 17;
206
+ _context4.next = 17;
148
207
  break;
149
208
  case 15:
150
- _context3.next = 17;
209
+ _context4.next = 17;
151
210
  return handleOnRequestSubmit();
152
211
  case 17:
153
212
  case "end":
154
- return _context3.stop();
213
+ return _context4.stop();
155
214
  }
156
- }, _callee3, null, [[2, 9]]);
215
+ }, _callee4, null, [[2, 9]]);
157
216
  }));
158
217
  return function handleSubmit() {
159
- return _ref4.apply(this, arguments);
218
+ return _ref5.apply(this, arguments);
160
219
  };
161
220
  }();
162
221
  if ((stepData === null || stepData === void 0 ? void 0 : stepData.length) > 0) {
163
222
  var buttons = [];
164
- if ((stepData === null || stepData === void 0 ? void 0 : stepData.length) > 1 && !shouldViewAll) {
223
+ if ((stepData === null || stepData === void 0 ? void 0 : stepData.length) > 1) {
165
224
  buttons.push({
166
225
  key: 'create-action-button-back',
167
226
  label: backButtonText,
168
- onClick: function onClick() {
169
- return setCurrentStep(function (prev) {
170
- // Find previous included step to render
171
- // There will always be a previous step otherwise we will
172
- // have disabled the back button since we have reached the first visible step
173
- do {
174
- var _stepData2;
175
- prev--;
176
- } while (!((_stepData2 = stepData[prev - 1]) !== null && _stepData2 !== void 0 && _stepData2.shouldIncludeStep));
177
- return prev;
178
- });
179
- },
227
+ onClick: handlePrevious,
180
228
  kind: 'secondary',
181
- disabled: currentStep === firstIncludedStep
229
+ disabled: currentStep === firstIncludedStep,
230
+ loading: loadingPrevious
182
231
  });
183
232
  }
184
233
  buttons.push({
@@ -191,8 +240,8 @@ export var useCreateComponentStepChange = function useCreateComponentStepChange(
191
240
  });
192
241
  buttons.push({
193
242
  key: 'create-action-button-submit',
194
- label: shouldViewAll ? submitButtonText : currentStep < lastIncludedStep ? nextButtonText : submitButtonText,
195
- onClick: shouldViewAll ? handleSubmit : currentStep < lastIncludedStep ? handleNext : handleSubmit,
243
+ label: currentStep < lastIncludedStep ? nextButtonText : submitButtonText,
244
+ onClick: currentStep < lastIncludedStep ? handleNext : handleSubmit,
196
245
  disabled: isSubmitDisabled,
197
246
  kind: 'primary',
198
247
  loading: isSubmitting,
@@ -200,5 +249,5 @@ export var useCreateComponentStepChange = function useCreateComponentStepChange(
200
249
  });
201
250
  setCreateComponentActions(buttons);
202
251
  }
203
- }, [firstIncludedStep, lastIncludedStep, stepData, onNext, isSubmitDisabled, backButtonText, cancelButtonText, currentStep, onClose, nextButtonText, submitButtonText, onRequestSubmit, isSubmitting, shouldViewAll, componentBlockClass, componentName, continueToNextStep, setCurrentStep, setCreateComponentActions, setIsSubmitting, setShouldViewAll, setModalIsOpen]);
252
+ }, [firstIncludedStep, lastIncludedStep, stepData, onNext, isSubmitDisabled, backButtonText, cancelButtonText, currentStep, onClose, nextButtonText, submitButtonText, onRequestSubmit, isSubmitting, componentBlockClass, componentName, continueToNextStep, setCurrentStep, setCreateComponentActions, setIsSubmitting, setModalIsOpen, moveToPreviousStep, onPrevious, setLoadingPrevious, loadingPrevious]);
204
253
  };