@carbon/ibm-products 2.6.1 → 2.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 +6288 -5847
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +3 -3
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +21 -21
- 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-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +1256 -184
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +3 -3
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +3666 -3609
- package/css/index.css.map +1 -1
- package/css/index.min.css +2 -2
- package/css/index.min.css.map +1 -1
- package/es/components/CreateTearsheet/CreateTearsheet.js +30 -14
- package/es/components/CreateTearsheet/CreateTearsheetStep.js +10 -4
- package/es/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +3 -0
- package/es/components/Datagrid/Datagrid/Datagrid.js +12 -7
- package/es/components/Datagrid/Datagrid/DatagridContent.js +18 -14
- package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +12 -1
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +1 -23
- package/es/components/Datagrid/utils/getColTitle.js +25 -0
- package/es/components/NotificationsPanel/NotificationsPanel.js +5 -5
- package/es/components/OptionsTile/OptionsTile.js +2 -4
- package/es/global/js/hooks/useCreateComponentStepChange.js +98 -49
- package/es/global/js/hooks/useResizeObserver.js +15 -1
- package/es/global/js/hooks/useRetrieveStepData.js +1 -1
- package/es/global/js/utils/StoryDocsPage.js +0 -1
- package/lib/components/CreateTearsheet/CreateTearsheet.js +30 -14
- package/lib/components/CreateTearsheet/CreateTearsheetStep.js +10 -4
- package/lib/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +3 -0
- package/lib/components/Datagrid/Datagrid/Datagrid.js +12 -7
- package/lib/components/Datagrid/Datagrid/DatagridContent.js +17 -13
- package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +12 -1
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +4 -26
- package/lib/components/Datagrid/utils/getColTitle.js +32 -0
- package/lib/components/NotificationsPanel/NotificationsPanel.js +5 -5
- package/lib/components/OptionsTile/OptionsTile.js +2 -4
- package/lib/global/js/hooks/useCreateComponentStepChange.js +98 -49
- package/lib/global/js/hooks/useResizeObserver.js +15 -1
- package/lib/global/js/hooks/useRetrieveStepData.js +1 -1
- package/lib/global/js/utils/StoryDocsPage.js +0 -1
- package/package.json +8 -8
@@ -7,27 +7,28 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
8
8
|
*/
|
9
9
|
|
10
|
+
import { FilterContext, FilterPanel } from './addons/Filtering';
|
10
11
|
import React, { useContext, useEffect, useRef } from 'react';
|
11
|
-
import
|
12
|
-
import
|
13
|
-
import {
|
14
|
-
import { px } from '@carbon/layout';
|
15
|
-
import DatagridHead from './DatagridHead';
|
12
|
+
import { Table, TableContainer } from '@carbon/react';
|
13
|
+
import { carbon, pkg } from '../../../settings';
|
14
|
+
import { CLEAR_FILTERS } from './addons/Filtering/constants';
|
16
15
|
import DatagridBody from './DatagridBody';
|
16
|
+
import DatagridHead from './DatagridHead';
|
17
17
|
import DatagridToolbar from './DatagridToolbar';
|
18
|
-
import {
|
19
|
-
import { carbon, pkg } from '../../../settings';
|
18
|
+
import { FilterSummary } from '../../FilterSummary';
|
20
19
|
import { InlineEditContext } from './addons/InlineEdit/InlineEditContext';
|
21
|
-
import
|
20
|
+
import PropTypes from 'prop-types';
|
21
|
+
import cx from 'classnames';
|
22
22
|
import { handleGridFocus } from './addons/InlineEdit/handleGridFocus';
|
23
|
+
import { handleGridKeyPress } from './addons/InlineEdit/handleGridKeyPress';
|
24
|
+
import { px } from '@carbon/layout';
|
23
25
|
import { useClickOutside } from '../../../global/js/hooks';
|
24
26
|
import { useMultipleKeyTracking } from '../../DataSpreadsheet/hooks';
|
25
|
-
import { FilterSummary } from '../../FilterSummary';
|
26
|
-
import { CLEAR_FILTERS } from './addons/Filtering/constants';
|
27
27
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
28
28
|
export var DatagridContent = function DatagridContent(_ref) {
|
29
29
|
var _cx4;
|
30
|
-
var datagridState = _ref.datagridState
|
30
|
+
var datagridState = _ref.datagridState,
|
31
|
+
title = _ref.title;
|
31
32
|
var _useContext = useContext(InlineEditContext),
|
32
33
|
inlineEditState = _useContext.state,
|
33
34
|
dispatch = _useContext.dispatch;
|
@@ -95,7 +96,8 @@ export var DatagridContent = function DatagridContent(_ref) {
|
|
95
96
|
} : null,
|
96
97
|
onFocus: withInlineEdit ? function () {
|
97
98
|
return handleGridFocus(inlineEditState, dispatch);
|
98
|
-
} : null
|
99
|
+
} : null,
|
100
|
+
title: title
|
99
101
|
}), !withVirtualScroll ? /*#__PURE__*/React.createElement(DatagridHead, datagridState) : null, /*#__PURE__*/React.createElement(DatagridBody, _extends({}, datagridState, {
|
100
102
|
rows: rows
|
101
103
|
})));
|
@@ -126,7 +128,8 @@ export var DatagridContent = function DatagridContent(_ref) {
|
|
126
128
|
filters: filterTags,
|
127
129
|
clearFilters: function clearFilters() {
|
128
130
|
return EventEmitter.dispatch(CLEAR_FILTERS);
|
129
|
-
}
|
131
|
+
},
|
132
|
+
renderLabel: filterProps.renderLabel
|
130
133
|
});
|
131
134
|
};
|
132
135
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TableContainer, {
|
@@ -177,5 +180,6 @@ DatagridContent.propTypes = {
|
|
177
180
|
setAllFilters: PropTypes.func,
|
178
181
|
getFilterProps: PropTypes.func,
|
179
182
|
state: PropTypes.object
|
180
|
-
})
|
183
|
+
}),
|
184
|
+
title: PropTypes.string
|
181
185
|
};
|
@@ -13,7 +13,18 @@ import cx from 'classnames';
|
|
13
13
|
import { TableHeader, TableRow } from '@carbon/react';
|
14
14
|
import { selectionColumnId } from '../common-column-ids';
|
15
15
|
import { pkg } from '../../../settings';
|
16
|
+
import getColTitle from '../utils/getColTitle';
|
16
17
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
18
|
+
var getAccessibilityProps = function getAccessibilityProps(header) {
|
19
|
+
var props = {};
|
20
|
+
var title = getColTitle(header);
|
21
|
+
if (title) {
|
22
|
+
props.title = title;
|
23
|
+
} else {
|
24
|
+
props['aria-hidden'] = true;
|
25
|
+
}
|
26
|
+
return props;
|
27
|
+
};
|
17
28
|
var HeaderRow = function HeaderRow(datagridState, headRef, headerGroup) {
|
18
29
|
return /*#__PURE__*/React.createElement(TableRow, _extends({}, headerGroup.getHeaderGroupProps({
|
19
30
|
role: false
|
@@ -36,7 +47,7 @@ var HeaderRow = function HeaderRow(datagridState, headRef, headerGroup) {
|
|
36
47
|
}), {
|
37
48
|
className: cx((_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__resizableColumn"), header.getResizerProps), _defineProperty(_cx, "".concat(blockClass, "__isResizing"), header.isResizing), _defineProperty(_cx, "".concat(blockClass, "__sortableColumn"), datagridState.isTableSortable), _defineProperty(_cx, "".concat(blockClass, "__isSorted"), header.isSorted), _cx), header.getHeaderProps().className),
|
38
49
|
key: header.id
|
39
|
-
}), header.render('Header'), header.getResizerProps && /*#__PURE__*/React.createElement("div", _extends({}, header.getResizerProps(), {
|
50
|
+
}, getAccessibilityProps(header)), header.render('Header'), header.getResizerProps && /*#__PURE__*/React.createElement("div", _extends({}, header.getResizerProps(), {
|
40
51
|
className: "".concat(blockClass, "__resizer")
|
41
52
|
})));
|
42
53
|
}));
|
@@ -11,6 +11,7 @@ import { Checkbox } from '@carbon/react';
|
|
11
11
|
import { isColumnVisible } from './common';
|
12
12
|
import DraggableElement from '../../DraggableElement';
|
13
13
|
import { pkg } from '../../../../../settings';
|
14
|
+
import getColTitle from '../../../utils/getColTitle';
|
14
15
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
15
16
|
export var DraggableItemsList = function DraggableItemsList(_ref) {
|
16
17
|
var columns = _ref.columns,
|
@@ -22,29 +23,6 @@ export var DraggableItemsList = function DraggableItemsList(_ref) {
|
|
22
23
|
setAriaRegionText = _ref.setAriaRegionText,
|
23
24
|
setColumnsObject = _ref.setColumnsObject,
|
24
25
|
setFocusIndex = _ref.setFocusIndex;
|
25
|
-
// This function recursively looks for the nested header element until we can find the key which contains the title.
|
26
|
-
// This can happen if multiple hooks are used together that manipulate the rendering of the column
|
27
|
-
// header, such as `useColumnCenterAlign` and `useSortableColumns`.
|
28
|
-
var getNestedTitle = function getNestedTitle(component) {
|
29
|
-
if (component && !component.key) {
|
30
|
-
return getNestedTitle(component.children);
|
31
|
-
}
|
32
|
-
if (component && component.key && typeof component.key === 'string') {
|
33
|
-
return component.key;
|
34
|
-
}
|
35
|
-
};
|
36
|
-
var getColTitle = function getColTitle(col) {
|
37
|
-
if (!col) {
|
38
|
-
return;
|
39
|
-
}
|
40
|
-
var checkTitle = function checkTitle() {
|
41
|
-
if (col.Header().props.children.props && col.Header().props.children.props.title) {
|
42
|
-
return col.Header().props.children.props.title;
|
43
|
-
}
|
44
|
-
return getNestedTitle(col.Header().props.children.props);
|
45
|
-
};
|
46
|
-
return typeof (col === null || col === void 0 ? void 0 : col.Header) === 'function' ? checkTitle() : col.Header.props.title;
|
47
|
-
};
|
48
26
|
return /*#__PURE__*/React.createElement(React.Fragment, null, columns
|
49
27
|
// hide the columns without Header, e.g the sticky actions, spacer
|
50
28
|
.filter(function (colDef) {
|
@@ -0,0 +1,25 @@
|
|
1
|
+
// This function recursively looks for the nested header element until we can find the key which contains the title.
|
2
|
+
// This can happen if multiple hooks are used together that manipulate the rendering of the column
|
3
|
+
// header, such as `useColumnCenterAlign` and `useSortableColumns`.
|
4
|
+
var getNestedTitle = function getNestedTitle(component) {
|
5
|
+
if (component && !component.key) {
|
6
|
+
return getNestedTitle(component.children);
|
7
|
+
}
|
8
|
+
if (component && component.key && typeof component.key === 'string') {
|
9
|
+
return component.key;
|
10
|
+
}
|
11
|
+
};
|
12
|
+
var getColTitle = function getColTitle(col) {
|
13
|
+
var _col$Header;
|
14
|
+
if (!col) {
|
15
|
+
return;
|
16
|
+
}
|
17
|
+
var checkTitle = function checkTitle() {
|
18
|
+
if (col.Header().props.children.props && col.Header().props.children.props.title) {
|
19
|
+
return col.Header().props.children.props.title;
|
20
|
+
}
|
21
|
+
return getNestedTitle(col.Header().props.children.props);
|
22
|
+
};
|
23
|
+
return typeof (col === null || col === void 0 ? void 0 : col.Header) === 'function' ? checkTitle() : col === null || col === void 0 || (_col$Header = col.Header) === null || _col$Header === void 0 || (_col$Header = _col$Header.props) === null || _col$Header === void 0 ? void 0 : _col$Header.title;
|
24
|
+
};
|
25
|
+
export default getColTitle;
|
@@ -331,7 +331,7 @@ export var NotificationsPanel = /*#__PURE__*/React.forwardRef(function (_ref, re
|
|
331
331
|
className: "".concat(blockClass, "__header-container")
|
332
332
|
}, /*#__PURE__*/React.createElement("div", {
|
333
333
|
className: "".concat(blockClass, "__header-flex")
|
334
|
-
}, /*#__PURE__*/React.createElement("
|
334
|
+
}, /*#__PURE__*/React.createElement("h2", {
|
335
335
|
className: "".concat(blockClass, "__header")
|
336
336
|
}, title), /*#__PURE__*/React.createElement(Button, {
|
337
337
|
size: "sm",
|
@@ -340,7 +340,7 @@ export var NotificationsPanel = /*#__PURE__*/React.forwardRef(function (_ref, re
|
|
340
340
|
onClick: function onClick() {
|
341
341
|
return onDismissAllNotifications();
|
342
342
|
}
|
343
|
-
}, dismissAllLabel)), /*#__PURE__*/React.createElement(Toggle, {
|
343
|
+
}, dismissAllLabel)), onDoNotDisturbChange && /*#__PURE__*/React.createElement(Toggle, {
|
344
344
|
size: "sm",
|
345
345
|
className: "".concat(blockClass, "__do-not-disturb-toggle"),
|
346
346
|
id: "".concat(blockClass, "__do-not-disturb-toggle-component"),
|
@@ -441,11 +441,11 @@ NotificationsPanel.propTypes = {
|
|
441
441
|
*/
|
442
442
|
dismissSingleNotificationIconDescription: PropTypes.string,
|
443
443
|
/**
|
444
|
-
* Determines if the `Do not disturb` toggle is on or off when the component is rendered
|
444
|
+
* Optional: Determines if the `Do not disturb` toggle is on or off when the component is rendered
|
445
445
|
*/
|
446
446
|
doNotDisturbDefaultToggled: PropTypes.bool,
|
447
447
|
/**
|
448
|
-
* Label for Do not disturb toggle
|
448
|
+
* Optional: Label for Do not disturb toggle
|
449
449
|
*/
|
450
450
|
doNotDisturbLabel: PropTypes.string,
|
451
451
|
/**
|
@@ -493,7 +493,7 @@ NotificationsPanel.propTypes = {
|
|
493
493
|
*/
|
494
494
|
onDismissSingleNotification: PropTypes.func,
|
495
495
|
/**
|
496
|
-
*
|
496
|
+
* Optional: function that returns the current selected value of the disable notification toggle
|
497
497
|
*/
|
498
498
|
onDoNotDisturbChange: PropTypes.func,
|
499
499
|
/**
|
@@ -217,13 +217,11 @@ export var OptionsTile = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
217
217
|
id: "".concat(id, "-toggle"),
|
218
218
|
className: "".concat(blockClass, "__toggle"),
|
219
219
|
toggled: enabled,
|
220
|
-
labelA: "",
|
221
|
-
labelB: "",
|
222
220
|
"aria-labelledby": titleId,
|
221
|
+
hideLabel: true,
|
223
222
|
onToggle: onToggle,
|
224
223
|
size: "sm",
|
225
|
-
disabled: isLocked
|
226
|
-
labelText: title
|
224
|
+
disabled: isLocked
|
227
225
|
})), isExpandable ? /*#__PURE__*/React.createElement("details", {
|
228
226
|
open: isOpen,
|
229
227
|
ref: detailsRef
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
2
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
3
3
|
/**
|
4
|
-
* Copyright IBM Corp. 2021,
|
4
|
+
* Copyright IBM Corp. 2021, 2023
|
5
5
|
*
|
6
6
|
* This source code is licensed under the Apache-2.0 license found in the
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
@@ -12,16 +12,19 @@ export var useCreateComponentStepChange = function useCreateComponentStepChange(
|
|
12
12
|
var firstIncludedStep = _ref.firstIncludedStep,
|
13
13
|
lastIncludedStep = _ref.lastIncludedStep,
|
14
14
|
stepData = _ref.stepData,
|
15
|
+
onPrevious = _ref.onPrevious,
|
15
16
|
onNext = _ref.onNext,
|
16
17
|
isSubmitDisabled = _ref.isSubmitDisabled,
|
17
18
|
setCurrentStep = _ref.setCurrentStep,
|
18
19
|
setIsSubmitting = _ref.setIsSubmitting,
|
19
|
-
|
20
|
+
_ref$setLoadingPrevio = _ref.setLoadingPrevious,
|
21
|
+
setLoadingPrevious = _ref$setLoadingPrevio === void 0 ? null : _ref$setLoadingPrevio,
|
22
|
+
_ref$loadingPrevious = _ref.loadingPrevious,
|
23
|
+
loadingPrevious = _ref$loadingPrevious === void 0 ? false : _ref$loadingPrevious,
|
20
24
|
onClose = _ref.onClose,
|
21
25
|
onRequestSubmit = _ref.onRequestSubmit,
|
22
26
|
componentName = _ref.componentName,
|
23
27
|
currentStep = _ref.currentStep,
|
24
|
-
shouldViewAll = _ref.shouldViewAll,
|
25
28
|
backButtonText = _ref.backButtonText,
|
26
29
|
cancelButtonText = _ref.cancelButtonText,
|
27
30
|
submitButtonText = _ref.submitButtonText,
|
@@ -43,6 +46,21 @@ export var useCreateComponentStepChange = function useCreateComponentStepChange(
|
|
43
46
|
return prev;
|
44
47
|
});
|
45
48
|
}, [setCurrentStep, setIsSubmitting, stepData]);
|
49
|
+
var moveToPreviousStep = useCallback(function () {
|
50
|
+
if (componentName !== 'CreateFullPage') {
|
51
|
+
setLoadingPrevious(false);
|
52
|
+
}
|
53
|
+
setCurrentStep(function (prev) {
|
54
|
+
// Find previous included step to render
|
55
|
+
// There will always be a previous step otherwise we will
|
56
|
+
// have disabled the back button since we have reached the first visible step
|
57
|
+
do {
|
58
|
+
var _stepData2;
|
59
|
+
prev--;
|
60
|
+
} while (!((_stepData2 = stepData[prev - 1]) !== null && _stepData2 !== void 0 && _stepData2.shouldIncludeStep));
|
61
|
+
return prev;
|
62
|
+
});
|
63
|
+
}, [setCurrentStep, stepData, setLoadingPrevious, componentName]);
|
46
64
|
|
47
65
|
// useEffect to handle multi step logic
|
48
66
|
useEffect(function () {
|
@@ -51,7 +69,6 @@ export var useCreateComponentStepChange = function useCreateComponentStepChange(
|
|
51
69
|
setCurrentStep(0);
|
52
70
|
}
|
53
71
|
setIsSubmitting(false);
|
54
|
-
setShouldViewAll(false);
|
55
72
|
onClose();
|
56
73
|
};
|
57
74
|
var handleOnRequestSubmit = /*#__PURE__*/function () {
|
@@ -81,104 +98,136 @@ export var useCreateComponentStepChange = function useCreateComponentStepChange(
|
|
81
98
|
return _ref2.apply(this, arguments);
|
82
99
|
};
|
83
100
|
}();
|
84
|
-
var
|
101
|
+
var handlePrevious = /*#__PURE__*/function () {
|
85
102
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
86
103
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
87
104
|
while (1) switch (_context2.prev = _context2.next) {
|
105
|
+
case 0:
|
106
|
+
if (!(componentName === 'CreateFullPage')) {
|
107
|
+
_context2.next = 2;
|
108
|
+
break;
|
109
|
+
}
|
110
|
+
return _context2.abrupt("return");
|
111
|
+
case 2:
|
112
|
+
setLoadingPrevious(true);
|
113
|
+
if (!(typeof onPrevious === 'function')) {
|
114
|
+
_context2.next = 15;
|
115
|
+
break;
|
116
|
+
}
|
117
|
+
_context2.prev = 4;
|
118
|
+
_context2.next = 7;
|
119
|
+
return onPrevious();
|
120
|
+
case 7:
|
121
|
+
moveToPreviousStep();
|
122
|
+
_context2.next = 13;
|
123
|
+
break;
|
124
|
+
case 10:
|
125
|
+
_context2.prev = 10;
|
126
|
+
_context2.t0 = _context2["catch"](4);
|
127
|
+
console.warn("".concat(componentName, " onBack error: ").concat(_context2.t0));
|
128
|
+
case 13:
|
129
|
+
_context2.next = 16;
|
130
|
+
break;
|
131
|
+
case 15:
|
132
|
+
moveToPreviousStep();
|
133
|
+
case 16:
|
134
|
+
case "end":
|
135
|
+
return _context2.stop();
|
136
|
+
}
|
137
|
+
}, _callee2, null, [[4, 10]]);
|
138
|
+
}));
|
139
|
+
return function handlePrevious() {
|
140
|
+
return _ref3.apply(this, arguments);
|
141
|
+
};
|
142
|
+
}();
|
143
|
+
var handleNext = /*#__PURE__*/function () {
|
144
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
145
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
146
|
+
while (1) switch (_context3.prev = _context3.next) {
|
88
147
|
case 0:
|
89
148
|
setIsSubmitting(true);
|
90
149
|
if (!(typeof onNext === 'function')) {
|
91
|
-
|
150
|
+
_context3.next = 14;
|
92
151
|
break;
|
93
152
|
}
|
94
|
-
|
95
|
-
|
153
|
+
_context3.prev = 2;
|
154
|
+
_context3.next = 5;
|
96
155
|
return onNext();
|
97
156
|
case 5:
|
98
157
|
continueToNextStep();
|
99
|
-
|
158
|
+
_context3.next = 12;
|
100
159
|
break;
|
101
160
|
case 8:
|
102
|
-
|
103
|
-
|
161
|
+
_context3.prev = 8;
|
162
|
+
_context3.t0 = _context3["catch"](2);
|
104
163
|
setIsSubmitting(false);
|
105
|
-
console.warn("".concat(componentName, " onNext error: ").concat(
|
164
|
+
console.warn("".concat(componentName, " onNext error: ").concat(_context3.t0));
|
106
165
|
case 12:
|
107
|
-
|
166
|
+
_context3.next = 15;
|
108
167
|
break;
|
109
168
|
case 14:
|
110
169
|
continueToNextStep();
|
111
170
|
case 15:
|
112
171
|
case "end":
|
113
|
-
return
|
172
|
+
return _context3.stop();
|
114
173
|
}
|
115
|
-
},
|
174
|
+
}, _callee3, null, [[2, 8]]);
|
116
175
|
}));
|
117
176
|
return function handleNext() {
|
118
|
-
return
|
177
|
+
return _ref4.apply(this, arguments);
|
119
178
|
};
|
120
179
|
}();
|
121
180
|
var handleSubmit = /*#__PURE__*/function () {
|
122
|
-
var
|
123
|
-
return _regeneratorRuntime.wrap(function
|
124
|
-
while (1) switch (
|
181
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
182
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
183
|
+
while (1) switch (_context4.prev = _context4.next) {
|
125
184
|
case 0:
|
126
185
|
setIsSubmitting(true);
|
127
186
|
// last step should have onNext as well
|
128
187
|
if (!(typeof onNext === 'function')) {
|
129
|
-
|
188
|
+
_context4.next = 15;
|
130
189
|
break;
|
131
190
|
}
|
132
|
-
|
133
|
-
|
191
|
+
_context4.prev = 2;
|
192
|
+
_context4.next = 5;
|
134
193
|
return onNext();
|
135
194
|
case 5:
|
136
|
-
|
195
|
+
_context4.next = 7;
|
137
196
|
return handleOnRequestSubmit();
|
138
197
|
case 7:
|
139
|
-
|
198
|
+
_context4.next = 13;
|
140
199
|
break;
|
141
200
|
case 9:
|
142
|
-
|
143
|
-
|
201
|
+
_context4.prev = 9;
|
202
|
+
_context4.t0 = _context4["catch"](2);
|
144
203
|
setIsSubmitting(false);
|
145
|
-
console.warn("".concat(componentName, " onNext error: ").concat(
|
204
|
+
console.warn("".concat(componentName, " onNext error: ").concat(_context4.t0));
|
146
205
|
case 13:
|
147
|
-
|
206
|
+
_context4.next = 17;
|
148
207
|
break;
|
149
208
|
case 15:
|
150
|
-
|
209
|
+
_context4.next = 17;
|
151
210
|
return handleOnRequestSubmit();
|
152
211
|
case 17:
|
153
212
|
case "end":
|
154
|
-
return
|
213
|
+
return _context4.stop();
|
155
214
|
}
|
156
|
-
},
|
215
|
+
}, _callee4, null, [[2, 9]]);
|
157
216
|
}));
|
158
217
|
return function handleSubmit() {
|
159
|
-
return
|
218
|
+
return _ref5.apply(this, arguments);
|
160
219
|
};
|
161
220
|
}();
|
162
221
|
if ((stepData === null || stepData === void 0 ? void 0 : stepData.length) > 0) {
|
163
222
|
var buttons = [];
|
164
|
-
if ((stepData === null || stepData === void 0 ? void 0 : stepData.length) > 1
|
223
|
+
if ((stepData === null || stepData === void 0 ? void 0 : stepData.length) > 1) {
|
165
224
|
buttons.push({
|
166
225
|
key: 'create-action-button-back',
|
167
226
|
label: backButtonText,
|
168
|
-
onClick:
|
169
|
-
return setCurrentStep(function (prev) {
|
170
|
-
// Find previous included step to render
|
171
|
-
// There will always be a previous step otherwise we will
|
172
|
-
// have disabled the back button since we have reached the first visible step
|
173
|
-
do {
|
174
|
-
var _stepData2;
|
175
|
-
prev--;
|
176
|
-
} while (!((_stepData2 = stepData[prev - 1]) !== null && _stepData2 !== void 0 && _stepData2.shouldIncludeStep));
|
177
|
-
return prev;
|
178
|
-
});
|
179
|
-
},
|
227
|
+
onClick: handlePrevious,
|
180
228
|
kind: 'secondary',
|
181
|
-
disabled: currentStep === firstIncludedStep
|
229
|
+
disabled: currentStep === firstIncludedStep,
|
230
|
+
loading: loadingPrevious
|
182
231
|
});
|
183
232
|
}
|
184
233
|
buttons.push({
|
@@ -191,8 +240,8 @@ export var useCreateComponentStepChange = function useCreateComponentStepChange(
|
|
191
240
|
});
|
192
241
|
buttons.push({
|
193
242
|
key: 'create-action-button-submit',
|
194
|
-
label:
|
195
|
-
onClick:
|
243
|
+
label: currentStep < lastIncludedStep ? nextButtonText : submitButtonText,
|
244
|
+
onClick: currentStep < lastIncludedStep ? handleNext : handleSubmit,
|
196
245
|
disabled: isSubmitDisabled,
|
197
246
|
kind: 'primary',
|
198
247
|
loading: isSubmitting,
|
@@ -200,5 +249,5 @@ export var useCreateComponentStepChange = function useCreateComponentStepChange(
|
|
200
249
|
});
|
201
250
|
setCreateComponentActions(buttons);
|
202
251
|
}
|
203
|
-
}, [firstIncludedStep, lastIncludedStep, stepData, onNext, isSubmitDisabled, backButtonText, cancelButtonText, currentStep, onClose, nextButtonText, submitButtonText, onRequestSubmit, isSubmitting,
|
252
|
+
}, [firstIncludedStep, lastIncludedStep, stepData, onNext, isSubmitDisabled, backButtonText, cancelButtonText, currentStep, onClose, nextButtonText, submitButtonText, onRequestSubmit, isSubmitting, componentBlockClass, componentName, continueToNextStep, setCurrentStep, setCreateComponentActions, setIsSubmitting, setModalIsOpen, moveToPreviousStep, onPrevious, setLoadingPrevious, loadingPrevious]);
|
204
253
|
};
|
@@ -18,11 +18,25 @@ export var useResizeObserver = function useResizeObserver(ref, callback) {
|
|
18
18
|
var entriesToHandle = useRef(null);
|
19
19
|
var cb = useRef(callback);
|
20
20
|
useEffect(function () {
|
21
|
-
// ref for callback removes it as dependency
|
21
|
+
// ref for callback removes it as dependency from useLayoutEffect
|
22
22
|
// This significantly reduces repeated calls if a function is redefined on every
|
23
23
|
// render
|
24
24
|
cb.current = callback;
|
25
25
|
}, [callback]);
|
26
|
+
useEffect(function () {
|
27
|
+
var getInitialSize = function getInitialSize() {
|
28
|
+
if (ref.current) {
|
29
|
+
var _ref$current;
|
30
|
+
var refComputedStyle = window.getComputedStyle(ref.current);
|
31
|
+
var initialWidth = (((_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.offsetWidth) || 0) - (parseFloat((refComputedStyle === null || refComputedStyle === void 0 ? void 0 : refComputedStyle.paddingLeft) || 0), parseFloat((refComputedStyle === null || refComputedStyle === void 0 ? void 0 : refComputedStyle.paddingRight) || 0));
|
32
|
+
setWidth(initialWidth);
|
33
|
+
}
|
34
|
+
};
|
35
|
+
if (!(ref !== null && ref !== void 0 && ref.current) && width !== 0) {
|
36
|
+
return;
|
37
|
+
}
|
38
|
+
getInitialSize();
|
39
|
+
}, [width, ref]);
|
26
40
|
useLayoutEffect(function () {
|
27
41
|
if (!(ref !== null && ref !== void 0 && ref.current)) {
|
28
42
|
return;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
2
2
|
/**
|
3
|
-
* Copyright IBM Corp. 2022,
|
3
|
+
* Copyright IBM Corp. 2022, 2023
|
4
4
|
*
|
5
5
|
* This source code is licensed under the Apache-2.0 license found in the
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
@@ -83,7 +83,6 @@ export var StoryDocsPage = function StoryDocsPage(_ref2) {
|
|
83
83
|
var isFullScreen = (csfFile === null || csfFile === void 0 || (_csfFile$meta = csfFile.meta) === null || _csfFile$meta === void 0 || (_csfFile$meta = _csfFile$meta.parameters) === null || _csfFile$meta === void 0 ? void 0 : _csfFile$meta.layout) === 'fullscreen' || false;
|
84
84
|
var storyHelperClass = isFullScreen ? 'c4p--story-docs-page--fullscreen' : '';
|
85
85
|
var processedBlocks = processBlocks(blocks, csfFile.stories, omitUnreferencedStories);
|
86
|
-
console.log(processBlocks);
|
87
86
|
var storyCount = (_processedBlocks$filt = processedBlocks === null || processedBlocks === void 0 ? void 0 : processedBlocks.filter(function (block) {
|
88
87
|
return !!block.story;
|
89
88
|
}).length) !== null && _processedBlocks$filt !== void 0 ? _processedBlocks$filt : 0;
|
@@ -89,26 +89,34 @@ var CreateTearsheet = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
89
89
|
_useState10 = (0, _slicedToArray2.default)(_useState9, 2),
|
90
90
|
isDisabled = _useState10[0],
|
91
91
|
setIsDisabled = _useState10[1];
|
92
|
-
var _useState11 = (0, _react.useState)(),
|
92
|
+
var _useState11 = (0, _react.useState)(false),
|
93
93
|
_useState12 = (0, _slicedToArray2.default)(_useState11, 2),
|
94
|
-
|
95
|
-
|
94
|
+
loadingPrevious = _useState12[0],
|
95
|
+
setLoadingPrevious = _useState12[1];
|
96
96
|
var _useState13 = (0, _react.useState)(),
|
97
97
|
_useState14 = (0, _slicedToArray2.default)(_useState13, 2),
|
98
|
-
|
99
|
-
|
100
|
-
var _useState15 = (0, _react.useState)(
|
98
|
+
onPrevious = _useState14[0],
|
99
|
+
_setOnPrevious = _useState14[1];
|
100
|
+
var _useState15 = (0, _react.useState)(),
|
101
101
|
_useState16 = (0, _slicedToArray2.default)(_useState15, 2),
|
102
|
-
|
103
|
-
|
104
|
-
var _useState17 = (0, _react.useState)(
|
102
|
+
onNext = _useState16[0],
|
103
|
+
_setOnNext = _useState16[1];
|
104
|
+
var _useState17 = (0, _react.useState)(),
|
105
105
|
_useState18 = (0, _slicedToArray2.default)(_useState17, 2),
|
106
|
-
|
107
|
-
|
108
|
-
var _useState19 = (0, _react.useState)(
|
106
|
+
onMount = _useState18[0],
|
107
|
+
_setOnMount = _useState18[1];
|
108
|
+
var _useState19 = (0, _react.useState)([]),
|
109
109
|
_useState20 = (0, _slicedToArray2.default)(_useState19, 2),
|
110
|
-
|
111
|
-
|
110
|
+
stepData = _useState20[0],
|
111
|
+
setStepData = _useState20[1];
|
112
|
+
var _useState21 = (0, _react.useState)(1),
|
113
|
+
_useState22 = (0, _slicedToArray2.default)(_useState21, 2),
|
114
|
+
firstIncludedStep = _useState22[0],
|
115
|
+
setFirstIncludedStep = _useState22[1];
|
116
|
+
var _useState23 = (0, _react.useState)(null),
|
117
|
+
_useState24 = (0, _slicedToArray2.default)(_useState23, 2),
|
118
|
+
lastIncludedStep = _useState24[0],
|
119
|
+
setLastIncludedStep = _useState24[1];
|
112
120
|
var previousState = (0, _hooks.usePreviousValue)({
|
113
121
|
currentStep: currentStep,
|
114
122
|
open: open
|
@@ -152,11 +160,14 @@ var CreateTearsheet = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
152
160
|
firstIncludedStep: firstIncludedStep,
|
153
161
|
lastIncludedStep: lastIncludedStep,
|
154
162
|
stepData: stepData,
|
163
|
+
onPrevious: onPrevious,
|
155
164
|
onNext: onNext,
|
156
165
|
isSubmitDisabled: isDisabled,
|
157
166
|
setCurrentStep: setCurrentStep,
|
158
167
|
setIsSubmitting: setIsSubmitting,
|
159
168
|
setShouldViewAll: setShouldViewAll,
|
169
|
+
setLoadingPrevious: setLoadingPrevious,
|
170
|
+
loadingPrevious: loadingPrevious,
|
160
171
|
onClose: onClose,
|
161
172
|
onRequestSubmit: onRequestSubmit,
|
162
173
|
componentName: componentName,
|
@@ -213,6 +224,11 @@ var CreateTearsheet = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
213
224
|
value: {
|
214
225
|
currentStep: currentStep,
|
215
226
|
setIsDisabled: setIsDisabled,
|
227
|
+
setOnPrevious: function setOnPrevious(fn) {
|
228
|
+
return _setOnPrevious(function () {
|
229
|
+
return fn;
|
230
|
+
});
|
231
|
+
},
|
216
232
|
setOnNext: function setOnNext(fn) {
|
217
233
|
return _setOnNext(function () {
|
218
234
|
return fn;
|
@@ -18,7 +18,7 @@ var _CreateTearsheet = require("./CreateTearsheet");
|
|
18
18
|
var _settings = require("../../settings");
|
19
19
|
var _pconsole = _interopRequireDefault(require("../../global/js/utils/pconsole"));
|
20
20
|
var _hooks = require("../../global/js/hooks");
|
21
|
-
var _excluded = ["children", "className", "description", "disableSubmit", "fieldsetLegendText", "hasFieldset", "includeStep", "introStep", "onNext", "
|
21
|
+
var _excluded = ["children", "className", "description", "disableSubmit", "fieldsetLegendText", "hasFieldset", "includeStep", "introStep", "onMount", "onNext", "onPrevious", "secondaryLabel", "subtitle", "title"];
|
22
22
|
/**
|
23
23
|
* Copyright IBM Corp. 2021, 2023
|
24
24
|
*
|
@@ -47,8 +47,9 @@ var CreateTearsheetStep = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, re
|
|
47
47
|
_ref$includeStep = _ref.includeStep,
|
48
48
|
includeStep = _ref$includeStep === void 0 ? defaults.includeStep : _ref$includeStep,
|
49
49
|
introStep = _ref.introStep,
|
50
|
-
onNext = _ref.onNext,
|
51
50
|
onMount = _ref.onMount,
|
51
|
+
onNext = _ref.onNext,
|
52
|
+
onPrevious = _ref.onPrevious,
|
52
53
|
secondaryLabel = _ref.secondaryLabel,
|
53
54
|
subtitle = _ref.subtitle,
|
54
55
|
title = _ref.title,
|
@@ -90,8 +91,9 @@ var CreateTearsheetStep = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, re
|
|
90
91
|
if (stepNumber === (stepsContext === null || stepsContext === void 0 ? void 0 : stepsContext.currentStep)) {
|
91
92
|
stepsContext.setIsDisabled(disableSubmit);
|
92
93
|
stepsContext === null || stepsContext === void 0 ? void 0 : stepsContext.setOnNext(onNext); // needs to be updated here otherwise there could be stale state values from only initially setting onNext
|
94
|
+
stepsContext === null || stepsContext === void 0 ? void 0 : stepsContext.setOnPrevious(onPrevious);
|
93
95
|
}
|
94
|
-
}, [stepsContext, stepNumber, disableSubmit, onNext]);
|
96
|
+
}, [stepsContext, stepNumber, disableSubmit, onNext, onPrevious]);
|
95
97
|
var renderDescription = function renderDescription() {
|
96
98
|
if (description) {
|
97
99
|
if (typeof description === 'string') {
|
@@ -177,11 +179,15 @@ CreateTearsheetStep.propTypes = {
|
|
177
179
|
*/
|
178
180
|
onMount: _propTypes.default.func,
|
179
181
|
/**
|
180
|
-
* Optional function to be called
|
182
|
+
* Optional function to be called when you move to the next step.
|
181
183
|
* For example, this can be used to validate input fields before proceeding to the next step.
|
182
184
|
* This function can _optionally_ return a promise that is either resolved or rejected and the CreateTearsheet will handle the submitting state of the next button.
|
183
185
|
*/
|
184
186
|
onNext: _propTypes.default.func,
|
187
|
+
/**
|
188
|
+
* Optional function to be called when you move to the previous step.
|
189
|
+
*/
|
190
|
+
onPrevious: _propTypes.default.func,
|
185
191
|
/**
|
186
192
|
* Sets the optional secondary label on the progress step component
|
187
193
|
*/
|
@@ -223,6 +223,9 @@ var MultiStepTearsheet = function MultiStepTearsheet(_ref2) {
|
|
223
223
|
},
|
224
224
|
checked: shouldIncludeAdditionalStep
|
225
225
|
})))), /*#__PURE__*/_react.default.createElement(_CreateTearsheetStep.CreateTearsheetStep, {
|
226
|
+
onPrevious: function onPrevious() {
|
227
|
+
console.log('custom onPrevious handler');
|
228
|
+
},
|
226
229
|
title: "Dynamic step",
|
227
230
|
subtitle: "Dynamic step subtitle",
|
228
231
|
description: "This is an example showing how to include a dynamic step into the CreateTearsheet",
|