@carbon/ibm-products 1.35.1 → 1.35.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/css/index-full-carbon.css +257 -237
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +2 -2
  4. package/css/index-full-carbon.min.css.map +1 -1
  5. package/css/index-without-carbon-released-only.css.map +1 -1
  6. package/css/index-without-carbon-released-only.min.css.map +1 -1
  7. package/css/index-without-carbon.css +257 -237
  8. package/css/index-without-carbon.css.map +1 -1
  9. package/css/index-without-carbon.min.css +2 -2
  10. package/css/index-without-carbon.min.css.map +1 -1
  11. package/css/index.css +257 -237
  12. package/css/index.css.map +1 -1
  13. package/css/index.min.css +2 -2
  14. package/css/index.min.css.map +1 -1
  15. package/es/components/Datagrid/Datagrid/DatagridContent.js +1 -1
  16. package/es/components/Datagrid/Datagrid/DatagridRow.js +3 -3
  17. package/es/components/Datagrid/Datagrid/DatagridToolbar.js +4 -2
  18. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +1 -1
  19. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +4 -3
  20. package/es/components/Datagrid/useRowExpander.js +13 -1
  21. package/es/components/InlineEdit/InlineEdit.js +22 -385
  22. package/es/components/InlineEditV1/InlineEditV1.js +406 -0
  23. package/es/components/InlineEditV1/index.js +8 -0
  24. package/es/components/InlineEditV2/InlineEditV2.js +48 -21
  25. package/es/components/InlineEditV2/index.js +7 -0
  26. package/es/components/index.js +1 -1
  27. package/es/global/js/package-settings.js +1 -0
  28. package/lib/components/Datagrid/Datagrid/DatagridContent.js +1 -1
  29. package/lib/components/Datagrid/Datagrid/DatagridRow.js +3 -3
  30. package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +4 -2
  31. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +1 -1
  32. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +4 -3
  33. package/lib/components/Datagrid/useColumnOrder.js +2 -1
  34. package/lib/components/Datagrid/useRowExpander.js +13 -1
  35. package/lib/components/InlineEdit/InlineEdit.js +22 -379
  36. package/lib/components/InlineEditV1/InlineEditV1.js +403 -0
  37. package/lib/components/InlineEditV1/index.js +12 -0
  38. package/lib/components/InlineEditV2/InlineEditV2.js +38 -20
  39. package/lib/components/index.js +1 -1
  40. package/lib/global/js/package-settings.js +1 -0
  41. package/package.json +10 -10
  42. package/scss/components/Datagrid/styles/_useExpandedRow.scss +18 -0
  43. package/scss/components/{InlineEdit → InlineEditV1}/_index.scss +1 -1
  44. package/scss/components/{InlineEdit/_inline-edit.scss → InlineEditV1/_inline-edit-v1.scss} +0 -0
  45. package/scss/components/{InlineEdit → InlineEditV1}/_storybook-styles.scss +0 -0
  46. package/scss/components/InlineEditV2/_index.scss +1 -1
  47. package/scss/components/InlineEditV2/_inline-edit-v2.scss +5 -1
  48. package/scss/components/InlineEditV2/_storybook-styles.scss +6 -0
  49. package/scss/components/_index-released-only.scss +1 -1
  50. package/scss/components/_index.scss +2 -1
@@ -0,0 +1,403 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof3 = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.InlineEditV1 = void 0;
9
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
+ 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
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
14
+ var _react = _interopRequireWildcard(require("react"));
15
+ var _propTypes = _interopRequireDefault(require("prop-types"));
16
+ var _classnames = _interopRequireDefault(require("classnames"));
17
+ var _devtools = require("../../global/js/utils/devtools");
18
+ var _settings = require("../../settings");
19
+ var _carbonComponentsReact = require("carbon-components-react");
20
+ var _iconsReact = require("@carbon/icons-react");
21
+ var _excluded = ["buttonTooltipAlignment", "buttonTooltipPosition", "cancelDescription", "className", "disabled", "editAlwaysVisible", "editDescription", "id", "invalid", "invalidText", "labelText", "light", "onCancel", "onSave", "onChange", "placeholder", "saveDescription", "size", "value"];
22
+ 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 || _typeof3(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; }
24
+ // The block part of our conventional BEM class names (blockClass__E--M).
25
+ var blockClass = "".concat(_settings.pkg.prefix, "--inline-edit");
26
+ var componentName = 'InlineEditV1';
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
+ console.warn('the v1 version of this component is being deprecated. please switch to the v2 component as soon as possible.');
38
+
39
+ /**
40
+ * TODO: A description of the component.
41
+ */
42
+ var InlineEditV1 = /*#__PURE__*/_react.default.forwardRef(function (_ref, refIn) {
43
+ var _cx, _refInput$current, _refInput$current$tex, _cx3;
44
+ var buttonTooltipAlignment = _ref.buttonTooltipAlignment,
45
+ buttonTooltipPosition = _ref.buttonTooltipPosition,
46
+ cancelDescription = _ref.cancelDescription,
47
+ className = _ref.className,
48
+ disabled = _ref.disabled,
49
+ editAlwaysVisible = _ref.editAlwaysVisible,
50
+ editDescription = _ref.editDescription,
51
+ id = _ref.id,
52
+ invalid = _ref.invalid,
53
+ invalidText = _ref.invalidText,
54
+ labelText = _ref.labelText,
55
+ _ref$light = _ref.light,
56
+ light = _ref$light === void 0 ? defaults.light : _ref$light,
57
+ onCancel = _ref.onCancel,
58
+ onSave = _ref.onSave,
59
+ onChange = _ref.onChange,
60
+ placeholder = _ref.placeholder,
61
+ saveDescription = _ref.saveDescription,
62
+ _ref$size = _ref.size,
63
+ size = _ref$size === void 0 ? defaults.size : _ref$size,
64
+ value = _ref.value,
65
+ rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
66
+ var refInput = (0, _react.useRef)({
67
+ textContent: value
68
+ });
69
+ var localRef = (0, _react.useRef)(null);
70
+ var ref = refIn || localRef;
71
+ var _useState = (0, _react.useState)(false),
72
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
73
+ editing = _useState2[0],
74
+ setEditing = _useState2[1];
75
+ var _useState3 = (0, _react.useState)(value),
76
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
77
+ internalValue = _useState4[0],
78
+ setInternalValue = _useState4[1];
79
+ var showValidation = invalid; // || warn;
80
+ var validationText = invalidText; // || warnText;
81
+ var validationIcon = showValidation ? /*#__PURE__*/_react.default.createElement(_iconsReact.WarningFilled16, null) : null;
82
+
83
+ // sanitize the tooltip values
84
+ var alignIsObject = (0, _typeof2.default)(buttonTooltipAlignment) === 'object';
85
+ var directionIsObject = (0, _typeof2.default)(buttonTooltipPosition) === 'object';
86
+ var tipPositions = buttons.reduce(function (acc, button) {
87
+ var _ref2, _ref3;
88
+ var tooltipAlignment = (_ref2 = alignIsObject ? buttonTooltipAlignment[button] : buttonTooltipAlignment) !== null && _ref2 !== void 0 ? _ref2 : defaults.buttonTooltipAlignment;
89
+ var tooltipPosition = (_ref3 = directionIsObject ? buttonTooltipPosition[button] : buttonTooltipPosition) !== null && _ref3 !== void 0 ? _ref3 : defaults.buttonTooltipPosition;
90
+ acc[button] = {
91
+ tooltipAlignment: tooltipAlignment,
92
+ tooltipPosition: tooltipPosition
93
+ };
94
+ return acc;
95
+ }, {});
96
+ var doSetEditing = function doSetEditing(value) {
97
+ if (value === false) {
98
+ // move scroll to start
99
+ refInput.current.scrollLeft = 0;
100
+ }
101
+ setEditing(!disabled && value);
102
+ };
103
+ var handleEdit = function handleEdit(ev) {
104
+ /* istanbul ignore else */
105
+ if (!disabled) {
106
+ var rightOfInput = ev.currentTarget.classList.contains("".concat(blockClass, "__edit")) || ev.target.classList.contains("".concat(blockClass, "__after-input-elements"));
107
+ var leftOfInput = ev.currentTarget = ev.target.classList.contains("".concat(blockClass));
108
+
109
+ // clicking on the content editable element should not set either of these to true
110
+ if (rightOfInput || leftOfInput) {
111
+ doSetEditing(true);
112
+ setTimeout(function () {
113
+ refInput.current.focus();
114
+ // select all the content
115
+ document.getSelection().selectAllChildren(refInput.current);
116
+ if (rightOfInput) {
117
+ document.getSelection().collapseToEnd();
118
+ refInput.current.scrollLeft = 9999; // never going to get there but ensures at end.
119
+ } else {
120
+ document.getSelection().collapseToStart();
121
+ refInput.current.scrollLeft = 0; // scroll to start
122
+ }
123
+ }, 0);
124
+ }
125
+ }
126
+ };
127
+ var handleFocus = function handleFocus(ev) {
128
+ ev.preventDefault();
129
+ if (!editing && ev.target.classList.contains("".concat(blockClass, "__input"))) {
130
+ doSetEditing(true);
131
+ }
132
+ };
133
+ var handleSave = function handleSave() {
134
+ doSetEditing(false);
135
+ document.getSelection().removeAllRanges();
136
+ if (onSave) {
137
+ onSave(refInput.current.textContent);
138
+ }
139
+ };
140
+ var handleInput = function handleInput() {
141
+ setInternalValue(refInput.current.textContent);
142
+ if (onChange) {
143
+ onChange(refInput.current.textContent);
144
+ }
145
+ };
146
+
147
+ // pasting into contentEditable not supported by userEvent
148
+ var handlePaste = /* istanbul ignore next */function handlePaste(ev) {
149
+ ev.preventDefault();
150
+
151
+ // Get clipboard as plain text
152
+ var text = (ev.clipboardData || window.clipboardData).getData('text/plain');
153
+
154
+ // remove \n
155
+ var sanitizedText = text.replaceAll(/\n/g, '') // remove carriage returns
156
+ .replaceAll(/\t/g, ' '); // replace tab with two spaces
157
+
158
+ if (document.queryCommandSupported('insertText')) {
159
+ document.execCommand('insertText', false, sanitizedText);
160
+ } else {
161
+ // Insert text at the current position of caret
162
+ var range = document.getSelection().getRangeAt(0);
163
+ range.deleteContents();
164
+ var textNode = document.createTextNode(sanitizedText);
165
+ range.insertNode(textNode);
166
+ // move selection end of textNode
167
+ range.selectNodeContents(textNode);
168
+ range.collapse(false);
169
+
170
+ // remove existing range
171
+ var selection = document.getSelection();
172
+ selection.removeAllRanges();
173
+
174
+ // set the new range
175
+ selection.addRange(range);
176
+ }
177
+ };
178
+ var handleCancel = function handleCancel() {
179
+ refInput.current.textContent = value;
180
+ handleInput(value);
181
+ doSetEditing(false);
182
+ document.getSelection().removeAllRanges();
183
+ if (onCancel) {
184
+ onCancel(value);
185
+ }
186
+ };
187
+ var handleBlur = function handleBlur(ev) {
188
+ if (!ref.current.contains(ev.relatedTarget)) {
189
+ handleSave();
190
+ }
191
+ };
192
+ var handleKeyDown = function handleKeyDown(ev) {
193
+ switch (ev.key) {
194
+ case 'Enter':
195
+ ev.preventDefault();
196
+ refInput.current.blur(); // will cause save
197
+ break;
198
+ case 'Escape':
199
+ handleCancel();
200
+ break;
201
+ }
202
+ };
203
+
204
+ /*
205
+ The HTML is structured as follows:
206
+ <container>
207
+ <!-- margin left of input to match Carbon -->
208
+ <content-editable>
209
+ <-- margin right of input space for after-input-elements -->
210
+ <after-input-elements>
211
+ </container>
212
+ NOTE:
213
+ - An input is not used as this would not permit a heading tag e.g. <h2>.
214
+ - Some padding is added to the left 16px standard for a Carbon text input
215
+ - The after-input-elements are position absolute with a margin to on the input to reserve space. Using inline-flex
216
+ - does not measure space properly for the input otherwise.
217
+ - The content editable is not expected to change size when buttons are added, to ensure the text does not move space
218
+ is reserved up front for buttons and invalid icon. Mostly this is only noticed if the width of the component is not 100%.
219
+ which can be shown by setting inlineEditFullWidth to false in storybook.
220
+ In making content-editable behave like an input of type text we have to account for.
221
+ - Enforcing a single line
222
+ - Pasting of non-text e.g. html or text with carriage returns
223
+ - The padding and border not hiding typed in text.
224
+ - Placing the cursor at the start or end depending on area clicked (before for left-padding)
225
+ */
226
+
227
+ var toolbarAnimation = true;
228
+ return (
229
+ /*#__PURE__*/
230
+ // eslint-disable-next-line
231
+ _react.default.createElement("div", {
232
+ className: (0, _classnames.default)(blockClass,
233
+ // Apply the block class to the main HTML element
234
+ className, // Apply any supplied class names to the main HTML element.
235
+ "".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)),
236
+ onClick: handleEdit // disabled eslint for click handler
237
+ ,
238
+ onBlur: handleBlur,
239
+ ref: ref
240
+ }, /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, rest, (0, _devtools.getDevtoolsProps)(componentName), {
241
+ id: id,
242
+ size: size,
243
+ 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)),
244
+ contentEditable: true,
245
+ "aria-label": labelText,
246
+ role: "textbox",
247
+ tabIndex: disabled ? -1 : 0,
248
+ onFocus: handleFocus,
249
+ onInput: handleInput,
250
+ onKeyDown: handleKeyDown,
251
+ onPaste: handlePaste,
252
+ suppressContentEditableWarning: true,
253
+ ref: refInput,
254
+ "data-placeholder": placeholder
255
+ }), value), /*#__PURE__*/_react.default.createElement("div", {
256
+ className: (0, _classnames.default)("".concat(blockClass, "__after-input-elements"))
257
+ // tabindex -1 fixes blur target test when clicking on after-input-elements background
258
+ ,
259
+ tabIndex: "-1"
260
+ }, /*#__PURE__*/_react.default.createElement("div", {
261
+ className: "".concat(blockClass, "__ellipsis"),
262
+ "aria-hidden": !editing
263
+ }, "\u2026"), /*#__PURE__*/_react.default.createElement("div", {
264
+ 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))
265
+ }, showValidation && /*#__PURE__*/_react.default.createElement("div", {
266
+ className: "".concat(blockClass, "__validation-icon")
267
+ }, validationIcon), editing ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, (0, _extends2.default)({
268
+ className: "".concat(blockClass, "__cancel"),
269
+ kind: "ghost",
270
+ hasIconOnly: true,
271
+ iconDescription: cancelDescription,
272
+ onClick: handleCancel,
273
+ renderIcon: _iconsReact.Close16
274
+ }, tipPositions.cancel)), /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, (0, _extends2.default)({
275
+ className: "".concat(blockClass, "__save"),
276
+ kind: "ghost",
277
+ hasIconOnly: true,
278
+ iconDescription: saveDescription,
279
+ onClick: handleSave,
280
+ renderIcon: _iconsReact.Checkmark16,
281
+ disabled: value === internalValue
282
+ }, tipPositions.save))) : /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, (0, _extends2.default)({
283
+ className: (0, _classnames.default)("".concat(blockClass, "__edit"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__edit--always-visible"), editAlwaysVisible)),
284
+ kind: "ghost",
285
+ hasIconOnly: true,
286
+ iconDescription: editDescription,
287
+ onClick: handleEdit,
288
+ renderIcon: disabled ? _iconsReact.EditOff16 : _iconsReact.Edit16,
289
+ disabled: disabled,
290
+ tabIndex: -1
291
+ }, tipPositions.edit)))), /*#__PURE__*/_react.default.createElement("div", {
292
+ className: (0, _classnames.default)("".concat(blockClass, "__disabled-cover"))
293
+ }), showValidation && validationText && validationText.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
294
+ className: "".concat(blockClass, "__validation-text ").concat(_settings.carbon.prefix, "--form-requirement")
295
+ }, validationText))
296
+ );
297
+ });
298
+
299
+ // Return a placeholder if not released and not enabled by feature flag
300
+ exports.InlineEditV1 = InlineEditV1;
301
+ exports.InlineEditV1 = InlineEditV1 = _settings.pkg.checkComponentEnabled(InlineEditV1, componentName);
302
+
303
+ // The display name of the component, used by React. Note that displayName
304
+ // is used in preference to relying on function.name.
305
+ InlineEditV1.displayName = componentName;
306
+
307
+ // The types and DocGen commentary for the component props,
308
+ // in alphabetical order (for consistency).
309
+ // See https://www.npmjs.com/package/prop-types#usage.
310
+ InlineEditV1.propTypes = {
311
+ /**
312
+ * buttonTooltipAlignment from the standard tooltip. Default center.
313
+ *
314
+ * Can be passed either as one of tooltip options or as an object specifying cancel, edit and save separately
315
+ */
316
+ buttonTooltipAlignment: _propTypes.default.oneOfType([_propTypes.default.oneOf(['start', 'center', 'end']), _propTypes.default.shape({
317
+ cancel: _propTypes.default.oneOf(['start', 'center', 'end']),
318
+ edit: _propTypes.default.oneOf(['start', 'center', 'end']),
319
+ save: _propTypes.default.oneOf(['start', 'center', 'end'])
320
+ })]),
321
+ /**
322
+ * buttonTooltipPosition from the standard tooltip
323
+ *
324
+ * Can be passed either as one of tooltip options or as an object specifying cancel, edit and save separately
325
+ */
326
+ buttonTooltipPosition: _propTypes.default.oneOfType([_propTypes.default.oneOf(['top', 'right', 'bottom', 'left']), _propTypes.default.shape({
327
+ cancel: _propTypes.default.oneOf(['top', 'right', 'bottom', 'left']),
328
+ edit: _propTypes.default.oneOf(['top', 'right', 'bottom', 'left']),
329
+ save: _propTypes.default.oneOf(['top', 'right', 'bottom', 'left'])
330
+ })]),
331
+ /**
332
+ * label for cancel button
333
+ */
334
+ cancelDescription: _propTypes.default.string.isRequired,
335
+ /**
336
+ * Provide an optional class to be applied to the containing node.
337
+ */
338
+ className: _propTypes.default.string,
339
+ /**
340
+ * disable edit
341
+ */
342
+ disabled: _propTypes.default.bool,
343
+ /**
344
+ * By default the edit icon is shown on hover only.
345
+ */
346
+ editAlwaysVisible: _propTypes.default.bool,
347
+ /**
348
+ * Label for the edit button
349
+ */
350
+ editDescription: _propTypes.default.string.isRequired,
351
+ /**
352
+ * ID for inline edit
353
+ */
354
+ id: _propTypes.default.string,
355
+ /**
356
+ * set invalid state for input
357
+ */
358
+ invalid: _propTypes.default.bool,
359
+ /**
360
+ * text shown when invalid is true
361
+ */
362
+ invalidText: _propTypes.default.string,
363
+ /**
364
+ * label for text input
365
+ */
366
+ labelText: _propTypes.default.string,
367
+ /**
368
+ * change background to light version (mimic React TextInput)
369
+ */
370
+ light: _propTypes.default.bool,
371
+ /**
372
+ * method called on cancel event
373
+ */
374
+ onCancel: _propTypes.default.func,
375
+ /**
376
+ * method called on input event (it's a React thing onChange behaves like on input).
377
+ *
378
+ * NOTE: caller to handle invalid states and associated text
379
+ */
380
+ onChange: _propTypes.default.func,
381
+ /**
382
+ * method called on change event
383
+ *
384
+ * NOTE: caller to handle invalid states and associated text
385
+ */
386
+ onSave: _propTypes.default.func,
387
+ /**
388
+ * placeholder for text input
389
+ */
390
+ placeholder: _propTypes.default.string,
391
+ /**
392
+ * label for save button
393
+ */
394
+ saveDescription: _propTypes.default.string.isRequired,
395
+ /**
396
+ * vertical size of control
397
+ */
398
+ size: _propTypes.default.oneOf(['sm', 'md', 'lg']),
399
+ /**
400
+ * initial/unedited value
401
+ */
402
+ value: _propTypes.default.string
403
+ };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "InlineEditV1", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _InlineEditV.InlineEditV1;
10
+ }
11
+ });
12
+ var _InlineEditV = require("./InlineEditV1");
@@ -17,22 +17,21 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
17
17
  var _iconsReact = require("@carbon/icons-react");
18
18
  var _settings = require("../../settings");
19
19
  var _devtools = require("../../global/js/utils/devtools");
20
- var _excluded = ["cancelLabel", "editLabel", "invalid", "invalidLabel", "onCancel", "onChange", "onSave", "readOnly", "readOnlyLabel", "saveLabel", "value"];
20
+ var _excluded = ["cancelLabel", "editLabel", "id", "invalid", "invalidLabel", "labelText", "onCancel", "onChange", "onSave", "saveLabel", "value"];
21
21
  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); }
22
22
  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; }
23
23
  var componentName = 'InlineEditV2';
24
24
  var blockClass = "".concat(_settings.pkg.prefix, "--inline-edit-v2");
25
25
  var InlineEditV2 = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
26
- var _cx;
27
26
  var cancelLabel = _ref.cancelLabel,
28
27
  editLabel = _ref.editLabel,
28
+ id = _ref.id,
29
29
  invalid = _ref.invalid,
30
30
  invalidLabel = _ref.invalidLabel,
31
+ labelText = _ref.labelText,
31
32
  onCancel = _ref.onCancel,
32
33
  onChange = _ref.onChange,
33
34
  onSave = _ref.onSave,
34
- readOnly = _ref.readOnly,
35
- readOnlyLabel = _ref.readOnlyLabel,
36
35
  saveLabel = _ref.saveLabel,
37
36
  value = _ref.value,
38
37
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
@@ -69,9 +68,10 @@ var InlineEditV2 = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
69
68
  onChange(target.value);
70
69
  };
71
70
  var onFocusHandler = function onFocusHandler(e) {
72
- if (readOnly) {
73
- return;
74
- }
71
+ // if (readOnly) {
72
+ // return;
73
+ // }
74
+
75
75
  if (!isTargetingChild(e)) {
76
76
  inputRef.current.focus();
77
77
  setFocused(true);
@@ -89,7 +89,8 @@ var InlineEditV2 = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
89
89
  onCancel(initialValue);
90
90
  };
91
91
  var onBlurHandler = function onBlurHandler(e) {
92
- if (readOnly || escaping.current) {
92
+ // if (readOnly || escaping.current) {
93
+ if (escaping.current) {
93
94
  return;
94
95
  }
95
96
  if (!isTargetingChild(e)) {
@@ -128,16 +129,21 @@ var InlineEditV2 = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
128
129
  return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, rest, {
129
130
  ref: ref
130
131
  }, (0, _devtools.getDevtoolsProps)(componentName)), /*#__PURE__*/_react.default.createElement("div", {
131
- className: (0, _classnames.default)(blockClass, (_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "-focused"), focused), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "-readonly"), readOnly), _cx)),
132
+ className: (0, _classnames.default)(blockClass, (0, _defineProperty2.default)({}, "".concat(blockClass, "-focused"), focused)),
132
133
  onFocus: onFocusHandler,
133
134
  onBlur: onBlurHandler
134
- }, /*#__PURE__*/_react.default.createElement("input", {
135
+ }, /*#__PURE__*/_react.default.createElement("label", {
136
+ className: "".concat(blockClass, "__text-input-label"),
137
+ htmlFor: id
138
+ }, labelText), /*#__PURE__*/_react.default.createElement("input", {
139
+ id: id,
135
140
  className: (0, _classnames.default)("".concat(blockClass, "__text-input"), "".concat(_settings.carbon.prefix, "--text-input"), "".concat(_settings.carbon.prefix, "--text-input--sm")),
136
141
  type: "text",
137
142
  value: value,
138
143
  onChange: onChangeHandler,
139
- ref: inputRef,
140
- readOnly: readOnly,
144
+ ref: inputRef
145
+ // readOnly={readOnly}
146
+ ,
141
147
  onKeyDown: onKeyHandler
142
148
  }), focused ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, invalid && /*#__PURE__*/_react.default.createElement(_iconsReact.WarningFilled16, {
143
149
  className: "".concat(blockClass, "__warning-icon")
@@ -164,10 +170,14 @@ var InlineEditV2 = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
164
170
  disabled: !canSave
165
171
  })) : /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, {
166
172
  className: "".concat(blockClass, "__btn ").concat(blockClass, "__btn-edit"),
167
- hasIconOnly: true,
168
- renderIcon: readOnly ? _iconsReact.EditOff24 : _iconsReact.Edit24,
169
- size: "sm",
170
- iconDescription: readOnly ? readOnlyLabel : editLabel,
173
+ hasIconOnly: true
174
+ // renderIcon={readOnly ? EditOff24 : Edit24}
175
+ ,
176
+ renderIcon: _iconsReact.Edit24,
177
+ size: "sm"
178
+ // iconDescription={readOnly ? readOnlyLabel : editLabel}
179
+ ,
180
+ iconDescription: editLabel,
171
181
  onClick: onFocusHandler,
172
182
  kind: "ghost",
173
183
  tabIndex: 0,
@@ -188,6 +198,10 @@ InlineEditV2.propTypes = {
188
198
  * label for edit button
189
199
  */
190
200
  editLabel: _propTypes.default.string.isRequired,
201
+ /**
202
+ * Specify a custom id for the input
203
+ */
204
+ id: _propTypes.default.string.isRequired,
191
205
  /**
192
206
  * determines if the input is invalid
193
207
  */
@@ -196,6 +210,10 @@ InlineEditV2.propTypes = {
196
210
  * text that is displayed if the input is invalid
197
211
  */
198
212
  invalidLabel: _propTypes.default.string,
213
+ /**
214
+ * Provide the text that will be read by a screen reader when visiting this control
215
+ */
216
+ labelText: _propTypes.default.string.isRequired,
199
217
  /**
200
218
  * handler that is called when the cancel button is pressed or when the user removes focus from the input and there is no new value
201
219
  */
@@ -211,11 +229,11 @@ InlineEditV2.propTypes = {
211
229
  /**
212
230
  * determines if the input is in readOnly mode
213
231
  */
214
- readOnly: _propTypes.default.bool,
232
+ // readOnly: PropTypes.bool,
215
233
  /**
216
234
  * label for the edit button that displays when in read only mode
217
235
  */
218
- readOnlyLabel: _propTypes.default.string,
236
+ // readOnlyLabel: PropTypes.string,
219
237
  /**
220
238
  * label for save button
221
239
  */
@@ -227,6 +245,6 @@ InlineEditV2.propTypes = {
227
245
  };
228
246
  InlineEditV2.defaultProps = {
229
247
  invalid: false,
230
- invalidLabel: '',
231
- readOnly: false
248
+ invalidLabel: ''
249
+ // readOnly: false,
232
250
  };
@@ -472,11 +472,11 @@ var _UserProfileImage = require("./UserProfileImage");
472
472
  var _WebTerminal = require("./WebTerminal");
473
473
  var _EditSidePanel = require("./EditSidePanel");
474
474
  var _OptionsTile = require("./OptionsTile");
475
- var _InlineEdit = require("./InlineEdit");
476
475
  var _DataSpreadsheet = require("./DataSpreadsheet");
477
476
  var _Datagrid = require("./Datagrid");
478
477
  var _EditTearsheet = require("./EditTearsheet");
479
478
  var _EditTearsheetNarrow = require("./EditTearsheetNarrow");
480
479
  var _EditFullPage = require("./EditFullPage");
481
480
  var _EditUpdateCards = require("./EditUpdateCards");
481
+ var _InlineEdit = require("./InlineEdit");
482
482
  var _InlineEditV = require("./InlineEditV2");
@@ -34,6 +34,7 @@ var defaults = {
34
34
  HTTPErrorOther: true,
35
35
  ImportModal: true,
36
36
  InlineEdit: true,
37
+ InlineEditV1: true,
37
38
  NotificationsPanel: true,
38
39
  NoDataEmptyState: true,
39
40
  NoTagsEmptyState: true,
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.35.1",
4
+ "version": "1.35.2",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -52,26 +52,26 @@
52
52
  },
53
53
  "devDependencies": {
54
54
  "@babel/cli": "^7.19.3",
55
- "@babel/core": "^7.19.3",
56
- "babel-preset-ibm-cloud-cognitive": "^0.14.22",
55
+ "@babel/core": "^7.19.6",
56
+ "babel-preset-ibm-cloud-cognitive": "^0.14.23",
57
57
  "chalk": "^4.1.2",
58
58
  "change-case": "^4.1.2",
59
59
  "copyfiles": "^2.4.1",
60
60
  "cross-env": "^7.0.3",
61
61
  "fs-extra": "^10.1.0",
62
62
  "glob": "^8.0.3",
63
- "jest": "^29.2.0",
64
- "jest-config-ibm-cloud-cognitive": "^0.24.8",
65
- "jest-environment-jsdom": "^29.2.0",
63
+ "jest": "^29.2.2",
64
+ "jest-config-ibm-cloud-cognitive": "^0.24.9",
65
+ "jest-environment-jsdom": "^29.2.2",
66
66
  "namor": "^1.1.2",
67
- "npm-check-updates": "^16.3.11",
67
+ "npm-check-updates": "^16.3.16",
68
68
  "npm-run-all": "^4.1.5",
69
69
  "rimraf": "^3.0.2",
70
70
  "sass": "^1.55.0",
71
71
  "yargs": "^17.6.0"
72
72
  },
73
73
  "dependencies": {
74
- "@babel/runtime": "^7.19.4",
74
+ "@babel/runtime": "^7.20.0",
75
75
  "@carbon/telemetry": "^0.1.0",
76
76
  "framer-motion": "^6.5.1",
77
77
  "immutability-helper": "^3.1.1",
@@ -79,7 +79,7 @@
79
79
  "react-dnd-html5-backend": "^15.1.3",
80
80
  "react-resize-detector": "^7.1.2",
81
81
  "react-table": "^7.8.0",
82
- "react-window": "^1.8.7"
82
+ "react-window": "^1.8.8"
83
83
  },
84
84
  "peerDependencies": {
85
85
  "@carbon/colors": "^10.37.1",
@@ -95,5 +95,5 @@
95
95
  "react": "^16.8.6 || ^17.0.1",
96
96
  "react-dom": "^16.8.6 || ^17.0.1"
97
97
  },
98
- "gitHead": "fc83f9206790480bfdb2a6cf5b7c26e7f7f4fb37"
98
+ "gitHead": "36dbe6575fb43b86043dae507ae9f31f680254e4"
99
99
  }
@@ -35,3 +35,21 @@
35
35
  width: 100%;
36
36
  @include shared-pseudo-styles();
37
37
  }
38
+
39
+ .#{$block-class}__carbon-row.#{$block-class}__carbon-row-expandable
40
+ .#{$block-class}__cell.#{$block-class}__expandable-row-cell {
41
+ padding: $spacing-03;
42
+ padding-right: 0;
43
+ }
44
+
45
+ .#{$block-class}__row-expander.#{$carbon-prefix}--btn {
46
+ display: flex;
47
+ width: $spacing-07;
48
+ height: $spacing-07;
49
+ min-height: $spacing-07;
50
+ justify-content: center;
51
+ padding: 0;
52
+ .#{$block-class}__row-expander--icon {
53
+ fill: $ui-05;
54
+ }
55
+ }
@@ -5,4 +5,4 @@
5
5
  // LICENSE file in the root directory of this source tree.
6
6
  //
7
7
 
8
- @import './inline-edit';
8
+ @import './inline-edit-v1';