@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
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
- var _excluded = ["body", "className", "error", "errorMessage", "filename", "inputLabel", "invalidInputText", "loading", "loadingMessage", "onClose", "onRequestSubmit", "open", "preformattedExtensions", "preformattedExtensionsLabel", "primaryButtonText", "secondaryButtonText", "successMessage", "successful", "title", "validExtensions"];
5
+ var _excluded = ["body", "className", "error", "errorMessage", "filename", "hidePasswordLabel", "inputLabel", "inputType", "invalidInputText", "loading", "loadingMessage", "onClose", "onRequestSubmit", "open", "preformattedExtensions", "preformattedExtensionsLabel", "primaryButtonText", "secondaryButtonText", "showPasswordLabel", "successMessage", "successful", "title", "validExtensions"];
6
6
 
7
7
  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
8
 
@@ -15,7 +15,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
15
15
  // LICENSE file in the root directory of this source tree.
16
16
  //
17
17
  import React, { useState, useRef, forwardRef } from 'react';
18
- import { Button, ComposedModal, ModalHeader, ModalFooter, ModalBody, TextInput, RadioButton, RadioButtonGroup, FormGroup, Loading } from 'carbon-components-react';
18
+ import { Button, ComposedModal, ModalHeader, ModalFooter, ModalBody, TextInput, RadioButton, RadioButtonGroup, FormGroup, Loading, PasswordInput } from 'carbon-components-react';
19
19
  import cx from 'classnames';
20
20
  import { ErrorFilled16, CheckmarkFilled16 } from '@carbon/icons-react';
21
21
  import PropTypes from 'prop-types';
@@ -31,7 +31,9 @@ export var ExportModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
31
31
  error = _ref.error,
32
32
  errorMessage = _ref.errorMessage,
33
33
  filename = _ref.filename,
34
+ hidePasswordLabel = _ref.hidePasswordLabel,
34
35
  inputLabel = _ref.inputLabel,
36
+ inputType = _ref.inputType,
35
37
  invalidInputText = _ref.invalidInputText,
36
38
  loading = _ref.loading,
37
39
  loadingMessage = _ref.loadingMessage,
@@ -42,6 +44,7 @@ export var ExportModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
42
44
  preformattedExtensionsLabel = _ref.preformattedExtensionsLabel,
43
45
  primaryButtonText = _ref.primaryButtonText,
44
46
  secondaryButtonText = _ref.secondaryButtonText,
47
+ showPasswordLabel = _ref.showPasswordLabel,
45
48
  successMessage = _ref.successMessage,
46
49
  successful = _ref.successful,
47
50
  title = _ref.title,
@@ -103,6 +106,17 @@ export var ExportModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
103
106
  var internalId = useRef(uuidv4());
104
107
  var primaryButtonDisabled = loading || !name || hasInvalidExtension();
105
108
  var submitted = loading || error || successful;
109
+
110
+ var commonInputProps = _defineProperty({
111
+ id: "text-input--".concat(internalId.current),
112
+ value: name,
113
+ onChange: onNameChangeHandler,
114
+ labelText: inputLabel,
115
+ invalid: hasInvalidExtension(),
116
+ invalidText: invalidInputText,
117
+ onBlur: onBlurHandler
118
+ }, 'data-modal-primary-focus', true);
119
+
106
120
  return /*#__PURE__*/React.createElement(ComposedModal, _extends({}, rest, {
107
121
  className: cx(blockClass, className),
108
122
  "aria-label": title,
@@ -134,16 +148,13 @@ export var ExportModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
134
148
  labelText: "".concat(o.extension, " (").concat(o.description, ")"),
135
149
  "data-modal-primary-focus": true
136
150
  });
137
- }))) : /*#__PURE__*/React.createElement(TextInput, {
138
- id: "text-input--".concat(internalId.current),
139
- value: name,
140
- onChange: onNameChangeHandler,
141
- labelText: inputLabel,
142
- invalid: hasInvalidExtension(),
143
- invalidText: invalidInputText,
144
- onBlur: onBlurHandler,
145
- "data-modal-primary-focus": true
146
- })), /*#__PURE__*/React.createElement("div", {
151
+ }))) : /*#__PURE__*/React.createElement("div", {
152
+ className: "".concat(blockClass, "__input-container")
153
+ }, inputType === 'text' ? /*#__PURE__*/React.createElement(TextInput, commonInputProps) : /*#__PURE__*/React.createElement(PasswordInput, _extends({}, commonInputProps, {
154
+ showPasswordLabel: showPasswordLabel,
155
+ hidePasswordLabel: hidePasswordLabel,
156
+ tooltipPosition: "left"
157
+ })))), /*#__PURE__*/React.createElement("div", {
147
158
  className: "".concat(blockClass, "__messaging")
148
159
  }, loading && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Loading, {
149
160
  small: true,
@@ -193,11 +204,21 @@ ExportModal.propTypes = {
193
204
  */
194
205
  filename: PropTypes.string.isRequired,
195
206
 
207
+ /**
208
+ * label text that's displayed when hovering over visibility toggler to hide key
209
+ */
210
+ hidePasswordLabel: PropTypes.string,
211
+
196
212
  /**
197
213
  * label for the text input
198
214
  */
199
215
  inputLabel: PropTypes.string,
200
216
 
217
+ /**
218
+ * specify the type of text input
219
+ */
220
+ inputType: PropTypes.oneOf(['text', 'password']),
221
+
201
222
  /**
202
223
  * text for an invalid input
203
224
  */
@@ -251,6 +272,11 @@ ExportModal.propTypes = {
251
272
  */
252
273
  secondaryButtonText: PropTypes.string.isRequired,
253
274
 
275
+ /**
276
+ * label text that's displayed when hovering over visibility toggler to show key
277
+ */
278
+ showPasswordLabel: PropTypes.string,
279
+
254
280
  /**
255
281
  * messaging to display if the export was successful
256
282
  */
@@ -272,6 +298,7 @@ ExportModal.propTypes = {
272
298
  validExtensions: PropTypes.array
273
299
  };
274
300
  ExportModal.defaultProps = {
301
+ inputType: 'text',
275
302
  preformattedExtensions: [],
276
303
  validExtensions: []
277
304
  };
@@ -2,11 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
- var _excluded = ["className", "disabled", "editDescription", "id", "inline", "invalid", "invalidText", "labelText", "onChange", "onInput", "onRevert", "revertDescription", "saveDescription", "saveDisabled", "size", "value", "warn", "warnText"];
6
-
7
- 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
- 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; }
5
+ var _excluded = ["cancelDescription", "className", "disabled", "editDescription", "editVisibleOnHoverOnly", "id", "invalid", "invalidText", "labelText", "light", "onCancel", "onSave", "onChange", "placeholder", "saveDescription", "size", "value", "warn", "warnText"];
10
6
 
11
7
  /**
12
8
  * Copyright IBM Corp. 2022, 2022
@@ -15,7 +11,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
15
11
  * LICENSE file in the root directory of this source tree.
16
12
  */
17
13
  // Import portions of React that are needed.
18
- import React, { useState } from 'react'; // Other standard imports.
14
+ import React, { useRef, useState } from 'react'; // Other standard imports.
19
15
 
20
16
  import PropTypes from 'prop-types';
21
17
  import cx from 'classnames';
@@ -24,9 +20,8 @@ import { pkg, carbon } from '../../settings'; // Carbon and package components w
24
20
 
25
21
  /* TODO: @import(s) of carbon components and other package components. */
26
22
 
27
- import { CancelableTextEdit } from '../';
28
23
  import { Button } from 'carbon-components-react';
29
- import { Edit16, EditOff16 } from '@carbon/icons-react'; // The block part of our conventional BEM class names (blockClass__E--M).
24
+ import { Close16, Edit16, EditOff16, Checkmark16, WarningFilled16, WarningAltFilled16 } from '@carbon/icons-react'; // The block part of our conventional BEM class names (blockClass__E--M).
30
25
 
31
26
  var blockClass = "".concat(pkg.prefix, "--inline-edit");
32
27
  var componentName = 'InlineEdit'; // NOTE: the component SCSS is not imported here: it is rolled up separately.
@@ -35,83 +30,249 @@ var componentName = 'InlineEdit'; // NOTE: the component SCSS is not imported he
35
30
  * TODO: A description of the component.
36
31
  */
37
32
 
38
- export var InlineEdit = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
39
- var className = _ref.className,
33
+ export var InlineEdit = /*#__PURE__*/React.forwardRef(function (_ref, refIn) {
34
+ var _cx, _cx3;
35
+
36
+ var cancelDescription = _ref.cancelDescription,
37
+ className = _ref.className,
40
38
  disabled = _ref.disabled,
41
39
  editDescription = _ref.editDescription,
40
+ editVisibleOnHoverOnly = _ref.editVisibleOnHoverOnly,
42
41
  id = _ref.id,
43
- inline = _ref.inline,
44
42
  invalid = _ref.invalid,
45
43
  invalidText = _ref.invalidText,
46
44
  labelText = _ref.labelText,
45
+ light = _ref.light,
46
+ onCancel = _ref.onCancel,
47
+ onSave = _ref.onSave,
47
48
  onChange = _ref.onChange,
48
- onInput = _ref.onInput,
49
- onRevert = _ref.onRevert,
50
- revertDescription = _ref.revertDescription,
49
+ placeholder = _ref.placeholder,
51
50
  saveDescription = _ref.saveDescription,
52
- saveDisabled = _ref.saveDisabled,
53
51
  size = _ref.size,
54
52
  value = _ref.value,
55
53
  warn = _ref.warn,
56
54
  warnText = _ref.warnText,
57
55
  rest = _objectWithoutProperties(_ref, _excluded);
58
56
 
57
+ var refInput = useRef(null);
58
+ var localRef = useRef(null);
59
+ var ref = refIn || localRef;
60
+
59
61
  var _useState = useState(false),
60
62
  _useState2 = _slicedToArray(_useState, 2),
61
63
  editing = _useState2[0],
62
64
  setEditing = _useState2[1];
63
65
 
64
- var handleEdit = function handleEdit() {
65
- return setEditing(function (prev) {
66
- return !prev;
67
- });
66
+ var _useState3 = useState(value),
67
+ _useState4 = _slicedToArray(_useState3, 2),
68
+ internalValue = _useState4[0],
69
+ setInternalValue = _useState4[1];
70
+
71
+ var showValidation = invalid || warn;
72
+ var validationText = invalidText || warnText;
73
+ var validationIcon = showValidation ? invalid ? /*#__PURE__*/React.createElement(WarningFilled16, null) : /*#__PURE__*/React.createElement(WarningAltFilled16, null) : null;
74
+
75
+ var doSetEditing = function doSetEditing(value) {
76
+ if (value === false) {
77
+ // move scroll to start
78
+ refInput.current.scrollLeft = 0;
79
+ }
80
+
81
+ setEditing(!disabled && value);
68
82
  };
69
83
 
70
- var handleChange = function handleChange(val) {
71
- setEditing(false);
72
- onChange(val);
84
+ var handleEdit = function handleEdit(ev) {
85
+ if (!disabled) {
86
+ var rightOfInput = ev.currentTarget.classList.contains("".concat(blockClass, "__edit")) || ev.target.classList.contains("".concat(blockClass, "__after-input-elements"));
87
+ var leftOfInput = ev.currentTarget = ev.target.classList.contains("".concat(blockClass)); // clicking on the content editable element should not set either of these to true
88
+
89
+ if (rightOfInput || leftOfInput) {
90
+ doSetEditing(true);
91
+ setTimeout(function () {
92
+ refInput.current.focus(); // select all the content
93
+
94
+ document.getSelection().selectAllChildren(refInput.current);
95
+
96
+ if (rightOfInput) {
97
+ document.getSelection().collapseToEnd();
98
+ refInput.current.scrollLeft = 9999; // never going to get there but ensures at end.
99
+ } else {
100
+ document.getSelection().collapseToStart();
101
+ refInput.current.scrollLeft = 0; // scroll to start
102
+ }
103
+ }, 0);
104
+ }
105
+ }
106
+ };
107
+
108
+ var handleFocus = function handleFocus(ev) {
109
+ ev.preventDefault();
110
+
111
+ if (!editing && ev.target.classList.contains("".concat(blockClass, "__input"))) {
112
+ doSetEditing(true);
113
+ }
114
+ };
115
+
116
+ var handleSave = function handleSave() {
117
+ doSetEditing(false);
118
+ document.getSelection().removeAllRanges();
119
+
120
+ if (onSave) {
121
+ onSave(refInput.current.innerText);
122
+ }
73
123
  };
74
124
 
75
- var handleRevert = function handleRevert() {
76
- setEditing(false);
77
- onRevert(value);
125
+ var handleInput = function handleInput() {
126
+ setInternalValue(refInput.current.innerText);
127
+
128
+ if (onChange) {
129
+ onChange(refInput.current.innerText);
130
+ }
131
+ };
132
+
133
+ var handlePaste = function handlePaste(ev) {
134
+ ev.preventDefault(); // Get clipboard as plain text
135
+
136
+ var text = (ev.clipboardData || window.clipboardData).getData('text/plain'); // remove \n
137
+
138
+ var sanitizedText = text.replaceAll(/\n/g, '') // remove carriage returns
139
+ .replaceAll(/\t/g, ' '); // replace tab with two spaces
140
+
141
+ if (document.queryCommandSupported('insertText')) {
142
+ document.execCommand('insertText', false, sanitizedText);
143
+ } else {
144
+ // Insert text at the current position of caret
145
+ var range = document.getSelection().getRangeAt(0);
146
+ range.deleteContents();
147
+ var textNode = document.createTextNode(sanitizedText);
148
+ range.insertNode(textNode); // move selection end of textNode
149
+
150
+ range.selectNodeContents(textNode);
151
+ range.collapse(false); // remove existing range
152
+
153
+ var selection = document.getSelection();
154
+ selection.removeAllRanges(); // set the new range
155
+
156
+ selection.addRange(range);
157
+ }
158
+ };
159
+
160
+ var handleCancel = function handleCancel() {
161
+ refInput.current.innerText = value;
162
+ handleInput(value);
163
+ doSetEditing(false);
164
+ document.getSelection().removeAllRanges();
165
+
166
+ if (onCancel) {
167
+ onCancel(value);
168
+ }
78
169
  };
79
170
 
80
- var stdProps = _objectSpread(_objectSpread({}, rest), {}, {
81
- className: cx(blockClass, // Apply the block class to the main HTML element
82
- className, // Apply any supplied class names to the main HTML element.
83
- _defineProperty({}, "".concat(blockClass, "--editing"), editing)),
84
- id: id,
85
- size: size,
86
- ref: ref
87
- }, getDevtoolsProps(componentName));
88
-
89
- return editing ? /*#__PURE__*/React.createElement(CancelableTextEdit, _extends({}, stdProps, {
90
- hideLabel: true,
91
- inline: inline,
92
- invalid: invalid,
93
- invalidText: invalidText,
94
- labelText: labelText,
95
- onChange: handleChange,
96
- onInput: onInput,
97
- onRevert: handleRevert,
98
- revertDescription: revertDescription,
99
- saveDescription: saveDescription,
100
- saveDisabled: saveDisabled,
101
- value: value,
102
- warn: warn,
103
- warnText: warnText
104
- })) : /*#__PURE__*/React.createElement("div", stdProps, /*#__PURE__*/React.createElement("div", {
105
- className: "".concat(blockClass, "__value")
106
- }, value), /*#__PURE__*/React.createElement(Button, {
107
- className: "".concat(blockClass, "__button ").concat(carbon.prefix, "--btn--md"),
108
- kind: "ghost",
109
- hasIconOnly: true,
110
- iconDescription: editDescription,
111
- onClick: handleEdit,
112
- renderIcon: disabled ? EditOff16 : Edit16,
113
- disabled: disabled
114
- }));
171
+ var handleBlur = function handleBlur(ev) {
172
+ if (!ref.current.contains(ev.relatedTarget)) {
173
+ handleSave();
174
+ }
175
+ };
176
+
177
+ var handleKeyDown = function handleKeyDown(ev) {
178
+ if (ev.key === 'Enter') {
179
+ ev.preventDefault();
180
+ refInput.current.blur(); // will cause save
181
+ }
182
+ };
183
+ /*
184
+ The HTML is structured as follows:
185
+ <container>
186
+ <!-- margin left of input to match Carbon -->
187
+ <content-editable>
188
+ <-- margin right of input space for after-input-elements -->
189
+ <after-input-elements>
190
+ </container>
191
+ NOTE:
192
+ - An input is not used as this would not permit a heading tag e.g. <h2>.
193
+ - Some padding is added to the left 16px standard for a Carbon text input
194
+ - The after-input-elements are position absolute with a margin to on the input to reserve space. Using inline-flex
195
+ - does not measure space properly for the input otherwise.
196
+ - The content editable is not expected to change size when buttons are added, to ensure the text does not move space
197
+ is reserved up front for buttons and invalid icon. Mostly this is only noticed if the width of the component is not 100%.
198
+ which can be shown by setting inlineEditFullWidth to false in storybook.
199
+ In making content-editable behave like an input of type text we have to account for.
200
+ - Enforcing a single line
201
+ - Pasting of non-text e.g. html or text with carriage returns
202
+ - The padding and border not hiding typed in text.
203
+ - Placing the cursor at the start or end depending on area clicked (before for left-padding)
204
+ */
205
+
206
+
207
+ var toolbarAnimation = true;
208
+ return (
209
+ /*#__PURE__*/
210
+ // eslint-disable-next-line
211
+ React.createElement("div", {
212
+ className: cx(blockClass, // Apply the block class to the main HTML element
213
+ className, // Apply any supplied class names to the main HTML element.
214
+ "".concat(blockClass, "--").concat(size), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "--disabled"), disabled), _defineProperty(_cx, "".concat(blockClass, "--editing"), editing), _defineProperty(_cx, "".concat(blockClass, "--invalid"), invalid), _defineProperty(_cx, "".concat(blockClass, "--warn"), warn), _defineProperty(_cx, "".concat(blockClass, "--light"), light), _defineProperty(_cx, "".concat(blockClass, "--overflows"), refInput.current && refInput.current.scrollWidth > refInput.current.offsetWidth), _cx)),
215
+ onClick: handleEdit // disabled eslint for click handler
216
+ ,
217
+ onBlur: handleBlur,
218
+ ref: ref
219
+ }, /*#__PURE__*/React.createElement("div", _extends({}, rest, getDevtoolsProps(componentName), {
220
+ id: id,
221
+ size: size,
222
+ className: cx("".concat(blockClass, "__input"), _defineProperty({}, "".concat(blockClass, "__input--empty"), refInput.current && refInput.current.innerText.length === 0)),
223
+ contentEditable: true,
224
+ "aria-label": labelText,
225
+ role: "textbox",
226
+ tabIndex: disabled ? -1 : 0,
227
+ onFocus: handleFocus,
228
+ onInput: handleInput,
229
+ onKeyDown: handleKeyDown,
230
+ onPaste: handlePaste,
231
+ suppressContentEditableWarning: true,
232
+ ref: refInput,
233
+ "data-placeholder": placeholder !== null && placeholder !== void 0 ? placeholder : labelText
234
+ }), value), /*#__PURE__*/React.createElement("div", {
235
+ className: cx("".concat(blockClass, "__after-input-elements")) // tabindex -1 fixes blur target test when clicking on after-input-elements background
236
+ ,
237
+ tabIndex: "-1"
238
+ }, /*#__PURE__*/React.createElement("div", {
239
+ className: "".concat(blockClass, "__ellipsis"),
240
+ "aria-hidden": !editing
241
+ }, "\u2026"), /*#__PURE__*/React.createElement("div", {
242
+ className: cx("".concat(blockClass, "__toolbar"), (_cx3 = {}, _defineProperty(_cx3, "".concat(blockClass, "__toolbar--animation"), toolbarAnimation), _defineProperty(_cx3, "".concat(blockClass, "__toolbar--saveable"), refInput.current && value !== internalValue), _cx3))
243
+ }, showValidation && /*#__PURE__*/React.createElement("div", {
244
+ className: "".concat(blockClass, "__validation-icon")
245
+ }, validationIcon), editing ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
246
+ className: "".concat(blockClass, "__cancel"),
247
+ kind: "ghost",
248
+ hasIconOnly: true,
249
+ iconDescription: cancelDescription,
250
+ onClick: handleCancel,
251
+ renderIcon: Close16
252
+ }), /*#__PURE__*/React.createElement(Button, {
253
+ className: "".concat(blockClass, "__save"),
254
+ kind: "ghost",
255
+ hasIconOnly: true,
256
+ iconDescription: saveDescription,
257
+ onClick: handleSave,
258
+ renderIcon: Checkmark16,
259
+ disabled: value === internalValue
260
+ })) : /*#__PURE__*/React.createElement(Button, {
261
+ "aria-hidden": "true",
262
+ className: cx("".concat(blockClass, "__edit"), _defineProperty({}, "".concat(blockClass, "__edit--hover-visible"), editVisibleOnHoverOnly)),
263
+ kind: "ghost",
264
+ hasIconOnly: true,
265
+ iconDescription: editDescription,
266
+ onClick: handleEdit,
267
+ renderIcon: disabled ? EditOff16 : Edit16,
268
+ disabled: disabled,
269
+ tabIndex: -1
270
+ }))), /*#__PURE__*/React.createElement("div", {
271
+ className: cx("".concat(blockClass, "__disabled-cover"))
272
+ }), showValidation && validationText && validationText.length > 0 && /*#__PURE__*/React.createElement("div", {
273
+ className: "".concat(blockClass, "__validation-text ").concat(carbon.prefix, "--form-requirement")
274
+ }, validationText))
275
+ );
115
276
  }); // Return a placeholder if not released and not enabled by feature flag
116
277
 
117
278
  InlineEdit = pkg.checkComponentEnabled(InlineEdit, componentName); // The display name of the component, used by React. Note that displayName
@@ -122,6 +283,11 @@ InlineEdit.displayName = componentName; // The types and DocGen commentary for t
122
283
  // See https://www.npmjs.com/package/prop-types#usage.
123
284
 
124
285
  InlineEdit.propTypes = {
286
+ /**
287
+ * label for cancel button
288
+ */
289
+ cancelDescription: PropTypes.string.isRequired,
290
+
125
291
  /**
126
292
  * Provide an optional class to be applied to the containing node.
127
293
  */
@@ -138,16 +304,15 @@ InlineEdit.propTypes = {
138
304
  editDescription: PropTypes.string.isRequired,
139
305
 
140
306
  /**
141
- * ID for inline edit
307
+ * In some scenarios the edit icon only needs to be shown on hover. These cases are where continual visibility of
308
+ * the edit icon is redundant. E.g. a spreadsheet a property panel.
142
309
  */
143
- id: PropTypes.string,
144
-
145
- /* TODO: add types and DocGen for all props. */
310
+ editVisibleOnHoverOnly: PropTypes.bool,
146
311
 
147
312
  /**
148
- * inline variant
149
- */
150
- inline: PropTypes.bool,
313
+ * ID for inline edit
314
+ */
315
+ id: PropTypes.string,
151
316
 
152
317
  /**
153
318
  * set invalid state for input
@@ -165,34 +330,38 @@ InlineEdit.propTypes = {
165
330
  labelText: PropTypes.string,
166
331
 
167
332
  /**
168
- * method called on change event
333
+ * change background to light version (mimic React TextInput)
169
334
  */
170
- onChange: PropTypes.func,
335
+ light: PropTypes.bool,
171
336
 
172
337
  /**
173
- * method called on input event
338
+ * method called on cancel event
174
339
  */
175
- onInput: PropTypes.func,
340
+ onCancel: PropTypes.func,
176
341
 
177
342
  /**
178
- * method called on revert event
343
+ * method called on input event (it's a React thing onChange behaves like on input).
344
+ *
345
+ * NOTE: caller to handle invalid/warn states and associated text
179
346
  */
180
- onRevert: PropTypes.func,
347
+ onChange: PropTypes.func,
181
348
 
182
349
  /**
183
- * label for revert button
350
+ * method called on change event
351
+ *
352
+ * NOTE: caller to handle invalid/warn states and associated text
184
353
  */
185
- revertDescription: PropTypes.string.isRequired,
354
+ onSave: PropTypes.func,
186
355
 
187
356
  /**
188
- * label for save button
357
+ * placeholder for text input
189
358
  */
190
- saveDescription: PropTypes.string.isRequired,
359
+ placeholder: PropTypes.string,
191
360
 
192
361
  /**
193
- * disabled state of the save button
362
+ * label for save button
194
363
  */
195
- saveDisabled: PropTypes.bool,
364
+ saveDescription: PropTypes.string.isRequired,
196
365
 
197
366
  /**
198
367
  * vertical size of control
@@ -219,6 +388,7 @@ InlineEdit.propTypes = {
219
388
  // component needs to make a choice or assumption when a prop is not supplied.
220
389
 
221
390
  InlineEdit.defaultProps = {
222
- /* TODO: add defaults for relevant props. */
391
+ light: true,
392
+ // defaults to true to reflect design
223
393
  size: 'md'
224
394
  };
@@ -5,7 +5,7 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
5
5
  var _excluded = ["className", "data", "daysAgoText", "dismissAllLabel", "dismissSingleNotificationIconDescription", "doNotDisturbDefaultToggled", "doNotDisturbLabel", "emptyStateLabel", "hoursAgoText", "hourAgoText", "minuteAgoText", "minutesAgoText", "monthsAgoText", "monthAgoText", "nowText", "onClickOutside", "onDismissAllNotifications", "onDismissSingleNotification", "onDoNotDisturbChange", "onSettingsClick", "onViewAllClick", "open", "previousLabel", "readLessLabel", "readMoreLabel", "secondsAgoText", "settingsIconDescription", "title", "todayLabel", "viewAllLabel", "yearsAgoText", "yearAgoText", "yesterdayAtText", "yesterdayLabel"];
6
6
 
7
7
  /**
8
- * Copyright IBM Corp. 2020, 2021
8
+ * Copyright IBM Corp. 2020, 2022
9
9
  *
10
10
  * This source code is licensed under the Apache-2.0 license found in the
11
11
  * LICENSE file in the root directory of this source tree.
@@ -22,7 +22,8 @@ import { timeAgo } from './utils';
22
22
  import { NotificationsEmptyState } from '../EmptyStates/NotificationsEmptyState'; // Carbon and package components we use.
23
23
 
24
24
  import { Button, Link, Toggle } from 'carbon-components-react';
25
- import { ErrorFilled16, WarningAltFilled16, CheckmarkFilled16, InformationSquareFilled16, ChevronDown16, Close16, Settings16 } from '@carbon/icons-react'; // The block part of our conventional BEM class names (blockClass__E--M).
25
+ import { ErrorFilled16, WarningAltFilled16, CheckmarkFilled16, InformationSquareFilled16, ChevronDown16, Close16, Settings16 } from '@carbon/icons-react';
26
+ import { usePreviousValue } from '../../global/js/hooks'; // The block part of our conventional BEM class names (blockClass__E--M).
26
27
 
27
28
  var componentName = 'NotificationsPanel';
28
29
  var blockClass = "".concat(pkg.prefix, "--notifications-panel");
@@ -75,6 +76,12 @@ export var NotificationsPanel = /*#__PURE__*/React.forwardRef(function (_ref, re
75
76
  allNotifications = _useState4[0],
76
77
  setAllNotifications = _useState4[1];
77
78
 
79
+ var previousState = usePreviousValue({
80
+ open: open
81
+ });
82
+ var reducedMotion = window && window.matchMedia ? window.matchMedia('(prefers-reduced-motion: reduce)') : {
83
+ matches: true
84
+ };
78
85
  useEffect(function () {
79
86
  // Set the notifications passed to the state within this component
80
87
  setAllNotifications(data);
@@ -94,6 +101,12 @@ export var NotificationsPanel = /*#__PURE__*/React.forwardRef(function (_ref, re
94
101
  !open && setRender(false);
95
102
  };
96
103
 
104
+ useEffect(function () {
105
+ if (!open && previousState !== null && previousState !== void 0 && previousState.open && reducedMotion.matches) {
106
+ setRender(false);
107
+ }
108
+ }, [open, reducedMotion.matches, previousState === null || previousState === void 0 ? void 0 : previousState.open]);
109
+
97
110
  var sortChronologically = function sortChronologically(arr) {
98
111
  if (!arr || arr && !arr.length) {
99
112
  return;
@@ -233,7 +246,7 @@ export var NotificationsPanel = /*#__PURE__*/React.forwardRef(function (_ref, re
233
246
  id: blockClass,
234
247
  className: cx(blockClass, className, "".concat(blockClass, "__container")),
235
248
  style: {
236
- animation: "".concat(open ? 'fadeIn 250ms' : 'fadeOut 250ms')
249
+ animation: !reducedMotion.matches ? "".concat(open ? 'fade-in 250ms' : 'fade-out 250ms') : null
237
250
  },
238
251
  onAnimationEnd: onAnimationEnd,
239
252
  ref: ref || notificationPanelRef
@@ -361,16 +361,17 @@ export var PageHeader = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
361
361
  }, /*#__PURE__*/React.createElement("div", {
362
362
  className: "".concat(blockClass, "__non-navigation-row-content")
363
363
  }, hasBreadcrumbRow ? /*#__PURE__*/React.createElement(Row, {
364
- className: cx("".concat(blockClass, "__breadcrumb-row"), (_cx2 = {}, _defineProperty(_cx2, "".concat(blockClass, "__breadcrumb-row--next-to-tabs"), nextToTabsCheck()), _defineProperty(_cx2, "".concat(blockClass, "__breadcrumb-row--has-breadcrumbs"), breadcrumbs), _defineProperty(_cx2, "".concat(blockClass, "__breadcrumb-row--has-action-bar"), hasActionBar || widthIsNarrow), _defineProperty(_cx2, "".concat(blockClass, "__has-page-actions-without-action-bar"), !hasActionBar && !widthIsNarrow && pageActions), _cx2))
364
+ className: cx("".concat(blockClass, "__breadcrumb-row"), (_cx2 = {}, _defineProperty(_cx2, "".concat(blockClass, "__breadcrumb-row--next-to-tabs"), nextToTabsCheck()), _defineProperty(_cx2, "".concat(blockClass, "__breadcrumb-row--has-breadcrumbs"), breadcrumbs || breadcrumbItemForTitle), _defineProperty(_cx2, "".concat(blockClass, "__breadcrumb-row--has-action-bar"), hasActionBar || widthIsNarrow), _defineProperty(_cx2, "".concat(blockClass, "__has-page-actions-without-action-bar"), !hasActionBar && !widthIsNarrow && pageActions), _cx2))
365
365
  }, /*#__PURE__*/React.createElement("div", {
366
366
  className: "".concat(blockClass, "__breadcrumb-row--container")
367
367
  }, /*#__PURE__*/React.createElement(Column, {
368
368
  className: cx("".concat(blockClass, "__breadcrumb-column"), _defineProperty({}, "".concat(blockClass, "__breadcrumb-column--background"), !!breadcrumbs || hasActionBar || widthIsNarrow))
369
- }, breadcrumbs ? /*#__PURE__*/React.createElement(BreadcrumbWithOverflow, {
369
+ }, breadcrumbs || breadcrumbItemForTitle ? /*#__PURE__*/React.createElement(BreadcrumbWithOverflow, {
370
370
  className: "".concat(blockClass, "__breadcrumb"),
371
371
  noTrailingSlash: !!title,
372
372
  overflowAriaLabel: breadcrumbOverflowAriaLabel,
373
- breadcrumbs: breadcrumbs ? breadcrumbItemForTitle ? breadcrumbs.concat(breadcrumbItemForTitle) : breadcrumbs : null
373
+ breadcrumbs: breadcrumbs && breadcrumbItemForTitle ? breadcrumbs.concat(breadcrumbItemForTitle) : breadcrumbItemForTitle ? [breadcrumbItemForTitle] : breadcrumbs // breadcrumbs may be null or undefined
374
+
374
375
  }) : null), /*#__PURE__*/React.createElement(Column, {
375
376
  className: cx(["".concat(blockClass, "__action-bar-column ").concat(blockClass, "__action-bar-column--background"), (_ref7 = {}, _defineProperty(_ref7, "".concat(blockClass, "__action-bar-column--has-page-actions"), pageActions), _defineProperty(_ref7, "".concat(blockClass, "__action-bar-column--influenced-by-collapse-button"), spaceForCollapseButton), _ref7)])
376
377
  }, /*#__PURE__*/React.createElement("div", {
@@ -766,9 +767,10 @@ PageHeader.propTypes = _objectSpread({
766
767
  * - text: title string
767
768
  * - icon: optional icon
768
769
  * - loading: boolean shows loading indicator if true
769
- * - onChange: function to process edits only supply if in place edit is desired
770
+ * - onChange: function to process the live value (React change === HTML Input)
771
+ * - onSave: function to process a confirmed change
770
772
  * - editableLabel: label for edit required if onChange supplied
771
- * - revertDescription: label for edit revert button
773
+ * - cancelDescription: label for edit cancel button
772
774
  * - saveDescription: label for edit save button
773
775
  * - 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.
774
776
  * - content: title or name of current location shown in main part of page header
@@ -786,7 +788,8 @@ PageHeader.propTypes = _objectSpread({
786
788
  id: PropTypes.string,
787
789
  // .isRequired.if(inlineEditRequired),
788
790
  onChange: PropTypes.func,
789
- revertDescription: PropTypes.string,
791
+ onSave: PropTypes.func,
792
+ cancelDescription: PropTypes.string,
790
793
  //.isRequired.if(inlineEditRequired),
791
794
  saveDescription: PropTypes.string //.isRequired.if(inlineEditRequired),
792
795
  // Update docgen if changed