@carbon/ibm-products 1.8.0 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. package/css/index-full-carbon.css +82 -9
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +3 -3
  4. package/css/index-full-carbon.min.css.map +1 -1
  5. package/css/index-without-carbon-released-only.css +1 -2
  6. package/css/index-without-carbon-released-only.css.map +1 -1
  7. package/css/index-without-carbon-released-only.min.css +1 -1
  8. package/css/index-without-carbon-released-only.min.css.map +1 -1
  9. package/css/index-without-carbon.css +82 -9
  10. package/css/index-without-carbon.css.map +1 -1
  11. package/css/index-without-carbon.min.css +3 -3
  12. package/css/index-without-carbon.min.css.map +1 -1
  13. package/css/index.css +82 -9
  14. package/css/index.css.map +1 -1
  15. package/css/index.min.css +3 -3
  16. package/css/index.min.css.map +1 -1
  17. package/es/components/AddSelect/AddSelect.js +104 -16
  18. package/es/components/AddSelect/AddSelectBreadcrumbs.js +4 -4
  19. package/es/components/AddSelect/AddSelectColumn.js +21 -0
  20. package/es/components/AddSelect/AddSelectList.js +67 -8
  21. package/es/components/AddSelect/AddSelectSidebar.js +7 -1
  22. package/es/components/DataSpreadsheet/DataSpreadsheet.js +42 -2
  23. package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +194 -10
  24. package/es/components/DataSpreadsheet/createActiveCellFn.js +1 -1
  25. package/es/components/DataSpreadsheet/createCellSelectionArea.js +45 -0
  26. package/es/components/InlineEdit/InlineEdit.js +23 -13
  27. package/es/global/js/utils/DisplayBox.js +31 -0
  28. package/es/global/js/utils/deepCloneObject.js +26 -0
  29. package/lib/components/AddSelect/AddSelect.js +102 -15
  30. package/lib/components/AddSelect/AddSelectBreadcrumbs.js +2 -3
  31. package/lib/components/AddSelect/AddSelectColumn.js +37 -0
  32. package/lib/components/AddSelect/AddSelectList.js +65 -8
  33. package/lib/components/AddSelect/AddSelectSidebar.js +7 -1
  34. package/lib/components/DataSpreadsheet/DataSpreadsheet.js +42 -2
  35. package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +198 -10
  36. package/lib/components/DataSpreadsheet/createActiveCellFn.js +1 -1
  37. package/lib/components/DataSpreadsheet/createCellSelectionArea.js +56 -0
  38. package/lib/components/InlineEdit/InlineEdit.js +23 -13
  39. package/lib/global/js/utils/DisplayBox.js +46 -0
  40. package/lib/global/js/utils/deepCloneObject.js +37 -0
  41. package/package.json +8 -8
  42. package/scss/components/ActionBar/_storybook-styles.scss +8 -0
  43. package/scss/components/ActionSet/_storybook-styles.scss +1 -3
  44. package/scss/components/AddSelect/_add-select.scss +58 -2
  45. package/scss/components/BreadcrumbWithOverflow/_storybook-styles.scss +8 -0
  46. package/scss/components/ButtonSetWithOverflow/_storybook-styles.scss +8 -0
  47. package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +18 -0
  48. package/scss/components/InlineEdit/_inline-edit.scss +11 -4
  49. package/scss/components/InlineEdit/_storybook-styles.scss +1 -0
  50. package/scss/components/TagSet/_storybook-styles.scss +8 -0
  51. package/scss/components/Tearsheet/_tearsheet.scss +1 -2
  52. package/scss/global/styles/_display-box.scss +62 -0
@@ -11,6 +11,8 @@ exports.DataSpreadsheetBody = void 0;
11
11
 
12
12
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
13
 
14
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
15
+
14
16
  var _react = _interopRequireWildcard(require("react"));
15
17
 
16
18
  var _propTypes = _interopRequireDefault(require("prop-types"));
@@ -21,6 +23,12 @@ var _classnames = _interopRequireDefault(require("classnames"));
21
23
 
22
24
  var _settings = require("../../settings");
23
25
 
26
+ var _deepCloneObject = require("../../global/js/utils/deepCloneObject");
27
+
28
+ var _uuidv = _interopRequireDefault(require("../../global/js/utils/uuidv4"));
29
+
30
+ var _createCellSelectionArea = require("./createCellSelectionArea");
31
+
24
32
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
25
33
 
26
34
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -40,10 +48,95 @@ var DataSpreadsheetBody = function DataSpreadsheetBody(_ref) {
40
48
  prepareRow = _ref.prepareRow,
41
49
  rows = _ref.rows,
42
50
  setActiveCellCoordinates = _ref.setActiveCellCoordinates,
51
+ selectionAreas = _ref.selectionAreas,
52
+ setContainerHasFocus = _ref.setContainerHasFocus,
53
+ setSelectionAreas = _ref.setSelectionAreas,
43
54
  scrollBarSize = _ref.scrollBarSize,
44
- totalColumnsWidth = _ref.totalColumnsWidth;
45
- // Make sure that if the cellSize prop changes, the active
55
+ totalColumnsWidth = _ref.totalColumnsWidth,
56
+ clickAndHoldActive = _ref.clickAndHoldActive,
57
+ setClickAndHoldActive = _ref.setClickAndHoldActive,
58
+ currentMatcher = _ref.currentMatcher,
59
+ setCurrentMatcher = _ref.setCurrentMatcher;
60
+ // Create cell selection areas based on selectionAreas array
61
+ (0, _react.useEffect)(function () {
62
+ if (selectionAreas && selectionAreas.length) {
63
+ selectionAreas.map(function (area) {
64
+ if (!area.areaCreated && area.point1 && area.point2 && area.matcher) {
65
+ // Do not create a cell selection area if point1 and point2 have the same values
66
+ // Cell selections must have two distinctly different points for an area to be created
67
+ if (area.point1.row === area.point2.row && area.point1.column === area.point2.column) {
68
+ var selectionAreasClone = (0, _deepCloneObject.deepCloneObject)(selectionAreas);
69
+ var indexOfCurrentArea = selectionAreasClone.findIndex(function (item) {
70
+ return item.matcher === area.matcher;
71
+ });
72
+ selectionAreasClone[indexOfCurrentArea].areaCreated = false;
73
+ selectionAreasClone[indexOfCurrentArea].point2 = null;
74
+ return setSelectionAreas(selectionAreasClone);
75
+ }
76
+
77
+ (0, _createCellSelectionArea.createCellSelectionArea)({
78
+ area: area,
79
+ blockClass: blockClass,
80
+ selectionAreas: selectionAreas,
81
+ setSelectionAreas: setSelectionAreas
82
+ });
83
+ }
84
+
85
+ return;
86
+ });
87
+ }
88
+ }, [selectionAreas, setSelectionAreas]); // Mouse up
89
+
90
+ (0, _react.useEffect)(function () {
91
+ var handleMouseUp = function handleMouseUp(event) {
92
+ setClickAndHoldActive(false);
93
+ var cellButton = event.target.closest(".".concat(blockClass, "__body--td"));
94
+
95
+ if (cellButton) {
96
+ var endCellCoordinates = {
97
+ row: Number(cellButton.getAttribute('data-row-index')),
98
+ column: Number(cellButton.getAttribute('data-column-index'))
99
+ };
100
+ setCurrentMatcher(null);
101
+ setSelectionAreas(function (prev) {
102
+ var selectionAreaClone = (0, _deepCloneObject.deepCloneObject)(prev);
103
+ var indexOfItemToUpdate = selectionAreaClone.findIndex(function (item) {
104
+ return item.matcher === currentMatcher;
105
+ }); // No items in the array have an object that matches the value of currentMatcher
106
+
107
+ if (indexOfItemToUpdate === -1) {
108
+ return prev;
109
+ }
110
+
111
+ selectionAreaClone[indexOfItemToUpdate].point2 = endCellCoordinates;
112
+ selectionAreaClone[indexOfItemToUpdate].areaCreated = false;
113
+ return selectionAreaClone;
114
+ });
115
+ } else {
116
+ var selectionAreaClone = (0, _deepCloneObject.deepCloneObject)(selectionAreas);
117
+ var indexOfItemToUpdate = selectionAreaClone.findIndex(function (item) {
118
+ return item.matcher === currentMatcher;
119
+ });
120
+
121
+ if (indexOfItemToUpdate === -1) {
122
+ return;
123
+ }
124
+
125
+ var newArray = selectionAreaClone.filter(function (item) {
126
+ return item.matcher !== currentMatcher;
127
+ });
128
+ setCurrentMatcher(null);
129
+ setSelectionAreas(newArray);
130
+ }
131
+ };
132
+
133
+ document.addEventListener('mouseup', handleMouseUp);
134
+ return function () {
135
+ document.removeEventListener('mouseup', handleMouseUp);
136
+ };
137
+ }, [selectionAreas, currentMatcher, setSelectionAreas, setClickAndHoldActive, setCurrentMatcher]); // Make sure that if the cellSize prop changes, the active
46
138
  // cell also gets updated with the new size
139
+
47
140
  (0, _react.useEffect)(function () {
48
141
  var listContainer = spreadsheetBodyRef === null || spreadsheetBodyRef === void 0 ? void 0 : spreadsheetBodyRef.current;
49
142
  var activeCellButton = listContainer.querySelector(".".concat(blockClass, "__active-cell--highlight"));
@@ -54,12 +147,68 @@ var DataSpreadsheetBody = function DataSpreadsheetBody(_ref) {
54
147
  }, [defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeight]); // onClick fn for each cell in the data spreadsheet body,
55
148
  // adds the active cell highlight
56
149
 
57
- var handleBodyCellClick = (0, _react.useCallback)(function (cell, columnIndex) {
58
- setActiveCellCoordinates({
150
+ var handleBodyCellClick = (0, _react.useCallback)(function (event, cell, columnIndex) {
151
+ var isHoldingCommandKey = event.metaKey || event.ctrlKey;
152
+ setContainerHasFocus(true);
153
+ var activeCoordinates = {
59
154
  row: cell.row.index,
60
155
  column: columnIndex
61
- });
62
- }, [setActiveCellCoordinates]); // Renders each cell in the spreadsheet body
156
+ };
157
+ var tempMatcher = (0, _uuidv.default)();
158
+ setActiveCellCoordinates(activeCoordinates); // prevent multiple selections unless cmd key is held
159
+ // meaning that selectionAreas should only have one item by default
160
+
161
+ if (isHoldingCommandKey) {
162
+ setSelectionAreas(function (prev) {
163
+ return [].concat((0, _toConsumableArray2.default)(prev), [{
164
+ point1: activeCoordinates,
165
+ matcher: tempMatcher
166
+ }]);
167
+ });
168
+ } else {
169
+ // remove all previous cell selections
170
+ var cellSelections = spreadsheetBodyRef.current.querySelectorAll(".".concat(blockClass, "__selection-area--element"));
171
+ Array.from(cellSelections).forEach(function (element) {
172
+ return element.remove();
173
+ });
174
+ setSelectionAreas([{
175
+ point1: activeCoordinates,
176
+ matcher: tempMatcher
177
+ }]);
178
+ }
179
+
180
+ setCurrentMatcher(tempMatcher);
181
+ setClickAndHoldActive(true);
182
+ }, [setActiveCellCoordinates, setSelectionAreas, setContainerHasFocus, setClickAndHoldActive, setCurrentMatcher]);
183
+ var handleBodyCellHover = (0, _react.useCallback)(function (event, cell, columnIndex) {
184
+ if (clickAndHoldActive) {
185
+ var cellCoordinates = {
186
+ row: cell.row.index,
187
+ column: columnIndex
188
+ };
189
+ setSelectionAreas(function (prev) {
190
+ var _selectionAreaClone$i, _selectionAreaClone$i2;
191
+
192
+ var selectionAreaClone = (0, _deepCloneObject.deepCloneObject)(prev);
193
+ var indexOfItemToUpdate = selectionAreaClone.findIndex(function (item) {
194
+ return item.matcher === currentMatcher;
195
+ }); // No items in the array match up with the currentMatcher value
196
+
197
+ if (indexOfItemToUpdate === -1) {
198
+ return prev;
199
+ } // Do not update state if you're still hovering on the same cell
200
+
201
+
202
+ if (((_selectionAreaClone$i = selectionAreaClone[indexOfItemToUpdate].point2) === null || _selectionAreaClone$i === void 0 ? void 0 : _selectionAreaClone$i.row) === cellCoordinates.row && ((_selectionAreaClone$i2 = selectionAreaClone[indexOfItemToUpdate].point2) === null || _selectionAreaClone$i2 === void 0 ? void 0 : _selectionAreaClone$i2.column) === cellCoordinates.column) {
203
+ return prev;
204
+ }
205
+
206
+ selectionAreaClone[indexOfItemToUpdate].point2 = cellCoordinates;
207
+ selectionAreaClone[indexOfItemToUpdate].areaCreated = false;
208
+ return selectionAreaClone;
209
+ });
210
+ }
211
+ }, [clickAndHoldActive, currentMatcher, setSelectionAreas]); // Renders each cell in the spreadsheet body
63
212
 
64
213
  var RenderRow = (0, _react.useCallback)(function (_ref2) {
65
214
  var index = _ref2.index,
@@ -86,15 +235,19 @@ var DataSpreadsheetBody = function DataSpreadsheetBody(_ref) {
86
235
  "data-row-index": cell.row.index,
87
236
  "data-column-index": index
88
237
  }, cell.getCellProps(), {
89
- className: (0, _classnames.default)("".concat(blockClass, "__td"), "".concat(blockClass, "--interactive-cell-element")),
238
+ className: (0, _classnames.default)("".concat(blockClass, "__td"), "".concat(blockClass, "__body--td"), "".concat(blockClass, "--interactive-cell-element")),
90
239
  key: "cell_".concat(index),
91
- onClick: function onClick() {
92
- return handleBodyCellClick(cell, index);
240
+ onMouseDown: function onMouseDown(event) {
241
+ return handleBodyCellClick(event, cell, index);
242
+ },
243
+ onMouseOver: function onMouseOver(event) {
244
+ return handleBodyCellHover(event, cell, index);
93
245
  },
246
+ onFocus: function onFocus() {},
94
247
  type: "button"
95
248
  }), cell.render('Cell'));
96
249
  }));
97
- }, [prepareRow, rows, defaultColumn.rowHeaderWidth, handleBodyCellClick]);
250
+ }, [prepareRow, rows, defaultColumn.rowHeaderWidth, handleBodyCellClick, handleBodyCellHover]);
98
251
  var spreadsheetBodyRef = (0, _react.useRef)();
99
252
  return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
100
253
  ref: spreadsheetBodyRef,
@@ -110,6 +263,16 @@ var DataSpreadsheetBody = function DataSpreadsheetBody(_ref) {
110
263
 
111
264
  exports.DataSpreadsheetBody = DataSpreadsheetBody;
112
265
  DataSpreadsheetBody.propTypes = {
266
+ /**
267
+ * Is the user clicking and holding in the data spreadsheet body
268
+ */
269
+ clickAndHoldActive: _propTypes.default.bool,
270
+
271
+ /**
272
+ * This represents the id of the current cell selection area
273
+ */
274
+ currentMatcher: _propTypes.default.string,
275
+
113
276
  /**
114
277
  * Default spreadsheet sizing values
115
278
  */
@@ -149,11 +312,36 @@ DataSpreadsheetBody.propTypes = {
149
312
  */
150
313
  scrollBarSize: _propTypes.default.number,
151
314
 
315
+ /**
316
+ * Array of selection areas
317
+ */
318
+ selectionAreas: _propTypes.default.array,
319
+
152
320
  /**
153
321
  * Setter fn for activeCellCoordinates state value
154
322
  */
155
323
  setActiveCellCoordinates: _propTypes.default.func,
156
324
 
325
+ /**
326
+ * Setter fn for clickAndHold state value
327
+ */
328
+ setClickAndHoldActive: _propTypes.default.func,
329
+
330
+ /**
331
+ * Setter fn for containerHasFocus state value
332
+ */
333
+ setContainerHasFocus: _propTypes.default.func,
334
+
335
+ /**
336
+ * Setter fn for currentMatcher state value
337
+ */
338
+ setCurrentMatcher: _propTypes.default.func,
339
+
340
+ /**
341
+ * Setter fn for selectionAreas state value
342
+ */
343
+ setSelectionAreas: _propTypes.default.func,
344
+
157
345
  /**
158
346
  * The total columns width
159
347
  */
@@ -49,7 +49,7 @@ var createActiveCellFn = function createActiveCellFn(_ref) {
49
49
  activeCellButton.focus();
50
50
 
51
51
  if (typeof (coords === null || coords === void 0 ? void 0 : coords.column) === 'number' && typeof (coords === null || coords === void 0 ? void 0 : coords.row) === 'number') {
52
- onActiveCellChange(activeCellValue);
52
+ onActiveCellChange === null || onActiveCellChange === void 0 ? void 0 : onActiveCellChange(activeCellValue);
53
53
  }
54
54
  };
55
55
 
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createCellSelectionArea = void 0;
7
+
8
+ var _layout = require("@carbon/layout");
9
+
10
+ var _deepCloneObject = require("../../global/js/utils/deepCloneObject");
11
+
12
+ /**
13
+ * Copyright IBM Corp. 2022, 2022
14
+ *
15
+ * This source code is licensed under the Apache-2.0 license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */
18
+ var createCellSelectionArea = function createCellSelectionArea(_ref) {
19
+ var area = _ref.area,
20
+ blockClass = _ref.blockClass,
21
+ selectionAreas = _ref.selectionAreas,
22
+ setSelectionAreas = _ref.setSelectionAreas;
23
+ var greatestRow = Math.max(area.point1.row, area.point2.row);
24
+ var greatestColumn = Math.max(area.point1.column, area.point2.column);
25
+ var lowestRowIndex = Math.min(area.point1.row, area.point2.row);
26
+ var lowestColumnIndex = Math.min(area.point1.column, area.point2.column);
27
+ var point1Element = document.querySelector("[data-row-index=\"".concat(area.point1.row, "\"][data-column-index=\"").concat(area.point1.column, "\"]"));
28
+ var selectionAreaCellWidth = point1Element.offsetWidth;
29
+ var selectionAreaCellHeight = point1Element.offsetHeight;
30
+ var selectionAreaTotalWidth = selectionAreaCellWidth * (greatestColumn - lowestColumnIndex + 1);
31
+ var selectionAreaTotalHeight = selectionAreaCellHeight * (greatestRow - lowestRowIndex + 1);
32
+ var bodyContainer = document.querySelector(".".concat(blockClass, "__list--container")).firstElementChild;
33
+ var placementElement = bodyContainer.querySelector("[data-row-index=\"".concat(lowestRowIndex, "\"][data-column-index=\"").concat(lowestColumnIndex, "\"]"));
34
+ var relativePosition = {
35
+ top: placementElement.getBoundingClientRect().top - bodyContainer.getBoundingClientRect().top,
36
+ left: placementElement.getBoundingClientRect().left - bodyContainer.getBoundingClientRect().left
37
+ };
38
+ var selectionAreaElement = document.querySelector("[data-matcher-id=\"".concat(area.matcher, "\"]")) || document.createElement('div');
39
+ selectionAreaElement.classList.add("".concat(blockClass, "__selection-area--element"));
40
+ selectionAreaElement.setAttribute('data-matcher-id', area.matcher);
41
+ selectionAreaElement.style.width = (0, _layout.px)(selectionAreaTotalWidth);
42
+ selectionAreaElement.style.height = (0, _layout.px)(selectionAreaTotalHeight);
43
+ selectionAreaElement.style.left = (0, _layout.px)(relativePosition.left);
44
+ selectionAreaElement.style.top = (0, _layout.px)(relativePosition.top);
45
+ bodyContainer.appendChild(selectionAreaElement);
46
+ var selectionAreasClone = (0, _deepCloneObject.deepCloneObject)(selectionAreas);
47
+ var indexOfCurrentArea = selectionAreasClone.findIndex(function (item) {
48
+ return item.matcher === area.matcher;
49
+ }); // We need to add another property to the selectionAreas object array to
50
+ // let us know if an area has been created for each item already, ie createdArea: true
51
+
52
+ selectionAreasClone[indexOfCurrentArea].areaCreated = true;
53
+ setSelectionAreas(selectionAreasClone);
54
+ };
55
+
56
+ exports.createCellSelectionArea = createCellSelectionArea;
@@ -31,7 +31,7 @@ var _carbonComponentsReact = require("carbon-components-react");
31
31
 
32
32
  var _iconsReact = require("@carbon/icons-react");
33
33
 
34
- var _excluded = ["cancelDescription", "className", "disabled", "editDescription", "editVisibleOnHoverOnly", "id", "invalid", "invalidText", "labelText", "light", "onCancel", "onSave", "onChange", "placeholder", "saveDescription", "size", "value", "warn", "warnText"];
34
+ var _excluded = ["cancelDescription", "className", "disabled", "editAlwaysVisible", "editDescription", "id", "invalid", "invalidText", "labelText", "light", "onCancel", "onSave", "onChange", "placeholder", "saveDescription", "size", "value", "warn", "warnText"];
35
35
 
36
36
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
37
37
 
@@ -56,8 +56,8 @@ var InlineEdit = /*#__PURE__*/_react.default.forwardRef(function (_ref, refIn) {
56
56
  var cancelDescription = _ref.cancelDescription,
57
57
  className = _ref.className,
58
58
  disabled = _ref.disabled,
59
+ editAlwaysVisible = _ref.editAlwaysVisible,
59
60
  editDescription = _ref.editDescription,
60
- editVisibleOnHoverOnly = _ref.editVisibleOnHoverOnly,
61
61
  id = _ref.id,
62
62
  invalid = _ref.invalid,
63
63
  invalidText = _ref.invalidText,
@@ -103,6 +103,7 @@ var InlineEdit = /*#__PURE__*/_react.default.forwardRef(function (_ref, refIn) {
103
103
  };
104
104
 
105
105
  var handleEdit = function handleEdit(ev) {
106
+ /* istanbul ignore else */
106
107
  if (!disabled) {
107
108
  var rightOfInput = ev.currentTarget.classList.contains("".concat(blockClass, "__edit")) || ev.target.classList.contains("".concat(blockClass, "__after-input-elements"));
108
109
  var leftOfInput = ev.currentTarget = ev.target.classList.contains("".concat(blockClass)); // clicking on the content editable element should not set either of these to true
@@ -149,9 +150,12 @@ var InlineEdit = /*#__PURE__*/_react.default.forwardRef(function (_ref, refIn) {
149
150
  if (onChange) {
150
151
  onChange(refInput.current.innerText);
151
152
  }
152
- };
153
+ }; // pasting into contentEditable not supported by userEvent
154
+
153
155
 
154
- var handlePaste = function handlePaste(ev) {
156
+ var handlePaste =
157
+ /* istanbul ignore next */
158
+ function handlePaste(ev) {
155
159
  ev.preventDefault(); // Get clipboard as plain text
156
160
 
157
161
  var text = (ev.clipboardData || window.clipboardData).getData('text/plain'); // remove \n
@@ -196,9 +200,16 @@ var InlineEdit = /*#__PURE__*/_react.default.forwardRef(function (_ref, refIn) {
196
200
  };
197
201
 
198
202
  var handleKeyDown = function handleKeyDown(ev) {
199
- if (ev.key === 'Enter') {
200
- ev.preventDefault();
201
- refInput.current.blur(); // will cause save
203
+ switch (ev.key) {
204
+ case 'Enter':
205
+ ev.preventDefault();
206
+ refInput.current.blur(); // will cause save
207
+
208
+ break;
209
+
210
+ case 'Escape':
211
+ handleCancel();
212
+ break;
202
213
  }
203
214
  };
204
215
  /*
@@ -280,7 +291,7 @@ var InlineEdit = /*#__PURE__*/_react.default.forwardRef(function (_ref, refIn) {
280
291
  disabled: value === internalValue
281
292
  })) : /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, {
282
293
  "aria-hidden": "true",
283
- className: (0, _classnames.default)("".concat(blockClass, "__edit"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__edit--hover-visible"), editVisibleOnHoverOnly)),
294
+ className: (0, _classnames.default)("".concat(blockClass, "__edit"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__edit--always-visible"), editAlwaysVisible)),
284
295
  kind: "ghost",
285
296
  hasIconOnly: true,
286
297
  iconDescription: editDescription,
@@ -322,15 +333,14 @@ InlineEdit.propTypes = {
322
333
  disabled: _propTypes.default.bool,
323
334
 
324
335
  /**
325
- * Label for the edit button
336
+ * By default the edit icon is shown on hover only.
326
337
  */
327
- editDescription: _propTypes.default.string.isRequired,
338
+ editAlwaysVisible: _propTypes.default.bool,
328
339
 
329
340
  /**
330
- * In some scenarios the edit icon only needs to be shown on hover. These cases are where continual visibility of
331
- * the edit icon is redundant. E.g. a spreadsheet a property panel.
341
+ * Label for the edit button
332
342
  */
333
- editVisibleOnHoverOnly: _propTypes.default.bool,
343
+ editDescription: _propTypes.default.string.isRequired,
334
344
 
335
345
  /**
336
346
  * ID for inline edit
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.DisplayBox = void 0;
9
+
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+
12
+ var _react = _interopRequireDefault(require("react"));
13
+
14
+ var _classnames = _interopRequireDefault(require("classnames"));
15
+
16
+ /**
17
+ * Copyright IBM Corp. 2022, 2022
18
+ *
19
+ * This source code is licensed under the Apache-2.0 license found in the
20
+ * LICENSE file in the root directory of this source tree.
21
+ */
22
+ var blockClass = 'ccs-sb--display-box';
23
+
24
+ var DisplayBox = function DisplayBox(_ref) {
25
+ var children = _ref.children,
26
+ className = _ref.className,
27
+ msg = _ref.msg;
28
+ return /*#__PURE__*/_react.default.createElement("div", {
29
+ className: (0, _classnames.default)(blockClass, className)
30
+ }, /*#__PURE__*/_react.default.createElement("div", {
31
+ className: "".concat(blockClass, "__indicator")
32
+ }, /*#__PURE__*/_react.default.createElement("div", {
33
+ className: "".concat(blockClass, "__message")
34
+ }, msg || /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, "width available to component", /*#__PURE__*/_react.default.createElement("br", null), "(use containerWidth control to adjust)")), /*#__PURE__*/_react.default.createElement("div", {
35
+ className: "".concat(blockClass, "__indicator--left")
36
+ }), /*#__PURE__*/_react.default.createElement("div", {
37
+ className: "".concat(blockClass, "__indicator--right")
38
+ })), children);
39
+ };
40
+
41
+ exports.DisplayBox = DisplayBox;
42
+ DisplayBox.propTypes = {
43
+ children: _propTypes.default.node,
44
+ className: _propTypes.default.string,
45
+ msg: _propTypes.default.node
46
+ };
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.deepCloneObject = void 0;
9
+
10
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
11
+
12
+ /**
13
+ * Copyright IBM Corp. 2022, 2022
14
+ *
15
+ * This source code is licensed under the Apache-2.0 license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */
18
+ // Utility to return a deep clone of a nested object or array.
19
+ var deepCloneObject = function deepCloneObject(objectToClone) {
20
+ // Return the value if objectToClone is not an object
21
+ if ((0, _typeof2.default)(objectToClone) !== 'object' || objectToClone === null) {
22
+ return objectToClone;
23
+ } // Create a new array/object to hold the values
24
+
25
+
26
+ var clonedObject = Array.isArray(objectToClone) ? [] : {};
27
+
28
+ for (var key in objectToClone) {
29
+ var value = objectToClone[key]; // Recursively check for nested objects/arrays
30
+
31
+ clonedObject[key] = deepCloneObject(value);
32
+ }
33
+
34
+ return clonedObject;
35
+ };
36
+
37
+ exports.deepCloneObject = deepCloneObject;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@carbon/ibm-products",
3
3
  "description": "Carbon for IBM Products",
4
- "version": "1.8.0",
4
+ "version": "1.9.0",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -50,21 +50,21 @@
50
50
  "upgrade-dependencies": "npm-check-updates -u --dep dev,peer,prod --color --reject '/(carbon|^react$|^react-dom$|^chalk$)/'"
51
51
  },
52
52
  "devDependencies": {
53
- "@babel/cli": "^7.17.3",
53
+ "@babel/cli": "^7.17.6",
54
54
  "@babel/core": "^7.17.5",
55
- "babel-preset-ibm-cloud-cognitive": "^0.14.8",
55
+ "babel-preset-ibm-cloud-cognitive": "^0.14.9",
56
56
  "chalk": "^4.1.2",
57
57
  "change-case": "^4.1.2",
58
58
  "copyfiles": "^2.4.1",
59
59
  "cross-env": "^7.0.3",
60
- "fs-extra": "^10.0.0",
60
+ "fs-extra": "^10.0.1",
61
61
  "glob": "^7.2.0",
62
62
  "jest": "^27.5.1",
63
- "jest-config-ibm-cloud-cognitive": "^0.23.9",
64
- "npm-check-updates": "^12.3.1",
63
+ "jest-config-ibm-cloud-cognitive": "^0.23.10",
64
+ "npm-check-updates": "^12.4.0",
65
65
  "npm-run-all": "^4.1.5",
66
66
  "rimraf": "^3.0.2",
67
- "sass": "^1.49.8",
67
+ "sass": "^1.49.9",
68
68
  "yargs": "^17.3.1"
69
69
  },
70
70
  "dependencies": {
@@ -88,5 +88,5 @@
88
88
  "react": "^16.8.6 || ^17.0.1",
89
89
  "react-dom": "^16.8.6 || ^17.0.1"
90
90
  },
91
- "gitHead": "b2c8e5a32233fac65bb3eeb18df919efc0dcd3af"
91
+ "gitHead": "a21d7abe81dcae33cd53a13cc9d34e60edade3d4"
92
92
  }
@@ -0,0 +1,8 @@
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
+
8
+ @import '../../global/styles/display-box';
@@ -6,15 +6,13 @@
6
6
  //
7
7
 
8
8
  @import '../../global/styles/project-settings';
9
+ @import '../../global/styles/display-box';
9
10
 
10
11
  $block-class: #{$pkg-prefix}--action-set;
11
12
 
12
13
  .#{$block-class}__story-container {
13
14
  width: 96vw;
14
15
  min-height: 3rem;
15
- border: 1px solid $decorative-01;
16
- margin: $spacing-04 auto 0;
17
- box-shadow: 0 0 10px 5px $ui-04;
18
16
  }
19
17
 
20
18
  .#{$block-class}__story-container--xlg {