@carbon/ibm-products 2.0.0-rc.26 → 2.0.0-rc.28

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. package/css/index-full-carbon.css +131 -251
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +3 -5
  4. package/css/index-full-carbon.min.css.map +1 -1
  5. package/css/index-without-carbon-released-only.css +202 -219
  6. package/css/index-without-carbon-released-only.css.map +1 -1
  7. package/css/index-without-carbon-released-only.min.css +1 -3
  8. package/css/index-without-carbon-released-only.min.css.map +1 -1
  9. package/css/index-without-carbon.css +131 -251
  10. package/css/index-without-carbon.css.map +1 -1
  11. package/css/index-without-carbon.min.css +3 -5
  12. package/css/index-without-carbon.min.css.map +1 -1
  13. package/css/index.css +131 -251
  14. package/css/index.css.map +1 -1
  15. package/css/index.min.css +3 -5
  16. package/css/index.min.css.map +1 -1
  17. package/es/components/AboutModal/AboutModal.js +3 -4
  18. package/es/components/ActionBar/ActionBar.js +13 -29
  19. package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +15 -21
  20. package/es/components/ButtonSetWithOverflow/ButtonSetWithOverflow.js +7 -11
  21. package/es/components/Card/Card.js +8 -6
  22. package/es/components/Card/CardHeader.js +2 -2
  23. package/es/components/Datagrid/Datagrid/DatagridEmptyBody.js +15 -20
  24. package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +6 -2
  25. package/es/components/Datagrid/Datagrid/DatagridRefBody.js +3 -1
  26. package/es/components/Datagrid/Datagrid/DatagridRow.js +6 -2
  27. package/es/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +7 -8
  28. package/es/components/Datagrid/Datagrid/DatagridSimpleBody.js +3 -1
  29. package/es/components/Datagrid/Datagrid/DatagridToolbar.js +6 -5
  30. package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +6 -5
  31. package/es/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +17 -3
  32. package/es/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +19 -4
  33. package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +19 -5
  34. package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useInitialStateFromFilters.js +2 -1
  35. package/es/components/Datagrid/Datagrid/addons/Filtering/utils.js +19 -1
  36. package/es/components/Datagrid/useFiltering.js +4 -2
  37. package/es/components/Datagrid/useOnRowClick.js +11 -1
  38. package/es/components/Datagrid/useSelectRows.js +2 -0
  39. package/es/components/{InlineEditV2/InlineEditV2.js → EditInPlace/EditInPlace.js} +92 -30
  40. package/es/components/{InlineEdit → EditInPlace}/index.js +1 -1
  41. package/es/components/ExpressiveCard/ExpressiveCard.js +3 -3
  42. package/es/components/PageHeader/PageHeader.js +40 -38
  43. package/es/components/PageHeader/PageHeaderTitle.js +18 -18
  44. package/es/components/ProductiveCard/ProductiveCard.js +3 -3
  45. package/es/components/SidePanel/SidePanel.js +25 -26
  46. package/es/components/TagSet/TagSet.js +5 -7
  47. package/es/components/Tearsheet/TearsheetShell.js +4 -6
  48. package/es/components/index.js +1 -1
  49. package/es/global/js/hooks/useResizeObserver.js +79 -0
  50. package/es/global/js/hooks/useWindowResize.js +6 -0
  51. package/es/global/js/hooks/useWindowScroll.js +7 -0
  52. package/es/global/js/package-settings.js +2 -4
  53. package/lib/components/AboutModal/AboutModal.js +3 -4
  54. package/lib/components/ActionBar/ActionBar.js +13 -29
  55. package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +13 -19
  56. package/lib/components/ButtonSetWithOverflow/ButtonSetWithOverflow.js +7 -11
  57. package/lib/components/Card/Card.js +7 -5
  58. package/lib/components/Card/CardHeader.js +2 -2
  59. package/lib/components/Datagrid/Datagrid/DatagridEmptyBody.js +14 -19
  60. package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +6 -2
  61. package/lib/components/Datagrid/Datagrid/DatagridRefBody.js +3 -1
  62. package/lib/components/Datagrid/Datagrid/DatagridRow.js +6 -2
  63. package/lib/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +2 -1
  64. package/lib/components/Datagrid/Datagrid/DatagridSimpleBody.js +3 -1
  65. package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +5 -4
  66. package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +6 -5
  67. package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +17 -3
  68. package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +19 -4
  69. package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +19 -5
  70. package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useInitialStateFromFilters.js +2 -1
  71. package/lib/components/Datagrid/Datagrid/addons/Filtering/utils.js +18 -1
  72. package/lib/components/Datagrid/useFiltering.js +4 -2
  73. package/lib/components/Datagrid/useOnRowClick.js +11 -1
  74. package/lib/components/Datagrid/useSelectRows.js +2 -0
  75. package/lib/components/{InlineEditV2/InlineEditV2.js → EditInPlace/EditInPlace.js} +100 -34
  76. package/lib/components/{InlineEdit → EditInPlace}/index.js +3 -3
  77. package/lib/components/ExpressiveCard/ExpressiveCard.js +3 -3
  78. package/lib/components/PageHeader/PageHeader.js +40 -38
  79. package/lib/components/PageHeader/PageHeaderTitle.js +19 -19
  80. package/lib/components/ProductiveCard/ProductiveCard.js +3 -3
  81. package/lib/components/SidePanel/SidePanel.js +25 -26
  82. package/lib/components/TagSet/TagSet.js +5 -7
  83. package/lib/components/Tearsheet/TearsheetShell.js +4 -6
  84. package/lib/components/index.js +7 -7
  85. package/lib/global/js/hooks/useResizeObserver.js +91 -0
  86. package/lib/global/js/hooks/useWindowScroll.js +6 -0
  87. package/lib/global/js/package-settings.js +2 -4
  88. package/package.json +3 -4
  89. package/scss/components/ActionBar/_action-bar.scss +0 -4
  90. package/scss/components/BreadcrumbWithOverflow/_breadcrumb-with-overflow.scss +10 -1
  91. package/scss/components/Card/_card.scss +13 -6
  92. package/scss/components/Datagrid/styles/_useSelectAllToggle.scss +11 -7
  93. package/scss/components/{InlineEditV2/_inline-edit-v2.scss → EditInPlace/_edit-in-place.scss} +56 -14
  94. package/scss/components/{InlineEditV1 → EditInPlace}/_index-with-carbon.scss +1 -1
  95. package/scss/components/{InlineEditV2 → EditInPlace}/_index.scss +1 -1
  96. package/scss/components/{InlineEditV1 → EditInPlace}/_storybook-styles.scss +3 -15
  97. package/scss/components/ExportModal/_export-modal.scss +0 -4
  98. package/scss/components/ExpressiveCard/_expressive-card.scss +1 -1
  99. package/scss/components/PageHeader/_page-header.scss +3 -10
  100. package/scss/components/ProductiveCard/_productive-card.scss +31 -2
  101. package/scss/components/TagSet/_tag-set.scss +1 -0
  102. package/scss/components/UserProfileImage/_user-profile-image.scss +5 -0
  103. package/scss/components/_index-released-only-with-carbon.scss +1 -1
  104. package/scss/components/_index-released-only.scss +1 -1
  105. package/scss/components/_index-with-carbon.scss +1 -2
  106. package/scss/components/_index.scss +1 -2
  107. package/es/components/InlineEdit/InlineEdit.js +0 -47
  108. package/es/components/InlineEditV1/InlineEditV1.js +0 -442
  109. package/es/components/InlineEditV1/index.js +0 -7
  110. package/es/components/InlineEditV2/index.js +0 -7
  111. package/lib/components/InlineEdit/InlineEdit.js +0 -63
  112. package/lib/components/InlineEditV1/InlineEditV1.js +0 -459
  113. package/lib/components/InlineEditV1/index.js +0 -13
  114. package/lib/components/InlineEditV2/index.js +0 -13
  115. package/scss/components/InlineEditV1/_carbon-imports.scss +0 -6
  116. package/scss/components/InlineEditV1/_index.scss +0 -8
  117. package/scss/components/InlineEditV1/_inline-edit-v1.scss +0 -269
  118. package/scss/components/InlineEditV2/_index-with-carbon.scss +0 -9
  119. package/scss/components/InlineEditV2/_storybook-styles.scss +0 -9
  120. /package/scss/components/{InlineEditV2 → EditInPlace}/_carbon-imports.scss +0 -0
@@ -1,8 +1,13 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ import _typeof from "@babel/runtime/helpers/typeof";
3
4
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
5
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
- var _excluded = ["cancelLabel", "editLabel", "id", "invalid", "invalidLabel", "labelText", "onCancel", "onChange", "onSave", "saveLabel", "value"];
6
+ var _excluded = ["cancelLabel", "editAlwaysVisible", "editLabel", "id", "inheritTypography", "invalid", "invalidLabel", "invalidText", "labelText", "onCancel", "onChange", "onSave", "saveLabel", "size", "tooltipAlignment", "value"];
7
+
8
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
9
+
10
+ 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; }
6
11
 
7
12
  /**
8
13
  * Copyright IBM Corp. 2022, 2022
@@ -18,21 +23,31 @@ import { Edit, Checkmark, Close, // EditOff,
18
23
  WarningFilled } from '@carbon/react/icons';
19
24
  import { pkg, carbon } from '../../settings';
20
25
  import { getDevtoolsProps } from '../../global/js/utils/devtools';
21
- var componentName = 'InlineEditV2';
22
- var blockClass = "".concat(pkg.prefix, "--inline-edit-v2");
23
- export var InlineEditV2 = /*#__PURE__*/forwardRef(function (_ref, ref) {
26
+ var componentName = 'EditInPlace';
27
+ var blockClass = "".concat(pkg.prefix, "--edit-in-place");
28
+ var defaults = {
29
+ tooltipAlignment: 'top',
30
+ size: 'sm'
31
+ };
32
+ export var EditInPlace = /*#__PURE__*/forwardRef(function (_ref, ref) {
24
33
  var _cx;
25
34
 
26
35
  var cancelLabel = _ref.cancelLabel,
36
+ editAlwaysVisible = _ref.editAlwaysVisible,
27
37
  editLabel = _ref.editLabel,
28
38
  id = _ref.id,
39
+ inheritTypography = _ref.inheritTypography,
29
40
  invalid = _ref.invalid,
30
- invalidLabel = _ref.invalidLabel,
41
+ deprecated_invalidLabel = _ref.invalidLabel,
42
+ invalidText = _ref.invalidText,
31
43
  labelText = _ref.labelText,
32
44
  onCancel = _ref.onCancel,
33
45
  onChange = _ref.onChange,
34
46
  onSave = _ref.onSave,
35
47
  saveLabel = _ref.saveLabel,
48
+ _ref$size = _ref.size,
49
+ size = _ref$size === void 0 ? defaults.size : _ref$size,
50
+ tooltipAlignment = _ref.tooltipAlignment,
36
51
  value = _ref.value,
37
52
  rest = _objectWithoutProperties(_ref, _excluded);
38
53
 
@@ -54,20 +69,27 @@ export var InlineEditV2 = /*#__PURE__*/forwardRef(function (_ref, ref) {
54
69
  var inputRef = useRef(null);
55
70
  var canSave = value !== initialValue && !invalid;
56
71
  var escaping = useRef(false);
72
+ var tipAlignIsObject = _typeof(tooltipAlignment) === 'object';
73
+ var tipAlignments = ['edit', 'save', 'cancel'].reduce(function (acc, tips) {
74
+ var _ref2;
75
+
76
+ acc[tips] = (_ref2 = tipAlignIsObject ? tooltipAlignment[tips] : tooltipAlignment) !== null && _ref2 !== void 0 ? _ref2 : defaults.tooltipAlignment;
77
+ return acc;
78
+ }, {});
57
79
  useEffect(function () {
58
80
  if (!initialValue && !dirtyInput) {
59
81
  setInitialValue(value);
60
82
  }
61
83
  }, [initialValue, dirtyInput, value]);
62
84
 
63
- var isTargetingChild = function isTargetingChild(_ref2) {
64
- var currentTarget = _ref2.currentTarget,
65
- relatedTarget = _ref2.relatedTarget;
85
+ var isTargetingChild = function isTargetingChild(_ref3) {
86
+ var currentTarget = _ref3.currentTarget,
87
+ relatedTarget = _ref3.relatedTarget;
66
88
  return currentTarget.contains(relatedTarget);
67
89
  };
68
90
 
69
- var onChangeHandler = function onChangeHandler(_ref3) {
70
- var target = _ref3.target;
91
+ var onChangeHandler = function onChangeHandler(_ref4) {
92
+ var target = _ref4.target;
71
93
 
72
94
  if (!dirtyInput) {
73
95
  setDirtyInput(true);
@@ -149,7 +171,7 @@ export var InlineEditV2 = /*#__PURE__*/forwardRef(function (_ref, ref) {
149
171
  return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
150
172
  ref: ref
151
173
  }, getDevtoolsProps(componentName)), /*#__PURE__*/React.createElement("div", {
152
- className: cx(blockClass, (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "--focused"), focused), _defineProperty(_cx, "".concat(blockClass, "--invalid"), invalid), _cx)),
174
+ className: cx(blockClass, "".concat(blockClass, "--").concat(size), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "--focused"), focused), _defineProperty(_cx, "".concat(blockClass, "--invalid"), invalid), _defineProperty(_cx, "".concat(blockClass, "--inherit-type"), inheritTypography), _defineProperty(_cx, "".concat(blockClass, "--overflows"), inputRef.current && inputRef.current.scrollWidth > inputRef.current.offsetWidth), _cx)),
153
175
  onFocus: onFocusHandler,
154
176
  onBlur: onBlurHandler
155
177
  }, /*#__PURE__*/React.createElement("label", {
@@ -157,7 +179,7 @@ export var InlineEditV2 = /*#__PURE__*/forwardRef(function (_ref, ref) {
157
179
  htmlFor: id
158
180
  }, labelText), /*#__PURE__*/React.createElement("input", {
159
181
  id: id,
160
- className: cx("".concat(blockClass, "__text-input"), "".concat(carbon.prefix, "--text-input"), "".concat(carbon.prefix, "--text-input--sm")),
182
+ className: cx("".concat(blockClass, "__text-input"), "".concat(carbon.prefix, "--text-input"), "".concat(carbon.prefix, "--text-input--").concat(size)),
161
183
  type: "text",
162
184
  value: value,
163
185
  onChange: onChangeHandler,
@@ -165,12 +187,16 @@ export var InlineEditV2 = /*#__PURE__*/forwardRef(function (_ref, ref) {
165
187
  ,
166
188
  onKeyDown: onKeyHandler
167
189
  }), /*#__PURE__*/React.createElement("div", {
190
+ className: "".concat(blockClass, "__ellipsis"),
191
+ "aria-hidden": !focused
192
+ }, "\u2026"), /*#__PURE__*/React.createElement("div", {
168
193
  className: "".concat(blockClass, "__toolbar")
169
- }, focused ? /*#__PURE__*/React.createElement(React.Fragment, null, invalid && /*#__PURE__*/React.createElement(WarningFilled, {
194
+ }, invalid && /*#__PURE__*/React.createElement(WarningFilled, {
170
195
  size: 16,
171
196
  className: "".concat(blockClass, "__warning-icon")
172
- }), /*#__PURE__*/React.createElement(IconButton, {
173
- size: "sm",
197
+ }), focused ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(IconButton, {
198
+ align: tipAlignments.cancel,
199
+ size: size,
174
200
  label: cancelLabel,
175
201
  onClick: onCancelHandler,
176
202
  kind: "ghost",
@@ -180,7 +206,8 @@ export var InlineEditV2 = /*#__PURE__*/forwardRef(function (_ref, ref) {
180
206
  }, /*#__PURE__*/React.createElement(Close, {
181
207
  size: 16
182
208
  })), /*#__PURE__*/React.createElement(IconButton, {
183
- size: "sm",
209
+ align: tipAlignments.save,
210
+ size: size,
184
211
  label: saveLabel,
185
212
  onClick: onSaveHandler,
186
213
  kind: "ghost",
@@ -191,8 +218,9 @@ export var InlineEditV2 = /*#__PURE__*/forwardRef(function (_ref, ref) {
191
218
  }, /*#__PURE__*/React.createElement(Checkmark, {
192
219
  size: 16
193
220
  }))) : /*#__PURE__*/React.createElement(IconButton, {
194
- className: "".concat(blockClass, "__btn ").concat(blockClass, "__btn-edit"),
195
- size: "sm",
221
+ align: tipAlignments.edit,
222
+ className: cx("".concat(blockClass, "__btn"), "".concat(blockClass, "__btn-edit"), _defineProperty({}, "".concat(blockClass, "__btn-edit--always-visible"), editAlwaysVisible)),
223
+ size: size,
196
224
  label: editLabel,
197
225
  onClick: onFocusHandler,
198
226
  kind: "ghost",
@@ -200,18 +228,32 @@ export var InlineEditV2 = /*#__PURE__*/forwardRef(function (_ref, ref) {
200
228
  key: "edit"
201
229
  }, /*#__PURE__*/React.createElement(Edit, {
202
230
  size: 16
203
- })))), focused && invalid && /*#__PURE__*/React.createElement("p", {
231
+ })))), invalid && /*#__PURE__*/React.createElement("p", {
204
232
  className: "".concat(blockClass, "__warning-text")
205
- }, invalidLabel));
233
+ }, invalidText !== null && invalidText !== void 0 ? invalidText : deprecated_invalidLabel));
206
234
  });
207
- InlineEditV2 = pkg.checkComponentEnabled(InlineEditV2, componentName);
208
- InlineEditV2.displayName = componentName;
209
- InlineEditV2.propTypes = {
235
+ EditInPlace = pkg.checkComponentEnabled(EditInPlace, componentName);
236
+ EditInPlace.displayName = componentName;
237
+ export var deprecatedProps = {
238
+ /**
239
+ * **Deprecated**
240
+ * invalidLabel was misnamed, using invalidText to match Carbon
241
+ */
242
+ invalidText: PropTypes.string
243
+ };
244
+ var alignPropType = PropTypes.oneOf(['top', 'top-left', 'top-right', 'bottom', 'bottom-left', 'bottom-right', 'left', 'right']);
245
+ EditInPlace.propTypes = _objectSpread({
210
246
  /**
211
247
  * label for cancel button
212
248
  */
213
249
  cancelLabel: PropTypes.string.isRequired,
214
250
 
251
+ /**
252
+ * By default the edit icon is shown on hover only.
253
+ */
254
+ editAlwaysVisible: PropTypes.bool,
255
+
256
+ /**
215
257
  /**
216
258
  * label for edit button
217
259
  */
@@ -222,6 +264,15 @@ InlineEditV2.propTypes = {
222
264
  */
223
265
  id: PropTypes.string.isRequired,
224
266
 
267
+ /**
268
+ * inheritTypography - causes the text entry field to inherit typography settings
269
+ * assigned to the container. This is useful when editing titles for instance.
270
+ *
271
+ * NOTE: The size property limits the vertical size of the input element.
272
+ * Inherited font's should be selected to fit within the size selected.
273
+ */
274
+ inheritTypography: PropTypes.bool,
275
+
225
276
  /**
226
277
  * determines if the input is invalid
227
278
  */
@@ -230,7 +281,7 @@ InlineEditV2.propTypes = {
230
281
  /**
231
282
  * text that is displayed if the input is invalid
232
283
  */
233
- invalidLabel: PropTypes.string,
284
+ invalidText: PropTypes.string,
234
285
 
235
286
  /**
236
287
  * Provide the text that will be read by a screen reader when visiting this control
@@ -267,13 +318,24 @@ InlineEditV2.propTypes = {
267
318
  */
268
319
  saveLabel: PropTypes.string.isRequired,
269
320
 
321
+ /**
322
+ * vertical size of control
323
+ */
324
+ size: PropTypes.oneOf(['sm', 'md', 'lg']),
325
+
326
+ /**
327
+ * tooltipAlignment from the standard tooltip. Default center.
328
+ *
329
+ * Can be passed either as one of tooltip options or as an object specifying cancel, edit and save separately
330
+ */
331
+ tooltipAlignment: PropTypes.oneOfType([alignPropType, PropTypes.shape({
332
+ cancel: alignPropType,
333
+ edit: alignPropType,
334
+ save: alignPropType
335
+ })]),
336
+
270
337
  /**
271
338
  * current value of the input
272
339
  */
273
340
  value: PropTypes.string.isRequired
274
- };
275
- InlineEditV2.defaultProps = {
276
- invalid: false,
277
- invalidLabel: '' // readOnly: false,
278
-
279
- };
341
+ }, deprecatedProps);
@@ -4,4 +4,4 @@
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- export { InlineEdit } from './InlineEdit';
7
+ export { EditInPlace } from './EditInPlace';
@@ -46,12 +46,12 @@ ExpressiveCard.propTypes = {
46
46
  /**
47
47
  * Optional header description
48
48
  */
49
- description: PropTypes.string,
49
+ description: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.node]),
50
50
 
51
51
  /**
52
52
  * Optional label for the top of the card
53
53
  */
54
- label: PropTypes.string,
54
+ label: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.node]),
55
55
 
56
56
  /**
57
57
  * Optional media content like an image to be placed in the card
@@ -126,6 +126,6 @@ ExpressiveCard.propTypes = {
126
126
  /**
127
127
  * Title that's displayed at the top of the card
128
128
  */
129
- title: PropTypes.string
129
+ title: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.node])
130
130
  };
131
131
  ExpressiveCard.displayName = componentName;
@@ -18,7 +18,7 @@ import React, { useEffect, useRef, useState } from 'react';
18
18
  import PropTypes from 'prop-types';
19
19
  import { spacing10, baseFontSize } from '@carbon/layout';
20
20
  import cx from 'classnames';
21
- import { useResizeDetector } from 'react-resize-detector';
21
+ import { useResizeObserver } from '../../global/js/hooks/useResizeObserver';
22
22
  import { FlexGrid, Column, Row, Button, Tag } from '@carbon/react';
23
23
  import { breakpoints } from '@carbon/layout';
24
24
  import { useWindowResize, useNearestScroll } from '../../global/js/hooks';
@@ -39,7 +39,7 @@ var defaults = {
39
39
  narrowGrid: false
40
40
  };
41
41
  export var PageHeader = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
42
- var _withoutBackground, _enableBreadcrumbScro, _ref6, _cx2, _ref7, _cx4, _cx7;
42
+ var _withoutBackground, _enableBreadcrumbScro, _ref7, _cx2, _ref8, _cx4, _cx7;
43
43
 
44
44
  var actionBarItems = _ref.actionBarItems,
45
45
  actionBarMenuOptionsClass = _ref.actionBarMenuOptionsClass,
@@ -195,7 +195,9 @@ export var PageHeader = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
195
195
  /* istanbul ignore next */
196
196
 
197
197
 
198
- var handleResizeActionBarColumn = function handleResizeActionBarColumn(width) {
198
+ var handleResizeActionBarColumn = function handleResizeActionBarColumn(_ref4) {
199
+ var width = _ref4.width;
200
+
199
201
  /* don't know how to test resize */
200
202
 
201
203
  /* istanbul ignore next */
@@ -280,8 +282,8 @@ export var PageHeader = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
280
282
  }, [headerRef, enableBreadcrumbScroll, metrics, metrics.breadcrumbRowHeight, metrics.breadcrumbRowSpaceBelow, metrics.breadcrumbTitleHeight, metrics.breadcrumbRowWidth, metrics.headerHeight, metrics.headerWidth, metrics.headerOffset, metrics.headerTopValue, metrics.navigationRowHeight, navigation, scrollYValue, tags]);
281
283
  useNearestScroll(headerRef, // on scroll or various layout changes check updates if needed
282
284
  // istanbul ignore next
283
- function (_ref4) {
284
- var current = _ref4.current;
285
+ function (_ref5) {
286
+ var current = _ref5.current;
285
287
  setPageHeaderStyles(function (prev) {
286
288
  return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, "--".concat(blockClass, "--breadcrumb-top"), "".concat(metrics.headerOffset, "px")));
287
289
  });
@@ -297,8 +299,8 @@ export var PageHeader = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
297
299
  document.documentElement.style.setProperty("--".concat(blockClass, "--tagset-tooltip-offset"), "".concat(tagsetTooltipOffset, "px"));
298
300
  setScrollYValue(current.scrollY);
299
301
  }, [metrics.headerHeight, metrics.headerTopValue, metrics.headerOffset, enableBreadcrumbScroll]);
300
- useWindowResize(function (_ref5) {
301
- var current = _ref5.current;
302
+ useWindowResize(function (_ref6) {
303
+ var current = _ref6.current;
302
304
  // on window resize and other updates some values may have changed
303
305
  checkUpdateVerticalSpace();
304
306
  setWidthIsNarrow(current.innerWidth / 16 < parseInt(breakpoints.md.width)); // small (below medium) media query
@@ -348,15 +350,11 @@ export var PageHeader = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
348
350
  utilSetCollapsed(collapseHeader, metrics.headerOffset, metrics.headerTopValue);
349
351
  }
350
352
  }, [collapseHeader, metrics.headerOffset, metrics.headerTopValue]);
351
- useResizeDetector({
352
- onResize: handleResizeActionBarColumn,
353
- targetRef: sizingContainerRef,
354
- handleWidth: true
353
+ useResizeObserver(sizingContainerRef, {
354
+ callback: handleResizeActionBarColumn
355
355
  });
356
- useResizeDetector({
357
- onResize: handleResize,
358
- targetRef: headerRef,
359
- handleHeight: true
356
+ useResizeObserver(headerRef, {
357
+ callback: handleResize
360
358
  }); // Determine what form of title to display in the breadcrumb
361
359
 
362
360
  var breadcrumbItemForTitle = utilGetBreadcrumbItemForTitle(blockClass, collapseTitle, title);
@@ -364,7 +362,7 @@ export var PageHeader = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
364
362
  className: "".concat(blockClass, "--offset-top-measuring-element"),
365
363
  ref: offsetTopMeasuringRef
366
364
  }), /*#__PURE__*/React.createElement("section", _extends({}, rest, {
367
- className: cx([blockClass, "".concat(blockClass, "--no-margins-below-row"), className, (_ref6 = {}, _defineProperty(_ref6, "".concat(blockClass, "--has-navigation"), navigation || tags), _defineProperty(_ref6, "".concat(blockClass, "--has-navigation-tags-only"), !navigation && tags), _ref6)]),
365
+ className: cx([blockClass, "".concat(blockClass, "--no-margins-below-row"), className, (_ref7 = {}, _defineProperty(_ref7, "".concat(blockClass, "--has-navigation"), navigation || tags), _defineProperty(_ref7, "".concat(blockClass, "--has-navigation-tags-only"), !navigation && tags), _ref7)]),
368
366
  style: pageHeaderStyles,
369
367
  ref: headerRef
370
368
  }, getDevtoolsProps(componentName)), /*#__PURE__*/React.createElement(FlexGrid, {
@@ -386,7 +384,7 @@ export var PageHeader = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
386
384
  breadcrumbs: breadcrumbs && breadcrumbItemForTitle ? breadcrumbs.concat(breadcrumbItemForTitle) : breadcrumbItemForTitle ? [breadcrumbItemForTitle] : breadcrumbs // breadcrumbs may be null or undefined
387
385
 
388
386
  }) : null), /*#__PURE__*/React.createElement(Column, {
389
- 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)])
387
+ className: cx(["".concat(blockClass, "__action-bar-column ").concat(blockClass, "__action-bar-column--background"), (_ref8 = {}, _defineProperty(_ref8, "".concat(blockClass, "__action-bar-column--has-page-actions"), pageActions), _defineProperty(_ref8, "".concat(blockClass, "__action-bar-column--influenced-by-collapse-button"), spaceForCollapseButton), _ref8)])
390
388
  }, /*#__PURE__*/React.createElement("div", {
391
389
  className: "".concat(blockClass, "__action-bar-column-content"),
392
390
  ref: sizingContainerRef
@@ -446,8 +444,9 @@ export var PageHeader = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
446
444
  showAllTagsLabel: showAllTagsLabel,
447
445
  tags: tags,
448
446
  overflowClassName: "".concat(blockClass, "__navigation-tags-overflow")
449
- })) : null) : null), hasCollapseButton ? /*#__PURE__*/React.createElement(Button, {
450
- className: cx("".concat(blockClass, "__collapse-expand-toggle"), _defineProperty({}, "".concat(blockClass, "__collapse-expand-toggle--collapsed"), fullyCollapsed)),
447
+ })) : null) : null), hasCollapseButton ? /*#__PURE__*/React.createElement("div", {
448
+ className: cx("".concat(blockClass, "__collapse-expand-toggle"), _defineProperty({}, "".concat(blockClass, "__collapse-expand-toggle--collapsed"), fullyCollapsed))
449
+ }, /*#__PURE__*/React.createElement(Button, {
451
450
  hasIconOnly: true,
452
451
  iconDescription:
453
452
  /* istanbul ignore next */
@@ -463,7 +462,7 @@ export var PageHeader = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
463
462
  tooltipPosition: "bottom",
464
463
  tooltipAlignment: "end",
465
464
  type: "button"
466
- }) : null));
465
+ })) : null));
467
466
 
468
467
  function thePageActions(isBreadcrumbRow, inBreadcrumbRow) {
469
468
  if (pageActions) {
@@ -542,8 +541,8 @@ PageHeader.propTypes = _objectSpread({
542
541
  *
543
542
  * NOTE: This prop is required if actionBarItems are supplied
544
543
  */
545
- actionBarOverflowAriaLabel: PropTypes.string.isRequired.if(function (_ref9) {
546
- var actionBarItems = _ref9.actionBarItems;
544
+ actionBarOverflowAriaLabel: PropTypes.string.isRequired.if(function (_ref10) {
545
+ var actionBarItems = _ref10.actionBarItems;
547
546
  return actionBarItems && actionBarItems.length > 0;
548
547
  }),
549
548
 
@@ -578,8 +577,8 @@ PageHeader.propTypes = _objectSpread({
578
577
  * If the user supplies breadcrumbs then this property is required.
579
578
  * It is used in an overflow menu when there is insufficient space to display all breadcrumbs inline.
580
579
  */
581
- breadcrumbOverflowAriaLabel: PropTypes.string.isRequired.if(function (_ref10) {
582
- var breadcrumbs = _ref10.breadcrumbs;
580
+ breadcrumbOverflowAriaLabel: PropTypes.string.isRequired.if(function (_ref11) {
581
+ var breadcrumbs = _ref11.breadcrumbs;
583
582
  return breadcrumbs && breadcrumbs.length > 0;
584
583
  }),
585
584
 
@@ -618,8 +617,8 @@ PageHeader.propTypes = _objectSpread({
618
617
  /**
619
618
  * A text version of the `label` for display, required if `label` is not a string.
620
619
  */
621
- title: PropTypes.string.isRequired.if(function (_ref11) {
622
- var label = _ref11.label;
620
+ title: PropTypes.string.isRequired.if(function (_ref12) {
621
+ var label = _ref12.label;
623
622
  return typeof label !== 'string';
624
623
  })
625
624
  })),
@@ -649,9 +648,9 @@ PageHeader.propTypes = _objectSpread({
649
648
  * If `hasCollapseHeaderToggle` is set and `withoutBackground` is unset/falsy then assistive text is
650
649
  * required for both the expend and collapse states of the button component used.
651
650
  */
652
- collapseHeaderIconDescription: PropTypes.string.isRequired.if(function (_ref12) {
653
- var withoutBackground = _ref12.withoutBackground,
654
- hasCollapseHeaderToggle = _ref12.hasCollapseHeaderToggle;
651
+ collapseHeaderIconDescription: PropTypes.string.isRequired.if(function (_ref13) {
652
+ var withoutBackground = _ref13.withoutBackground,
653
+ hasCollapseHeaderToggle = _ref13.hasCollapseHeaderToggle;
655
654
  return !withoutBackground && hasCollapseHeaderToggle;
656
655
  }),
657
656
 
@@ -671,9 +670,9 @@ PageHeader.propTypes = _objectSpread({
671
670
  * If `hasCollapseHeaderToggle` is set and `withoutBackground` is unset/falsy then assistive text is
672
671
  * required for both the expend and collapse states of the button component used.
673
672
  */
674
- expandHeaderIconDescription: PropTypes.string.isRequired.if(function (_ref13) {
675
- var withoutBackground = _ref13.withoutBackground,
676
- hasCollapseHeaderToggle = _ref13.hasCollapseHeaderToggle;
673
+ expandHeaderIconDescription: PropTypes.string.isRequired.if(function (_ref14) {
674
+ var withoutBackground = _ref14.withoutBackground,
675
+ hasCollapseHeaderToggle = _ref14.hasCollapseHeaderToggle;
677
676
  return !withoutBackground && hasCollapseHeaderToggle;
678
677
  }),
679
678
 
@@ -744,8 +743,8 @@ PageHeader.propTypes = _objectSpread({
744
743
  *
745
744
  * NOTE: This prop is required if pageActions are supplied
746
745
  */
747
- pageActionsOverflowLabel: PropTypes.node.isRequired.if(function (_ref14) {
748
- var pageActions = _ref14.pageActions;
746
+ pageActionsOverflowLabel: PropTypes.node.isRequired.if(function (_ref15) {
747
+ var pageActions = _ref15.pageActions;
749
748
  return pageActions && pageActions.length > 0 && !pageActions.content;
750
749
  }),
751
750
 
@@ -808,14 +807,17 @@ PageHeader.propTypes = _objectSpread({
808
807
  loading: PropTypes.bool,
809
808
  // inline edit version properties
810
809
  editableLabel: PropTypes.string,
811
- // .isRequired.if(inlineEditRequired),
810
+ // .isRequired.if(editInPlaceRequired),
812
811
  id: PropTypes.string,
813
- // .isRequired.if(inlineEditRequired),
812
+ // .isRequired.if(editInPlaceRequired),
813
+ onCancel: PropTypes.func,
814
814
  onChange: PropTypes.func,
815
815
  onSave: PropTypes.func,
816
816
  cancelDescription: PropTypes.string,
817
- //.isRequired.if(inlineEditRequired),
818
- saveDescription: PropTypes.string //.isRequired.if(inlineEditRequired),
817
+ //.isRequired.if(editInPlaceRequired),
818
+ editDescription: PropTypes.string,
819
+ // .isRequired.if(editInPlaceRequired),
820
+ saveDescription: PropTypes.string //.isRequired.if(editInPlaceRequired),
819
821
  // Update docgen if changed
820
822
 
821
823
  }), PropTypes.string, PropTypes.shape({
@@ -1,12 +1,12 @@
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", "onSave", "editDescription", "editableLabel", "revertDescription", "saveDescription"];
4
+ var _excluded = ["text", "content", "loading", "icon", "asText", "onChange", "onSave", "editDescription", "editableLabel", "cancelDescription", "saveDescription"];
5
5
  import React from 'react';
6
6
  import PropTypes from 'prop-types';
7
7
  import cx from 'classnames';
8
8
  import { SkeletonText } from '@carbon/react';
9
- import { InlineEdit } from '../';
9
+ import { EditInPlace } from '../';
10
10
  /**
11
11
  *
12
12
  * Utility component used by Page Header
@@ -29,7 +29,7 @@ export var PageHeaderTitle = function PageHeaderTitle(_ref) {
29
29
  onSave = title.onSave,
30
30
  editDescription = title.editDescription,
31
31
  editableLabel = title.editableLabel,
32
- revertDescription = title.revertDescription,
32
+ cancelDescription = title.cancelDescription,
33
33
  saveDescription = title.saveDescription,
34
34
  rest = _objectWithoutProperties(title, _excluded);
35
35
 
@@ -47,17 +47,17 @@ export var PageHeaderTitle = function PageHeaderTitle(_ref) {
47
47
  className: "".concat(blockClass, "__title-icon")
48
48
  }) : null, loading ? /*#__PURE__*/React.createElement(SkeletonText, {
49
49
  className: "".concat(blockClass, "__title-skeleton")
50
- }) : isEditable ? /*#__PURE__*/React.createElement(InlineEdit, _extends({
51
- v1: true,
52
- hideLabel: true,
50
+ }) : isEditable ? /*#__PURE__*/React.createElement(EditInPlace, _extends({
51
+ tooltipAlignment: "bottom",
53
52
  value: text,
54
- editDescription: editDescription,
53
+ cancelLabel: cancelDescription,
54
+ editLabel: editDescription,
55
+ saveLabel: saveDescription,
56
+ labelText: editableLabel,
55
57
  onChange: onChange,
56
58
  onSave: onSave,
57
- labelText: editableLabel,
58
- revertDescription: revertDescription,
59
- saveDescription: saveDescription,
60
- buttonTooltipPosition: "bottom"
59
+ size: "md",
60
+ inheritTypography: true
61
61
  }, rest)) : /*#__PURE__*/React.createElement("span", {
62
62
  title: !loading ? asText : null
63
63
  }, text));
@@ -71,7 +71,7 @@ export var PageHeaderTitle = function PageHeaderTitle(_ref) {
71
71
  title: titleText
72
72
  }, titleInnards);
73
73
  };
74
- export var inlineEditRequired = function inlineEditRequired(_ref2) {
74
+ export var editInPlaceRequired = function editInPlaceRequired(_ref2) {
75
75
  var onSave = _ref2.onSave;
76
76
  return !!onSave;
77
77
  };
@@ -97,7 +97,7 @@ PageHeaderTitle.propTypes = {
97
97
  * - onSave: function to process a confirmed change
98
98
  * - editDescription: description for edit button
99
99
  * - editableLabel: label for edit required if onSave supplied
100
- * - revertDescription: description for edit revert button
100
+ * - cancelDescription: description for edit cancel button
101
101
  * - saveDescription: description for edit save button
102
102
  * - 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.
103
103
  * - content: title or name of current location shown in main part of page header
@@ -110,13 +110,13 @@ PageHeaderTitle.propTypes = {
110
110
  icon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
111
111
  loading: PropTypes.bool,
112
112
  // inline edit version properties
113
- editDescription: PropTypes.string.isRequired.if(inlineEditRequired),
114
- editableLabel: PropTypes.string.isRequired.if(inlineEditRequired),
115
- id: PropTypes.string.isRequired.if(inlineEditRequired),
113
+ editDescription: PropTypes.string.isRequired.if(editInPlaceRequired),
114
+ editableLabel: PropTypes.string.isRequired.if(editInPlaceRequired),
115
+ id: PropTypes.string.isRequired.if(editInPlaceRequired),
116
116
  onChange: PropTypes.func,
117
117
  onSave: PropTypes.func,
118
- revertDescription: PropTypes.string.isRequired.if(inlineEditRequired),
119
- saveDescription: PropTypes.string.isRequired.if(inlineEditRequired) // Update docgen if changed
118
+ cancelDescription: PropTypes.string.isRequired.if(editInPlaceRequired),
119
+ saveDescription: PropTypes.string.isRequired.if(editInPlaceRequired) // Update docgen if changed
120
120
 
121
121
  }), PropTypes.string, PropTypes.shape({
122
122
  content: PropTypes.node.isRequired,
@@ -75,12 +75,12 @@ ProductiveCard.propTypes = {
75
75
  /**
76
76
  * Optional header description
77
77
  */
78
- description: PropTypes.string,
78
+ description: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.node]),
79
79
 
80
80
  /**
81
81
  * Optional label for the top of the card
82
82
  */
83
- label: PropTypes.string,
83
+ label: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.node]),
84
84
 
85
85
  /**
86
86
  * Provides the callback for a clickable card
@@ -130,7 +130,7 @@ ProductiveCard.propTypes = {
130
130
  /**
131
131
  * Title that's displayed at the top of the card
132
132
  */
133
- title: PropTypes.string,
133
+ title: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.node]),
134
134
 
135
135
  /**
136
136
  * Determines title size