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,156 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import styled, { css } from 'styled-components';
|
|
4
|
+
import isPropValid from '@emotion/is-prop-valid';
|
|
5
|
+
import { focusStyle, normalizeColor, styledComponentsConfig } from '../../utils';
|
|
6
|
+
var getMetricSize = function getMetricSize(theme, size) {
|
|
7
|
+
var _theme$global, _theme$global2;
|
|
8
|
+
return ((_theme$global = theme.global) == null || (_theme$global = _theme$global.edgeSize) == null ? void 0 : _theme$global[size]) || ((_theme$global2 = theme.global) == null || (_theme$global2 = _theme$global2.size) == null ? void 0 : _theme$global2[size]) || size;
|
|
9
|
+
};
|
|
10
|
+
var getTextMetric = function getTextMetric(theme, size, metric) {
|
|
11
|
+
var _theme$text, _theme$text2;
|
|
12
|
+
return ((_theme$text = theme.text) == null || (_theme$text = _theme$text[size]) == null ? void 0 : _theme$text[metric]) || ((_theme$text2 = theme.text) == null || (_theme$text2 = _theme$text2.medium) == null ? void 0 : _theme$text2[metric]);
|
|
13
|
+
};
|
|
14
|
+
var getSubStepSizeToken = function getSubStepSizeToken(indicatorSize) {
|
|
15
|
+
switch (indicatorSize) {
|
|
16
|
+
case 'large':
|
|
17
|
+
return 'small';
|
|
18
|
+
case 'small':
|
|
19
|
+
return 'xsmall';
|
|
20
|
+
default:
|
|
21
|
+
return 'small';
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
var getConnectorColor = function getConnectorColor(stepStatus, theme) {
|
|
25
|
+
var _theme$stepper;
|
|
26
|
+
return normalizeColor(((_theme$stepper = theme.stepper) == null || (_theme$stepper = _theme$stepper[stepStatus]) == null || (_theme$stepper = _theme$stepper.connector) == null ? void 0 : _theme$stepper.color) || 'border', theme);
|
|
27
|
+
};
|
|
28
|
+
var StyledStepItem = styled.li.withConfig({
|
|
29
|
+
shouldForwardProp: function shouldForwardProp(prop) {
|
|
30
|
+
return isPropValid(prop) && prop !== 'direction';
|
|
31
|
+
}
|
|
32
|
+
}).withConfig({
|
|
33
|
+
displayName: "StyledStepper__StyledStepItem",
|
|
34
|
+
componentId: "sc-gmpe0p-0"
|
|
35
|
+
})(["display:flex;position:relative;", ""], function (props) {
|
|
36
|
+
if (props.direction === 'vertical') {
|
|
37
|
+
var paddingBottom = '0px';
|
|
38
|
+
if (!props.isSubStep && !props.isLast && !props.hasSubSteps) {
|
|
39
|
+
paddingBottom = "" + props.theme.global.edgeSize.medium;
|
|
40
|
+
}
|
|
41
|
+
return css(["flex-direction:column;align-items:flex-start;padding-bottom:", ";"], paddingBottom);
|
|
42
|
+
}
|
|
43
|
+
if (props.isSubStep) {
|
|
44
|
+
// horizontal and sub-steps isn't supported
|
|
45
|
+
return css(["flex-direction:row;align-items:center;flex:none;min-width:0;overflow:hidden;"]);
|
|
46
|
+
}
|
|
47
|
+
return css(["flex-direction:column;align-items:center;flex:1;min-width:0;overflow:visible;"]);
|
|
48
|
+
});
|
|
49
|
+
var StyledStepButton = styled.button.withConfig({
|
|
50
|
+
shouldForwardProp: function shouldForwardProp(prop) {
|
|
51
|
+
return isPropValid(prop) && prop !== 'direction';
|
|
52
|
+
}
|
|
53
|
+
}).withConfig({
|
|
54
|
+
displayName: "StyledStepper__StyledStepButton",
|
|
55
|
+
componentId: "sc-gmpe0p-1"
|
|
56
|
+
})(["display:flex;background:none;border:none;padding:", ";cursor:", ";outline:none;", ""], function (props) {
|
|
57
|
+
var _props$theme$global, _props$theme$stepper;
|
|
58
|
+
return (_props$theme$global = props.theme.global) == null || (_props$theme$global = _props$theme$global.edgeSize) == null ? void 0 : _props$theme$global[((_props$theme$stepper = props.theme.stepper) == null || (_props$theme$stepper = _props$theme$stepper.button) == null ? void 0 : _props$theme$stepper.pad) || 'xxsmall'];
|
|
59
|
+
}, function (props) {
|
|
60
|
+
return props.isClickable ? 'pointer' : 'default';
|
|
61
|
+
}, function (props) {
|
|
62
|
+
var _props$theme$global2, _props$theme$stepper2, _props$theme$global3, _props$theme$stepper3;
|
|
63
|
+
return props.direction === 'vertical' ? css(["flex-direction:row;align-items:flex-start;gap:", ";text-align:left;"], (_props$theme$global2 = props.theme.global) == null || (_props$theme$global2 = _props$theme$global2.edgeSize) == null ? void 0 : _props$theme$global2[((_props$theme$stepper2 = props.theme.stepper) == null || (_props$theme$stepper2 = _props$theme$stepper2.vertical) == null || (_props$theme$stepper2 = _props$theme$stepper2.button) == null ? void 0 : _props$theme$stepper2.gap) || 'small']) : css(["flex-direction:column;align-items:center;gap:", ";text-align:center;width:100%;"], (_props$theme$global3 = props.theme.global) == null || (_props$theme$global3 = _props$theme$global3.edgeSize) == null ? void 0 : _props$theme$global3[((_props$theme$stepper3 = props.theme.stepper) == null || (_props$theme$stepper3 = _props$theme$stepper3.horizontal) == null || (_props$theme$stepper3 = _props$theme$stepper3.button) == null ? void 0 : _props$theme$stepper3.gap) || 'xxsmall']);
|
|
64
|
+
});
|
|
65
|
+
var StyledStepContent = styled.span.withConfig({
|
|
66
|
+
shouldForwardProp: function shouldForwardProp(prop) {
|
|
67
|
+
return isPropValid(prop) && prop !== 'direction';
|
|
68
|
+
}
|
|
69
|
+
}).withConfig({
|
|
70
|
+
displayName: "StyledStepper__StyledStepContent",
|
|
71
|
+
componentId: "sc-gmpe0p-2"
|
|
72
|
+
})(["display:flex;flex-direction:column;", ""], function (props) {
|
|
73
|
+
if (props.direction === 'vertical' && !props.isSubStep && !props.hasDescription) {
|
|
74
|
+
var _props$theme$stepper4;
|
|
75
|
+
var indicatorSizeToken = ((_props$theme$stepper4 = props.theme.stepper) == null || (_props$theme$stepper4 = _props$theme$stepper4.indicator) == null ? void 0 : _props$theme$stepper4.size) || 'medium';
|
|
76
|
+
var indicatorSize = getMetricSize(props.theme, indicatorSizeToken);
|
|
77
|
+
var lineHeight = getTextMetric(props.theme, 'small', 'height');
|
|
78
|
+
return css(["padding-top:calc((", " - ", ") / 2);"], indicatorSize, lineHeight);
|
|
79
|
+
}
|
|
80
|
+
return '';
|
|
81
|
+
});
|
|
82
|
+
var StyledIndicator = styled.span.withConfig(styledComponentsConfig).withConfig({
|
|
83
|
+
displayName: "StyledStepper__StyledIndicator",
|
|
84
|
+
componentId: "sc-gmpe0p-3"
|
|
85
|
+
})(["display:flex;align-items:center;justify-content:center;border-radius:50%;transition:transform 0.1s ease,background-color 0.15s ease,border-color 0.15s ease,color 0.15s ease;", " ", " ", ":focus-visible &{", "}", ""], function (props) {
|
|
86
|
+
return function (_props$theme$stepper5, _props$theme$stepper6, _props$theme$global4) {
|
|
87
|
+
var indicatorSizeToken = ((_props$theme$stepper5 = props.theme.stepper) == null || (_props$theme$stepper5 = _props$theme$stepper5.indicator) == null ? void 0 : _props$theme$stepper5.size) || 'medium';
|
|
88
|
+
var parentSize = getMetricSize(props.theme, indicatorSizeToken);
|
|
89
|
+
var subStepSize = getMetricSize(props.theme, getSubStepSizeToken(indicatorSizeToken));
|
|
90
|
+
var size = props.isSubStep ? subStepSize : parentSize;
|
|
91
|
+
var borderWidth = ((_props$theme$stepper6 = props.theme.stepper) == null || (_props$theme$stepper6 = _props$theme$stepper6.indicator) == null || (_props$theme$stepper6 = _props$theme$stepper6.border) == null ? void 0 : _props$theme$stepper6.width) || ((_props$theme$global4 = props.theme.global) == null || (_props$theme$global4 = _props$theme$global4.borderSize) == null ? void 0 : _props$theme$global4.small) || '2px';
|
|
92
|
+
return css(["width:", ";height:", ";min-width:", ";min-height:", ";border:", " solid;"], size, size, size, size, borderWidth);
|
|
93
|
+
}();
|
|
94
|
+
}, function (props) {
|
|
95
|
+
var _theme$stepper2;
|
|
96
|
+
var theme = props.theme;
|
|
97
|
+
var stateTheme = ((_theme$stepper2 = theme.stepper) == null || (_theme$stepper2 = _theme$stepper2[props.effectiveState]) == null ? void 0 : _theme$stepper2.indicator) || {};
|
|
98
|
+
return css(["background:", ";color:", ";border-color:", ";"], normalizeColor((stateTheme == null ? void 0 : stateTheme.background) || 'transparent', theme), normalizeColor((stateTheme == null ? void 0 : stateTheme.color) || 'text-weak', theme), normalizeColor((stateTheme == null ? void 0 : stateTheme.border) || 'border', theme));
|
|
99
|
+
}, StyledStepButton, focusStyle(), function (props) {
|
|
100
|
+
var _theme$stepper3, _stateTheme$hover, _stateTheme$hover2, _stateTheme$hover3, _theme$stepper4, _theme$stepper5;
|
|
101
|
+
if (!props.isClickable) return '';
|
|
102
|
+
var theme = props.theme;
|
|
103
|
+
var stateTheme = ((_theme$stepper3 = theme.stepper) == null || (_theme$stepper3 = _theme$stepper3[props.effectiveState]) == null ? void 0 : _theme$stepper3.indicator) || {};
|
|
104
|
+
var backgroundColor = stateTheme != null && stateTheme.background ? normalizeColor(stateTheme.background, theme) : undefined;
|
|
105
|
+
var borderColor = stateTheme != null && stateTheme.border ? normalizeColor(stateTheme.border, theme) : undefined;
|
|
106
|
+
var color = stateTheme != null && stateTheme.color ? normalizeColor(stateTheme.color, theme) : undefined;
|
|
107
|
+
var stateBackgroundHoverColor = stateTheme != null && (_stateTheme$hover = stateTheme.hover) != null && _stateTheme$hover.background ? normalizeColor(stateTheme.hover.background, theme) : undefined;
|
|
108
|
+
var stateBorderHoverColor = stateTheme != null && (_stateTheme$hover2 = stateTheme.hover) != null && _stateTheme$hover2.border ? normalizeColor(stateTheme.hover.border, theme) : undefined;
|
|
109
|
+
var stateColorHoverColor = stateTheme != null && (_stateTheme$hover3 = stateTheme.hover) != null && _stateTheme$hover3.color ? normalizeColor(stateTheme.hover.color, theme) : undefined;
|
|
110
|
+
var defaultBackgroundHoverColor = backgroundColor ? "color-mix(in srgb, " + backgroundColor + " 80%, black)" : normalizeColor(((_theme$stepper4 = theme.stepper) == null || (_theme$stepper4 = _theme$stepper4.hover) == null ? void 0 : _theme$stepper4.background) || 'background-contrast', theme);
|
|
111
|
+
var defaultBorderHoverColor = borderColor ? "color-mix(in srgb, " + borderColor + " 80%, black)" : normalizeColor(((_theme$stepper5 = theme.stepper) == null || (_theme$stepper5 = _theme$stepper5.hover) == null ? void 0 : _theme$stepper5.border) || 'text', theme);
|
|
112
|
+
var defaultColorHoverColor = color ? "color-mix(in srgb, " + color + " 80%, black)" : normalizeColor('text-strong', theme);
|
|
113
|
+
var hoverBackgroundColor = stateBackgroundHoverColor || defaultBackgroundHoverColor;
|
|
114
|
+
var hoverBorderColor = stateBorderHoverColor || defaultBorderHoverColor;
|
|
115
|
+
var hoverColor = stateColorHoverColor || defaultColorHoverColor;
|
|
116
|
+
var hoverStyles = function () {
|
|
117
|
+
return css(["background:", ";border-color:", ";color:", ";"], hoverBackgroundColor, hoverBorderColor, hoverColor);
|
|
118
|
+
}();
|
|
119
|
+
return css(["", ":not([aria-disabled]):active &{transform:scale(0.95);}", ":not([aria-disabled]):hover &{", "}"], StyledStepButton, StyledStepButton, hoverStyles);
|
|
120
|
+
});
|
|
121
|
+
var StyledConnector = styled.span.withConfig(styledComponentsConfig).withConfig({
|
|
122
|
+
displayName: "StyledStepper__StyledConnector",
|
|
123
|
+
componentId: "sc-gmpe0p-4"
|
|
124
|
+
})(["", " position:absolute;background:", ";"], function (props) {
|
|
125
|
+
var _theme$stepper6, _theme$stepper7, _props$theme$global5, _props$theme$stepper7, _theme$stepper8, _theme$global3, _theme$global4, _props$theme$stepper8;
|
|
126
|
+
var theme = props.theme;
|
|
127
|
+
var indicatorSizeToken = ((_theme$stepper6 = theme.stepper) == null || (_theme$stepper6 = _theme$stepper6.indicator) == null ? void 0 : _theme$stepper6.size) || 'medium';
|
|
128
|
+
var parentSize = getMetricSize(theme, indicatorSizeToken);
|
|
129
|
+
var indicatorBorderWidth = getMetricSize(theme, ((_theme$stepper7 = theme.stepper) == null || (_theme$stepper7 = _theme$stepper7.indicator) == null || (_theme$stepper7 = _theme$stepper7.border) == null ? void 0 : _theme$stepper7.width) || '2px');
|
|
130
|
+
var buttonPad = (_props$theme$global5 = props.theme.global) == null || (_props$theme$global5 = _props$theme$global5.edgeSize) == null ? void 0 : _props$theme$global5[((_props$theme$stepper7 = props.theme.stepper) == null || (_props$theme$stepper7 = _props$theme$stepper7.button) == null ? void 0 : _props$theme$stepper7.pad) || 'xxsmall'];
|
|
131
|
+
var connectorThickness = ((_theme$stepper8 = theme.stepper) == null || (_theme$stepper8 = _theme$stepper8.connector) == null || (_theme$stepper8 = _theme$stepper8.stroke) == null ? void 0 : _theme$stepper8.width) || ((_theme$global3 = theme.global) == null || (_theme$global3 = _theme$global3.borderSize) == null ? void 0 : _theme$global3.small) || '2px';
|
|
132
|
+
var connectorRadius = ((_theme$global4 = theme.global) == null || (_theme$global4 = _theme$global4.edgeSize) == null ? void 0 : _theme$global4.xsmall) || '4px';
|
|
133
|
+
var connectorOffset = "calc(" + parentSize + " / 2 + " + buttonPad + ")";
|
|
134
|
+
var connectorGap = '4px';
|
|
135
|
+
var nonBetweenTop = "calc(" + parentSize + " + " + buttonPad + " +\n (" + indicatorBorderWidth + " * 2) + " + connectorGap + ")";
|
|
136
|
+
return css(["border-radius:", ";", ""], connectorRadius, props.direction === 'horizontal' ? css(["top:", ";left:calc(", "50% + ", ");right:calc(-50% + ", ");height:", ";margin-inline:", ";"], connectorOffset, props.isBetween ? '-' : '', connectorOffset, connectorOffset, connectorThickness, props.theme.global.edgeSize[((_props$theme$stepper8 = props.theme.stepper) == null || (_props$theme$stepper8 = _props$theme$stepper8.horizontal) == null || (_props$theme$stepper8 = _props$theme$stepper8.connector) == null ? void 0 : _props$theme$stepper8.margin) || 'xxsmall']) : css(["left:calc( ", " + ", " - ", " / 2 );top:", ";bottom:0;", " width:", ";margin-block:0;"], connectorOffset, indicatorBorderWidth, connectorThickness, props.isBetween ? 0 : nonBetweenTop, !props.isBetween && css(["min-height:12px;"]), connectorThickness));
|
|
137
|
+
}, function (props) {
|
|
138
|
+
return getConnectorColor(props.status, props.theme);
|
|
139
|
+
});
|
|
140
|
+
var StyledSubStepsList = styled.ol.withConfig({
|
|
141
|
+
shouldForwardProp: function shouldForwardProp(prop) {
|
|
142
|
+
return isPropValid(prop) && prop !== 'direction';
|
|
143
|
+
}
|
|
144
|
+
}).withConfig({
|
|
145
|
+
displayName: "StyledStepper__StyledSubStepsList",
|
|
146
|
+
componentId: "sc-gmpe0p-5"
|
|
147
|
+
})(["list-style:none;margin:0;padding:0;", ""], function (props) {
|
|
148
|
+
var _props$theme$stepper9, _props$theme$global6, _props$theme$stepper0, _props$theme$global7, _props$theme$stepper1;
|
|
149
|
+
if (props.direction !== 'vertical') return '';
|
|
150
|
+
var indicatorSizeToken = ((_props$theme$stepper9 = props.theme.stepper) == null || (_props$theme$stepper9 = _props$theme$stepper9.indicator) == null ? void 0 : _props$theme$stepper9.size) || 'medium';
|
|
151
|
+
var indicatorSize = getMetricSize(props.theme, indicatorSizeToken);
|
|
152
|
+
var textGap = (_props$theme$global6 = props.theme.global) == null || (_props$theme$global6 = _props$theme$global6.edgeSize) == null ? void 0 : _props$theme$global6[((_props$theme$stepper0 = props.theme.stepper) == null || (_props$theme$stepper0 = _props$theme$stepper0.vertical) == null || (_props$theme$stepper0 = _props$theme$stepper0.button) == null ? void 0 : _props$theme$stepper0.gap) || 'small'];
|
|
153
|
+
var buttonPad = (_props$theme$global7 = props.theme.global) == null || (_props$theme$global7 = _props$theme$global7.edgeSize) == null ? void 0 : _props$theme$global7[((_props$theme$stepper1 = props.theme.stepper) == null || (_props$theme$stepper1 = _props$theme$stepper1.button) == null ? void 0 : _props$theme$stepper1.pad) || 'xxsmall'];
|
|
154
|
+
return css(["padding-inline-start:calc(", " + ", " + ", ");"], indicatorSize, textGap, buttonPad);
|
|
155
|
+
});
|
|
156
|
+
export { StyledStepItem, StyledStepButton, StyledStepContent, StyledIndicator, StyledConnector, StyledSubStepsList };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
export type StepStatus = 'pending' | 'completed' | 'error' | 'disabled';
|
|
4
|
+
|
|
5
|
+
export interface StepType {
|
|
6
|
+
id: string;
|
|
7
|
+
title: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
status?: StepStatus;
|
|
10
|
+
disabledReason?: string;
|
|
11
|
+
errorMessage?: string;
|
|
12
|
+
'aria-label'?: string;
|
|
13
|
+
children?: Omit<StepType, 'children'>[];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface StepperProps
|
|
17
|
+
extends Omit<React.HTMLAttributes<HTMLOListElement>, 'children'> {
|
|
18
|
+
steps: StepType[];
|
|
19
|
+
currentStep: string;
|
|
20
|
+
direction?: 'horizontal' | 'vertical';
|
|
21
|
+
clickableSteps?: boolean;
|
|
22
|
+
showDescription?: boolean;
|
|
23
|
+
onStepClick?: (stepId: string) => void;
|
|
24
|
+
id?: string;
|
|
25
|
+
'aria-label'?: string;
|
|
26
|
+
children?: React.ReactNode;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface StepperContextValue {
|
|
30
|
+
currentStep: string;
|
|
31
|
+
steps: StepType[];
|
|
32
|
+
direction: 'horizontal' | 'vertical';
|
|
33
|
+
clickableSteps: boolean;
|
|
34
|
+
showDescription: boolean;
|
|
35
|
+
onStepClick?: (stepId: string) => void;
|
|
36
|
+
stepIndex: (stepId: string) => number;
|
|
37
|
+
isPriorStep: (stepId: string) => boolean;
|
|
38
|
+
isAfterStep: (stepId: string) => boolean;
|
|
39
|
+
isCurrentStep: (stepId: string) => boolean;
|
|
40
|
+
canNavigateTo: (stepId: string) => boolean;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
declare const Stepper: React.ForwardRefExoticComponent<
|
|
44
|
+
StepperProps & React.RefAttributes<HTMLOListElement>
|
|
45
|
+
>;
|
|
46
|
+
|
|
47
|
+
declare const StepperContext: React.Context<StepperContextValue>;
|
|
48
|
+
declare const useStepper: () => StepperContextValue;
|
|
49
|
+
|
|
50
|
+
export interface StepperStepProps {
|
|
51
|
+
step: StepType;
|
|
52
|
+
stepNumber: number;
|
|
53
|
+
isLast: boolean;
|
|
54
|
+
showConnector?: boolean;
|
|
55
|
+
direction: 'horizontal' | 'vertical';
|
|
56
|
+
focusedIndex: number;
|
|
57
|
+
index: number;
|
|
58
|
+
isSubStep?: boolean;
|
|
59
|
+
onKeyDown?: (event: React.KeyboardEvent, index: number) => void;
|
|
60
|
+
stepsRef: React.MutableRefObject<StepType[] | null>;
|
|
61
|
+
stepRefs?: React.MutableRefObject<Map<number, HTMLButtonElement>>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
declare const StepperStep: React.FC<StepperStepProps>;
|
|
65
|
+
declare const StepperIndicator: React.FC<{}>;
|
|
66
|
+
declare const StepperLabel: React.FC<{}>;
|
|
67
|
+
declare const StepperDescription: React.FC<{}>;
|
|
68
|
+
declare const StepperError: React.FC<{}>;
|
|
69
|
+
declare const StepperDisabledReason: React.FC<{}>;
|
|
70
|
+
|
|
71
|
+
export {
|
|
72
|
+
Stepper,
|
|
73
|
+
StepperContext,
|
|
74
|
+
useStepper,
|
|
75
|
+
StepperIndicator,
|
|
76
|
+
StepperLabel,
|
|
77
|
+
StepperDescription,
|
|
78
|
+
StepperError,
|
|
79
|
+
StepperDisabledReason,
|
|
80
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { Stepper } from './Stepper';
|
|
2
|
+
export { StepperContext, useStepper } from './StepperContext';
|
|
3
|
+
export { StepperIndicator } from './StepperIndicator';
|
|
4
|
+
export { StepperDescription } from './StepperDescription';
|
|
5
|
+
export { StepperLabel } from './StepperLabel';
|
|
6
|
+
export { StepperError, StepperDisabledReason } from './StepperHelperText';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
var PropType = {};
|
|
3
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4
|
+
PropType = {
|
|
5
|
+
steps: PropTypes.arrayOf(PropTypes.shape({
|
|
6
|
+
id: PropTypes.string.isRequired,
|
|
7
|
+
title: PropTypes.string.isRequired,
|
|
8
|
+
description: PropTypes.string,
|
|
9
|
+
status: PropTypes.oneOf(['pending', 'completed', 'error', 'disabled']),
|
|
10
|
+
disabledReason: PropTypes.string,
|
|
11
|
+
errorMessage: PropTypes.string,
|
|
12
|
+
children: PropTypes.arrayOf(PropTypes.shape({
|
|
13
|
+
id: PropTypes.string.isRequired,
|
|
14
|
+
title: PropTypes.string.isRequired,
|
|
15
|
+
description: PropTypes.string,
|
|
16
|
+
status: PropTypes.oneOf(['pending', 'completed', 'error', 'disabled']),
|
|
17
|
+
disabledReason: PropTypes.string,
|
|
18
|
+
errorMessage: PropTypes.string
|
|
19
|
+
}))
|
|
20
|
+
})).isRequired,
|
|
21
|
+
currentStep: PropTypes.string.isRequired,
|
|
22
|
+
direction: PropTypes.oneOf(['horizontal', 'vertical']),
|
|
23
|
+
clickableSteps: PropTypes.bool,
|
|
24
|
+
showDescription: PropTypes.bool,
|
|
25
|
+
onStepClick: PropTypes.func,
|
|
26
|
+
id: PropTypes.string,
|
|
27
|
+
children: PropTypes.node
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export var StepperPropTypes = PropType;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Box } from 'grommet';
|
|
3
|
+
import { Stepper } from '../Stepper';
|
|
4
|
+
var DisabledSteps = function DisabledSteps() {
|
|
5
|
+
var _useState = useState('billing'),
|
|
6
|
+
currentStep = _useState[0],
|
|
7
|
+
setCurrentStep = _useState[1];
|
|
8
|
+
var steps = [{
|
|
9
|
+
id: 'account',
|
|
10
|
+
title: 'Account',
|
|
11
|
+
status: 'completed'
|
|
12
|
+
}, {
|
|
13
|
+
id: 'billing',
|
|
14
|
+
title: 'Billing',
|
|
15
|
+
status: 'pending'
|
|
16
|
+
}, {
|
|
17
|
+
id: 'confirm',
|
|
18
|
+
title: 'Confirm',
|
|
19
|
+
status: 'disabled',
|
|
20
|
+
disabledReason: 'Complete billing first.'
|
|
21
|
+
}];
|
|
22
|
+
return (
|
|
23
|
+
/*#__PURE__*/
|
|
24
|
+
// Uncomment <Grommet> lines when using outside of storybook
|
|
25
|
+
// <Grommet theme={...}>
|
|
26
|
+
React.createElement(Box, {
|
|
27
|
+
pad: "large"
|
|
28
|
+
}, /*#__PURE__*/React.createElement(Stepper, {
|
|
29
|
+
steps: steps,
|
|
30
|
+
currentStep: currentStep,
|
|
31
|
+
onStepClick: function onStepClick(id) {
|
|
32
|
+
return setCurrentStep(id);
|
|
33
|
+
}
|
|
34
|
+
}))
|
|
35
|
+
// </Grommet>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
export default {
|
|
39
|
+
title: 'Visualizations/Stepper/Disabled Steps'
|
|
40
|
+
};
|
|
41
|
+
export { DisabledSteps };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Box } from 'grommet';
|
|
3
|
+
import { Stepper } from '../Stepper';
|
|
4
|
+
var ErrorStates = function ErrorStates() {
|
|
5
|
+
var _useState = useState('billing'),
|
|
6
|
+
currentStep = _useState[0],
|
|
7
|
+
setCurrentStep = _useState[1];
|
|
8
|
+
var steps = [{
|
|
9
|
+
id: 'account',
|
|
10
|
+
title: 'Account',
|
|
11
|
+
status: 'completed'
|
|
12
|
+
}, {
|
|
13
|
+
id: 'billing',
|
|
14
|
+
title: 'Billing',
|
|
15
|
+
status: 'error',
|
|
16
|
+
errorMessage: 'Card number is invalid.'
|
|
17
|
+
}, {
|
|
18
|
+
id: 'review',
|
|
19
|
+
title: 'Review',
|
|
20
|
+
status: 'pending'
|
|
21
|
+
}];
|
|
22
|
+
return (
|
|
23
|
+
/*#__PURE__*/
|
|
24
|
+
// Uncomment <Grommet> lines when using outside of storybook
|
|
25
|
+
// <Grommet theme={...}>
|
|
26
|
+
React.createElement(Box, {
|
|
27
|
+
pad: "large"
|
|
28
|
+
}, /*#__PURE__*/React.createElement(Stepper, {
|
|
29
|
+
steps: steps,
|
|
30
|
+
currentStep: currentStep,
|
|
31
|
+
onStepClick: function onStepClick(id) {
|
|
32
|
+
return setCurrentStep(id);
|
|
33
|
+
}
|
|
34
|
+
}))
|
|
35
|
+
// </Grommet>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
export default {
|
|
39
|
+
title: 'Visualizations/Stepper/Error States'
|
|
40
|
+
};
|
|
41
|
+
export { ErrorStates };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Box, Paragraph } from 'grommet';
|
|
3
|
+
import { Stepper } from '../Stepper';
|
|
4
|
+
var HorizontalSteps = function HorizontalSteps() {
|
|
5
|
+
var _useState = useState('profile'),
|
|
6
|
+
currentStep = _useState[0],
|
|
7
|
+
setCurrentStep = _useState[1];
|
|
8
|
+
var steps = [{
|
|
9
|
+
id: 'account',
|
|
10
|
+
title: 'Account',
|
|
11
|
+
status: 'completed'
|
|
12
|
+
}, {
|
|
13
|
+
id: 'profile',
|
|
14
|
+
title: 'Profile',
|
|
15
|
+
status: 'pending'
|
|
16
|
+
}, {
|
|
17
|
+
id: 'review',
|
|
18
|
+
title: 'Review',
|
|
19
|
+
status: 'pending'
|
|
20
|
+
}];
|
|
21
|
+
return (
|
|
22
|
+
/*#__PURE__*/
|
|
23
|
+
// Uncomment <Grommet> lines when using outside of storybook
|
|
24
|
+
// <Grommet theme={...}>
|
|
25
|
+
React.createElement(Box, {
|
|
26
|
+
gap: "medium",
|
|
27
|
+
pad: "large"
|
|
28
|
+
}, /*#__PURE__*/React.createElement(Stepper, {
|
|
29
|
+
steps: steps,
|
|
30
|
+
currentStep: currentStep,
|
|
31
|
+
direction: "horizontal",
|
|
32
|
+
onStepClick: function onStepClick(id) {
|
|
33
|
+
return setCurrentStep(id);
|
|
34
|
+
}
|
|
35
|
+
}), /*#__PURE__*/React.createElement(Box, {
|
|
36
|
+
pad: "medium",
|
|
37
|
+
background: "background-contrast",
|
|
38
|
+
round: "small"
|
|
39
|
+
}, /*#__PURE__*/React.createElement(Paragraph, null, "Step content for \"", currentStep, "\"")))
|
|
40
|
+
// </Grommet>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
export default {
|
|
44
|
+
title: 'Visualizations/Stepper/Horizontal Steps'
|
|
45
|
+
};
|
|
46
|
+
export { HorizontalSteps };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Box, Text, Button } from 'grommet';
|
|
3
|
+
import { Stepper } from '../Stepper';
|
|
4
|
+
var Interactive = function Interactive() {
|
|
5
|
+
var _useState = useState('step1'),
|
|
6
|
+
currentStep = _useState[0],
|
|
7
|
+
setCurrentStep = _useState[1];
|
|
8
|
+
var steps = [{
|
|
9
|
+
id: 'step1',
|
|
10
|
+
title: 'Step 1',
|
|
11
|
+
status: 'completed'
|
|
12
|
+
}, {
|
|
13
|
+
id: 'step2',
|
|
14
|
+
title: 'Step 2',
|
|
15
|
+
status: 'error',
|
|
16
|
+
errorMessage: 'Fix the issue before proceeding.'
|
|
17
|
+
}, {
|
|
18
|
+
id: 'step3',
|
|
19
|
+
title: 'Step 3',
|
|
20
|
+
status: 'pending'
|
|
21
|
+
}];
|
|
22
|
+
return (
|
|
23
|
+
/*#__PURE__*/
|
|
24
|
+
// Uncomment <Grommet> lines when using outside of storybook
|
|
25
|
+
// <Grommet theme={...}>
|
|
26
|
+
React.createElement(Box, {
|
|
27
|
+
pad: "large",
|
|
28
|
+
gap: "medium"
|
|
29
|
+
}, /*#__PURE__*/React.createElement(Text, null, "Current : ", currentStep), /*#__PURE__*/React.createElement(Box, {
|
|
30
|
+
width: "xlarge"
|
|
31
|
+
}, /*#__PURE__*/React.createElement(Stepper, {
|
|
32
|
+
steps: steps,
|
|
33
|
+
currentStep: currentStep,
|
|
34
|
+
onStepClick: function onStepClick(id) {
|
|
35
|
+
return setCurrentStep(id);
|
|
36
|
+
}
|
|
37
|
+
})), /*#__PURE__*/React.createElement(Box, {
|
|
38
|
+
direction: "row",
|
|
39
|
+
gap: "small"
|
|
40
|
+
}, steps.map(function (step) {
|
|
41
|
+
return /*#__PURE__*/React.createElement(Button, {
|
|
42
|
+
key: step.id,
|
|
43
|
+
label: "Go to " + step.id,
|
|
44
|
+
onClick: function onClick() {
|
|
45
|
+
return setCurrentStep(step.id);
|
|
46
|
+
},
|
|
47
|
+
disabled: step.status === 'disabled'
|
|
48
|
+
});
|
|
49
|
+
})))
|
|
50
|
+
// </Grommet>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
export default {
|
|
54
|
+
title: 'Visualizations/Stepper/Interactive'
|
|
55
|
+
};
|
|
56
|
+
export { Interactive };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { Box, Text } from 'grommet';
|
|
3
|
+
import { Stepper } from '../Stepper';
|
|
4
|
+
var KeyboardNavigation = function KeyboardNavigation() {
|
|
5
|
+
var _useState = useState('step1'),
|
|
6
|
+
currentStep = _useState[0],
|
|
7
|
+
setCurrentStep = _useState[1];
|
|
8
|
+
var stepperRef = useRef();
|
|
9
|
+
var steps = [{
|
|
10
|
+
id: 'step1',
|
|
11
|
+
title: 'Step 1',
|
|
12
|
+
status: 'completed'
|
|
13
|
+
}, {
|
|
14
|
+
id: 'step2',
|
|
15
|
+
title: 'Step 2',
|
|
16
|
+
status: 'pending'
|
|
17
|
+
}, {
|
|
18
|
+
id: 'step3',
|
|
19
|
+
title: 'Step 3',
|
|
20
|
+
status: 'pending'
|
|
21
|
+
}, {
|
|
22
|
+
id: 'step4',
|
|
23
|
+
title: 'Step 4',
|
|
24
|
+
status: 'disabled',
|
|
25
|
+
disabledReason: 'Complete all prior steps.'
|
|
26
|
+
}, {
|
|
27
|
+
id: 'step5',
|
|
28
|
+
title: 'Step 5',
|
|
29
|
+
status: 'pending'
|
|
30
|
+
}];
|
|
31
|
+
useEffect(function () {
|
|
32
|
+
var _stepperRef$current;
|
|
33
|
+
// Auto-focus the first step button so the focus ring is visible immediately
|
|
34
|
+
var firstButton = (_stepperRef$current = stepperRef.current) == null ? void 0 : _stepperRef$current.querySelector('button');
|
|
35
|
+
if (firstButton) firstButton.focus();
|
|
36
|
+
}, []);
|
|
37
|
+
return (
|
|
38
|
+
/*#__PURE__*/
|
|
39
|
+
// Uncomment <Grommet> lines when using outside of storybook
|
|
40
|
+
// <Grommet theme={...}>
|
|
41
|
+
React.createElement(Box, {
|
|
42
|
+
pad: "large",
|
|
43
|
+
gap: "medium"
|
|
44
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
45
|
+
weight: "bold"
|
|
46
|
+
}, "Use Arrow keys to navigate and Enter/Space to select."), /*#__PURE__*/React.createElement(Stepper, {
|
|
47
|
+
ref: stepperRef,
|
|
48
|
+
steps: steps,
|
|
49
|
+
currentStep: currentStep,
|
|
50
|
+
onStepClick: function onStepClick(id) {
|
|
51
|
+
setCurrentStep(id);
|
|
52
|
+
}
|
|
53
|
+
}), /*#__PURE__*/React.createElement(Text, null, "Selected : ", currentStep))
|
|
54
|
+
// </Grommet>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
export default {
|
|
58
|
+
title: 'Visualizations/Stepper/Keyboard Navigation'
|
|
59
|
+
};
|
|
60
|
+
export { KeyboardNavigation };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Box, Text } from 'grommet';
|
|
3
|
+
import { Stepper } from '../Stepper';
|
|
4
|
+
var NestedSubSteps = function NestedSubSteps() {
|
|
5
|
+
var _steps$find;
|
|
6
|
+
var _useState = useState('email'),
|
|
7
|
+
currentStep = _useState[0],
|
|
8
|
+
setCurrentStep = _useState[1];
|
|
9
|
+
var steps = [{
|
|
10
|
+
id: 'account',
|
|
11
|
+
title: 'Account Setup',
|
|
12
|
+
children: [{
|
|
13
|
+
id: 'email',
|
|
14
|
+
title: 'Email',
|
|
15
|
+
status: 'completed'
|
|
16
|
+
}, {
|
|
17
|
+
id: 'password',
|
|
18
|
+
title: 'Password',
|
|
19
|
+
status: 'pending'
|
|
20
|
+
}]
|
|
21
|
+
}, {
|
|
22
|
+
id: 'profile',
|
|
23
|
+
title: 'Profile Setup',
|
|
24
|
+
children: [{
|
|
25
|
+
id: 'name',
|
|
26
|
+
title: 'Name',
|
|
27
|
+
status: 'pending'
|
|
28
|
+
}, {
|
|
29
|
+
id: 'photo',
|
|
30
|
+
title: 'Photo',
|
|
31
|
+
status: 'error',
|
|
32
|
+
errorMessage: 'Please upload a valid photo.'
|
|
33
|
+
}]
|
|
34
|
+
}, {
|
|
35
|
+
id: 'confirm',
|
|
36
|
+
title: 'Confirm',
|
|
37
|
+
status: 'pending'
|
|
38
|
+
}];
|
|
39
|
+
return (
|
|
40
|
+
/*#__PURE__*/
|
|
41
|
+
// Uncomment <Grommet> lines when using outside of storybook
|
|
42
|
+
// <Grommet theme={...}>
|
|
43
|
+
React.createElement(Box, {
|
|
44
|
+
pad: "large",
|
|
45
|
+
gap: "medium"
|
|
46
|
+
}, /*#__PURE__*/React.createElement(Stepper, {
|
|
47
|
+
steps: steps,
|
|
48
|
+
currentStep: currentStep,
|
|
49
|
+
direction: "vertical",
|
|
50
|
+
"aria-label": "Account setup progress",
|
|
51
|
+
onStepClick: function onStepClick(id) {
|
|
52
|
+
return setCurrentStep(id);
|
|
53
|
+
}
|
|
54
|
+
}), /*#__PURE__*/React.createElement(Text, null, "Parent:", ' ', ((_steps$find = steps.find(function (s) {
|
|
55
|
+
var _s$children;
|
|
56
|
+
return (_s$children = s.children) == null ? void 0 : _s$children.some(function (c) {
|
|
57
|
+
return c.id === currentStep;
|
|
58
|
+
});
|
|
59
|
+
})) == null ? void 0 : _steps$find.title) || 'None'), /*#__PURE__*/React.createElement(Text, null, "Current Step: ", currentStep))
|
|
60
|
+
// </Grommet>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
export default {
|
|
64
|
+
title: 'Visualizations/Stepper/Nested Sub-Steps'
|
|
65
|
+
};
|
|
66
|
+
export { NestedSubSteps };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Box } from 'grommet';
|
|
3
|
+
import { Stepper } from '../Stepper';
|
|
4
|
+
var ReadOnly = function ReadOnly() {
|
|
5
|
+
var steps = [{
|
|
6
|
+
id: 'step1',
|
|
7
|
+
title: 'Step 1',
|
|
8
|
+
status: 'completed'
|
|
9
|
+
}, {
|
|
10
|
+
id: 'step2',
|
|
11
|
+
title: 'Step 2',
|
|
12
|
+
status: 'completed'
|
|
13
|
+
}, {
|
|
14
|
+
id: 'step3',
|
|
15
|
+
title: 'Step 3',
|
|
16
|
+
status: 'pending'
|
|
17
|
+
}, {
|
|
18
|
+
id: 'step4',
|
|
19
|
+
title: 'Step 4',
|
|
20
|
+
status: 'pending'
|
|
21
|
+
}];
|
|
22
|
+
return (
|
|
23
|
+
/*#__PURE__*/
|
|
24
|
+
// Uncomment <Grommet> lines when using outside of storybook
|
|
25
|
+
// <Grommet theme={...}>
|
|
26
|
+
React.createElement(Box, {
|
|
27
|
+
pad: "large"
|
|
28
|
+
}, /*#__PURE__*/React.createElement(Stepper, {
|
|
29
|
+
steps: steps,
|
|
30
|
+
currentStep: "step3",
|
|
31
|
+
clickableSteps: false
|
|
32
|
+
}))
|
|
33
|
+
// </Grommet>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
export default {
|
|
37
|
+
title: 'Visualizations/Stepper/Read-Only'
|
|
38
|
+
};
|
|
39
|
+
export { ReadOnly };
|