@carbon/ibm-products 1.2.4 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. package/css/index-full-carbon.css +662 -313
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +2 -2
  4. package/css/index-without-carbon-released-only.css +156 -81
  5. package/css/index-without-carbon-released-only.css.map +1 -1
  6. package/css/index-without-carbon-released-only.min.css +2 -2
  7. package/css/index-without-carbon.css +393 -81
  8. package/css/index-without-carbon.css.map +1 -1
  9. package/css/index-without-carbon.min.css +2 -2
  10. package/css/index.css +615 -81
  11. package/css/index.css.map +1 -1
  12. package/css/index.min.css +2 -2
  13. package/es/components/APIKeyModal/APIKeyModal.js +25 -29
  14. package/es/components/ActionBar/ActionBar.js +4 -1
  15. package/es/components/ActionSet/ActionSet.js +22 -10
  16. package/es/components/ActionSet/actions.js +25 -17
  17. package/es/components/AddSelect/AddSelect.js +157 -0
  18. package/es/components/AddSelect/index.js +7 -0
  19. package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +19 -15
  20. package/es/components/CancelableTextEdit/CancelableTextEdit.js +245 -0
  21. package/es/components/{CreateTearsheet/constants.js → CancelableTextEdit/index.js} +1 -2
  22. package/es/components/CreateFullPage/CreateFullPage.js +102 -258
  23. package/es/components/CreateFullPage/CreateFullPageStep.js +65 -13
  24. package/es/components/CreateFullPage/index.js +1 -2
  25. package/es/components/CreateInfluencer/CreateInfluencer.js +40 -220
  26. package/es/components/CreateTearsheet/CreateTearsheet.js +95 -146
  27. package/es/components/CreateTearsheet/CreateTearsheetStep.js +70 -20
  28. package/es/components/CreateTearsheet/index.js +0 -1
  29. package/es/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +87 -28
  30. package/es/components/CreateTearsheet/preview-components/MultiStepWithIntro.js +8 -6
  31. package/es/components/ExportModal/ExportModal.js +41 -12
  32. package/es/components/ImportModal/ImportModal.js +2 -1
  33. package/es/components/InlineEdit/InlineEdit.js +224 -0
  34. package/es/components/InlineEdit/index.js +7 -0
  35. package/es/components/MultiAddSelect/MultiAddSelect.js +16 -0
  36. package/es/components/MultiAddSelect/index.js +1 -0
  37. package/es/components/OptionsTile/OptionsTile.js +36 -15
  38. package/es/components/PageHeader/PageHeader.js +54 -33
  39. package/es/components/PageHeader/PageHeaderTitle.js +78 -7
  40. package/es/components/PageHeader/PageHeaderUtils.js +21 -2
  41. package/es/components/RemoveModal/RemoveModal.js +4 -2
  42. package/es/components/SidePanel/SidePanel.js +1 -1
  43. package/es/components/SingleAddSelect/SingleAddSelect.js +15 -0
  44. package/es/components/SingleAddSelect/index.js +1 -0
  45. package/es/components/TagSet/TagSet.js +4 -1
  46. package/es/components/Tearsheet/Tearsheet.js +1 -1
  47. package/es/components/Tearsheet/TearsheetNarrow.js +1 -1
  48. package/es/components/Tearsheet/TearsheetShell.js +1 -1
  49. package/es/components/Toolbar/Toolbar.js +69 -8
  50. package/es/components/index.js +5 -1
  51. package/es/global/js/hooks/index.js +1 -0
  52. package/es/global/js/hooks/useCreateComponentFocus.js +15 -19
  53. package/es/global/js/hooks/useCreateComponentStepChange.js +69 -79
  54. package/es/global/js/hooks/useResetCreateComponent.js +7 -4
  55. package/es/global/js/hooks/useRetrieveStepData.js +51 -0
  56. package/es/global/js/hooks/useValidCreateStepCount.js +4 -7
  57. package/es/global/js/package-settings.js +5 -1
  58. package/es/global/js/utils/lastIndexInArray.js +26 -0
  59. package/es/global/js/utils/story-helper.js +1 -1
  60. package/lib/components/APIKeyModal/APIKeyModal.js +25 -29
  61. package/lib/components/ActionBar/ActionBar.js +4 -1
  62. package/lib/components/ActionSet/ActionSet.js +22 -10
  63. package/lib/components/ActionSet/actions.js +25 -17
  64. package/lib/components/AddSelect/AddSelect.js +178 -0
  65. package/lib/components/AddSelect/index.js +13 -0
  66. package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +18 -14
  67. package/lib/components/CancelableTextEdit/CancelableTextEdit.js +265 -0
  68. package/lib/components/CancelableTextEdit/index.js +13 -0
  69. package/lib/components/CreateFullPage/CreateFullPage.js +102 -258
  70. package/lib/components/CreateFullPage/CreateFullPageStep.js +68 -13
  71. package/lib/components/CreateFullPage/index.js +1 -9
  72. package/lib/components/CreateInfluencer/CreateInfluencer.js +38 -231
  73. package/lib/components/CreateTearsheet/CreateTearsheet.js +97 -148
  74. package/lib/components/CreateTearsheet/CreateTearsheetStep.js +72 -19
  75. package/lib/components/CreateTearsheet/index.js +0 -8
  76. package/lib/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +86 -34
  77. package/lib/components/CreateTearsheet/preview-components/MultiStepWithIntro.js +8 -6
  78. package/lib/components/ExportModal/ExportModal.js +38 -11
  79. package/lib/components/ImportModal/ImportModal.js +2 -1
  80. package/lib/components/InlineEdit/InlineEdit.js +242 -0
  81. package/lib/components/InlineEdit/index.js +13 -0
  82. package/lib/components/MultiAddSelect/MultiAddSelect.js +37 -0
  83. package/lib/components/MultiAddSelect/index.js +13 -0
  84. package/lib/components/OptionsTile/OptionsTile.js +36 -15
  85. package/lib/components/PageHeader/PageHeader.js +54 -33
  86. package/lib/components/PageHeader/PageHeaderTitle.js +87 -9
  87. package/lib/components/PageHeader/PageHeaderUtils.js +21 -2
  88. package/lib/components/RemoveModal/RemoveModal.js +4 -2
  89. package/lib/components/SidePanel/SidePanel.js +1 -1
  90. package/lib/components/SingleAddSelect/SingleAddSelect.js +36 -0
  91. package/lib/components/SingleAddSelect/index.js +13 -0
  92. package/lib/components/TagSet/TagSet.js +4 -1
  93. package/lib/components/Tearsheet/Tearsheet.js +1 -1
  94. package/lib/components/Tearsheet/TearsheetNarrow.js +1 -1
  95. package/lib/components/Tearsheet/TearsheetShell.js +1 -1
  96. package/lib/components/Toolbar/Toolbar.js +69 -6
  97. package/lib/components/index.js +33 -1
  98. package/lib/global/js/hooks/index.js +8 -0
  99. package/lib/global/js/hooks/useCreateComponentFocus.js +15 -19
  100. package/lib/global/js/hooks/useCreateComponentStepChange.js +69 -79
  101. package/lib/global/js/hooks/useResetCreateComponent.js +7 -4
  102. package/lib/global/js/hooks/useRetrieveStepData.js +62 -0
  103. package/lib/global/js/hooks/useValidCreateStepCount.js +4 -7
  104. package/lib/global/js/package-settings.js +5 -1
  105. package/lib/global/js/utils/lastIndexInArray.js +35 -0
  106. package/lib/global/js/utils/story-helper.js +1 -1
  107. package/package.json +22 -22
  108. package/scss/components/AddSelect/_add-select.scss +84 -0
  109. package/scss/components/AddSelect/_index.scss +10 -0
  110. package/scss/components/AddSelect/_storybook-styles.scss +6 -0
  111. package/scss/components/BreadcrumbWithOverflow/_breadcrumb-with-overflow.scss +19 -15
  112. package/scss/components/CancelableTextEdit/_cancelable-text-edit.scss +211 -0
  113. package/{es/components/CreateFullPage/constants.js → scss/components/CancelableTextEdit/_index.scss} +2 -2
  114. package/scss/components/CancelableTextEdit/_storybook-styles.scss +15 -0
  115. package/scss/components/CreateFullPage/_create-full-page.scss +4 -11
  116. package/scss/components/CreateTearsheet/_create-tearsheet.scss +4 -8
  117. package/scss/components/InlineEdit/_index.scss +8 -0
  118. package/scss/components/InlineEdit/_inline-edit.scss +44 -0
  119. package/scss/components/InlineEdit/_storybook-styles.scss +15 -0
  120. package/scss/components/MultiAddSelect/_index.scss +1 -0
  121. package/scss/components/MultiAddSelect/_multi-add-select.scss +1 -0
  122. package/scss/components/MultiAddSelect/_storybook-styles.scss +6 -0
  123. package/scss/components/PageHeader/_page-header.scss +14 -4
  124. package/scss/components/SingleAddSelect/_index.scss +1 -0
  125. package/scss/components/SingleAddSelect/_single-add-select.scss +1 -0
  126. package/scss/components/SingleAddSelect/_storybook-styles.scss +6 -0
  127. package/scss/components/StatusIcon/_status-icon.scss +2 -0
  128. package/scss/components/_index.scss +4 -0
  129. package/es/components/CreateFullPage/CreateFullPageSection.js +0 -53
  130. package/es/components/CreateTearsheet/CreateTearsheetSection.js +0 -83
  131. package/es/components/CreateTearsheet/preview-components/MultiStepWithSectionsTearsheet.js +0 -327
  132. package/es/global/js/utils/hasValidType.js +0 -94
  133. package/lib/components/CreateFullPage/CreateFullPageSection.js +0 -74
  134. package/lib/components/CreateFullPage/constants.js +0 -16
  135. package/lib/components/CreateTearsheet/CreateTearsheetSection.js +0 -105
  136. package/lib/components/CreateTearsheet/constants.js +0 -17
  137. package/lib/components/CreateTearsheet/preview-components/MultiStepWithSectionsTearsheet.js +0 -354
  138. package/lib/global/js/utils/hasValidType.js +0 -110
@@ -1,7 +1,12 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _extends from "@babel/runtime/helpers/extends";
3
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
+ var _excluded = ["text", "content", "loading", "icon", "asText", "onChange", "editDescription", "editableLabel", "revertDescription", "saveDescription"];
2
5
  import React from 'react';
6
+ import PropTypes from 'prop-types';
3
7
  import cx from 'classnames';
4
8
  import { SkeletonText } from 'carbon-components-react';
9
+ import { InlineEdit } from '../';
5
10
  /**
6
11
  *
7
12
  * Utility component used by Page Header
@@ -14,14 +19,21 @@ export var PageHeaderTitle = function PageHeaderTitle(_ref) {
14
19
  title = _ref.title;
15
20
  var titleInnards; // eslint-disable-next-line
16
21
  // debugger;
17
- // eslint-disable-next-line react/prop-types
18
22
 
19
23
  var text = title.text,
20
24
  content = title.content,
21
25
  loading = title.loading,
22
26
  icon = title.icon,
23
- asText = title.asText;
27
+ asText = title.asText,
28
+ onChange = title.onChange,
29
+ editDescription = title.editDescription,
30
+ editableLabel = title.editableLabel,
31
+ revertDescription = title.revertDescription,
32
+ saveDescription = title.saveDescription,
33
+ rest = _objectWithoutProperties(title, _excluded);
34
+
24
35
  var titleText;
36
+ var isEditable = !!onChange;
25
37
 
26
38
  if (text || !content) {
27
39
  if (text === undefined && typeof title === 'string') {
@@ -32,18 +44,77 @@ export var PageHeaderTitle = function PageHeaderTitle(_ref) {
32
44
  var TitleIcon = icon;
33
45
  titleInnards = /*#__PURE__*/React.createElement(React.Fragment, null, icon && !loading ? /*#__PURE__*/React.createElement(TitleIcon, {
34
46
  className: "".concat(blockClass, "__title-icon")
35
- }) : null, /*#__PURE__*/React.createElement("span", {
36
- title: !loading ? asText : null
37
- }, loading ? /*#__PURE__*/React.createElement(SkeletonText, {
47
+ }) : null, loading ? /*#__PURE__*/React.createElement(SkeletonText, {
38
48
  className: "".concat(blockClass, "__title-skeleton")
39
- }) : text));
49
+ }) : isEditable ? /*#__PURE__*/React.createElement(InlineEdit, _extends({
50
+ hideLabel: true,
51
+ value: text,
52
+ editDescription: editDescription,
53
+ onChange: onChange,
54
+ labelText: editableLabel,
55
+ revertDescription: revertDescription,
56
+ saveDescription: saveDescription
57
+ }, rest)) : /*#__PURE__*/React.createElement("span", {
58
+ title: !loading ? asText : null
59
+ }, text));
40
60
  } else {
41
61
  titleInnards = content;
42
62
  titleText = asText;
43
63
  }
44
64
 
45
65
  return /*#__PURE__*/React.createElement("div", {
46
- className: cx("".concat(blockClass, "__title"), _defineProperty({}, "".concat(blockClass, "__title--fades"), hasBreadcrumbRow)),
66
+ className: cx("".concat(blockClass, "__title"), _defineProperty({}, "".concat(blockClass, "__title--editable"), isEditable), _defineProperty({}, "".concat(blockClass, "__title--fades"), hasBreadcrumbRow)),
47
67
  title: titleText
48
68
  }, titleInnards);
69
+ };
70
+ export var inlineEditRequired = function inlineEditRequired(_ref2) {
71
+ var onChange = _ref2.onChange;
72
+ return !!onChange;
73
+ };
74
+ PageHeaderTitle.propTypes = {
75
+ // passed from page header
76
+ blockClass: PropTypes.string.isRequired,
77
+
78
+ /**
79
+ * controlled from within page header
80
+ */
81
+ hasBreadcrumbRow: PropTypes.bool,
82
+
83
+ /**
84
+ * An optional page title supplied as a string or object with the following attributes: text, icon, loading
85
+ *
86
+ * Can be supplied either as:
87
+ * - String
88
+ * - Object containing
89
+ * - text: title string
90
+ * - icon: optional icon
91
+ * - loading: boolean shows loading indicator if true
92
+ * - onChange: function to process edits only supply if in place edit is desired
93
+ * - editDescription: description for edit button
94
+ * - editableLabel: label for edit required if onChange supplied
95
+ * - revertDescription: description for edit revert button
96
+ * - saveDescription: description for edit save button
97
+ * - Object containing user defined contents. These must fit within the area defined for the title in both main part of the header and the breadcrumb.
98
+ * - content: title or name of current location shown in main part of page header
99
+ * - breadcrumbContent: version of content used in the breadcrumb on scroll. If not supplied
100
+ * - asText: String based representation of the title
101
+ */
102
+ title: PropTypes.oneOfType([PropTypes.shape({
103
+ // Update docgen if changed
104
+ text: PropTypes.string.isRequired,
105
+ icon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
106
+ loading: PropTypes.bool,
107
+ // inline edit version properties
108
+ editDescription: PropTypes.string.isRequired.if(inlineEditRequired),
109
+ editableLabel: PropTypes.string.isRequired.if(inlineEditRequired),
110
+ id: PropTypes.string.isRequired.if(inlineEditRequired),
111
+ onChange: PropTypes.func,
112
+ revertDescription: PropTypes.string.isRequired.if(inlineEditRequired),
113
+ saveDescription: PropTypes.string.isRequired.if(inlineEditRequired) // Update docgen if changed
114
+
115
+ }), PropTypes.string, PropTypes.shape({
116
+ content: PropTypes.node.isRequired,
117
+ breadcrumbContent: PropTypes.node,
118
+ asText: PropTypes.string.isRequired
119
+ })])
49
120
  };
@@ -22,10 +22,12 @@ export var blockClass = "".concat(pkg.prefix, "--page-header");
22
22
  * @param {{}} offsetTopMeasuringRef
23
23
  * @param {{}} navigation
24
24
  * @param {boolean} disableBreadcrumbScroll
25
+ * @param {boolean} hasActionBar
26
+ * @param {boolean} widthIsNarrow
25
27
  * @param {()} setMetrics
26
28
  */
27
29
 
28
- export var utilCheckUpdateVerticalSpace = function utilCheckUpdateVerticalSpace(headerRef, offsetTopMeasuringRef, navigation, disableBreadcrumbScroll, setMetrics) {
30
+ export var utilCheckUpdateVerticalSpace = function utilCheckUpdateVerticalSpace(headerRef, offsetTopMeasuringRef, navigation, disableBreadcrumbScroll, hasActionBar, widthIsNarrow, setMetrics) {
29
31
  var dynamicRefs = {};
30
32
 
31
33
  var getDynamicRef = function getDynamicRef(selector) {
@@ -60,6 +62,7 @@ export var utilCheckUpdateVerticalSpace = function utilCheckUpdateVerticalSpace(
60
62
  var subtitleRowEl = getDynamicRef(".".concat(blockClass, "__subtitle-row"));
61
63
  var availableRowEl = getDynamicRef(".".concat(blockClass, "__available-row"));
62
64
  var navigationRowEl = getDynamicRef(".".concat(blockClass, "__navigation-row"));
65
+ var pageActionsEl = getDynamicRef(".".concat(blockClass, "__page-actions"));
63
66
  /* istanbul ignore next */
64
67
 
65
68
  update.headerHeight = headerRef.current ? headerRef.current.clientHeight : 0;
@@ -81,7 +84,8 @@ export var utilCheckUpdateVerticalSpace = function utilCheckUpdateVerticalSpace(
81
84
  update.breadcrumbRowWidth = breadcrumbRowEl ? breadcrumbRowEl.offsetWidth : 0;
82
85
  /* istanbul ignore next */
83
86
 
84
- update.breadcrumbTitleHeight = breadcrumbTitleEl ? breadcrumbTitleEl.clientHeight : 1;
87
+ update.breadcrumbTitleHeight = breadcrumbTitleEl ? breadcrumbTitleEl.offsetHeight // clientHeight returns 0 when window small
88
+ : 1;
85
89
  /* istanbul ignore next */
86
90
 
87
91
  update.titleRowHeight = titleRowEl ? titleRowEl.clientHeight : 0;
@@ -102,9 +106,19 @@ export var utilCheckUpdateVerticalSpace = function utilCheckUpdateVerticalSpace(
102
106
  update.headerTopValue += update.navigationRowHeight;
103
107
  }
104
108
 
109
+ if (!hasActionBar && !widthIsNarrow) {
110
+ // Add difference between $spacing-08 and $spacing-07 to ensure space below breadcrumb is correct on scroll
111
+ // $spacing-07 is used as size for breadcrumb when no action bar otherwise $spacing-08
112
+ update.headerTopValue += 8;
113
+ }
114
+
105
115
  if (disableBreadcrumbScroll || !navigation) {
106
116
  // adjust sticky top if no navigation or breadcrumb is to stay on screen
107
117
  update.headerTopValue += update.breadcrumbRowHeight;
118
+ } else {
119
+ if (navigation && !widthIsNarrow) {
120
+ update.headerTopValue -= 8;
121
+ }
108
122
  }
109
123
 
110
124
  if (window) {
@@ -125,6 +139,11 @@ export var utilCheckUpdateVerticalSpace = function utilCheckUpdateVerticalSpace(
125
139
  if (titleRowEl) {
126
140
  val = parseFloat(window.getComputedStyle(titleRowEl).getPropertyValue('margin-top'), 10);
127
141
  update.titleRowSpaceAbove = isNaN(val) ? 0 : val;
142
+
143
+ if (pageActionsEl) {
144
+ val = parseFloat(window.getComputedStyle(pageActionsEl).getPropertyValue('margin-top'), 10);
145
+ update.pageActionsSpaceAbove = titleRowEl.clientHeight - pageActionsEl.clientHeight + update.titleRowSpaceAbove - (isNaN(val) ? 0 : val);
146
+ }
128
147
  }
129
148
  } else {
130
149
  update.breadcrumbRowSpaceBelow = 0;
@@ -88,11 +88,13 @@ export var RemoveModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
88
88
  labelText: inputLabelText,
89
89
  placeholder: inputPlaceholderText,
90
90
  onChange: onChangeHandler,
91
- value: userInput
91
+ value: userInput,
92
+ "data-modal-primary-focus": true
92
93
  })), /*#__PURE__*/React.createElement(ModalFooter, null, /*#__PURE__*/React.createElement(Button, {
93
94
  type: "button",
94
95
  kind: "secondary",
95
- onClick: onClose
96
+ onClick: onClose,
97
+ "data-modal-primary-focus": !textConfirmation
96
98
  }, secondaryButtonText), /*#__PURE__*/React.createElement(Button, {
97
99
  type: "submit",
98
100
  kind: "danger",
@@ -508,7 +508,7 @@ SidePanel.propTypes = {
508
508
  * See https://react.carbondesignsystem.com/?path=/docs/components-button--default#component-api
509
509
  */
510
510
  actions: allPropTypes([ActionSet.validateActions(), PropTypes.arrayOf(PropTypes.shape(_objectSpread(_objectSpread({}, Button.propTypes), {}, {
511
- kind: PropTypes.oneOf(['ghost', 'secondary', 'primary']),
511
+ kind: PropTypes.oneOf(['ghost', 'danger--ghost', 'secondary', 'danger', 'primary']),
512
512
  label: PropTypes.string,
513
513
  loading: PropTypes.bool,
514
514
  // we duplicate this Button prop to improve the DocGen here
@@ -0,0 +1,15 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React, { forwardRef } from 'react'; // import PropTypes from 'prop-types';
3
+
4
+ import { AddSelect } from '../AddSelect';
5
+ import { getDevtoolsProps } from '../../global/js/utils/devtools';
6
+ import { pkg } from '../../settings';
7
+ var componentName = 'SingleAddSelect';
8
+ export var SingleAddSelect = /*#__PURE__*/forwardRef(function (props, ref) {
9
+ return /*#__PURE__*/React.createElement(AddSelect, _extends({}, props, {
10
+ ref: ref
11
+ }, getDevtoolsProps(componentName)));
12
+ });
13
+ SingleAddSelect = pkg.checkComponentEnabled(SingleAddSelect, componentName);
14
+ SingleAddSelect.propTypes = {};
15
+ SingleAddSelect.displayName = componentName;
@@ -0,0 +1 @@
1
+ export { SingleAddSelect } from './SingleAddSelect';
@@ -3,7 +3,7 @@ import _extends from "@babel/runtime/helpers/extends";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
5
  var _excluded = ["align", "className", "maxVisible", "overflowAlign", "overflowClassName", "overflowDirection", "allTagsModalTitle", "allTagsModalSearchLabel", "allTagsModalSearchPlaceholderText", "showAllTagsLabel", "tags"],
6
- _excluded2 = ["label"],
6
+ _excluded2 = ["label", "id"],
7
7
  _excluded3 = ["label"];
8
8
 
9
9
  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; }
@@ -84,6 +84,7 @@ export var TagSet = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
84
84
 
85
85
  setHiddenSizingTags(tags && tags.length > 0 ? tags.map(function (_ref2, index) {
86
86
  var label = _ref2.label,
87
+ id = _ref2.id,
87
88
  other = _objectWithoutProperties(_ref2, _excluded2);
88
89
 
89
90
  return /*#__PURE__*/React.createElement("div", {
@@ -93,6 +94,8 @@ export var TagSet = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
93
94
  return newSizingTags[index] = el;
94
95
  }
95
96
  }, /*#__PURE__*/React.createElement(Tag, _extends({}, other, {
97
+ // ensure id is not duplicated
98
+ "data-original-id": id,
96
99
  filter: false
97
100
  }), label));
98
101
  }) : []);
@@ -82,7 +82,7 @@ Tearsheet.propTypes = _objectSpread({
82
82
  actions: allPropTypes([ActionSet.validateActions(function () {
83
83
  return 'max';
84
84
  }), PropTypes.arrayOf(PropTypes.shape(_objectSpread(_objectSpread({}, Button.propTypes), {}, {
85
- kind: PropTypes.oneOf(['ghost', 'secondary', 'primary']),
85
+ kind: PropTypes.oneOf(['ghost', 'danger--ghost', 'secondary', 'danger', 'primary']),
86
86
  label: PropTypes.string,
87
87
  loading: PropTypes.bool,
88
88
  // we duplicate this Button prop to improve the DocGen here
@@ -78,7 +78,7 @@ TearsheetNarrow.propTypes = _objectSpread({
78
78
  actions: allPropTypes([ActionSet.validateActions(function () {
79
79
  return 'lg';
80
80
  }), PropTypes.arrayOf(PropTypes.shape(_objectSpread(_objectSpread({}, Button.propTypes), {}, {
81
- kind: PropTypes.oneOf(['ghost', 'secondary', 'primary']),
81
+ kind: PropTypes.oneOf(['ghost', 'danger--ghost', 'secondary', 'danger', 'primary']),
82
82
  label: PropTypes.string,
83
83
  loading: PropTypes.bool,
84
84
  // we duplicate this Button prop to improve the DocGen here
@@ -281,7 +281,7 @@ TearsheetShell.propTypes = _objectSpread({
281
281
  actions: PropTypes.arrayOf( // NB we don't include the validator here, as the component wrapping this
282
282
  // one should ensure appropriate validation is done.
283
283
  PropTypes.shape(_objectSpread(_objectSpread({}, Button.propTypes), {}, {
284
- kind: PropTypes.oneOf(['ghost', 'secondary', 'primary']),
284
+ kind: PropTypes.oneOf(['ghost', 'danger--ghost', 'secondary', 'danger', 'primary']),
285
285
  label: PropTypes.string,
286
286
  loading: PropTypes.bool,
287
287
  // we duplicate this Button prop to improve the DocGen here
@@ -1,17 +1,19 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
4
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
5
  var _excluded = ["children", "className", "vertical"];
5
6
 
6
7
  /**
7
- * Copyright IBM Corp. 2021, 2021
8
+ * Copyright IBM Corp. 2021, 2022
8
9
  *
9
10
  * This source code is licensed under the Apache-2.0 license found in the
10
11
  * LICENSE file in the root directory of this source tree.
11
12
  */
12
13
  import cx from 'classnames';
13
14
  import { bool, node, string } from 'prop-types';
14
- import React, { createContext, forwardRef } from 'react';
15
+ import React, { createContext, forwardRef, useCallback, useEffect, useRef, useState } from 'react';
16
+ import { getFocusableElements as _getFocusableElements } from '../../global/js/utils/getFocusableElements';
15
17
  import { pkg } from '../../settings';
16
18
  var checkComponentEnabled = pkg.checkComponentEnabled,
17
19
  prefix = pkg.prefix;
@@ -19,15 +21,74 @@ var blockClass = "".concat(prefix, "--toolbar");
19
21
  var ToolbarContext = /*#__PURE__*/createContext();
20
22
  /** Toolbars are a collection of action items that organize a program’s interaction patterns into a series of closely related commands. */
21
23
 
22
- var Toolbar = /*#__PURE__*/forwardRef(function (_ref, ref) {
23
- var children = _ref.children,
24
- className = _ref.className,
25
- vertical = _ref.vertical,
26
- rest = _objectWithoutProperties(_ref, _excluded);
24
+ var Toolbar = /*#__PURE__*/forwardRef(function (_ref2, r) {
25
+ var children = _ref2.children,
26
+ className = _ref2.className,
27
+ vertical = _ref2.vertical,
28
+ rest = _objectWithoutProperties(_ref2, _excluded);
29
+
30
+ var focusableElements = useRef();
31
+ var getFocusableElements = useCallback(function () {
32
+ return focusableElements.current;
33
+ }, [focusableElements]);
34
+
35
+ var _ref = useRef();
36
+
37
+ var ref = r || _ref;
38
+
39
+ var _useState = useState(),
40
+ _useState2 = _slicedToArray(_useState, 2),
41
+ focus = _useState2[0],
42
+ setFocus = _useState2[1];
43
+
44
+ useEffect(function () {
45
+ focusableElements.current = _getFocusableElements(ref.current);
46
+ typeof focus !== 'undefined' && getFocusableElements().forEach(function (element, index) {
47
+ element[index !== focus ? 'setAttribute' : 'removeAttribute']('tabindex', -1);
48
+ });
49
+ });
50
+ useEffect(function () {
51
+ typeof focus !== 'undefined' && getFocusableElements()[focus].focus();
52
+ }, [focus, getFocusableElements]);
53
+
54
+ var _ref3 = !vertical ? ['ArrowRight', 'ArrowLeft'] : ['ArrowDown', 'ArrowUp'],
55
+ _ref4 = _slicedToArray(_ref3, 2),
56
+ arrowNext = _ref4[0],
57
+ arrowPrevious = _ref4[1];
58
+
59
+ function onArrowDown(increment) {
60
+ var nextFocus = focus + increment;
61
+ getFocusableElements()[nextFocus] && setFocus(nextFocus);
62
+ }
63
+
64
+ function onFocus(_ref5) {
65
+ var target = _ref5.target;
66
+ var elements = getFocusableElements();
67
+ elements.includes(target) && setFocus(elements.indexOf(target));
68
+ }
69
+
70
+ function onKeyDown(_ref6) {
71
+ var key = _ref6.key,
72
+ target = _ref6.target;
73
+
74
+ if (getFocusableElements().includes(target)) {
75
+ switch (key) {
76
+ case arrowNext:
77
+ onArrowDown(1);
78
+ break;
79
+
80
+ case arrowPrevious:
81
+ onArrowDown(-1);
82
+ break;
83
+ }
84
+ }
85
+ }
27
86
 
28
87
  return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
29
88
  ref: ref,
30
- className: cx(blockClass, className, _defineProperty({}, "".concat(blockClass, "--vertical"), vertical))
89
+ className: cx(blockClass, className, _defineProperty({}, "".concat(blockClass, "--vertical"), vertical)),
90
+ onFocus: onFocus,
91
+ onKeyDown: onKeyDown
31
92
  }, vertical && {
32
93
  'aria-orientation': 'vertical'
33
94
  }, {
@@ -20,12 +20,14 @@ export { HTTPError403, HTTPError404, HTTPErrorOther } from './HTTPErrors';
20
20
  export { ImportModal } from './ImportModal';
21
21
  export { LoadingBar } from './LoadingBar';
22
22
  export { ModifiedTabs } from './ModifiedTabs';
23
+ export { MultiAddSelect } from './MultiAddSelect';
23
24
  export { NotificationsPanel } from './NotificationsPanel';
24
25
  export { PageHeader } from './PageHeader';
25
26
  export { ProductiveCard } from './ProductiveCard';
26
27
  export { RemoveModal } from './RemoveModal';
27
28
  export { Saving } from './Saving';
28
29
  export { SidePanel } from './SidePanel';
30
+ export { SingleAddSelect } from './SingleAddSelect';
29
31
  export { StatusIcon } from './StatusIcon';
30
32
  export { TagSet } from './TagSet';
31
33
  export { Tearsheet, TearsheetNarrow } from './Tearsheet';
@@ -33,4 +35,6 @@ export { Toolbar, ToolbarButton, ToolbarGroup } from './Toolbar';
33
35
  export { UserProfileImage } from './UserProfileImage';
34
36
  export { WebTerminal } from './WebTerminal';
35
37
  export { EditSidePanel } from './EditSidePanel';
36
- export { OptionsTile } from './OptionsTile';
38
+ export { OptionsTile } from './OptionsTile';
39
+ export { CancelableTextEdit } from './CancelableTextEdit';
40
+ export { InlineEdit } from './InlineEdit';
@@ -11,4 +11,5 @@ export { useCreateComponentFocus } from './useCreateComponentFocus';
11
11
  export { useCreateComponentStepChange } from './useCreateComponentStepChange';
12
12
  export { usePreviousValue } from './usePreviousValue';
13
13
  export { useResetCreateComponent } from './useResetCreateComponent';
14
+ export { useRetrieveStepData } from './useRetrieveStepData';
14
15
  export { useValidCreateStepCount } from './useValidCreateStepCount';
@@ -5,33 +5,29 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import { useEffect } from 'react';
8
- import { getFocusableElements } from '../utils/getFocusableElements';
9
- /**
10
- * Returns the previous state values included in the param
11
- * @param {object} previousState
12
- * @param {number} currentStep
13
- * @param {Function} getCreateComponentSteps
14
- * @param {string} componentBlockClass
15
- */
8
+ import { getFocusableElements } from '../utils/getFocusableElements'; // Focus the first focusable element and call the onMount prop for the current step if one is provided
16
9
 
17
- export var useCreateComponentFocus = function useCreateComponentFocus(previousState, currentStep, getCreateComponentSteps, componentBlockClass) {
10
+ export var useCreateComponentFocus = function useCreateComponentFocus(_ref) {
11
+ var previousState = _ref.previousState,
12
+ currentStep = _ref.currentStep,
13
+ blockClass = _ref.blockClass,
14
+ onMount = _ref.onMount;
15
+ useEffect(function () {
16
+ if (typeof onMount === 'function') {
17
+ onMount();
18
+ }
19
+ }, [onMount]);
18
20
  useEffect(function () {
19
21
  if ((previousState === null || previousState === void 0 ? void 0 : previousState.currentStep) !== currentStep && currentStep > 0) {
20
- var visibleStepInnerContent = document.querySelector(".".concat(componentBlockClass, "__step.").concat(componentBlockClass, "__step--visible-step"));
21
- var createComponentSteps = getCreateComponentSteps();
22
- var focusableStepElements = createComponentSteps && createComponentSteps.length && getFocusableElements(visibleStepInnerContent);
23
- var activeStepComponent = createComponentSteps && createComponentSteps.length && createComponentSteps[currentStep - 1];
24
-
25
- if (activeStepComponent && activeStepComponent.props.onMount) {
26
- activeStepComponent.props.onMount();
27
- }
22
+ var visibleStepInnerContent = document.querySelector(".".concat(blockClass, "__step.").concat(blockClass, "__step__step--visible-step"));
23
+ var focusableStepElements = visibleStepInnerContent ? getFocusableElements(visibleStepInnerContent) : [];
28
24
 
29
25
  if (focusableStepElements && focusableStepElements.length) {
30
26
  focusableStepElements[0].focus();
31
27
  } else {
32
- var nextButton = document.querySelector(".".concat(componentBlockClass, "__create-button"));
28
+ var nextButton = document.querySelector(".".concat(blockClass, "__create-button"));
33
29
  nextButton === null || nextButton === void 0 ? void 0 : nextButton.focus();
34
30
  }
35
31
  }
36
- }, [currentStep, getCreateComponentSteps, previousState, componentBlockClass]);
32
+ }, [currentStep, previousState, blockClass, onMount]);
37
33
  };