grommet 2.55.0 → 2.56.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/COPYRIGHT.md +3 -1
- package/components/Button/Button.js +7 -4
- package/components/Button/stories/CustomThemed/ChildrenPlainOption.stories.js +86 -0
- package/components/Calendar/Calendar.js +2 -1
- package/components/Cards/Cards.js +1 -2
- package/components/DateTimeInput/DateTimeInput.js +1093 -0
- package/components/DateTimeInput/README.md +2 -0
- package/components/DateTimeInput/StyledDateTimeInput.js +74 -0
- package/components/DateTimeInput/index.d.ts +47 -0
- package/components/DateTimeInput/index.js +6 -0
- package/components/DateTimeInput/propTypes.js +42 -0
- package/components/DateTimeInput/stories/CustomThemed/Custom.stories.tsx +53 -0
- package/components/DateTimeInput/stories/Form.stories.tsx +44 -0
- package/components/DateTimeInput/stories/Inline.stories.tsx +45 -0
- package/components/DateTimeInput/stories/Locale.stories.tsx +59 -0
- package/components/DateTimeInput/stories/Simple.stories.tsx +23 -0
- package/components/Form/Form.js +7 -4
- package/components/Form/index.d.ts +3 -0
- package/components/Form/stories/AggregateValidation.stories.js +6 -8
- package/components/FormField/FormField.js +164 -91
- package/components/Grommet/index.d.ts +21 -0
- package/components/Grommet/propTypes.js +26 -0
- package/components/Stepper/StepConnector.js +38 -0
- package/components/Stepper/Stepper.js +303 -0
- package/components/Stepper/StepperContext.js +43 -0
- package/components/Stepper/StepperDescription.js +26 -0
- package/components/Stepper/StepperHelperText.js +44 -0
- package/components/Stepper/StepperIndicator.js +74 -0
- package/components/Stepper/StepperLabel.js +41 -0
- package/components/Stepper/StepperStep.js +137 -0
- package/components/Stepper/StyledStepper.js +162 -0
- package/components/Stepper/index.d.ts +80 -0
- package/components/Stepper/index.js +18 -0
- package/components/Stepper/propTypes.js +35 -0
- package/components/Stepper/stories/DisabledSteps.stories.js +45 -0
- package/components/Stepper/stories/ErrorStates.stories.js +45 -0
- package/components/Stepper/stories/HorizontalSteps.stories.js +50 -0
- package/components/Stepper/stories/Interactive.stories.js +60 -0
- package/components/Stepper/stories/KeyboardNavigation.stories.js +64 -0
- package/components/Stepper/stories/NestedSubSteps.stories.js +70 -0
- package/components/Stepper/stories/ReadOnly.stories.js +43 -0
- package/components/Stepper/stories/ThemingLightDark.stories.js +58 -0
- package/components/Stepper/stories/VerticalSteps.stories.js +67 -0
- package/components/Tab/Tab.js +19 -6
- package/components/Tabs/Tabs.js +156 -22
- package/components/TimeInput/README.md +2 -0
- package/components/TimeInput/StyledTimeInput.js +73 -0
- package/components/TimeInput/TimeInput.js +692 -0
- package/components/TimeInput/TimeInputPopup.js +489 -0
- package/components/TimeInput/index.d.ts +44 -0
- package/components/TimeInput/index.js +6 -0
- package/components/TimeInput/propTypes.js +39 -0
- package/components/TimeInput/stories/Controlled.stories.tsx +29 -0
- package/components/TimeInput/stories/Disabled.stories.tsx +13 -0
- package/components/TimeInput/stories/Form.stories.tsx +38 -0
- package/components/TimeInput/stories/ReadOnly.stories.tsx +13 -0
- package/components/TimeInput/stories/Simple.stories.tsx +19 -0
- package/components/TimeInput/stories/Step.stories.tsx +14 -0
- package/components/TimeInput/stories/ThemingLightDark.stories.tsx +22 -0
- package/components/TimeInput/stories/Uncontrolled.stories.tsx +22 -0
- package/components/TimeInput/useSectionedTimeField.js +358 -0
- package/components/TimeInput/utils.js +192 -0
- package/components/Wizard/StyledWizard.js +16 -0
- package/components/Wizard/Wizard.js +770 -0
- package/components/Wizard/WizardContent.js +90 -0
- package/components/Wizard/WizardContext.js +35 -0
- package/components/Wizard/WizardFooter.js +123 -0
- package/components/Wizard/WizardHeader.js +63 -0
- package/components/Wizard/WizardProgress.js +84 -0
- package/components/Wizard/WizardStepHeader.js +55 -0
- package/components/Wizard/index.d.ts +171 -0
- package/components/Wizard/index.js +19 -0
- package/components/Wizard/propTypes.js +56 -0
- package/components/Wizard/stories/BasicLinear.stories.js +71 -0
- package/components/Wizard/stories/Branching.stories.js +96 -0
- package/components/Wizard/stories/Composable.stories.js +75 -0
- package/components/Wizard/stories/Controlled.stories.js +136 -0
- package/components/Wizard/stories/LongContent.stories.js +118 -0
- package/components/Wizard/stories/Modal.stories.js +143 -0
- package/components/Wizard/stories/NestedSubSteps.stories.js +79 -0
- package/components/Wizard/stories/Validation.stories.js +123 -0
- package/components/index.d.ts +6 -0
- package/components/index.js +24 -0
- package/es6/components/Button/Button.js +7 -4
- package/es6/components/Button/stories/CustomThemed/ChildrenPlainOption.stories.js +81 -0
- package/es6/components/Calendar/Calendar.js +2 -0
- package/es6/components/Cards/Cards.js +1 -2
- package/es6/components/DateTimeInput/DateTimeInput.js +1090 -0
- package/es6/components/DateTimeInput/README.md +2 -0
- package/es6/components/DateTimeInput/StyledDateTimeInput.js +68 -0
- package/es6/components/DateTimeInput/index.d.ts +47 -0
- package/es6/components/DateTimeInput/index.js +3 -0
- package/es6/components/DateTimeInput/propTypes.js +36 -0
- package/es6/components/DateTimeInput/stories/CustomThemed/Custom.stories.tsx +53 -0
- package/es6/components/DateTimeInput/stories/Form.stories.tsx +44 -0
- package/es6/components/DateTimeInput/stories/Inline.stories.tsx +45 -0
- package/es6/components/DateTimeInput/stories/Locale.stories.tsx +59 -0
- package/es6/components/DateTimeInput/stories/Simple.stories.tsx +23 -0
- package/es6/components/Form/Form.js +7 -3
- package/es6/components/Form/index.d.ts +3 -0
- package/es6/components/Form/stories/AggregateValidation.stories.js +6 -9
- package/es6/components/FormField/FormField.js +165 -91
- package/es6/components/Grommet/index.d.ts +21 -0
- package/es6/components/Grommet/propTypes.js +26 -0
- package/es6/components/Stepper/StepConnector.js +33 -0
- package/es6/components/Stepper/Stepper.js +301 -0
- package/es6/components/Stepper/StepperContext.js +39 -0
- package/es6/components/Stepper/StepperDescription.js +21 -0
- package/es6/components/Stepper/StepperHelperText.js +39 -0
- package/es6/components/Stepper/StepperIndicator.js +69 -0
- package/es6/components/Stepper/StepperLabel.js +36 -0
- package/es6/components/Stepper/StepperStep.js +133 -0
- package/es6/components/Stepper/StyledStepper.js +156 -0
- package/es6/components/Stepper/index.d.ts +80 -0
- package/es6/components/Stepper/index.js +6 -0
- package/es6/components/Stepper/propTypes.js +30 -0
- package/es6/components/Stepper/stories/DisabledSteps.stories.js +41 -0
- package/es6/components/Stepper/stories/ErrorStates.stories.js +41 -0
- package/es6/components/Stepper/stories/HorizontalSteps.stories.js +46 -0
- package/es6/components/Stepper/stories/Interactive.stories.js +56 -0
- package/es6/components/Stepper/stories/KeyboardNavigation.stories.js +60 -0
- package/es6/components/Stepper/stories/NestedSubSteps.stories.js +66 -0
- package/es6/components/Stepper/stories/ReadOnly.stories.js +39 -0
- package/es6/components/Stepper/stories/ThemingLightDark.stories.js +54 -0
- package/es6/components/Stepper/stories/VerticalSteps.stories.js +63 -0
- package/es6/components/Tab/Tab.js +19 -6
- package/es6/components/Tabs/Tabs.js +157 -23
- package/es6/components/TimeInput/README.md +2 -0
- package/es6/components/TimeInput/StyledTimeInput.js +68 -0
- package/es6/components/TimeInput/TimeInput.js +689 -0
- package/es6/components/TimeInput/TimeInputPopup.js +485 -0
- package/es6/components/TimeInput/index.d.ts +44 -0
- package/es6/components/TimeInput/index.js +1 -0
- package/es6/components/TimeInput/propTypes.js +33 -0
- package/es6/components/TimeInput/stories/Controlled.stories.tsx +29 -0
- package/es6/components/TimeInput/stories/Disabled.stories.tsx +13 -0
- package/es6/components/TimeInput/stories/Form.stories.tsx +38 -0
- package/es6/components/TimeInput/stories/ReadOnly.stories.tsx +13 -0
- package/es6/components/TimeInput/stories/Simple.stories.tsx +19 -0
- package/es6/components/TimeInput/stories/Step.stories.tsx +14 -0
- package/es6/components/TimeInput/stories/ThemingLightDark.stories.tsx +22 -0
- package/es6/components/TimeInput/stories/Uncontrolled.stories.tsx +22 -0
- package/es6/components/TimeInput/useSectionedTimeField.js +355 -0
- package/es6/components/TimeInput/utils.js +187 -0
- package/es6/components/Wizard/StyledWizard.js +11 -0
- package/es6/components/Wizard/Wizard.js +768 -0
- package/es6/components/Wizard/WizardContent.js +87 -0
- package/es6/components/Wizard/WizardContext.js +31 -0
- package/es6/components/Wizard/WizardFooter.js +120 -0
- package/es6/components/Wizard/WizardHeader.js +60 -0
- package/es6/components/Wizard/WizardProgress.js +80 -0
- package/es6/components/Wizard/WizardStepHeader.js +51 -0
- package/es6/components/Wizard/index.d.ts +171 -0
- package/es6/components/Wizard/index.js +7 -0
- package/es6/components/Wizard/propTypes.js +51 -0
- package/es6/components/Wizard/stories/BasicLinear.stories.js +67 -0
- package/es6/components/Wizard/stories/Branching.stories.js +93 -0
- package/es6/components/Wizard/stories/Composable.stories.js +72 -0
- package/es6/components/Wizard/stories/Controlled.stories.js +133 -0
- package/es6/components/Wizard/stories/LongContent.stories.js +115 -0
- package/es6/components/Wizard/stories/Modal.stories.js +141 -0
- package/es6/components/Wizard/stories/NestedSubSteps.stories.js +76 -0
- package/es6/components/Wizard/stories/Validation.stories.js +118 -0
- package/es6/components/index.d.ts +6 -0
- package/es6/components/index.js +6 -0
- package/es6/index.d.ts +6 -0
- package/es6/languages/default.json +48 -0
- package/es6/themes/base.d.ts +223 -0
- package/es6/themes/base.js +366 -0
- package/es6/utils/DOM.js +11 -2
- package/es6/utils/dates.js +10 -0
- package/es6/utils/sectionHelpers.js +57 -0
- package/es6/utils/useSectionedField.js +45 -0
- package/grommet.min.js +2 -1
- package/grommet.min.js.LICENSE.txt +1 -0
- package/grommet.min.js.map +1 -1
- package/index.d.ts +6 -0
- package/languages/default.json +48 -0
- package/package.json +57 -52
- package/themes/base.d.ts +223 -0
- package/themes/base.js +366 -1
- package/tools/license-header.js +2 -0
- package/utils/DOM.js +11 -2
- package/utils/dates.js +11 -1
- package/utils/sectionHelpers.js +61 -0
- package/utils/useSectionedField.js +50 -0
- package/components/TextInput/stories/CustomThemed/CustomSuggestions.stories.tsx +0 -180
- package/components/TextInput/stories/CustomThemed/Themed.stories.js +0 -79
- package/es6/components/TextInput/stories/CustomThemed/CustomSuggestions.stories.tsx +0 -180
- package/es6/components/TextInput/stories/CustomThemed/Themed.stories.js +0 -74
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
function _objectDestructuringEmpty(t) { if (null == t) throw new TypeError("Cannot destructure " + t); }
|
|
2
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
|
+
// SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
import React, { useCallback } from 'react';
|
|
6
|
+
import { Form } from '../Form';
|
|
7
|
+
import { Box } from '../Box';
|
|
8
|
+
import { Notification } from '../Notification';
|
|
9
|
+
import { useThemeValue } from '../../utils/useThemeValue';
|
|
10
|
+
import { useWizard } from './WizardContext';
|
|
11
|
+
|
|
12
|
+
// WizardContent renders the current step body and any wizard-level
|
|
13
|
+
// validation error message.
|
|
14
|
+
export var WizardContent = function WizardContent(_ref) {
|
|
15
|
+
var _theme$wizard;
|
|
16
|
+
var rest = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
|
|
17
|
+
var _useThemeValue = useThemeValue(),
|
|
18
|
+
theme = _useThemeValue.theme;
|
|
19
|
+
var wizard = useWizard();
|
|
20
|
+
var currentStep = wizard.currentStep,
|
|
21
|
+
currentStepIndex = wizard.currentStepIndex,
|
|
22
|
+
currentStepObj = wizard.currentStepObj,
|
|
23
|
+
totalSteps = wizard.totalSteps,
|
|
24
|
+
formValue = wizard.formValue,
|
|
25
|
+
complete = wizard.complete,
|
|
26
|
+
next = wizard.next,
|
|
27
|
+
renderStep = wizard.renderStep,
|
|
28
|
+
setFormValue = wizard.setFormValue,
|
|
29
|
+
validationError = wizard.validationError;
|
|
30
|
+
var contentTheme = (_theme$wizard = theme.wizard) == null ? void 0 : _theme$wizard.content;
|
|
31
|
+
var submit = currentStepIndex >= totalSteps - 1 ? complete : next;
|
|
32
|
+
var onValidate = useCallback(function (_ref2) {
|
|
33
|
+
var valid = _ref2.valid,
|
|
34
|
+
errors = _ref2.errors,
|
|
35
|
+
submitting = _ref2.submitting;
|
|
36
|
+
var formElement = document.getElementById(currentStep + "-form");
|
|
37
|
+
if (formElement) {
|
|
38
|
+
formElement.setAttribute('data-form-valid', String(valid));
|
|
39
|
+
}
|
|
40
|
+
if (submitting) {
|
|
41
|
+
// focus the first error field that exists in the DOM
|
|
42
|
+
var names = Object.keys(errors || {});
|
|
43
|
+
var firstInvalid = names.reduce(function (found, name) {
|
|
44
|
+
if (found) return found;
|
|
45
|
+
var matches = document.getElementsByName(name);
|
|
46
|
+
return matches.length > 0 ? matches[0] : null;
|
|
47
|
+
}, null);
|
|
48
|
+
if (firstInvalid) {
|
|
49
|
+
setTimeout(function () {
|
|
50
|
+
return firstInvalid.focus();
|
|
51
|
+
}, 0);
|
|
52
|
+
}
|
|
53
|
+
if (!valid) {
|
|
54
|
+
// Since onSubmit won't get called in this case, go ahead and
|
|
55
|
+
// call submit() to trigger wizard-level state changes. It will
|
|
56
|
+
// get to the runValidation step, see that
|
|
57
|
+
// the form is invalid from the data-form-valid attribute and set
|
|
58
|
+
// the appropriate blocked state.
|
|
59
|
+
// TODO: consider a method on the wizard context to set the
|
|
60
|
+
// blocked state directly instead of calling submit()
|
|
61
|
+
submit();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}, [currentStep, submit]);
|
|
65
|
+
if (!currentStepObj) return null;
|
|
66
|
+
var stepRender = currentStepObj.render || renderStep;
|
|
67
|
+
var body = stepRender ? stepRender(currentStepObj, wizard) : null;
|
|
68
|
+
return /*#__PURE__*/React.createElement(Form, {
|
|
69
|
+
id: currentStep + "-form",
|
|
70
|
+
value: formValue,
|
|
71
|
+
onChange: setFormValue,
|
|
72
|
+
onSubmit: submit,
|
|
73
|
+
onValidate: onValidate,
|
|
74
|
+
method: "post",
|
|
75
|
+
"data-form-valid": "true",
|
|
76
|
+
style: {
|
|
77
|
+
display: 'flex',
|
|
78
|
+
flex: '1 1 auto'
|
|
79
|
+
}
|
|
80
|
+
}, /*#__PURE__*/React.createElement(Box, _extends({}, contentTheme, {
|
|
81
|
+
flex: "grow"
|
|
82
|
+
}, rest), body, validationError && /*#__PURE__*/React.createElement(Notification, {
|
|
83
|
+
status: "critical",
|
|
84
|
+
message: validationError
|
|
85
|
+
})));
|
|
86
|
+
};
|
|
87
|
+
WizardContent.displayName = 'WizardContent';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
// WizardContext exposes wizard state and navigation actions to descendants.
|
|
4
|
+
export var WizardContext = /*#__PURE__*/React.createContext({
|
|
5
|
+
steps: [],
|
|
6
|
+
currentStep: '',
|
|
7
|
+
currentStepIndex: 0,
|
|
8
|
+
currentStepObj: undefined,
|
|
9
|
+
totalSteps: 0,
|
|
10
|
+
stepStates: {},
|
|
11
|
+
formValue: {},
|
|
12
|
+
setFormValue: function setFormValue() {},
|
|
13
|
+
validationError: undefined,
|
|
14
|
+
isValidating: false,
|
|
15
|
+
isBlocked: false,
|
|
16
|
+
isCompleted: false,
|
|
17
|
+
canGoNext: true,
|
|
18
|
+
next: function next() {},
|
|
19
|
+
previous: function previous() {},
|
|
20
|
+
goTo: function goTo() {},
|
|
21
|
+
skip: function skip() {},
|
|
22
|
+
complete: function complete() {},
|
|
23
|
+
cancel: function cancel() {},
|
|
24
|
+
// True when `onCancel` was provided; drives the footer Cancel button.
|
|
25
|
+
hasCancelHandler: false,
|
|
26
|
+
showProgress: false,
|
|
27
|
+
renderStep: undefined
|
|
28
|
+
});
|
|
29
|
+
export var useWizard = function useWizard() {
|
|
30
|
+
return useContext(WizardContext);
|
|
31
|
+
};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
var _excluded = ["children"];
|
|
2
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
4
|
+
// SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
|
|
5
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { Box } from '../Box';
|
|
8
|
+
import { Button } from '../Button';
|
|
9
|
+
import { MessageContext } from '../../contexts/MessageContext';
|
|
10
|
+
import { ResponsiveContext } from '../../contexts/ResponsiveContext';
|
|
11
|
+
import { useThemeValue } from '../../utils/useThemeValue';
|
|
12
|
+
import { useWizard } from './WizardContext';
|
|
13
|
+
|
|
14
|
+
// WizardFooter renders navigation buttons. Pass `children` to fully
|
|
15
|
+
// replace the default set.
|
|
16
|
+
export var WizardFooter = function WizardFooter(_ref) {
|
|
17
|
+
var _theme$wizard;
|
|
18
|
+
var children = _ref.children,
|
|
19
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
20
|
+
var _useThemeValue = useThemeValue(),
|
|
21
|
+
theme = _useThemeValue.theme;
|
|
22
|
+
var _React$useContext = React.useContext(MessageContext),
|
|
23
|
+
format = _React$useContext.format;
|
|
24
|
+
var _useWizard = useWizard(),
|
|
25
|
+
currentStep = _useWizard.currentStep,
|
|
26
|
+
currentStepObj = _useWizard.currentStepObj,
|
|
27
|
+
currentStepIndex = _useWizard.currentStepIndex,
|
|
28
|
+
totalSteps = _useWizard.totalSteps,
|
|
29
|
+
canGoNext = _useWizard.canGoNext,
|
|
30
|
+
previous = _useWizard.previous,
|
|
31
|
+
skip = _useWizard.skip,
|
|
32
|
+
cancel = _useWizard.cancel,
|
|
33
|
+
hasCancelHandler = _useWizard.hasCancelHandler,
|
|
34
|
+
messages = _useWizard.messages;
|
|
35
|
+
if (!currentStepObj) return null;
|
|
36
|
+
var isFirstStep = currentStepIndex <= 0;
|
|
37
|
+
var isLastStep = currentStepIndex >= totalSteps - 1;
|
|
38
|
+
var canGoPrevious = !isFirstStep;
|
|
39
|
+
var footerTheme = (_theme$wizard = theme.wizard) == null ? void 0 : _theme$wizard.footer;
|
|
40
|
+
|
|
41
|
+
// Only build the default buttons when `children` isn't provided; a
|
|
42
|
+
// custom footer replaces them entirely.
|
|
43
|
+
var content = children;
|
|
44
|
+
if (content === undefined) {
|
|
45
|
+
var _footerTheme$button, _footerTheme$button2, _footerTheme$button3, _footerTheme$button4, _footerTheme$button5;
|
|
46
|
+
var label = function label(id) {
|
|
47
|
+
return format({
|
|
48
|
+
id: "wizard." + id,
|
|
49
|
+
messages: messages
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
var NextIcon = footerTheme == null || (_footerTheme$button = footerTheme.button) == null || (_footerTheme$button = _footerTheme$button.next) == null ? void 0 : _footerTheme$button.icon;
|
|
53
|
+
var PreviousIcon = footerTheme == null || (_footerTheme$button2 = footerTheme.button) == null || (_footerTheme$button2 = _footerTheme$button2.previous) == null ? void 0 : _footerTheme$button2.icon;
|
|
54
|
+
var SkipIcon = footerTheme == null || (_footerTheme$button3 = footerTheme.button) == null || (_footerTheme$button3 = _footerTheme$button3.skip) == null ? void 0 : _footerTheme$button3.icon;
|
|
55
|
+
var CompleteIcon = footerTheme == null || (_footerTheme$button4 = footerTheme.button) == null || (_footerTheme$button4 = _footerTheme$button4.complete) == null ? void 0 : _footerTheme$button4.icon;
|
|
56
|
+
var CancelIcon = footerTheme == null || (_footerTheme$button5 = footerTheme.button) == null || (_footerTheme$button5 = _footerTheme$button5.cancel) == null ? void 0 : _footerTheme$button5.icon;
|
|
57
|
+
content = [hasCancelHandler && /*#__PURE__*/React.createElement(Button, {
|
|
58
|
+
key: "cancel",
|
|
59
|
+
label: label('cancel'),
|
|
60
|
+
icon: CancelIcon ? /*#__PURE__*/React.createElement(CancelIcon, {
|
|
61
|
+
"aria-hidden": "true"
|
|
62
|
+
}) : undefined,
|
|
63
|
+
onClick: cancel
|
|
64
|
+
}), !isFirstStep && /*#__PURE__*/React.createElement(Button, {
|
|
65
|
+
key: "previous",
|
|
66
|
+
label: label('previous'),
|
|
67
|
+
secondary: true,
|
|
68
|
+
icon: PreviousIcon ? /*#__PURE__*/React.createElement(PreviousIcon, {
|
|
69
|
+
"aria-hidden": "true"
|
|
70
|
+
}) : undefined,
|
|
71
|
+
disabled: !canGoPrevious,
|
|
72
|
+
onClick: previous
|
|
73
|
+
}), currentStepObj.skippable && !isLastStep && /*#__PURE__*/React.createElement(Button, {
|
|
74
|
+
key: "skip",
|
|
75
|
+
label: label('skip'),
|
|
76
|
+
secondary: true,
|
|
77
|
+
icon: SkipIcon ? /*#__PURE__*/React.createElement(SkipIcon, {
|
|
78
|
+
"aria-hidden": "true"
|
|
79
|
+
}) : undefined,
|
|
80
|
+
reverse: true,
|
|
81
|
+
onClick: skip
|
|
82
|
+
}), isLastStep ? /*#__PURE__*/React.createElement(Button, {
|
|
83
|
+
key: "complete",
|
|
84
|
+
label: label('complete'),
|
|
85
|
+
icon: CompleteIcon ? /*#__PURE__*/React.createElement(CompleteIcon, {
|
|
86
|
+
"aria-hidden": "true"
|
|
87
|
+
}) : undefined,
|
|
88
|
+
primary: true,
|
|
89
|
+
disabled: !canGoNext,
|
|
90
|
+
type: "submit",
|
|
91
|
+
form: currentStep + "-form"
|
|
92
|
+
}) : /*#__PURE__*/React.createElement(Button, {
|
|
93
|
+
key: "next",
|
|
94
|
+
label: label('next'),
|
|
95
|
+
primary: true,
|
|
96
|
+
icon: NextIcon ? /*#__PURE__*/React.createElement(NextIcon, {
|
|
97
|
+
"aria-hidden": "true"
|
|
98
|
+
}) : undefined,
|
|
99
|
+
reverse: true,
|
|
100
|
+
disabled: !canGoNext,
|
|
101
|
+
type: "submit",
|
|
102
|
+
form: currentStep + "-form"
|
|
103
|
+
})];
|
|
104
|
+
}
|
|
105
|
+
return /*#__PURE__*/React.createElement(ResponsiveContext.Consumer, null, function (size) {
|
|
106
|
+
var isSmall = size === 'small';
|
|
107
|
+
return /*#__PURE__*/React.createElement(Box, _extends({
|
|
108
|
+
background: footerTheme == null ? void 0 : footerTheme.background,
|
|
109
|
+
border: footerTheme == null ? void 0 : footerTheme.border,
|
|
110
|
+
pad: footerTheme == null ? void 0 : footerTheme.pad,
|
|
111
|
+
gap: footerTheme == null ? void 0 : footerTheme.gap,
|
|
112
|
+
direction: "row",
|
|
113
|
+
justify: footerTheme == null ? void 0 : footerTheme.justify,
|
|
114
|
+
align: "center",
|
|
115
|
+
wrap: isSmall,
|
|
116
|
+
flex: false
|
|
117
|
+
}, rest), content);
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
WizardFooter.displayName = 'WizardFooter';
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
var _excluded = ["title", "children"];
|
|
2
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
4
|
+
// SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
|
|
5
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { Box } from '../Box';
|
|
8
|
+
import { Button } from '../Button';
|
|
9
|
+
import { Heading } from '../Heading';
|
|
10
|
+
import { MessageContext } from '../../contexts/MessageContext';
|
|
11
|
+
import { useThemeValue } from '../../utils/useThemeValue';
|
|
12
|
+
import { useWizard } from './WizardContext';
|
|
13
|
+
|
|
14
|
+
// Header above the progress track. Hosts the close (X) button which
|
|
15
|
+
// invokes `cancel` from context.
|
|
16
|
+
export var WizardHeader = function WizardHeader(_ref) {
|
|
17
|
+
var _theme$wizard, _headerTheme$title, _headerTheme$close;
|
|
18
|
+
var title = _ref.title,
|
|
19
|
+
children = _ref.children,
|
|
20
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
21
|
+
var _useThemeValue = useThemeValue(),
|
|
22
|
+
theme = _useThemeValue.theme;
|
|
23
|
+
var _React$useContext = React.useContext(MessageContext),
|
|
24
|
+
format = _React$useContext.format;
|
|
25
|
+
var _useWizard = useWizard(),
|
|
26
|
+
cancel = _useWizard.cancel,
|
|
27
|
+
messages = _useWizard.messages;
|
|
28
|
+
var headerTheme = (_theme$wizard = theme.wizard) == null ? void 0 : _theme$wizard.header;
|
|
29
|
+
|
|
30
|
+
// Custom children override the themed title.
|
|
31
|
+
var content = children !== undefined ? children : title && /*#__PURE__*/React.createElement(Heading, {
|
|
32
|
+
level: 1,
|
|
33
|
+
size: headerTheme == null || (_headerTheme$title = headerTheme.title) == null ? void 0 : _headerTheme$title.size,
|
|
34
|
+
margin: "none"
|
|
35
|
+
}, title);
|
|
36
|
+
var CloseIcon = headerTheme == null || (_headerTheme$close = headerTheme.close) == null ? void 0 : _headerTheme$close.icon;
|
|
37
|
+
var closeLabel = format({
|
|
38
|
+
id: 'wizard.close',
|
|
39
|
+
messages: messages
|
|
40
|
+
});
|
|
41
|
+
return /*#__PURE__*/React.createElement(Box, _extends({
|
|
42
|
+
pad: headerTheme == null ? void 0 : headerTheme.pad,
|
|
43
|
+
background: headerTheme == null ? void 0 : headerTheme.background,
|
|
44
|
+
direction: "row",
|
|
45
|
+
align: "center",
|
|
46
|
+
justify: "between",
|
|
47
|
+
flex: false
|
|
48
|
+
}, rest), /*#__PURE__*/React.createElement(Box, {
|
|
49
|
+
direction: "row",
|
|
50
|
+
align: "center",
|
|
51
|
+
flex: true
|
|
52
|
+
}, content), /*#__PURE__*/React.createElement(Button, {
|
|
53
|
+
"aria-label": closeLabel,
|
|
54
|
+
icon: CloseIcon ? /*#__PURE__*/React.createElement(CloseIcon, {
|
|
55
|
+
"aria-hidden": "true"
|
|
56
|
+
}) : undefined,
|
|
57
|
+
onClick: cancel
|
|
58
|
+
}));
|
|
59
|
+
};
|
|
60
|
+
WizardHeader.displayName = 'WizardHeader';
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
var _excluded = ["aria-label", "showDescription"];
|
|
2
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { Box } from '../Box';
|
|
6
|
+
import { Stepper } from '../Stepper';
|
|
7
|
+
import { useThemeValue } from '../../utils/useThemeValue';
|
|
8
|
+
import { MessageContext } from '../../contexts/MessageContext';
|
|
9
|
+
import { useWizard } from './WizardContext';
|
|
10
|
+
|
|
11
|
+
// WizardProgress delegates step rendering to <Stepper>. Descriptions
|
|
12
|
+
// are hidden by default (WizardStepHeader shows them in the body).
|
|
13
|
+
export var WizardProgress = function WizardProgress(_ref) {
|
|
14
|
+
var _theme$wizard, _theme$wizard2;
|
|
15
|
+
var ariaLabelProp = _ref['aria-label'],
|
|
16
|
+
_ref$showDescription = _ref.showDescription,
|
|
17
|
+
showDescription = _ref$showDescription === void 0 ? false : _ref$showDescription,
|
|
18
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
19
|
+
var _useThemeValue = useThemeValue(),
|
|
20
|
+
theme = _useThemeValue.theme;
|
|
21
|
+
var _React$useContext = React.useContext(MessageContext),
|
|
22
|
+
format = _React$useContext.format;
|
|
23
|
+
var _useWizard = useWizard(),
|
|
24
|
+
steps = _useWizard.steps,
|
|
25
|
+
currentStep = _useWizard.currentStep,
|
|
26
|
+
showProgress = _useWizard.showProgress,
|
|
27
|
+
stepStates = _useWizard.stepStates,
|
|
28
|
+
messages = _useWizard.messages;
|
|
29
|
+
|
|
30
|
+
// Opt-in: render nothing when `showProgress` is false.
|
|
31
|
+
if (!showProgress) return null;
|
|
32
|
+
var progressTheme = showProgress === 'vertical' ? (_theme$wizard = theme.wizard) == null || (_theme$wizard = _theme$wizard.progress) == null ? void 0 : _theme$wizard.vertical : (_theme$wizard2 = theme.wizard) == null || (_theme$wizard2 = _theme$wizard2.progress) == null ? void 0 : _theme$wizard2.horizontal;
|
|
33
|
+
|
|
34
|
+
// Map wizard steps (with optional children) into Stepper's step model.
|
|
35
|
+
var stepperSteps = steps.map(function (step) {
|
|
36
|
+
var mapped = {
|
|
37
|
+
id: step.id,
|
|
38
|
+
title: step.title,
|
|
39
|
+
description: step.description,
|
|
40
|
+
status: stepStates[step.id]
|
|
41
|
+
};
|
|
42
|
+
if (step.disabledReason) mapped.disabledReason = step.disabledReason;
|
|
43
|
+
if (step['aria-label']) mapped['aria-label'] = step['aria-label'];
|
|
44
|
+
if (step.children && step.children.length) {
|
|
45
|
+
mapped.children = step.children.map(function (child) {
|
|
46
|
+
return _extends({
|
|
47
|
+
id: child.id,
|
|
48
|
+
title: child.title,
|
|
49
|
+
description: child.description,
|
|
50
|
+
status: stepStates[child.id]
|
|
51
|
+
}, child.disabledReason ? {
|
|
52
|
+
disabledReason: child.disabledReason
|
|
53
|
+
} : {}, child['aria-label'] ? {
|
|
54
|
+
'aria-label': child['aria-label']
|
|
55
|
+
} : {});
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return mapped;
|
|
59
|
+
});
|
|
60
|
+
var ariaLabel = ariaLabelProp || format({
|
|
61
|
+
id: 'wizard.progress',
|
|
62
|
+
messages: messages
|
|
63
|
+
});
|
|
64
|
+
return /*#__PURE__*/React.createElement(Box, _extends({
|
|
65
|
+
pad: progressTheme == null ? void 0 : progressTheme.pad,
|
|
66
|
+
width: showProgress === 'vertical' ? progressTheme == null ? void 0 : progressTheme.width : undefined,
|
|
67
|
+
flex: false
|
|
68
|
+
// Vertical rail should hug its steps, not stretch to the body height.
|
|
69
|
+
,
|
|
70
|
+
alignSelf: showProgress === 'vertical' ? 'start' : undefined
|
|
71
|
+
}, rest), /*#__PURE__*/React.createElement(Stepper, {
|
|
72
|
+
steps: stepperSteps,
|
|
73
|
+
currentStep: currentStep,
|
|
74
|
+
direction: showProgress === 'vertical' ? 'vertical' : 'horizontal',
|
|
75
|
+
clickableSteps: false,
|
|
76
|
+
showDescription: showDescription,
|
|
77
|
+
"aria-label": ariaLabel
|
|
78
|
+
}));
|
|
79
|
+
};
|
|
80
|
+
WizardProgress.displayName = 'WizardProgress';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
function _objectDestructuringEmpty(t) { if (null == t) throw new TypeError("Cannot destructure " + t); }
|
|
2
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Box } from '../Box';
|
|
5
|
+
import { Heading } from '../Heading';
|
|
6
|
+
import { Paragraph } from '../Paragraph';
|
|
7
|
+
import { Text } from '../Text';
|
|
8
|
+
import { MessageContext } from '../../contexts/MessageContext';
|
|
9
|
+
import { useThemeValue } from '../../utils/useThemeValue';
|
|
10
|
+
import { useWizard } from './WizardContext';
|
|
11
|
+
import { StyledWizardFocusAnchor } from './StyledWizard';
|
|
12
|
+
|
|
13
|
+
// Renders the "Step X of Y" counter, title, and description. Wrapped in an
|
|
14
|
+
// `aria-live="polite"` focus anchor (located via `data-g-wizard-focus-anchor`)
|
|
15
|
+
// so Wizard can move focus here on step transitions for screen readers.
|
|
16
|
+
export var WizardStepHeader = function WizardStepHeader(_ref) {
|
|
17
|
+
var _theme$wizard, _theme$wizard2;
|
|
18
|
+
var rest = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
|
|
19
|
+
var _useThemeValue = useThemeValue(),
|
|
20
|
+
theme = _useThemeValue.theme;
|
|
21
|
+
var _React$useContext = React.useContext(MessageContext),
|
|
22
|
+
format = _React$useContext.format;
|
|
23
|
+
var _useWizard = useWizard(),
|
|
24
|
+
currentStepObj = _useWizard.currentStepObj,
|
|
25
|
+
currentStepIndex = _useWizard.currentStepIndex,
|
|
26
|
+
totalSteps = _useWizard.totalSteps,
|
|
27
|
+
messages = _useWizard.messages;
|
|
28
|
+
if (!currentStepObj) return null;
|
|
29
|
+
var stepHeaderTheme = (_theme$wizard = theme.wizard) == null ? void 0 : _theme$wizard.stepHeader;
|
|
30
|
+
var counterTheme = (_theme$wizard2 = theme.wizard) == null || (_theme$wizard2 = _theme$wizard2.stepHeader) == null ? void 0 : _theme$wizard2.counter;
|
|
31
|
+
var counterTemplate = format({
|
|
32
|
+
id: 'wizard.stepHeader.counter',
|
|
33
|
+
values: {
|
|
34
|
+
step: currentStepIndex + 1,
|
|
35
|
+
total: totalSteps
|
|
36
|
+
},
|
|
37
|
+
messages: messages
|
|
38
|
+
});
|
|
39
|
+
return /*#__PURE__*/React.createElement(StyledWizardFocusAnchor, {
|
|
40
|
+
"data-g-wizard-focus-anchor": true,
|
|
41
|
+
tabIndex: -1,
|
|
42
|
+
"aria-live": "polite"
|
|
43
|
+
}, /*#__PURE__*/React.createElement(Box, _extends({
|
|
44
|
+
pad: stepHeaderTheme == null ? void 0 : stepHeaderTheme.pad,
|
|
45
|
+
gap: stepHeaderTheme == null ? void 0 : stepHeaderTheme.gap,
|
|
46
|
+
flex: false
|
|
47
|
+
}, rest), /*#__PURE__*/React.createElement(Text, counterTheme, counterTemplate), /*#__PURE__*/React.createElement(Heading, _extends({
|
|
48
|
+
level: 2
|
|
49
|
+
}, stepHeaderTheme == null ? void 0 : stepHeaderTheme.title), currentStepObj.title), currentStepObj.description && /*#__PURE__*/React.createElement(Paragraph, stepHeaderTheme == null ? void 0 : stepHeaderTheme.description, currentStepObj.description)));
|
|
50
|
+
};
|
|
51
|
+
WizardStepHeader.displayName = 'WizardStepHeader';
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { BoxExtendedProps } from '../Box';
|
|
3
|
+
|
|
4
|
+
export type WizardShowProgress = 'horizontal' | 'vertical' | false;
|
|
5
|
+
|
|
6
|
+
export type WizardStepStatus = 'pending' | 'completed' | 'error' | 'disabled';
|
|
7
|
+
|
|
8
|
+
export type WizardTrigger =
|
|
9
|
+
| 'next'
|
|
10
|
+
| 'previous'
|
|
11
|
+
| 'goTo'
|
|
12
|
+
| 'skip'
|
|
13
|
+
| 'complete'
|
|
14
|
+
| 'cancel';
|
|
15
|
+
|
|
16
|
+
export type WizardPhase =
|
|
17
|
+
| 'requested'
|
|
18
|
+
| 'validating'
|
|
19
|
+
| 'validated'
|
|
20
|
+
| 'navigated'
|
|
21
|
+
| 'blocked'
|
|
22
|
+
| 'completed'
|
|
23
|
+
| 'cancelled';
|
|
24
|
+
|
|
25
|
+
export interface WizardStep<TValue = Record<string, any>> {
|
|
26
|
+
id: string;
|
|
27
|
+
title: string;
|
|
28
|
+
description?: React.ReactNode;
|
|
29
|
+
render?: (
|
|
30
|
+
step: WizardStep<TValue>,
|
|
31
|
+
api: WizardContextValue<TValue>,
|
|
32
|
+
) => React.ReactNode;
|
|
33
|
+
validate?: (
|
|
34
|
+
value: TValue,
|
|
35
|
+
) =>
|
|
36
|
+
| boolean
|
|
37
|
+
| string
|
|
38
|
+
| void
|
|
39
|
+
| { error?: string }
|
|
40
|
+
| Promise<boolean | string | void | { error?: string }>;
|
|
41
|
+
nextStep?: (value: TValue) => string | undefined | null;
|
|
42
|
+
skippable?: boolean;
|
|
43
|
+
disabled?: boolean;
|
|
44
|
+
disabledReason?: string;
|
|
45
|
+
children?: WizardStep<TValue>[];
|
|
46
|
+
'aria-label'?: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Discriminated union for onStepChange events. Consumers can narrow on
|
|
50
|
+
// `trigger` + `phase` to reason about event flow without inspecting DOM.
|
|
51
|
+
export interface NavigationStepChangeEvent {
|
|
52
|
+
trigger: Exclude<WizardTrigger, 'cancel'>;
|
|
53
|
+
phase: Exclude<WizardPhase, 'cancelled'>;
|
|
54
|
+
from?: string;
|
|
55
|
+
to?: string;
|
|
56
|
+
error?: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface TerminalStepChangeEvent {
|
|
60
|
+
trigger: 'cancel' | 'complete';
|
|
61
|
+
phase: 'cancelled' | 'completed';
|
|
62
|
+
from?: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export type StepChangeEvent =
|
|
66
|
+
| NavigationStepChangeEvent
|
|
67
|
+
| TerminalStepChangeEvent;
|
|
68
|
+
|
|
69
|
+
export interface WizardMessages {
|
|
70
|
+
previous?: string;
|
|
71
|
+
next?: string;
|
|
72
|
+
skip?: string;
|
|
73
|
+
cancel?: string;
|
|
74
|
+
close?: string;
|
|
75
|
+
complete?: string;
|
|
76
|
+
counter?: string;
|
|
77
|
+
progress?: string;
|
|
78
|
+
validationError?: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface WizardProps<TValue = Record<string, any>> {
|
|
82
|
+
steps: WizardStep<TValue>[];
|
|
83
|
+
currentStep?: string;
|
|
84
|
+
defaultStep?: string;
|
|
85
|
+
showProgress?: WizardShowProgress;
|
|
86
|
+
onStepChange?: (event: StepChangeEvent) => void;
|
|
87
|
+
onComplete?: (event: { value: TValue; completedSteps: string[] }) => void;
|
|
88
|
+
onCancel?: (event: { value: TValue; reason: 'user' }) => void;
|
|
89
|
+
renderStep?: (
|
|
90
|
+
step: WizardStep<TValue>,
|
|
91
|
+
api: WizardContextValue<TValue>,
|
|
92
|
+
) => React.ReactNode;
|
|
93
|
+
title?: string;
|
|
94
|
+
footer?: React.ReactNode;
|
|
95
|
+
scrollToTop?: boolean;
|
|
96
|
+
value?: TValue;
|
|
97
|
+
defaultValue?: TValue;
|
|
98
|
+
onChange?: (event: { value: TValue }) => void;
|
|
99
|
+
id?: string;
|
|
100
|
+
'aria-label'?: string;
|
|
101
|
+
messages?: WizardMessages;
|
|
102
|
+
children?: React.ReactNode;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
declare const Wizard: <TValue = Record<string, any>>(
|
|
106
|
+
props: WizardProps<TValue> & { ref?: React.Ref<HTMLDivElement> },
|
|
107
|
+
) => React.ReactElement;
|
|
108
|
+
|
|
109
|
+
export { Wizard };
|
|
110
|
+
|
|
111
|
+
export interface WizardContextValue<TValue = Record<string, any>> {
|
|
112
|
+
steps: WizardStep<TValue>[];
|
|
113
|
+
currentStep: string;
|
|
114
|
+
currentStepIndex: number;
|
|
115
|
+
currentStepObj?: WizardStep<TValue>;
|
|
116
|
+
totalSteps: number;
|
|
117
|
+
stepStates: Record<string, WizardStepStatus>;
|
|
118
|
+
formValue: TValue;
|
|
119
|
+
setFormValue: (next: TValue | ((prev: TValue) => TValue)) => void;
|
|
120
|
+
validationError?: string;
|
|
121
|
+
isValidating: boolean;
|
|
122
|
+
isBlocked: boolean;
|
|
123
|
+
isCompleted: boolean;
|
|
124
|
+
canGoNext: boolean;
|
|
125
|
+
next: () => void;
|
|
126
|
+
previous: () => void;
|
|
127
|
+
goTo: (stepId: string) => void;
|
|
128
|
+
skip: () => void;
|
|
129
|
+
complete: () => void;
|
|
130
|
+
cancel: () => void;
|
|
131
|
+
showProgress: WizardShowProgress;
|
|
132
|
+
renderStep?: (
|
|
133
|
+
step: WizardStep<TValue>,
|
|
134
|
+
api: WizardContextValue<TValue>,
|
|
135
|
+
) => React.ReactNode;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export const WizardContext: React.Context<WizardContextValue>;
|
|
139
|
+
|
|
140
|
+
export function useWizard<
|
|
141
|
+
TValue = Record<string, any>,
|
|
142
|
+
>(): WizardContextValue<TValue>;
|
|
143
|
+
|
|
144
|
+
export interface WizardHeaderProps extends BoxExtendedProps {
|
|
145
|
+
title?: string;
|
|
146
|
+
children?: React.ReactNode;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export const WizardHeader: React.FC<WizardHeaderProps>;
|
|
150
|
+
|
|
151
|
+
export interface WizardProgressProps extends BoxExtendedProps {
|
|
152
|
+
'aria-label'?: string;
|
|
153
|
+
showDescription?: boolean;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export const WizardProgress: React.FC<WizardProgressProps>;
|
|
157
|
+
|
|
158
|
+
export interface WizardStepHeaderProps extends BoxExtendedProps {}
|
|
159
|
+
|
|
160
|
+
export const WizardStepHeader: React.FC<WizardStepHeaderProps>;
|
|
161
|
+
|
|
162
|
+
export interface WizardContentProps<TValue = Record<string, any>>
|
|
163
|
+
extends BoxExtendedProps {}
|
|
164
|
+
|
|
165
|
+
export const WizardContent: <TValue = Record<string, any>>(
|
|
166
|
+
props: WizardContentProps<TValue>,
|
|
167
|
+
) => React.ReactElement;
|
|
168
|
+
|
|
169
|
+
export interface WizardFooterProps extends BoxExtendedProps {}
|
|
170
|
+
|
|
171
|
+
export const WizardFooter: React.FC<WizardFooterProps>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { Wizard } from './Wizard';
|
|
2
|
+
export { WizardContext, useWizard } from './WizardContext';
|
|
3
|
+
export { WizardHeader } from './WizardHeader';
|
|
4
|
+
export { WizardProgress } from './WizardProgress';
|
|
5
|
+
export { WizardStepHeader } from './WizardStepHeader';
|
|
6
|
+
export { WizardContent } from './WizardContent';
|
|
7
|
+
export { WizardFooter } from './WizardFooter';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
var propType = {};
|
|
4
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5
|
+
var stepShape = {
|
|
6
|
+
id: PropTypes.string.isRequired,
|
|
7
|
+
title: PropTypes.string.isRequired,
|
|
8
|
+
description: PropTypes.node,
|
|
9
|
+
render: PropTypes.func,
|
|
10
|
+
validate: PropTypes.func,
|
|
11
|
+
nextStep: PropTypes.func,
|
|
12
|
+
skippable: PropTypes.bool,
|
|
13
|
+
disabled: PropTypes.bool,
|
|
14
|
+
disabledReason: PropTypes.string,
|
|
15
|
+
'aria-label': PropTypes.string
|
|
16
|
+
};
|
|
17
|
+
var nestedStepShape = _extends({}, stepShape, {
|
|
18
|
+
children: PropTypes.array
|
|
19
|
+
});
|
|
20
|
+
propType = {
|
|
21
|
+
steps: PropTypes.arrayOf(PropTypes.shape(nestedStepShape)).isRequired,
|
|
22
|
+
currentStep: PropTypes.string,
|
|
23
|
+
defaultStep: PropTypes.string,
|
|
24
|
+
showProgress: PropTypes.oneOfType([PropTypes.oneOf(['horizontal', 'vertical']), PropTypes.bool]),
|
|
25
|
+
onStepChange: PropTypes.func,
|
|
26
|
+
onComplete: PropTypes.func,
|
|
27
|
+
onCancel: PropTypes.func,
|
|
28
|
+
renderStep: PropTypes.func,
|
|
29
|
+
title: PropTypes.string,
|
|
30
|
+
footer: PropTypes.node,
|
|
31
|
+
scrollToTop: PropTypes.bool,
|
|
32
|
+
value: PropTypes.object,
|
|
33
|
+
defaultValue: PropTypes.object,
|
|
34
|
+
onChange: PropTypes.func,
|
|
35
|
+
id: PropTypes.string,
|
|
36
|
+
'aria-label': PropTypes.string,
|
|
37
|
+
children: PropTypes.node,
|
|
38
|
+
messages: PropTypes.shape({
|
|
39
|
+
previous: PropTypes.string,
|
|
40
|
+
next: PropTypes.string,
|
|
41
|
+
skip: PropTypes.string,
|
|
42
|
+
cancel: PropTypes.string,
|
|
43
|
+
close: PropTypes.string,
|
|
44
|
+
complete: PropTypes.string,
|
|
45
|
+
counter: PropTypes.string,
|
|
46
|
+
progress: PropTypes.string,
|
|
47
|
+
validationError: PropTypes.string
|
|
48
|
+
})
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export var WizardPropTypes = propType;
|