@carbon/ibm-products 1.2.4 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. package/css/index-full-carbon.css +662 -313
  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 +156 -81
  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 +393 -81
  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 +615 -81
  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/ActionSet/ActionSet.js +22 -10
  16. package/es/components/ActionSet/actions.js +25 -17
  17. package/es/components/AddSelect/AddSelect.js +157 -0
  18. package/es/components/AddSelect/index.js +7 -0
  19. package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +19 -15
  20. package/es/components/CancelableTextEdit/CancelableTextEdit.js +245 -0
  21. package/es/components/{CreateTearsheet/constants.js → CancelableTextEdit/index.js} +1 -2
  22. package/es/components/CreateFullPage/CreateFullPage.js +102 -258
  23. package/es/components/CreateFullPage/CreateFullPageStep.js +65 -13
  24. package/es/components/CreateFullPage/index.js +1 -2
  25. package/es/components/CreateInfluencer/CreateInfluencer.js +40 -220
  26. package/es/components/CreateTearsheet/CreateTearsheet.js +95 -146
  27. package/es/components/CreateTearsheet/CreateTearsheetStep.js +70 -20
  28. package/es/components/CreateTearsheet/index.js +0 -1
  29. package/es/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +87 -28
  30. package/es/components/CreateTearsheet/preview-components/MultiStepWithIntro.js +8 -6
  31. package/es/components/ExportModal/ExportModal.js +41 -12
  32. package/es/components/ImportModal/ImportModal.js +2 -1
  33. package/es/components/InlineEdit/InlineEdit.js +224 -0
  34. package/es/components/InlineEdit/index.js +7 -0
  35. package/es/components/MultiAddSelect/MultiAddSelect.js +16 -0
  36. package/es/components/MultiAddSelect/index.js +1 -0
  37. package/es/components/OptionsTile/OptionsTile.js +36 -15
  38. package/es/components/PageHeader/PageHeader.js +54 -33
  39. package/es/components/PageHeader/PageHeaderTitle.js +78 -7
  40. package/es/components/PageHeader/PageHeaderUtils.js +21 -2
  41. package/es/components/RemoveModal/RemoveModal.js +4 -2
  42. package/es/components/SidePanel/SidePanel.js +1 -1
  43. package/es/components/SingleAddSelect/SingleAddSelect.js +15 -0
  44. package/es/components/SingleAddSelect/index.js +1 -0
  45. package/es/components/TagSet/TagSet.js +4 -1
  46. package/es/components/Tearsheet/Tearsheet.js +1 -1
  47. package/es/components/Tearsheet/TearsheetNarrow.js +1 -1
  48. package/es/components/Tearsheet/TearsheetShell.js +1 -1
  49. package/es/components/Toolbar/Toolbar.js +69 -8
  50. package/es/components/index.js +5 -1
  51. package/es/global/js/hooks/index.js +1 -0
  52. package/es/global/js/hooks/useCreateComponentFocus.js +15 -19
  53. package/es/global/js/hooks/useCreateComponentStepChange.js +69 -79
  54. package/es/global/js/hooks/useResetCreateComponent.js +7 -4
  55. package/es/global/js/hooks/useRetrieveStepData.js +51 -0
  56. package/es/global/js/hooks/useValidCreateStepCount.js +4 -7
  57. package/es/global/js/package-settings.js +5 -1
  58. package/es/global/js/utils/lastIndexInArray.js +26 -0
  59. package/es/global/js/utils/story-helper.js +1 -1
  60. package/lib/components/APIKeyModal/APIKeyModal.js +25 -29
  61. package/lib/components/ActionBar/ActionBar.js +4 -1
  62. package/lib/components/ActionSet/ActionSet.js +22 -10
  63. package/lib/components/ActionSet/actions.js +25 -17
  64. package/lib/components/AddSelect/AddSelect.js +178 -0
  65. package/lib/components/AddSelect/index.js +13 -0
  66. package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +18 -14
  67. package/lib/components/CancelableTextEdit/CancelableTextEdit.js +265 -0
  68. package/lib/components/CancelableTextEdit/index.js +13 -0
  69. package/lib/components/CreateFullPage/CreateFullPage.js +102 -258
  70. package/lib/components/CreateFullPage/CreateFullPageStep.js +68 -13
  71. package/lib/components/CreateFullPage/index.js +1 -9
  72. package/lib/components/CreateInfluencer/CreateInfluencer.js +38 -231
  73. package/lib/components/CreateTearsheet/CreateTearsheet.js +97 -148
  74. package/lib/components/CreateTearsheet/CreateTearsheetStep.js +72 -19
  75. package/lib/components/CreateTearsheet/index.js +0 -8
  76. package/lib/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +86 -34
  77. package/lib/components/CreateTearsheet/preview-components/MultiStepWithIntro.js +8 -6
  78. package/lib/components/ExportModal/ExportModal.js +38 -11
  79. package/lib/components/ImportModal/ImportModal.js +2 -1
  80. package/lib/components/InlineEdit/InlineEdit.js +242 -0
  81. package/lib/components/InlineEdit/index.js +13 -0
  82. package/lib/components/MultiAddSelect/MultiAddSelect.js +37 -0
  83. package/lib/components/MultiAddSelect/index.js +13 -0
  84. package/lib/components/OptionsTile/OptionsTile.js +36 -15
  85. package/lib/components/PageHeader/PageHeader.js +54 -33
  86. package/lib/components/PageHeader/PageHeaderTitle.js +87 -9
  87. package/lib/components/PageHeader/PageHeaderUtils.js +21 -2
  88. package/lib/components/RemoveModal/RemoveModal.js +4 -2
  89. package/lib/components/SidePanel/SidePanel.js +1 -1
  90. package/lib/components/SingleAddSelect/SingleAddSelect.js +36 -0
  91. package/lib/components/SingleAddSelect/index.js +13 -0
  92. package/lib/components/TagSet/TagSet.js +4 -1
  93. package/lib/components/Tearsheet/Tearsheet.js +1 -1
  94. package/lib/components/Tearsheet/TearsheetNarrow.js +1 -1
  95. package/lib/components/Tearsheet/TearsheetShell.js +1 -1
  96. package/lib/components/Toolbar/Toolbar.js +69 -6
  97. package/lib/components/index.js +33 -1
  98. package/lib/global/js/hooks/index.js +8 -0
  99. package/lib/global/js/hooks/useCreateComponentFocus.js +15 -19
  100. package/lib/global/js/hooks/useCreateComponentStepChange.js +69 -79
  101. package/lib/global/js/hooks/useResetCreateComponent.js +7 -4
  102. package/lib/global/js/hooks/useRetrieveStepData.js +62 -0
  103. package/lib/global/js/hooks/useValidCreateStepCount.js +4 -7
  104. package/lib/global/js/package-settings.js +5 -1
  105. package/lib/global/js/utils/lastIndexInArray.js +35 -0
  106. package/lib/global/js/utils/story-helper.js +1 -1
  107. package/package.json +22 -22
  108. package/scss/components/AddSelect/_add-select.scss +84 -0
  109. package/scss/components/AddSelect/_index.scss +10 -0
  110. package/scss/components/AddSelect/_storybook-styles.scss +6 -0
  111. package/scss/components/BreadcrumbWithOverflow/_breadcrumb-with-overflow.scss +19 -15
  112. package/scss/components/CancelableTextEdit/_cancelable-text-edit.scss +211 -0
  113. package/{es/components/CreateFullPage/constants.js → scss/components/CancelableTextEdit/_index.scss} +2 -2
  114. package/scss/components/CancelableTextEdit/_storybook-styles.scss +15 -0
  115. package/scss/components/CreateFullPage/_create-full-page.scss +4 -11
  116. package/scss/components/CreateTearsheet/_create-tearsheet.scss +4 -8
  117. package/scss/components/InlineEdit/_index.scss +8 -0
  118. package/scss/components/InlineEdit/_inline-edit.scss +44 -0
  119. package/scss/components/InlineEdit/_storybook-styles.scss +15 -0
  120. package/scss/components/MultiAddSelect/_index.scss +1 -0
  121. package/scss/components/MultiAddSelect/_multi-add-select.scss +1 -0
  122. package/scss/components/MultiAddSelect/_storybook-styles.scss +6 -0
  123. package/scss/components/PageHeader/_page-header.scss +14 -4
  124. package/scss/components/SingleAddSelect/_index.scss +1 -0
  125. package/scss/components/SingleAddSelect/_single-add-select.scss +1 -0
  126. package/scss/components/SingleAddSelect/_storybook-styles.scss +6 -0
  127. package/scss/components/StatusIcon/_status-icon.scss +2 -0
  128. package/scss/components/_index.scss +4 -0
  129. package/es/components/CreateFullPage/CreateFullPageSection.js +0 -53
  130. package/es/components/CreateTearsheet/CreateTearsheetSection.js +0 -83
  131. package/es/components/CreateTearsheet/preview-components/MultiStepWithSectionsTearsheet.js +0 -327
  132. package/es/global/js/utils/hasValidType.js +0 -94
  133. package/lib/components/CreateFullPage/CreateFullPageSection.js +0 -74
  134. package/lib/components/CreateFullPage/constants.js +0 -16
  135. package/lib/components/CreateTearsheet/CreateTearsheetSection.js +0 -105
  136. package/lib/components/CreateTearsheet/constants.js +0 -17
  137. package/lib/components/CreateTearsheet/preview-components/MultiStepWithSectionsTearsheet.js +0 -354
  138. 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
  }));
@@ -38,7 +38,7 @@ var ActionSetButton = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
38
38
 
39
39
  return /*#__PURE__*/React.createElement(Button, _extends({}, rest, {
40
40
  isExpressive: true,
41
- className: cx(className, ["".concat(blockClass, "__action-button"), _defineProperty({}, "".concat(blockClass, "__action-button--ghost"), kind === 'ghost')]),
41
+ className: cx(className, ["".concat(blockClass, "__action-button"), _defineProperty({}, "".concat(blockClass, "__action-button--ghost"), kind === 'ghost' || kind === 'danger--ghost')]),
42
42
  disabled: disabled || loading || false,
43
43
  kind: kind,
44
44
  onClick: onClick,
@@ -48,7 +48,7 @@ var ActionSetButton = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
48
48
  });
49
49
  ActionSetButton.displayName = 'ActionSetButton';
50
50
  ActionSetButton.propTypes = _objectSpread(_objectSpread({}, Button.PropTypes), {}, {
51
- kind: PropTypes.oneOf(['ghost', 'secondary', 'primary']),
51
+ kind: PropTypes.oneOf(['ghost', 'danger--ghost', 'secondary', 'danger', 'primary']),
52
52
  label: PropTypes.string,
53
53
  loading: PropTypes.bool
54
54
  });
@@ -82,13 +82,24 @@ export var ActionSet = /*#__PURE__*/React.forwardRef(function (_ref3, ref) {
82
82
 
83
83
  var buttons = actions && ((_actions$slice = actions.slice) === null || _actions$slice === void 0 ? void 0 : _actions$slice.call(actions, 0)) || []; // We stack the buttons in a xs/sm set, or if there are three or more in a md set.
84
84
 
85
- var stacking = willStack(size, buttons.length); // order the actions with ghost buttons first and primary buttons last
86
- // (and the opposite way if we're stacking)
85
+ var stacking = willStack(size, buttons.length); // Order of button kinds: ghost first, then danger--ghost, then most other types,
86
+ // then danger, and finally primary
87
+
88
+ var buttonOrder = function buttonOrder(kind) {
89
+ var _ghost$dangerGhost$;
90
+
91
+ return (_ghost$dangerGhost$ = {
92
+ ghost: 1,
93
+ 'danger--ghost': 2,
94
+ danger: 4,
95
+ primary: 5
96
+ }[kind]) !== null && _ghost$dangerGhost$ !== void 0 ? _ghost$dangerGhost$ : 3;
97
+ }; // order the actions with ghost/ghost-danger buttons first and primary/danger buttons last
98
+ // (or the opposite way if we're stacking)
99
+
87
100
 
88
101
  buttons.sort(function (action1, action2) {
89
- var kind1 = action1.kind || defaultKind;
90
- var kind2 = action2.kind || defaultKind;
91
- return kind1 === 'ghost' || kind2 === 'primary' ? stacking ? 1 : -1 : kind1 === 'primary' || kind2 === 'ghost' ? stacking ? -1 : 1 : 0;
102
+ return (buttonOrder(action1.kind || defaultKind) - buttonOrder(action2.kind || defaultKind)) * (stacking ? -1 : 1);
92
103
  });
93
104
  return /*#__PURE__*/React.createElement(ButtonSet, _extends({}, rest, {
94
105
  className: cx(blockClass, className, (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "--row-single"), !stacking && buttons.length === 1), _defineProperty(_cx, "".concat(blockClass, "--row-double"), !stacking && buttons.length === 2), _defineProperty(_cx, "".concat(blockClass, "--row-triple"), !stacking && buttons.length === 3), _defineProperty(_cx, "".concat(blockClass, "--row-quadruple"), !stacking && buttons.length >= 4), _defineProperty(_cx, "".concat(blockClass, "--stacking"), stacking), _cx), "".concat(blockClass, "--").concat(size)),
@@ -137,13 +148,14 @@ ActionSet.validateActions = function (sizeFn) {
137
148
 
138
149
  var primaryActions = countActions('primary');
139
150
  var secondaryActions = countActions('secondary');
140
- var ghostActions = countActions('ghost');
151
+ var dangerActions = countActions('danger');
152
+ var ghostActions = countActions('ghost') + countActions('danger--ghost');
141
153
  stacking && actions > 3 && problems.push("you cannot have more than three actions in this size of ".concat(componentName));
142
154
  actions > 4 && problems.push("you cannot have more than four actions in a ".concat(componentName));
143
155
  primaryActions > 1 && problems.push("you cannot have more than one 'primary' action in a ".concat(componentName));
144
156
  ghostActions > 1 && problems.push("you cannot have more than one 'ghost' action in a ".concat(componentName));
145
157
  stacking && actions > 1 && ghostActions > 0 && problems.push("you cannot have a 'ghost' button in conjunction with other action types in this size of ".concat(componentName));
146
- actions > primaryActions + secondaryActions + ghostActions && problems.push("you can only have 'primary', 'secondary' and 'ghost' buttons in a ".concat(componentName));
158
+ actions > primaryActions + secondaryActions + dangerActions + ghostActions && problems.push("you can only have 'primary', 'danger', 'secondary', 'ghost' and 'danger--ghost' buttons in a ".concat(componentName));
147
159
  }
148
160
 
149
161
  return problems.length > 0 ? new Error("Invalid ".concat(location, " `").concat(name, "` supplied to `").concat(componentName, "`: ").concat(problems.join(', and '), ".")) : null;
@@ -164,7 +176,7 @@ ActionSet.propTypes = {
164
176
  * See https://react.carbondesignsystem.com/?path=/docs/components-button--default#component-api
165
177
  */
166
178
  actions: allPropTypes([ActionSet.validateActions(), PropTypes.arrayOf(PropTypes.shape(_objectSpread(_objectSpread({}, Button.propTypes), {}, {
167
- kind: PropTypes.oneOf(['ghost', 'secondary', 'primary']),
179
+ kind: PropTypes.oneOf(['ghost', 'danger--ghost', 'secondary', 'danger', 'primary']),
168
180
  label: PropTypes.string,
169
181
  loading: PropTypes.bool,
170
182
  // we duplicate this Button prop to improve the DocGen here
@@ -4,19 +4,22 @@
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 actionsOptions = [0, 1, 2, 3, 4, 5, 6, 7];
7
+ export var actionsOptions = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
8
8
  export var actionsLabels = {
9
9
  0: 'None',
10
10
  1: 'One button',
11
- 2: 'One ghost button',
12
- 3: 'Two buttons',
13
- 4: 'Two buttons including one ghost',
14
- 5: 'Three buttons',
15
- 6: 'Three buttons including one ghost',
16
- 7: 'Four buttons including one ghost'
11
+ 2: 'A danger button',
12
+ 3: 'A ghost button',
13
+ 4: 'Two buttons',
14
+ 5: 'Two buttons with one ghost',
15
+ 6: 'Three buttons',
16
+ 7: 'Three buttons with one ghost',
17
+ 8: 'Three buttons with one danger',
18
+ 9: 'Four buttons with one ghost',
19
+ 10: 'Four buttons with two danger'
17
20
  };
18
21
  export var actionsMapping = function actionsMapping(labels, action) {
19
- var _labels$primary, _labels$secondary, _labels$secondary2, _labels$ghost;
22
+ var _labels$primary, _labels$danger, _labels$secondary, _labels$secondary2, _labels$dangerGhost, _labels$ghost;
20
23
 
21
24
  var act = function act(label, kind, key) {
22
25
  var actionCall = action && action("Click on '".concat(label, "'"));
@@ -32,17 +35,22 @@ export var actionsMapping = function actionsMapping(labels, action) {
32
35
  };
33
36
 
34
37
  var primary = act((_labels$primary = labels === null || labels === void 0 ? void 0 : labels.primary) !== null && _labels$primary !== void 0 ? _labels$primary : 'Primary', 'primary', 1);
35
- var secondary = act((_labels$secondary = labels === null || labels === void 0 ? void 0 : labels.secondary) !== null && _labels$secondary !== void 0 ? _labels$secondary : 'Secondary', 'secondary', 2);
36
- var secondary2 = act((_labels$secondary2 = labels === null || labels === void 0 ? void 0 : labels.secondary2) !== null && _labels$secondary2 !== void 0 ? _labels$secondary2 : 'Secondary', 'secondary', 3);
37
- var ghost = act((_labels$ghost = labels === null || labels === void 0 ? void 0 : labels.ghost) !== null && _labels$ghost !== void 0 ? _labels$ghost : 'Ghost', 'ghost', 4);
38
+ var danger = act((_labels$danger = labels === null || labels === void 0 ? void 0 : labels.danger) !== null && _labels$danger !== void 0 ? _labels$danger : 'Danger', 'danger', 2);
39
+ var secondary = act((_labels$secondary = labels === null || labels === void 0 ? void 0 : labels.secondary) !== null && _labels$secondary !== void 0 ? _labels$secondary : 'Secondary', 'secondary', 3);
40
+ var secondary2 = act((_labels$secondary2 = labels === null || labels === void 0 ? void 0 : labels.secondary2) !== null && _labels$secondary2 !== void 0 ? _labels$secondary2 : 'Secondary', 'secondary', 4);
41
+ var dangerGhost = act((_labels$dangerGhost = labels === null || labels === void 0 ? void 0 : labels.dangerGhost) !== null && _labels$dangerGhost !== void 0 ? _labels$dangerGhost : 'Danger-ghost', 'danger--ghost', 5);
42
+ var ghost = act((_labels$ghost = labels === null || labels === void 0 ? void 0 : labels.ghost) !== null && _labels$ghost !== void 0 ? _labels$ghost : 'Ghost', 'ghost', 6);
38
43
  return {
39
44
  0: [],
40
45
  1: [primary],
41
- 2: [ghost],
42
- 3: [primary, secondary],
43
- 4: [primary, ghost],
44
- 5: [primary, secondary, secondary2],
45
- 6: [primary, secondary, ghost],
46
- 7: [primary, secondary, secondary2, ghost]
46
+ 2: [danger],
47
+ 3: [ghost],
48
+ 4: [primary, secondary],
49
+ 5: [primary, ghost],
50
+ 6: [primary, secondary, secondary2],
51
+ 7: [primary, secondary, ghost],
52
+ 8: [danger, secondary, ghost],
53
+ 9: [primary, secondary, secondary2, ghost],
54
+ 10: [danger, secondary, secondary2, dangerGhost]
47
55
  };
48
56
  };
@@ -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);