@carbon/ibm-products 2.43.2-canary.18 → 2.43.2-canary.19

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,7 +19,7 @@ import { InlineEditButton } from '../InlineEditButton/InlineEditButton.js';
19
19
 
20
20
  var blockClass = "".concat(pkg.prefix, "--datagrid");
21
21
  var InlineEditCell = function InlineEditCell(_ref) {
22
- var _config$validator, _value$text;
22
+ var _config$validator;
23
23
  var cell = _ref.cell,
24
24
  config = _ref.config,
25
25
  _ref$disabledCell = _ref.disabledCell,
@@ -447,6 +447,24 @@ var InlineEditCell = function InlineEditCell(_ref) {
447
447
  ref: textInputRef
448
448
  }));
449
449
  };
450
+ var getLabel = function getLabel() {
451
+ var _value$text, _checkStaticCell;
452
+ var checkStaticCell = function checkStaticCell(val) {
453
+ if (_typeof(val) === 'object' && val !== null && val !== void 0 && val.isStaticCell) {
454
+ return val === null || val === void 0 ? void 0 : val.value;
455
+ }
456
+ };
457
+ switch (type) {
458
+ case 'selection':
459
+ checkStaticCell(value);
460
+ return (_value$text = value === null || value === void 0 ? void 0 : value.text) !== null && _value$text !== void 0 ? _value$text : value;
461
+ case 'date':
462
+ checkStaticCell(value);
463
+ return buildDate(value);
464
+ default:
465
+ return (_checkStaticCell = checkStaticCell(value)) !== null && _checkStaticCell !== void 0 ? _checkStaticCell : value;
466
+ }
467
+ };
450
468
  return (
451
469
  /*#__PURE__*/
452
470
  // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
@@ -455,7 +473,7 @@ var InlineEditCell = function InlineEditCell(_ref) {
455
473
  "data-cell-id": cellId,
456
474
  "data-column-index": columnIndex,
457
475
  "data-row-index": cell.row.index,
458
- "data-disabled": disabledCell,
476
+ "data-disabled": disabledCell || nonEditCell,
459
477
  "data-inline-type": type,
460
478
  onClick: !nonEditCell ? handleInlineCellClick : addActiveState,
461
479
  onKeyDown: !nonEditCell ? handleKeyDown : null,
@@ -463,7 +481,7 @@ var InlineEditCell = function InlineEditCell(_ref) {
463
481
  }, !nonEditCell && !disabledCell && renderRegularCell(), (!inEditMode || disabledCell) && /*#__PURE__*/React__default.createElement(InlineEditButton, {
464
482
  isActiveCell: cellId === activeCellId,
465
483
  renderIcon: setRenderIcon(),
466
- label: type === 'selection' ? (_value$text = value === null || value === void 0 ? void 0 : value.text) !== null && _value$text !== void 0 ? _value$text : value : type === 'date' ? buildDate(value) : value,
484
+ label: getLabel(),
467
485
  disabledCell: disabledCell,
468
486
  labelIcon: (value === null || value === void 0 ? void 0 : value.icon) || null,
469
487
  placeholder: placeholder,
@@ -5,6 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
+ import { typeof as _typeof } from '../../_virtual/_rollupPluginBabelHelpers.js';
8
9
  import React__default from 'react';
9
10
  import { pkg } from '../../settings.js';
10
11
  import cx from 'classnames';
@@ -13,12 +14,13 @@ import { InlineEditCell } from './Datagrid/addons/InlineEdit/InlineEditCell/Inli
13
14
  var blockClass = "".concat(pkg.prefix, "--datagrid");
14
15
  var useInlineEdit = function useInlineEdit(hooks) {
15
16
  var addInlineEdit = function addInlineEdit(props, _ref) {
16
- var _cell$column, _cell$column2;
17
+ var _cell$column, _cell$column2, _cell$value, _cell$value2, _cell$value3;
17
18
  var cell = _ref.cell,
18
19
  instance = _ref.instance;
19
20
  var columnInlineEditConfig = cell.column.inlineEdit;
20
21
  var inlineEditType = (_cell$column = cell.column) === null || _cell$column === void 0 || (_cell$column = _cell$column.inlineEdit) === null || _cell$column === void 0 ? void 0 : _cell$column.type;
21
22
  var isDisabled = (_cell$column2 = cell.column) === null || _cell$column2 === void 0 ? void 0 : _cell$column2.isDisabled;
23
+ var staticCell = _typeof(cell.value) === 'object' && cell.column.id === ((_cell$value = cell.value) === null || _cell$value === void 0 ? void 0 : _cell$value.columnId) && ((_cell$value2 = cell.value) === null || _cell$value2 === void 0 ? void 0 : _cell$value2.isStaticCell);
22
24
  var renderInlineEditComponent = function renderInlineEditComponent(type) {
23
25
  return /*#__PURE__*/React__default.createElement(InlineEditCell, {
24
26
  config: columnInlineEditConfig,
@@ -38,7 +40,15 @@ var useInlineEdit = function useInlineEdit(hooks) {
38
40
  return [props, {
39
41
  className: cx("".concat(blockClass, "__cell"), "".concat(blockClass, "__cell-inline-edit")),
40
42
  role: 'gridcell',
41
- children: /*#__PURE__*/React__default.createElement(React__default.Fragment, null, inlineEditType === 'text' && renderInlineEditComponent(inlineEditType), inlineEditType === 'number' && renderInlineEditComponent(inlineEditType), inlineEditType === 'selection' && renderInlineEditComponent(inlineEditType), inlineEditType === 'date' && renderInlineEditComponent(inlineEditType), !inlineEditType && /*#__PURE__*/React__default.createElement(InlineEditCell, {
43
+ children: /*#__PURE__*/React__default.createElement(React__default.Fragment, null, !staticCell && inlineEditType === 'text' && renderInlineEditComponent(inlineEditType), !staticCell && inlineEditType === 'number' && renderInlineEditComponent(inlineEditType), !staticCell && inlineEditType === 'selection' && renderInlineEditComponent(inlineEditType), !staticCell && inlineEditType === 'date' && renderInlineEditComponent(inlineEditType), staticCell && /*#__PURE__*/React__default.createElement(InlineEditCell, {
44
+ config: columnInlineEditConfig,
45
+ tabIndex: -1,
46
+ value: (_cell$value3 = cell.value) === null || _cell$value3 === void 0 ? void 0 : _cell$value3.value,
47
+ cell: cell,
48
+ instance: instance,
49
+ nonEditCell: true,
50
+ type: "text"
51
+ }), !inlineEditType && /*#__PURE__*/React__default.createElement(InlineEditCell, {
42
52
  config: columnInlineEditConfig,
43
53
  tabIndex: -1,
44
54
  value: cell.value,
@@ -28,7 +28,7 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
28
28
 
29
29
  var blockClass = "".concat(settings.pkg.prefix, "--datagrid");
30
30
  var InlineEditCell = function InlineEditCell(_ref) {
31
- var _config$validator, _value$text;
31
+ var _config$validator;
32
32
  var cell = _ref.cell,
33
33
  config = _ref.config,
34
34
  _ref$disabledCell = _ref.disabledCell,
@@ -456,6 +456,24 @@ var InlineEditCell = function InlineEditCell(_ref) {
456
456
  ref: textInputRef
457
457
  }));
458
458
  };
459
+ var getLabel = function getLabel() {
460
+ var _value$text, _checkStaticCell;
461
+ var checkStaticCell = function checkStaticCell(val) {
462
+ if (_rollupPluginBabelHelpers["typeof"](val) === 'object' && val !== null && val !== void 0 && val.isStaticCell) {
463
+ return val === null || val === void 0 ? void 0 : val.value;
464
+ }
465
+ };
466
+ switch (type) {
467
+ case 'selection':
468
+ checkStaticCell(value);
469
+ return (_value$text = value === null || value === void 0 ? void 0 : value.text) !== null && _value$text !== void 0 ? _value$text : value;
470
+ case 'date':
471
+ checkStaticCell(value);
472
+ return buildDate(value);
473
+ default:
474
+ return (_checkStaticCell = checkStaticCell(value)) !== null && _checkStaticCell !== void 0 ? _checkStaticCell : value;
475
+ }
476
+ };
459
477
  return (
460
478
  /*#__PURE__*/
461
479
  // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
@@ -464,7 +482,7 @@ var InlineEditCell = function InlineEditCell(_ref) {
464
482
  "data-cell-id": cellId,
465
483
  "data-column-index": columnIndex,
466
484
  "data-row-index": cell.row.index,
467
- "data-disabled": disabledCell,
485
+ "data-disabled": disabledCell || nonEditCell,
468
486
  "data-inline-type": type,
469
487
  onClick: !nonEditCell ? handleInlineCellClick : addActiveState,
470
488
  onKeyDown: !nonEditCell ? handleKeyDown : null,
@@ -472,7 +490,7 @@ var InlineEditCell = function InlineEditCell(_ref) {
472
490
  }, !nonEditCell && !disabledCell && renderRegularCell(), (!inEditMode || disabledCell) && /*#__PURE__*/React__default["default"].createElement(InlineEditButton.InlineEditButton, {
473
491
  isActiveCell: cellId === activeCellId,
474
492
  renderIcon: setRenderIcon(),
475
- label: type === 'selection' ? (_value$text = value === null || value === void 0 ? void 0 : value.text) !== null && _value$text !== void 0 ? _value$text : value : type === 'date' ? buildDate(value) : value,
493
+ label: getLabel(),
476
494
  disabledCell: disabledCell,
477
495
  labelIcon: (value === null || value === void 0 ? void 0 : value.icon) || null,
478
496
  placeholder: placeholder,
@@ -9,6 +9,7 @@
9
9
 
10
10
  Object.defineProperty(exports, '__esModule', { value: true });
11
11
 
12
+ var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
12
13
  var React = require('react');
13
14
  var settings = require('../../settings.js');
14
15
  var cx = require('classnames');
@@ -22,12 +23,13 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
22
23
  var blockClass = "".concat(settings.pkg.prefix, "--datagrid");
23
24
  var useInlineEdit = function useInlineEdit(hooks) {
24
25
  var addInlineEdit = function addInlineEdit(props, _ref) {
25
- var _cell$column, _cell$column2;
26
+ var _cell$column, _cell$column2, _cell$value, _cell$value2, _cell$value3;
26
27
  var cell = _ref.cell,
27
28
  instance = _ref.instance;
28
29
  var columnInlineEditConfig = cell.column.inlineEdit;
29
30
  var inlineEditType = (_cell$column = cell.column) === null || _cell$column === void 0 || (_cell$column = _cell$column.inlineEdit) === null || _cell$column === void 0 ? void 0 : _cell$column.type;
30
31
  var isDisabled = (_cell$column2 = cell.column) === null || _cell$column2 === void 0 ? void 0 : _cell$column2.isDisabled;
32
+ var staticCell = _rollupPluginBabelHelpers["typeof"](cell.value) === 'object' && cell.column.id === ((_cell$value = cell.value) === null || _cell$value === void 0 ? void 0 : _cell$value.columnId) && ((_cell$value2 = cell.value) === null || _cell$value2 === void 0 ? void 0 : _cell$value2.isStaticCell);
31
33
  var renderInlineEditComponent = function renderInlineEditComponent(type) {
32
34
  return /*#__PURE__*/React__default["default"].createElement(InlineEditCell.InlineEditCell, {
33
35
  config: columnInlineEditConfig,
@@ -47,7 +49,15 @@ var useInlineEdit = function useInlineEdit(hooks) {
47
49
  return [props, {
48
50
  className: cx__default["default"]("".concat(blockClass, "__cell"), "".concat(blockClass, "__cell-inline-edit")),
49
51
  role: 'gridcell',
50
- children: /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, inlineEditType === 'text' && renderInlineEditComponent(inlineEditType), inlineEditType === 'number' && renderInlineEditComponent(inlineEditType), inlineEditType === 'selection' && renderInlineEditComponent(inlineEditType), inlineEditType === 'date' && renderInlineEditComponent(inlineEditType), !inlineEditType && /*#__PURE__*/React__default["default"].createElement(InlineEditCell.InlineEditCell, {
52
+ children: /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, !staticCell && inlineEditType === 'text' && renderInlineEditComponent(inlineEditType), !staticCell && inlineEditType === 'number' && renderInlineEditComponent(inlineEditType), !staticCell && inlineEditType === 'selection' && renderInlineEditComponent(inlineEditType), !staticCell && inlineEditType === 'date' && renderInlineEditComponent(inlineEditType), staticCell && /*#__PURE__*/React__default["default"].createElement(InlineEditCell.InlineEditCell, {
53
+ config: columnInlineEditConfig,
54
+ tabIndex: -1,
55
+ value: (_cell$value3 = cell.value) === null || _cell$value3 === void 0 ? void 0 : _cell$value3.value,
56
+ cell: cell,
57
+ instance: instance,
58
+ nonEditCell: true,
59
+ type: "text"
60
+ }), !inlineEditType && /*#__PURE__*/React__default["default"].createElement(InlineEditCell.InlineEditCell, {
51
61
  config: columnInlineEditConfig,
52
62
  tabIndex: -1,
53
63
  value: cell.value,
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": "2.43.2-canary.18+ea48b9e2e",
4
+ "version": "2.43.2-canary.19+648571ed7",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -119,5 +119,5 @@
119
119
  "react": "^16.8.6 || ^17.0.1 || ^18.2.0",
120
120
  "react-dom": "^16.8.6 || ^17.0.1 || ^18.2.0"
121
121
  },
122
- "gitHead": "ea48b9e2ef44bcf0927eb88cbf2673dbf98400de"
122
+ "gitHead": "648571ed78f6418eae53d3ff10ea7fd89fb8ea45"
123
123
  }