@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,406 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ import _typeof from "@babel/runtime/helpers/typeof";
4
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
5
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
6
+ var _excluded = ["buttonTooltipAlignment", "buttonTooltipPosition", "cancelDescription", "className", "disabled", "editAlwaysVisible", "editDescription", "id", "invalid", "invalidText", "labelText", "light", "onCancel", "onSave", "onChange", "placeholder", "saveDescription", "size", "value"];
7
+ /**
8
+ * Copyright IBM Corp. 2022, 2022
9
+ *
10
+ * This source code is licensed under the Apache-2.0 license found in the
11
+ * LICENSE file in the root directory of this source tree.
12
+ */
13
+
14
+ // Import portions of React that are needed.
15
+ import React, { useRef, useState } from 'react';
16
+
17
+ // Other standard imports.
18
+ import PropTypes from 'prop-types';
19
+ import cx from 'classnames';
20
+ import { getDevtoolsProps } from '../../global/js/utils/devtools';
21
+ import { pkg, carbon } from '../../settings';
22
+
23
+ // Carbon and package components we use.
24
+ /* TODO: @import(s) of carbon components and other package components. */
25
+ import { Button } from 'carbon-components-react';
26
+ import { Close16, Edit16, EditOff16, Checkmark16, WarningFilled16 } from '@carbon/icons-react';
27
+
28
+ // The block part of our conventional BEM class names (blockClass__E--M).
29
+ var blockClass = "".concat(pkg.prefix, "--inline-edit");
30
+ var componentName = 'InlineEditV1';
31
+ // NOTE: the component SCSS is not imported here: it is rolled up separately.
32
+
33
+ var defaults = {
34
+ buttonTooltipAlignment: 'center',
35
+ buttonTooltipPosition: 'top',
36
+ light: true,
37
+ // defaults to true to reflect design
38
+ size: 'md'
39
+ };
40
+ var buttons = ['cancel', 'edit', 'save'];
41
+ console.warn('the v1 version of this component is being deprecated. please switch to the v2 component as soon as possible.');
42
+
43
+ /**
44
+ * TODO: A description of the component.
45
+ */
46
+ export var InlineEditV1 = /*#__PURE__*/React.forwardRef(function (_ref, refIn) {
47
+ var _cx, _refInput$current, _refInput$current$tex, _cx3;
48
+ var buttonTooltipAlignment = _ref.buttonTooltipAlignment,
49
+ buttonTooltipPosition = _ref.buttonTooltipPosition,
50
+ cancelDescription = _ref.cancelDescription,
51
+ className = _ref.className,
52
+ disabled = _ref.disabled,
53
+ editAlwaysVisible = _ref.editAlwaysVisible,
54
+ editDescription = _ref.editDescription,
55
+ id = _ref.id,
56
+ invalid = _ref.invalid,
57
+ invalidText = _ref.invalidText,
58
+ labelText = _ref.labelText,
59
+ _ref$light = _ref.light,
60
+ light = _ref$light === void 0 ? defaults.light : _ref$light,
61
+ onCancel = _ref.onCancel,
62
+ onSave = _ref.onSave,
63
+ onChange = _ref.onChange,
64
+ placeholder = _ref.placeholder,
65
+ saveDescription = _ref.saveDescription,
66
+ _ref$size = _ref.size,
67
+ size = _ref$size === void 0 ? defaults.size : _ref$size,
68
+ value = _ref.value,
69
+ rest = _objectWithoutProperties(_ref, _excluded);
70
+ var refInput = useRef({
71
+ textContent: value
72
+ });
73
+ var localRef = useRef(null);
74
+ var ref = refIn || localRef;
75
+ var _useState = useState(false),
76
+ _useState2 = _slicedToArray(_useState, 2),
77
+ editing = _useState2[0],
78
+ setEditing = _useState2[1];
79
+ var _useState3 = useState(value),
80
+ _useState4 = _slicedToArray(_useState3, 2),
81
+ internalValue = _useState4[0],
82
+ setInternalValue = _useState4[1];
83
+ var showValidation = invalid; // || warn;
84
+ var validationText = invalidText; // || warnText;
85
+ var validationIcon = showValidation ? /*#__PURE__*/React.createElement(WarningFilled16, null) : null;
86
+
87
+ // sanitize the tooltip values
88
+ var alignIsObject = _typeof(buttonTooltipAlignment) === 'object';
89
+ var directionIsObject = _typeof(buttonTooltipPosition) === 'object';
90
+ var tipPositions = buttons.reduce(function (acc, button) {
91
+ var _ref2, _ref3;
92
+ var tooltipAlignment = (_ref2 = alignIsObject ? buttonTooltipAlignment[button] : buttonTooltipAlignment) !== null && _ref2 !== void 0 ? _ref2 : defaults.buttonTooltipAlignment;
93
+ var tooltipPosition = (_ref3 = directionIsObject ? buttonTooltipPosition[button] : buttonTooltipPosition) !== null && _ref3 !== void 0 ? _ref3 : defaults.buttonTooltipPosition;
94
+ acc[button] = {
95
+ tooltipAlignment: tooltipAlignment,
96
+ tooltipPosition: tooltipPosition
97
+ };
98
+ return acc;
99
+ }, {});
100
+ var doSetEditing = function doSetEditing(value) {
101
+ if (value === false) {
102
+ // move scroll to start
103
+ refInput.current.scrollLeft = 0;
104
+ }
105
+ setEditing(!disabled && value);
106
+ };
107
+ var handleEdit = function handleEdit(ev) {
108
+ /* istanbul ignore else */
109
+ if (!disabled) {
110
+ var rightOfInput = ev.currentTarget.classList.contains("".concat(blockClass, "__edit")) || ev.target.classList.contains("".concat(blockClass, "__after-input-elements"));
111
+ var leftOfInput = ev.currentTarget = ev.target.classList.contains("".concat(blockClass));
112
+
113
+ // clicking on the content editable element should not set either of these to true
114
+ if (rightOfInput || leftOfInput) {
115
+ doSetEditing(true);
116
+ setTimeout(function () {
117
+ refInput.current.focus();
118
+ // select all the content
119
+ document.getSelection().selectAllChildren(refInput.current);
120
+ if (rightOfInput) {
121
+ document.getSelection().collapseToEnd();
122
+ refInput.current.scrollLeft = 9999; // never going to get there but ensures at end.
123
+ } else {
124
+ document.getSelection().collapseToStart();
125
+ refInput.current.scrollLeft = 0; // scroll to start
126
+ }
127
+ }, 0);
128
+ }
129
+ }
130
+ };
131
+ var handleFocus = function handleFocus(ev) {
132
+ ev.preventDefault();
133
+ if (!editing && ev.target.classList.contains("".concat(blockClass, "__input"))) {
134
+ doSetEditing(true);
135
+ }
136
+ };
137
+ var handleSave = function handleSave() {
138
+ doSetEditing(false);
139
+ document.getSelection().removeAllRanges();
140
+ if (onSave) {
141
+ onSave(refInput.current.textContent);
142
+ }
143
+ };
144
+ var handleInput = function handleInput() {
145
+ setInternalValue(refInput.current.textContent);
146
+ if (onChange) {
147
+ onChange(refInput.current.textContent);
148
+ }
149
+ };
150
+
151
+ // pasting into contentEditable not supported by userEvent
152
+ var handlePaste = /* istanbul ignore next */function handlePaste(ev) {
153
+ ev.preventDefault();
154
+
155
+ // Get clipboard as plain text
156
+ var text = (ev.clipboardData || window.clipboardData).getData('text/plain');
157
+
158
+ // remove \n
159
+ var sanitizedText = text.replaceAll(/\n/g, '') // remove carriage returns
160
+ .replaceAll(/\t/g, ' '); // replace tab with two spaces
161
+
162
+ if (document.queryCommandSupported('insertText')) {
163
+ document.execCommand('insertText', false, sanitizedText);
164
+ } else {
165
+ // Insert text at the current position of caret
166
+ var range = document.getSelection().getRangeAt(0);
167
+ range.deleteContents();
168
+ var textNode = document.createTextNode(sanitizedText);
169
+ range.insertNode(textNode);
170
+ // move selection end of textNode
171
+ range.selectNodeContents(textNode);
172
+ range.collapse(false);
173
+
174
+ // remove existing range
175
+ var selection = document.getSelection();
176
+ selection.removeAllRanges();
177
+
178
+ // set the new range
179
+ selection.addRange(range);
180
+ }
181
+ };
182
+ var handleCancel = function handleCancel() {
183
+ refInput.current.textContent = value;
184
+ handleInput(value);
185
+ doSetEditing(false);
186
+ document.getSelection().removeAllRanges();
187
+ if (onCancel) {
188
+ onCancel(value);
189
+ }
190
+ };
191
+ var handleBlur = function handleBlur(ev) {
192
+ if (!ref.current.contains(ev.relatedTarget)) {
193
+ handleSave();
194
+ }
195
+ };
196
+ var handleKeyDown = function handleKeyDown(ev) {
197
+ switch (ev.key) {
198
+ case 'Enter':
199
+ ev.preventDefault();
200
+ refInput.current.blur(); // will cause save
201
+ break;
202
+ case 'Escape':
203
+ handleCancel();
204
+ break;
205
+ }
206
+ };
207
+
208
+ /*
209
+ The HTML is structured as follows:
210
+ <container>
211
+ <!-- margin left of input to match Carbon -->
212
+ <content-editable>
213
+ <-- margin right of input space for after-input-elements -->
214
+ <after-input-elements>
215
+ </container>
216
+ NOTE:
217
+ - An input is not used as this would not permit a heading tag e.g. <h2>.
218
+ - Some padding is added to the left 16px standard for a Carbon text input
219
+ - The after-input-elements are position absolute with a margin to on the input to reserve space. Using inline-flex
220
+ - does not measure space properly for the input otherwise.
221
+ - The content editable is not expected to change size when buttons are added, to ensure the text does not move space
222
+ is reserved up front for buttons and invalid icon. Mostly this is only noticed if the width of the component is not 100%.
223
+ which can be shown by setting inlineEditFullWidth to false in storybook.
224
+ In making content-editable behave like an input of type text we have to account for.
225
+ - Enforcing a single line
226
+ - Pasting of non-text e.g. html or text with carriage returns
227
+ - The padding and border not hiding typed in text.
228
+ - Placing the cursor at the start or end depending on area clicked (before for left-padding)
229
+ */
230
+
231
+ var toolbarAnimation = true;
232
+ return (
233
+ /*#__PURE__*/
234
+ // eslint-disable-next-line
235
+ React.createElement("div", {
236
+ className: cx(blockClass,
237
+ // Apply the block class to the main HTML element
238
+ className, // Apply any supplied class names to the main HTML element.
239
+ "".concat(blockClass, "--").concat(size), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "--disabled"), disabled), _defineProperty(_cx, "".concat(blockClass, "--editing"), editing), _defineProperty(_cx, "".concat(blockClass, "--invalid"), invalid), _defineProperty(_cx, "".concat(blockClass, "--light"), light), _defineProperty(_cx, "".concat(blockClass, "--overflows"), refInput.current && refInput.current.scrollWidth > refInput.current.offsetWidth), _cx)),
240
+ onClick: handleEdit // disabled eslint for click handler
241
+ ,
242
+ onBlur: handleBlur,
243
+ ref: ref
244
+ }, /*#__PURE__*/React.createElement("div", _extends({}, rest, getDevtoolsProps(componentName), {
245
+ id: id,
246
+ size: size,
247
+ 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)),
248
+ contentEditable: true,
249
+ "aria-label": labelText,
250
+ role: "textbox",
251
+ tabIndex: disabled ? -1 : 0,
252
+ onFocus: handleFocus,
253
+ onInput: handleInput,
254
+ onKeyDown: handleKeyDown,
255
+ onPaste: handlePaste,
256
+ suppressContentEditableWarning: true,
257
+ ref: refInput,
258
+ "data-placeholder": placeholder
259
+ }), value), /*#__PURE__*/React.createElement("div", {
260
+ className: cx("".concat(blockClass, "__after-input-elements"))
261
+ // tabindex -1 fixes blur target test when clicking on after-input-elements background
262
+ ,
263
+ tabIndex: "-1"
264
+ }, /*#__PURE__*/React.createElement("div", {
265
+ className: "".concat(blockClass, "__ellipsis"),
266
+ "aria-hidden": !editing
267
+ }, "\u2026"), /*#__PURE__*/React.createElement("div", {
268
+ className: cx("".concat(blockClass, "__toolbar"), (_cx3 = {}, _defineProperty(_cx3, "".concat(blockClass, "__toolbar--animation"), toolbarAnimation), _defineProperty(_cx3, "".concat(blockClass, "__toolbar--saveable"), refInput.current && value !== internalValue), _cx3))
269
+ }, showValidation && /*#__PURE__*/React.createElement("div", {
270
+ className: "".concat(blockClass, "__validation-icon")
271
+ }, validationIcon), editing ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, _extends({
272
+ className: "".concat(blockClass, "__cancel"),
273
+ kind: "ghost",
274
+ hasIconOnly: true,
275
+ iconDescription: cancelDescription,
276
+ onClick: handleCancel,
277
+ renderIcon: Close16
278
+ }, tipPositions.cancel)), /*#__PURE__*/React.createElement(Button, _extends({
279
+ className: "".concat(blockClass, "__save"),
280
+ kind: "ghost",
281
+ hasIconOnly: true,
282
+ iconDescription: saveDescription,
283
+ onClick: handleSave,
284
+ renderIcon: Checkmark16,
285
+ disabled: value === internalValue
286
+ }, tipPositions.save))) : /*#__PURE__*/React.createElement(Button, _extends({
287
+ className: cx("".concat(blockClass, "__edit"), _defineProperty({}, "".concat(blockClass, "__edit--always-visible"), editAlwaysVisible)),
288
+ kind: "ghost",
289
+ hasIconOnly: true,
290
+ iconDescription: editDescription,
291
+ onClick: handleEdit,
292
+ renderIcon: disabled ? EditOff16 : Edit16,
293
+ disabled: disabled,
294
+ tabIndex: -1
295
+ }, tipPositions.edit)))), /*#__PURE__*/React.createElement("div", {
296
+ className: cx("".concat(blockClass, "__disabled-cover"))
297
+ }), showValidation && validationText && validationText.length > 0 && /*#__PURE__*/React.createElement("div", {
298
+ className: "".concat(blockClass, "__validation-text ").concat(carbon.prefix, "--form-requirement")
299
+ }, validationText))
300
+ );
301
+ });
302
+
303
+ // Return a placeholder if not released and not enabled by feature flag
304
+ InlineEditV1 = pkg.checkComponentEnabled(InlineEditV1, componentName);
305
+
306
+ // The display name of the component, used by React. Note that displayName
307
+ // is used in preference to relying on function.name.
308
+ InlineEditV1.displayName = componentName;
309
+
310
+ // The types and DocGen commentary for the component props,
311
+ // in alphabetical order (for consistency).
312
+ // See https://www.npmjs.com/package/prop-types#usage.
313
+ InlineEditV1.propTypes = {
314
+ /**
315
+ * buttonTooltipAlignment from the standard tooltip. Default center.
316
+ *
317
+ * Can be passed either as one of tooltip options or as an object specifying cancel, edit and save separately
318
+ */
319
+ buttonTooltipAlignment: PropTypes.oneOfType([PropTypes.oneOf(['start', 'center', 'end']), PropTypes.shape({
320
+ cancel: PropTypes.oneOf(['start', 'center', 'end']),
321
+ edit: PropTypes.oneOf(['start', 'center', 'end']),
322
+ save: PropTypes.oneOf(['start', 'center', 'end'])
323
+ })]),
324
+ /**
325
+ * buttonTooltipPosition from the standard tooltip
326
+ *
327
+ * Can be passed either as one of tooltip options or as an object specifying cancel, edit and save separately
328
+ */
329
+ buttonTooltipPosition: PropTypes.oneOfType([PropTypes.oneOf(['top', 'right', 'bottom', 'left']), PropTypes.shape({
330
+ cancel: PropTypes.oneOf(['top', 'right', 'bottom', 'left']),
331
+ edit: PropTypes.oneOf(['top', 'right', 'bottom', 'left']),
332
+ save: PropTypes.oneOf(['top', 'right', 'bottom', 'left'])
333
+ })]),
334
+ /**
335
+ * label for cancel button
336
+ */
337
+ cancelDescription: PropTypes.string.isRequired,
338
+ /**
339
+ * Provide an optional class to be applied to the containing node.
340
+ */
341
+ className: PropTypes.string,
342
+ /**
343
+ * disable edit
344
+ */
345
+ disabled: PropTypes.bool,
346
+ /**
347
+ * By default the edit icon is shown on hover only.
348
+ */
349
+ editAlwaysVisible: PropTypes.bool,
350
+ /**
351
+ * Label for the edit button
352
+ */
353
+ editDescription: PropTypes.string.isRequired,
354
+ /**
355
+ * ID for inline edit
356
+ */
357
+ id: PropTypes.string,
358
+ /**
359
+ * set invalid state for input
360
+ */
361
+ invalid: PropTypes.bool,
362
+ /**
363
+ * text shown when invalid is true
364
+ */
365
+ invalidText: PropTypes.string,
366
+ /**
367
+ * label for text input
368
+ */
369
+ labelText: PropTypes.string,
370
+ /**
371
+ * change background to light version (mimic React TextInput)
372
+ */
373
+ light: PropTypes.bool,
374
+ /**
375
+ * method called on cancel event
376
+ */
377
+ onCancel: PropTypes.func,
378
+ /**
379
+ * method called on input event (it's a React thing onChange behaves like on input).
380
+ *
381
+ * NOTE: caller to handle invalid states and associated text
382
+ */
383
+ onChange: PropTypes.func,
384
+ /**
385
+ * method called on change event
386
+ *
387
+ * NOTE: caller to handle invalid states and associated text
388
+ */
389
+ onSave: PropTypes.func,
390
+ /**
391
+ * placeholder for text input
392
+ */
393
+ placeholder: PropTypes.string,
394
+ /**
395
+ * label for save button
396
+ */
397
+ saveDescription: PropTypes.string.isRequired,
398
+ /**
399
+ * vertical size of control
400
+ */
401
+ size: PropTypes.oneOf(['sm', 'md', 'lg']),
402
+ /**
403
+ * initial/unedited value
404
+ */
405
+ value: PropTypes.string
406
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2022
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ export { InlineEditV1 } from './InlineEditV1';
@@ -2,27 +2,35 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
- var _excluded = ["cancelLabel", "editLabel", "invalid", "invalidLabel", "onCancel", "onChange", "onSave", "readOnly", "readOnlyLabel", "saveLabel", "value"];
5
+ var _excluded = ["cancelLabel", "editLabel", "id", "invalid", "invalidLabel", "labelText", "onCancel", "onChange", "onSave", "saveLabel", "value"];
6
+ /**
7
+ * Copyright IBM Corp. 2022, 2022
8
+ *
9
+ * This source code is licensed under the Apache-2.0 license found in the
10
+ * LICENSE file in the root directory of this source tree.
11
+ */
12
+
6
13
  import React, { useState, useEffect, forwardRef, useRef } from 'react';
7
14
  import { Button } from 'carbon-components-react';
8
15
  import cx from 'classnames';
9
16
  import PropTypes from 'prop-types';
10
- import { Edit24, Checkmark24, Close24, EditOff24, WarningFilled16 } from '@carbon/icons-react';
17
+ import { Edit24, Checkmark24, Close24,
18
+ // EditOff24,
19
+ WarningFilled16 } from '@carbon/icons-react';
11
20
  import { pkg, carbon } from '../../settings';
12
21
  import { getDevtoolsProps } from '../../global/js/utils/devtools';
13
22
  var componentName = 'InlineEditV2';
14
23
  var blockClass = "".concat(pkg.prefix, "--inline-edit-v2");
15
24
  export var InlineEditV2 = /*#__PURE__*/forwardRef(function (_ref, ref) {
16
- var _cx;
17
25
  var cancelLabel = _ref.cancelLabel,
18
26
  editLabel = _ref.editLabel,
27
+ id = _ref.id,
19
28
  invalid = _ref.invalid,
20
29
  invalidLabel = _ref.invalidLabel,
30
+ labelText = _ref.labelText,
21
31
  onCancel = _ref.onCancel,
22
32
  onChange = _ref.onChange,
23
33
  onSave = _ref.onSave,
24
- readOnly = _ref.readOnly,
25
- readOnlyLabel = _ref.readOnlyLabel,
26
34
  saveLabel = _ref.saveLabel,
27
35
  value = _ref.value,
28
36
  rest = _objectWithoutProperties(_ref, _excluded);
@@ -59,9 +67,10 @@ export var InlineEditV2 = /*#__PURE__*/forwardRef(function (_ref, ref) {
59
67
  onChange(target.value);
60
68
  };
61
69
  var onFocusHandler = function onFocusHandler(e) {
62
- if (readOnly) {
63
- return;
64
- }
70
+ // if (readOnly) {
71
+ // return;
72
+ // }
73
+
65
74
  if (!isTargetingChild(e)) {
66
75
  inputRef.current.focus();
67
76
  setFocused(true);
@@ -79,7 +88,8 @@ export var InlineEditV2 = /*#__PURE__*/forwardRef(function (_ref, ref) {
79
88
  onCancel(initialValue);
80
89
  };
81
90
  var onBlurHandler = function onBlurHandler(e) {
82
- if (readOnly || escaping.current) {
91
+ // if (readOnly || escaping.current) {
92
+ if (escaping.current) {
83
93
  return;
84
94
  }
85
95
  if (!isTargetingChild(e)) {
@@ -118,16 +128,21 @@ export var InlineEditV2 = /*#__PURE__*/forwardRef(function (_ref, ref) {
118
128
  return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
119
129
  ref: ref
120
130
  }, getDevtoolsProps(componentName)), /*#__PURE__*/React.createElement("div", {
121
- className: cx(blockClass, (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "-focused"), focused), _defineProperty(_cx, "".concat(blockClass, "-readonly"), readOnly), _cx)),
131
+ className: cx(blockClass, _defineProperty({}, "".concat(blockClass, "-focused"), focused)),
122
132
  onFocus: onFocusHandler,
123
133
  onBlur: onBlurHandler
124
- }, /*#__PURE__*/React.createElement("input", {
134
+ }, /*#__PURE__*/React.createElement("label", {
135
+ className: "".concat(blockClass, "__text-input-label"),
136
+ htmlFor: id
137
+ }, labelText), /*#__PURE__*/React.createElement("input", {
138
+ id: id,
125
139
  className: cx("".concat(blockClass, "__text-input"), "".concat(carbon.prefix, "--text-input"), "".concat(carbon.prefix, "--text-input--sm")),
126
140
  type: "text",
127
141
  value: value,
128
142
  onChange: onChangeHandler,
129
- ref: inputRef,
130
- readOnly: readOnly,
143
+ ref: inputRef
144
+ // readOnly={readOnly}
145
+ ,
131
146
  onKeyDown: onKeyHandler
132
147
  }), focused ? /*#__PURE__*/React.createElement(React.Fragment, null, invalid && /*#__PURE__*/React.createElement(WarningFilled16, {
133
148
  className: "".concat(blockClass, "__warning-icon")
@@ -154,10 +169,14 @@ export var InlineEditV2 = /*#__PURE__*/forwardRef(function (_ref, ref) {
154
169
  disabled: !canSave
155
170
  })) : /*#__PURE__*/React.createElement(Button, {
156
171
  className: "".concat(blockClass, "__btn ").concat(blockClass, "__btn-edit"),
157
- hasIconOnly: true,
158
- renderIcon: readOnly ? EditOff24 : Edit24,
159
- size: "sm",
160
- iconDescription: readOnly ? readOnlyLabel : editLabel,
172
+ hasIconOnly: true
173
+ // renderIcon={readOnly ? EditOff24 : Edit24}
174
+ ,
175
+ renderIcon: Edit24,
176
+ size: "sm"
177
+ // iconDescription={readOnly ? readOnlyLabel : editLabel}
178
+ ,
179
+ iconDescription: editLabel,
161
180
  onClick: onFocusHandler,
162
181
  kind: "ghost",
163
182
  tabIndex: 0,
@@ -177,6 +196,10 @@ InlineEditV2.propTypes = {
177
196
  * label for edit button
178
197
  */
179
198
  editLabel: PropTypes.string.isRequired,
199
+ /**
200
+ * Specify a custom id for the input
201
+ */
202
+ id: PropTypes.string.isRequired,
180
203
  /**
181
204
  * determines if the input is invalid
182
205
  */
@@ -185,6 +208,10 @@ InlineEditV2.propTypes = {
185
208
  * text that is displayed if the input is invalid
186
209
  */
187
210
  invalidLabel: PropTypes.string,
211
+ /**
212
+ * Provide the text that will be read by a screen reader when visiting this control
213
+ */
214
+ labelText: PropTypes.string.isRequired,
188
215
  /**
189
216
  * 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
190
217
  */
@@ -200,11 +227,11 @@ InlineEditV2.propTypes = {
200
227
  /**
201
228
  * determines if the input is in readOnly mode
202
229
  */
203
- readOnly: PropTypes.bool,
230
+ // readOnly: PropTypes.bool,
204
231
  /**
205
232
  * label for the edit button that displays when in read only mode
206
233
  */
207
- readOnlyLabel: PropTypes.string,
234
+ // readOnlyLabel: PropTypes.string,
208
235
  /**
209
236
  * label for save button
210
237
  */
@@ -216,6 +243,6 @@ InlineEditV2.propTypes = {
216
243
  };
217
244
  InlineEditV2.defaultProps = {
218
245
  invalid: false,
219
- invalidLabel: '',
220
- readOnly: false
246
+ invalidLabel: ''
247
+ // readOnly: false,
221
248
  };
@@ -1 +1,8 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2022
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
1
8
  export { InlineEditV2 } from './InlineEditV2';
@@ -36,11 +36,11 @@ export { UserProfileImage } from './UserProfileImage';
36
36
  export { WebTerminal, WebTerminalContentWrapper, useWebTerminal, WebTerminalProvider } from './WebTerminal';
37
37
  export { EditSidePanel } from './EditSidePanel';
38
38
  export { OptionsTile } from './OptionsTile';
39
- export { InlineEdit } from './InlineEdit';
40
39
  export { DataSpreadsheet } from './DataSpreadsheet';
41
40
  export { Datagrid, useDatagrid, useInfiniteScroll, useNestedRows, useSelectRows, useExpandedRow, useOnRowClick, useSortableColumns, useRowIsMouseOver, useColumnRightAlign, useDisableSelectRows, useStickyColumn, useActionsColumn, useCustomizeColumns, useSelectAllWithToggle, useColumnOrder, useInlineEdit } from './Datagrid';
42
41
  export { EditTearsheet } from './EditTearsheet';
43
42
  export { EditTearsheetNarrow } from './EditTearsheetNarrow';
44
43
  export { EditFullPage } from './EditFullPage';
45
44
  export { EditUpdateCards } from './EditUpdateCards';
45
+ export { InlineEdit } from './InlineEdit';
46
46
  export { InlineEditV2 } from './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,
@@ -109,7 +109,7 @@ var DatagridContent = function DatagridContent(_ref) {
109
109
  return;
110
110
  }
111
111
  var gridElement = document.querySelector("#".concat(tableId));
112
- var tableHeader = document.querySelector(".".concat(_settings.carbon.prefix, "--data-table-header"));
112
+ var tableHeader = gridElement === null || gridElement === void 0 ? void 0 : gridElement.querySelector(".".concat(_settings.carbon.prefix, "--data-table-header"));
113
113
  gridElement.style.setProperty("--".concat(blockClass, "--grid-width"), (0, _layout.px)(totalColumnsWidth + 32));
114
114
  if (gridActive) {
115
115
  gridElement.style.setProperty("--".concat(blockClass, "--grid-header-height"), (0, _layout.px)((tableHeader === null || tableHeader === void 0 ? void 0 : tableHeader.clientHeight) || 0));
@@ -32,7 +32,7 @@ var DatagridRow = function DatagridRow(datagridState) {
32
32
  var activeCellId = state.activeCellId;
33
33
  var activeCellObject = activeCellId && (0, _getCellIdAsObject.getCellIdAsObject)(activeCellId);
34
34
  return /*#__PURE__*/_react.default.createElement(TableRow, (0, _extends2.default)({
35
- 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))
35
+ 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(blockClass, "__carbon-row-expandable"), row.canExpand), (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))
36
36
  }, row.getRowProps(), {
37
37
  key: row.id,
38
38
  onMouseEnter: function onMouseEnter(event) {
@@ -43,7 +43,7 @@ var DatagridRow = function DatagridRow(datagridState) {
43
43
  var hoverRow = event.target.closest(".".concat(blockClass, "__carbon-row-expanded"));
44
44
  hoverRow === null || hoverRow === void 0 ? void 0 : hoverRow.classList.remove("".concat(blockClass, "__carbon-row-expanded-hover-active"));
45
45
  }
46
- }), row.cells.map(function (cell) {
46
+ }), row.cells.map(function (cell, index) {
47
47
  var cellProps = cell.getCellProps();
48
48
  var children = cellProps.children,
49
49
  restProps = (0, _objectWithoutProperties2.default)(cellProps, _excluded);
@@ -55,7 +55,7 @@ var DatagridRow = function DatagridRow(datagridState) {
55
55
  });
56
56
  }
57
57
  return /*#__PURE__*/_react.default.createElement(TableCell, (0, _extends2.default)({
58
- className: "".concat(blockClass, "__cell")
58
+ className: (0, _classnames.default)("".concat(blockClass, "__cell"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__expandable-row-cell"), row.canExpand && index === 0))
59
59
  }, restProps, {
60
60
  key: cell.column.id
61
61
  }), content);
@@ -41,7 +41,8 @@ var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridS
41
41
  setReceivedInitialWidth = _useState6[1];
42
42
  var selectedFlatRows = datagridState.selectedFlatRows,
43
43
  toggleAllRowsSelected = datagridState.toggleAllRowsSelected,
44
- toolbarBatchActions = datagridState.toolbarBatchActions;
44
+ toolbarBatchActions = datagridState.toolbarBatchActions,
45
+ setGlobalFilter = datagridState.setGlobalFilter;
45
46
  var totalSelected = selectedFlatRows && selectedFlatRows.length;
46
47
 
47
48
  // Get initial width of batch actions container,
@@ -113,7 +114,8 @@ var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridS
113
114
  shouldShowBatchActions: totalSelected > 0,
114
115
  totalSelected: totalSelected,
115
116
  onCancel: function onCancel() {
116
- return toggleAllRowsSelected(false);
117
+ toggleAllRowsSelected(false);
118
+ setGlobalFilter(null);
117
119
  }
118
120
  }, !displayAllInMenu && toolbarBatchActions && (toolbarBatchActions === null || toolbarBatchActions === void 0 ? void 0 : toolbarBatchActions.map(function (batchAction, index) {
119
121
  if (index < 2 && toolbarBatchActions.length > 3 || index < 3 && toolbarBatchActions.length === 3) {
@@ -34,7 +34,7 @@ var RowSizeDropdown = function RowSizeDropdown(_ref) {
34
34
  hasIconOnly: true,
35
35
  ref: buttonRef,
36
36
  kind: "ghost",
37
- tooltipPosition: "left",
37
+ tooltipPosition: "bottom",
38
38
  renderIcon: _iconsReact.Settings16,
39
39
  onClick: function onClick() {
40
40
  return setIsOpen(!isOpen);