@carbon/ibm-products 1.2.5 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. package/css/index-full-carbon.css +1028 -517
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +3 -3
  4. package/css/index-without-carbon-released-only.css +187 -108
  5. package/css/index-without-carbon-released-only.css.map +1 -1
  6. package/css/index-without-carbon-released-only.min.css +3 -3
  7. package/css/index-without-carbon.css +580 -114
  8. package/css/index-without-carbon.css.map +1 -1
  9. package/css/index-without-carbon.min.css +3 -3
  10. package/css/index.css +804 -116
  11. package/css/index.css.map +1 -1
  12. package/css/index.min.css +3 -3
  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 +198 -0
  18. package/es/components/AddSelect/AddSelectBreadcrumbs.js +56 -0
  19. package/es/components/AddSelect/AddSelectList.js +94 -0
  20. package/es/components/AddSelect/AddSelectSidebar.js +46 -0
  21. package/es/components/AddSelect/index.js +7 -0
  22. package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +24 -17
  23. package/es/components/CancelableTextEdit/CancelableTextEdit.js +245 -0
  24. package/es/components/{CreateTearsheet/constants.js → CancelableTextEdit/index.js} +1 -2
  25. package/es/components/Card/Card.js +6 -4
  26. package/es/components/CreateFullPage/CreateFullPage.js +102 -258
  27. package/es/components/CreateFullPage/CreateFullPageStep.js +65 -13
  28. package/es/components/CreateFullPage/index.js +1 -2
  29. package/es/components/CreateInfluencer/CreateInfluencer.js +40 -220
  30. package/es/components/CreateTearsheet/CreateTearsheet.js +95 -146
  31. package/es/components/CreateTearsheet/CreateTearsheetStep.js +70 -20
  32. package/es/components/CreateTearsheet/index.js +0 -1
  33. package/es/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +87 -28
  34. package/es/components/CreateTearsheet/preview-components/MultiStepWithIntro.js +8 -6
  35. package/es/components/ExportModal/ExportModal.js +41 -12
  36. package/es/components/ImportModal/ImportModal.js +2 -1
  37. package/es/components/InlineEdit/InlineEdit.js +373 -0
  38. package/es/components/InlineEdit/index.js +7 -0
  39. package/es/components/MultiAddSelect/MultiAddSelect.js +16 -0
  40. package/es/components/MultiAddSelect/index.js +1 -0
  41. package/es/components/NotificationsPanel/NotificationsPanel.js +16 -3
  42. package/es/components/OptionsTile/OptionsTile.js +36 -15
  43. package/es/components/PageHeader/PageHeader.js +59 -35
  44. package/es/components/PageHeader/PageHeaderTitle.js +82 -7
  45. package/es/components/PageHeader/PageHeaderUtils.js +21 -2
  46. package/es/components/RemoveModal/RemoveModal.js +4 -2
  47. package/es/components/SidePanel/SidePanel.js +33 -16
  48. package/es/components/SingleAddSelect/SingleAddSelect.js +15 -0
  49. package/es/components/SingleAddSelect/index.js +1 -0
  50. package/es/components/TagSet/TagSet.js +4 -1
  51. package/es/components/Tearsheet/Tearsheet.js +1 -1
  52. package/es/components/Tearsheet/TearsheetNarrow.js +1 -1
  53. package/es/components/Tearsheet/TearsheetShell.js +1 -1
  54. package/es/components/Toolbar/Toolbar.js +69 -8
  55. package/es/components/WebTerminal/WebTerminal.js +1 -1
  56. package/es/components/index.js +5 -1
  57. package/es/global/js/hooks/index.js +1 -0
  58. package/es/global/js/hooks/useCreateComponentFocus.js +15 -19
  59. package/es/global/js/hooks/useCreateComponentStepChange.js +69 -79
  60. package/es/global/js/hooks/useResetCreateComponent.js +7 -4
  61. package/es/global/js/hooks/useRetrieveStepData.js +51 -0
  62. package/es/global/js/hooks/useValidCreateStepCount.js +4 -7
  63. package/es/global/js/package-settings.js +5 -1
  64. package/es/global/js/utils/lastIndexInArray.js +26 -0
  65. package/es/settings.js +0 -5
  66. package/lib/components/APIKeyModal/APIKeyModal.js +25 -29
  67. package/lib/components/ActionBar/ActionBar.js +4 -1
  68. package/lib/components/ActionSet/ActionSet.js +22 -10
  69. package/lib/components/ActionSet/actions.js +25 -17
  70. package/lib/components/AddSelect/AddSelect.js +223 -0
  71. package/lib/components/AddSelect/AddSelectBreadcrumbs.js +71 -0
  72. package/lib/components/AddSelect/AddSelectList.js +112 -0
  73. package/lib/components/AddSelect/AddSelectSidebar.js +63 -0
  74. package/lib/components/AddSelect/index.js +13 -0
  75. package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +23 -16
  76. package/lib/components/CancelableTextEdit/CancelableTextEdit.js +265 -0
  77. package/lib/components/CancelableTextEdit/index.js +13 -0
  78. package/lib/components/Card/Card.js +6 -4
  79. package/lib/components/CreateFullPage/CreateFullPage.js +102 -258
  80. package/lib/components/CreateFullPage/CreateFullPageStep.js +68 -13
  81. package/lib/components/CreateFullPage/index.js +1 -9
  82. package/lib/components/CreateInfluencer/CreateInfluencer.js +38 -231
  83. package/lib/components/CreateTearsheet/CreateTearsheet.js +97 -148
  84. package/lib/components/CreateTearsheet/CreateTearsheetStep.js +72 -19
  85. package/lib/components/CreateTearsheet/index.js +0 -8
  86. package/lib/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +86 -34
  87. package/lib/components/CreateTearsheet/preview-components/MultiStepWithIntro.js +8 -6
  88. package/lib/components/ExportModal/ExportModal.js +38 -11
  89. package/lib/components/ImportModal/ImportModal.js +2 -1
  90. package/lib/components/InlineEdit/InlineEdit.js +389 -0
  91. package/lib/components/InlineEdit/index.js +13 -0
  92. package/lib/components/MultiAddSelect/MultiAddSelect.js +37 -0
  93. package/lib/components/MultiAddSelect/index.js +13 -0
  94. package/lib/components/NotificationsPanel/NotificationsPanel.js +13 -1
  95. package/lib/components/OptionsTile/OptionsTile.js +36 -15
  96. package/lib/components/PageHeader/PageHeader.js +59 -35
  97. package/lib/components/PageHeader/PageHeaderTitle.js +91 -9
  98. package/lib/components/PageHeader/PageHeaderUtils.js +21 -2
  99. package/lib/components/RemoveModal/RemoveModal.js +4 -2
  100. package/lib/components/SidePanel/SidePanel.js +33 -16
  101. package/lib/components/SingleAddSelect/SingleAddSelect.js +36 -0
  102. package/lib/components/SingleAddSelect/index.js +13 -0
  103. package/lib/components/TagSet/TagSet.js +4 -1
  104. package/lib/components/Tearsheet/Tearsheet.js +1 -1
  105. package/lib/components/Tearsheet/TearsheetNarrow.js +1 -1
  106. package/lib/components/Tearsheet/TearsheetShell.js +1 -1
  107. package/lib/components/Toolbar/Toolbar.js +69 -6
  108. package/lib/components/WebTerminal/WebTerminal.js +1 -1
  109. package/lib/components/index.js +33 -1
  110. package/lib/global/js/hooks/index.js +8 -0
  111. package/lib/global/js/hooks/useCreateComponentFocus.js +15 -19
  112. package/lib/global/js/hooks/useCreateComponentStepChange.js +69 -79
  113. package/lib/global/js/hooks/useResetCreateComponent.js +7 -4
  114. package/lib/global/js/hooks/useRetrieveStepData.js +62 -0
  115. package/lib/global/js/hooks/useValidCreateStepCount.js +4 -7
  116. package/lib/global/js/package-settings.js +5 -1
  117. package/lib/global/js/utils/lastIndexInArray.js +35 -0
  118. package/lib/settings.js +0 -6
  119. package/package.json +19 -19
  120. package/scss/components/AddSelect/_add-select.scss +108 -0
  121. package/scss/components/AddSelect/_index.scss +10 -0
  122. package/scss/components/AddSelect/_storybook-styles.scss +6 -0
  123. package/scss/components/BreadcrumbWithOverflow/_breadcrumb-with-overflow.scss +19 -15
  124. package/scss/components/BreadcrumbWithOverflow/_index.scss +1 -1
  125. package/scss/components/CancelableTextEdit/_cancelable-text-edit.scss +212 -0
  126. package/{es/components/CreateFullPage/constants.js → scss/components/CancelableTextEdit/_index.scss} +2 -2
  127. package/scss/components/CancelableTextEdit/_storybook-styles.scss +15 -0
  128. package/scss/components/CreateFullPage/_create-full-page.scss +4 -11
  129. package/scss/components/CreateInfluencer/_create-influencer.scss +4 -4
  130. package/scss/components/CreateTearsheet/_create-tearsheet.scss +6 -10
  131. package/scss/components/InlineEdit/_index.scss +8 -0
  132. package/scss/components/InlineEdit/_inline-edit.scss +245 -0
  133. package/scss/components/InlineEdit/_storybook-styles.scss +28 -0
  134. package/scss/components/MultiAddSelect/_index.scss +1 -0
  135. package/scss/components/MultiAddSelect/_multi-add-select.scss +1 -0
  136. package/scss/components/MultiAddSelect/_storybook-styles.scss +6 -0
  137. package/scss/components/NotificationsPanel/_notifications-panel.scss +2 -2
  138. package/scss/components/PageHeader/_index.scss +1 -1
  139. package/scss/components/PageHeader/_page-header.scss +15 -5
  140. package/scss/components/ProductiveCard/_productive-card.scss +0 -4
  141. package/scss/components/SidePanel/_side-panel.scss +15 -6
  142. package/scss/components/SingleAddSelect/_index.scss +1 -0
  143. package/scss/components/SingleAddSelect/_single-add-select.scss +1 -0
  144. package/scss/components/SingleAddSelect/_storybook-styles.scss +6 -0
  145. package/scss/components/StatusIcon/_index.scss +1 -1
  146. package/scss/components/StatusIcon/_status-icon.scss +2 -0
  147. package/scss/components/TagSet/_index.scss +1 -1
  148. package/scss/components/UserProfileImage/_index.scss +1 -1
  149. package/scss/components/WebTerminal/_web-terminal.scss +2 -2
  150. package/scss/components/_index.scss +4 -0
  151. package/scss/global/styles/_project-settings.scss +5 -1
  152. package/es/components/CreateFullPage/CreateFullPageSection.js +0 -53
  153. package/es/components/CreateTearsheet/CreateTearsheetSection.js +0 -83
  154. package/es/components/CreateTearsheet/preview-components/MultiStepWithSectionsTearsheet.js +0 -327
  155. package/es/generated/feature-flags/feature-flags.js +0 -15
  156. package/es/global/js/utils/hasValidType.js +0 -94
  157. package/lib/components/CreateFullPage/CreateFullPageSection.js +0 -74
  158. package/lib/components/CreateFullPage/constants.js +0 -16
  159. package/lib/components/CreateTearsheet/CreateTearsheetSection.js +0 -105
  160. package/lib/components/CreateTearsheet/constants.js +0 -17
  161. package/lib/components/CreateTearsheet/preview-components/MultiStepWithSectionsTearsheet.js +0 -354
  162. package/lib/generated/feature-flags/feature-flags.js +0 -22
  163. package/lib/global/js/utils/hasValidType.js +0 -110
  164. package/scss/generated/feature-flags/_feature-flags.scss +0 -19
@@ -112,7 +112,6 @@ var APIKeyModal = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
112
112
  currentStep = _useState6[0],
113
113
  setCurrentStep = _useState6[1];
114
114
 
115
- var inputRef = (0, _react.useRef)();
116
115
  var copyRef = (0, _react.useRef)();
117
116
  var apiKeyInputId = (0, _react.useRef)((0, _uuidv.default)());
118
117
  var nameInputId = (0, _react.useRef)((0, _uuidv.default)());
@@ -126,11 +125,6 @@ var APIKeyModal = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
126
125
  ref: copyRef
127
126
  };
128
127
  var blockClass = "".concat(_settings.pkg.prefix, "--apikey-modal");
129
- (0, _react.useEffect)(function () {
130
- if (inputRef.current && open) {
131
- inputRef.current.focus();
132
- }
133
- }, [open]);
134
128
  (0, _react.useEffect)(function () {
135
129
  if (copyRef.current && open && apiKeyLoaded) {
136
130
  copyRef.current.focus();
@@ -204,70 +198,72 @@ var APIKeyModal = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
204
198
  };
205
199
 
206
200
  var submitHandler = /*#__PURE__*/function () {
207
- var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
201
+ var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(e) {
208
202
  return _regenerator.default.wrap(function _callee$(_context) {
209
203
  while (1) {
210
204
  switch (_context.prev = _context.next) {
211
205
  case 0:
206
+ e.preventDefault();
207
+
212
208
  if (!hasNextStep) {
213
- _context.next = 4;
209
+ _context.next = 5;
214
210
  break;
215
211
  }
216
212
 
217
213
  setCurrentStep(currentStep + 1);
218
- _context.next = 21;
214
+ _context.next = 22;
219
215
  break;
220
216
 
221
- case 4:
217
+ case 5:
222
218
  if (!apiKeyLoaded) {
223
- _context.next = 20;
219
+ _context.next = 21;
224
220
  break;
225
221
  }
226
222
 
227
223
  if (!onCopy) {
228
- _context.next = 9;
224
+ _context.next = 10;
229
225
  break;
230
226
  }
231
227
 
232
228
  onCopy(apiKey);
233
- _context.next = 18;
229
+ _context.next = 19;
234
230
  break;
235
231
 
236
- case 9:
237
- _context.prev = 9;
238
- _context.next = 12;
232
+ case 10:
233
+ _context.prev = 10;
234
+ _context.next = 13;
239
235
  return navigator.clipboard.writeText(apiKey);
240
236
 
241
- case 12:
242
- _context.next = 18;
237
+ case 13:
238
+ _context.next = 19;
243
239
  break;
244
240
 
245
- case 14:
246
- _context.prev = 14;
247
- _context.t0 = _context["catch"](9);
241
+ case 15:
242
+ _context.prev = 15;
243
+ _context.t0 = _context["catch"](10);
248
244
  console.error(_context.t0);
249
245
  setCopyError(true);
250
246
 
251
- case 18:
252
- _context.next = 21;
247
+ case 19:
248
+ _context.next = 22;
253
249
  break;
254
250
 
255
- case 20:
251
+ case 21:
256
252
  if (editing) {
257
253
  onRequestEdit(name);
258
254
  } else {
259
255
  onRequestGenerate(name);
260
256
  }
261
257
 
262
- case 21:
258
+ case 22:
263
259
  case "end":
264
260
  return _context.stop();
265
261
  }
266
262
  }
267
- }, _callee, null, [[9, 14]]);
263
+ }, _callee, null, [[10, 15]]);
268
264
  }));
269
265
 
270
- return function submitHandler() {
266
+ return function submitHandler(_x) {
271
267
  return _ref2.apply(this, arguments);
272
268
  };
273
269
  }();
@@ -318,8 +314,8 @@ var APIKeyModal = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
318
314
  value: name,
319
315
  id: nameInputId.current,
320
316
  disabled: loading,
321
- ref: inputRef,
322
- required: nameRequired
317
+ required: nameRequired,
318
+ "data-modal-primary-focus": true
323
319
  })), loading && /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.InlineLoading, {
324
320
  description: loadingText,
325
321
  className: "".concat(blockClass, "__loader")
@@ -38,7 +38,7 @@ var _ActionBarItem = require("./ActionBarItem");
38
38
  var _ActionBarOverflowItems = require("./ActionBarOverflowItems");
39
39
 
40
40
  var _excluded = ["actions", "className", "maxVisible", "menuOptionsClass", "onWidthChange", "overflowAriaLabel", "rightAlign"],
41
- _excluded2 = ["key"],
41
+ _excluded2 = ["key", "id"],
42
42
  _excluded3 = ["key"];
43
43
 
44
44
  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); }
@@ -100,8 +100,11 @@ var ActionBar = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
100
100
  key: "hidden-overflow-menu"
101
101
  }), actions.map(function (_ref2) {
102
102
  var key = _ref2.key,
103
+ id = _ref2.id,
103
104
  rest = (0, _objectWithoutProperties2.default)(_ref2, _excluded2);
104
105
  return /*#__PURE__*/_react.default.createElement(_ActionBarItem.ActionBarItem, (0, _extends2.default)({}, rest, {
106
+ // ensure id is not duplicated
107
+ "data-original-id": id,
105
108
  key: "hidden-item-".concat(key),
106
109
  className: "".concat(blockClass, "__hidden-sizing-item")
107
110
  }));
@@ -46,7 +46,7 @@ var ActionSetButton = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
46
46
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
47
47
  return /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, (0, _extends2.default)({}, rest, {
48
48
  isExpressive: true,
49
- className: (0, _classnames.default)(className, ["".concat(blockClass, "__action-button"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__action-button--ghost"), kind === 'ghost')]),
49
+ className: (0, _classnames.default)(className, ["".concat(blockClass, "__action-button"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__action-button--ghost"), kind === 'ghost' || kind === 'danger--ghost')]),
50
50
  disabled: disabled || loading || false,
51
51
  kind: kind,
52
52
  onClick: onClick,
@@ -57,7 +57,7 @@ var ActionSetButton = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
57
57
 
58
58
  ActionSetButton.displayName = 'ActionSetButton';
59
59
  ActionSetButton.propTypes = _objectSpread(_objectSpread({}, _carbonComponentsReact.Button.PropTypes), {}, {
60
- kind: _propTypes.default.oneOf(['ghost', 'secondary', 'primary']),
60
+ kind: _propTypes.default.oneOf(['ghost', 'danger--ghost', 'secondary', 'danger', 'primary']),
61
61
  label: _propTypes.default.string,
62
62
  loading: _propTypes.default.bool
63
63
  });
@@ -90,13 +90,24 @@ var ActionSet = /*#__PURE__*/_react.default.forwardRef(function (_ref3, ref) {
90
90
  rest = (0, _objectWithoutProperties2.default)(_ref3, _excluded2);
91
91
  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.
92
92
 
93
- var stacking = willStack(size, buttons.length); // order the actions with ghost buttons first and primary buttons last
94
- // (and the opposite way if we're stacking)
93
+ var stacking = willStack(size, buttons.length); // Order of button kinds: ghost first, then danger--ghost, then most other types,
94
+ // then danger, and finally primary
95
+
96
+ var buttonOrder = function buttonOrder(kind) {
97
+ var _ghost$dangerGhost$;
98
+
99
+ return (_ghost$dangerGhost$ = {
100
+ ghost: 1,
101
+ 'danger--ghost': 2,
102
+ danger: 4,
103
+ primary: 5
104
+ }[kind]) !== null && _ghost$dangerGhost$ !== void 0 ? _ghost$dangerGhost$ : 3;
105
+ }; // order the actions with ghost/ghost-danger buttons first and primary/danger buttons last
106
+ // (or the opposite way if we're stacking)
107
+
95
108
 
96
109
  buttons.sort(function (action1, action2) {
97
- var kind1 = action1.kind || defaultKind;
98
- var kind2 = action2.kind || defaultKind;
99
- return kind1 === 'ghost' || kind2 === 'primary' ? stacking ? 1 : -1 : kind1 === 'primary' || kind2 === 'ghost' ? stacking ? -1 : 1 : 0;
110
+ return (buttonOrder(action1.kind || defaultKind) - buttonOrder(action2.kind || defaultKind)) * (stacking ? -1 : 1);
100
111
  });
101
112
  return /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.ButtonSet, (0, _extends2.default)({}, rest, {
102
113
  className: (0, _classnames.default)(blockClass, className, (_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "--row-single"), !stacking && buttons.length === 1), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "--row-double"), !stacking && buttons.length === 2), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "--row-triple"), !stacking && buttons.length === 3), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "--row-quadruple"), !stacking && buttons.length >= 4), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "--stacking"), stacking), _cx), "".concat(blockClass, "--").concat(size)),
@@ -147,13 +158,14 @@ ActionSet.validateActions = function (sizeFn) {
147
158
 
148
159
  var primaryActions = countActions('primary');
149
160
  var secondaryActions = countActions('secondary');
150
- var ghostActions = countActions('ghost');
161
+ var dangerActions = countActions('danger');
162
+ var ghostActions = countActions('ghost') + countActions('danger--ghost');
151
163
  stacking && actions > 3 && problems.push("you cannot have more than three actions in this size of ".concat(componentName));
152
164
  actions > 4 && problems.push("you cannot have more than four actions in a ".concat(componentName));
153
165
  primaryActions > 1 && problems.push("you cannot have more than one 'primary' action in a ".concat(componentName));
154
166
  ghostActions > 1 && problems.push("you cannot have more than one 'ghost' action in a ".concat(componentName));
155
167
  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));
156
- actions > primaryActions + secondaryActions + ghostActions && problems.push("you can only have 'primary', 'secondary' and 'ghost' buttons in a ".concat(componentName));
168
+ actions > primaryActions + secondaryActions + dangerActions + ghostActions && problems.push("you can only have 'primary', 'danger', 'secondary', 'ghost' and 'danger--ghost' buttons in a ".concat(componentName));
157
169
  }
158
170
 
159
171
  return problems.length > 0 ? new Error("Invalid ".concat(location, " `").concat(name, "` supplied to `").concat(componentName, "`: ").concat(problems.join(', and '), ".")) : null;
@@ -174,7 +186,7 @@ ActionSet.propTypes = {
174
186
  * See https://react.carbondesignsystem.com/?path=/docs/components-button--default#component-api
175
187
  */
176
188
  actions: (0, _propsHelper.allPropTypes)([ActionSet.validateActions(), _propTypes.default.arrayOf(_propTypes.default.shape(_objectSpread(_objectSpread({}, _carbonComponentsReact.Button.propTypes), {}, {
177
- kind: _propTypes.default.oneOf(['ghost', 'secondary', 'primary']),
189
+ kind: _propTypes.default.oneOf(['ghost', 'danger--ghost', 'secondary', 'danger', 'primary']),
178
190
  label: _propTypes.default.string,
179
191
  loading: _propTypes.default.bool,
180
192
  // we duplicate this Button prop to improve the DocGen here
@@ -11,22 +11,25 @@ exports.actionsOptions = exports.actionsMapping = exports.actionsLabels = void 0
11
11
  * This source code is licensed under the Apache-2.0 license found in the
12
12
  * LICENSE file in the root directory of this source tree.
13
13
  */
14
- var actionsOptions = [0, 1, 2, 3, 4, 5, 6, 7];
14
+ var actionsOptions = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
15
15
  exports.actionsOptions = actionsOptions;
16
16
  var actionsLabels = {
17
17
  0: 'None',
18
18
  1: 'One button',
19
- 2: 'One ghost button',
20
- 3: 'Two buttons',
21
- 4: 'Two buttons including one ghost',
22
- 5: 'Three buttons',
23
- 6: 'Three buttons including one ghost',
24
- 7: 'Four buttons including one ghost'
19
+ 2: 'A danger button',
20
+ 3: 'A ghost button',
21
+ 4: 'Two buttons',
22
+ 5: 'Two buttons with one ghost',
23
+ 6: 'Three buttons',
24
+ 7: 'Three buttons with one ghost',
25
+ 8: 'Three buttons with one danger',
26
+ 9: 'Four buttons with one ghost',
27
+ 10: 'Four buttons with two danger'
25
28
  };
26
29
  exports.actionsLabels = actionsLabels;
27
30
 
28
31
  var actionsMapping = function actionsMapping(labels, action) {
29
- var _labels$primary, _labels$secondary, _labels$secondary2, _labels$ghost;
32
+ var _labels$primary, _labels$danger, _labels$secondary, _labels$secondary2, _labels$dangerGhost, _labels$ghost;
30
33
 
31
34
  var act = function act(label, kind, key) {
32
35
  var actionCall = action && action("Click on '".concat(label, "'"));
@@ -42,18 +45,23 @@ var actionsMapping = function actionsMapping(labels, action) {
42
45
  };
43
46
 
44
47
  var primary = act((_labels$primary = labels === null || labels === void 0 ? void 0 : labels.primary) !== null && _labels$primary !== void 0 ? _labels$primary : 'Primary', 'primary', 1);
45
- var secondary = act((_labels$secondary = labels === null || labels === void 0 ? void 0 : labels.secondary) !== null && _labels$secondary !== void 0 ? _labels$secondary : 'Secondary', 'secondary', 2);
46
- var secondary2 = act((_labels$secondary2 = labels === null || labels === void 0 ? void 0 : labels.secondary2) !== null && _labels$secondary2 !== void 0 ? _labels$secondary2 : 'Secondary', 'secondary', 3);
47
- var ghost = act((_labels$ghost = labels === null || labels === void 0 ? void 0 : labels.ghost) !== null && _labels$ghost !== void 0 ? _labels$ghost : 'Ghost', 'ghost', 4);
48
+ var danger = act((_labels$danger = labels === null || labels === void 0 ? void 0 : labels.danger) !== null && _labels$danger !== void 0 ? _labels$danger : 'Danger', 'danger', 2);
49
+ var secondary = act((_labels$secondary = labels === null || labels === void 0 ? void 0 : labels.secondary) !== null && _labels$secondary !== void 0 ? _labels$secondary : 'Secondary', 'secondary', 3);
50
+ var secondary2 = act((_labels$secondary2 = labels === null || labels === void 0 ? void 0 : labels.secondary2) !== null && _labels$secondary2 !== void 0 ? _labels$secondary2 : 'Secondary', 'secondary', 4);
51
+ 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);
52
+ var ghost = act((_labels$ghost = labels === null || labels === void 0 ? void 0 : labels.ghost) !== null && _labels$ghost !== void 0 ? _labels$ghost : 'Ghost', 'ghost', 6);
48
53
  return {
49
54
  0: [],
50
55
  1: [primary],
51
- 2: [ghost],
52
- 3: [primary, secondary],
53
- 4: [primary, ghost],
54
- 5: [primary, secondary, secondary2],
55
- 6: [primary, secondary, ghost],
56
- 7: [primary, secondary, secondary2, ghost]
56
+ 2: [danger],
57
+ 3: [ghost],
58
+ 4: [primary, secondary],
59
+ 5: [primary, ghost],
60
+ 6: [primary, secondary, secondary2],
61
+ 7: [primary, secondary, ghost],
62
+ 8: [danger, secondary, ghost],
63
+ 9: [primary, secondary, secondary2, ghost],
64
+ 10: [danger, secondary, secondary2, dangerGhost]
57
65
  };
58
66
  };
59
67
 
@@ -0,0 +1,223 @@
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.AddSelect = 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 _propTypes = _interopRequireDefault(require("prop-types"));
23
+
24
+ var _classnames = _interopRequireDefault(require("classnames"));
25
+
26
+ var _carbonComponentsReact = require("carbon-components-react");
27
+
28
+ var _Tearsheet = require("../../components/Tearsheet");
29
+
30
+ var _NoDataEmptyState = require("../../components/EmptyStates/NoDataEmptyState");
31
+
32
+ var _settings = require("../../settings");
33
+
34
+ var _AddSelectSidebar = require("./AddSelectSidebar");
35
+
36
+ var _AddSelectBreadcrumbs = require("./AddSelectBreadcrumbs");
37
+
38
+ var _AddSelectList = require("./AddSelectList");
39
+
40
+ var _excluded = ["className", "description", "influencerTitle", "inputPlaceholder", "items", "itemsLabel", "multi", "noResultsDescription", "noResultsTitle", "noSelectionDescription", "noSelectionTitle", "onClose", "onCloseButtonText", "onSearchFilter", "onSubmit", "onSubmitButtonText", "open", "title"];
41
+
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); }
43
+
44
+ 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; }
45
+
46
+ var componentName = 'AddSelect';
47
+ var AddSelect = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
48
+ var _cx;
49
+
50
+ var className = _ref.className,
51
+ description = _ref.description,
52
+ influencerTitle = _ref.influencerTitle,
53
+ inputPlaceholder = _ref.inputPlaceholder,
54
+ items = _ref.items,
55
+ itemsLabel = _ref.itemsLabel,
56
+ multi = _ref.multi,
57
+ noResultsDescription = _ref.noResultsDescription,
58
+ noResultsTitle = _ref.noResultsTitle,
59
+ noSelectionDescription = _ref.noSelectionDescription,
60
+ noSelectionTitle = _ref.noSelectionTitle,
61
+ onClose = _ref.onClose,
62
+ onCloseButtonText = _ref.onCloseButtonText,
63
+ onSearchFilter = _ref.onSearchFilter,
64
+ onSubmit = _ref.onSubmit,
65
+ onSubmitButtonText = _ref.onSubmitButtonText,
66
+ open = _ref.open,
67
+ title = _ref.title,
68
+ rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
69
+ var blockClass = "".concat(_settings.pkg.prefix, "--add-select"); // hooks
70
+
71
+ var _useState = (0, _react.useState)([]),
72
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
73
+ path = _useState2[0],
74
+ setPath = _useState2[1];
75
+
76
+ var _useState3 = (0, _react.useState)(''),
77
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
78
+ singleSelection = _useState4[0],
79
+ setSingleSelection = _useState4[1];
80
+
81
+ var _useState5 = (0, _react.useState)([]),
82
+ _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
83
+ multiSelection = _useState6[0],
84
+ setMultiSelection = _useState6[1];
85
+
86
+ var _useState7 = (0, _react.useState)(''),
87
+ _useState8 = (0, _slicedToArray2.default)(_useState7, 2),
88
+ searchTerm = _useState8[0],
89
+ setSearchTerm = _useState8[1]; // handlers
90
+
91
+
92
+ var handleSearch = function handleSearch(e) {
93
+ setSearchTerm(e.target.value);
94
+ }; // item filtering
95
+
96
+
97
+ var getFilteredItems = function getFilteredItems() {
98
+ var hasPath = path.length > 0;
99
+ /**
100
+ * how to traverse the levels of items-
101
+ * the path represents the ids of each level / item / breadcrumb
102
+ * using this path we can drill down into the items until we get to the last one the user selected
103
+ */
104
+
105
+ var itemsToFilter = hasPath ? path.reduce(function (prev, cur) {
106
+ return prev.find(function (item) {
107
+ return item.id === cur.id;
108
+ }).children;
109
+ }, items) : items;
110
+ var results = itemsToFilter.filter(function (item) {
111
+ if (!searchTerm) {
112
+ return item;
113
+ } // if user provides their own filter function use that
114
+
115
+
116
+ if (onSearchFilter) {
117
+ return onSearchFilter(item, searchTerm);
118
+ } // otherwise use the default label filter
119
+
120
+
121
+ return item.label.toLowerCase().includes(searchTerm);
122
+ });
123
+ return results;
124
+ };
125
+
126
+ var filteredItems = getFilteredItems(); // main content
127
+
128
+ var body = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
129
+ className: "".concat(blockClass, "__header")
130
+ }, /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.TextInput, {
131
+ id: "temp-id",
132
+ labelText: "temp label",
133
+ placeholder: inputPlaceholder,
134
+ value: searchTerm,
135
+ onChange: handleSearch
136
+ }), /*#__PURE__*/_react.default.createElement("div", {
137
+ className: "".concat(blockClass, "__items-label-container")
138
+ }, path.length ? /*#__PURE__*/_react.default.createElement(_AddSelectBreadcrumbs.AddSelectBreadcrumbs, {
139
+ itemsLabel: itemsLabel,
140
+ path: path,
141
+ setPath: setPath
142
+ }) : /*#__PURE__*/_react.default.createElement("p", {
143
+ className: "".concat(blockClass, "__items-label")
144
+ }, itemsLabel), /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Tag, {
145
+ type: "gray",
146
+ size: "sm",
147
+ className: "".concat(blockClass, "__items-label-tag")
148
+ }, filteredItems.length))), filteredItems.length > 0 ? /*#__PURE__*/_react.default.createElement(_AddSelectList.AddSelectList, {
149
+ filteredItems: filteredItems,
150
+ multi: multi,
151
+ multiSelection: multiSelection,
152
+ path: path,
153
+ setMultiSelection: setMultiSelection,
154
+ setPath: setPath,
155
+ setSingleSelection: setSingleSelection,
156
+ singleSelection: singleSelection
157
+ }) : /*#__PURE__*/_react.default.createElement("div", {
158
+ className: "".concat(blockClass, "__body")
159
+ }, /*#__PURE__*/_react.default.createElement(_NoDataEmptyState.NoDataEmptyState, {
160
+ subtitle: noResultsDescription,
161
+ title: noResultsTitle
162
+ })));
163
+
164
+ var commonTearsheetProps = {
165
+ open: open,
166
+ title: title,
167
+ description: description,
168
+ closeIconDescription: 'temp description',
169
+ actions: [{
170
+ label: onCloseButtonText,
171
+ kind: 'secondary',
172
+ onClick: onClose
173
+ }, {
174
+ label: onSubmitButtonText,
175
+ kind: 'primary',
176
+ onClick: onSubmit,
177
+ disabled: multi ? multiSelection.length === 0 : !singleSelection
178
+ }]
179
+ };
180
+ var sidebarProps = {
181
+ influencerTitle: influencerTitle,
182
+ multiSelection: multiSelection,
183
+ noSelectionDescription: noSelectionDescription,
184
+ noSelectionTitle: noSelectionTitle
185
+ };
186
+ var classNames = (0, _classnames.default)(className, blockClass, (_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__single"), !multi), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__multi"), multi), _cx));
187
+ return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
188
+ ref: ref,
189
+ className: classNames
190
+ }, rest), multi ? /*#__PURE__*/_react.default.createElement(_Tearsheet.Tearsheet, (0, _extends2.default)({}, commonTearsheetProps, {
191
+ influencer: multi && /*#__PURE__*/_react.default.createElement(_AddSelectSidebar.AddSelectSidebar, sidebarProps),
192
+ influencerPosition: "right"
193
+ }), body) : /*#__PURE__*/_react.default.createElement(_Tearsheet.TearsheetNarrow, commonTearsheetProps, body));
194
+ });
195
+ exports.AddSelect = AddSelect;
196
+ AddSelect.propTypes = {
197
+ className: _propTypes.default.string,
198
+ description: _propTypes.default.string,
199
+ influencerTitle: _propTypes.default.string,
200
+ inputPlaceholder: _propTypes.default.string,
201
+ items: _propTypes.default.arrayOf(_propTypes.default.shape({
202
+ id: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
203
+ label: _propTypes.default.string,
204
+ value: _propTypes.default.string
205
+ })),
206
+ itemsLabel: _propTypes.default.string,
207
+ multi: _propTypes.default.bool,
208
+ noResultsDescription: _propTypes.default.string,
209
+ noResultsTitle: _propTypes.default.string,
210
+ noSelectionDescription: _propTypes.default.string,
211
+ noSelectionTitle: _propTypes.default.string,
212
+ onClose: _propTypes.default.func,
213
+ onCloseButtonText: _propTypes.default.string,
214
+ onSearchFilter: _propTypes.default.func,
215
+ onSubmit: _propTypes.default.func,
216
+ onSubmitButtonText: _propTypes.default.string,
217
+ open: _propTypes.default.bool,
218
+ title: _propTypes.default.string
219
+ };
220
+ AddSelect.defaultProps = {
221
+ items: []
222
+ };
223
+ AddSelect.displayName = componentName;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.AddSelectBreadcrumbs = void 0;
9
+
10
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
+
12
+ var _react = _interopRequireDefault(require("react"));
13
+
14
+ var _carbonComponentsReact = require("carbon-components-react");
15
+
16
+ var _propTypes = _interopRequireDefault(require("prop-types"));
17
+
18
+ //
19
+ // Copyright IBM Corp. 2022
20
+ //
21
+ // This source code is licensed under the Apache-2.0 license found in the
22
+ // LICENSE file in the root directory of this source tree.
23
+ //
24
+ var componentName = 'AddSelectBreadcrumbs';
25
+
26
+ var AddSelectBreadcrumbs = function AddSelectBreadcrumbs(_ref) {
27
+ var itemsLabel = _ref.itemsLabel,
28
+ path = _ref.path,
29
+ setPath = _ref.setPath;
30
+
31
+ var clickHandler = function clickHandler(id) {
32
+ var newPath = (0, _toConsumableArray2.default)(path);
33
+ var pathIdx = newPath.findIndex(function (entry) {
34
+ return entry.id === id;
35
+ });
36
+ var finalPath = newPath.splice(0, pathIdx + 1);
37
+ setPath(finalPath);
38
+ };
39
+
40
+ var resetPath = function resetPath() {
41
+ setPath([]);
42
+ };
43
+
44
+ return /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Breadcrumb, {
45
+ noTrailingSlash: true
46
+ }, /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.BreadcrumbItem, {
47
+ onClick: resetPath
48
+ }, itemsLabel), path.map(function (entry, idx, arr) {
49
+ var isCurrentPage = idx === arr.length - 1;
50
+
51
+ var crumbHandler = function crumbHandler() {
52
+ if (!isCurrentPage) {
53
+ clickHandler(entry.id);
54
+ }
55
+ };
56
+
57
+ return /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.BreadcrumbItem, {
58
+ key: entry.id,
59
+ isCurrentPage: isCurrentPage,
60
+ onClick: crumbHandler
61
+ }, entry.label);
62
+ }));
63
+ };
64
+
65
+ exports.AddSelectBreadcrumbs = AddSelectBreadcrumbs;
66
+ AddSelectBreadcrumbs.propTypes = {
67
+ itemsLabel: _propTypes.default.string,
68
+ path: _propTypes.default.array,
69
+ setPath: _propTypes.default.func
70
+ };
71
+ AddSelectBreadcrumbs.displayName = componentName;