grommet 2.56.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/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/Stepper/StepConnector.js +19 -49
- package/components/Stepper/Stepper.js +5 -11
- package/components/Stepper/StepperStep.js +14 -4
- package/components/Stepper/StyledStepper.js +59 -21
- package/components/TimeInput/TimeInput.js +50 -47
- package/components/TimeInput/TimeInputPopup.js +172 -76
- package/components/TimeInput/index.d.ts +3 -0
- package/components/TimeInput/propTypes.js +4 -0
- package/components/TimeInput/useSectionedTimeField.js +33 -34
- package/components/TimeInput/utils.js +31 -26
- 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 +4 -0
- package/components/index.js +12 -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/Stepper/StepConnector.js +18 -48
- package/es6/components/Stepper/Stepper.js +5 -10
- package/es6/components/Stepper/StepperStep.js +15 -4
- package/es6/components/Stepper/StyledStepper.js +57 -21
- package/es6/components/TimeInput/TimeInput.js +50 -46
- package/es6/components/TimeInput/TimeInputPopup.js +172 -76
- package/es6/components/TimeInput/index.d.ts +3 -0
- package/es6/components/TimeInput/propTypes.js +3 -0
- package/es6/components/TimeInput/useSectionedTimeField.js +34 -35
- package/es6/components/TimeInput/utils.js +25 -21
- 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 +4 -0
- package/es6/components/index.js +4 -0
- package/es6/index.d.ts +4 -0
- package/es6/languages/default.json +28 -0
- package/es6/themes/base.d.ts +115 -0
- package/es6/themes/base.js +158 -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 +4 -0
- package/languages/default.json +28 -0
- package/package.json +35 -31
- package/themes/base.d.ts +115 -0
- package/themes/base.js +158 -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
|
@@ -0,0 +1,67 @@
|
|
|
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 React, { useState } from 'react';
|
|
3
|
+
import { Box, Notification, Paragraph, TextInput } from 'grommet';
|
|
4
|
+
import { Wizard } from '../Wizard';
|
|
5
|
+
var steps = [{
|
|
6
|
+
id: 'account',
|
|
7
|
+
title: 'Account',
|
|
8
|
+
description: 'Tell us about your account.',
|
|
9
|
+
render: function render(step, api) {
|
|
10
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
11
|
+
gap: "small"
|
|
12
|
+
}, /*#__PURE__*/React.createElement(Paragraph, null, "Enter an email to continue."), /*#__PURE__*/React.createElement(TextInput, {
|
|
13
|
+
placeholder: "you@example.com",
|
|
14
|
+
value: api.formValue.email || '',
|
|
15
|
+
onChange: function onChange(event) {
|
|
16
|
+
return api.setFormValue(_extends({}, api.formValue, {
|
|
17
|
+
email: event.target.value
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
}, {
|
|
23
|
+
id: 'profile',
|
|
24
|
+
title: 'Profile',
|
|
25
|
+
description: 'Fill in your profile details.',
|
|
26
|
+
render: function render() {
|
|
27
|
+
return /*#__PURE__*/React.createElement(Paragraph, null, "Placeholder profile form for the second step.");
|
|
28
|
+
}
|
|
29
|
+
}, {
|
|
30
|
+
id: 'review',
|
|
31
|
+
title: 'Review',
|
|
32
|
+
description: 'Review and finish.',
|
|
33
|
+
render: function render(step, api) {
|
|
34
|
+
return /*#__PURE__*/React.createElement(Paragraph, null, "Ready to submit for ", api.formValue.email || 'unknown user', ".");
|
|
35
|
+
}
|
|
36
|
+
}];
|
|
37
|
+
var BasicLinear = function BasicLinear() {
|
|
38
|
+
var _useState = useState(false),
|
|
39
|
+
complete = _useState[0],
|
|
40
|
+
setComplete = _useState[1];
|
|
41
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
42
|
+
fill: true
|
|
43
|
+
}, /*#__PURE__*/React.createElement(Wizard, {
|
|
44
|
+
"aria-label": "Onboarding",
|
|
45
|
+
title: "Set up your account",
|
|
46
|
+
steps: steps,
|
|
47
|
+
onComplete: function onComplete() {
|
|
48
|
+
return setComplete(true);
|
|
49
|
+
}
|
|
50
|
+
}), complete && /*#__PURE__*/React.createElement(Notification, {
|
|
51
|
+
toast: {
|
|
52
|
+
position: 'top'
|
|
53
|
+
},
|
|
54
|
+
status: "normal",
|
|
55
|
+
title: "Wizard complete",
|
|
56
|
+
onClose: function onClose() {
|
|
57
|
+
return setComplete(false);
|
|
58
|
+
}
|
|
59
|
+
}));
|
|
60
|
+
};
|
|
61
|
+
BasicLinear.args = {
|
|
62
|
+
full: true
|
|
63
|
+
};
|
|
64
|
+
export default {
|
|
65
|
+
title: 'Layout/Wizard/Basic Linear'
|
|
66
|
+
};
|
|
67
|
+
export { BasicLinear };
|
|
@@ -0,0 +1,93 @@
|
|
|
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 React, { useMemo, useState } from 'react';
|
|
3
|
+
import { Box, CheckBox, Notification, Paragraph } from 'grommet';
|
|
4
|
+
import { Wizard } from '../Wizard';
|
|
5
|
+
|
|
6
|
+
// Branching wizard: the Review step is added only when the user checks
|
|
7
|
+
// "Include a manual review step"; the stepper updates live.
|
|
8
|
+
var planStep = {
|
|
9
|
+
id: 'plan',
|
|
10
|
+
title: 'Plan',
|
|
11
|
+
description: 'Include optional a manual review.',
|
|
12
|
+
render: function render(step, api) {
|
|
13
|
+
return /*#__PURE__*/React.createElement(CheckBox, {
|
|
14
|
+
label: "Include a manual review step",
|
|
15
|
+
checked: !!api.formValue.review,
|
|
16
|
+
onChange: function onChange(event) {
|
|
17
|
+
return api.setFormValue(_extends({}, api.formValue, {
|
|
18
|
+
review: event.target.checked
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
var reviewStep = {
|
|
25
|
+
id: 'review',
|
|
26
|
+
title: 'Review',
|
|
27
|
+
description: 'Someone will review your changes.',
|
|
28
|
+
render: function render() {
|
|
29
|
+
return /*#__PURE__*/React.createElement(Paragraph, null, "Reviewer will be assigned.");
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
var deployStep = {
|
|
33
|
+
id: 'deploy',
|
|
34
|
+
title: 'Deploy',
|
|
35
|
+
description: 'Deploy your changes.',
|
|
36
|
+
render: function render() {
|
|
37
|
+
return /*#__PURE__*/React.createElement(Paragraph, null, "Ready to deploy.");
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
var Branching = function Branching() {
|
|
41
|
+
var _useState = useState({
|
|
42
|
+
review: false
|
|
43
|
+
}),
|
|
44
|
+
value = _useState[0],
|
|
45
|
+
setValue = _useState[1];
|
|
46
|
+
var _useState2 = useState(null),
|
|
47
|
+
result = _useState2[0],
|
|
48
|
+
setResult = _useState2[1];
|
|
49
|
+
var steps = useMemo(function () {
|
|
50
|
+
return value.review ? [planStep, reviewStep, deployStep] : [planStep, deployStep];
|
|
51
|
+
}, [value.review]);
|
|
52
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
53
|
+
fill: true
|
|
54
|
+
}, /*#__PURE__*/React.createElement(Wizard, {
|
|
55
|
+
"aria-label": "Deployment",
|
|
56
|
+
title: "Deploy an application",
|
|
57
|
+
showProgress: "horizontal",
|
|
58
|
+
steps: steps,
|
|
59
|
+
value: value,
|
|
60
|
+
onChange: function onChange(_ref) {
|
|
61
|
+
var nextValue = _ref.value;
|
|
62
|
+
return setValue(nextValue);
|
|
63
|
+
},
|
|
64
|
+
messages: {
|
|
65
|
+
next: 'Continue',
|
|
66
|
+
complete: 'Deploy'
|
|
67
|
+
},
|
|
68
|
+
onComplete: function onComplete(_ref2) {
|
|
69
|
+
var nextValue = _ref2.value;
|
|
70
|
+
return setResult({
|
|
71
|
+
status: 'complete',
|
|
72
|
+
value: nextValue
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}), result && /*#__PURE__*/React.createElement(Notification, {
|
|
76
|
+
toast: {
|
|
77
|
+
position: 'top'
|
|
78
|
+
},
|
|
79
|
+
status: "normal",
|
|
80
|
+
title: "Wizard complete",
|
|
81
|
+
message: result.value && Object.keys(result.value).length > 0 ? "Completed: " + JSON.stringify(result.value) : undefined,
|
|
82
|
+
onClose: function onClose() {
|
|
83
|
+
return setResult(null);
|
|
84
|
+
}
|
|
85
|
+
}));
|
|
86
|
+
};
|
|
87
|
+
Branching.args = {
|
|
88
|
+
full: true
|
|
89
|
+
};
|
|
90
|
+
export default {
|
|
91
|
+
title: 'Layout/Wizard/Branching'
|
|
92
|
+
};
|
|
93
|
+
export { Branching };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Box, Heading, Notification, Paragraph } from 'grommet';
|
|
3
|
+
import { Wizard } from '../Wizard';
|
|
4
|
+
import { WizardHeader } from '../WizardHeader';
|
|
5
|
+
import { WizardProgress } from '../WizardProgress';
|
|
6
|
+
import { WizardContent } from '../WizardContent';
|
|
7
|
+
import { WizardFooter } from '../WizardFooter';
|
|
8
|
+
|
|
9
|
+
// Composable wizard: consumers assemble the layout from sub-components.
|
|
10
|
+
// Passing `children` bypasses the default layout — each sub-component
|
|
11
|
+
// reads from WizardContext, so no props need to be threaded through.
|
|
12
|
+
// Insert <WizardStepHeader /> between progress and content to show the
|
|
13
|
+
// current step's title and description.
|
|
14
|
+
var steps = [{
|
|
15
|
+
id: 'account',
|
|
16
|
+
title: 'Account',
|
|
17
|
+
description: 'Tell us about your account.',
|
|
18
|
+
render: function render() {
|
|
19
|
+
return /*#__PURE__*/React.createElement(Paragraph, null, "Placeholder account form.");
|
|
20
|
+
}
|
|
21
|
+
}, {
|
|
22
|
+
id: 'profile',
|
|
23
|
+
title: 'Profile',
|
|
24
|
+
description: 'Fill in your profile details.',
|
|
25
|
+
render: function render() {
|
|
26
|
+
return /*#__PURE__*/React.createElement(Paragraph, null, "Placeholder profile form.");
|
|
27
|
+
}
|
|
28
|
+
}, {
|
|
29
|
+
id: 'review',
|
|
30
|
+
title: 'Review',
|
|
31
|
+
description: 'Review and finish.',
|
|
32
|
+
render: function render() {
|
|
33
|
+
return /*#__PURE__*/React.createElement(Paragraph, null, "Ready to submit.");
|
|
34
|
+
}
|
|
35
|
+
}];
|
|
36
|
+
var Composable = function Composable() {
|
|
37
|
+
var _useState = useState(false),
|
|
38
|
+
complete = _useState[0],
|
|
39
|
+
setComplete = _useState[1];
|
|
40
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
41
|
+
fill: true
|
|
42
|
+
}, /*#__PURE__*/React.createElement(Wizard, {
|
|
43
|
+
"aria-label": "Composable wizard",
|
|
44
|
+
showProgress: "horizontal",
|
|
45
|
+
steps: steps,
|
|
46
|
+
onComplete: function onComplete() {
|
|
47
|
+
return setComplete(true);
|
|
48
|
+
}
|
|
49
|
+
}, /*#__PURE__*/React.createElement(WizardHeader, null, /*#__PURE__*/React.createElement(Heading, {
|
|
50
|
+
level: 2,
|
|
51
|
+
size: "small",
|
|
52
|
+
margin: "none"
|
|
53
|
+
}, "Set up your account")), /*#__PURE__*/React.createElement(WizardProgress, null), /*#__PURE__*/React.createElement(WizardContent, {
|
|
54
|
+
background: "light-3"
|
|
55
|
+
}), /*#__PURE__*/React.createElement(WizardFooter, null)), complete && /*#__PURE__*/React.createElement(Notification, {
|
|
56
|
+
toast: {
|
|
57
|
+
position: 'top'
|
|
58
|
+
},
|
|
59
|
+
status: "normal",
|
|
60
|
+
title: "Wizard complete",
|
|
61
|
+
onClose: function onClose() {
|
|
62
|
+
return setComplete(false);
|
|
63
|
+
}
|
|
64
|
+
}));
|
|
65
|
+
};
|
|
66
|
+
Composable.args = {
|
|
67
|
+
full: true
|
|
68
|
+
};
|
|
69
|
+
export default {
|
|
70
|
+
title: 'Layout/Wizard/Composable'
|
|
71
|
+
};
|
|
72
|
+
export { Composable };
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Box, Button, Heading, Layer, Notification, Paragraph } from 'grommet';
|
|
3
|
+
import { Wizard } from '../Wizard';
|
|
4
|
+
|
|
5
|
+
// Controlled Wizard: parent owns currentStep and reacts to onStepChange.
|
|
6
|
+
var steps = [{
|
|
7
|
+
id: 'one',
|
|
8
|
+
title: 'One',
|
|
9
|
+
render: function render() {
|
|
10
|
+
return /*#__PURE__*/React.createElement(Paragraph, null, "Step one.");
|
|
11
|
+
}
|
|
12
|
+
}, {
|
|
13
|
+
id: 'two',
|
|
14
|
+
title: 'Two',
|
|
15
|
+
skippable: true,
|
|
16
|
+
render: function render() {
|
|
17
|
+
return /*#__PURE__*/React.createElement(Paragraph, null, "Step two.");
|
|
18
|
+
}
|
|
19
|
+
}, {
|
|
20
|
+
id: 'three',
|
|
21
|
+
title: 'Three',
|
|
22
|
+
render: function render() {
|
|
23
|
+
return /*#__PURE__*/React.createElement(Paragraph, null, "Step three.");
|
|
24
|
+
}
|
|
25
|
+
}];
|
|
26
|
+
var Controlled = function Controlled() {
|
|
27
|
+
var _useState = useState('one'),
|
|
28
|
+
currentStep = _useState[0],
|
|
29
|
+
setCurrentStep = _useState[1];
|
|
30
|
+
var _useState2 = useState(null),
|
|
31
|
+
result = _useState2[0],
|
|
32
|
+
setResult = _useState2[1];
|
|
33
|
+
var _useState3 = useState(0),
|
|
34
|
+
resetKey = _useState3[0],
|
|
35
|
+
setResetKey = _useState3[1];
|
|
36
|
+
var _useState4 = useState(false),
|
|
37
|
+
confirmCancel = _useState4[0],
|
|
38
|
+
setConfirmCancel = _useState4[1];
|
|
39
|
+
var _useState5 = useState(true),
|
|
40
|
+
wizardOpen = _useState5[0],
|
|
41
|
+
setWizardOpen = _useState5[1];
|
|
42
|
+
var handleCancel = function handleCancel() {
|
|
43
|
+
setConfirmCancel(true);
|
|
44
|
+
};
|
|
45
|
+
var confirmCancelYes = function confirmCancelYes() {
|
|
46
|
+
setConfirmCancel(false);
|
|
47
|
+
setResult(null);
|
|
48
|
+
setCurrentStep('one');
|
|
49
|
+
setResetKey(function (key) {
|
|
50
|
+
return key + 1;
|
|
51
|
+
});
|
|
52
|
+
setWizardOpen(false);
|
|
53
|
+
};
|
|
54
|
+
var confirmCancelNo = function confirmCancelNo() {
|
|
55
|
+
setConfirmCancel(false);
|
|
56
|
+
};
|
|
57
|
+
var reopenWizard = function reopenWizard() {
|
|
58
|
+
setWizardOpen(true);
|
|
59
|
+
};
|
|
60
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
61
|
+
fill: true
|
|
62
|
+
}, wizardOpen ? /*#__PURE__*/React.createElement(Wizard, {
|
|
63
|
+
key: resetKey,
|
|
64
|
+
"aria-label": "Controlled wizard",
|
|
65
|
+
title: "Configure workspace",
|
|
66
|
+
showProgress: "horizontal",
|
|
67
|
+
steps: steps,
|
|
68
|
+
currentStep: currentStep,
|
|
69
|
+
onStepChange: function onStepChange(event) {
|
|
70
|
+
if (event.phase === 'navigated' && event.to) {
|
|
71
|
+
setCurrentStep(event.to);
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
onComplete: function onComplete(_ref) {
|
|
75
|
+
var value = _ref.value;
|
|
76
|
+
return setResult({
|
|
77
|
+
status: 'complete',
|
|
78
|
+
value: value
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
onCancel: handleCancel
|
|
82
|
+
}) : /*#__PURE__*/React.createElement(Box, {
|
|
83
|
+
pad: "medium",
|
|
84
|
+
align: "start"
|
|
85
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
86
|
+
primary: true,
|
|
87
|
+
label: "Reopen wizard",
|
|
88
|
+
onClick: reopenWizard
|
|
89
|
+
})), confirmCancel && /*#__PURE__*/React.createElement(Layer, {
|
|
90
|
+
modal: true,
|
|
91
|
+
position: "center",
|
|
92
|
+
onEsc: confirmCancelNo,
|
|
93
|
+
onClickOutside: confirmCancelNo
|
|
94
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
95
|
+
pad: "medium",
|
|
96
|
+
gap: "medium",
|
|
97
|
+
width: "medium"
|
|
98
|
+
}, /*#__PURE__*/React.createElement(Heading, {
|
|
99
|
+
level: 3,
|
|
100
|
+
margin: "none"
|
|
101
|
+
}, "Cancel wizard?"), /*#__PURE__*/React.createElement(Paragraph, {
|
|
102
|
+
margin: "none"
|
|
103
|
+
}, "Are you sure you want to cancel? Your progress will be lost."), /*#__PURE__*/React.createElement(Box, {
|
|
104
|
+
direction: "row",
|
|
105
|
+
justify: "end",
|
|
106
|
+
gap: "small"
|
|
107
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
108
|
+
label: "Keep editing",
|
|
109
|
+
onClick: confirmCancelNo
|
|
110
|
+
}), /*#__PURE__*/React.createElement(Button, {
|
|
111
|
+
label: "Yes, cancel",
|
|
112
|
+
primary: true,
|
|
113
|
+
color: "status-critical",
|
|
114
|
+
onClick: confirmCancelYes
|
|
115
|
+
})))), result && /*#__PURE__*/React.createElement(Notification, {
|
|
116
|
+
toast: {
|
|
117
|
+
position: 'top'
|
|
118
|
+
},
|
|
119
|
+
status: "normal",
|
|
120
|
+
title: "Wizard complete",
|
|
121
|
+
message: result.value && Object.keys(result.value).length > 0 ? "Completed: " + JSON.stringify(result.value) : undefined,
|
|
122
|
+
onClose: function onClose() {
|
|
123
|
+
return setResult(null);
|
|
124
|
+
}
|
|
125
|
+
}));
|
|
126
|
+
};
|
|
127
|
+
Controlled.args = {
|
|
128
|
+
full: true
|
|
129
|
+
};
|
|
130
|
+
export default {
|
|
131
|
+
title: 'Layout/Wizard/Controlled'
|
|
132
|
+
};
|
|
133
|
+
export { Controlled };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Box, FormField, Heading, Notification, Paragraph, TextArea, TextInput } from 'grommet';
|
|
3
|
+
import { Wizard } from '../Wizard';
|
|
4
|
+
|
|
5
|
+
// Long-content step demonstrating that the wizard header, stepper, and
|
|
6
|
+
// footer remain in place while the content column scrolls internally.
|
|
7
|
+
// Uses form fields plus a big block of prose so vertical space is
|
|
8
|
+
// clearly exceeded on typical viewports.
|
|
9
|
+
var LongStepBody = function LongStepBody(_ref) {
|
|
10
|
+
var heading = _ref.heading,
|
|
11
|
+
_ref$count = _ref.count,
|
|
12
|
+
count = _ref$count === void 0 ? 40 : _ref$count;
|
|
13
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
14
|
+
gap: "medium"
|
|
15
|
+
}, /*#__PURE__*/React.createElement(Heading, {
|
|
16
|
+
level: 3,
|
|
17
|
+
margin: {
|
|
18
|
+
vertical: 'none'
|
|
19
|
+
}
|
|
20
|
+
}, heading), /*#__PURE__*/React.createElement(Paragraph, {
|
|
21
|
+
fill: true
|
|
22
|
+
}, "Scroll this content column. The wizard header at the top and the footer at the bottom stay pinned \u2014 only the middle scrolls."), /*#__PURE__*/React.createElement(FormField, {
|
|
23
|
+
label: "Name",
|
|
24
|
+
htmlFor: "long-content-name"
|
|
25
|
+
}, /*#__PURE__*/React.createElement(TextInput, {
|
|
26
|
+
id: "long-content-name",
|
|
27
|
+
placeholder: "Your name"
|
|
28
|
+
})), /*#__PURE__*/React.createElement(FormField, {
|
|
29
|
+
label: "Notes",
|
|
30
|
+
htmlFor: "long-content-notes"
|
|
31
|
+
}, /*#__PURE__*/React.createElement(TextArea, {
|
|
32
|
+
id: "long-content-notes",
|
|
33
|
+
rows: 4,
|
|
34
|
+
placeholder: "Notes\u2026"
|
|
35
|
+
})), Array.from({
|
|
36
|
+
length: count
|
|
37
|
+
}).map(function (_, index) {
|
|
38
|
+
return (
|
|
39
|
+
/*#__PURE__*/
|
|
40
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
41
|
+
React.createElement(Paragraph, {
|
|
42
|
+
key: index,
|
|
43
|
+
fill: true
|
|
44
|
+
}, "Filler paragraph " + (index + 1) + ". This wizard example intentionally\n renders a lot of content so the scroll behavior is visible in\n Storybook. Long-form documentation, review screens, and\n confirmation lists commonly exceed the viewport height and\n need the middle column to scroll while the primary\n navigation stays visible.")
|
|
45
|
+
);
|
|
46
|
+
}));
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// Step data intentionally omits `description` so the stepper shows
|
|
50
|
+
// only the step titles; the descriptive text is rendered instead as
|
|
51
|
+
// the content heading inside the white card via LongStepBody.
|
|
52
|
+
var steps = [{
|
|
53
|
+
id: 'details',
|
|
54
|
+
title: 'Details',
|
|
55
|
+
render: function render() {
|
|
56
|
+
return /*#__PURE__*/React.createElement(LongStepBody, {
|
|
57
|
+
heading: "Enter details for the new resource"
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}, {
|
|
61
|
+
id: 'configure',
|
|
62
|
+
title: 'Configure',
|
|
63
|
+
render: function render() {
|
|
64
|
+
return /*#__PURE__*/React.createElement(LongStepBody, {
|
|
65
|
+
heading: "Configure options for this resource",
|
|
66
|
+
count: 30
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}, {
|
|
70
|
+
id: 'review',
|
|
71
|
+
title: 'Review',
|
|
72
|
+
render: function render() {
|
|
73
|
+
return /*#__PURE__*/React.createElement(LongStepBody, {
|
|
74
|
+
heading: "Review and finish",
|
|
75
|
+
count: 60
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}];
|
|
79
|
+
var LongContent = function LongContent() {
|
|
80
|
+
var _useState = useState(null),
|
|
81
|
+
result = _useState[0],
|
|
82
|
+
setResult = _useState[1];
|
|
83
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
84
|
+
fill: true
|
|
85
|
+
}, /*#__PURE__*/React.createElement(Wizard, {
|
|
86
|
+
"aria-label": "Long content wizard",
|
|
87
|
+
title: "Create resource",
|
|
88
|
+
showProgress: "horizontal",
|
|
89
|
+
steps: steps,
|
|
90
|
+
onComplete: function onComplete(_ref2) {
|
|
91
|
+
var value = _ref2.value;
|
|
92
|
+
return setResult({
|
|
93
|
+
status: 'complete',
|
|
94
|
+
value: value
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}), result && /*#__PURE__*/React.createElement(Notification, {
|
|
98
|
+
toast: {
|
|
99
|
+
position: 'top'
|
|
100
|
+
},
|
|
101
|
+
status: "normal",
|
|
102
|
+
title: "Wizard complete",
|
|
103
|
+
message: result.value && Object.keys(result.value).length > 0 ? "Completed: " + JSON.stringify(result.value) : undefined,
|
|
104
|
+
onClose: function onClose() {
|
|
105
|
+
return setResult(null);
|
|
106
|
+
}
|
|
107
|
+
}));
|
|
108
|
+
};
|
|
109
|
+
LongContent.args = {
|
|
110
|
+
full: true
|
|
111
|
+
};
|
|
112
|
+
export default {
|
|
113
|
+
title: 'Layout/Wizard/Long Content'
|
|
114
|
+
};
|
|
115
|
+
export { LongContent };
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Box, Button, Layer, Notification, Paragraph } from 'grommet';
|
|
3
|
+
import { FormNext } from "grommet-icons/es6/icons/FormNext";
|
|
4
|
+
import { FormPrevious } from "grommet-icons/es6/icons/FormPrevious";
|
|
5
|
+
import { Wizard } from '../Wizard';
|
|
6
|
+
import { WizardFooter } from '../WizardFooter';
|
|
7
|
+
import { useWizard } from '../WizardContext';
|
|
8
|
+
|
|
9
|
+
// Wizard inside a modal Layer. `onCancel` wires the header X to the
|
|
10
|
+
// parent-owned close handler. A custom footer composed via <WizardFooter>
|
|
11
|
+
// children preserves the themed shell while omitting the Cancel button.
|
|
12
|
+
var NoCancelFooter = function NoCancelFooter() {
|
|
13
|
+
var _useWizard = useWizard(),
|
|
14
|
+
currentStepIndex = _useWizard.currentStepIndex,
|
|
15
|
+
totalSteps = _useWizard.totalSteps,
|
|
16
|
+
canGoNext = _useWizard.canGoNext,
|
|
17
|
+
previous = _useWizard.previous,
|
|
18
|
+
next = _useWizard.next,
|
|
19
|
+
complete = _useWizard.complete;
|
|
20
|
+
var isFirstStep = currentStepIndex <= 0;
|
|
21
|
+
var isLastStep = currentStepIndex >= totalSteps - 1;
|
|
22
|
+
return /*#__PURE__*/React.createElement(WizardFooter, null, !isFirstStep && /*#__PURE__*/React.createElement(Button, {
|
|
23
|
+
label: "Previous",
|
|
24
|
+
icon: /*#__PURE__*/React.createElement(FormPrevious, {
|
|
25
|
+
"aria-hidden": "true"
|
|
26
|
+
}),
|
|
27
|
+
onClick: previous
|
|
28
|
+
}), isLastStep ? /*#__PURE__*/React.createElement(Button, {
|
|
29
|
+
label: "Complete",
|
|
30
|
+
primary: true,
|
|
31
|
+
disabled: !canGoNext,
|
|
32
|
+
onClick: complete
|
|
33
|
+
}) : /*#__PURE__*/React.createElement(Button, {
|
|
34
|
+
label: "Next",
|
|
35
|
+
primary: true,
|
|
36
|
+
reverse: true,
|
|
37
|
+
icon: /*#__PURE__*/React.createElement(FormNext, {
|
|
38
|
+
"aria-hidden": "true"
|
|
39
|
+
}),
|
|
40
|
+
disabled: !canGoNext,
|
|
41
|
+
onClick: next
|
|
42
|
+
}));
|
|
43
|
+
};
|
|
44
|
+
var steps = [{
|
|
45
|
+
id: 'details',
|
|
46
|
+
title: 'Details',
|
|
47
|
+
description: 'Enter details for the new resource.',
|
|
48
|
+
render: function render() {
|
|
49
|
+
return /*#__PURE__*/React.createElement(Paragraph, null, "Describe the resource you are creating.");
|
|
50
|
+
}
|
|
51
|
+
}, {
|
|
52
|
+
id: 'configure',
|
|
53
|
+
title: 'Configure',
|
|
54
|
+
description: 'Configure options for this resource.',
|
|
55
|
+
render: function render() {
|
|
56
|
+
return /*#__PURE__*/React.createElement(Paragraph, null, "Pick configuration options.");
|
|
57
|
+
}
|
|
58
|
+
}, {
|
|
59
|
+
id: 'review',
|
|
60
|
+
title: 'Review',
|
|
61
|
+
description: 'Review and finish.',
|
|
62
|
+
render: function render() {
|
|
63
|
+
return /*#__PURE__*/React.createElement(Paragraph, null, "Confirm and create the resource.");
|
|
64
|
+
}
|
|
65
|
+
}];
|
|
66
|
+
var Modal = function Modal() {
|
|
67
|
+
var _useState = useState(false),
|
|
68
|
+
open = _useState[0],
|
|
69
|
+
setOpen = _useState[1];
|
|
70
|
+
var _useState2 = useState(null),
|
|
71
|
+
result = _useState2[0],
|
|
72
|
+
setResult = _useState2[1];
|
|
73
|
+
var _useState3 = useState(0),
|
|
74
|
+
resetKey = _useState3[0],
|
|
75
|
+
setResetKey = _useState3[1];
|
|
76
|
+
var close = function close() {
|
|
77
|
+
setOpen(false);
|
|
78
|
+
setResetKey(function (key) {
|
|
79
|
+
return key + 1;
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
83
|
+
fill: true,
|
|
84
|
+
pad: "medium",
|
|
85
|
+
gap: "medium"
|
|
86
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
87
|
+
align: "start"
|
|
88
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
89
|
+
primary: true,
|
|
90
|
+
label: "Open wizard",
|
|
91
|
+
onClick: function onClick() {
|
|
92
|
+
return setOpen(true);
|
|
93
|
+
}
|
|
94
|
+
})), open &&
|
|
95
|
+
/*#__PURE__*/
|
|
96
|
+
// Composed sizing: the wrapping Layer + Box choose the modal's
|
|
97
|
+
// dimensions. Swap these values to make the wizard narrower,
|
|
98
|
+
// wider, or full-screen — the Wizard fills whatever it's placed in.
|
|
99
|
+
React.createElement(Layer, {
|
|
100
|
+
modal: true,
|
|
101
|
+
position: "center",
|
|
102
|
+
onEsc: close,
|
|
103
|
+
onClickOutside: close
|
|
104
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
105
|
+
width: "xlarge",
|
|
106
|
+
height: "large"
|
|
107
|
+
}, /*#__PURE__*/React.createElement(Wizard, {
|
|
108
|
+
key: resetKey,
|
|
109
|
+
"aria-label": "Modal wizard",
|
|
110
|
+
title: "Create resource",
|
|
111
|
+
showProgress: "horizontal",
|
|
112
|
+
steps: steps,
|
|
113
|
+
footer: /*#__PURE__*/React.createElement(NoCancelFooter, null),
|
|
114
|
+
onComplete: function onComplete(_ref) {
|
|
115
|
+
var value = _ref.value;
|
|
116
|
+
setResult({
|
|
117
|
+
status: 'complete',
|
|
118
|
+
value: value
|
|
119
|
+
});
|
|
120
|
+
close();
|
|
121
|
+
},
|
|
122
|
+
onCancel: close
|
|
123
|
+
}))), result && /*#__PURE__*/React.createElement(Notification, {
|
|
124
|
+
toast: {
|
|
125
|
+
position: 'top'
|
|
126
|
+
},
|
|
127
|
+
status: "normal",
|
|
128
|
+
title: "Wizard complete",
|
|
129
|
+
message: result.value && Object.keys(result.value).length > 0 ? "Completed: " + JSON.stringify(result.value) : undefined,
|
|
130
|
+
onClose: function onClose() {
|
|
131
|
+
return setResult(null);
|
|
132
|
+
}
|
|
133
|
+
}));
|
|
134
|
+
};
|
|
135
|
+
Modal.args = {
|
|
136
|
+
full: true
|
|
137
|
+
};
|
|
138
|
+
export default {
|
|
139
|
+
title: 'Layout/Wizard/Modal'
|
|
140
|
+
};
|
|
141
|
+
export { Modal };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Box, Notification, Paragraph } from 'grommet';
|
|
3
|
+
import { Wizard } from '../Wizard';
|
|
4
|
+
|
|
5
|
+
// Nested wizard with sub-steps under a parent group. Parent is never a
|
|
6
|
+
// navigation target; child steps are visited in order.
|
|
7
|
+
var steps = [{
|
|
8
|
+
id: 'setup',
|
|
9
|
+
title: 'Setup',
|
|
10
|
+
children: [{
|
|
11
|
+
id: 'setup-account',
|
|
12
|
+
title: 'Account',
|
|
13
|
+
description: 'Create an account.',
|
|
14
|
+
render: function render() {
|
|
15
|
+
return /*#__PURE__*/React.createElement(Paragraph, null, "Account form here.");
|
|
16
|
+
}
|
|
17
|
+
}, {
|
|
18
|
+
id: 'setup-profile',
|
|
19
|
+
title: 'Profile',
|
|
20
|
+
description: 'Fill in your profile.',
|
|
21
|
+
render: function render() {
|
|
22
|
+
return /*#__PURE__*/React.createElement(Paragraph, null, "Profile form here.");
|
|
23
|
+
}
|
|
24
|
+
}]
|
|
25
|
+
}, {
|
|
26
|
+
id: 'billing',
|
|
27
|
+
title: 'Billing',
|
|
28
|
+
description: 'Set up billing.',
|
|
29
|
+
render: function render() {
|
|
30
|
+
return /*#__PURE__*/React.createElement(Paragraph, null, "Billing form here.");
|
|
31
|
+
}
|
|
32
|
+
}, {
|
|
33
|
+
id: 'review',
|
|
34
|
+
title: 'Review',
|
|
35
|
+
description: 'Review and submit.',
|
|
36
|
+
render: function render() {
|
|
37
|
+
return /*#__PURE__*/React.createElement(Paragraph, null, "Review summary here.");
|
|
38
|
+
}
|
|
39
|
+
}];
|
|
40
|
+
var NestedSubSteps = function NestedSubSteps() {
|
|
41
|
+
var _useState = useState(null),
|
|
42
|
+
result = _useState[0],
|
|
43
|
+
setResult = _useState[1];
|
|
44
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
45
|
+
fill: true
|
|
46
|
+
}, /*#__PURE__*/React.createElement(Wizard, {
|
|
47
|
+
"aria-label": "Nested wizard",
|
|
48
|
+
title: "Set up your organization",
|
|
49
|
+
showProgress: "vertical",
|
|
50
|
+
steps: steps,
|
|
51
|
+
onComplete: function onComplete(_ref) {
|
|
52
|
+
var value = _ref.value;
|
|
53
|
+
return setResult({
|
|
54
|
+
status: 'complete',
|
|
55
|
+
value: value
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}), result && /*#__PURE__*/React.createElement(Notification, {
|
|
59
|
+
toast: {
|
|
60
|
+
position: 'top'
|
|
61
|
+
},
|
|
62
|
+
status: "normal",
|
|
63
|
+
title: "Wizard complete",
|
|
64
|
+
message: result.value && Object.keys(result.value).length > 0 ? "Completed: " + JSON.stringify(result.value) : undefined,
|
|
65
|
+
onClose: function onClose() {
|
|
66
|
+
return setResult(null);
|
|
67
|
+
}
|
|
68
|
+
}));
|
|
69
|
+
};
|
|
70
|
+
NestedSubSteps.args = {
|
|
71
|
+
full: true
|
|
72
|
+
};
|
|
73
|
+
export default {
|
|
74
|
+
title: 'Layout/Wizard/Nested Sub-Steps'
|
|
75
|
+
};
|
|
76
|
+
export { NestedSubSteps };
|