@carbon/ibm-products 1.2.3 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. package/css/index-full-carbon.css +538 -273
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +2 -2
  4. package/css/index-without-carbon-released-only.css +32 -41
  5. package/css/index-without-carbon-released-only.css.map +1 -1
  6. package/css/index-without-carbon-released-only.min.css +2 -2
  7. package/css/index-without-carbon.css +269 -41
  8. package/css/index-without-carbon.css.map +1 -1
  9. package/css/index-without-carbon.min.css +2 -2
  10. package/css/index.css +491 -41
  11. package/css/index.css.map +1 -1
  12. package/css/index.min.css +2 -2
  13. package/es/components/APIKeyModal/APIKeyModal.js +25 -29
  14. package/es/components/ActionBar/ActionBar.js +4 -1
  15. package/es/components/AddSelect/AddSelect.js +157 -0
  16. package/es/components/AddSelect/index.js +7 -0
  17. package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +19 -15
  18. package/es/components/CancelableTextEdit/CancelableTextEdit.js +245 -0
  19. package/es/components/{CreateTearsheet/constants.js → CancelableTextEdit/index.js} +1 -2
  20. package/es/components/CreateFullPage/CreateFullPage.js +78 -259
  21. package/es/components/CreateFullPage/CreateFullPageStep.js +58 -14
  22. package/es/components/CreateFullPage/index.js +1 -2
  23. package/es/components/CreateInfluencer/CreateInfluencer.js +23 -225
  24. package/es/components/CreateTearsheet/CreateTearsheet.js +69 -146
  25. package/es/components/CreateTearsheet/CreateTearsheetStep.js +59 -16
  26. package/es/components/CreateTearsheet/index.js +0 -1
  27. package/es/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +66 -27
  28. package/es/components/ExportModal/ExportModal.js +4 -2
  29. package/es/components/ImportModal/ImportModal.js +2 -1
  30. package/es/components/InlineEdit/InlineEdit.js +224 -0
  31. package/es/components/InlineEdit/index.js +7 -0
  32. package/es/components/MultiAddSelect/MultiAddSelect.js +16 -0
  33. package/es/components/MultiAddSelect/index.js +1 -0
  34. package/es/components/OptionsTile/OptionsTile.js +36 -15
  35. package/es/components/PageHeader/PageHeader.js +54 -33
  36. package/es/components/PageHeader/PageHeaderTitle.js +78 -7
  37. package/es/components/PageHeader/PageHeaderUtils.js +21 -2
  38. package/es/components/RemoveModal/RemoveModal.js +4 -2
  39. package/es/components/SingleAddSelect/SingleAddSelect.js +15 -0
  40. package/es/components/SingleAddSelect/index.js +1 -0
  41. package/es/components/TagSet/TagSet.js +4 -1
  42. package/es/components/Toolbar/Toolbar.js +69 -8
  43. package/es/components/index.js +5 -1
  44. package/es/global/js/hooks/useCreateComponentFocus.js +15 -19
  45. package/es/global/js/hooks/useCreateComponentStepChange.js +44 -74
  46. package/es/global/js/hooks/useValidCreateStepCount.js +4 -7
  47. package/es/global/js/package-settings.js +5 -1
  48. package/es/global/js/utils/story-helper.js +1 -1
  49. package/lib/components/APIKeyModal/APIKeyModal.js +25 -29
  50. package/lib/components/ActionBar/ActionBar.js +4 -1
  51. package/lib/components/AddSelect/AddSelect.js +178 -0
  52. package/lib/components/AddSelect/index.js +13 -0
  53. package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +18 -14
  54. package/lib/components/CancelableTextEdit/CancelableTextEdit.js +265 -0
  55. package/lib/components/CancelableTextEdit/index.js +13 -0
  56. package/lib/components/CreateFullPage/CreateFullPage.js +78 -259
  57. package/lib/components/CreateFullPage/CreateFullPageStep.js +61 -14
  58. package/lib/components/CreateFullPage/index.js +1 -9
  59. package/lib/components/CreateInfluencer/CreateInfluencer.js +21 -236
  60. package/lib/components/CreateTearsheet/CreateTearsheet.js +71 -148
  61. package/lib/components/CreateTearsheet/CreateTearsheetStep.js +61 -15
  62. package/lib/components/CreateTearsheet/index.js +0 -8
  63. package/lib/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +67 -35
  64. package/lib/components/ExportModal/ExportModal.js +4 -2
  65. package/lib/components/ImportModal/ImportModal.js +2 -1
  66. package/lib/components/InlineEdit/InlineEdit.js +242 -0
  67. package/lib/components/InlineEdit/index.js +13 -0
  68. package/lib/components/MultiAddSelect/MultiAddSelect.js +37 -0
  69. package/lib/components/MultiAddSelect/index.js +13 -0
  70. package/lib/components/OptionsTile/OptionsTile.js +36 -15
  71. package/lib/components/PageHeader/PageHeader.js +54 -33
  72. package/lib/components/PageHeader/PageHeaderTitle.js +87 -9
  73. package/lib/components/PageHeader/PageHeaderUtils.js +21 -2
  74. package/lib/components/RemoveModal/RemoveModal.js +4 -2
  75. package/lib/components/SingleAddSelect/SingleAddSelect.js +36 -0
  76. package/lib/components/SingleAddSelect/index.js +13 -0
  77. package/lib/components/TagSet/TagSet.js +4 -1
  78. package/lib/components/Toolbar/Toolbar.js +69 -6
  79. package/lib/components/index.js +33 -1
  80. package/lib/global/js/hooks/useCreateComponentFocus.js +15 -19
  81. package/lib/global/js/hooks/useCreateComponentStepChange.js +44 -74
  82. package/lib/global/js/hooks/useValidCreateStepCount.js +4 -7
  83. package/lib/global/js/package-settings.js +5 -1
  84. package/lib/global/js/utils/story-helper.js +1 -1
  85. package/package.json +15 -15
  86. package/scss/components/AddSelect/_add-select.scss +84 -0
  87. package/scss/components/AddSelect/_index.scss +10 -0
  88. package/scss/components/AddSelect/_storybook-styles.scss +6 -0
  89. package/scss/components/BreadcrumbWithOverflow/_breadcrumb-with-overflow.scss +19 -15
  90. package/scss/components/CancelableTextEdit/_cancelable-text-edit.scss +211 -0
  91. package/{es/components/CreateFullPage/constants.js → scss/components/CancelableTextEdit/_index.scss} +2 -2
  92. package/scss/components/CancelableTextEdit/_storybook-styles.scss +15 -0
  93. package/scss/components/CreateFullPage/_create-full-page.scss +4 -11
  94. package/scss/components/CreateTearsheet/_create-tearsheet.scss +4 -8
  95. package/scss/components/InlineEdit/_index.scss +8 -0
  96. package/scss/components/InlineEdit/_inline-edit.scss +44 -0
  97. package/scss/components/InlineEdit/_storybook-styles.scss +15 -0
  98. package/scss/components/MultiAddSelect/_index.scss +1 -0
  99. package/scss/components/MultiAddSelect/_multi-add-select.scss +1 -0
  100. package/scss/components/MultiAddSelect/_storybook-styles.scss +6 -0
  101. package/scss/components/PageHeader/_page-header.scss +14 -4
  102. package/scss/components/SingleAddSelect/_index.scss +1 -0
  103. package/scss/components/SingleAddSelect/_single-add-select.scss +1 -0
  104. package/scss/components/SingleAddSelect/_storybook-styles.scss +6 -0
  105. package/scss/components/_index.scss +4 -0
  106. package/es/components/CreateFullPage/CreateFullPageSection.js +0 -53
  107. package/es/components/CreateTearsheet/CreateTearsheetSection.js +0 -83
  108. package/es/components/CreateTearsheet/preview-components/MultiStepWithSectionsTearsheet.js +0 -327
  109. package/es/global/js/utils/hasValidType.js +0 -94
  110. package/lib/components/CreateFullPage/CreateFullPageSection.js +0 -74
  111. package/lib/components/CreateFullPage/constants.js +0 -16
  112. package/lib/components/CreateTearsheet/CreateTearsheetSection.js +0 -105
  113. package/lib/components/CreateTearsheet/constants.js +0 -17
  114. package/lib/components/CreateTearsheet/preview-components/MultiStepWithSectionsTearsheet.js +0 -354
  115. package/lib/global/js/utils/hasValidType.js +0 -110
@@ -87,7 +87,6 @@ export var APIKeyModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
87
87
  currentStep = _useState6[0],
88
88
  setCurrentStep = _useState6[1];
89
89
 
90
- var inputRef = useRef();
91
90
  var copyRef = useRef();
92
91
  var apiKeyInputId = useRef(uuidv4());
93
92
  var nameInputId = useRef(uuidv4());
@@ -101,11 +100,6 @@ export var APIKeyModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
101
100
  ref: copyRef
102
101
  };
103
102
  var blockClass = "".concat(pkg.prefix, "--apikey-modal");
104
- useEffect(function () {
105
- if (inputRef.current && open) {
106
- inputRef.current.focus();
107
- }
108
- }, [open]);
109
103
  useEffect(function () {
110
104
  if (copyRef.current && open && apiKeyLoaded) {
111
105
  copyRef.current.focus();
@@ -179,70 +173,72 @@ export var APIKeyModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
179
173
  };
180
174
 
181
175
  var submitHandler = /*#__PURE__*/function () {
182
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
176
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(e) {
183
177
  return _regeneratorRuntime.wrap(function _callee$(_context) {
184
178
  while (1) {
185
179
  switch (_context.prev = _context.next) {
186
180
  case 0:
181
+ e.preventDefault();
182
+
187
183
  if (!hasNextStep) {
188
- _context.next = 4;
184
+ _context.next = 5;
189
185
  break;
190
186
  }
191
187
 
192
188
  setCurrentStep(currentStep + 1);
193
- _context.next = 21;
189
+ _context.next = 22;
194
190
  break;
195
191
 
196
- case 4:
192
+ case 5:
197
193
  if (!apiKeyLoaded) {
198
- _context.next = 20;
194
+ _context.next = 21;
199
195
  break;
200
196
  }
201
197
 
202
198
  if (!onCopy) {
203
- _context.next = 9;
199
+ _context.next = 10;
204
200
  break;
205
201
  }
206
202
 
207
203
  onCopy(apiKey);
208
- _context.next = 18;
204
+ _context.next = 19;
209
205
  break;
210
206
 
211
- case 9:
212
- _context.prev = 9;
213
- _context.next = 12;
207
+ case 10:
208
+ _context.prev = 10;
209
+ _context.next = 13;
214
210
  return navigator.clipboard.writeText(apiKey);
215
211
 
216
- case 12:
217
- _context.next = 18;
212
+ case 13:
213
+ _context.next = 19;
218
214
  break;
219
215
 
220
- case 14:
221
- _context.prev = 14;
222
- _context.t0 = _context["catch"](9);
216
+ case 15:
217
+ _context.prev = 15;
218
+ _context.t0 = _context["catch"](10);
223
219
  console.error(_context.t0);
224
220
  setCopyError(true);
225
221
 
226
- case 18:
227
- _context.next = 21;
222
+ case 19:
223
+ _context.next = 22;
228
224
  break;
229
225
 
230
- case 20:
226
+ case 21:
231
227
  if (editing) {
232
228
  onRequestEdit(name);
233
229
  } else {
234
230
  onRequestGenerate(name);
235
231
  }
236
232
 
237
- case 21:
233
+ case 22:
238
234
  case "end":
239
235
  return _context.stop();
240
236
  }
241
237
  }
242
- }, _callee, null, [[9, 14]]);
238
+ }, _callee, null, [[10, 15]]);
243
239
  }));
244
240
 
245
- return function submitHandler() {
241
+ return function submitHandler(_x) {
246
242
  return _ref2.apply(this, arguments);
247
243
  };
248
244
  }();
@@ -293,8 +289,8 @@ export var APIKeyModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
293
289
  value: name,
294
290
  id: nameInputId.current,
295
291
  disabled: loading,
296
- ref: inputRef,
297
- required: nameRequired
292
+ required: nameRequired,
293
+ "data-modal-primary-focus": true
298
294
  })), loading && /*#__PURE__*/React.createElement(InlineLoading, {
299
295
  description: loadingText,
300
296
  className: "".concat(blockClass, "__loader")
@@ -3,7 +3,7 @@ import _extends from "@babel/runtime/helpers/extends";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
5
  var _excluded = ["actions", "className", "maxVisible", "menuOptionsClass", "onWidthChange", "overflowAriaLabel", "rightAlign"],
6
- _excluded2 = ["key"],
6
+ _excluded2 = ["key", "id"],
7
7
  _excluded3 = ["key"];
8
8
 
9
9
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
@@ -80,9 +80,12 @@ export var ActionBar = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
80
80
  key: "hidden-overflow-menu"
81
81
  }), actions.map(function (_ref2) {
82
82
  var key = _ref2.key,
83
+ id = _ref2.id,
83
84
  rest = _objectWithoutProperties(_ref2, _excluded2);
84
85
 
85
86
  return /*#__PURE__*/React.createElement(ActionBarItem, _extends({}, rest, {
87
+ // ensure id is not duplicated
88
+ "data-original-id": id,
86
89
  key: "hidden-item-".concat(key),
87
90
  className: "".concat(blockClass, "__hidden-sizing-item")
88
91
  }));
@@ -0,0 +1,157 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
+ var _excluded = ["actions", "className", "description", "influencerTitle", "inputPlaceholder", "items", "itemsLabel", "multi", "noResultsDescription", "noResultsTitle", "noSelectionDescription", "noSelectionTitle", "onSearchFilter", "open", "title"];
5
+ //
6
+ // Copyright IBM Corp. 2021
7
+ //
8
+ // This source code is licensed under the Apache-2.0 license found in the
9
+ // LICENSE file in the root directory of this source tree.
10
+ //
11
+ import React, { forwardRef, useState } from 'react';
12
+ import PropTypes from 'prop-types';
13
+ import cx from 'classnames';
14
+ import { StructuredListRow, StructuredListWrapper, StructuredListBody, StructuredListCell, // StructuredListInput,
15
+ TextInput, Tag } from 'carbon-components-react';
16
+ import { Tearsheet, TearsheetNarrow } from '../../components/Tearsheet';
17
+ import { NoDataEmptyState } from '../../components/EmptyStates/NoDataEmptyState';
18
+ import { pkg } from '../../settings';
19
+ var componentName = 'AddSelect';
20
+ export var AddSelect = /*#__PURE__*/forwardRef(function (_ref, ref) {
21
+ var actions = _ref.actions,
22
+ className = _ref.className,
23
+ description = _ref.description,
24
+ influencerTitle = _ref.influencerTitle,
25
+ inputPlaceholder = _ref.inputPlaceholder,
26
+ items = _ref.items,
27
+ itemsLabel = _ref.itemsLabel,
28
+ multi = _ref.multi,
29
+ noResultsDescription = _ref.noResultsDescription,
30
+ noResultsTitle = _ref.noResultsTitle,
31
+ noSelectionDescription = _ref.noSelectionDescription,
32
+ noSelectionTitle = _ref.noSelectionTitle,
33
+ onSearchFilter = _ref.onSearchFilter,
34
+ open = _ref.open,
35
+ title = _ref.title,
36
+ rest = _objectWithoutProperties(_ref, _excluded);
37
+
38
+ var blockClass = "".concat(pkg.prefix, "--add-select");
39
+ var commonTearsheetProps = {
40
+ open: open,
41
+ title: title,
42
+ actions: actions,
43
+ description: description,
44
+ closeIconDescription: 'temp description'
45
+ }; // hooks
46
+
47
+ var _useState = useState(0),
48
+ _useState2 = _slicedToArray(_useState, 1),
49
+ selected = _useState2[0];
50
+
51
+ var _useState3 = useState(''),
52
+ _useState4 = _slicedToArray(_useState3, 2),
53
+ searchTerm = _useState4[0],
54
+ setSearchTerm = _useState4[1]; // handlers
55
+
56
+
57
+ var onSearchHandler = function onSearchHandler(e) {
58
+ var value = e.target.value;
59
+ setSearchTerm(value);
60
+
61
+ if (onSearchFilter) {
62
+ onSearchFilter(value);
63
+ }
64
+ }; // data manipulation
65
+
66
+
67
+ var getFilteredItems = function getFilteredItems() {
68
+ // if the user uses their own filter then they provide the filtered items
69
+ if (onSearchFilter) {
70
+ return items;
71
+ } // by default, just filter results by their label from a single search term
72
+
73
+
74
+ return items.filter(function (i) {
75
+ return i.label.includes(searchTerm);
76
+ });
77
+ };
78
+
79
+ var filteredResults = getFilteredItems(); // sidebar
80
+
81
+ var influencer = /*#__PURE__*/React.createElement("div", {
82
+ className: "".concat(blockClass, "__influencer")
83
+ }, /*#__PURE__*/React.createElement("div", {
84
+ className: "".concat(blockClass, "__influencer-header")
85
+ }, /*#__PURE__*/React.createElement("p", {
86
+ className: "".concat(blockClass, "__influencer-title")
87
+ }, influencerTitle), /*#__PURE__*/React.createElement(Tag, {
88
+ type: "gray",
89
+ size: "sm"
90
+ }, selected)), /*#__PURE__*/React.createElement("div", {
91
+ className: "".concat(blockClass, "__influencer-body")
92
+ }, selected > 0 ? /*#__PURE__*/React.createElement("p", null, "content") : /*#__PURE__*/React.createElement(NoDataEmptyState, {
93
+ subtitle: noSelectionDescription,
94
+ title: noSelectionTitle,
95
+ size: "sm"
96
+ }))); // main content
97
+
98
+ var body = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
99
+ className: "".concat(blockClass, "__header")
100
+ }, /*#__PURE__*/React.createElement(TextInput, {
101
+ id: "temp-id",
102
+ labelText: "temp label",
103
+ placeholder: inputPlaceholder,
104
+ value: searchTerm,
105
+ onChange: onSearchHandler
106
+ }), /*#__PURE__*/React.createElement("div", {
107
+ className: "".concat(blockClass, "__items-label-container")
108
+ }, /*#__PURE__*/React.createElement("p", {
109
+ className: "".concat(blockClass, "__items-label")
110
+ }, itemsLabel), /*#__PURE__*/React.createElement(Tag, {
111
+ type: "gray",
112
+ size: "sm"
113
+ }, filteredResults.length))), filteredResults.length > 0 ? /*#__PURE__*/React.createElement(StructuredListWrapper, {
114
+ selection: true,
115
+ className: "".concat(blockClass, "__selections")
116
+ }, /*#__PURE__*/React.createElement(StructuredListBody, null, filteredResults.map(function (item) {
117
+ return /*#__PURE__*/React.createElement(StructuredListRow, {
118
+ key: item.id
119
+ }, /*#__PURE__*/React.createElement(StructuredListCell, null, /*#__PURE__*/React.createElement("p", null, item.label)));
120
+ }))) : /*#__PURE__*/React.createElement("div", {
121
+ className: "".concat(blockClass, "__body")
122
+ }, /*#__PURE__*/React.createElement(NoDataEmptyState, {
123
+ subtitle: noResultsDescription,
124
+ title: noResultsTitle
125
+ })));
126
+ return /*#__PURE__*/React.createElement("div", _extends({
127
+ ref: ref,
128
+ className: cx(className, blockClass)
129
+ }, rest), multi ? /*#__PURE__*/React.createElement(Tearsheet, _extends({}, commonTearsheetProps, {
130
+ influencer: multi && influencer,
131
+ influencerPosition: "right"
132
+ }), body) : /*#__PURE__*/React.createElement(TearsheetNarrow, commonTearsheetProps, body));
133
+ });
134
+ AddSelect.propTypes = {
135
+ actions: PropTypes.array,
136
+ className: PropTypes.string,
137
+ description: PropTypes.string,
138
+ influencerTitle: PropTypes.string,
139
+ inputPlaceholder: PropTypes.string,
140
+ items: PropTypes.arrayOf(PropTypes.shape({
141
+ label: PropTypes.string,
142
+ id: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
143
+ })),
144
+ itemsLabel: PropTypes.string,
145
+ multi: PropTypes.bool,
146
+ noResultsDescription: PropTypes.string,
147
+ noResultsTitle: PropTypes.string,
148
+ noSelectionDescription: PropTypes.string,
149
+ noSelectionTitle: PropTypes.string,
150
+ onSearchFilter: PropTypes.func,
151
+ open: PropTypes.bool,
152
+ title: PropTypes.string
153
+ };
154
+ AddSelect.defaultProps = {
155
+ items: []
156
+ };
157
+ AddSelect.displayName = componentName;
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright IBM Corp. 2021
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
+ export { AddSelect } from './AddSelect';
@@ -3,7 +3,7 @@ import _extends from "@babel/runtime/helpers/extends";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
5
  var _excluded = ["breadcrumbs", "className", "maxVisible", "noTrailingSlash", "overflowAriaLabel"],
6
- _excluded2 = ["label", "key", "title"],
6
+ _excluded2 = ["label", "key", "title", "id"],
7
7
  _excluded3 = ["className", "key", "label", "title"];
8
8
 
9
9
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
@@ -23,7 +23,7 @@ import React, { useState, useEffect, useRef } from 'react'; // Other standard im
23
23
 
24
24
  import PropTypes from 'prop-types';
25
25
  import cx from 'classnames';
26
- import { Button } from 'carbon-components-react';
26
+ import { Link, TooltipIcon } from 'carbon-components-react';
27
27
  import { pkg, carbon } from '../../settings';
28
28
  import { useResizeDetector } from 'react-resize-detector';
29
29
  import { ArrowLeft16 } from '@carbon/icons-react'; // Carbon and package components we use.
@@ -105,11 +105,14 @@ export var BreadcrumbWithOverflow = function BreadcrumbWithOverflow(_ref) {
105
105
  var label = _ref3.label,
106
106
  key = _ref3.key,
107
107
  title = _ref3.title,
108
+ id = _ref3.id,
108
109
  rest = _objectWithoutProperties(_ref3, _excluded2);
109
110
 
110
111
  return /*#__PURE__*/React.createElement(BreadcrumbItem, _extends({
111
112
  key: key
112
113
  }, rest, {
114
+ // ensure id is not duplicated
115
+ "data-original-id": id,
113
116
  title: title !== null && title !== void 0 ? title : label
114
117
  }), label);
115
118
  }))));
@@ -258,7 +261,7 @@ export var BreadcrumbWithOverflow = function BreadcrumbWithOverflow(_ref) {
258
261
  /* istanbul ignore if */
259
262
  // not sure how to test media queries
260
263
 
261
- if ((_backItem = backItem) !== null && _backItem !== void 0 && _backItem.isCurrentPage) {
264
+ if (backItem.isCurrentPage) {
262
265
  backItem = breadcrumbs[breadcrumbs.length - 2];
263
266
  }
264
267
 
@@ -275,20 +278,21 @@ export var BreadcrumbWithOverflow = function BreadcrumbWithOverflow(_ref) {
275
278
  ref: breadcrumbItemWithOverflow
276
279
  }, /*#__PURE__*/React.createElement("div", {
277
280
  className: cx(["".concat(blockClass, "__space")])
278
- }, hiddenSizingItems, ((_backItem2 = backItem) === null || _backItem2 === void 0 ? void 0 : _backItem2.href) && ((_backItem3 = backItem) === null || _backItem3 === void 0 ? void 0 : _backItem3.title) && /*#__PURE__*/React.createElement(Button, {
279
- className: "".concat(blockClass, "__breadcrumb-back-button"),
280
- hasIconOnly: true,
281
- iconDescription: backItem.title,
282
- kind: "ghost",
283
- href: backItem.href,
284
- renderIcon: ArrowLeft16,
285
- size: "field",
286
- tooltipPosition: "right",
287
- type: "button"
288
- }), /*#__PURE__*/React.createElement(Breadcrumb, _extends({
281
+ }, hiddenSizingItems, /*#__PURE__*/React.createElement(Breadcrumb, _extends({
289
282
  className: cx("".concat(blockClass, "__breadcrumb-container"), _defineProperty({}, "".concat(blockClass, "__breadcrumb-container-with-items"), displayedBreadcrumbItems.length > 1)),
290
283
  noTrailingSlash: noTrailingSlash
291
- }, other), displayedBreadcrumbItems)));
284
+ }, other), ((_backItem = backItem) === null || _backItem === void 0 ? void 0 : _backItem.href) && (((_backItem2 = backItem) === null || _backItem2 === void 0 ? void 0 : _backItem2.label) || ((_backItem3 = backItem) === null || _backItem3 === void 0 ? void 0 : _backItem3.title)) && /*#__PURE__*/React.createElement(BreadcrumbItem, {
285
+ className: cx("".concat(blockClass, "__breadcrumb-back"))
286
+ }, /*#__PURE__*/React.createElement(Link, {
287
+ href: backItem.href,
288
+ renderIcon: function renderIcon() {
289
+ return /*#__PURE__*/React.createElement(TooltipIcon, {
290
+ tooltipText: backItem.title || backItem.label,
291
+ direction: "right",
292
+ renderIcon: ArrowLeft16
293
+ });
294
+ }
295
+ })), displayedBreadcrumbItems)));
292
296
  }; // Return a placeholder if not released and not enabled by feature flag
293
297
 
294
298
  BreadcrumbWithOverflow = pkg.checkComponentEnabled(BreadcrumbWithOverflow, componentName);
@@ -0,0 +1,245 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
+ var _excluded = ["className", "hideLabel", "inline", "invalid", "invalidText", "labelText", "onChange", "onInput", "onRevert", "revertDescription", "saveDescription", "saveDisabled", "size", "value", "warn", "warnText"];
6
+
7
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
8
+
9
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
10
+
11
+ /**
12
+ * Copyright IBM Corp. 2021, 2021
13
+ *
14
+ * This source code is licensed under the Apache-2.0 license found in the
15
+ * LICENSE file in the root directory of this source tree.
16
+ */
17
+ // Import portions of React that are needed.
18
+ import React, { useEffect, useState } from 'react'; // Other standard imports.
19
+
20
+ import PropTypes from 'prop-types';
21
+ import cx from 'classnames';
22
+ import { Button, TextInput } from 'carbon-components-react';
23
+ import { prepareProps } from '../../global/js/utils/props-helper';
24
+ import { pkg, carbon } from '../../settings';
25
+ import { getDevtoolsProps } from '../../global/js/utils/devtools';
26
+ import { Checkmark16, Reset16 } from '@carbon/icons-react'; // Carbon and package components we use.
27
+
28
+ /* TODO: @import(s) of carbon components and other package components. */
29
+ // The block part of our conventional BEM class names (blockClass__E--M).
30
+
31
+ var blockClass = "".concat(pkg.prefix, "--cancelable-text-edit");
32
+ var componentName = 'CancelableTextEdit'; // NOTE: the component SCSS is not imported here: it is rolled up separately.
33
+
34
+ /**
35
+ * TODO: A description of the component.
36
+ */
37
+
38
+ export var CancelableTextEdit = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
39
+ var _cx;
40
+
41
+ var className = _ref.className,
42
+ hideLabel = _ref.hideLabel,
43
+ inline = _ref.inline,
44
+ invalid = _ref.invalid,
45
+ invalidText = _ref.invalidText,
46
+ labelText = _ref.labelText,
47
+ onChange = _ref.onChange,
48
+ onInput = _ref.onInput,
49
+ onRevert = _ref.onRevert,
50
+ revertDescription = _ref.revertDescription,
51
+ saveDescription = _ref.saveDescription,
52
+ saveDisabled = _ref.saveDisabled,
53
+ size = _ref.size,
54
+ value = _ref.value,
55
+ warn = _ref.warn,
56
+ warnText = _ref.warnText,
57
+ rest = _objectWithoutProperties(_ref, _excluded);
58
+
59
+ // remove these props later
60
+ var removeProps = ['children', 'onInput', 'onChange', 'value'];
61
+ var showWarn = inline && warn && !invalid;
62
+ var showInvalid = inline && invalid;
63
+
64
+ var _useState = useState(value !== null && value !== void 0 ? value : ''),
65
+ _useState2 = _slicedToArray(_useState, 2),
66
+ liveValue = _useState2[0],
67
+ setLiveValue = _useState2[1];
68
+
69
+ useEffect(function () {
70
+ if (value !== liveValue) {
71
+ setLiveValue(value);
72
+ } // Do not care if liveValue changes here
73
+ // eslint-disable-next-line react-hooks/exhaustive-deps
74
+
75
+ }, [value]);
76
+
77
+ var doInput = function doInput(newValue) {
78
+ setLiveValue(newValue);
79
+
80
+ if (onInput) {
81
+ onInput(newValue);
82
+ }
83
+ };
84
+
85
+ var handleInput = function handleInput(ev) {
86
+ doInput(ev.target.value);
87
+ };
88
+
89
+ var handleRevert = function handleRevert() {
90
+ doInput(value);
91
+
92
+ if (onRevert) {
93
+ onRevert(value);
94
+ }
95
+ };
96
+
97
+ var handleSave = function handleSave() {
98
+ if (onChange && !invalid) {
99
+ onChange(liveValue);
100
+ }
101
+ };
102
+
103
+ return /*#__PURE__*/React.createElement("div", _extends({
104
+ className: cx(className, "".concat(blockClass), "".concat(blockClass, "--").concat(size), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "--invalid"), invalid), _defineProperty(_cx, "".concat(blockClass, "--warn"), warn), _defineProperty(_cx, "".concat(blockClass, "--inline"), inline), _cx))
105
+ }, getDevtoolsProps(componentName)), /*#__PURE__*/React.createElement("div", {
106
+ className: "".concat(blockClass, "__main")
107
+ }, /*#__PURE__*/React.createElement(TextInput, _extends({}, prepareProps(rest, removeProps), {
108
+ // it is not permitted to pass children down to TextInput guard against this
109
+ className: "".concat(blockClass, "__input"),
110
+ ref: ref,
111
+ onInput: handleInput,
112
+ size: size,
113
+ value: liveValue !== null && liveValue !== void 0 ? liveValue : '' // ?? '' prevents controlled components test failure https://reactjs.org/docs/forms.html#controlled-components
114
+ ,
115
+ hideLabel: hideLabel,
116
+ inline: inline,
117
+ invalid: invalid,
118
+ invalidText: invalidText,
119
+ labelText: labelText,
120
+ warn: warn,
121
+ warnText: warnText
122
+ })), /*#__PURE__*/React.createElement("div", {
123
+ className: "".concat(blockClass, "__buttons")
124
+ }, !inline && !hideLabel && labelText && /*#__PURE__*/React.createElement("div", {
125
+ className: "".concat(blockClass, "__label-spacer ").concat(carbon.prefix, "--label")
126
+ }, "\xA0"), /*#__PURE__*/React.createElement("div", {
127
+ className: "".concat(blockClass, "__buttons-inner")
128
+ }, /*#__PURE__*/React.createElement(Button, {
129
+ className: "".concat(blockClass, "__revert"),
130
+ kind: "ghost",
131
+ hasIconOnly: true,
132
+ iconDescription: revertDescription,
133
+ onClick: handleRevert,
134
+ renderIcon: Reset16
135
+ }), /*#__PURE__*/React.createElement(Button, {
136
+ className: "".concat(blockClass, "__save"),
137
+ kind: "ghost",
138
+ hasIconOnly: true,
139
+ iconDescription: saveDescription,
140
+ onClick: handleSave,
141
+ renderIcon: Checkmark16,
142
+ disabled: invalid || saveDisabled || value === liveValue,
143
+ "data-v": value,
144
+ "data-lv": liveValue
145
+ })))), inline && (showInvalid || showWarn) && /*#__PURE__*/React.createElement("div", {
146
+ className: "".concat(blockClass, "__problem ").concat(carbon.prefix, "--form-requirement")
147
+ }, showInvalid ? invalidText : warnText));
148
+ }); // Return a placeholder if not released and not enabled by feature flag
149
+
150
+ CancelableTextEdit = pkg.checkComponentEnabled(CancelableTextEdit, componentName); // The display name of the component, used by React. Note that displayName
151
+ // is used in preference to relying on function.name.
152
+
153
+ CancelableTextEdit.displayName = componentName; // The types and DocGen commentary for the component props,
154
+ // in alphabetical order (for consistency).
155
+ // See https://www.npmjs.com/package/prop-types#usage.
156
+
157
+ CancelableTextEdit.propTypes = _objectSpread(_objectSpread({}, prepareProps(TextInput.propTypes, ['inline', 'invalid', 'invalidText', 'labelText', 'onChange', 'onInput', 'value', 'warn', 'warnText'])), {}, {
158
+ /**
159
+ * Provide an optional class to be applied to the containing node.
160
+ */
161
+ className: PropTypes.string,
162
+
163
+ /**
164
+ * hide the label
165
+ */
166
+ hideLabel: PropTypes.bool,
167
+
168
+ /**
169
+ * inline variant
170
+ */
171
+ inline: PropTypes.bool,
172
+
173
+ /**
174
+ * set invalid state for input
175
+ */
176
+ invalid: PropTypes.bool,
177
+
178
+ /**
179
+ * text shown when invalid is true
180
+ */
181
+ invalidText: PropTypes.string,
182
+
183
+ /**
184
+ * label for text input
185
+ */
186
+ labelText: PropTypes.string,
187
+
188
+ /**
189
+ * method called on change event
190
+ */
191
+ onChange: PropTypes.func,
192
+
193
+ /**
194
+ * method called on input event
195
+ */
196
+ onInput: PropTypes.func,
197
+
198
+ /**
199
+ * method called on revert event
200
+ */
201
+ onRevert: PropTypes.func,
202
+
203
+ /**
204
+ * label for revert button
205
+ */
206
+ revertDescription: PropTypes.string.isRequired,
207
+
208
+ /**
209
+ * label for save button
210
+ */
211
+ saveDescription: PropTypes.string.isRequired,
212
+
213
+ /**
214
+ * disabled state of the save button
215
+ */
216
+ saveDisabled: PropTypes.bool,
217
+
218
+ /**
219
+ * vertical size of control
220
+ */
221
+ size: PropTypes.oneOf(['sm', 'md', 'lg']),
222
+
223
+ /**
224
+ * initial/unedited value
225
+ */
226
+ value: PropTypes.string,
227
+
228
+ /**
229
+ * set warn state for input
230
+ */
231
+ warn: PropTypes.bool,
232
+
233
+ /**
234
+ * text shown when warn true
235
+ */
236
+ warnText: PropTypes.string
237
+ }); // Default values for component props. Default values are not required for
238
+ // props that are required, nor for props where the component can apply
239
+ // 'undefined' values reasonably. Default values should be provided when the
240
+ // component needs to make a choice or assumption when a prop is not supplied.
241
+
242
+ CancelableTextEdit.defaultProps = {
243
+ /* TODO: add defaults for relevant props. */
244
+ size: 'md'
245
+ };
@@ -4,5 +4,4 @@
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- export var CREATE_TEARSHEET_STEP = 'CreateTearsheetStep';
8
- export var CREATE_TEARSHEET_SECTION = 'CreateTearsheetSection';
7
+ export { CancelableTextEdit } from './CancelableTextEdit';