@carbon/ibm-products 1.35.1 → 1.35.2
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +257 -237
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +2 -2
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +257 -237
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +2 -2
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +257 -237
- package/css/index.css.map +1 -1
- package/css/index.min.css +2 -2
- package/css/index.min.css.map +1 -1
- package/es/components/Datagrid/Datagrid/DatagridContent.js +1 -1
- package/es/components/Datagrid/Datagrid/DatagridRow.js +3 -3
- package/es/components/Datagrid/Datagrid/DatagridToolbar.js +4 -2
- package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +1 -1
- package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +4 -3
- package/es/components/Datagrid/useRowExpander.js +13 -1
- package/es/components/InlineEdit/InlineEdit.js +22 -385
- package/es/components/InlineEditV1/InlineEditV1.js +406 -0
- package/es/components/InlineEditV1/index.js +8 -0
- package/es/components/InlineEditV2/InlineEditV2.js +48 -21
- package/es/components/InlineEditV2/index.js +7 -0
- package/es/components/index.js +1 -1
- package/es/global/js/package-settings.js +1 -0
- package/lib/components/Datagrid/Datagrid/DatagridContent.js +1 -1
- package/lib/components/Datagrid/Datagrid/DatagridRow.js +3 -3
- package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +4 -2
- package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +1 -1
- package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +4 -3
- package/lib/components/Datagrid/useColumnOrder.js +2 -1
- package/lib/components/Datagrid/useRowExpander.js +13 -1
- package/lib/components/InlineEdit/InlineEdit.js +22 -379
- package/lib/components/InlineEditV1/InlineEditV1.js +403 -0
- package/lib/components/InlineEditV1/index.js +12 -0
- package/lib/components/InlineEditV2/InlineEditV2.js +38 -20
- package/lib/components/index.js +1 -1
- package/lib/global/js/package-settings.js +1 -0
- package/package.json +10 -10
- package/scss/components/Datagrid/styles/_useExpandedRow.scss +18 -0
- package/scss/components/{InlineEdit → InlineEditV1}/_index.scss +1 -1
- package/scss/components/{InlineEdit/_inline-edit.scss → InlineEditV1/_inline-edit-v1.scss} +0 -0
- package/scss/components/{InlineEdit → InlineEditV1}/_storybook-styles.scss +0 -0
- package/scss/components/InlineEditV2/_index.scss +1 -1
- package/scss/components/InlineEditV2/_inline-edit-v2.scss +5 -1
- package/scss/components/InlineEditV2/_storybook-styles.scss +6 -0
- package/scss/components/_index-released-only.scss +1 -1
- package/scss/components/_index.scss +2 -1
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
exports.default = void 0;
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
11
|
+
var _layout = require("@carbon/layout");
|
11
12
|
var _carbonComponentsReact = require("carbon-components-react");
|
12
13
|
var _isArray = _interopRequireDefault(require("lodash/isArray"));
|
13
14
|
var _settings = require("../../../../../settings");
|
@@ -52,8 +53,8 @@ var RowSizeRadioGroup = function RowSizeRadioGroup(_ref) {
|
|
52
53
|
return /*#__PURE__*/_react.default.createElement("div", {
|
53
54
|
className: "".concat(blockClass, "__row-size-dropdown"),
|
54
55
|
style: {
|
55
|
-
top: top,
|
56
|
-
right: right
|
56
|
+
top: (0, _layout.rem)(top),
|
57
|
+
right: (0, _layout.rem)(right)
|
57
58
|
},
|
58
59
|
role: "presentation",
|
59
60
|
onClick: function onClick(e) {
|
@@ -96,7 +97,7 @@ var getDropdownPosition = function getDropdownPosition(buttonEle) {
|
|
96
97
|
var parent = buttonEle.parentElement;
|
97
98
|
if (parent instanceof HTMLElement) {
|
98
99
|
var top = buttonEle.offsetTop + buttonEle.offsetHeight;
|
99
|
-
var right = parent.offsetWidth -
|
100
|
+
var right = parent.offsetWidth - (buttonEle.offsetLeft + buttonEle.offsetWidth);
|
100
101
|
return {
|
101
102
|
top: top,
|
102
103
|
right: right
|
@@ -10,5 +10,6 @@ var _reactTable = require("react-table");
|
|
10
10
|
*
|
11
11
|
* This source code is licensed under the Apache-2.0 license found in the
|
12
12
|
* LICENSE file in the root directory of this source tree.
|
13
|
-
*/
|
13
|
+
*/
|
14
|
+
var _default = _reactTable.useColumnOrder;
|
14
15
|
exports.default = _default;
|
@@ -6,8 +6,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
});
|
7
7
|
exports.default = void 0;
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
9
10
|
var _react = _interopRequireDefault(require("react"));
|
10
11
|
var _iconsReact = require("@carbon/icons-react");
|
12
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
13
|
+
var _settings = require("../../settings");
|
11
14
|
/* eslint-disable react/prop-types */
|
12
15
|
/*
|
13
16
|
* Licensed Materials - Property of IBM
|
@@ -17,13 +20,22 @@ var _iconsReact = require("@carbon/icons-react");
|
|
17
20
|
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
18
21
|
*/
|
19
22
|
|
23
|
+
var blockClass = "".concat(_settings.pkg.prefix, "--datagrid");
|
20
24
|
var useRowExpander = function useRowExpander(hooks) {
|
21
25
|
var visibleColumns = function visibleColumns(columns) {
|
22
26
|
var expanderColumn = {
|
23
27
|
id: 'expander',
|
24
28
|
Cell: function Cell(_ref) {
|
25
29
|
var row = _ref.row;
|
26
|
-
return row.canExpand && /*#__PURE__*/_react.default.createElement("
|
30
|
+
return row.canExpand && /*#__PURE__*/_react.default.createElement("button", (0, _extends2.default)({
|
31
|
+
type: "button",
|
32
|
+
"aria-label": "Expand current row",
|
33
|
+
className: (0, _classnames.default)("".concat(blockClass, "__row-expander"), "".concat(_settings.carbon.prefix, "--btn"), "".concat(_settings.carbon.prefix, "--btn--ghost"))
|
34
|
+
}, row.getToggleRowExpandedProps()), row.isExpanded ? /*#__PURE__*/_react.default.createElement(_iconsReact.ChevronUp16, {
|
35
|
+
className: "".concat(blockClass, "__row-expander--icon")
|
36
|
+
}) : /*#__PURE__*/_react.default.createElement(_iconsReact.ChevronDown16, {
|
37
|
+
className: "".concat(blockClass, "__row-expander--icon")
|
38
|
+
}));
|
27
39
|
},
|
28
40
|
width: 48,
|
29
41
|
disableResizing: true,
|
@@ -1,402 +1,45 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
var
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
6
6
|
value: true
|
7
7
|
});
|
8
8
|
exports.InlineEdit = void 0;
|
9
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
10
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
11
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
12
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
13
10
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
14
11
|
var _react = _interopRequireWildcard(require("react"));
|
15
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
16
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
17
|
-
var _devtools = require("../../global/js/utils/devtools");
|
18
13
|
var _settings = require("../../settings");
|
19
|
-
var
|
20
|
-
var
|
21
|
-
var _excluded = ["
|
14
|
+
var _InlineEditV = require("../InlineEditV1");
|
15
|
+
var _InlineEditV2 = require("../InlineEditV2");
|
16
|
+
var _excluded = ["v2"];
|
22
17
|
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); }
|
23
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null ||
|
24
|
-
|
25
|
-
var
|
26
|
-
var componentName = 'InlineEdit';
|
27
|
-
// NOTE: the component SCSS is not imported here: it is rolled up separately.
|
28
|
-
|
29
|
-
var defaults = {
|
30
|
-
buttonTooltipAlignment: 'center',
|
31
|
-
buttonTooltipPosition: 'top',
|
32
|
-
light: true,
|
33
|
-
// defaults to true to reflect design
|
34
|
-
size: 'md'
|
35
|
-
};
|
36
|
-
var buttons = ['cancel', 'edit', 'save'];
|
37
|
-
|
18
|
+
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; }
|
19
|
+
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; }
|
20
|
+
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; }
|
38
21
|
/**
|
39
|
-
*
|
22
|
+
* this is a wrapper component that will allow us to support v1 and v2 versions of InlineEdit
|
23
|
+
* if the user passes in the v2 feature flag the v2 version of the component will be rendered
|
24
|
+
* since this is a temporary solution the named export should just remain InlineEdit unlike how
|
25
|
+
* Card works as a base layer for Productive and Expressive cards.
|
40
26
|
*/
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
cancelDescription = _ref.cancelDescription,
|
46
|
-
className = _ref.className,
|
47
|
-
disabled = _ref.disabled,
|
48
|
-
editAlwaysVisible = _ref.editAlwaysVisible,
|
49
|
-
editDescription = _ref.editDescription,
|
50
|
-
id = _ref.id,
|
51
|
-
invalid = _ref.invalid,
|
52
|
-
invalidText = _ref.invalidText,
|
53
|
-
labelText = _ref.labelText,
|
54
|
-
_ref$light = _ref.light,
|
55
|
-
light = _ref$light === void 0 ? defaults.light : _ref$light,
|
56
|
-
onCancel = _ref.onCancel,
|
57
|
-
onSave = _ref.onSave,
|
58
|
-
onChange = _ref.onChange,
|
59
|
-
placeholder = _ref.placeholder,
|
60
|
-
saveDescription = _ref.saveDescription,
|
61
|
-
_ref$size = _ref.size,
|
62
|
-
size = _ref$size === void 0 ? defaults.size : _ref$size,
|
63
|
-
value = _ref.value,
|
27
|
+
|
28
|
+
var componentName = 'InlineEdit';
|
29
|
+
var InlineEdit = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
30
|
+
var v2 = _ref.v2,
|
64
31
|
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
65
|
-
var
|
66
|
-
|
32
|
+
var props = _objectSpread(_objectSpread({}, rest), {}, {
|
33
|
+
ref: ref
|
67
34
|
});
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
editing = _useState2[0],
|
73
|
-
setEditing = _useState2[1];
|
74
|
-
var _useState3 = (0, _react.useState)(value),
|
75
|
-
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
76
|
-
internalValue = _useState4[0],
|
77
|
-
setInternalValue = _useState4[1];
|
78
|
-
var showValidation = invalid; // || warn;
|
79
|
-
var validationText = invalidText; // || warnText;
|
80
|
-
var validationIcon = showValidation ? /*#__PURE__*/_react.default.createElement(_iconsReact.WarningFilled16, null) : null;
|
81
|
-
|
82
|
-
// sanitize the tooltip values
|
83
|
-
var alignIsObject = (0, _typeof2.default)(buttonTooltipAlignment) === 'object';
|
84
|
-
var directionIsObject = (0, _typeof2.default)(buttonTooltipPosition) === 'object';
|
85
|
-
var tipPositions = buttons.reduce(function (acc, button) {
|
86
|
-
var _ref2, _ref3;
|
87
|
-
var tooltipAlignment = (_ref2 = alignIsObject ? buttonTooltipAlignment[button] : buttonTooltipAlignment) !== null && _ref2 !== void 0 ? _ref2 : defaults.buttonTooltipAlignment;
|
88
|
-
var tooltipPosition = (_ref3 = directionIsObject ? buttonTooltipPosition[button] : buttonTooltipPosition) !== null && _ref3 !== void 0 ? _ref3 : defaults.buttonTooltipPosition;
|
89
|
-
acc[button] = {
|
90
|
-
tooltipAlignment: tooltipAlignment,
|
91
|
-
tooltipPosition: tooltipPosition
|
92
|
-
};
|
93
|
-
return acc;
|
94
|
-
}, {});
|
95
|
-
var doSetEditing = function doSetEditing(value) {
|
96
|
-
if (value === false) {
|
97
|
-
// move scroll to start
|
98
|
-
refInput.current.scrollLeft = 0;
|
99
|
-
}
|
100
|
-
setEditing(!disabled && value);
|
101
|
-
};
|
102
|
-
var handleEdit = function handleEdit(ev) {
|
103
|
-
/* istanbul ignore else */
|
104
|
-
if (!disabled) {
|
105
|
-
var rightOfInput = ev.currentTarget.classList.contains("".concat(blockClass, "__edit")) || ev.target.classList.contains("".concat(blockClass, "__after-input-elements"));
|
106
|
-
var leftOfInput = ev.currentTarget = ev.target.classList.contains("".concat(blockClass));
|
107
|
-
|
108
|
-
// clicking on the content editable element should not set either of these to true
|
109
|
-
if (rightOfInput || leftOfInput) {
|
110
|
-
doSetEditing(true);
|
111
|
-
setTimeout(function () {
|
112
|
-
refInput.current.focus();
|
113
|
-
// select all the content
|
114
|
-
document.getSelection().selectAllChildren(refInput.current);
|
115
|
-
if (rightOfInput) {
|
116
|
-
document.getSelection().collapseToEnd();
|
117
|
-
refInput.current.scrollLeft = 9999; // never going to get there but ensures at end.
|
118
|
-
} else {
|
119
|
-
document.getSelection().collapseToStart();
|
120
|
-
refInput.current.scrollLeft = 0; // scroll to start
|
121
|
-
}
|
122
|
-
}, 0);
|
123
|
-
}
|
124
|
-
}
|
125
|
-
};
|
126
|
-
var handleFocus = function handleFocus(ev) {
|
127
|
-
ev.preventDefault();
|
128
|
-
if (!editing && ev.target.classList.contains("".concat(blockClass, "__input"))) {
|
129
|
-
doSetEditing(true);
|
130
|
-
}
|
131
|
-
};
|
132
|
-
var handleSave = function handleSave() {
|
133
|
-
doSetEditing(false);
|
134
|
-
document.getSelection().removeAllRanges();
|
135
|
-
if (onSave) {
|
136
|
-
onSave(refInput.current.textContent);
|
137
|
-
}
|
138
|
-
};
|
139
|
-
var handleInput = function handleInput() {
|
140
|
-
setInternalValue(refInput.current.textContent);
|
141
|
-
if (onChange) {
|
142
|
-
onChange(refInput.current.textContent);
|
143
|
-
}
|
144
|
-
};
|
145
|
-
|
146
|
-
// pasting into contentEditable not supported by userEvent
|
147
|
-
var handlePaste = /* istanbul ignore next */function handlePaste(ev) {
|
148
|
-
ev.preventDefault();
|
149
|
-
|
150
|
-
// Get clipboard as plain text
|
151
|
-
var text = (ev.clipboardData || window.clipboardData).getData('text/plain');
|
152
|
-
|
153
|
-
// remove \n
|
154
|
-
var sanitizedText = text.replaceAll(/\n/g, '') // remove carriage returns
|
155
|
-
.replaceAll(/\t/g, ' '); // replace tab with two spaces
|
156
|
-
|
157
|
-
if (document.queryCommandSupported('insertText')) {
|
158
|
-
document.execCommand('insertText', false, sanitizedText);
|
159
|
-
} else {
|
160
|
-
// Insert text at the current position of caret
|
161
|
-
var range = document.getSelection().getRangeAt(0);
|
162
|
-
range.deleteContents();
|
163
|
-
var textNode = document.createTextNode(sanitizedText);
|
164
|
-
range.insertNode(textNode);
|
165
|
-
// move selection end of textNode
|
166
|
-
range.selectNodeContents(textNode);
|
167
|
-
range.collapse(false);
|
168
|
-
|
169
|
-
// remove existing range
|
170
|
-
var selection = document.getSelection();
|
171
|
-
selection.removeAllRanges();
|
172
|
-
|
173
|
-
// set the new range
|
174
|
-
selection.addRange(range);
|
175
|
-
}
|
176
|
-
};
|
177
|
-
var handleCancel = function handleCancel() {
|
178
|
-
refInput.current.textContent = value;
|
179
|
-
handleInput(value);
|
180
|
-
doSetEditing(false);
|
181
|
-
document.getSelection().removeAllRanges();
|
182
|
-
if (onCancel) {
|
183
|
-
onCancel(value);
|
184
|
-
}
|
185
|
-
};
|
186
|
-
var handleBlur = function handleBlur(ev) {
|
187
|
-
if (!ref.current.contains(ev.relatedTarget)) {
|
188
|
-
handleSave();
|
189
|
-
}
|
190
|
-
};
|
191
|
-
var handleKeyDown = function handleKeyDown(ev) {
|
192
|
-
switch (ev.key) {
|
193
|
-
case 'Enter':
|
194
|
-
ev.preventDefault();
|
195
|
-
refInput.current.blur(); // will cause save
|
196
|
-
break;
|
197
|
-
case 'Escape':
|
198
|
-
handleCancel();
|
199
|
-
break;
|
200
|
-
}
|
201
|
-
};
|
202
|
-
|
203
|
-
/*
|
204
|
-
The HTML is structured as follows:
|
205
|
-
<container>
|
206
|
-
<!-- margin left of input to match Carbon -->
|
207
|
-
<content-editable>
|
208
|
-
<-- margin right of input space for after-input-elements -->
|
209
|
-
<after-input-elements>
|
210
|
-
</container>
|
211
|
-
NOTE:
|
212
|
-
- An input is not used as this would not permit a heading tag e.g. <h2>.
|
213
|
-
- Some padding is added to the left 16px standard for a Carbon text input
|
214
|
-
- The after-input-elements are position absolute with a margin to on the input to reserve space. Using inline-flex
|
215
|
-
- does not measure space properly for the input otherwise.
|
216
|
-
- The content editable is not expected to change size when buttons are added, to ensure the text does not move space
|
217
|
-
is reserved up front for buttons and invalid icon. Mostly this is only noticed if the width of the component is not 100%.
|
218
|
-
which can be shown by setting inlineEditFullWidth to false in storybook.
|
219
|
-
In making content-editable behave like an input of type text we have to account for.
|
220
|
-
- Enforcing a single line
|
221
|
-
- Pasting of non-text e.g. html or text with carriage returns
|
222
|
-
- The padding and border not hiding typed in text.
|
223
|
-
- Placing the cursor at the start or end depending on area clicked (before for left-padding)
|
224
|
-
*/
|
225
|
-
|
226
|
-
var toolbarAnimation = true;
|
227
|
-
return (
|
228
|
-
/*#__PURE__*/
|
229
|
-
// eslint-disable-next-line
|
230
|
-
_react.default.createElement("div", {
|
231
|
-
className: (0, _classnames.default)(blockClass,
|
232
|
-
// Apply the block class to the main HTML element
|
233
|
-
className, // Apply any supplied class names to the main HTML element.
|
234
|
-
"".concat(blockClass, "--").concat(size), (_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "--disabled"), disabled), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "--editing"), editing), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "--invalid"), invalid), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "--light"), light), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "--overflows"), refInput.current && refInput.current.scrollWidth > refInput.current.offsetWidth), _cx)),
|
235
|
-
onClick: handleEdit // disabled eslint for click handler
|
236
|
-
,
|
237
|
-
onBlur: handleBlur,
|
238
|
-
ref: ref
|
239
|
-
}, /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, rest, (0, _devtools.getDevtoolsProps)(componentName), {
|
240
|
-
id: id,
|
241
|
-
size: size,
|
242
|
-
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)),
|
243
|
-
contentEditable: true,
|
244
|
-
"aria-label": labelText,
|
245
|
-
role: "textbox",
|
246
|
-
tabIndex: disabled ? -1 : 0,
|
247
|
-
onFocus: handleFocus,
|
248
|
-
onInput: handleInput,
|
249
|
-
onKeyDown: handleKeyDown,
|
250
|
-
onPaste: handlePaste,
|
251
|
-
suppressContentEditableWarning: true,
|
252
|
-
ref: refInput,
|
253
|
-
"data-placeholder": placeholder
|
254
|
-
}), value), /*#__PURE__*/_react.default.createElement("div", {
|
255
|
-
className: (0, _classnames.default)("".concat(blockClass, "__after-input-elements"))
|
256
|
-
// tabindex -1 fixes blur target test when clicking on after-input-elements background
|
257
|
-
,
|
258
|
-
tabIndex: "-1"
|
259
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
260
|
-
className: "".concat(blockClass, "__ellipsis"),
|
261
|
-
"aria-hidden": !editing
|
262
|
-
}, "\u2026"), /*#__PURE__*/_react.default.createElement("div", {
|
263
|
-
className: (0, _classnames.default)("".concat(blockClass, "__toolbar"), (_cx3 = {}, (0, _defineProperty2.default)(_cx3, "".concat(blockClass, "__toolbar--animation"), toolbarAnimation), (0, _defineProperty2.default)(_cx3, "".concat(blockClass, "__toolbar--saveable"), refInput.current && value !== internalValue), _cx3))
|
264
|
-
}, showValidation && /*#__PURE__*/_react.default.createElement("div", {
|
265
|
-
className: "".concat(blockClass, "__validation-icon")
|
266
|
-
}, validationIcon), editing ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, (0, _extends2.default)({
|
267
|
-
className: "".concat(blockClass, "__cancel"),
|
268
|
-
kind: "ghost",
|
269
|
-
hasIconOnly: true,
|
270
|
-
iconDescription: cancelDescription,
|
271
|
-
onClick: handleCancel,
|
272
|
-
renderIcon: _iconsReact.Close16
|
273
|
-
}, tipPositions.cancel)), /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, (0, _extends2.default)({
|
274
|
-
className: "".concat(blockClass, "__save"),
|
275
|
-
kind: "ghost",
|
276
|
-
hasIconOnly: true,
|
277
|
-
iconDescription: saveDescription,
|
278
|
-
onClick: handleSave,
|
279
|
-
renderIcon: _iconsReact.Checkmark16,
|
280
|
-
disabled: value === internalValue
|
281
|
-
}, tipPositions.save))) : /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, (0, _extends2.default)({
|
282
|
-
className: (0, _classnames.default)("".concat(blockClass, "__edit"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__edit--always-visible"), editAlwaysVisible)),
|
283
|
-
kind: "ghost",
|
284
|
-
hasIconOnly: true,
|
285
|
-
iconDescription: editDescription,
|
286
|
-
onClick: handleEdit,
|
287
|
-
renderIcon: disabled ? _iconsReact.EditOff16 : _iconsReact.Edit16,
|
288
|
-
disabled: disabled,
|
289
|
-
tabIndex: -1
|
290
|
-
}, tipPositions.edit)))), /*#__PURE__*/_react.default.createElement("div", {
|
291
|
-
className: (0, _classnames.default)("".concat(blockClass, "__disabled-cover"))
|
292
|
-
}), showValidation && validationText && validationText.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
|
293
|
-
className: "".concat(blockClass, "__validation-text ").concat(_settings.carbon.prefix, "--form-requirement")
|
294
|
-
}, validationText))
|
295
|
-
);
|
35
|
+
if (v2 === true) {
|
36
|
+
return /*#__PURE__*/_react.default.createElement(_InlineEditV2.InlineEditV2, props);
|
37
|
+
}
|
38
|
+
return /*#__PURE__*/_react.default.createElement(_InlineEditV.InlineEditV1, props);
|
296
39
|
});
|
297
|
-
|
298
|
-
// Return a placeholder if not released and not enabled by feature flag
|
299
40
|
exports.InlineEdit = InlineEdit;
|
300
41
|
exports.InlineEdit = InlineEdit = _settings.pkg.checkComponentEnabled(InlineEdit, componentName);
|
301
|
-
|
302
|
-
// The display name of the component, used by React. Note that displayName
|
303
|
-
// is used in preference to relying on function.name.
|
304
42
|
InlineEdit.displayName = componentName;
|
305
|
-
|
306
|
-
// The types and DocGen commentary for the component props,
|
307
|
-
// in alphabetical order (for consistency).
|
308
|
-
// See https://www.npmjs.com/package/prop-types#usage.
|
309
43
|
InlineEdit.propTypes = {
|
310
|
-
|
311
|
-
* buttonTooltipAlignment from the standard tooltip. Default center.
|
312
|
-
*
|
313
|
-
* Can be passed either as one of tooltip options or as an object specifying cancel, edit and save separately
|
314
|
-
*/
|
315
|
-
buttonTooltipAlignment: _propTypes.default.oneOfType([_propTypes.default.oneOf(['start', 'center', 'end']), _propTypes.default.shape({
|
316
|
-
cancel: _propTypes.default.oneOf(['start', 'center', 'end']),
|
317
|
-
edit: _propTypes.default.oneOf(['start', 'center', 'end']),
|
318
|
-
save: _propTypes.default.oneOf(['start', 'center', 'end'])
|
319
|
-
})]),
|
320
|
-
/**
|
321
|
-
* buttonTooltipPosition from the standard tooltip
|
322
|
-
*
|
323
|
-
* Can be passed either as one of tooltip options or as an object specifying cancel, edit and save separately
|
324
|
-
*/
|
325
|
-
buttonTooltipPosition: _propTypes.default.oneOfType([_propTypes.default.oneOf(['top', 'right', 'bottom', 'left']), _propTypes.default.shape({
|
326
|
-
cancel: _propTypes.default.oneOf(['top', 'right', 'bottom', 'left']),
|
327
|
-
edit: _propTypes.default.oneOf(['top', 'right', 'bottom', 'left']),
|
328
|
-
save: _propTypes.default.oneOf(['top', 'right', 'bottom', 'left'])
|
329
|
-
})]),
|
330
|
-
/**
|
331
|
-
* label for cancel button
|
332
|
-
*/
|
333
|
-
cancelDescription: _propTypes.default.string.isRequired,
|
334
|
-
/**
|
335
|
-
* Provide an optional class to be applied to the containing node.
|
336
|
-
*/
|
337
|
-
className: _propTypes.default.string,
|
338
|
-
/**
|
339
|
-
* disable edit
|
340
|
-
*/
|
341
|
-
disabled: _propTypes.default.bool,
|
342
|
-
/**
|
343
|
-
* By default the edit icon is shown on hover only.
|
344
|
-
*/
|
345
|
-
editAlwaysVisible: _propTypes.default.bool,
|
346
|
-
/**
|
347
|
-
* Label for the edit button
|
348
|
-
*/
|
349
|
-
editDescription: _propTypes.default.string.isRequired,
|
350
|
-
/**
|
351
|
-
* ID for inline edit
|
352
|
-
*/
|
353
|
-
id: _propTypes.default.string,
|
354
|
-
/**
|
355
|
-
* set invalid state for input
|
356
|
-
*/
|
357
|
-
invalid: _propTypes.default.bool,
|
358
|
-
/**
|
359
|
-
* text shown when invalid is true
|
360
|
-
*/
|
361
|
-
invalidText: _propTypes.default.string,
|
362
|
-
/**
|
363
|
-
* label for text input
|
364
|
-
*/
|
365
|
-
labelText: _propTypes.default.string,
|
366
|
-
/**
|
367
|
-
* change background to light version (mimic React TextInput)
|
368
|
-
*/
|
369
|
-
light: _propTypes.default.bool,
|
370
|
-
/**
|
371
|
-
* method called on cancel event
|
372
|
-
*/
|
373
|
-
onCancel: _propTypes.default.func,
|
374
|
-
/**
|
375
|
-
* method called on input event (it's a React thing onChange behaves like on input).
|
376
|
-
*
|
377
|
-
* NOTE: caller to handle invalid states and associated text
|
378
|
-
*/
|
379
|
-
onChange: _propTypes.default.func,
|
380
|
-
/**
|
381
|
-
* method called on change event
|
382
|
-
*
|
383
|
-
* NOTE: caller to handle invalid states and associated text
|
384
|
-
*/
|
385
|
-
onSave: _propTypes.default.func,
|
386
|
-
/**
|
387
|
-
* placeholder for text input
|
388
|
-
*/
|
389
|
-
placeholder: _propTypes.default.string,
|
390
|
-
/**
|
391
|
-
* label for save button
|
392
|
-
*/
|
393
|
-
saveDescription: _propTypes.default.string.isRequired,
|
394
|
-
/**
|
395
|
-
* vertical size of control
|
396
|
-
*/
|
397
|
-
size: _propTypes.default.oneOf(['sm', 'md', 'lg']),
|
398
|
-
/**
|
399
|
-
* initial/unedited value
|
400
|
-
*/
|
401
|
-
value: _propTypes.default.string
|
44
|
+
v2: _propTypes.default.bool
|
402
45
|
};
|