@carbon/ibm-products 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/css/index-full-carbon.css +206 -44
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +3 -3
  4. package/css/index-without-carbon-released-only.css +31 -27
  5. package/css/index-without-carbon-released-only.css.map +1 -1
  6. package/css/index-without-carbon-released-only.min.css +3 -3
  7. package/css/index-without-carbon.css +193 -39
  8. package/css/index-without-carbon.css.map +1 -1
  9. package/css/index-without-carbon.min.css +3 -3
  10. package/css/index.css +195 -41
  11. package/css/index.css.map +1 -1
  12. package/css/index.min.css +3 -3
  13. package/es/components/AddSelect/AddSelect.js +106 -65
  14. package/es/components/AddSelect/AddSelectBreadcrumbs.js +56 -0
  15. package/es/components/AddSelect/AddSelectList.js +94 -0
  16. package/es/components/AddSelect/AddSelectSidebar.js +46 -0
  17. package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +5 -2
  18. package/es/components/CancelableTextEdit/CancelableTextEdit.js +2 -2
  19. package/es/components/Card/Card.js +6 -4
  20. package/es/components/InlineEdit/InlineEdit.js +223 -74
  21. package/es/components/NotificationsPanel/NotificationsPanel.js +16 -3
  22. package/es/components/PageHeader/PageHeader.js +7 -4
  23. package/es/components/PageHeader/PageHeaderTitle.js +10 -6
  24. package/es/components/SidePanel/SidePanel.js +32 -15
  25. package/es/components/WebTerminal/WebTerminal.js +1 -1
  26. package/es/settings.js +0 -5
  27. package/lib/components/AddSelect/AddSelect.js +110 -65
  28. package/lib/components/AddSelect/AddSelectBreadcrumbs.js +71 -0
  29. package/lib/components/AddSelect/AddSelectList.js +112 -0
  30. package/lib/components/AddSelect/AddSelectSidebar.js +63 -0
  31. package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +5 -2
  32. package/lib/components/CancelableTextEdit/CancelableTextEdit.js +1 -1
  33. package/lib/components/Card/Card.js +6 -4
  34. package/lib/components/InlineEdit/InlineEdit.js +219 -72
  35. package/lib/components/NotificationsPanel/NotificationsPanel.js +13 -1
  36. package/lib/components/PageHeader/PageHeader.js +7 -4
  37. package/lib/components/PageHeader/PageHeaderTitle.js +10 -6
  38. package/lib/components/SidePanel/SidePanel.js +32 -15
  39. package/lib/components/WebTerminal/WebTerminal.js +1 -1
  40. package/lib/settings.js +0 -6
  41. package/package.json +12 -12
  42. package/scss/components/AddSelect/_add-select.scss +24 -0
  43. package/scss/components/BreadcrumbWithOverflow/_index.scss +1 -1
  44. package/scss/components/CancelableTextEdit/_cancelable-text-edit.scss +1 -0
  45. package/scss/components/CreateInfluencer/_create-influencer.scss +4 -4
  46. package/scss/components/CreateTearsheet/_create-tearsheet.scss +2 -2
  47. package/scss/components/InlineEdit/_inline-edit.scss +210 -9
  48. package/scss/components/InlineEdit/_storybook-styles.scss +13 -0
  49. package/scss/components/NotificationsPanel/_notifications-panel.scss +2 -2
  50. package/scss/components/PageHeader/_index.scss +1 -1
  51. package/scss/components/PageHeader/_page-header.scss +1 -1
  52. package/scss/components/ProductiveCard/_productive-card.scss +0 -4
  53. package/scss/components/SidePanel/_side-panel.scss +15 -6
  54. package/scss/components/StatusIcon/_index.scss +1 -1
  55. package/scss/components/TagSet/_index.scss +1 -1
  56. package/scss/components/UserProfileImage/_index.scss +1 -1
  57. package/scss/components/WebTerminal/_web-terminal.scss +2 -2
  58. package/scss/global/styles/_project-settings.scss +5 -1
  59. package/es/generated/feature-flags/feature-flags.js +0 -15
  60. package/lib/generated/feature-flags/feature-flags.js +0 -22
  61. package/scss/generated/feature-flags/_feature-flags.scss +0 -19
@@ -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", "saveDescription", "saveDisabled", "size", "value", "warn", "warnText"];
10
6
 
11
7
  /**
12
8
  * Copyright IBM Corp. 2022, 2022
@@ -15,18 +11,17 @@ 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';
22
18
  import { getDevtoolsProps } from '../../global/js/utils/devtools';
23
- import { pkg, carbon } from '../../settings'; // Carbon and package components we use.
19
+ import { pkg } from '../../settings'; // Carbon and package components we use.
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,19 +30,22 @@ 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, _cx2;
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,
51
49
  saveDescription = _ref.saveDescription,
52
50
  saveDisabled = _ref.saveDisabled,
53
51
  size = _ref.size,
@@ -56,62 +54,208 @@ export var InlineEdit = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
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 showValidationText = invalid || warn;
72
+ var validationText = invalidText || warnText;
73
+ var validationIcon = showValidationText ? invalid ? /*#__PURE__*/React.createElement(WarningFilled16, null) : /*#__PURE__*/React.createElement(WarningAltFilled16, null) : null;
74
+
75
+ var handleEdit = function handleEdit(ev) {
76
+ if (!disabled) {
77
+ var rightOfInput = ev.currentTarget.classList.contains("".concat(blockClass, "__edit")) || ev.target.classList.contains("".concat(blockClass, "__controls"));
78
+ var leftOfInput = ev.currentTarget = ev.target.classList.contains("".concat(blockClass)); // clicking on the content editable element should not set either of these to true
79
+
80
+ if (rightOfInput || leftOfInput) {
81
+ setEditing(true);
82
+ setTimeout(function () {
83
+ refInput.current.focus(); // select all the content
84
+
85
+ document.getSelection().selectAllChildren(refInput.current);
86
+
87
+ if (rightOfInput) {
88
+ document.getSelection().collapseToEnd();
89
+ refInput.current.scrollLeft = 9999; // never going to get there but ensures at end.
90
+ } else {
91
+ document.getSelection().collapseToStart();
92
+ refInput.current.scrollLeft = 0; // scroll to start
93
+ }
94
+ }, 0);
95
+ }
96
+ }
97
+ };
98
+
99
+ var handleFocus = function handleFocus(ev) {
100
+ if (!editing && ev.target.classList.contains("".concat(blockClass, "__input"))) {
101
+ // console.log(editing);
102
+ setEditing(true);
103
+ }
68
104
  };
69
105
 
70
- var handleChange = function handleChange(val) {
106
+ var handleSave = function handleSave() {
71
107
  setEditing(false);
72
- onChange(val);
108
+ document.getSelection().removeAllRanges();
109
+
110
+ if (onSave) {
111
+ onSave(refInput.current.innerText);
112
+ }
113
+ };
114
+
115
+ var handlePaste = function handlePaste(ev) {
116
+ ev.preventDefault(); // Get clipboard as plain text
117
+
118
+ var text = (ev.clipboardData || window.clipboardData).getData('text/plain'); // remove \n
119
+
120
+ var sanitizedText = text.replaceAll(/\n/g, '') // remove carriage returns
121
+ .replaceAll(/\t/g, ' '); // replace tab with two spaces
122
+
123
+ if (document.queryCommandSupported('insertText')) {
124
+ document.execCommand('insertText', false, sanitizedText);
125
+ } else {
126
+ // Insert text at the current position of caret
127
+ var range = document.getSelection().getRangeAt(0);
128
+ range.deleteContents();
129
+ var textNode = document.createTextNode(sanitizedText);
130
+ range.insertNode(textNode); // move selection end of textNode
131
+
132
+ range.selectNodeContents(textNode);
133
+ range.collapse(false); // remove existing range
134
+
135
+ var selection = document.getSelection();
136
+ selection.removeAllRanges(); // set the new range
137
+
138
+ selection.addRange(range);
139
+ }
73
140
  };
74
141
 
75
- var handleRevert = function handleRevert() {
142
+ var handleInput = function handleInput() {
143
+ setInternalValue(refInput.current.innerText);
144
+
145
+ if (onChange) {
146
+ onChange(refInput.current.innerText);
147
+ }
148
+ };
149
+
150
+ var handleCancel = function handleCancel() {
151
+ refInput.current.innerText = value;
152
+ handleInput(value);
76
153
  setEditing(false);
77
- onRevert(value);
154
+ document.getSelection().removeAllRanges();
155
+
156
+ if (onCancel) {
157
+ onCancel(value);
158
+ }
78
159
  };
79
160
 
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
- }));
161
+ var handleBlur = function handleBlur(ev) {
162
+ if (!ref.current.contains(ev.relatedTarget)) {
163
+ setEditing(false);
164
+ handleSave();
165
+ }
166
+ };
167
+
168
+ var handleKeyDown = function handleKeyDown(ev) {
169
+ if (ev.key === 'Enter') {
170
+ ev.preventDefault();
171
+ refInput.current.blur(); // will cause save
172
+ }
173
+ };
174
+ /*
175
+ The HTML is structured as follows:
176
+ <container>
177
+ <!-- margin left of input to match Carbon -->
178
+ <content-editable>
179
+ <-- margin right of input space for controls -->
180
+ <controls>
181
+ </container>
182
+ NOTE:
183
+ - An input is not used as this would not permit a heading tag e.g. <h2>.
184
+ - Some padding is added to the left 16px standard for a Carbon text input
185
+ - The controls are position absolute with a margin to on the input to reserve space. Using inline-flex
186
+ - does not measure space properly for the input otherwise.
187
+ - The content editable is not expected to change size when buttons are added, to ensure the text does not move space
188
+ is reserved up front for buttons and invalid icon. Mostly this is only noticed if the width of the component is not 100%.
189
+ which can be shown by setting inlineEditFullWidth to false in storybook.
190
+ In making content-editable behave like an input of type text we have to account for.
191
+ - Enforcing a single line
192
+ - Pasting of non-text e.g. html or text with carriage returns
193
+ - The padding and border not hiding typed in text.
194
+ - Placing the cursor at the start or end depending on area clicked (before for left-padding)
195
+ */
196
+
197
+
198
+ var controlsAnimation = true;
199
+ return (
200
+ /*#__PURE__*/
201
+ // eslint-disable-next-line
202
+ React.createElement("div", {
203
+ className: cx(blockClass, // Apply the block class to the main HTML element
204
+ className, // Apply any supplied class names to the main HTML element.
205
+ "".concat(blockClass, "--").concat(size), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "--editing"), editing), _defineProperty(_cx, "".concat(blockClass, "--invalid"), invalid), _defineProperty(_cx, "".concat(blockClass, "--light"), light), _cx)),
206
+ onClick: handleEdit // disabled eslint for click handler
207
+ ,
208
+ onBlur: handleBlur,
209
+ ref: ref
210
+ }, /*#__PURE__*/React.createElement("div", _extends({}, rest, getDevtoolsProps(componentName), {
211
+ id: id,
212
+ size: size,
213
+ className: "".concat(blockClass, "__input"),
214
+ contentEditable: true,
215
+ "aria-label": labelText,
216
+ role: "textbox",
217
+ tabIndex: "0",
218
+ onFocus: handleFocus,
219
+ onInput: handleInput,
220
+ onKeyDown: handleKeyDown,
221
+ onPaste: handlePaste,
222
+ suppressContentEditableWarning: true,
223
+ ref: refInput
224
+ }), value), refInput.current && refInput.current.innerText.length === 0 && /*#__PURE__*/React.createElement("div", {
225
+ className: "".concat(blockClass, "__placeholder")
226
+ }, labelText), showValidationText && validationText.length > 0 && /*#__PURE__*/React.createElement("div", {
227
+ className: "".concat(blockClass, "__validation-text")
228
+ }, validationText), /*#__PURE__*/React.createElement("div", {
229
+ className: "".concat(blockClass, "__validation-icon")
230
+ }, validationIcon), /*#__PURE__*/React.createElement("div", {
231
+ className: cx("".concat(blockClass, "__controls"), (_cx2 = {}, _defineProperty(_cx2, "".concat(blockClass, "__controls--animation"), controlsAnimation), _defineProperty(_cx2, "".concat(blockClass, "__controls--saveable"), invalid || saveDisabled || refInput.current && value !== internalValue), _cx2))
232
+ }, editing ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
233
+ className: "".concat(blockClass, "__cancel"),
234
+ kind: "ghost",
235
+ hasIconOnly: true,
236
+ iconDescription: cancelDescription,
237
+ onClick: handleCancel,
238
+ renderIcon: Close16
239
+ }), /*#__PURE__*/React.createElement(Button, {
240
+ className: "".concat(blockClass, "__save"),
241
+ kind: "ghost",
242
+ hasIconOnly: true,
243
+ iconDescription: saveDescription,
244
+ onClick: handleSave,
245
+ renderIcon: Checkmark16,
246
+ disabled: invalid || saveDisabled || value === internalValue
247
+ })) : /*#__PURE__*/React.createElement(Button, {
248
+ "aria-hidden": "true",
249
+ className: cx("".concat(blockClass, "__edit"), _defineProperty({}, "".concat(blockClass, "__edit--hover-visible"), editVisibleOnHoverOnly)),
250
+ kind: "ghost",
251
+ hasIconOnly: true,
252
+ iconDescription: editDescription,
253
+ onClick: handleEdit,
254
+ renderIcon: disabled ? EditOff16 : Edit16,
255
+ disabled: disabled,
256
+ tabIndex: -1
257
+ })))
258
+ );
115
259
  }); // Return a placeholder if not released and not enabled by feature flag
116
260
 
117
261
  InlineEdit = pkg.checkComponentEnabled(InlineEdit, componentName); // The display name of the component, used by React. Note that displayName
@@ -122,6 +266,11 @@ InlineEdit.displayName = componentName; // The types and DocGen commentary for t
122
266
  // See https://www.npmjs.com/package/prop-types#usage.
123
267
 
124
268
  InlineEdit.propTypes = {
269
+ /**
270
+ * label for cancel button
271
+ */
272
+ cancelDescription: PropTypes.string.isRequired,
273
+
125
274
  /**
126
275
  * Provide an optional class to be applied to the containing node.
127
276
  */
@@ -138,16 +287,15 @@ InlineEdit.propTypes = {
138
287
  editDescription: PropTypes.string.isRequired,
139
288
 
140
289
  /**
141
- * ID for inline edit
290
+ * In some scenarios the edit icon only needs to be shown on hover. These cases are where continual visibility of
291
+ * the edit icon is redundant. E.g. a spreadsheet a property panel.
142
292
  */
143
- id: PropTypes.string,
144
-
145
- /* TODO: add types and DocGen for all props. */
293
+ editVisibleOnHoverOnly: PropTypes.bool,
146
294
 
147
295
  /**
148
- * inline variant
149
- */
150
- inline: PropTypes.bool,
296
+ * ID for inline edit
297
+ */
298
+ id: PropTypes.string,
151
299
 
152
300
  /**
153
301
  * set invalid state for input
@@ -165,24 +313,24 @@ InlineEdit.propTypes = {
165
313
  labelText: PropTypes.string,
166
314
 
167
315
  /**
168
- * method called on change event
316
+ * change background to light version (mimic React TextInput)
169
317
  */
170
- onChange: PropTypes.func,
318
+ light: PropTypes.bool,
171
319
 
172
320
  /**
173
- * method called on input event
321
+ * method called on cancel event
174
322
  */
175
- onInput: PropTypes.func,
323
+ onCancel: PropTypes.func,
176
324
 
177
325
  /**
178
- * method called on revert event
326
+ * method called on input event (it's a React thing onChange behaves like on input)
179
327
  */
180
- onRevert: PropTypes.func,
328
+ onChange: PropTypes.func,
181
329
 
182
330
  /**
183
- * label for revert button
331
+ * method called on change event
184
332
  */
185
- revertDescription: PropTypes.string.isRequired,
333
+ onSave: PropTypes.func,
186
334
 
187
335
  /**
188
336
  * label for save button
@@ -219,6 +367,7 @@ InlineEdit.propTypes = {
219
367
  // component needs to make a choice or assumption when a prop is not supplied.
220
368
 
221
369
  InlineEdit.defaultProps = {
222
- /* TODO: add defaults for relevant props. */
370
+ light: true,
371
+ // defaults to true to reflect design
223
372
  size: 'md'
224
373
  };
@@ -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,7 +767,8 @@ 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
773
  * - revertDescription: label for edit revert button
772
774
  * - saveDescription: label for edit save button
@@ -786,6 +788,7 @@ PageHeader.propTypes = _objectSpread({
786
788
  id: PropTypes.string,
787
789
  // .isRequired.if(inlineEditRequired),
788
790
  onChange: PropTypes.func,
791
+ onSave: PropTypes.func,
789
792
  revertDescription: PropTypes.string,
790
793
  //.isRequired.if(inlineEditRequired),
791
794
  saveDescription: PropTypes.string //.isRequired.if(inlineEditRequired),
@@ -1,7 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- var _excluded = ["text", "content", "loading", "icon", "asText", "onChange", "editDescription", "editableLabel", "revertDescription", "saveDescription"];
4
+ var _excluded = ["text", "content", "loading", "icon", "asText", "onChange", "onSave", "editDescription", "editableLabel", "revertDescription", "saveDescription"];
5
5
  import React from 'react';
6
6
  import PropTypes from 'prop-types';
7
7
  import cx from 'classnames';
@@ -26,6 +26,7 @@ export var PageHeaderTitle = function PageHeaderTitle(_ref) {
26
26
  icon = title.icon,
27
27
  asText = title.asText,
28
28
  onChange = title.onChange,
29
+ onSave = title.onSave,
29
30
  editDescription = title.editDescription,
30
31
  editableLabel = title.editableLabel,
31
32
  revertDescription = title.revertDescription,
@@ -33,7 +34,7 @@ export var PageHeaderTitle = function PageHeaderTitle(_ref) {
33
34
  rest = _objectWithoutProperties(title, _excluded);
34
35
 
35
36
  var titleText;
36
- var isEditable = !!onChange;
37
+ var isEditable = !!onSave;
37
38
 
38
39
  if (text || !content) {
39
40
  if (text === undefined && typeof title === 'string') {
@@ -51,6 +52,7 @@ export var PageHeaderTitle = function PageHeaderTitle(_ref) {
51
52
  value: text,
52
53
  editDescription: editDescription,
53
54
  onChange: onChange,
55
+ onSave: onSave,
54
56
  labelText: editableLabel,
55
57
  revertDescription: revertDescription,
56
58
  saveDescription: saveDescription
@@ -68,8 +70,8 @@ export var PageHeaderTitle = function PageHeaderTitle(_ref) {
68
70
  }, titleInnards);
69
71
  };
70
72
  export var inlineEditRequired = function inlineEditRequired(_ref2) {
71
- var onChange = _ref2.onChange;
72
- return !!onChange;
73
+ var onSave = _ref2.onSave;
74
+ return !!onSave;
73
75
  };
74
76
  PageHeaderTitle.propTypes = {
75
77
  // passed from page header
@@ -89,9 +91,10 @@ PageHeaderTitle.propTypes = {
89
91
  * - text: title string
90
92
  * - icon: optional icon
91
93
  * - loading: boolean shows loading indicator if true
92
- * - onChange: function to process edits only supply if in place edit is desired
94
+ * - onChange: function to process the live value (React change === HTML Input)
95
+ * - onSave: function to process a confirmed change
93
96
  * - editDescription: description for edit button
94
- * - editableLabel: label for edit required if onChange supplied
97
+ * - editableLabel: label for edit required if onSave supplied
95
98
  * - revertDescription: description for edit revert button
96
99
  * - saveDescription: description for edit save button
97
100
  * - 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.
@@ -109,6 +112,7 @@ PageHeaderTitle.propTypes = {
109
112
  editableLabel: PropTypes.string.isRequired.if(inlineEditRequired),
110
113
  id: PropTypes.string.isRequired.if(inlineEditRequired),
111
114
  onChange: PropTypes.func,
115
+ onSave: PropTypes.func,
112
116
  revertDescription: PropTypes.string.isRequired.if(inlineEditRequired),
113
117
  saveDescription: PropTypes.string.isRequired.if(inlineEditRequired) // Update docgen if changed
114
118