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.
Files changed (190) hide show
  1. package/COPYRIGHT.md +3 -1
  2. package/components/Button/Button.js +7 -4
  3. package/components/Button/stories/CustomThemed/ChildrenPlainOption.stories.js +86 -0
  4. package/components/Calendar/Calendar.js +2 -1
  5. package/components/Cards/Cards.js +1 -2
  6. package/components/DateTimeInput/DateTimeInput.js +1093 -0
  7. package/components/DateTimeInput/README.md +2 -0
  8. package/components/DateTimeInput/StyledDateTimeInput.js +74 -0
  9. package/components/DateTimeInput/index.d.ts +47 -0
  10. package/components/DateTimeInput/index.js +6 -0
  11. package/components/DateTimeInput/propTypes.js +42 -0
  12. package/components/DateTimeInput/stories/CustomThemed/Custom.stories.tsx +53 -0
  13. package/components/DateTimeInput/stories/Form.stories.tsx +44 -0
  14. package/components/DateTimeInput/stories/Inline.stories.tsx +45 -0
  15. package/components/DateTimeInput/stories/Locale.stories.tsx +59 -0
  16. package/components/DateTimeInput/stories/Simple.stories.tsx +23 -0
  17. package/components/Form/Form.js +7 -4
  18. package/components/Form/index.d.ts +3 -0
  19. package/components/Form/stories/AggregateValidation.stories.js +6 -8
  20. package/components/FormField/FormField.js +164 -91
  21. package/components/Grommet/index.d.ts +21 -0
  22. package/components/Grommet/propTypes.js +26 -0
  23. package/components/Stepper/StepConnector.js +38 -0
  24. package/components/Stepper/Stepper.js +303 -0
  25. package/components/Stepper/StepperContext.js +43 -0
  26. package/components/Stepper/StepperDescription.js +26 -0
  27. package/components/Stepper/StepperHelperText.js +44 -0
  28. package/components/Stepper/StepperIndicator.js +74 -0
  29. package/components/Stepper/StepperLabel.js +41 -0
  30. package/components/Stepper/StepperStep.js +137 -0
  31. package/components/Stepper/StyledStepper.js +162 -0
  32. package/components/Stepper/index.d.ts +80 -0
  33. package/components/Stepper/index.js +18 -0
  34. package/components/Stepper/propTypes.js +35 -0
  35. package/components/Stepper/stories/DisabledSteps.stories.js +45 -0
  36. package/components/Stepper/stories/ErrorStates.stories.js +45 -0
  37. package/components/Stepper/stories/HorizontalSteps.stories.js +50 -0
  38. package/components/Stepper/stories/Interactive.stories.js +60 -0
  39. package/components/Stepper/stories/KeyboardNavigation.stories.js +64 -0
  40. package/components/Stepper/stories/NestedSubSteps.stories.js +70 -0
  41. package/components/Stepper/stories/ReadOnly.stories.js +43 -0
  42. package/components/Stepper/stories/ThemingLightDark.stories.js +58 -0
  43. package/components/Stepper/stories/VerticalSteps.stories.js +67 -0
  44. package/components/Tab/Tab.js +19 -6
  45. package/components/Tabs/Tabs.js +156 -22
  46. package/components/TimeInput/README.md +2 -0
  47. package/components/TimeInput/StyledTimeInput.js +73 -0
  48. package/components/TimeInput/TimeInput.js +692 -0
  49. package/components/TimeInput/TimeInputPopup.js +489 -0
  50. package/components/TimeInput/index.d.ts +44 -0
  51. package/components/TimeInput/index.js +6 -0
  52. package/components/TimeInput/propTypes.js +39 -0
  53. package/components/TimeInput/stories/Controlled.stories.tsx +29 -0
  54. package/components/TimeInput/stories/Disabled.stories.tsx +13 -0
  55. package/components/TimeInput/stories/Form.stories.tsx +38 -0
  56. package/components/TimeInput/stories/ReadOnly.stories.tsx +13 -0
  57. package/components/TimeInput/stories/Simple.stories.tsx +19 -0
  58. package/components/TimeInput/stories/Step.stories.tsx +14 -0
  59. package/components/TimeInput/stories/ThemingLightDark.stories.tsx +22 -0
  60. package/components/TimeInput/stories/Uncontrolled.stories.tsx +22 -0
  61. package/components/TimeInput/useSectionedTimeField.js +358 -0
  62. package/components/TimeInput/utils.js +192 -0
  63. package/components/Wizard/StyledWizard.js +16 -0
  64. package/components/Wizard/Wizard.js +770 -0
  65. package/components/Wizard/WizardContent.js +90 -0
  66. package/components/Wizard/WizardContext.js +35 -0
  67. package/components/Wizard/WizardFooter.js +123 -0
  68. package/components/Wizard/WizardHeader.js +63 -0
  69. package/components/Wizard/WizardProgress.js +84 -0
  70. package/components/Wizard/WizardStepHeader.js +55 -0
  71. package/components/Wizard/index.d.ts +171 -0
  72. package/components/Wizard/index.js +19 -0
  73. package/components/Wizard/propTypes.js +56 -0
  74. package/components/Wizard/stories/BasicLinear.stories.js +71 -0
  75. package/components/Wizard/stories/Branching.stories.js +96 -0
  76. package/components/Wizard/stories/Composable.stories.js +75 -0
  77. package/components/Wizard/stories/Controlled.stories.js +136 -0
  78. package/components/Wizard/stories/LongContent.stories.js +118 -0
  79. package/components/Wizard/stories/Modal.stories.js +143 -0
  80. package/components/Wizard/stories/NestedSubSteps.stories.js +79 -0
  81. package/components/Wizard/stories/Validation.stories.js +123 -0
  82. package/components/index.d.ts +6 -0
  83. package/components/index.js +24 -0
  84. package/es6/components/Button/Button.js +7 -4
  85. package/es6/components/Button/stories/CustomThemed/ChildrenPlainOption.stories.js +81 -0
  86. package/es6/components/Calendar/Calendar.js +2 -0
  87. package/es6/components/Cards/Cards.js +1 -2
  88. package/es6/components/DateTimeInput/DateTimeInput.js +1090 -0
  89. package/es6/components/DateTimeInput/README.md +2 -0
  90. package/es6/components/DateTimeInput/StyledDateTimeInput.js +68 -0
  91. package/es6/components/DateTimeInput/index.d.ts +47 -0
  92. package/es6/components/DateTimeInput/index.js +3 -0
  93. package/es6/components/DateTimeInput/propTypes.js +36 -0
  94. package/es6/components/DateTimeInput/stories/CustomThemed/Custom.stories.tsx +53 -0
  95. package/es6/components/DateTimeInput/stories/Form.stories.tsx +44 -0
  96. package/es6/components/DateTimeInput/stories/Inline.stories.tsx +45 -0
  97. package/es6/components/DateTimeInput/stories/Locale.stories.tsx +59 -0
  98. package/es6/components/DateTimeInput/stories/Simple.stories.tsx +23 -0
  99. package/es6/components/Form/Form.js +7 -3
  100. package/es6/components/Form/index.d.ts +3 -0
  101. package/es6/components/Form/stories/AggregateValidation.stories.js +6 -9
  102. package/es6/components/FormField/FormField.js +165 -91
  103. package/es6/components/Grommet/index.d.ts +21 -0
  104. package/es6/components/Grommet/propTypes.js +26 -0
  105. package/es6/components/Stepper/StepConnector.js +33 -0
  106. package/es6/components/Stepper/Stepper.js +301 -0
  107. package/es6/components/Stepper/StepperContext.js +39 -0
  108. package/es6/components/Stepper/StepperDescription.js +21 -0
  109. package/es6/components/Stepper/StepperHelperText.js +39 -0
  110. package/es6/components/Stepper/StepperIndicator.js +69 -0
  111. package/es6/components/Stepper/StepperLabel.js +36 -0
  112. package/es6/components/Stepper/StepperStep.js +133 -0
  113. package/es6/components/Stepper/StyledStepper.js +156 -0
  114. package/es6/components/Stepper/index.d.ts +80 -0
  115. package/es6/components/Stepper/index.js +6 -0
  116. package/es6/components/Stepper/propTypes.js +30 -0
  117. package/es6/components/Stepper/stories/DisabledSteps.stories.js +41 -0
  118. package/es6/components/Stepper/stories/ErrorStates.stories.js +41 -0
  119. package/es6/components/Stepper/stories/HorizontalSteps.stories.js +46 -0
  120. package/es6/components/Stepper/stories/Interactive.stories.js +56 -0
  121. package/es6/components/Stepper/stories/KeyboardNavigation.stories.js +60 -0
  122. package/es6/components/Stepper/stories/NestedSubSteps.stories.js +66 -0
  123. package/es6/components/Stepper/stories/ReadOnly.stories.js +39 -0
  124. package/es6/components/Stepper/stories/ThemingLightDark.stories.js +54 -0
  125. package/es6/components/Stepper/stories/VerticalSteps.stories.js +63 -0
  126. package/es6/components/Tab/Tab.js +19 -6
  127. package/es6/components/Tabs/Tabs.js +157 -23
  128. package/es6/components/TimeInput/README.md +2 -0
  129. package/es6/components/TimeInput/StyledTimeInput.js +68 -0
  130. package/es6/components/TimeInput/TimeInput.js +689 -0
  131. package/es6/components/TimeInput/TimeInputPopup.js +485 -0
  132. package/es6/components/TimeInput/index.d.ts +44 -0
  133. package/es6/components/TimeInput/index.js +1 -0
  134. package/es6/components/TimeInput/propTypes.js +33 -0
  135. package/es6/components/TimeInput/stories/Controlled.stories.tsx +29 -0
  136. package/es6/components/TimeInput/stories/Disabled.stories.tsx +13 -0
  137. package/es6/components/TimeInput/stories/Form.stories.tsx +38 -0
  138. package/es6/components/TimeInput/stories/ReadOnly.stories.tsx +13 -0
  139. package/es6/components/TimeInput/stories/Simple.stories.tsx +19 -0
  140. package/es6/components/TimeInput/stories/Step.stories.tsx +14 -0
  141. package/es6/components/TimeInput/stories/ThemingLightDark.stories.tsx +22 -0
  142. package/es6/components/TimeInput/stories/Uncontrolled.stories.tsx +22 -0
  143. package/es6/components/TimeInput/useSectionedTimeField.js +355 -0
  144. package/es6/components/TimeInput/utils.js +187 -0
  145. package/es6/components/Wizard/StyledWizard.js +11 -0
  146. package/es6/components/Wizard/Wizard.js +768 -0
  147. package/es6/components/Wizard/WizardContent.js +87 -0
  148. package/es6/components/Wizard/WizardContext.js +31 -0
  149. package/es6/components/Wizard/WizardFooter.js +120 -0
  150. package/es6/components/Wizard/WizardHeader.js +60 -0
  151. package/es6/components/Wizard/WizardProgress.js +80 -0
  152. package/es6/components/Wizard/WizardStepHeader.js +51 -0
  153. package/es6/components/Wizard/index.d.ts +171 -0
  154. package/es6/components/Wizard/index.js +7 -0
  155. package/es6/components/Wizard/propTypes.js +51 -0
  156. package/es6/components/Wizard/stories/BasicLinear.stories.js +67 -0
  157. package/es6/components/Wizard/stories/Branching.stories.js +93 -0
  158. package/es6/components/Wizard/stories/Composable.stories.js +72 -0
  159. package/es6/components/Wizard/stories/Controlled.stories.js +133 -0
  160. package/es6/components/Wizard/stories/LongContent.stories.js +115 -0
  161. package/es6/components/Wizard/stories/Modal.stories.js +141 -0
  162. package/es6/components/Wizard/stories/NestedSubSteps.stories.js +76 -0
  163. package/es6/components/Wizard/stories/Validation.stories.js +118 -0
  164. package/es6/components/index.d.ts +6 -0
  165. package/es6/components/index.js +6 -0
  166. package/es6/index.d.ts +6 -0
  167. package/es6/languages/default.json +48 -0
  168. package/es6/themes/base.d.ts +223 -0
  169. package/es6/themes/base.js +366 -0
  170. package/es6/utils/DOM.js +11 -2
  171. package/es6/utils/dates.js +10 -0
  172. package/es6/utils/sectionHelpers.js +57 -0
  173. package/es6/utils/useSectionedField.js +45 -0
  174. package/grommet.min.js +2 -1
  175. package/grommet.min.js.LICENSE.txt +1 -0
  176. package/grommet.min.js.map +1 -1
  177. package/index.d.ts +6 -0
  178. package/languages/default.json +48 -0
  179. package/package.json +57 -52
  180. package/themes/base.d.ts +223 -0
  181. package/themes/base.js +366 -1
  182. package/tools/license-header.js +2 -0
  183. package/utils/DOM.js +11 -2
  184. package/utils/dates.js +11 -1
  185. package/utils/sectionHelpers.js +61 -0
  186. package/utils/useSectionedField.js +50 -0
  187. package/components/TextInput/stories/CustomThemed/CustomSuggestions.stories.tsx +0 -180
  188. package/components/TextInput/stories/CustomThemed/Themed.stories.js +0 -79
  189. package/es6/components/TextInput/stories/CustomThemed/CustomSuggestions.stories.tsx +0 -180
  190. package/es6/components/TextInput/stories/CustomThemed/Themed.stories.js +0 -74
@@ -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 };