@carbon/ibm-products 1.4.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +527 -90
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +9 -3
- package/css/index-full-carbon.min.css.map +1 -0
- package/css/index-without-carbon-released-only.css +157 -67
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +3 -3
- package/css/index-without-carbon-released-only.min.css.map +1 -0
- package/css/index-without-carbon.css +468 -84
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +9 -3
- package/css/index-without-carbon.min.css.map +1 -0
- package/css/index.css +470 -86
- package/css/index.css.map +1 -1
- package/css/index.min.css +9 -3
- package/css/index.min.css.map +1 -0
- package/es/components/ActionSet/ActionSet.js +23 -11
- package/es/components/ActionSet/actions.js +25 -17
- package/es/components/AddSelect/AddSelect.js +115 -67
- package/es/components/AddSelect/AddSelectBreadcrumbs.js +56 -0
- package/es/components/AddSelect/AddSelectList.js +94 -0
- package/es/components/AddSelect/AddSelectSidebar.js +110 -0
- package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +5 -2
- package/es/components/ButtonMenu/ButtonMenu.js +1 -1
- package/es/components/CancelableTextEdit/CancelableTextEdit.js +2 -2
- package/es/components/Card/Card.js +6 -4
- package/es/components/CreateFullPage/CreateFullPage.js +30 -5
- package/es/components/CreateFullPage/CreateFullPageStep.js +40 -32
- package/es/components/CreateInfluencer/CreateInfluencer.js +25 -3
- package/es/components/CreateTearsheet/CreateTearsheet.js +32 -6
- package/es/components/CreateTearsheet/CreateTearsheetStep.js +45 -38
- package/es/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +24 -4
- package/es/components/CreateTearsheet/preview-components/MultiStepWithIntro.js +8 -6
- package/es/components/DataSpreadsheet/DataSpreadsheet.js +154 -0
- package/es/components/DataSpreadsheet/generateData.js +47 -0
- package/es/components/DataSpreadsheet/index.js +7 -0
- package/es/components/EmptyStates/EmptyState.js +1 -1
- package/es/components/EmptyStates/EmptyStateContent.js +2 -2
- package/es/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +1 -1
- package/es/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +1 -1
- package/es/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +1 -1
- package/es/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +1 -1
- package/es/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +1 -1
- package/es/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +1 -1
- package/es/components/ExportModal/ExportModal.js +39 -12
- package/es/components/InlineEdit/InlineEdit.js +250 -80
- package/es/components/NotificationsPanel/NotificationsPanel.js +16 -3
- package/es/components/PageHeader/PageHeader.js +9 -6
- package/es/components/PageHeader/PageHeaderTitle.js +10 -6
- package/es/components/SidePanel/SidePanel.js +33 -16
- package/es/components/Tearsheet/Tearsheet.js +1 -1
- package/es/components/Tearsheet/TearsheetNarrow.js +1 -1
- package/es/components/Tearsheet/TearsheetShell.js +4 -5
- package/es/components/WebTerminal/WebTerminal.js +1 -1
- package/es/components/index.js +2 -1
- package/es/global/js/hooks/index.js +1 -0
- package/es/global/js/hooks/useCreateComponentStepChange.js +31 -11
- package/es/global/js/hooks/useResetCreateComponent.js +7 -4
- package/es/global/js/hooks/useRetrieveStepData.js +51 -0
- package/es/global/js/package-settings.js +2 -1
- package/es/global/js/utils/getScrollbarWidth.js +14 -0
- package/es/global/js/utils/lastIndexInArray.js +26 -0
- package/es/settings.js +0 -5
- package/lib/components/ActionSet/ActionSet.js +23 -11
- package/lib/components/ActionSet/actions.js +25 -17
- package/lib/components/AddSelect/AddSelect.js +119 -67
- package/lib/components/AddSelect/AddSelectBreadcrumbs.js +71 -0
- package/lib/components/AddSelect/AddSelectList.js +112 -0
- package/lib/components/AddSelect/AddSelectSidebar.js +122 -0
- package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +5 -2
- package/lib/components/ButtonMenu/ButtonMenu.js +1 -1
- package/lib/components/CancelableTextEdit/CancelableTextEdit.js +1 -1
- package/lib/components/Card/Card.js +6 -4
- package/lib/components/CreateFullPage/CreateFullPage.js +29 -4
- package/lib/components/CreateFullPage/CreateFullPageStep.js +38 -30
- package/lib/components/CreateInfluencer/CreateInfluencer.js +25 -3
- package/lib/components/CreateTearsheet/CreateTearsheet.js +31 -5
- package/lib/components/CreateTearsheet/CreateTearsheetStep.js +43 -36
- package/lib/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +22 -2
- package/lib/components/CreateTearsheet/preview-components/MultiStepWithIntro.js +8 -6
- package/lib/components/DataSpreadsheet/DataSpreadsheet.js +171 -0
- package/lib/components/DataSpreadsheet/generateData.js +58 -0
- package/lib/components/DataSpreadsheet/index.js +13 -0
- package/lib/components/EmptyStates/EmptyState.js +1 -1
- package/lib/components/EmptyStates/EmptyStateContent.js +2 -2
- package/lib/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +1 -1
- package/lib/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +1 -1
- package/lib/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +1 -1
- package/lib/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +1 -1
- package/lib/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +1 -1
- package/lib/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +1 -1
- package/lib/components/ExportModal/ExportModal.js +36 -11
- package/lib/components/InlineEdit/InlineEdit.js +247 -79
- package/lib/components/NotificationsPanel/NotificationsPanel.js +13 -1
- package/lib/components/PageHeader/PageHeader.js +9 -6
- package/lib/components/PageHeader/PageHeaderTitle.js +10 -6
- package/lib/components/SidePanel/SidePanel.js +33 -16
- package/lib/components/Tearsheet/Tearsheet.js +1 -1
- package/lib/components/Tearsheet/TearsheetNarrow.js +1 -1
- package/lib/components/Tearsheet/TearsheetShell.js +3 -4
- package/lib/components/WebTerminal/WebTerminal.js +1 -1
- package/lib/components/index.js +9 -1
- package/lib/global/js/hooks/index.js +8 -0
- package/lib/global/js/hooks/useCreateComponentStepChange.js +31 -11
- package/lib/global/js/hooks/useResetCreateComponent.js +7 -4
- package/lib/global/js/hooks/useRetrieveStepData.js +62 -0
- package/lib/global/js/package-settings.js +2 -1
- package/lib/global/js/utils/getScrollbarWidth.js +23 -0
- package/lib/global/js/utils/lastIndexInArray.js +35 -0
- package/lib/settings.js +0 -6
- package/package.json +27 -25
- package/scss/components/AddSelect/_add-select.scss +59 -5
- package/scss/components/BreadcrumbWithOverflow/_index.scss +1 -1
- package/scss/components/CancelableTextEdit/_cancelable-text-edit.scss +1 -0
- package/scss/components/CancelableTextEdit/_storybook-styles.scss +0 -7
- package/scss/components/CreateInfluencer/_create-influencer.scss +4 -4
- package/scss/components/CreateTearsheet/_create-tearsheet.scss +2 -2
- package/scss/components/CreateTearsheetNarrow/_storybook-styles.scss +0 -6
- package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +79 -0
- package/scss/components/DataSpreadsheet/_index.scss +8 -0
- package/scss/components/DataSpreadsheet/_storybook-styles.scss +6 -0
- package/scss/components/EditSidePanel/_storybook-styles.scss +0 -8
- package/scss/components/InlineEdit/_inline-edit.scss +288 -10
- package/scss/components/InlineEdit/_storybook-styles.scss +12 -6
- package/scss/components/LoadingBar/_storybook-styles.scss +0 -5
- package/scss/components/NotificationsPanel/_notifications-panel.scss +2 -2
- package/scss/components/OptionsTile/_storybook-styles.scss +0 -7
- package/scss/components/PageHeader/_index.scss +1 -1
- package/scss/components/PageHeader/_page-header.scss +4 -1
- package/scss/components/ProductiveCard/_productive-card.scss +0 -4
- package/scss/components/SidePanel/_side-panel.scss +15 -6
- package/scss/components/StatusIcon/_index.scss +1 -1
- package/scss/components/StatusIcon/_status-icon.scss +6 -4
- package/scss/components/TagSet/_index.scss +1 -1
- package/scss/components/UserProfileImage/_index.scss +1 -1
- package/scss/components/UserProfileImage/_user-profile-image.scss +2 -2
- package/scss/components/WebTerminal/_web-terminal.scss +2 -2
- package/scss/components/_index.scss +1 -0
- package/scss/global/styles/_project-settings.scss +5 -1
- package/es/generated/feature-flags/feature-flags.js +0 -15
- package/lib/generated/feature-flags/feature-flags.js +0 -22
- package/scss/generated/feature-flags/_feature-flags.scss +0 -19
@@ -1,7 +1,7 @@
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
4
|
-
var _excluded = ["text", "content", "loading", "icon", "asText", "onChange", "editDescription", "editableLabel", "revertDescription", "saveDescription"];
|
4
|
+
var _excluded = ["text", "content", "loading", "icon", "asText", "onChange", "onSave", "editDescription", "editableLabel", "revertDescription", "saveDescription"];
|
5
5
|
import React from 'react';
|
6
6
|
import PropTypes from 'prop-types';
|
7
7
|
import cx from 'classnames';
|
@@ -26,6 +26,7 @@ export var PageHeaderTitle = function PageHeaderTitle(_ref) {
|
|
26
26
|
icon = title.icon,
|
27
27
|
asText = title.asText,
|
28
28
|
onChange = title.onChange,
|
29
|
+
onSave = title.onSave,
|
29
30
|
editDescription = title.editDescription,
|
30
31
|
editableLabel = title.editableLabel,
|
31
32
|
revertDescription = title.revertDescription,
|
@@ -33,7 +34,7 @@ export var PageHeaderTitle = function PageHeaderTitle(_ref) {
|
|
33
34
|
rest = _objectWithoutProperties(title, _excluded);
|
34
35
|
|
35
36
|
var titleText;
|
36
|
-
var isEditable = !!
|
37
|
+
var isEditable = !!onSave;
|
37
38
|
|
38
39
|
if (text || !content) {
|
39
40
|
if (text === undefined && typeof title === 'string') {
|
@@ -51,6 +52,7 @@ export var PageHeaderTitle = function PageHeaderTitle(_ref) {
|
|
51
52
|
value: text,
|
52
53
|
editDescription: editDescription,
|
53
54
|
onChange: onChange,
|
55
|
+
onSave: onSave,
|
54
56
|
labelText: editableLabel,
|
55
57
|
revertDescription: revertDescription,
|
56
58
|
saveDescription: saveDescription
|
@@ -68,8 +70,8 @@ export var PageHeaderTitle = function PageHeaderTitle(_ref) {
|
|
68
70
|
}, titleInnards);
|
69
71
|
};
|
70
72
|
export var inlineEditRequired = function inlineEditRequired(_ref2) {
|
71
|
-
var
|
72
|
-
return !!
|
73
|
+
var onSave = _ref2.onSave;
|
74
|
+
return !!onSave;
|
73
75
|
};
|
74
76
|
PageHeaderTitle.propTypes = {
|
75
77
|
// passed from page header
|
@@ -89,9 +91,10 @@ PageHeaderTitle.propTypes = {
|
|
89
91
|
* - text: title string
|
90
92
|
* - icon: optional icon
|
91
93
|
* - loading: boolean shows loading indicator if true
|
92
|
-
* - onChange: function to process
|
94
|
+
* - onChange: function to process the live value (React change === HTML Input)
|
95
|
+
* - onSave: function to process a confirmed change
|
93
96
|
* - editDescription: description for edit button
|
94
|
-
* - editableLabel: label for edit required if
|
97
|
+
* - editableLabel: label for edit required if onSave supplied
|
95
98
|
* - revertDescription: description for edit revert button
|
96
99
|
* - saveDescription: description for edit save button
|
97
100
|
* - Object containing user defined contents. These must fit within the area defined for the title in both main part of the header and the breadcrumb.
|
@@ -109,6 +112,7 @@ PageHeaderTitle.propTypes = {
|
|
109
112
|
editableLabel: PropTypes.string.isRequired.if(inlineEditRequired),
|
110
113
|
id: PropTypes.string.isRequired.if(inlineEditRequired),
|
111
114
|
onChange: PropTypes.func,
|
115
|
+
onSave: PropTypes.func,
|
112
116
|
revertDescription: PropTypes.string.isRequired.if(inlineEditRequired),
|
113
117
|
saveDescription: PropTypes.string.isRequired.if(inlineEditRequired) // Update docgen if changed
|
114
118
|
|
@@ -89,8 +89,12 @@ export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
89
89
|
var sidePanelInnerRef = useRef();
|
90
90
|
var sidePanelCloseRef = useRef();
|
91
91
|
var previousState = usePreviousValue({
|
92
|
-
size: size
|
93
|
-
|
92
|
+
size: size,
|
93
|
+
open: open
|
94
|
+
});
|
95
|
+
var reducedMotion = window && window.matchMedia ? window.matchMedia('(prefers-reduced-motion: reduce)') : {
|
96
|
+
matches: true
|
97
|
+
}; // scroll panel to top going between steps
|
94
98
|
|
95
99
|
useEffect(function () {
|
96
100
|
var panelRef = ref || sidePanelRef;
|
@@ -169,7 +173,7 @@ export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
169
173
|
|
170
174
|
|
171
175
|
useEffect(function () {
|
172
|
-
if (open && animateTitle && animationComplete && title && title.length) {
|
176
|
+
if (open && animateTitle && animationComplete && title && title.length && !reducedMotion.matches) {
|
173
177
|
var _document$querySelect2, _document$querySelect3, _document$querySelect4;
|
174
178
|
|
175
179
|
var sidePanelOuter = document.querySelector("#".concat(blockClass, "-outer"));
|
@@ -261,7 +265,7 @@ export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
261
265
|
_sidePanelOuter === null || _sidePanelOuter === void 0 ? void 0 : _sidePanelOuter.style.setProperty("--".concat(blockClass, "--subtitle-container-height"), "".concat(_sidePanelSubtitleElementHeight, "px"));
|
262
266
|
_sidePanelOuter === null || _sidePanelOuter === void 0 ? void 0 : _sidePanelOuter.style.setProperty("--".concat(blockClass, "--action-bar-container-height"), "".concat(sidePanelActionBarElementHeight, "px"));
|
263
267
|
}
|
264
|
-
}, [open, animateTitle, animationComplete, shouldRender, panelHeight, title, size]); // click outside functionality if `includeOverlay` prop is set
|
268
|
+
}, [open, animateTitle, animationComplete, shouldRender, panelHeight, title, size, reducedMotion.matches]); // click outside functionality if `includeOverlay` prop is set
|
265
269
|
|
266
270
|
useEffect(function () {
|
267
271
|
var handleOutsideClick = function handleOutsideClick(event) {
|
@@ -287,7 +291,7 @@ export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
287
291
|
return function () {
|
288
292
|
document.removeEventListener('click', handleOutsideClick);
|
289
293
|
};
|
290
|
-
}, [includeOverlay, onRequestClose, open, preventCloseOnClickOutside, ref]); // initialize the side panel to open
|
294
|
+
}, [includeOverlay, onRequestClose, open, preventCloseOnClickOutside, ref, onUnmount]); // initialize the side panel to open
|
291
295
|
|
292
296
|
useEffect(function () {
|
293
297
|
if (open) {
|
@@ -297,14 +301,21 @@ export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
297
301
|
|
298
302
|
var onAnimationEnd = function onAnimationEnd() {
|
299
303
|
if (!open) {
|
300
|
-
onUnmount
|
304
|
+
onUnmount === null || onUnmount === void 0 ? void 0 : onUnmount();
|
301
305
|
setRender(false);
|
302
306
|
}
|
303
307
|
|
304
308
|
setAnimationComplete(true);
|
305
|
-
}; //
|
309
|
+
}; // Set the internal state `animationComplete` to true if
|
310
|
+
// prefers reduced motion is true
|
306
311
|
|
307
312
|
|
313
|
+
useEffect(function () {
|
314
|
+
if (reducedMotion.matches) {
|
315
|
+
setAnimationComplete(true);
|
316
|
+
}
|
317
|
+
}, [reducedMotion.matches]); // initializes the side panel to open
|
318
|
+
|
308
319
|
var _onAnimationStart = function onAnimationStart(event) {
|
309
320
|
event.persist();
|
310
321
|
var isPanelTarget = event.target.id === "".concat(blockClass, "-outer");
|
@@ -325,7 +336,13 @@ export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
325
336
|
pageContentElement.style.marginLeft = 0;
|
326
337
|
}
|
327
338
|
}
|
328
|
-
}, [open, placement, selectorPageContent, slideIn]);
|
339
|
+
}, [open, placement, selectorPageContent, slideIn]);
|
340
|
+
useEffect(function () {
|
341
|
+
if (!open && previousState !== null && previousState !== void 0 && previousState.open && reducedMotion.matches) {
|
342
|
+
setRender(false);
|
343
|
+
onUnmount === null || onUnmount === void 0 ? void 0 : onUnmount();
|
344
|
+
}
|
345
|
+
}, [open, onUnmount, reducedMotion.matches, previousState === null || previousState === void 0 ? void 0 : previousState.open]); // used to set margins of content for slide in panel version
|
329
346
|
|
330
347
|
useEffect(function () {
|
331
348
|
if (shouldRender && slideIn) {
|
@@ -333,15 +350,15 @@ export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
333
350
|
|
334
351
|
if (placement && placement === 'right' && pageContentElement) {
|
335
352
|
pageContentElement.style.marginRight = 0;
|
336
|
-
pageContentElement.style.transition = "margin-right ".concat(moderate02);
|
353
|
+
pageContentElement.style.transition = !reducedMotion.matches ? "margin-right ".concat(moderate02) : null;
|
337
354
|
pageContentElement.style.marginRight = SIDE_PANEL_SIZES[size];
|
338
355
|
} else if (pageContentElement) {
|
339
356
|
pageContentElement.style.marginLeft = 0;
|
340
|
-
pageContentElement.style.transition = "margin-left ".concat(moderate02);
|
357
|
+
pageContentElement.style.transition = !reducedMotion.matches ? "margin-left ".concat(moderate02) : null;
|
341
358
|
pageContentElement.style.marginLeft = SIDE_PANEL_SIZES[size];
|
342
359
|
}
|
343
360
|
}
|
344
|
-
}, [slideIn, selectorPageContent, placement, shouldRender, size]); // adds focus trap functionality
|
361
|
+
}, [slideIn, selectorPageContent, placement, shouldRender, size, reducedMotion.matches]); // adds focus trap functionality
|
345
362
|
|
346
363
|
/* istanbul ignore next */
|
347
364
|
|
@@ -368,7 +385,7 @@ export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
368
385
|
var _cx, _cx2;
|
369
386
|
|
370
387
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
371
|
-
className: cx("".concat(blockClass, "__title-container"), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__on-detail-step"), currentStep > 0), _defineProperty(_cx, "".concat(blockClass, "__on-detail-step-without-title"), currentStep > 0 && !title), _defineProperty(_cx, "".concat(blockClass, "__title-container--no-title-animation"), !animateTitle), _defineProperty(_cx, "".concat(blockClass, "__title-container-is-animating"), !animationComplete || !open), _defineProperty(_cx, "".concat(blockClass, "__title-container-without-title"), !title), _cx))
|
388
|
+
className: cx("".concat(blockClass, "__title-container"), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__on-detail-step"), currentStep > 0), _defineProperty(_cx, "".concat(blockClass, "__on-detail-step-without-title"), currentStep > 0 && !title), _defineProperty(_cx, "".concat(blockClass, "__title-container--no-title-animation"), !animateTitle), _defineProperty(_cx, "".concat(blockClass, "__title-container-is-animating"), !animationComplete || !open), _defineProperty(_cx, "".concat(blockClass, "__title-container-without-title"), !title), _defineProperty(_cx, "".concat(blockClass, "__title-container--reduced-motion"), reducedMotion.matches), _cx))
|
372
389
|
}, currentStep > 0 && /*#__PURE__*/React.createElement(Button, {
|
373
390
|
"aria-label": navigationBackIconDescription,
|
374
391
|
kind: "ghost",
|
@@ -426,7 +443,7 @@ export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
426
443
|
className: "".concat(blockClass, "__title-text"),
|
427
444
|
title: title,
|
428
445
|
"aria-hidden": false
|
429
|
-
}, title), animateTitle && title && title.length && /*#__PURE__*/React.createElement("h2", {
|
446
|
+
}, title), animateTitle && title && title.length && !reducedMotion.matches && /*#__PURE__*/React.createElement("h2", {
|
430
447
|
className: "".concat(blockClass, "__collapsed-title-text"),
|
431
448
|
title: title,
|
432
449
|
"aria-hidden": true
|
@@ -443,7 +460,7 @@ export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
443
460
|
id: "".concat(blockClass, "-outer"),
|
444
461
|
className: mainPanelClassNames,
|
445
462
|
style: {
|
446
|
-
animation: "".concat(open ? placement === 'right' ? "
|
463
|
+
animation: !reducedMotion.matches ? "".concat(open ? placement === 'right' ? "side-panel-entrance-right ".concat(moderate02) : "side-panel-entrance-left ".concat(moderate02) : placement === 'right' ? "side-panel-exit-right ".concat(moderate02) : "side-panel-exit-left ".concat(moderate02)) : null
|
447
464
|
},
|
448
465
|
onAnimationEnd: onAnimationEnd,
|
449
466
|
onAnimationStart: function onAnimationStart(event) {
|
@@ -476,7 +493,7 @@ export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
476
493
|
ref: sidePanelOverlayRef,
|
477
494
|
className: "".concat(blockClass, "__overlay"),
|
478
495
|
style: {
|
479
|
-
animation: "".concat(open ? "
|
496
|
+
animation: !reducedMotion.matches ? "".concat(open ? "side-panel-overlay-entrance ".concat(moderate02) : "side-panel-overlay-exit ".concat(moderate02)) : null
|
480
497
|
}
|
481
498
|
}));
|
482
499
|
}); // Return a placeholder if not released and not enabled by feature flag
|
@@ -508,7 +525,7 @@ SidePanel.propTypes = {
|
|
508
525
|
* See https://react.carbondesignsystem.com/?path=/docs/components-button--default#component-api
|
509
526
|
*/
|
510
527
|
actions: allPropTypes([ActionSet.validateActions(), PropTypes.arrayOf(PropTypes.shape(_objectSpread(_objectSpread({}, Button.propTypes), {}, {
|
511
|
-
kind: PropTypes.oneOf(['ghost', 'secondary', 'primary']),
|
528
|
+
kind: PropTypes.oneOf(['ghost', 'danger--ghost', 'secondary', 'danger', 'primary']),
|
512
529
|
label: PropTypes.string,
|
513
530
|
loading: PropTypes.bool,
|
514
531
|
// we duplicate this Button prop to improve the DocGen here
|
@@ -82,7 +82,7 @@ Tearsheet.propTypes = _objectSpread({
|
|
82
82
|
actions: allPropTypes([ActionSet.validateActions(function () {
|
83
83
|
return 'max';
|
84
84
|
}), PropTypes.arrayOf(PropTypes.shape(_objectSpread(_objectSpread({}, Button.propTypes), {}, {
|
85
|
-
kind: PropTypes.oneOf(['ghost', 'secondary', 'primary']),
|
85
|
+
kind: PropTypes.oneOf(['ghost', 'danger--ghost', 'secondary', 'danger', 'primary']),
|
86
86
|
label: PropTypes.string,
|
87
87
|
loading: PropTypes.bool,
|
88
88
|
// we duplicate this Button prop to improve the DocGen here
|
@@ -78,7 +78,7 @@ TearsheetNarrow.propTypes = _objectSpread({
|
|
78
78
|
actions: allPropTypes([ActionSet.validateActions(function () {
|
79
79
|
return 'lg';
|
80
80
|
}), PropTypes.arrayOf(PropTypes.shape(_objectSpread(_objectSpread({}, Button.propTypes), {}, {
|
81
|
-
kind: PropTypes.oneOf(['ghost', 'secondary', 'primary']),
|
81
|
+
kind: PropTypes.oneOf(['ghost', 'danger--ghost', 'secondary', 'danger', 'primary']),
|
82
82
|
label: PropTypes.string,
|
83
83
|
loading: PropTypes.bool,
|
84
84
|
// we duplicate this Button prop to improve the DocGen here
|
@@ -15,7 +15,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
15
15
|
* LICENSE file in the root directory of this source tree.
|
16
16
|
*/
|
17
17
|
// Import portions of React that are needed.
|
18
|
-
import React, { useEffect,
|
18
|
+
import React, { useEffect, useState, useRef } from 'react';
|
19
19
|
import { useResizeDetector } from 'react-resize-detector'; // Other standard imports.
|
20
20
|
|
21
21
|
import PropTypes from 'prop-types';
|
@@ -120,10 +120,9 @@ export var TearsheetShell = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
120
120
|
setTimeout(function () {
|
121
121
|
return element.focus();
|
122
122
|
}, 1);
|
123
|
-
};
|
123
|
+
};
|
124
124
|
|
125
|
-
|
126
|
-
useLayoutEffect(function () {
|
125
|
+
useEffect(function () {
|
127
126
|
var notify = function notify() {
|
128
127
|
return stack.all.forEach(function (handler) {
|
129
128
|
handler(Math.min(stack.open.length, maxDepth), stack.open.indexOf(handler) + 1);
|
@@ -281,7 +280,7 @@ TearsheetShell.propTypes = _objectSpread({
|
|
281
280
|
actions: PropTypes.arrayOf( // NB we don't include the validator here, as the component wrapping this
|
282
281
|
// one should ensure appropriate validation is done.
|
283
282
|
PropTypes.shape(_objectSpread(_objectSpread({}, Button.propTypes), {}, {
|
284
|
-
kind: PropTypes.oneOf(['ghost', 'secondary', 'primary']),
|
283
|
+
kind: PropTypes.oneOf(['ghost', 'danger--ghost', 'secondary', 'danger', 'primary']),
|
285
284
|
label: PropTypes.string,
|
286
285
|
loading: PropTypes.bool,
|
287
286
|
// we duplicate this Button prop to improve the DocGen here
|
@@ -63,7 +63,7 @@ export var WebTerminal = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
63
63
|
ref: ref,
|
64
64
|
className: cx([blockClass, (_ref2 = {}, _defineProperty(_ref2, "".concat(blockClass, "--open"), open), _defineProperty(_ref2, "".concat(blockClass, "--closed"), !open), _defineProperty(_ref2, className, className), _ref2)]),
|
65
65
|
style: {
|
66
|
-
animation: "".concat(open ? '
|
66
|
+
animation: "".concat(open ? 'web-terminal-entrance 250ms' : 'web-terminal-exit 250ms')
|
67
67
|
},
|
68
68
|
onAnimationEnd: onAnimationEnd
|
69
69
|
}), /*#__PURE__*/React.createElement("header", {
|
package/es/components/index.js
CHANGED
@@ -37,4 +37,5 @@ export { WebTerminal } from './WebTerminal';
|
|
37
37
|
export { EditSidePanel } from './EditSidePanel';
|
38
38
|
export { OptionsTile } from './OptionsTile';
|
39
39
|
export { CancelableTextEdit } from './CancelableTextEdit';
|
40
|
-
export { InlineEdit } from './InlineEdit';
|
40
|
+
export { InlineEdit } from './InlineEdit';
|
41
|
+
export { DataSpreadsheet } from './DataSpreadsheet';
|
@@ -11,4 +11,5 @@ export { useCreateComponentFocus } from './useCreateComponentFocus';
|
|
11
11
|
export { useCreateComponentStepChange } from './useCreateComponentStepChange';
|
12
12
|
export { usePreviousValue } from './usePreviousValue';
|
13
13
|
export { useResetCreateComponent } from './useResetCreateComponent';
|
14
|
+
export { useRetrieveStepData } from './useRetrieveStepData';
|
14
15
|
export { useValidCreateStepCount } from './useValidCreateStepCount';
|
@@ -2,14 +2,16 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
3
3
|
|
4
4
|
/**
|
5
|
-
* Copyright IBM Corp. 2021,
|
5
|
+
* Copyright IBM Corp. 2021, 2022
|
6
6
|
*
|
7
7
|
* This source code is licensed under the Apache-2.0 license found in the
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
9
9
|
*/
|
10
10
|
import { useCallback, useEffect } from 'react';
|
11
11
|
export var useCreateComponentStepChange = function useCreateComponentStepChange(_ref) {
|
12
|
-
var
|
12
|
+
var firstIncludedStep = _ref.firstIncludedStep,
|
13
|
+
lastIncludedStep = _ref.lastIncludedStep,
|
14
|
+
stepData = _ref.stepData,
|
13
15
|
onNext = _ref.onNext,
|
14
16
|
isSubmitDisabled = _ref.isSubmitDisabled,
|
15
17
|
setCurrentStep = _ref.setCurrentStep,
|
@@ -174,20 +176,29 @@ export var useCreateComponentStepChange = function useCreateComponentStepChange(
|
|
174
176
|
};
|
175
177
|
}();
|
176
178
|
|
177
|
-
if (
|
179
|
+
if ((stepData === null || stepData === void 0 ? void 0 : stepData.length) > 0) {
|
178
180
|
var buttons = [];
|
179
181
|
|
180
|
-
if (
|
182
|
+
if ((stepData === null || stepData === void 0 ? void 0 : stepData.length) > 1 && !shouldViewAll) {
|
181
183
|
buttons.push({
|
182
184
|
key: 'create-action-button-back',
|
183
185
|
label: backButtonText,
|
184
186
|
onClick: function onClick() {
|
185
187
|
return setCurrentStep(function (prev) {
|
186
|
-
|
188
|
+
// Find previous included step to render
|
189
|
+
// There will always be a previous step otherwise we will
|
190
|
+
// have disabled the back button since we have reached the first visible step
|
191
|
+
do {
|
192
|
+
var _stepData;
|
193
|
+
|
194
|
+
prev--;
|
195
|
+
} while (!((_stepData = stepData[prev - 1]) !== null && _stepData !== void 0 && _stepData.shouldIncludeStep));
|
196
|
+
|
197
|
+
return prev;
|
187
198
|
});
|
188
199
|
},
|
189
200
|
kind: 'secondary',
|
190
|
-
disabled: currentStep ===
|
201
|
+
disabled: currentStep === firstIncludedStep
|
191
202
|
});
|
192
203
|
}
|
193
204
|
|
@@ -201,8 +212,8 @@ export var useCreateComponentStepChange = function useCreateComponentStepChange(
|
|
201
212
|
});
|
202
213
|
buttons.push({
|
203
214
|
key: 'create-action-button-submit',
|
204
|
-
label: shouldViewAll ? submitButtonText : currentStep <
|
205
|
-
onClick: shouldViewAll ? handleSubmit : currentStep <
|
215
|
+
label: shouldViewAll ? submitButtonText : currentStep < lastIncludedStep ? nextButtonText : submitButtonText,
|
216
|
+
onClick: shouldViewAll ? handleSubmit : currentStep < lastIncludedStep ? handleNext : handleSubmit,
|
206
217
|
disabled: isSubmitDisabled,
|
207
218
|
kind: 'primary',
|
208
219
|
loading: isSubmitting,
|
@@ -210,11 +221,20 @@ export var useCreateComponentStepChange = function useCreateComponentStepChange(
|
|
210
221
|
});
|
211
222
|
setCreateComponentActions(buttons);
|
212
223
|
}
|
213
|
-
}, [
|
224
|
+
}, [firstIncludedStep, lastIncludedStep, stepData, onNext, isSubmitDisabled, backButtonText, cancelButtonText, currentStep, onClose, nextButtonText, submitButtonText, onRequestSubmit, isSubmitting, shouldViewAll, componentBlockClass, componentName, continueToNextStep, setCurrentStep, setCreateComponentActions, setIsSubmitting, setShouldViewAll, setModalIsOpen]);
|
214
225
|
var continueToNextStep = useCallback(function () {
|
215
226
|
setIsSubmitting(false);
|
216
227
|
setCurrentStep(function (prev) {
|
217
|
-
|
228
|
+
// Find next included step to render
|
229
|
+
// There will always be a next step otherwise we will
|
230
|
+
// have reach the onSubmit
|
231
|
+
do {
|
232
|
+
var _stepData2;
|
233
|
+
|
234
|
+
prev++;
|
235
|
+
} while (!((_stepData2 = stepData[prev - 1]) !== null && _stepData2 !== void 0 && _stepData2.shouldIncludeStep));
|
236
|
+
|
237
|
+
return prev;
|
218
238
|
});
|
219
|
-
}, [setCurrentStep, setIsSubmitting]);
|
239
|
+
}, [setCurrentStep, setIsSubmitting, stepData]);
|
220
240
|
};
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/**
|
2
|
-
* Copyright IBM Corp. 2021,
|
2
|
+
* Copyright IBM Corp. 2021, 2022
|
3
3
|
*
|
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.
|
@@ -8,6 +8,7 @@ import { useEffect } from 'react';
|
|
8
8
|
/**
|
9
9
|
* Resets the current step of the create component if it has been closed.
|
10
10
|
* @param {object} useResetCreateComponent - Create component that uses this custom hook
|
11
|
+
* @param {object} useResetCreateComponent.firstIncludedStep
|
11
12
|
* @param {object} useResetCreateComponent.previousState
|
12
13
|
* @param {boolean} useResetCreateComponent.open
|
13
14
|
* @param {Function} useResetCreateComponent.setCurrentStep
|
@@ -17,7 +18,8 @@ import { useEffect } from 'react';
|
|
17
18
|
*/
|
18
19
|
|
19
20
|
export var useResetCreateComponent = function useResetCreateComponent(_ref) {
|
20
|
-
var
|
21
|
+
var firstIncludedStep = _ref.firstIncludedStep,
|
22
|
+
previousState = _ref.previousState,
|
21
23
|
open = _ref.open,
|
22
24
|
setCurrentStep = _ref.setCurrentStep,
|
23
25
|
initialStep = _ref.initialStep,
|
@@ -28,7 +30,8 @@ export var useResetCreateComponent = function useResetCreateComponent(_ref) {
|
|
28
30
|
if (initialStep && totalSteps && Number(initialStep) <= Number(totalSteps) && Number(initialStep) > 0) {
|
29
31
|
setCurrentStep(Number(initialStep));
|
30
32
|
} else {
|
31
|
-
|
33
|
+
// default should be fist includedStep instead of just 1
|
34
|
+
setCurrentStep(firstIncludedStep);
|
32
35
|
} // An invalid initialStep value was provided, we'll default to rendering the first step in this scenario
|
33
36
|
|
34
37
|
|
@@ -36,5 +39,5 @@ export var useResetCreateComponent = function useResetCreateComponent(_ref) {
|
|
36
39
|
console.warn("".concat(componentName, ": An invalid `initialStep` prop was supplied. The `initialStep` prop should be a number that is greater than 0 or less than or equal to the number of steps your ").concat(componentName, " has."));
|
37
40
|
}
|
38
41
|
}
|
39
|
-
}, [open, previousState, setCurrentStep, initialStep, totalSteps, componentName]);
|
42
|
+
}, [firstIncludedStep, open, previousState, setCurrentStep, initialStep, totalSteps, componentName]);
|
40
43
|
};
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Copyright IBM Corp. 2022, 2022
|
5
|
+
*
|
6
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
8
|
+
*/
|
9
|
+
import { useEffect } from 'react';
|
10
|
+
/**
|
11
|
+
* This useEffect makes sure that every CreateTearsheetStep/CreateFullPageStep reports back it's
|
12
|
+
* title, secondaryLabel, introStep, and shouldIncludeStep data so that it can be sent to the CreateInfluencer.
|
13
|
+
* @param {object} useResetCreateComponent
|
14
|
+
* @param {object} useResetCreateComponent.stepsContext
|
15
|
+
* @param {number} useResetCreateComponent.stepNumber
|
16
|
+
* @param {boolean} useResetCreateComponent.introStep
|
17
|
+
* @param {boolean} useResetCreateComponent.shouldIncludeStep
|
18
|
+
* @param {string} useResetCreateComponent.secondaryLabel
|
19
|
+
* @param {string} useResetCreateComponent.title
|
20
|
+
*/
|
21
|
+
|
22
|
+
export var useRetrieveStepData = function useRetrieveStepData(_ref) {
|
23
|
+
var stepsContext = _ref.stepsContext,
|
24
|
+
stepNumber = _ref.stepNumber,
|
25
|
+
introStep = _ref.introStep,
|
26
|
+
shouldIncludeStep = _ref.shouldIncludeStep,
|
27
|
+
secondaryLabel = _ref.secondaryLabel,
|
28
|
+
title = _ref.title;
|
29
|
+
useEffect(function () {
|
30
|
+
if (stepsContext) {
|
31
|
+
stepsContext.setStepData(function (prev) {
|
32
|
+
var stepItem = {
|
33
|
+
title: title,
|
34
|
+
secondaryLabel: secondaryLabel,
|
35
|
+
introStep: introStep,
|
36
|
+
shouldIncludeStep: shouldIncludeStep
|
37
|
+
};
|
38
|
+
var previousItem = prev[stepNumber - 1];
|
39
|
+
|
40
|
+
if ((previousItem === null || previousItem === void 0 ? void 0 : previousItem.title) !== stepItem.title || (previousItem === null || previousItem === void 0 ? void 0 : previousItem.secondaryLabel) !== stepItem.secondaryLabel || (previousItem === null || previousItem === void 0 ? void 0 : previousItem.introStep) !== stepItem.introStep || (previousItem === null || previousItem === void 0 ? void 0 : previousItem.shouldIncludeStep) !== stepItem.shouldIncludeStep) {
|
41
|
+
var clone = _toConsumableArray(prev);
|
42
|
+
|
43
|
+
clone[stepNumber - 1] = stepItem;
|
44
|
+
return clone;
|
45
|
+
}
|
46
|
+
|
47
|
+
return prev;
|
48
|
+
});
|
49
|
+
}
|
50
|
+
}, [shouldIncludeStep, title, secondaryLabel, introStep, stepsContext, stepNumber]);
|
51
|
+
};
|
@@ -0,0 +1,14 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2022, 2022
|
3
|
+
*
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
7
|
+
export var getScrollbarWidth = function getScrollbarWidth() {
|
8
|
+
var scrollDiv = document.createElement('div');
|
9
|
+
scrollDiv.setAttribute('style', 'width: 100px; height: 100px; overflow: scroll; position:absolute; top:-9999px;');
|
10
|
+
document.body.appendChild(scrollDiv);
|
11
|
+
var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
|
12
|
+
document.body.removeChild(scrollDiv);
|
13
|
+
return scrollbarWidth;
|
14
|
+
};
|
@@ -0,0 +1,26 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2022, 2022
|
3
|
+
*
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
7
|
+
|
8
|
+
/**
|
9
|
+
* This utility will return the index of the last instance of an
|
10
|
+
* item in the given array of objects whose key is equal to the value
|
11
|
+
* parameter. If there are no matches, -1 is returned as similar to findIndex
|
12
|
+
* @param {Array<Object.*>} array
|
13
|
+
* @param {string} key
|
14
|
+
* @param {string|boolean|number} value
|
15
|
+
*/
|
16
|
+
export var lastIndexInArray = function lastIndexInArray(array, key, value) {
|
17
|
+
for (var i = array.length - 1; i >= 0; i--) {
|
18
|
+
var _array$i;
|
19
|
+
|
20
|
+
if (((_array$i = array[i]) === null || _array$i === void 0 ? void 0 : _array$i[key]) === value) {
|
21
|
+
return i + 1;
|
22
|
+
}
|
23
|
+
}
|
24
|
+
|
25
|
+
return -1;
|
26
|
+
};
|
package/es/settings.js
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
import { Canary } from './components/_Canary';
|
2
|
-
import featureFlags from './generated/feature-flags/feature-flags';
|
3
2
|
import pkgSettings from './global/js/package-settings';
|
4
3
|
import { settings as carbonSettings } from 'carbon-components';
|
5
4
|
import React from 'react';
|
@@ -13,10 +12,6 @@ export var carbon = {
|
|
13
12
|
carbonSettings.prefix = val;
|
14
13
|
},
|
15
14
|
|
16
|
-
get flags() {
|
17
|
-
return featureFlags;
|
18
|
-
},
|
19
|
-
|
20
15
|
get themes() {
|
21
16
|
return themes;
|
22
17
|
}
|
@@ -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,11 +57,11 @@ 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
|
});
|
64
|
-
var defaultKind =
|
64
|
+
var defaultKind = 'primary';
|
65
65
|
|
66
66
|
var willStack = function willStack(size, numberOfActions) {
|
67
67
|
return size === 'xs' || size === 'sm' || size === 'md' && numberOfActions > 2;
|
@@ -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); //
|
94
|
-
//
|
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
|
-
|
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
|
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
|