@carbon/ibm-products 1.2.3 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +538 -273
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +2 -2
- package/css/index-without-carbon-released-only.css +32 -41
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +2 -2
- package/css/index-without-carbon.css +269 -41
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +2 -2
- package/css/index.css +491 -41
- package/css/index.css.map +1 -1
- package/css/index.min.css +2 -2
- package/es/components/APIKeyModal/APIKeyModal.js +25 -29
- package/es/components/ActionBar/ActionBar.js +4 -1
- package/es/components/AddSelect/AddSelect.js +157 -0
- package/es/components/AddSelect/index.js +7 -0
- package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +19 -15
- package/es/components/CancelableTextEdit/CancelableTextEdit.js +245 -0
- package/es/components/{CreateTearsheet/constants.js → CancelableTextEdit/index.js} +1 -2
- package/es/components/CreateFullPage/CreateFullPage.js +78 -259
- package/es/components/CreateFullPage/CreateFullPageStep.js +58 -14
- package/es/components/CreateFullPage/index.js +1 -2
- package/es/components/CreateInfluencer/CreateInfluencer.js +23 -225
- package/es/components/CreateTearsheet/CreateTearsheet.js +69 -146
- package/es/components/CreateTearsheet/CreateTearsheetStep.js +59 -16
- package/es/components/CreateTearsheet/index.js +0 -1
- package/es/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +66 -27
- package/es/components/ExportModal/ExportModal.js +4 -2
- package/es/components/ImportModal/ImportModal.js +2 -1
- package/es/components/InlineEdit/InlineEdit.js +224 -0
- package/es/components/InlineEdit/index.js +7 -0
- package/es/components/MultiAddSelect/MultiAddSelect.js +16 -0
- package/es/components/MultiAddSelect/index.js +1 -0
- package/es/components/OptionsTile/OptionsTile.js +36 -15
- package/es/components/PageHeader/PageHeader.js +54 -33
- package/es/components/PageHeader/PageHeaderTitle.js +78 -7
- package/es/components/PageHeader/PageHeaderUtils.js +21 -2
- package/es/components/RemoveModal/RemoveModal.js +4 -2
- package/es/components/SingleAddSelect/SingleAddSelect.js +15 -0
- package/es/components/SingleAddSelect/index.js +1 -0
- package/es/components/TagSet/TagSet.js +4 -1
- package/es/components/Toolbar/Toolbar.js +69 -8
- package/es/components/index.js +5 -1
- package/es/global/js/hooks/useCreateComponentFocus.js +15 -19
- package/es/global/js/hooks/useCreateComponentStepChange.js +44 -74
- package/es/global/js/hooks/useValidCreateStepCount.js +4 -7
- package/es/global/js/package-settings.js +5 -1
- package/es/global/js/utils/story-helper.js +1 -1
- package/lib/components/APIKeyModal/APIKeyModal.js +25 -29
- package/lib/components/ActionBar/ActionBar.js +4 -1
- package/lib/components/AddSelect/AddSelect.js +178 -0
- package/lib/components/AddSelect/index.js +13 -0
- package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +18 -14
- package/lib/components/CancelableTextEdit/CancelableTextEdit.js +265 -0
- package/lib/components/CancelableTextEdit/index.js +13 -0
- package/lib/components/CreateFullPage/CreateFullPage.js +78 -259
- package/lib/components/CreateFullPage/CreateFullPageStep.js +61 -14
- package/lib/components/CreateFullPage/index.js +1 -9
- package/lib/components/CreateInfluencer/CreateInfluencer.js +21 -236
- package/lib/components/CreateTearsheet/CreateTearsheet.js +71 -148
- package/lib/components/CreateTearsheet/CreateTearsheetStep.js +61 -15
- package/lib/components/CreateTearsheet/index.js +0 -8
- package/lib/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +67 -35
- package/lib/components/ExportModal/ExportModal.js +4 -2
- package/lib/components/ImportModal/ImportModal.js +2 -1
- package/lib/components/InlineEdit/InlineEdit.js +242 -0
- package/lib/components/InlineEdit/index.js +13 -0
- package/lib/components/MultiAddSelect/MultiAddSelect.js +37 -0
- package/lib/components/MultiAddSelect/index.js +13 -0
- package/lib/components/OptionsTile/OptionsTile.js +36 -15
- package/lib/components/PageHeader/PageHeader.js +54 -33
- package/lib/components/PageHeader/PageHeaderTitle.js +87 -9
- package/lib/components/PageHeader/PageHeaderUtils.js +21 -2
- package/lib/components/RemoveModal/RemoveModal.js +4 -2
- package/lib/components/SingleAddSelect/SingleAddSelect.js +36 -0
- package/lib/components/SingleAddSelect/index.js +13 -0
- package/lib/components/TagSet/TagSet.js +4 -1
- package/lib/components/Toolbar/Toolbar.js +69 -6
- package/lib/components/index.js +33 -1
- package/lib/global/js/hooks/useCreateComponentFocus.js +15 -19
- package/lib/global/js/hooks/useCreateComponentStepChange.js +44 -74
- package/lib/global/js/hooks/useValidCreateStepCount.js +4 -7
- package/lib/global/js/package-settings.js +5 -1
- package/lib/global/js/utils/story-helper.js +1 -1
- package/package.json +15 -15
- package/scss/components/AddSelect/_add-select.scss +84 -0
- package/scss/components/AddSelect/_index.scss +10 -0
- package/scss/components/AddSelect/_storybook-styles.scss +6 -0
- package/scss/components/BreadcrumbWithOverflow/_breadcrumb-with-overflow.scss +19 -15
- package/scss/components/CancelableTextEdit/_cancelable-text-edit.scss +211 -0
- package/{es/components/CreateFullPage/constants.js → scss/components/CancelableTextEdit/_index.scss} +2 -2
- package/scss/components/CancelableTextEdit/_storybook-styles.scss +15 -0
- package/scss/components/CreateFullPage/_create-full-page.scss +4 -11
- package/scss/components/CreateTearsheet/_create-tearsheet.scss +4 -8
- package/scss/components/InlineEdit/_index.scss +8 -0
- package/scss/components/InlineEdit/_inline-edit.scss +44 -0
- package/scss/components/InlineEdit/_storybook-styles.scss +15 -0
- package/scss/components/MultiAddSelect/_index.scss +1 -0
- package/scss/components/MultiAddSelect/_multi-add-select.scss +1 -0
- package/scss/components/MultiAddSelect/_storybook-styles.scss +6 -0
- package/scss/components/PageHeader/_page-header.scss +14 -4
- package/scss/components/SingleAddSelect/_index.scss +1 -0
- package/scss/components/SingleAddSelect/_single-add-select.scss +1 -0
- package/scss/components/SingleAddSelect/_storybook-styles.scss +6 -0
- package/scss/components/_index.scss +4 -0
- package/es/components/CreateFullPage/CreateFullPageSection.js +0 -53
- package/es/components/CreateTearsheet/CreateTearsheetSection.js +0 -83
- package/es/components/CreateTearsheet/preview-components/MultiStepWithSectionsTearsheet.js +0 -327
- package/es/global/js/utils/hasValidType.js +0 -94
- package/lib/components/CreateFullPage/CreateFullPageSection.js +0 -74
- package/lib/components/CreateFullPage/constants.js +0 -16
- package/lib/components/CreateTearsheet/CreateTearsheetSection.js +0 -105
- package/lib/components/CreateTearsheet/constants.js +0 -17
- package/lib/components/CreateTearsheet/preview-components/MultiStepWithSectionsTearsheet.js +0 -354
- package/lib/global/js/utils/hasValidType.js +0 -110
@@ -1,17 +1,19 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
3
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
4
5
|
var _excluded = ["children", "className", "vertical"];
|
5
6
|
|
6
7
|
/**
|
7
|
-
* Copyright IBM Corp. 2021,
|
8
|
+
* Copyright IBM Corp. 2021, 2022
|
8
9
|
*
|
9
10
|
* This source code is licensed under the Apache-2.0 license found in the
|
10
11
|
* LICENSE file in the root directory of this source tree.
|
11
12
|
*/
|
12
13
|
import cx from 'classnames';
|
13
14
|
import { bool, node, string } from 'prop-types';
|
14
|
-
import React, { createContext, forwardRef } from 'react';
|
15
|
+
import React, { createContext, forwardRef, useCallback, useEffect, useRef, useState } from 'react';
|
16
|
+
import { getFocusableElements as _getFocusableElements } from '../../global/js/utils/getFocusableElements';
|
15
17
|
import { pkg } from '../../settings';
|
16
18
|
var checkComponentEnabled = pkg.checkComponentEnabled,
|
17
19
|
prefix = pkg.prefix;
|
@@ -19,15 +21,74 @@ var blockClass = "".concat(prefix, "--toolbar");
|
|
19
21
|
var ToolbarContext = /*#__PURE__*/createContext();
|
20
22
|
/** Toolbars are a collection of action items that organize a program’s interaction patterns into a series of closely related commands. */
|
21
23
|
|
22
|
-
var Toolbar = /*#__PURE__*/forwardRef(function (
|
23
|
-
var children =
|
24
|
-
className =
|
25
|
-
vertical =
|
26
|
-
rest = _objectWithoutProperties(
|
24
|
+
var Toolbar = /*#__PURE__*/forwardRef(function (_ref2, r) {
|
25
|
+
var children = _ref2.children,
|
26
|
+
className = _ref2.className,
|
27
|
+
vertical = _ref2.vertical,
|
28
|
+
rest = _objectWithoutProperties(_ref2, _excluded);
|
29
|
+
|
30
|
+
var focusableElements = useRef();
|
31
|
+
var getFocusableElements = useCallback(function () {
|
32
|
+
return focusableElements.current;
|
33
|
+
}, [focusableElements]);
|
34
|
+
|
35
|
+
var _ref = useRef();
|
36
|
+
|
37
|
+
var ref = r || _ref;
|
38
|
+
|
39
|
+
var _useState = useState(),
|
40
|
+
_useState2 = _slicedToArray(_useState, 2),
|
41
|
+
focus = _useState2[0],
|
42
|
+
setFocus = _useState2[1];
|
43
|
+
|
44
|
+
useEffect(function () {
|
45
|
+
focusableElements.current = _getFocusableElements(ref.current);
|
46
|
+
typeof focus !== 'undefined' && getFocusableElements().forEach(function (element, index) {
|
47
|
+
element[index !== focus ? 'setAttribute' : 'removeAttribute']('tabindex', -1);
|
48
|
+
});
|
49
|
+
});
|
50
|
+
useEffect(function () {
|
51
|
+
typeof focus !== 'undefined' && getFocusableElements()[focus].focus();
|
52
|
+
}, [focus, getFocusableElements]);
|
53
|
+
|
54
|
+
var _ref3 = !vertical ? ['ArrowRight', 'ArrowLeft'] : ['ArrowDown', 'ArrowUp'],
|
55
|
+
_ref4 = _slicedToArray(_ref3, 2),
|
56
|
+
arrowNext = _ref4[0],
|
57
|
+
arrowPrevious = _ref4[1];
|
58
|
+
|
59
|
+
function onArrowDown(increment) {
|
60
|
+
var nextFocus = focus + increment;
|
61
|
+
getFocusableElements()[nextFocus] && setFocus(nextFocus);
|
62
|
+
}
|
63
|
+
|
64
|
+
function onFocus(_ref5) {
|
65
|
+
var target = _ref5.target;
|
66
|
+
var elements = getFocusableElements();
|
67
|
+
elements.includes(target) && setFocus(elements.indexOf(target));
|
68
|
+
}
|
69
|
+
|
70
|
+
function onKeyDown(_ref6) {
|
71
|
+
var key = _ref6.key,
|
72
|
+
target = _ref6.target;
|
73
|
+
|
74
|
+
if (getFocusableElements().includes(target)) {
|
75
|
+
switch (key) {
|
76
|
+
case arrowNext:
|
77
|
+
onArrowDown(1);
|
78
|
+
break;
|
79
|
+
|
80
|
+
case arrowPrevious:
|
81
|
+
onArrowDown(-1);
|
82
|
+
break;
|
83
|
+
}
|
84
|
+
}
|
85
|
+
}
|
27
86
|
|
28
87
|
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
29
88
|
ref: ref,
|
30
|
-
className: cx(blockClass, className, _defineProperty({}, "".concat(blockClass, "--vertical"), vertical))
|
89
|
+
className: cx(blockClass, className, _defineProperty({}, "".concat(blockClass, "--vertical"), vertical)),
|
90
|
+
onFocus: onFocus,
|
91
|
+
onKeyDown: onKeyDown
|
31
92
|
}, vertical && {
|
32
93
|
'aria-orientation': 'vertical'
|
33
94
|
}, {
|
package/es/components/index.js
CHANGED
@@ -20,12 +20,14 @@ export { HTTPError403, HTTPError404, HTTPErrorOther } from './HTTPErrors';
|
|
20
20
|
export { ImportModal } from './ImportModal';
|
21
21
|
export { LoadingBar } from './LoadingBar';
|
22
22
|
export { ModifiedTabs } from './ModifiedTabs';
|
23
|
+
export { MultiAddSelect } from './MultiAddSelect';
|
23
24
|
export { NotificationsPanel } from './NotificationsPanel';
|
24
25
|
export { PageHeader } from './PageHeader';
|
25
26
|
export { ProductiveCard } from './ProductiveCard';
|
26
27
|
export { RemoveModal } from './RemoveModal';
|
27
28
|
export { Saving } from './Saving';
|
28
29
|
export { SidePanel } from './SidePanel';
|
30
|
+
export { SingleAddSelect } from './SingleAddSelect';
|
29
31
|
export { StatusIcon } from './StatusIcon';
|
30
32
|
export { TagSet } from './TagSet';
|
31
33
|
export { Tearsheet, TearsheetNarrow } from './Tearsheet';
|
@@ -33,4 +35,6 @@ export { Toolbar, ToolbarButton, ToolbarGroup } from './Toolbar';
|
|
33
35
|
export { UserProfileImage } from './UserProfileImage';
|
34
36
|
export { WebTerminal } from './WebTerminal';
|
35
37
|
export { EditSidePanel } from './EditSidePanel';
|
36
|
-
export { OptionsTile } from './OptionsTile';
|
38
|
+
export { OptionsTile } from './OptionsTile';
|
39
|
+
export { CancelableTextEdit } from './CancelableTextEdit';
|
40
|
+
export { InlineEdit } from './InlineEdit';
|
@@ -5,33 +5,29 @@
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
6
6
|
*/
|
7
7
|
import { useEffect } from 'react';
|
8
|
-
import { getFocusableElements } from '../utils/getFocusableElements';
|
9
|
-
/**
|
10
|
-
* Returns the previous state values included in the param
|
11
|
-
* @param {object} previousState
|
12
|
-
* @param {number} currentStep
|
13
|
-
* @param {Function} getCreateComponentSteps
|
14
|
-
* @param {string} componentBlockClass
|
15
|
-
*/
|
8
|
+
import { getFocusableElements } from '../utils/getFocusableElements'; // Focus the first focusable element and call the onMount prop for the current step if one is provided
|
16
9
|
|
17
|
-
export var useCreateComponentFocus = function useCreateComponentFocus(
|
10
|
+
export var useCreateComponentFocus = function useCreateComponentFocus(_ref) {
|
11
|
+
var previousState = _ref.previousState,
|
12
|
+
currentStep = _ref.currentStep,
|
13
|
+
blockClass = _ref.blockClass,
|
14
|
+
onMount = _ref.onMount;
|
15
|
+
useEffect(function () {
|
16
|
+
if (typeof onMount === 'function') {
|
17
|
+
onMount();
|
18
|
+
}
|
19
|
+
}, [onMount]);
|
18
20
|
useEffect(function () {
|
19
21
|
if ((previousState === null || previousState === void 0 ? void 0 : previousState.currentStep) !== currentStep && currentStep > 0) {
|
20
|
-
var visibleStepInnerContent = document.querySelector(".".concat(
|
21
|
-
var
|
22
|
-
var focusableStepElements = createComponentSteps && createComponentSteps.length && getFocusableElements(visibleStepInnerContent);
|
23
|
-
var activeStepComponent = createComponentSteps && createComponentSteps.length && createComponentSteps[currentStep - 1];
|
24
|
-
|
25
|
-
if (activeStepComponent && activeStepComponent.props.onMount) {
|
26
|
-
activeStepComponent.props.onMount();
|
27
|
-
}
|
22
|
+
var visibleStepInnerContent = document.querySelector(".".concat(blockClass, "__step.").concat(blockClass, "__step__step--visible-step"));
|
23
|
+
var focusableStepElements = visibleStepInnerContent ? getFocusableElements(visibleStepInnerContent) : [];
|
28
24
|
|
29
25
|
if (focusableStepElements && focusableStepElements.length) {
|
30
26
|
focusableStepElements[0].focus();
|
31
27
|
} else {
|
32
|
-
var nextButton = document.querySelector(".".concat(
|
28
|
+
var nextButton = document.querySelector(".".concat(blockClass, "__create-button"));
|
33
29
|
nextButton === null || nextButton === void 0 ? void 0 : nextButton.focus();
|
34
30
|
}
|
35
31
|
}
|
36
|
-
}, [currentStep,
|
32
|
+
}, [currentStep, previousState, blockClass, onMount]);
|
37
33
|
};
|
@@ -9,13 +9,15 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
9
9
|
*/
|
10
10
|
import { useCallback, useEffect } from 'react';
|
11
11
|
export var useCreateComponentStepChange = function useCreateComponentStepChange(_ref) {
|
12
|
-
var
|
12
|
+
var totalStepCount = _ref.totalStepCount,
|
13
|
+
onNext = _ref.onNext,
|
14
|
+
isSubmitDisabled = _ref.isSubmitDisabled,
|
15
|
+
setCurrentStep = _ref.setCurrentStep,
|
13
16
|
setIsSubmitting = _ref.setIsSubmitting,
|
14
17
|
setShouldViewAll = _ref.setShouldViewAll,
|
15
18
|
onClose = _ref.onClose,
|
16
19
|
onRequestSubmit = _ref.onRequestSubmit,
|
17
20
|
componentName = _ref.componentName,
|
18
|
-
getComponentSteps = _ref.getComponentSteps,
|
19
21
|
currentStep = _ref.currentStep,
|
20
22
|
shouldViewAll = _ref.shouldViewAll,
|
21
23
|
backButtonText = _ref.backButtonText,
|
@@ -28,8 +30,6 @@ export var useCreateComponentStepChange = function useCreateComponentStepChange(
|
|
28
30
|
setModalIsOpen = _ref.setModalIsOpen;
|
29
31
|
// useEffect to handle multi step logic
|
30
32
|
useEffect(function () {
|
31
|
-
var _getComponentSteps;
|
32
|
-
|
33
33
|
var onUnmount = function onUnmount() {
|
34
34
|
if (componentName !== 'CreateFullPage') {
|
35
35
|
setCurrentStep(0);
|
@@ -74,73 +74,47 @@ export var useCreateComponentStepChange = function useCreateComponentStepChange(
|
|
74
74
|
};
|
75
75
|
}();
|
76
76
|
|
77
|
-
var isSubmitDisabled = function isSubmitDisabled() {
|
78
|
-
var step = 0;
|
79
|
-
var submitDisabled = false;
|
80
|
-
var viewAllSubmitDisabled = false;
|
81
|
-
var createComponentSteps = getComponentSteps();
|
82
|
-
createComponentSteps.forEach(function (child) {
|
83
|
-
step++;
|
84
|
-
|
85
|
-
if (currentStep === step) {
|
86
|
-
submitDisabled = child.props.disableSubmit;
|
87
|
-
}
|
88
|
-
|
89
|
-
if (shouldViewAll && child.props.disableSubmit) {
|
90
|
-
viewAllSubmitDisabled = true;
|
91
|
-
}
|
92
|
-
});
|
93
|
-
|
94
|
-
if (!shouldViewAll) {
|
95
|
-
return submitDisabled;
|
96
|
-
}
|
97
|
-
|
98
|
-
return viewAllSubmitDisabled;
|
99
|
-
};
|
100
|
-
|
101
77
|
var handleNext = /*#__PURE__*/function () {
|
102
78
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
103
|
-
var createSteps;
|
104
79
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
105
80
|
while (1) {
|
106
81
|
switch (_context2.prev = _context2.next) {
|
107
82
|
case 0:
|
108
83
|
setIsSubmitting(true);
|
109
|
-
createSteps = getComponentSteps();
|
110
84
|
|
111
|
-
if (!
|
112
|
-
_context2.next =
|
85
|
+
if (!(typeof onNext === 'function')) {
|
86
|
+
_context2.next = 14;
|
113
87
|
break;
|
114
88
|
}
|
115
89
|
|
116
|
-
_context2.prev =
|
117
|
-
_context2.next =
|
118
|
-
return
|
90
|
+
_context2.prev = 2;
|
91
|
+
_context2.next = 5;
|
92
|
+
return onNext();
|
119
93
|
|
120
|
-
case
|
94
|
+
case 5:
|
121
95
|
continueToNextStep();
|
122
|
-
_context2.next =
|
96
|
+
_context2.next = 12;
|
123
97
|
break;
|
124
98
|
|
125
|
-
case
|
126
|
-
_context2.prev =
|
127
|
-
_context2.t0 = _context2["catch"](
|
99
|
+
case 8:
|
100
|
+
_context2.prev = 8;
|
101
|
+
_context2.t0 = _context2["catch"](2);
|
128
102
|
setIsSubmitting(false);
|
129
103
|
console.warn("".concat(componentName, " onNext error: ").concat(_context2.t0));
|
130
104
|
|
131
|
-
case
|
132
|
-
_context2.next =
|
105
|
+
case 12:
|
106
|
+
_context2.next = 15;
|
133
107
|
break;
|
134
108
|
|
135
|
-
case
|
109
|
+
case 14:
|
136
110
|
continueToNextStep();
|
137
111
|
|
138
|
-
case
|
112
|
+
case 15:
|
139
113
|
case "end":
|
140
114
|
return _context2.stop();
|
141
115
|
}
|
142
116
|
}
|
143
|
-
}, _callee2, null, [[
|
117
|
+
}, _callee2, null, [[2, 8]]);
|
144
118
|
}));
|
145
119
|
|
146
120
|
return function handleNext() {
|
@@ -150,51 +124,49 @@ export var useCreateComponentStepChange = function useCreateComponentStepChange(
|
|
150
124
|
|
151
125
|
var handleSubmit = /*#__PURE__*/function () {
|
152
126
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
153
|
-
var createSteps;
|
154
127
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
155
128
|
while (1) {
|
156
129
|
switch (_context3.prev = _context3.next) {
|
157
130
|
case 0:
|
158
|
-
setIsSubmitting(true);
|
159
|
-
createSteps = getComponentSteps(); // last step should have onNext as well
|
131
|
+
setIsSubmitting(true); // last step should have onNext as well
|
160
132
|
|
161
|
-
if (!
|
162
|
-
_context3.next =
|
133
|
+
if (!(typeof onNext === 'function')) {
|
134
|
+
_context3.next = 15;
|
163
135
|
break;
|
164
136
|
}
|
165
137
|
|
166
|
-
_context3.prev =
|
167
|
-
_context3.next =
|
168
|
-
return
|
138
|
+
_context3.prev = 2;
|
139
|
+
_context3.next = 5;
|
140
|
+
return onNext();
|
169
141
|
|
170
|
-
case
|
171
|
-
_context3.next =
|
142
|
+
case 5:
|
143
|
+
_context3.next = 7;
|
172
144
|
return handleOnRequestSubmit();
|
173
145
|
|
174
|
-
case
|
175
|
-
_context3.next =
|
146
|
+
case 7:
|
147
|
+
_context3.next = 13;
|
176
148
|
break;
|
177
149
|
|
178
|
-
case
|
179
|
-
_context3.prev =
|
180
|
-
_context3.t0 = _context3["catch"](
|
150
|
+
case 9:
|
151
|
+
_context3.prev = 9;
|
152
|
+
_context3.t0 = _context3["catch"](2);
|
181
153
|
setIsSubmitting(false);
|
182
154
|
console.warn("".concat(componentName, " onNext error: ").concat(_context3.t0));
|
183
155
|
|
184
|
-
case
|
185
|
-
_context3.next =
|
156
|
+
case 13:
|
157
|
+
_context3.next = 17;
|
186
158
|
break;
|
187
159
|
|
188
|
-
case
|
189
|
-
_context3.next =
|
160
|
+
case 15:
|
161
|
+
_context3.next = 17;
|
190
162
|
return handleOnRequestSubmit();
|
191
163
|
|
192
|
-
case
|
164
|
+
case 17:
|
193
165
|
case "end":
|
194
166
|
return _context3.stop();
|
195
167
|
}
|
196
168
|
}
|
197
|
-
}, _callee3, null, [[
|
169
|
+
}, _callee3, null, [[2, 9]]);
|
198
170
|
}));
|
199
171
|
|
200
172
|
return function handleSubmit() {
|
@@ -202,12 +174,10 @@ export var useCreateComponentStepChange = function useCreateComponentStepChange(
|
|
202
174
|
};
|
203
175
|
}();
|
204
176
|
|
205
|
-
if (
|
206
|
-
var createSteps = getComponentSteps();
|
207
|
-
var total = createSteps.length;
|
177
|
+
if (totalStepCount > 0) {
|
208
178
|
var buttons = [];
|
209
179
|
|
210
|
-
if (
|
180
|
+
if (totalStepCount > 1 && !shouldViewAll) {
|
211
181
|
buttons.push({
|
212
182
|
key: 'create-action-button-back',
|
213
183
|
label: backButtonText,
|
@@ -231,16 +201,16 @@ export var useCreateComponentStepChange = function useCreateComponentStepChange(
|
|
231
201
|
});
|
232
202
|
buttons.push({
|
233
203
|
key: 'create-action-button-submit',
|
234
|
-
label: shouldViewAll ? submitButtonText : currentStep <
|
235
|
-
onClick: shouldViewAll ? handleSubmit : currentStep <
|
236
|
-
disabled: isSubmitDisabled
|
204
|
+
label: shouldViewAll ? submitButtonText : currentStep < totalStepCount ? nextButtonText : submitButtonText,
|
205
|
+
onClick: shouldViewAll ? handleSubmit : currentStep < totalStepCount ? handleNext : handleSubmit,
|
206
|
+
disabled: isSubmitDisabled,
|
237
207
|
kind: 'primary',
|
238
208
|
loading: isSubmitting,
|
239
209
|
className: "".concat(componentBlockClass, "__create-button")
|
240
210
|
});
|
241
211
|
setCreateComponentActions(buttons);
|
242
212
|
}
|
243
|
-
}, [
|
213
|
+
}, [totalStepCount, onNext, isSubmitDisabled, backButtonText, cancelButtonText, currentStep, onClose, nextButtonText, submitButtonText, onRequestSubmit, isSubmitting, shouldViewAll, componentBlockClass, componentName, continueToNextStep, setCurrentStep, setCreateComponentActions, setIsSubmitting, setShouldViewAll, setModalIsOpen]);
|
244
214
|
var continueToNextStep = useCallback(function () {
|
245
215
|
setIsSubmitting(false);
|
246
216
|
setCurrentStep(function (prev) {
|
@@ -7,17 +7,14 @@
|
|
7
7
|
import { useEffect } from 'react';
|
8
8
|
/**
|
9
9
|
* Logs a warning to console if an invalid number of steps are used with the given CreateComponent
|
10
|
-
* @param {
|
10
|
+
* @param {number} stepCount
|
11
11
|
* @param {string} componentName
|
12
12
|
*/
|
13
13
|
|
14
|
-
export var useValidCreateStepCount = function useValidCreateStepCount(
|
14
|
+
export var useValidCreateStepCount = function useValidCreateStepCount(stepCount, componentName) {
|
15
15
|
useEffect(function () {
|
16
|
-
|
17
|
-
var total = createSteps.length;
|
18
|
-
|
19
|
-
if (total === 1) {
|
16
|
+
if (stepCount === 1) {
|
20
17
|
console.warn("".concat(componentName, ": ").concat(componentName, "s with one step are not permitted. If you require only one step, please use either the CreateTearsheetNarrow, CreateSidePanel, or CreateModal components."));
|
21
18
|
}
|
22
|
-
}, [
|
19
|
+
}, [stepCount, componentName]);
|
23
20
|
};
|
@@ -52,6 +52,8 @@ var defaults = {
|
|
52
52
|
UnauthorizedEmptyState: true,
|
53
53
|
UserProfileImage: true,
|
54
54
|
// other public components not yet reviewed and released:
|
55
|
+
MultiAddSelect: false,
|
56
|
+
SingleAddSelect: false,
|
55
57
|
LoadingBar: false,
|
56
58
|
ModifiedTabs: false,
|
57
59
|
Toolbar: false,
|
@@ -59,7 +61,9 @@ var defaults = {
|
|
59
61
|
ToolbarGroup: false,
|
60
62
|
WebTerminal: false,
|
61
63
|
EditSidePanel: false,
|
62
|
-
OptionsTile: false
|
64
|
+
OptionsTile: false,
|
65
|
+
CancelableTextEdit: false,
|
66
|
+
InlineEdit: false
|
63
67
|
/* new component flags here - comment used by generate CLI */
|
64
68
|
|
65
69
|
},
|
@@ -17,7 +17,7 @@ import { getPathForComponent } from '../../../../../core/story-structure';
|
|
17
17
|
|
18
18
|
export var getStoryTitle = function getStoryTitle(componentName) {
|
19
19
|
var title = // if the component isn't in the master structure, put it in a lost+found section
|
20
|
-
getPathForComponent('c', componentName) || "
|
20
|
+
getPathForComponent('c', componentName) || "Carbon for IBM Products/Lost + found/".concat(componentName); // add a canary tag if the component is public but not normally enabled
|
21
21
|
|
22
22
|
return !pkg.isComponentEnabled(componentName, true) && pkg.isComponentPublic(componentName, true) ? "".concat(title, "#canary") : title;
|
23
23
|
};
|
@@ -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 =
|
209
|
+
_context.next = 5;
|
214
210
|
break;
|
215
211
|
}
|
216
212
|
|
217
213
|
setCurrentStep(currentStep + 1);
|
218
|
-
_context.next =
|
214
|
+
_context.next = 22;
|
219
215
|
break;
|
220
216
|
|
221
|
-
case
|
217
|
+
case 5:
|
222
218
|
if (!apiKeyLoaded) {
|
223
|
-
_context.next =
|
219
|
+
_context.next = 21;
|
224
220
|
break;
|
225
221
|
}
|
226
222
|
|
227
223
|
if (!onCopy) {
|
228
|
-
_context.next =
|
224
|
+
_context.next = 10;
|
229
225
|
break;
|
230
226
|
}
|
231
227
|
|
232
228
|
onCopy(apiKey);
|
233
|
-
_context.next =
|
229
|
+
_context.next = 19;
|
234
230
|
break;
|
235
231
|
|
236
|
-
case
|
237
|
-
_context.prev =
|
238
|
-
_context.next =
|
232
|
+
case 10:
|
233
|
+
_context.prev = 10;
|
234
|
+
_context.next = 13;
|
239
235
|
return navigator.clipboard.writeText(apiKey);
|
240
236
|
|
241
|
-
case
|
242
|
-
_context.next =
|
237
|
+
case 13:
|
238
|
+
_context.next = 19;
|
243
239
|
break;
|
244
240
|
|
245
|
-
case
|
246
|
-
_context.prev =
|
247
|
-
_context.t0 = _context["catch"](
|
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
|
252
|
-
_context.next =
|
247
|
+
case 19:
|
248
|
+
_context.next = 22;
|
253
249
|
break;
|
254
250
|
|
255
|
-
case
|
251
|
+
case 21:
|
256
252
|
if (editing) {
|
257
253
|
onRequestEdit(name);
|
258
254
|
} else {
|
259
255
|
onRequestGenerate(name);
|
260
256
|
}
|
261
257
|
|
262
|
-
case
|
258
|
+
case 22:
|
263
259
|
case "end":
|
264
260
|
return _context.stop();
|
265
261
|
}
|
266
262
|
}
|
267
|
-
}, _callee, null, [[
|
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
|
-
|
322
|
-
|
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
|
}));
|