@carbon/ibm-products 1.32.0 → 1.32.1
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +14 -0
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +1 -1
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon.css +10 -0
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +1 -1
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +10 -0
- package/css/index.css.map +1 -1
- package/css/index.min.css +1 -1
- package/css/index.min.css.map +1 -1
- package/es/components/DataSpreadsheet/hooks/useMultipleKeyTracking.js +2 -2
- package/es/components/Datagrid/Datagrid/DatagridContent.js +29 -25
- package/es/components/Datagrid/Datagrid/DatagridRow.js +10 -2
- package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +1 -1
- package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +1 -1
- package/es/components/Datagrid/utils/makeData.js +25 -5
- package/es/components/InlineEdit/InlineEdit.js +7 -7
- package/es/components/OptionsTile/OptionsTile.js +4 -2
- package/lib/components/DataSpreadsheet/hooks/useMultipleKeyTracking.js +2 -2
- package/lib/components/Datagrid/Datagrid/DatagridContent.js +29 -25
- package/lib/components/Datagrid/Datagrid/DatagridRow.js +19 -2
- package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +1 -1
- package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +1 -1
- package/lib/components/Datagrid/utils/makeData.js +26 -5
- package/lib/components/InlineEdit/InlineEdit.js +7 -7
- package/lib/components/OptionsTile/OptionsTile.js +4 -2
- package/package.json +12 -12
- package/scss/components/Datagrid/styles/_useInlineEdit.scss +6 -0
- package/scss/components/OptionsTile/_options-tile.scss +4 -0
@@ -93,7 +93,7 @@ var getDropdownPosition = function getDropdownPosition(buttonEle) {
|
|
93
93
|
|
94
94
|
if (parent instanceof HTMLElement) {
|
95
95
|
var top = buttonEle.offsetTop + buttonEle.offsetHeight;
|
96
|
-
var right = parent.offsetWidth - parent.offsetLeft -
|
96
|
+
var right = parent.offsetWidth - parent.offsetLeft - buttonEle.offsetLeft;
|
97
97
|
return {
|
98
98
|
top: top,
|
99
99
|
right: right
|
@@ -12,12 +12,20 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
12
12
|
*/
|
13
13
|
import React from 'react';
|
14
14
|
import namor from 'namor';
|
15
|
+
import { StatusIcon } from '../../StatusIcon';
|
15
16
|
import { inlineEditSelectItems } from './getInlineEditColumns';
|
16
17
|
|
17
|
-
var getRandomInteger = function getRandomInteger(min, max) {
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
var getRandomInteger = function getRandomInteger(min, max, decimalPlaces) {
|
19
|
+
var roundedMin = Math.ceil(min);
|
20
|
+
var roundedMax = Math.floor(max);
|
21
|
+
var randomNumber = Math.random() * (max - min) + min;
|
22
|
+
|
23
|
+
if (!decimalPlaces) {
|
24
|
+
return Math.floor(Math.random() * (roundedMax - roundedMin + 1)) + roundedMin;
|
25
|
+
}
|
26
|
+
|
27
|
+
var power = Math.pow(10, decimalPlaces);
|
28
|
+
return Math.floor(randomNumber * power) / power;
|
21
29
|
};
|
22
30
|
|
23
31
|
export var makeData = function makeData() {
|
@@ -47,6 +55,16 @@ export var range = function range(len) {
|
|
47
55
|
return arr;
|
48
56
|
};
|
49
57
|
|
58
|
+
var renderStatusIcon = function renderStatusIcon(statusChance) {
|
59
|
+
var iconProps = {
|
60
|
+
size: 'sm',
|
61
|
+
theme: 'light',
|
62
|
+
kind: statusChance > 0.66 ? 'critical' : statusChance > 0.33 ? 'minor-warning' : 'normal',
|
63
|
+
iconDescription: statusChance > 0.66 ? 'Critical' : statusChance > 0.33 ? 'Minor warning' : 'Normal'
|
64
|
+
};
|
65
|
+
return /*#__PURE__*/React.createElement(StatusIcon, iconProps);
|
66
|
+
};
|
67
|
+
|
50
68
|
var newPerson = function newPerson() {
|
51
69
|
var statusChance = Math.random();
|
52
70
|
var initialChartTypeIndex = getRandomInteger(0, 2);
|
@@ -149,7 +167,9 @@ var newPerson = function newPerson() {
|
|
149
167
|
}),
|
150
168
|
status: statusChance > 0.66 ? 'relationship' : statusChance > 0.33 ? 'complicated' : 'single',
|
151
169
|
chartType: initialChartTypeIndex === 0 ? inlineEditSelectItems[0] : initialChartTypeIndex === 1 ? inlineEditSelectItems[1] : inlineEditSelectItems[2],
|
152
|
-
activeSince: statusChance > 0.66 ? activeSinceDate : statusChance > 0.33 ? yesterdayDate : twoDaysAgoDate
|
170
|
+
activeSince: statusChance > 0.66 ? activeSinceDate : statusChance > 0.33 ? yesterdayDate : twoDaysAgoDate,
|
171
|
+
bonus: "$\r".concat(getRandomInteger(100, 500, 2)),
|
172
|
+
status_icon: renderStatusIcon(statusChance)
|
153
173
|
};
|
154
174
|
};
|
155
175
|
|
@@ -40,7 +40,7 @@ var buttons = ['cancel', 'edit', 'save'];
|
|
40
40
|
*/
|
41
41
|
|
42
42
|
export var InlineEdit = /*#__PURE__*/React.forwardRef(function (_ref, refIn) {
|
43
|
-
var _cx, _refInput$current, _refInput$current$
|
43
|
+
var _cx, _refInput$current, _refInput$current$tex, _cx3;
|
44
44
|
|
45
45
|
var buttonTooltipAlignment = _ref.buttonTooltipAlignment,
|
46
46
|
buttonTooltipPosition = _ref.buttonTooltipPosition,
|
@@ -66,7 +66,7 @@ export var InlineEdit = /*#__PURE__*/React.forwardRef(function (_ref, refIn) {
|
|
66
66
|
rest = _objectWithoutProperties(_ref, _excluded);
|
67
67
|
|
68
68
|
var refInput = useRef({
|
69
|
-
|
69
|
+
textContent: value
|
70
70
|
});
|
71
71
|
var localRef = useRef(null);
|
72
72
|
var ref = refIn || localRef;
|
@@ -148,15 +148,15 @@ export var InlineEdit = /*#__PURE__*/React.forwardRef(function (_ref, refIn) {
|
|
148
148
|
document.getSelection().removeAllRanges();
|
149
149
|
|
150
150
|
if (onSave) {
|
151
|
-
onSave(refInput.current.
|
151
|
+
onSave(refInput.current.textContent);
|
152
152
|
}
|
153
153
|
};
|
154
154
|
|
155
155
|
var handleInput = function handleInput() {
|
156
|
-
setInternalValue(refInput.current.
|
156
|
+
setInternalValue(refInput.current.textContent);
|
157
157
|
|
158
158
|
if (onChange) {
|
159
|
-
onChange(refInput.current.
|
159
|
+
onChange(refInput.current.textContent);
|
160
160
|
}
|
161
161
|
}; // pasting into contentEditable not supported by userEvent
|
162
162
|
|
@@ -191,7 +191,7 @@ export var InlineEdit = /*#__PURE__*/React.forwardRef(function (_ref, refIn) {
|
|
191
191
|
};
|
192
192
|
|
193
193
|
var handleCancel = function handleCancel() {
|
194
|
-
refInput.current.
|
194
|
+
refInput.current.textContent = value;
|
195
195
|
handleInput(value);
|
196
196
|
doSetEditing(false);
|
197
197
|
document.getSelection().removeAllRanges();
|
@@ -259,7 +259,7 @@ export var InlineEdit = /*#__PURE__*/React.forwardRef(function (_ref, refIn) {
|
|
259
259
|
}, /*#__PURE__*/React.createElement("div", _extends({}, rest, getDevtoolsProps(componentName), {
|
260
260
|
id: id,
|
261
261
|
size: size,
|
262
|
-
className: cx("".concat(blockClass, "__input"), _defineProperty({}, "".concat(blockClass, "__input--empty"), ((_refInput$current = refInput.current) === null || _refInput$current === void 0 ? void 0 : (_refInput$current$
|
262
|
+
className: cx("".concat(blockClass, "__input"), _defineProperty({}, "".concat(blockClass, "__input--empty"), ((_refInput$current = refInput.current) === null || _refInput$current === void 0 ? void 0 : (_refInput$current$tex = _refInput$current.textContent) === null || _refInput$current$tex === void 0 ? void 0 : _refInput$current$tex.length) === 0)),
|
263
263
|
contentEditable: true,
|
264
264
|
"aria-label": labelText,
|
265
265
|
role: "textbox",
|
@@ -202,12 +202,14 @@ export var OptionsTile = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
202
202
|
className: "".concat(blockClass, "__heading")
|
203
203
|
}, /*#__PURE__*/React.createElement("h6", {
|
204
204
|
id: titleId,
|
205
|
-
className: "".concat(blockClass, "__title")
|
205
|
+
className: "".concat(blockClass, "__title"),
|
206
|
+
title: title
|
206
207
|
}, title), text && /*#__PURE__*/React.createElement("span", {
|
207
208
|
className: cx(summaryClasses),
|
208
209
|
"aria-hidden": summaryHidden
|
209
210
|
}, Icon && /*#__PURE__*/React.createElement(Icon, null), /*#__PURE__*/React.createElement("span", {
|
210
|
-
className: "".concat(blockClass, "__summary-text")
|
211
|
+
className: "".concat(blockClass, "__summary-text"),
|
212
|
+
title: text
|
211
213
|
}, text)));
|
212
214
|
}
|
213
215
|
|
@@ -80,7 +80,7 @@ var useMultipleKeyTracking = function useMultipleKeyTracking(_ref) {
|
|
80
80
|
};
|
81
81
|
}, []);
|
82
82
|
(0, _react.useEffect)(function () {
|
83
|
-
if (containerHasFocus && !isEditing) {
|
83
|
+
if (ref && containerHasFocus && !isEditing) {
|
84
84
|
ref.current.onkeydown = ref.current.onkeyup = function (event) {
|
85
85
|
// If keydown, we will add the new key to the keysPressedList array
|
86
86
|
if (event.type === 'keydown') {
|
@@ -132,7 +132,7 @@ var useMultipleKeyTracking = function useMultipleKeyTracking(_ref) {
|
|
132
132
|
// or is currently in edit mode
|
133
133
|
|
134
134
|
|
135
|
-
if (!containerHasFocus || isEditing) {
|
135
|
+
if (ref && !containerHasFocus || isEditing) {
|
136
136
|
ref.current.onkeydown = undefined;
|
137
137
|
ref.current.onkeyup = undefined;
|
138
138
|
|
@@ -48,8 +48,6 @@ var TableContainer = _carbonComponentsReact.DataTable.TableContainer,
|
|
48
48
|
var blockClass = "".concat(_settings.pkg.prefix, "--datagrid");
|
49
49
|
|
50
50
|
var DatagridContent = function DatagridContent(_ref) {
|
51
|
-
var _getTableProps;
|
52
|
-
|
53
51
|
var datagridState = _ref.datagridState;
|
54
52
|
|
55
53
|
var _useContext = (0, _react.useContext)(_InlineEditContext.InlineEditContext),
|
@@ -85,7 +83,7 @@ var DatagridContent = function DatagridContent(_ref) {
|
|
85
83
|
// and swapped out with an input, i.e. text, number, selection, or date picker
|
86
84
|
|
87
85
|
|
88
|
-
if (target.closest(".".concat(blockClass, "__inline-edit-button")) || target.closest(".".concat(blockClass, "__inline-edit--select"))) {
|
86
|
+
if (target.closest(".".concat(blockClass, "__inline-edit-button")) || target.closest(".".concat(blockClass, "__inline-edit--select")) || target.closest(".".concat(blockClass, "__row-size-button"))) {
|
89
87
|
return;
|
90
88
|
}
|
91
89
|
|
@@ -95,8 +93,33 @@ var DatagridContent = function DatagridContent(_ref) {
|
|
95
93
|
});
|
96
94
|
});
|
97
95
|
|
96
|
+
var renderTable = function renderTable() {
|
97
|
+
var _getTableProps;
|
98
|
+
|
99
|
+
return /*#__PURE__*/_react.default.createElement(Table, (0, _extends2.default)({}, getTableProps(), {
|
100
|
+
className: (0, _classnames.default)(withVirtualScroll ? '' : "".concat(blockClass, "__table-simple"), "".concat(blockClass, "__vertical-align-").concat(verticalAlign), (0, _defineProperty2.default)({}, "".concat(blockClass, "__variable-row-height"), variableRowHeight), (0, _defineProperty2.default)({}, "".concat(blockClass, "__table-with-inline-edit"), withInlineEdit), (0, _defineProperty2.default)({}, "".concat(blockClass, "__table-grid-active"), gridActive), (_getTableProps = getTableProps()) === null || _getTableProps === void 0 ? void 0 : _getTableProps.className),
|
101
|
+
role: withInlineEdit && 'grid',
|
102
|
+
tabIndex: withInlineEdit && 0,
|
103
|
+
onKeyDown: withInlineEdit ? function (event) {
|
104
|
+
return (0, _handleGridKeyPress.handleGridKeyPress)({
|
105
|
+
event: event,
|
106
|
+
dispatch: dispatch,
|
107
|
+
state: state,
|
108
|
+
instance: datagridState,
|
109
|
+
keysPressedList: keysPressedList,
|
110
|
+
usingMac: usingMac
|
111
|
+
});
|
112
|
+
} : null,
|
113
|
+
onFocus: withInlineEdit ? function () {
|
114
|
+
return (0, _handleGridFocus.handleGridFocus)(state, dispatch);
|
115
|
+
} : null
|
116
|
+
}), /*#__PURE__*/_react.default.createElement(_DatagridHead.default, datagridState), /*#__PURE__*/_react.default.createElement(_DatagridBody.default, (0, _extends2.default)({}, datagridState, {
|
117
|
+
rows: rows
|
118
|
+
})));
|
119
|
+
};
|
120
|
+
|
98
121
|
var _useMultipleKeyTracki = (0, _hooks2.useMultipleKeyTracking)({
|
99
|
-
ref: multiKeyTrackingRef,
|
122
|
+
ref: withInlineEdit ? multiKeyTrackingRef : null,
|
100
123
|
containerHasFocus: gridActive,
|
101
124
|
isEditing: !!editId
|
102
125
|
}),
|
@@ -112,28 +135,9 @@ var DatagridContent = function DatagridContent(_ref) {
|
|
112
135
|
ref: gridAreaRef
|
113
136
|
}, leftPanel && leftPanel.isOpen && /*#__PURE__*/_react.default.createElement("div", {
|
114
137
|
className: "".concat(blockClass, "__datagridLeftPanel")
|
115
|
-
}, leftPanel.panelContent), /*#__PURE__*/_react.default.createElement("div", {
|
138
|
+
}, leftPanel.panelContent), withInlineEdit ? /*#__PURE__*/_react.default.createElement("div", {
|
116
139
|
ref: multiKeyTrackingRef
|
117
|
-
},
|
118
|
-
className: (0, _classnames.default)(withVirtualScroll ? '' : "".concat(blockClass, "__table-simple"), "".concat(blockClass, "__vertical-align-").concat(verticalAlign), (0, _defineProperty2.default)({}, "".concat(blockClass, "__variable-row-height"), variableRowHeight), (0, _defineProperty2.default)({}, "".concat(blockClass, "__table-with-inline-edit"), withInlineEdit), (0, _defineProperty2.default)({}, "".concat(blockClass, "__table-grid-active"), gridActive), (_getTableProps = getTableProps()) === null || _getTableProps === void 0 ? void 0 : _getTableProps.className),
|
119
|
-
role: withInlineEdit && 'grid',
|
120
|
-
tabIndex: withInlineEdit && 0,
|
121
|
-
onKeyDown: withInlineEdit ? function (event) {
|
122
|
-
return (0, _handleGridKeyPress.handleGridKeyPress)({
|
123
|
-
event: event,
|
124
|
-
dispatch: dispatch,
|
125
|
-
state: state,
|
126
|
-
instance: datagridState,
|
127
|
-
keysPressedList: keysPressedList,
|
128
|
-
usingMac: usingMac
|
129
|
-
});
|
130
|
-
} : null,
|
131
|
-
onFocus: withInlineEdit ? function () {
|
132
|
-
return (0, _handleGridFocus.handleGridFocus)(state, dispatch);
|
133
|
-
} : null
|
134
|
-
}), /*#__PURE__*/_react.default.createElement(_DatagridHead.default, datagridState), /*#__PURE__*/_react.default.createElement(_DatagridBody.default, (0, _extends2.default)({}, datagridState, {
|
135
|
-
rows: rows
|
136
|
-
})))))), (rows === null || rows === void 0 ? void 0 : rows.length) > 0 && !isFetching && DatagridPagination && DatagridPagination(datagridState), CustomizeColumnsModal && /*#__PURE__*/_react.default.createElement(CustomizeColumnsModal, {
|
140
|
+
}, renderTable()) : renderTable())), (rows === null || rows === void 0 ? void 0 : rows.length) > 0 && !isFetching && DatagridPagination && DatagridPagination(datagridState), CustomizeColumnsModal && /*#__PURE__*/_react.default.createElement(CustomizeColumnsModal, {
|
137
141
|
instance: datagridState
|
138
142
|
}));
|
139
143
|
};
|
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
4
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
6
|
+
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
6
8
|
value: true
|
7
9
|
});
|
@@ -13,7 +15,7 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
|
|
13
15
|
|
14
16
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
15
17
|
|
16
|
-
var _react =
|
18
|
+
var _react = _interopRequireWildcard(require("react"));
|
17
19
|
|
18
20
|
var _carbonComponentsReact = require("carbon-components-react");
|
19
21
|
|
@@ -23,7 +25,16 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
23
25
|
|
24
26
|
var _settings = require("../../../settings");
|
25
27
|
|
28
|
+
var _InlineEditContext = require("./addons/InlineEdit/InlineEditContext/InlineEditContext");
|
29
|
+
|
30
|
+
var _getCellIdAsObject = require("./addons/InlineEdit/InlineEditContext/getCellIdAsObject");
|
31
|
+
|
26
32
|
var _excluded = ["children"];
|
33
|
+
|
34
|
+
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); }
|
35
|
+
|
36
|
+
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; }
|
37
|
+
|
27
38
|
var blockClass = "".concat(_settings.pkg.prefix, "--datagrid");
|
28
39
|
var TableRow = _carbonComponentsReact.DataTable.TableRow,
|
29
40
|
TableCell = _carbonComponentsReact.DataTable.TableCell; // eslint-disable-next-line react/prop-types
|
@@ -32,8 +43,14 @@ var DatagridRow = function DatagridRow(datagridState) {
|
|
32
43
|
var _cx;
|
33
44
|
|
34
45
|
var row = datagridState.row;
|
46
|
+
|
47
|
+
var _useContext = (0, _react.useContext)(_InlineEditContext.InlineEditContext),
|
48
|
+
state = _useContext.state;
|
49
|
+
|
50
|
+
var activeCellId = state.activeCellId;
|
51
|
+
var activeCellObject = activeCellId && (0, _getCellIdAsObject.getCellIdAsObject)(activeCellId);
|
35
52
|
return /*#__PURE__*/_react.default.createElement(TableRow, (0, _extends2.default)({
|
36
|
-
className: (0, _classnames.default)("".concat(blockClass, "__carbon-row"), (_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__carbon-row-expanded"), row.isExpanded), (0, _defineProperty2.default)(_cx, "".concat(_settings.carbon.prefix, "--data-table--selected"), row.isSelected), _cx))
|
53
|
+
className: (0, _classnames.default)("".concat(blockClass, "__carbon-row"), (_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__carbon-row-expanded"), row.isExpanded), (0, _defineProperty2.default)(_cx, "".concat(_settings.carbon.prefix, "--data-table--selected"), row.isSelected), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__carbon-row-hover-active"), activeCellObject && row.index === activeCellObject.row), _cx))
|
37
54
|
}, row.getRowProps(), {
|
38
55
|
key: row.id,
|
39
56
|
onMouseEnter: function onMouseEnter(event) {
|
@@ -60,7 +60,7 @@ var RowSizeDropdown = function RowSizeDropdown(_ref) {
|
|
60
60
|
return setIsOpen(!isOpen);
|
61
61
|
},
|
62
62
|
iconDescription: legendText,
|
63
|
-
className: (0, _classnames.default)((0, _defineProperty2.default)({}, "".concat(blockClass, "__row-size-button--open"), isOpen))
|
63
|
+
className: (0, _classnames.default)("".concat(blockClass, "__row-size-button"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__row-size-button--open"), isOpen))
|
64
64
|
}), isOpen && /*#__PURE__*/React.createElement(_RowSizeRadioGroup.default, (0, _extends2.default)({}, props, {
|
65
65
|
legendText: legendText,
|
66
66
|
buttonRef: buttonRef,
|
@@ -113,7 +113,7 @@ var getDropdownPosition = function getDropdownPosition(buttonEle) {
|
|
113
113
|
|
114
114
|
if (parent instanceof HTMLElement) {
|
115
115
|
var top = buttonEle.offsetTop + buttonEle.offsetHeight;
|
116
|
-
var right = parent.offsetWidth - parent.offsetLeft -
|
116
|
+
var right = parent.offsetWidth - parent.offsetLeft - buttonEle.offsetLeft;
|
117
117
|
return {
|
118
118
|
top: top,
|
119
119
|
right: right
|
@@ -13,16 +13,25 @@ var _react = _interopRequireDefault(require("react"));
|
|
13
13
|
|
14
14
|
var _namor = _interopRequireDefault(require("namor"));
|
15
15
|
|
16
|
+
var _StatusIcon = require("../../StatusIcon");
|
17
|
+
|
16
18
|
var _getInlineEditColumns = require("./getInlineEditColumns");
|
17
19
|
|
18
20
|
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; }
|
19
21
|
|
20
22
|
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) { (0, _defineProperty2.default)(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; }
|
21
23
|
|
22
|
-
var getRandomInteger = function getRandomInteger(min, max) {
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
var getRandomInteger = function getRandomInteger(min, max, decimalPlaces) {
|
25
|
+
var roundedMin = Math.ceil(min);
|
26
|
+
var roundedMax = Math.floor(max);
|
27
|
+
var randomNumber = Math.random() * (max - min) + min;
|
28
|
+
|
29
|
+
if (!decimalPlaces) {
|
30
|
+
return Math.floor(Math.random() * (roundedMax - roundedMin + 1)) + roundedMin;
|
31
|
+
}
|
32
|
+
|
33
|
+
var power = Math.pow(10, decimalPlaces);
|
34
|
+
return Math.floor(randomNumber * power) / power;
|
26
35
|
};
|
27
36
|
|
28
37
|
var makeData = function makeData() {
|
@@ -57,6 +66,16 @@ var range = function range(len) {
|
|
57
66
|
|
58
67
|
exports.range = range;
|
59
68
|
|
69
|
+
var renderStatusIcon = function renderStatusIcon(statusChance) {
|
70
|
+
var iconProps = {
|
71
|
+
size: 'sm',
|
72
|
+
theme: 'light',
|
73
|
+
kind: statusChance > 0.66 ? 'critical' : statusChance > 0.33 ? 'minor-warning' : 'normal',
|
74
|
+
iconDescription: statusChance > 0.66 ? 'Critical' : statusChance > 0.33 ? 'Minor warning' : 'Normal'
|
75
|
+
};
|
76
|
+
return /*#__PURE__*/_react.default.createElement(_StatusIcon.StatusIcon, iconProps);
|
77
|
+
};
|
78
|
+
|
60
79
|
var newPerson = function newPerson() {
|
61
80
|
var statusChance = Math.random();
|
62
81
|
var initialChartTypeIndex = getRandomInteger(0, 2);
|
@@ -159,7 +178,9 @@ var newPerson = function newPerson() {
|
|
159
178
|
}),
|
160
179
|
status: statusChance > 0.66 ? 'relationship' : statusChance > 0.33 ? 'complicated' : 'single',
|
161
180
|
chartType: initialChartTypeIndex === 0 ? _getInlineEditColumns.inlineEditSelectItems[0] : initialChartTypeIndex === 1 ? _getInlineEditColumns.inlineEditSelectItems[1] : _getInlineEditColumns.inlineEditSelectItems[2],
|
162
|
-
activeSince: statusChance > 0.66 ? activeSinceDate : statusChance > 0.33 ? yesterdayDate : twoDaysAgoDate
|
181
|
+
activeSince: statusChance > 0.66 ? activeSinceDate : statusChance > 0.33 ? yesterdayDate : twoDaysAgoDate,
|
182
|
+
bonus: "$\r".concat(getRandomInteger(100, 500, 2)),
|
183
|
+
status_icon: renderStatusIcon(statusChance)
|
163
184
|
};
|
164
185
|
};
|
165
186
|
|
@@ -56,7 +56,7 @@ var buttons = ['cancel', 'edit', 'save'];
|
|
56
56
|
*/
|
57
57
|
|
58
58
|
var InlineEdit = /*#__PURE__*/_react.default.forwardRef(function (_ref, refIn) {
|
59
|
-
var _cx, _refInput$current, _refInput$current$
|
59
|
+
var _cx, _refInput$current, _refInput$current$tex, _cx3;
|
60
60
|
|
61
61
|
var buttonTooltipAlignment = _ref.buttonTooltipAlignment,
|
62
62
|
buttonTooltipPosition = _ref.buttonTooltipPosition,
|
@@ -81,7 +81,7 @@ var InlineEdit = /*#__PURE__*/_react.default.forwardRef(function (_ref, refIn) {
|
|
81
81
|
value = _ref.value,
|
82
82
|
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
83
83
|
var refInput = (0, _react.useRef)({
|
84
|
-
|
84
|
+
textContent: value
|
85
85
|
});
|
86
86
|
var localRef = (0, _react.useRef)(null);
|
87
87
|
var ref = refIn || localRef;
|
@@ -163,15 +163,15 @@ var InlineEdit = /*#__PURE__*/_react.default.forwardRef(function (_ref, refIn) {
|
|
163
163
|
document.getSelection().removeAllRanges();
|
164
164
|
|
165
165
|
if (onSave) {
|
166
|
-
onSave(refInput.current.
|
166
|
+
onSave(refInput.current.textContent);
|
167
167
|
}
|
168
168
|
};
|
169
169
|
|
170
170
|
var handleInput = function handleInput() {
|
171
|
-
setInternalValue(refInput.current.
|
171
|
+
setInternalValue(refInput.current.textContent);
|
172
172
|
|
173
173
|
if (onChange) {
|
174
|
-
onChange(refInput.current.
|
174
|
+
onChange(refInput.current.textContent);
|
175
175
|
}
|
176
176
|
}; // pasting into contentEditable not supported by userEvent
|
177
177
|
|
@@ -206,7 +206,7 @@ var InlineEdit = /*#__PURE__*/_react.default.forwardRef(function (_ref, refIn) {
|
|
206
206
|
};
|
207
207
|
|
208
208
|
var handleCancel = function handleCancel() {
|
209
|
-
refInput.current.
|
209
|
+
refInput.current.textContent = value;
|
210
210
|
handleInput(value);
|
211
211
|
doSetEditing(false);
|
212
212
|
document.getSelection().removeAllRanges();
|
@@ -274,7 +274,7 @@ var InlineEdit = /*#__PURE__*/_react.default.forwardRef(function (_ref, refIn) {
|
|
274
274
|
}, /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, rest, (0, _devtools.getDevtoolsProps)(componentName), {
|
275
275
|
id: id,
|
276
276
|
size: size,
|
277
|
-
className: (0, _classnames.default)("".concat(blockClass, "__input"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__input--empty"), ((_refInput$current = refInput.current) === null || _refInput$current === void 0 ? void 0 : (_refInput$current$
|
277
|
+
className: (0, _classnames.default)("".concat(blockClass, "__input"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__input--empty"), ((_refInput$current = refInput.current) === null || _refInput$current === void 0 ? void 0 : (_refInput$current$tex = _refInput$current.textContent) === null || _refInput$current$tex === void 0 ? void 0 : _refInput$current$tex.length) === 0)),
|
278
278
|
contentEditable: true,
|
279
279
|
"aria-label": labelText,
|
280
280
|
role: "textbox",
|
@@ -221,12 +221,14 @@ var OptionsTile = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
221
221
|
className: "".concat(blockClass, "__heading")
|
222
222
|
}, /*#__PURE__*/_react.default.createElement("h6", {
|
223
223
|
id: titleId,
|
224
|
-
className: "".concat(blockClass, "__title")
|
224
|
+
className: "".concat(blockClass, "__title"),
|
225
|
+
title: title
|
225
226
|
}, title), text && /*#__PURE__*/_react.default.createElement("span", {
|
226
227
|
className: (0, _classnames.default)(summaryClasses),
|
227
228
|
"aria-hidden": summaryHidden
|
228
229
|
}, Icon && /*#__PURE__*/_react.default.createElement(Icon, null), /*#__PURE__*/_react.default.createElement("span", {
|
229
|
-
className: "".concat(blockClass, "__summary-text")
|
230
|
+
className: "".concat(blockClass, "__summary-text"),
|
231
|
+
title: text
|
230
232
|
}, text)));
|
231
233
|
}
|
232
234
|
|
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.32.
|
4
|
+
"version": "1.32.1",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"main": "lib/index.js",
|
7
7
|
"module": "es/index.js",
|
@@ -51,26 +51,26 @@
|
|
51
51
|
},
|
52
52
|
"devDependencies": {
|
53
53
|
"@babel/cli": "^7.18.10",
|
54
|
-
"@babel/core": "^7.
|
55
|
-
"babel-preset-ibm-cloud-cognitive": "^0.14.
|
54
|
+
"@babel/core": "^7.19.1",
|
55
|
+
"babel-preset-ibm-cloud-cognitive": "^0.14.20",
|
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
60
|
"fs-extra": "^10.1.0",
|
61
61
|
"glob": "^8.0.3",
|
62
|
-
"jest": "^29.0.
|
63
|
-
"jest-config-ibm-cloud-cognitive": "^0.24.
|
64
|
-
"jest-environment-jsdom": "^29.0.
|
62
|
+
"jest": "^29.0.3",
|
63
|
+
"jest-config-ibm-cloud-cognitive": "^0.24.6",
|
64
|
+
"jest-environment-jsdom": "^29.0.3",
|
65
65
|
"namor": "^1.1.2",
|
66
|
-
"npm-check-updates": "^16.
|
66
|
+
"npm-check-updates": "^16.1.3",
|
67
67
|
"npm-run-all": "^4.1.5",
|
68
68
|
"rimraf": "^3.0.2",
|
69
|
-
"sass": "^1.54.
|
69
|
+
"sass": "^1.54.9",
|
70
70
|
"yargs": "^17.5.1"
|
71
71
|
},
|
72
72
|
"dependencies": {
|
73
|
-
"@babel/runtime": "^7.
|
73
|
+
"@babel/runtime": "^7.19.0",
|
74
74
|
"@carbon/telemetry": "^0.1.0",
|
75
75
|
"immutability-helper": "^3.1.1",
|
76
76
|
"react-dnd": "^15.1.2",
|
@@ -87,11 +87,11 @@
|
|
87
87
|
"@carbon/motion": "^10.29.0",
|
88
88
|
"@carbon/themes": "^10.55.0",
|
89
89
|
"@carbon/type": "^10.45.0",
|
90
|
-
"carbon-components": "^10.58.
|
91
|
-
"carbon-components-react": "^7.59.
|
90
|
+
"carbon-components": "^10.58.1",
|
91
|
+
"carbon-components-react": "^7.59.1",
|
92
92
|
"carbon-icons": "^7.0.7",
|
93
93
|
"react": "^16.8.6 || ^17.0.1",
|
94
94
|
"react-dom": "^16.8.6 || ^17.0.1"
|
95
95
|
},
|
96
|
-
"gitHead": "
|
96
|
+
"gitHead": "829c3e97ae9b2412f7fcb1859dc8dd8b019963ee"
|
97
97
|
}
|
@@ -85,6 +85,7 @@ $row-heights: (
|
|
85
85
|
cursor: pointer;
|
86
86
|
outline: 0; // handled by active class
|
87
87
|
.#{$block-class}__label-icon {
|
88
|
+
height: $spacing-05;
|
88
89
|
padding-right: $spacing-05;
|
89
90
|
}
|
90
91
|
&.#{$block-class}__inline-edit-button--non-edit {
|
@@ -209,3 +210,8 @@ $row-heights: (
|
|
209
210
|
text-overflow: ellipsis;
|
210
211
|
white-space: nowrap;
|
211
212
|
}
|
213
|
+
|
214
|
+
.#{$carbon-prefix}--data-table .#{$block-class}__carbon-row-hover-active td {
|
215
|
+
border-top-color: $hover-ui;
|
216
|
+
background-color: $hover-ui;
|
217
|
+
}
|
@@ -70,13 +70,17 @@
|
|
70
70
|
}
|
71
71
|
|
72
72
|
.#{$block-class}__heading {
|
73
|
+
overflow: hidden;
|
73
74
|
grid-column: 2;
|
74
75
|
}
|
75
76
|
|
76
77
|
.#{$block-class}__title {
|
77
78
|
@include carbon--type-style('productive-heading-01');
|
78
79
|
|
80
|
+
overflow: hidden;
|
79
81
|
color: $text-01;
|
82
|
+
text-overflow: ellipsis;
|
83
|
+
white-space: nowrap;
|
80
84
|
}
|
81
85
|
|
82
86
|
.#{$block-class}__summary {
|