@carbon/ibm-products 2.0.0-rc.6 → 2.0.0-rc.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. package/README.md +2 -2
  2. package/css/index-full-carbon.css +96 -12
  3. package/css/index-full-carbon.css.map +1 -1
  4. package/css/index-full-carbon.min.css +3 -3
  5. package/css/index-full-carbon.min.css.map +1 -1
  6. package/css/index-without-carbon-released-only.css +6 -9
  7. package/css/index-without-carbon-released-only.css.map +1 -1
  8. package/css/index-without-carbon-released-only.min.css +2 -2
  9. package/css/index-without-carbon-released-only.min.css.map +1 -1
  10. package/css/index-without-carbon.css +96 -12
  11. package/css/index-without-carbon.css.map +1 -1
  12. package/css/index-without-carbon.min.css +3 -3
  13. package/css/index-without-carbon.min.css.map +1 -1
  14. package/css/index.css +89 -9
  15. package/css/index.css.map +1 -1
  16. package/css/index.min.css +3 -3
  17. package/css/index.min.css.map +1 -1
  18. package/es/components/ActionSet/ActionSet.js +7 -3
  19. package/es/components/AddSelect/add-select-utils.js +2 -2
  20. package/es/components/DataSpreadsheet/DataSpreadsheet.js +2 -1
  21. package/es/components/DataSpreadsheet/utils/handleCellDeletion.js +10 -1
  22. package/es/components/Datagrid/useNestedRowExpander.js +7 -2
  23. package/es/components/InlineEdit/InlineEdit.js +27 -427
  24. package/es/components/InlineEditV1/InlineEditV1.js +447 -0
  25. package/es/components/InlineEditV1/index.js +7 -0
  26. package/es/components/InlineEditV2/InlineEditV2.js +289 -0
  27. package/es/components/InlineEditV2/index.js +7 -0
  28. package/es/components/OptionsTile/OptionsTile.js +28 -12
  29. package/es/components/PageHeader/PageHeaderTitle.js +2 -4
  30. package/es/global/js/hooks/index.js +2 -1
  31. package/es/global/js/hooks/useControllableState.js +83 -0
  32. package/es/global/js/package-settings.js +3 -1
  33. package/lib/components/ActionSet/ActionSet.js +7 -3
  34. package/lib/components/AddSelect/add-select-utils.js +2 -2
  35. package/lib/components/DataSpreadsheet/DataSpreadsheet.js +2 -1
  36. package/lib/components/DataSpreadsheet/utils/handleCellDeletion.js +10 -1
  37. package/lib/components/Datagrid/useNestedRowExpander.js +7 -1
  38. package/lib/components/InlineEdit/InlineEdit.js +27 -428
  39. package/lib/components/InlineEditV1/InlineEditV1.js +464 -0
  40. package/lib/components/InlineEditV1/index.js +13 -0
  41. package/lib/components/InlineEditV2/InlineEditV2.js +309 -0
  42. package/lib/components/InlineEditV2/index.js +13 -0
  43. package/lib/components/OptionsTile/OptionsTile.js +28 -11
  44. package/lib/components/PageHeader/PageHeaderTitle.js +2 -4
  45. package/lib/global/js/hooks/index.js +9 -1
  46. package/lib/global/js/hooks/useControllableState.js +94 -0
  47. package/lib/global/js/package-settings.js +3 -1
  48. package/package.json +2 -2
  49. package/scss/components/ActionSet/_action-set.scss +9 -4
  50. package/scss/components/Datagrid/styles/_useNestedRows.scss +17 -0
  51. package/scss/components/{InlineEdit → InlineEditV1}/_carbon-imports.scss +0 -0
  52. package/scss/components/{InlineEdit → InlineEditV1}/_index-with-carbon.scss +1 -1
  53. package/scss/components/{InlineEdit → InlineEditV1}/_index.scss +1 -1
  54. package/scss/components/{InlineEdit/_inline-edit.scss → InlineEditV1/_inline-edit-v1.scss} +0 -0
  55. package/scss/components/{InlineEdit → InlineEditV1}/_storybook-styles.scss +0 -0
  56. package/scss/components/InlineEditV2/_carbon-imports.scss +9 -0
  57. package/scss/components/InlineEditV2/_index-with-carbon.scss +9 -0
  58. package/scss/components/InlineEditV2/_index.scss +10 -0
  59. package/scss/components/InlineEditV2/_inline-edit-v2.scss +83 -0
  60. package/scss/components/InlineEditV2/_storybook-styles.scss +9 -0
  61. package/scss/components/PageHeader/_page-header.scss +0 -4
  62. package/scss/components/_index-released-only-with-carbon.scss +1 -1
  63. package/scss/components/_index-released-only.scss +1 -1
  64. package/scss/components/_index-with-carbon.scss +2 -1
  65. package/scss/components/_index.scss +2 -1
@@ -0,0 +1,309 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports.InlineEditV2 = void 0;
11
+
12
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
+
14
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
+
16
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
17
+
18
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
19
+
20
+ var _react = _interopRequireWildcard(require("react"));
21
+
22
+ var _react2 = require("@carbon/react");
23
+
24
+ var _classnames = _interopRequireDefault(require("classnames"));
25
+
26
+ var _propTypes = _interopRequireDefault(require("prop-types"));
27
+
28
+ var _icons = require("@carbon/react/icons");
29
+
30
+ var _settings = require("../../settings");
31
+
32
+ var _devtools = require("../../global/js/utils/devtools");
33
+
34
+ var _excluded = ["cancelLabel", "editLabel", "id", "invalid", "invalidLabel", "labelText", "onCancel", "onChange", "onSave", "saveLabel", "value"];
35
+
36
+ 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); }
37
+
38
+ 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; }
39
+
40
+ var componentName = 'InlineEditV2';
41
+ var blockClass = "".concat(_settings.pkg.prefix, "--inline-edit-v2");
42
+ var InlineEditV2 = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
43
+ var cancelLabel = _ref.cancelLabel,
44
+ editLabel = _ref.editLabel,
45
+ id = _ref.id,
46
+ invalid = _ref.invalid,
47
+ invalidLabel = _ref.invalidLabel,
48
+ labelText = _ref.labelText,
49
+ onCancel = _ref.onCancel,
50
+ onChange = _ref.onChange,
51
+ onSave = _ref.onSave,
52
+ saveLabel = _ref.saveLabel,
53
+ value = _ref.value,
54
+ rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
55
+
56
+ var _useState = (0, _react.useState)(false),
57
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
58
+ focused = _useState2[0],
59
+ setFocused = _useState2[1];
60
+
61
+ var _useState3 = (0, _react.useState)(''),
62
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
63
+ initialValue = _useState4[0],
64
+ setInitialValue = _useState4[1];
65
+
66
+ var _useState5 = (0, _react.useState)(false),
67
+ _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
68
+ dirtyInput = _useState6[0],
69
+ setDirtyInput = _useState6[1];
70
+
71
+ var inputRef = (0, _react.useRef)(null);
72
+ var canSave = value !== initialValue && !invalid;
73
+ var escaping = (0, _react.useRef)(false);
74
+ (0, _react.useEffect)(function () {
75
+ if (!initialValue && !dirtyInput) {
76
+ setInitialValue(value);
77
+ }
78
+ }, [initialValue, dirtyInput, value]);
79
+
80
+ var isTargetingChild = function isTargetingChild(_ref2) {
81
+ var currentTarget = _ref2.currentTarget,
82
+ relatedTarget = _ref2.relatedTarget;
83
+ return currentTarget.contains(relatedTarget);
84
+ };
85
+
86
+ var onChangeHandler = function onChangeHandler(_ref3) {
87
+ var target = _ref3.target;
88
+
89
+ if (!dirtyInput) {
90
+ setDirtyInput(true);
91
+ }
92
+
93
+ onChange(target.value);
94
+ };
95
+
96
+ var onFocusHandler = function onFocusHandler(e) {
97
+ // if (readOnly) {
98
+ // return;
99
+ // }
100
+ if (!isTargetingChild(e)) {
101
+ inputRef.current.focus();
102
+ setFocused(true);
103
+ }
104
+ };
105
+
106
+ var onSaveHandler = function onSaveHandler() {
107
+ setInitialValue(value);
108
+ setFocused(false);
109
+ setDirtyInput(false);
110
+ onSave();
111
+ };
112
+
113
+ var onCancelHandler = function onCancelHandler() {
114
+ setFocused(false);
115
+ setDirtyInput(false);
116
+ onCancel(initialValue);
117
+ };
118
+
119
+ var onBlurHandler = function onBlurHandler(e) {
120
+ // if (readOnly || escaping.current) {
121
+ if (escaping.current) {
122
+ return;
123
+ }
124
+
125
+ if (!isTargetingChild(e)) {
126
+ if (canSave) {
127
+ onSaveHandler();
128
+ } else {
129
+ onCancelHandler();
130
+ }
131
+ }
132
+ };
133
+
134
+ var returnHandler = function returnHandler() {
135
+ if (canSave) {
136
+ onSaveHandler();
137
+ }
138
+ };
139
+
140
+ var escapeHandler = function escapeHandler() {
141
+ onCancelHandler();
142
+ };
143
+
144
+ var onKeyHandler = function onKeyHandler(e) {
145
+ // to prevent blur handler from being called twice add additional state to check if escape is being used
146
+ escaping.current = true;
147
+
148
+ switch (e.key) {
149
+ case 'Escape':
150
+ inputRef.current.blur();
151
+ escapeHandler();
152
+ break;
153
+
154
+ case 'Enter':
155
+ inputRef.current.blur();
156
+ returnHandler();
157
+ break;
158
+
159
+ default:
160
+ break;
161
+ }
162
+
163
+ escaping.current = false;
164
+ };
165
+
166
+ return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, rest, {
167
+ ref: ref
168
+ }, (0, _devtools.getDevtoolsProps)(componentName)), /*#__PURE__*/_react.default.createElement("div", {
169
+ className: (0, _classnames.default)(blockClass, (0, _defineProperty2.default)({}, "".concat(blockClass, "-focused"), focused)),
170
+ onFocus: onFocusHandler,
171
+ onBlur: onBlurHandler
172
+ }, /*#__PURE__*/_react.default.createElement("label", {
173
+ className: "".concat(blockClass, "__text-input-label"),
174
+ htmlFor: id
175
+ }, labelText), /*#__PURE__*/_react.default.createElement("input", {
176
+ id: id,
177
+ className: (0, _classnames.default)("".concat(blockClass, "__text-input"), "".concat(_settings.carbon.prefix, "--text-input"), "".concat(_settings.carbon.prefix, "--text-input--sm")),
178
+ type: "text",
179
+ value: value,
180
+ onChange: onChangeHandler,
181
+ ref: inputRef // readOnly={readOnly}
182
+ ,
183
+ onKeyDown: onKeyHandler
184
+ }), focused ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, invalid && /*#__PURE__*/_react.default.createElement(_icons.WarningFilled, {
185
+ size: 16,
186
+ className: "".concat(blockClass, "__warning-icon")
187
+ }), /*#__PURE__*/_react.default.createElement(_react2.Button, {
188
+ hasIconOnly: true,
189
+ renderIcon: function renderIcon() {
190
+ return /*#__PURE__*/_react.default.createElement(_icons.Close, {
191
+ size: 24
192
+ });
193
+ },
194
+ size: "sm",
195
+ iconDescription: cancelLabel,
196
+ onClick: onCancelHandler,
197
+ kind: "ghost",
198
+ tabIndex: 0,
199
+ key: "cancel",
200
+ className: "".concat(blockClass, "__btn ").concat(blockClass, "__btn-cancel")
201
+ }), /*#__PURE__*/_react.default.createElement(_react2.Button, {
202
+ hasIconOnly: true,
203
+ renderIcon: function renderIcon() {
204
+ return /*#__PURE__*/_react.default.createElement(_icons.Checkmark, {
205
+ size: 24
206
+ });
207
+ },
208
+ size: "sm",
209
+ iconDescription: saveLabel,
210
+ onClick: onSaveHandler,
211
+ kind: "ghost",
212
+ tabIndex: 0,
213
+ key: "save",
214
+ className: "".concat(blockClass, "__btn ").concat(blockClass, "__btn-save"),
215
+ disabled: !canSave
216
+ })) : /*#__PURE__*/_react.default.createElement(_react2.Button, {
217
+ className: "".concat(blockClass, "__btn ").concat(blockClass, "__btn-edit"),
218
+ hasIconOnly: true // renderIcon={readOnly ? EditOff24 : Edit24}
219
+ ,
220
+ renderIcon: function renderIcon() {
221
+ return /*#__PURE__*/_react.default.createElement(_icons.Edit, {
222
+ size: 24
223
+ });
224
+ },
225
+ size: "sm" // iconDescription={readOnly ? readOnlyLabel : editLabel}
226
+ ,
227
+ iconDescription: editLabel,
228
+ onClick: onFocusHandler,
229
+ kind: "ghost",
230
+ tabIndex: 0,
231
+ key: "edit"
232
+ })), focused && invalid && /*#__PURE__*/_react.default.createElement("p", {
233
+ className: "".concat(blockClass, "__warning-text")
234
+ }, invalidLabel));
235
+ });
236
+ exports.InlineEditV2 = InlineEditV2;
237
+ exports.InlineEditV2 = InlineEditV2 = _settings.pkg.checkComponentEnabled(InlineEditV2, componentName);
238
+ InlineEditV2.displayName = componentName;
239
+ InlineEditV2.propTypes = {
240
+ /**
241
+ * label for cancel button
242
+ */
243
+ cancelLabel: _propTypes.default.string.isRequired,
244
+
245
+ /**
246
+ * label for edit button
247
+ */
248
+ editLabel: _propTypes.default.string.isRequired,
249
+
250
+ /**
251
+ * Specify a custom id for the input
252
+ */
253
+ id: _propTypes.default.string.isRequired,
254
+
255
+ /**
256
+ * determines if the input is invalid
257
+ */
258
+ invalid: _propTypes.default.bool,
259
+
260
+ /**
261
+ * text that is displayed if the input is invalid
262
+ */
263
+ invalidLabel: _propTypes.default.string,
264
+
265
+ /**
266
+ * Provide the text that will be read by a screen reader when visiting this control
267
+ */
268
+ labelText: _propTypes.default.string.isRequired,
269
+
270
+ /**
271
+ * 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
272
+ */
273
+ onCancel: _propTypes.default.func.isRequired,
274
+
275
+ /**
276
+ * handler that is called when the input is updated
277
+ */
278
+ onChange: _propTypes.default.func.isRequired,
279
+
280
+ /**
281
+ * handler that is called when the save button is pressed or when the user removes focus from the input if it has a new value
282
+ */
283
+ onSave: _propTypes.default.func.isRequired,
284
+
285
+ /**
286
+ * determines if the input is in readOnly mode
287
+ */
288
+ // readOnly: PropTypes.bool,
289
+
290
+ /**
291
+ * label for the edit button that displays when in read only mode
292
+ */
293
+ // readOnlyLabel: PropTypes.string,
294
+
295
+ /**
296
+ * label for save button
297
+ */
298
+ saveLabel: _propTypes.default.string.isRequired,
299
+
300
+ /**
301
+ * current value of the input
302
+ */
303
+ value: _propTypes.default.string.isRequired
304
+ };
305
+ InlineEditV2.defaultProps = {
306
+ invalid: false,
307
+ invalidLabel: '' // readOnly: false,
308
+
309
+ };
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "InlineEditV2", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _InlineEditV.InlineEditV2;
10
+ }
11
+ });
12
+
13
+ var _InlineEditV = require("./InlineEditV2");
@@ -29,13 +29,15 @@ var _uuidv = _interopRequireDefault(require("../../global/js/utils/uuidv4"));
29
29
 
30
30
  var _settings = require("../../settings");
31
31
 
32
+ var _hooks = require("../../global/js/hooks");
33
+
32
34
  var _react2 = require("@carbon/react");
33
35
 
34
36
  var _icons = require("@carbon/react/icons");
35
37
 
36
38
  var carbonMotion = _interopRequireWildcard(require("@carbon/motion"));
37
39
 
38
- var _excluded = ["children", "className", "enabled", "invalid", "invalidText", "locked", "lockedText", "onToggle", "open", "size", "summary", "title", "titleId", "warn", "warnText"];
40
+ var _excluded = ["children", "className", "enabled", "invalid", "invalidText", "locked", "lockedText", "onChange", "onToggle", "open", "size", "summary", "title", "titleId", "warn", "warnText"];
39
41
 
40
42
  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); }
41
43
 
@@ -47,6 +49,7 @@ var componentName = 'OptionsTile'; // NOTE: the component SCSS is not imported h
47
49
  // Default values for props
48
50
 
49
51
  var defaults = {
52
+ onChange: function onChange() {},
50
53
  size: 'xl'
51
54
  };
52
55
  /**
@@ -61,6 +64,8 @@ var OptionsTile = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
61
64
  invalidText = _ref.invalidText,
62
65
  locked = _ref.locked,
63
66
  lockedText = _ref.lockedText,
67
+ _ref$onChange = _ref.onChange,
68
+ _onChange = _ref$onChange === void 0 ? defaults.onChange : _ref$onChange,
64
69
  onToggle = _ref.onToggle,
65
70
  open = _ref.open,
66
71
  _ref$size = _ref.size,
@@ -74,18 +79,24 @@ var OptionsTile = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
74
79
 
75
80
  var _useState = (0, _react.useState)(open),
76
81
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
77
- isOpen = _useState2[0],
78
- setIsOpen = _useState2[1];
82
+ prevIsOpen = _useState2[0],
83
+ setPrevIsOpen = _useState2[1];
79
84
 
80
- var _useState3 = (0, _react.useState)(open),
85
+ var _useState3 = (0, _react.useState)(false),
81
86
  _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
82
- prevIsOpen = _useState4[0],
83
- setPrevIsOpen = _useState4[1];
84
-
85
- var _useState5 = (0, _react.useState)(false),
86
- _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
87
- closing = _useState6[0],
88
- setClosing = _useState6[1];
87
+ closing = _useState4[0],
88
+ setClosing = _useState4[1];
89
+
90
+ var _useControllableState = (0, _hooks.useControllableState)({
91
+ value: open,
92
+ defaultValue: open || null,
93
+ onChange: function onChange(value) {
94
+ return _onChange(value);
95
+ }
96
+ }),
97
+ _useControllableState2 = (0, _slicedToArray2.default)(_useControllableState, 2),
98
+ isOpen = _useControllableState2[0],
99
+ setIsOpen = _useControllableState2[1];
89
100
 
90
101
  var detailsRef = (0, _react.useRef)(null);
91
102
  var contentRef = (0, _react.useRef)(null);
@@ -318,6 +329,12 @@ OptionsTile.propTypes = {
318
329
  */
319
330
  lockedText: _propTypes.default.string,
320
331
 
332
+ /**
333
+ * Provide a function which will be called each time the user
334
+ * toggles the open state of the OptionsTile.
335
+ */
336
+ onChange: _propTypes.default.func,
337
+
321
338
  /**
322
339
  * Provide a function which will be called each time the user
323
340
  * interacts with the toggle.
@@ -81,12 +81,10 @@ var PageHeaderTitle = function PageHeaderTitle(_ref) {
81
81
  titleText = asText;
82
82
  }
83
83
 
84
- return /*#__PURE__*/_react.default.createElement("div", {
84
+ return /*#__PURE__*/_react.default.createElement("h1", {
85
85
  className: (0, _classnames.default)("".concat(blockClass, "__title"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__title--editable"), isEditable), (0, _defineProperty2.default)({}, "".concat(blockClass, "__title--fades"), hasBreadcrumbRow)),
86
86
  title: titleText
87
- }, /*#__PURE__*/_react.default.createElement("h1", {
88
- className: "".concat(blockClass, "__title-wrapper")
89
- }, titleInnards));
87
+ }, titleInnards);
90
88
  };
91
89
 
92
90
  exports.PageHeaderTitle = PageHeaderTitle;
@@ -15,6 +15,12 @@ Object.defineProperty(exports, "useClickOutside", {
15
15
  return _useClickOutside.useClickOutside;
16
16
  }
17
17
  });
18
+ Object.defineProperty(exports, "useControllableState", {
19
+ enumerable: true,
20
+ get: function get() {
21
+ return _useControllableState.useControllableState;
22
+ }
23
+ });
18
24
  Object.defineProperty(exports, "useCreateComponentFocus", {
19
25
  enumerable: true,
20
26
  get: function get() {
@@ -88,4 +94,6 @@ var _useResetCreateComponent = require("./useResetCreateComponent");
88
94
 
89
95
  var _useRetrieveStepData = require("./useRetrieveStepData");
90
96
 
91
- var _useValidCreateStepCount = require("./useValidCreateStepCount");
97
+ var _useValidCreateStepCount = require("./useValidCreateStepCount");
98
+
99
+ var _useControllableState = require("./useControllableState");
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.useControllableState = useControllableState;
9
+
10
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
+
12
+ var _react = require("react");
13
+
14
+ var _pconsole = _interopRequireDefault(require("../utils/pconsole"));
15
+
16
+ /**
17
+ * Copyright IBM Corp. 2016, 2022
18
+ *
19
+ * This source code is licensed under the Apache-2.0 license found in the
20
+ * LICENSE file in the root directory of this source tree.
21
+ */
22
+
23
+ /**
24
+ * This custom hook simplifies the behavior of a component if it has state that
25
+ * can be both controlled and uncontrolled. It functions identical to a
26
+ * useState() hook and provides [state, setState] for you to use. You can use
27
+ * the `onChange` argument to allow updates to the `state` to be communicated to
28
+ * owners of controlled components.
29
+ *
30
+ * Note: this hook will warn if a component is switching from controlled to
31
+ * uncontrolled, or vice-versa.
32
+ *
33
+ * @param {object} config
34
+ * @param {string} config.name - the name of the custom component
35
+ * @param {any} config.defaultValue - the default value used for the state. This will be
36
+ * the fallback value used if `value` is not defined.
37
+ * @param {Function} config.onChange - an optional function that is called when
38
+ * the value of the state changes. This is useful for communicating to parents of
39
+ * controlled components that the value is requesting to be changed.
40
+ * @param {any} config.value - a controlled value. Omitting this means that the state is
41
+ * uncontrolled
42
+ * @returns {[any, Function]}
43
+ */
44
+ function useControllableState(_ref) {
45
+ var defaultValue = _ref.defaultValue,
46
+ _ref$name = _ref.name,
47
+ name = _ref$name === void 0 ? 'custom' : _ref$name,
48
+ onChange = _ref.onChange,
49
+ value = _ref.value;
50
+
51
+ var _useState = (0, _react.useState)(value !== null && value !== void 0 ? value : defaultValue),
52
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
53
+ state = _useState2[0],
54
+ internalSetState = _useState2[1];
55
+
56
+ var controlled = (0, _react.useRef)(null);
57
+
58
+ if (controlled.current === null) {
59
+ controlled.current = value !== undefined;
60
+ }
61
+
62
+ function setState(stateOrUpdater) {
63
+ var value = typeof stateOrUpdater === 'function' ? stateOrUpdater(state) : stateOrUpdater;
64
+
65
+ if (controlled.current === false) {
66
+ internalSetState(value);
67
+ }
68
+
69
+ if (onChange) {
70
+ onChange(value);
71
+ }
72
+ }
73
+
74
+ (0, _react.useEffect)(function () {
75
+ var controlledValue = value !== undefined; // Uncontrolled -> Controlled
76
+ // If the component prop is uncontrolled, the prop value should be undefined
77
+
78
+ if (controlled.current === false && controlledValue) {
79
+ _pconsole.default.warn("A component is changing an uncontrolled %s component to be controlled.\n This is likely caused by the value changing to a defined value\n from undefined. Decide between using a controlled or uncontrolled\n value for the lifetime of the component.\n More info: https://reactjs.org/link/controlled-components");
80
+ } // Controlled -> Uncontrolled
81
+ // If the component prop is controlled, the prop value should be defined
82
+
83
+
84
+ if (controlled.current === true && !controlledValue) {
85
+ _pconsole.default.warn("A component is changing a controlled %s component to be uncontrolled.\n 'This is likely caused by the value changing to an undefined value\n 'from a defined one. Decide between using a controlled or\n 'uncontrolled value for the lifetime of the component.\n 'More info: https://reactjs.org/link/controlled-components");
86
+ }
87
+ }, [name, value]);
88
+
89
+ if (controlled.current === true) {
90
+ return [value, setState];
91
+ }
92
+
93
+ return [state, setState];
94
+ }
@@ -40,6 +40,7 @@ var defaults = {
40
40
  HTTPErrorOther: true,
41
41
  ImportModal: true,
42
42
  InlineEdit: true,
43
+ InlineEditV1: true,
43
44
  NotificationsPanel: true,
44
45
  NoDataEmptyState: true,
45
46
  NoTagsEmptyState: true,
@@ -74,7 +75,8 @@ var defaults = {
74
75
  EditTearsheet: false,
75
76
  EditTearsheetNarrow: false,
76
77
  EditFullPage: false,
77
- EditUpdateCards: false
78
+ EditUpdateCards: false,
79
+ InlineEditV2: false
78
80
  /* new component flags here - comment used by generate CLI */
79
81
 
80
82
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@carbon/ibm-products",
3
3
  "description": "Carbon for IBM Products",
4
- "version": "2.0.0-rc.6",
4
+ "version": "2.0.0-rc.8",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -94,5 +94,5 @@
94
94
  "react": "^16.8.6 || ^17.0.1",
95
95
  "react-dom": "^16.8.6 || ^17.0.1"
96
96
  },
97
- "gitHead": "86f2f494ebd950387c6dbbe4b84a5bce0f9fc6ba"
97
+ "gitHead": "84c6ea6511d0f4502aa315888ecb4ff108ec97f9"
98
98
  }
@@ -22,15 +22,20 @@ $action-set-block-class: #{c4p-settings.$pkg-prefix}--action-set;
22
22
  .#{$action-set-block-class} .#{$action-set-block-class}__action-button {
23
23
  @include type.type-style('body-short-01');
24
24
 
25
- height: $spacing-10;
26
25
  align-items: center;
27
- padding-top: $spacing-05;
28
- padding-bottom: $spacing-07;
29
26
  margin: 0;
27
+
28
+ &.#{$action-set-block-class}__action-button--expressive {
29
+ height: $spacing-10;
30
+ padding-top: $spacing-05;
31
+ padding-bottom: $spacing-07;
32
+ }
30
33
  }
31
34
 
32
35
  .#{$action-set-block-class}.#{c4p-settings.$carbon-prefix}--btn-set
33
- .#{$action-set-block-class}__action-button.#{c4p-settings.$carbon-prefix}--btn.#{c4p-settings.$carbon-prefix}--btn--expressive {
36
+ .#{$action-set-block-class}__action-button.#{c4p-settings.$carbon-prefix}--btn.#{c4p-settings.$carbon-prefix}--btn--expressive,
37
+ .#{$action-set-block-class}.#{c4p-settings.$carbon-prefix}--btn-set
38
+ .#{$action-set-block-class}__action-button.#{c4p-settings.$carbon-prefix}--btn {
34
39
  max-width: none;
35
40
  }
36
41
 
@@ -33,3 +33,20 @@
33
33
  td:first-child {
34
34
  border-bottom: none;
35
35
  }
36
+
37
+ .#{$block-class} .#{$block-class}__carbon-row-expandable {
38
+ position: relative;
39
+ }
40
+
41
+ .#{$block-class}
42
+ tr.#{$block-class}__carbon-nested-row
43
+ + :not(tr.#{$block-class}__carbon-nested-row)::before {
44
+ position: absolute;
45
+ /* stylelint-disable-next-line carbon/layout-token-use */
46
+ top: -1px;
47
+ left: 0;
48
+ width: 100%;
49
+ height: 1px;
50
+ background-color: $border-subtle;
51
+ content: '';
52
+ }
@@ -6,4 +6,4 @@
6
6
  //
7
7
 
8
8
  @use './carbon-imports';
9
- @use './inline-edit';
9
+ @use './inline-edit-v1';
@@ -5,4 +5,4 @@
5
5
  // LICENSE file in the root directory of this source tree.
6
6
  //
7
7
 
8
- @use './inline-edit';
8
+ @use './inline-edit-v1';
@@ -0,0 +1,9 @@
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
+ @use '@carbon/react/scss/components/button';
9
+ @use '@carbon/react/scss/components/text-input';
@@ -0,0 +1,9 @@
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
+ @use './carbon-imports';
9
+ @use './inline-edit-v2';
@@ -0,0 +1,10 @@
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
+ // An index file is most useful when you have multiple components
9
+
10
+ @use './inline-edit-v2';