@carbon/ibm-products 1.8.0 → 1.11.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 (111) hide show
  1. package/css/index-full-carbon.css +270 -5656
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +6 -6
  4. package/css/index-full-carbon.min.css.map +1 -1
  5. package/css/index-without-carbon-released-only.css +58 -3432
  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 -1
  9. package/css/index-without-carbon.css +238 -3922
  10. package/css/index-without-carbon.css.map +1 -1
  11. package/css/index-without-carbon.min.css +6 -6
  12. package/css/index-without-carbon.min.css.map +1 -1
  13. package/css/index.css +238 -3923
  14. package/css/index.css.map +1 -1
  15. package/css/index.min.css +6 -6
  16. package/css/index.min.css.map +1 -1
  17. package/es/components/AddSelect/AddSelect.js +147 -53
  18. package/es/components/AddSelect/AddSelectBreadcrumbs.js +4 -4
  19. package/es/components/AddSelect/AddSelectColumn.js +195 -0
  20. package/es/components/AddSelect/AddSelectList.js +67 -8
  21. package/es/components/AddSelect/AddSelectSidebar.js +8 -15
  22. package/es/components/AddSelect/add-select-utils.js +64 -0
  23. package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +2 -1
  24. package/es/components/ButtonMenu/ButtonMenu.js +1 -1
  25. package/es/components/DataSpreadsheet/DataSpreadsheet.js +505 -167
  26. package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +244 -17
  27. package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +74 -8
  28. package/es/components/DataSpreadsheet/hooks/useMoveActiveCell.js +27 -0
  29. package/es/components/DataSpreadsheet/hooks/useResetSpreadsheetFocus.js +28 -0
  30. package/es/components/DataSpreadsheet/hooks/useSpreadsheetOutsideClick.js +41 -0
  31. package/es/components/DataSpreadsheet/utils/checkActiveHeaderCell.js +34 -0
  32. package/es/components/DataSpreadsheet/utils/createActiveCellFn.js +58 -0
  33. package/es/components/DataSpreadsheet/utils/createCellSelectionArea.js +49 -0
  34. package/es/components/DataSpreadsheet/{generateData.js → utils/generateData.js} +6 -0
  35. package/es/components/DataSpreadsheet/{getCellSize.js → utils/getCellSize.js} +0 -0
  36. package/es/components/DataSpreadsheet/utils/handleHeaderCellSelection.js +46 -0
  37. package/es/components/DataSpreadsheet/utils/handleMultipleKeys.js +82 -0
  38. package/es/components/DataSpreadsheet/utils/removeCellSelections.js +30 -0
  39. package/es/components/InlineEdit/InlineEdit.js +80 -39
  40. package/es/components/OptionsTile/OptionsTile.js +31 -21
  41. package/es/components/OptionsTile/index.js +1 -1
  42. package/es/components/PageHeader/PageHeader.js +26 -15
  43. package/es/components/PageHeader/PageHeaderTitle.js +2 -1
  44. package/es/components/PageHeader/PageHeaderUtils.js +24 -29
  45. package/es/components/TagSet/TagSet.js +12 -3
  46. package/es/components/UserProfileImage/UserProfileImage.js +2 -1
  47. package/es/global/js/utils/DisplayBox.js +31 -0
  48. package/es/global/js/utils/deepCloneObject.js +26 -0
  49. package/lib/components/AddSelect/AddSelect.js +150 -54
  50. package/lib/components/AddSelect/AddSelectBreadcrumbs.js +2 -3
  51. package/lib/components/AddSelect/AddSelectColumn.js +219 -0
  52. package/lib/components/AddSelect/AddSelectList.js +65 -8
  53. package/lib/components/AddSelect/AddSelectSidebar.js +14 -15
  54. package/lib/components/AddSelect/add-select-utils.js +78 -0
  55. package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +2 -1
  56. package/lib/components/ButtonMenu/ButtonMenu.js +1 -1
  57. package/lib/components/DataSpreadsheet/DataSpreadsheet.js +514 -170
  58. package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +251 -18
  59. package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +82 -9
  60. package/lib/components/DataSpreadsheet/hooks/useMoveActiveCell.js +37 -0
  61. package/lib/components/DataSpreadsheet/hooks/useResetSpreadsheetFocus.js +39 -0
  62. package/lib/components/DataSpreadsheet/hooks/useSpreadsheetOutsideClick.js +52 -0
  63. package/lib/components/DataSpreadsheet/utils/checkActiveHeaderCell.js +45 -0
  64. package/lib/components/DataSpreadsheet/{createActiveCellFn.js → utils/createActiveCellFn.js} +22 -9
  65. package/lib/components/DataSpreadsheet/utils/createCellSelectionArea.js +60 -0
  66. package/lib/components/DataSpreadsheet/{generateData.js → utils/generateData.js} +6 -0
  67. package/lib/components/DataSpreadsheet/{getCellSize.js → utils/getCellSize.js} +0 -0
  68. package/lib/components/DataSpreadsheet/utils/handleHeaderCellSelection.js +59 -0
  69. package/lib/components/DataSpreadsheet/utils/handleMultipleKeys.js +92 -0
  70. package/lib/components/DataSpreadsheet/utils/removeCellSelections.js +41 -0
  71. package/lib/components/InlineEdit/InlineEdit.js +82 -40
  72. package/lib/components/OptionsTile/OptionsTile.js +30 -20
  73. package/lib/components/PageHeader/PageHeader.js +25 -15
  74. package/lib/components/PageHeader/PageHeaderTitle.js +2 -1
  75. package/lib/components/PageHeader/PageHeaderUtils.js +24 -29
  76. package/lib/components/TagSet/TagSet.js +13 -3
  77. package/lib/components/UserProfileImage/UserProfileImage.js +2 -1
  78. package/lib/global/js/utils/DisplayBox.js +46 -0
  79. package/lib/global/js/utils/deepCloneObject.js +37 -0
  80. package/package.json +17 -17
  81. package/scss/components/ActionBar/_storybook-styles.scss +8 -0
  82. package/scss/components/ActionSet/_storybook-styles.scss +1 -3
  83. package/scss/components/AddSelect/_add-select.scss +99 -14
  84. package/scss/components/BreadcrumbWithOverflow/_breadcrumb-with-overflow.scss +7 -3
  85. package/scss/components/BreadcrumbWithOverflow/_storybook-styles.scss +8 -0
  86. package/scss/components/ButtonSetWithOverflow/_storybook-styles.scss +8 -0
  87. package/scss/components/CreateInfluencer/_create-influencer.scss +2 -0
  88. package/scss/components/CreateModal/_create-modal.scss +1 -0
  89. package/scss/components/CreateSidePanel/_create-side-panel.scss +1 -1
  90. package/scss/components/CreateSidePanel/_storybook-styles.scss +1 -1
  91. package/scss/components/CreateTearsheet/_create-tearsheet.scss +1 -0
  92. package/scss/components/CreateTearsheetNarrow/_create-tearsheet-narrow.scss +1 -0
  93. package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +42 -6
  94. package/scss/components/EditSidePanel/_edit-side-panel.scss +9 -0
  95. package/scss/components/EditSidePanel/_storybook-styles.scss +1 -1
  96. package/scss/components/InlineEdit/_inline-edit.scss +53 -43
  97. package/scss/components/InlineEdit/_storybook-styles.scss +2 -0
  98. package/scss/components/LoadingBar/_loading-bar.scss +13 -0
  99. package/scss/components/NotificationsPanel/_notifications-panel.scss +3 -0
  100. package/scss/components/OptionsTile/_index.scss +1 -1
  101. package/scss/components/OptionsTile/_options-tile.scss +17 -17
  102. package/scss/components/OptionsTile/_storybook-styles.scss +4 -4
  103. package/scss/components/PageHeader/_page-header.scss +5 -2
  104. package/scss/components/SidePanel/_side-panel.scss +19 -12
  105. package/scss/components/StatusIcon/_status-icon.scss +1 -0
  106. package/scss/components/TagSet/_storybook-styles.scss +8 -0
  107. package/scss/components/Tearsheet/_tearsheet.scss +1 -2
  108. package/scss/components/UserProfileImage/_user-profile-image.scss +9 -0
  109. package/scss/components/WebTerminal/_web-terminal.scss +2 -0
  110. package/scss/global/styles/_display-box.scss +62 -0
  111. package/es/components/DataSpreadsheet/createActiveCellFn.js +0 -45
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2022
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { px } from '@carbon/layout';
8
+ import { deepCloneObject } from '../../../global/js/utils/deepCloneObject';
9
+ export var createCellSelectionArea = function createCellSelectionArea(_ref) {
10
+ var area = _ref.area,
11
+ blockClass = _ref.blockClass,
12
+ defaultColumn = _ref.defaultColumn,
13
+ selectionAreas = _ref.selectionAreas,
14
+ setSelectionAreas = _ref.setSelectionAreas;
15
+ var greatestRow = Math.max(area.point1.row, area.point2.row);
16
+ var greatestColumn = Math.max(area.point1.column, area.point2.column);
17
+ var lowestRowIndex = Math.min(area.point1.row, area.point2.row);
18
+ var lowestColumnIndex = Math.min(area.point1.column, area.point2.column);
19
+ var point1Element = document.querySelector("[data-row-index=\"".concat(area.point1.row, "\"][data-column-index=\"").concat(area.point1.column, "\"]")) || document.querySelector(".".concat(blockClass, "__body--td")); // if we can't find the point1 element (this can happen in the case where a virtualized row is not present anymore in the DOM), we get the default height/width of the first body cell we find
20
+
21
+ var selectionAreaCellWidth = point1Element.offsetWidth;
22
+ var selectionAreaCellHeight = point1Element.offsetHeight;
23
+ var selectionAreaTotalWidth = selectionAreaCellWidth * (greatestColumn - lowestColumnIndex + 1);
24
+ var selectionAreaTotalHeight = selectionAreaCellHeight * (greatestRow - lowestRowIndex + 1);
25
+ var bodyContainer = document.querySelector(".".concat(blockClass, "__list--container")).firstElementChild;
26
+ var placementElement = bodyContainer.querySelector("[data-row-index=\"".concat(lowestRowIndex, "\"][data-column-index=\"").concat(lowestColumnIndex, "\"]"));
27
+ var relativePosition = {
28
+ top: placementElement ? placementElement.getBoundingClientRect().top - bodyContainer.getBoundingClientRect().top : lowestRowIndex === 0 ? 0 : selectionAreaCellHeight * lowestRowIndex,
29
+ // calculate top value here if virtualized row is not in DOM
30
+ left: placementElement ? placementElement.getBoundingClientRect().left - bodyContainer.getBoundingClientRect().left : lowestColumnIndex === 0 ? 0 + (defaultColumn.rowHeaderWidth - 4) : selectionAreaCellWidth * lowestColumnIndex + (defaultColumn.rowHeaderWidth - 4) // calculate left value here if virtualized row is not in DOM, accounting for row header cell width (including borders)
31
+
32
+ };
33
+ var selectionAreaElement = document.querySelector("[data-matcher-id=\"".concat(area.matcher, "\"]")) || document.createElement('div');
34
+ selectionAreaElement.classList.add("".concat(blockClass, "__selection-area--element"));
35
+ selectionAreaElement.setAttribute('data-matcher-id', area.matcher);
36
+ selectionAreaElement.style.width = px(selectionAreaTotalWidth);
37
+ selectionAreaElement.style.height = px(selectionAreaTotalHeight);
38
+ selectionAreaElement.style.left = px(relativePosition.left);
39
+ selectionAreaElement.style.top = px(relativePosition.top);
40
+ bodyContainer.appendChild(selectionAreaElement);
41
+ var selectionAreasClone = deepCloneObject(selectionAreas);
42
+ var indexOfCurrentArea = selectionAreasClone.findIndex(function (item) {
43
+ return item.matcher === area.matcher;
44
+ }); // We need to add another property to the selectionAreas object array to
45
+ // let us know if an area has been created for each item already, ie createdArea: true
46
+
47
+ selectionAreasClone[indexOfCurrentArea].areaCreated = true;
48
+ setSelectionAreas(selectionAreasClone);
49
+ };
@@ -4,6 +4,12 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
4
4
 
5
5
  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
6
 
7
+ /**
8
+ * Copyright IBM Corp. 2022, 2022
9
+ *
10
+ * This source code is licensed under the Apache-2.0 license found in the
11
+ * LICENSE file in the root directory of this source tree.
12
+ */
7
13
  // cspell:disable
8
14
  var pets = ['dog', 'cat', 'bird', 'lizard', 'frog', 'hamster', 'fish', 'rabbit', 'snake'];
9
15
  var petNames = ['Bruno', 'Willow', 'Kona', 'Heidi', 'Rusty', 'Bonnie', 'Cash', 'Gucci', 'Brody', 'Emma', 'Loki', 'Angel', 'Astro', 'Sherman', 'Layla', 'Peanut', 'Grace', 'Mickey', 'Sasha', 'Finn', 'Tucker', 'Bear', 'Mocha', 'Roscoe']; // cspell:enable
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2022
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import uuidv4 from '../../../global/js/utils/uuidv4';
8
+ import { removeCellSelections } from './removeCellSelections';
9
+ export var handleHeaderCellSelection = function handleHeaderCellSelection(_ref) {
10
+ var type = _ref.type,
11
+ activeCellCoordinates = _ref.activeCellCoordinates,
12
+ rows = _ref.rows,
13
+ columns = _ref.columns,
14
+ setActiveCellCoordinates = _ref.setActiveCellCoordinates,
15
+ setCurrentMatcher = _ref.setCurrentMatcher,
16
+ setSelectionAreas = _ref.setSelectionAreas,
17
+ spreadsheetRef = _ref.spreadsheetRef,
18
+ index = _ref.index,
19
+ isKeyboard = _ref.isKeyboard;
20
+ var rowValue = isKeyboard ? activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row : index;
21
+ var columnValue = isKeyboard ? activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column : index;
22
+ var point1 = {
23
+ row: type === 'column' ? 0 : rowValue,
24
+ column: type === 'column' ? columnValue : 0
25
+ };
26
+ var point2 = {
27
+ row: type === 'column' ? rows.length - 1 : rowValue,
28
+ // going to always be the last row
29
+ column: type === 'column' ? columnValue : columns.length - 1
30
+ };
31
+ var tempMatcher = uuidv4();
32
+ setActiveCellCoordinates({
33
+ row: type === 'column' ? 0 : rowValue,
34
+ column: type === 'column' ? columnValue : 0
35
+ });
36
+ setCurrentMatcher(tempMatcher);
37
+ removeCellSelections({
38
+ spreadsheetRef: spreadsheetRef
39
+ });
40
+ setSelectionAreas([{
41
+ point1: point1,
42
+ point2: point2,
43
+ areaCreated: false,
44
+ matcher: tempMatcher
45
+ }]);
46
+ };
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2022
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { deepCloneObject } from '../../../global/js/utils/deepCloneObject';
8
+ export var handleMultipleKeys = function handleMultipleKeys(_ref) {
9
+ var _selectionAreasClone$;
10
+
11
+ var activeKeys = _ref.activeKeys,
12
+ selectionAreas = _ref.selectionAreas,
13
+ currentMatcher = _ref.currentMatcher,
14
+ rows = _ref.rows,
15
+ setSelectionAreas = _ref.setSelectionAreas,
16
+ columns = _ref.columns;
17
+ var activeKeyValues = activeKeys.current;
18
+ var selectionAreasClone = deepCloneObject(selectionAreas);
19
+ var indexOfCurrentArea = selectionAreasClone.findIndex(function (item) {
20
+ return item.matcher === currentMatcher;
21
+ });
22
+ var pointToUpdate = (_selectionAreasClone$ = selectionAreasClone[indexOfCurrentArea]) !== null && _selectionAreasClone$ !== void 0 && _selectionAreasClone$.point2 ? selectionAreasClone[indexOfCurrentArea].point2 : selectionAreasClone[indexOfCurrentArea].point1; // Down + Shift
23
+
24
+ if (activeKeyValues.includes('Shift') && activeKeyValues.includes('ArrowDown')) {
25
+ if (rows.length - 1 === pointToUpdate.row) {
26
+ return;
27
+ }
28
+
29
+ var newPoint = {
30
+ row: pointToUpdate.row + 1,
31
+ column: pointToUpdate.column
32
+ };
33
+ selectionAreasClone[indexOfCurrentArea].point2 = newPoint;
34
+ selectionAreasClone[indexOfCurrentArea].areaCreated = false;
35
+ setSelectionAreas(selectionAreasClone);
36
+ } // Right + Shift
37
+
38
+
39
+ if (activeKeyValues.includes('Shift') && activeKeyValues.includes('ArrowRight')) {
40
+ if (columns.length - 1 === pointToUpdate.column) {
41
+ return;
42
+ }
43
+
44
+ var _newPoint = {
45
+ row: pointToUpdate.row,
46
+ column: pointToUpdate.column + 1
47
+ };
48
+ selectionAreasClone[indexOfCurrentArea].point2 = _newPoint;
49
+ selectionAreasClone[indexOfCurrentArea].areaCreated = false;
50
+ setSelectionAreas(selectionAreasClone);
51
+ } // Up + Shift
52
+
53
+
54
+ if (activeKeyValues.includes('Shift') && activeKeyValues.includes('ArrowUp')) {
55
+ if (pointToUpdate.row === 0) {
56
+ return;
57
+ }
58
+
59
+ var _newPoint2 = {
60
+ row: pointToUpdate.row - 1,
61
+ column: pointToUpdate.column
62
+ };
63
+ selectionAreasClone[indexOfCurrentArea].point2 = _newPoint2;
64
+ selectionAreasClone[indexOfCurrentArea].areaCreated = false;
65
+ setSelectionAreas(selectionAreasClone);
66
+ } // Left + Shift
67
+
68
+
69
+ if (activeKeyValues.includes('Shift') && activeKeyValues.includes('ArrowLeft')) {
70
+ if (pointToUpdate.column === 0) {
71
+ return;
72
+ }
73
+
74
+ var _newPoint3 = {
75
+ row: pointToUpdate.row,
76
+ column: pointToUpdate.column - 1
77
+ };
78
+ selectionAreasClone[indexOfCurrentArea].point2 = _newPoint3;
79
+ selectionAreasClone[indexOfCurrentArea].areaCreated = false;
80
+ setSelectionAreas(selectionAreasClone);
81
+ }
82
+ };
@@ -0,0 +1,30 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+
3
+ /**
4
+ * Copyright IBM Corp. 2022, 2022
5
+ *
6
+ * This source code is licensed under the Apache-2.0 license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+ import { pkg } from '../../../settings'; // Removes the cell selection elements
10
+
11
+ export var removeCellSelections = function removeCellSelections(_ref) {
12
+ var matcher = _ref.matcher,
13
+ spreadsheetRef = _ref.spreadsheetRef,
14
+ _ref$blockClass = _ref.blockClass,
15
+ blockClass = _ref$blockClass === void 0 ? "".concat(pkg.prefix, "--data-spreadsheet") : _ref$blockClass;
16
+
17
+ if (matcher && typeof matcher === 'string') {
18
+ var selectionToRemove = spreadsheetRef.current.querySelector("[data-matcher-id=\"".concat(matcher, "\"]"));
19
+
20
+ if (selectionToRemove) {
21
+ selectionToRemove.remove();
22
+ }
23
+ } else {
24
+ var cellSelections = spreadsheetRef.current.querySelectorAll(".".concat(blockClass, "__selection-area--element"));
25
+
26
+ _toConsumableArray(cellSelections).forEach(function (element) {
27
+ return element.remove();
28
+ });
29
+ }
30
+ };
@@ -1,8 +1,9 @@
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 = ["cancelDescription", "className", "disabled", "editDescription", "editVisibleOnHoverOnly", "id", "invalid", "invalidText", "labelText", "light", "onCancel", "onSave", "onChange", "placeholder", "saveDescription", "size", "value", "warn", "warnText"];
6
+ var _excluded = ["buttonTooltipAlignment", "buttonTooltipPosition", "cancelDescription", "className", "disabled", "editAlwaysVisible", "editDescription", "id", "invalid", "invalidText", "labelText", "light", "onCancel", "onSave", "onChange", "placeholder", "saveDescription", "size", "value"];
6
7
 
7
8
  /**
8
9
  * Copyright IBM Corp. 2022, 2022
@@ -21,16 +22,19 @@ import { pkg, carbon } from '../../settings'; // Carbon and package components w
21
22
  /* TODO: @import(s) of carbon components and other package components. */
22
23
 
23
24
  import { Button } from 'carbon-components-react';
24
- import { Close16, Edit16, EditOff16, Checkmark16, WarningFilled16, WarningAltFilled16 } from '@carbon/icons-react'; // The block part of our conventional BEM class names (blockClass__E--M).
25
+ import { Close16, Edit16, EditOff16, Checkmark16, WarningFilled16 } from '@carbon/icons-react'; // The block part of our conventional BEM class names (blockClass__E--M).
25
26
 
26
27
  var blockClass = "".concat(pkg.prefix, "--inline-edit");
27
28
  var componentName = 'InlineEdit'; // NOTE: the component SCSS is not imported here: it is rolled up separately.
28
29
 
29
30
  var defaults = {
31
+ buttonTooltipAlignment: 'center',
32
+ buttonTooltipPosition: 'top',
30
33
  light: true,
31
34
  // defaults to true to reflect design
32
35
  size: 'md'
33
36
  };
37
+ var buttons = ['cancel', 'edit', 'save'];
34
38
  /**
35
39
  * TODO: A description of the component.
36
40
  */
@@ -38,11 +42,13 @@ var defaults = {
38
42
  export var InlineEdit = /*#__PURE__*/React.forwardRef(function (_ref, refIn) {
39
43
  var _cx, _refInput$current, _refInput$current$inn, _cx3;
40
44
 
41
- var cancelDescription = _ref.cancelDescription,
45
+ var buttonTooltipAlignment = _ref.buttonTooltipAlignment,
46
+ buttonTooltipPosition = _ref.buttonTooltipPosition,
47
+ cancelDescription = _ref.cancelDescription,
42
48
  className = _ref.className,
43
49
  disabled = _ref.disabled,
50
+ editAlwaysVisible = _ref.editAlwaysVisible,
44
51
  editDescription = _ref.editDescription,
45
- editVisibleOnHoverOnly = _ref.editVisibleOnHoverOnly,
46
52
  id = _ref.id,
47
53
  invalid = _ref.invalid,
48
54
  invalidText = _ref.invalidText,
@@ -57,8 +63,6 @@ export var InlineEdit = /*#__PURE__*/React.forwardRef(function (_ref, refIn) {
57
63
  _ref$size = _ref.size,
58
64
  size = _ref$size === void 0 ? defaults.size : _ref$size,
59
65
  value = _ref.value,
60
- warn = _ref.warn,
61
- warnText = _ref.warnText,
62
66
  rest = _objectWithoutProperties(_ref, _excluded);
63
67
 
64
68
  var refInput = useRef(null);
@@ -75,9 +79,25 @@ export var InlineEdit = /*#__PURE__*/React.forwardRef(function (_ref, refIn) {
75
79
  internalValue = _useState4[0],
76
80
  setInternalValue = _useState4[1];
77
81
 
78
- var showValidation = invalid || warn;
79
- var validationText = invalidText || warnText;
80
- var validationIcon = showValidation ? invalid ? /*#__PURE__*/React.createElement(WarningFilled16, null) : /*#__PURE__*/React.createElement(WarningAltFilled16, null) : null;
82
+ var showValidation = invalid; // || warn;
83
+
84
+ var validationText = invalidText; // || warnText;
85
+
86
+ var validationIcon = showValidation ? /*#__PURE__*/React.createElement(WarningFilled16, null) : null; // sanitize the tooltip values
87
+
88
+ var alignIsObject = _typeof(buttonTooltipAlignment) === 'object';
89
+ var directionIsObject = _typeof(buttonTooltipPosition) === 'object';
90
+ var tipPositions = buttons.reduce(function (acc, button) {
91
+ var _ref2, _ref3;
92
+
93
+ var tooltipAlignment = (_ref2 = alignIsObject ? buttonTooltipAlignment[button] : buttonTooltipAlignment) !== null && _ref2 !== void 0 ? _ref2 : defaults.buttonTooltipAlignment;
94
+ var tooltipPosition = (_ref3 = directionIsObject ? buttonTooltipPosition[button] : buttonTooltipPosition) !== null && _ref3 !== void 0 ? _ref3 : defaults.buttonTooltipPosition;
95
+ acc[button] = {
96
+ tooltipAlignment: tooltipAlignment,
97
+ tooltipPosition: tooltipPosition
98
+ };
99
+ return acc;
100
+ }, {});
81
101
 
82
102
  var doSetEditing = function doSetEditing(value) {
83
103
  if (value === false) {
@@ -89,6 +109,7 @@ export var InlineEdit = /*#__PURE__*/React.forwardRef(function (_ref, refIn) {
89
109
  };
90
110
 
91
111
  var handleEdit = function handleEdit(ev) {
112
+ /* istanbul ignore else */
92
113
  if (!disabled) {
93
114
  var rightOfInput = ev.currentTarget.classList.contains("".concat(blockClass, "__edit")) || ev.target.classList.contains("".concat(blockClass, "__after-input-elements"));
94
115
  var leftOfInput = ev.currentTarget = ev.target.classList.contains("".concat(blockClass)); // clicking on the content editable element should not set either of these to true
@@ -135,9 +156,12 @@ export var InlineEdit = /*#__PURE__*/React.forwardRef(function (_ref, refIn) {
135
156
  if (onChange) {
136
157
  onChange(refInput.current.innerText);
137
158
  }
138
- };
159
+ }; // pasting into contentEditable not supported by userEvent
160
+
139
161
 
140
- var handlePaste = function handlePaste(ev) {
162
+ var handlePaste =
163
+ /* istanbul ignore next */
164
+ function handlePaste(ev) {
141
165
  ev.preventDefault(); // Get clipboard as plain text
142
166
 
143
167
  var text = (ev.clipboardData || window.clipboardData).getData('text/plain'); // remove \n
@@ -182,9 +206,16 @@ export var InlineEdit = /*#__PURE__*/React.forwardRef(function (_ref, refIn) {
182
206
  };
183
207
 
184
208
  var handleKeyDown = function handleKeyDown(ev) {
185
- if (ev.key === 'Enter') {
186
- ev.preventDefault();
187
- refInput.current.blur(); // will cause save
209
+ switch (ev.key) {
210
+ case 'Enter':
211
+ ev.preventDefault();
212
+ refInput.current.blur(); // will cause save
213
+
214
+ break;
215
+
216
+ case 'Escape':
217
+ handleCancel();
218
+ break;
188
219
  }
189
220
  };
190
221
  /*
@@ -218,7 +249,7 @@ export var InlineEdit = /*#__PURE__*/React.forwardRef(function (_ref, refIn) {
218
249
  React.createElement("div", {
219
250
  className: cx(blockClass, // Apply the block class to the main HTML element
220
251
  className, // Apply any supplied class names to the main HTML element.
221
- "".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)),
252
+ "".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, "--light"), light), _defineProperty(_cx, "".concat(blockClass, "--overflows"), refInput.current && refInput.current.scrollWidth > refInput.current.offsetWidth), _cx)),
222
253
  onClick: handleEdit // disabled eslint for click handler
223
254
  ,
224
255
  onBlur: handleBlur,
@@ -249,14 +280,14 @@ export var InlineEdit = /*#__PURE__*/React.forwardRef(function (_ref, refIn) {
249
280
  className: cx("".concat(blockClass, "__toolbar"), (_cx3 = {}, _defineProperty(_cx3, "".concat(blockClass, "__toolbar--animation"), toolbarAnimation), _defineProperty(_cx3, "".concat(blockClass, "__toolbar--saveable"), refInput.current && value !== internalValue), _cx3))
250
281
  }, showValidation && /*#__PURE__*/React.createElement("div", {
251
282
  className: "".concat(blockClass, "__validation-icon")
252
- }, validationIcon), editing ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
283
+ }, validationIcon), editing ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, _extends({
253
284
  className: "".concat(blockClass, "__cancel"),
254
285
  kind: "ghost",
255
286
  hasIconOnly: true,
256
287
  iconDescription: cancelDescription,
257
288
  onClick: handleCancel,
258
289
  renderIcon: Close16
259
- }), /*#__PURE__*/React.createElement(Button, {
290
+ }, tipPositions.cancel)), /*#__PURE__*/React.createElement(Button, _extends({
260
291
  className: "".concat(blockClass, "__save"),
261
292
  kind: "ghost",
262
293
  hasIconOnly: true,
@@ -264,9 +295,8 @@ export var InlineEdit = /*#__PURE__*/React.forwardRef(function (_ref, refIn) {
264
295
  onClick: handleSave,
265
296
  renderIcon: Checkmark16,
266
297
  disabled: value === internalValue
267
- })) : /*#__PURE__*/React.createElement(Button, {
268
- "aria-hidden": "true",
269
- className: cx("".concat(blockClass, "__edit"), _defineProperty({}, "".concat(blockClass, "__edit--hover-visible"), editVisibleOnHoverOnly)),
298
+ }, tipPositions.save))) : /*#__PURE__*/React.createElement(Button, _extends({
299
+ className: cx("".concat(blockClass, "__edit"), _defineProperty({}, "".concat(blockClass, "__edit--always-visible"), editAlwaysVisible)),
270
300
  kind: "ghost",
271
301
  hasIconOnly: true,
272
302
  iconDescription: editDescription,
@@ -274,7 +304,7 @@ export var InlineEdit = /*#__PURE__*/React.forwardRef(function (_ref, refIn) {
274
304
  renderIcon: disabled ? EditOff16 : Edit16,
275
305
  disabled: disabled,
276
306
  tabIndex: -1
277
- }))), /*#__PURE__*/React.createElement("div", {
307
+ }, tipPositions.edit)))), /*#__PURE__*/React.createElement("div", {
278
308
  className: cx("".concat(blockClass, "__disabled-cover"))
279
309
  }), showValidation && validationText && validationText.length > 0 && /*#__PURE__*/React.createElement("div", {
280
310
  className: "".concat(blockClass, "__validation-text ").concat(carbon.prefix, "--form-requirement")
@@ -290,6 +320,28 @@ InlineEdit.displayName = componentName; // The types and DocGen commentary for t
290
320
  // See https://www.npmjs.com/package/prop-types#usage.
291
321
 
292
322
  InlineEdit.propTypes = {
323
+ /**
324
+ * buttonTooltipAlignment from the standard tooltip. Default center.
325
+ *
326
+ * Can be passed either as one of tooltip options or as an object specifying cancel, edit and save separately
327
+ */
328
+ buttonTooltipAlignment: PropTypes.oneOfType([PropTypes.oneOf(['start', 'center', 'end']), PropTypes.shape({
329
+ cancel: PropTypes.oneOf(['start', 'center', 'end']),
330
+ edit: PropTypes.oneOf(['start', 'center', 'end']),
331
+ save: PropTypes.oneOf(['start', 'center', 'end'])
332
+ })]),
333
+
334
+ /**
335
+ * buttonTooltipPosition from the standard tooltip
336
+ *
337
+ * Can be passed either as one of tooltip options or as an object specifying cancel, edit and save separately
338
+ */
339
+ buttonTooltipPosition: PropTypes.oneOfType([PropTypes.oneOf(['top', 'right', 'bottom', 'left']), PropTypes.shape({
340
+ cancel: PropTypes.oneOf(['top', 'right', 'bottom', 'left']),
341
+ edit: PropTypes.oneOf(['top', 'right', 'bottom', 'left']),
342
+ save: PropTypes.oneOf(['top', 'right', 'bottom', 'left'])
343
+ })]),
344
+
293
345
  /**
294
346
  * label for cancel button
295
347
  */
@@ -306,15 +358,14 @@ InlineEdit.propTypes = {
306
358
  disabled: PropTypes.bool,
307
359
 
308
360
  /**
309
- * Label for the edit button
361
+ * By default the edit icon is shown on hover only.
310
362
  */
311
- editDescription: PropTypes.string.isRequired,
363
+ editAlwaysVisible: PropTypes.bool,
312
364
 
313
365
  /**
314
- * In some scenarios the edit icon only needs to be shown on hover. These cases are where continual visibility of
315
- * the edit icon is redundant. E.g. a spreadsheet a property panel.
366
+ * Label for the edit button
316
367
  */
317
- editVisibleOnHoverOnly: PropTypes.bool,
368
+ editDescription: PropTypes.string.isRequired,
318
369
 
319
370
  /**
320
371
  * ID for inline edit
@@ -349,14 +400,14 @@ InlineEdit.propTypes = {
349
400
  /**
350
401
  * method called on input event (it's a React thing onChange behaves like on input).
351
402
  *
352
- * NOTE: caller to handle invalid/warn states and associated text
403
+ * NOTE: caller to handle invalid states and associated text
353
404
  */
354
405
  onChange: PropTypes.func,
355
406
 
356
407
  /**
357
408
  * method called on change event
358
409
  *
359
- * NOTE: caller to handle invalid/warn states and associated text
410
+ * NOTE: caller to handle invalid states and associated text
360
411
  */
361
412
  onSave: PropTypes.func,
362
413
 
@@ -378,15 +429,5 @@ InlineEdit.propTypes = {
378
429
  /**
379
430
  * initial/unedited value
380
431
  */
381
- value: PropTypes.string,
382
-
383
- /**
384
- * set warn state for input
385
- */
386
- warn: PropTypes.bool,
387
-
388
- /**
389
- * text shown when warn true
390
- */
391
- warnText: PropTypes.string
432
+ value: PropTypes.string
392
433
  };
@@ -2,10 +2,10 @@ 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 = ["children", "className", "enabled", "heading", "headingId", "invalid", "invalidText", "locked", "lockedText", "onToggle", "open", "size", "summary", "warn", "warnText"];
5
+ var _excluded = ["children", "className", "enabled", "invalid", "invalidText", "locked", "lockedText", "onToggle", "open", "size", "summary", "title", "titleId", "warn", "warnText"];
6
6
 
7
7
  /**
8
- * Copyright IBM Corp. 2021, 2021
8
+ * Copyright IBM Corp. 2021, 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.
@@ -38,8 +38,6 @@ export var OptionsTile = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
38
38
  var children = _ref.children,
39
39
  className = _ref.className,
40
40
  enabled = _ref.enabled,
41
- heading = _ref.heading,
42
- userDefinedHeadingId = _ref.headingId,
43
41
  invalid = _ref.invalid,
44
42
  invalidText = _ref.invalidText,
45
43
  locked = _ref.locked,
@@ -49,6 +47,8 @@ export var OptionsTile = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
49
47
  _ref$size = _ref.size,
50
48
  size = _ref$size === void 0 ? defaults.size : _ref$size,
51
49
  summary = _ref.summary,
50
+ title = _ref.title,
51
+ userDefinedTitleId = _ref.titleId,
52
52
  warn = _ref.warn,
53
53
  warnText = _ref.warnText,
54
54
  rest = _objectWithoutProperties(_ref, _excluded);
@@ -71,7 +71,7 @@ export var OptionsTile = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
71
71
  var detailsRef = useRef(null);
72
72
  var contentRef = useRef(null);
73
73
  var id = uuidv4();
74
- var headingId = userDefinedHeadingId !== null && userDefinedHeadingId !== void 0 ? userDefinedHeadingId : "".concat(id, "-heading");
74
+ var titleId = userDefinedTitleId !== null && userDefinedTitleId !== void 0 ? userDefinedTitleId : "".concat(id, "-title");
75
75
  var isExpandable = children !== undefined;
76
76
  var isInvalid = invalid;
77
77
  var isWarn = !isInvalid && warn;
@@ -185,15 +185,25 @@ export var OptionsTile = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
185
185
  } else if (locked) {
186
186
  Icon = Locked16;
187
187
  summaryClasses.push("".concat(blockClass, "__summary--locked"));
188
+
189
+ if (!text) {
190
+ text = lockedText;
191
+ }
192
+ }
193
+
194
+ var hasValidationState = invalid || warn || locked;
195
+ var summaryHidden = !hasValidationState && enabled === false;
196
+
197
+ if (summaryHidden) {
198
+ summaryClasses.push("".concat(blockClass, "__summary--hidden"));
188
199
  }
189
200
 
190
- var summaryHidden = enabled === false;
191
201
  return /*#__PURE__*/React.createElement("div", {
192
- className: "".concat(blockClass, "__title")
193
- }, /*#__PURE__*/React.createElement("h6", {
194
- id: headingId,
195
202
  className: "".concat(blockClass, "__heading")
196
- }, heading), text && /*#__PURE__*/React.createElement("span", {
203
+ }, /*#__PURE__*/React.createElement("h6", {
204
+ id: titleId,
205
+ className: "".concat(blockClass, "__title")
206
+ }, title), text && /*#__PURE__*/React.createElement("span", {
197
207
  className: cx(summaryClasses),
198
208
  "aria-hidden": summaryHidden
199
209
  }, Icon && /*#__PURE__*/React.createElement(Icon, null), /*#__PURE__*/React.createElement("span", {
@@ -214,7 +224,7 @@ export var OptionsTile = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
214
224
  toggled: enabled,
215
225
  labelA: "",
216
226
  labelB: "",
217
- "aria-labelledby": headingId,
227
+ "aria-labelledby": titleId,
218
228
  onToggle: onToggle,
219
229
  size: "sm",
220
230
  disabled: isLocked
@@ -261,16 +271,6 @@ OptionsTile.propTypes = {
261
271
  */
262
272
  enabled: PropTypes.bool,
263
273
 
264
- /**
265
- * Provide the heading for this OptionsTile.
266
- */
267
- heading: PropTypes.string.isRequired,
268
-
269
- /**
270
- * Optionally provide an id which should be used for the heading.
271
- */
272
- headingId: PropTypes.string,
273
-
274
274
  /**
275
275
  * Whether the OptionsTile is in invalid validation state.
276
276
  */
@@ -312,6 +312,16 @@ OptionsTile.propTypes = {
312
312
  */
313
313
  summary: PropTypes.string,
314
314
 
315
+ /**
316
+ * Provide the title for this OptionsTile.
317
+ */
318
+ title: PropTypes.string.isRequired,
319
+
320
+ /**
321
+ * Optionally provide an id which should be used for the title.
322
+ */
323
+ titleId: PropTypes.string,
324
+
315
325
  /**
316
326
  * Whether the OptionsTile is in warning validation state.
317
327
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright IBM Corp. 2021, 2021
2
+ * Copyright IBM Corp. 2021, 2022
3
3
  *
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.