@indico-data/design-system 2.0.3 → 2.1.3
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/.commitlintrc.ts +13 -0
- package/.harness/pipeline.yaml +1 -1
- package/.releaserc.json +16 -1
- package/README.md +57 -27
- package/lib/index.css +84 -67
- package/lib/index.d.ts +49 -156
- package/lib/index.esm.css +84 -67
- package/lib/index.esm.js +1 -287
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +0 -291
- package/lib/index.js.map +1 -1
- package/lib/legacy/components/index.d.ts +0 -2
- package/package.json +4 -3
- package/src/components/button/{Button.scss → styles/Button.scss} +5 -69
- package/src/components/button/styles/_variables.scss +89 -0
- package/src/index.ts +0 -5
- package/src/legacy/components/index.ts +0 -2
- package/src/styles/index.scss +1 -1
- package/src/styles/variables/themes/dark.scss +70 -74
- package/src/stylesAndAnimations/colors/constants.ts +60 -60
- package/lib/legacy/components/Wizard/Wizard.d.ts +0 -48
- package/lib/legacy/components/Wizard/Wizard.stories.d.ts +0 -29
- package/lib/legacy/components/Wizard/Wizard.styles.d.ts +0 -4
- package/lib/legacy/components/Wizard/index.d.ts +0 -2
- package/lib/legacy/components/WizardWithSidebar/WizardWithSidebar.d.ts +0 -58
- package/lib/legacy/components/WizardWithSidebar/WizardWithSidebar.stories.d.ts +0 -46
- package/lib/legacy/components/WizardWithSidebar/WizardWithSidebar.styles.d.ts +0 -9
- package/lib/legacy/components/WizardWithSidebar/index.d.ts +0 -2
- package/src/legacy/components/Wizard/Wizard.stories.tsx +0 -180
- package/src/legacy/components/Wizard/Wizard.styles.ts +0 -72
- package/src/legacy/components/Wizard/Wizard.tsx +0 -211
- package/src/legacy/components/Wizard/index.ts +0 -2
- package/src/legacy/components/WizardWithSidebar/WizardWithSidebar.stories.tsx +0 -143
- package/src/legacy/components/WizardWithSidebar/WizardWithSidebar.styles.ts +0 -107
- package/src/legacy/components/WizardWithSidebar/WizardWithSidebar.tsx +0 -278
- package/src/legacy/components/WizardWithSidebar/index.ts +0 -2
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { PermafrostComponent } from '@/types';
|
|
3
|
-
export type CancelText = {
|
|
4
|
-
confirmText: string;
|
|
5
|
-
message?: string;
|
|
6
|
-
rejectText: string;
|
|
7
|
-
title: string;
|
|
8
|
-
};
|
|
9
|
-
type Props = PermafrostComponent & {
|
|
10
|
-
children: React.ReactNode;
|
|
11
|
-
/**
|
|
12
|
-
* text for the cancel confirmation modal
|
|
13
|
-
*/
|
|
14
|
-
confirmCancel: CancelText;
|
|
15
|
-
disableNextStep?: boolean;
|
|
16
|
-
disablePrevStep?: boolean;
|
|
17
|
-
disableSubmit?: boolean;
|
|
18
|
-
isLastStep?: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* for testing/mocking purposes
|
|
21
|
-
*/
|
|
22
|
-
startingStep?: string;
|
|
23
|
-
stepSchema: {
|
|
24
|
-
[key: string]: {
|
|
25
|
-
inputsRequiringValidation: string[];
|
|
26
|
-
description: string[];
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* the text to appear on the submit button
|
|
31
|
-
*/
|
|
32
|
-
submitButtonLabel: string;
|
|
33
|
-
/**
|
|
34
|
-
* Puts button in "busy" mode, and replaces button label with this text
|
|
35
|
-
*/
|
|
36
|
-
submitProcessing?: string;
|
|
37
|
-
wizardTitle: string;
|
|
38
|
-
onCancel?(): void;
|
|
39
|
-
onNextPress?(): boolean;
|
|
40
|
-
/**
|
|
41
|
-
* returns the current step name to the parent component
|
|
42
|
-
*/
|
|
43
|
-
onStepChange(stepName: string): void;
|
|
44
|
-
onSubmit(): void;
|
|
45
|
-
/**
|
|
46
|
-
* Allows for any custom attribute to be added directly to "next button" in wizard
|
|
47
|
-
*/
|
|
48
|
-
nextButtonProps?: {
|
|
49
|
-
'data-cy': string;
|
|
50
|
-
};
|
|
51
|
-
bottomNav?: boolean;
|
|
52
|
-
validationErrors?: any;
|
|
53
|
-
backgroundColor?: string;
|
|
54
|
-
color?: string;
|
|
55
|
-
buttonColor?: string;
|
|
56
|
-
};
|
|
57
|
-
export declare function WizardWithSidebar(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
58
|
-
export {};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type { StoryObj } from '@storybook/react';
|
|
2
|
-
import { WizardWithSidebar } from './WizardWithSidebar';
|
|
3
|
-
declare const meta: {
|
|
4
|
-
component: typeof WizardWithSidebar;
|
|
5
|
-
title: string;
|
|
6
|
-
args: {
|
|
7
|
-
buttonColor: string;
|
|
8
|
-
backgroundColor: string;
|
|
9
|
-
color: string;
|
|
10
|
-
stepSchema: {
|
|
11
|
-
'Library Details': {
|
|
12
|
-
inputsRequiringValidation: string[];
|
|
13
|
-
description: never[];
|
|
14
|
-
};
|
|
15
|
-
'Configure Source': {
|
|
16
|
-
inputsRequiringValidation: never[];
|
|
17
|
-
description: string[];
|
|
18
|
-
};
|
|
19
|
-
Summary: {
|
|
20
|
-
inputsRequiringValidation: never[];
|
|
21
|
-
description: never[];
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
onCancel: () => void;
|
|
25
|
-
onSubmit: () => void;
|
|
26
|
-
wizardTitle: string;
|
|
27
|
-
confirmCancel: {
|
|
28
|
-
title: string;
|
|
29
|
-
message: string;
|
|
30
|
-
confirmText: string;
|
|
31
|
-
rejectText: string;
|
|
32
|
-
};
|
|
33
|
-
submitButtonLabel: string;
|
|
34
|
-
onNextPress: () => true;
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
export default meta;
|
|
38
|
-
type Story = StoryObj<typeof WizardWithSidebar>;
|
|
39
|
-
export declare const FirstStep: Story;
|
|
40
|
-
export declare const SecondStep: Story;
|
|
41
|
-
export declare const LastStep: Story;
|
|
42
|
-
export declare const DisabledNextStep: Story;
|
|
43
|
-
export declare const DisabledPreviousStep: Story;
|
|
44
|
-
export declare const SubmitProcessing: Story;
|
|
45
|
-
export declare const LastStepOverride: Story;
|
|
46
|
-
export declare const WithValidationErrors: Story;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
export declare const StyledWizardWithSidebar: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
3
|
-
backgroundcolor?: string | undefined;
|
|
4
|
-
color?: string | undefined;
|
|
5
|
-
buttoncolor?: string | undefined;
|
|
6
|
-
className?: string | undefined;
|
|
7
|
-
"data-cy"?: string | undefined;
|
|
8
|
-
id?: string | undefined;
|
|
9
|
-
}>>;
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
-
|
|
4
|
-
import { Wizard } from './Wizard';
|
|
5
|
-
import { WizardCard, WizardSection } from './Wizard.styles';
|
|
6
|
-
|
|
7
|
-
const meta = {
|
|
8
|
-
component: Wizard,
|
|
9
|
-
title: 'legacy/wizards/Wizard',
|
|
10
|
-
args: {
|
|
11
|
-
steps: ['Task Details', 'Labels and Keywords', 'Labelers'],
|
|
12
|
-
onCancel: () => console.info('cancelling'),
|
|
13
|
-
onSubmit: () => console.info('submitting'),
|
|
14
|
-
wizardTitle: 'New Teach Task',
|
|
15
|
-
confirmCancel: {
|
|
16
|
-
title: 'Are you sure you want to stop creating this Task?',
|
|
17
|
-
message: 'Your Task will not be saved, nor available to be labeled.',
|
|
18
|
-
confirmText: 'Yes, go ahead',
|
|
19
|
-
rejectText: 'No, go back',
|
|
20
|
-
},
|
|
21
|
-
submitButtonLabel: 'Add Teach Task',
|
|
22
|
-
// Evidently, we need to add this prop or its corresponding logic within the component evaluates to false in storybook.
|
|
23
|
-
// Was not happening in earlier version, so was not necessary.
|
|
24
|
-
onNextPress: () => true,
|
|
25
|
-
},
|
|
26
|
-
} satisfies Meta<typeof Wizard>;
|
|
27
|
-
|
|
28
|
-
export default meta;
|
|
29
|
-
type Story = StoryObj<typeof Wizard>;
|
|
30
|
-
|
|
31
|
-
function StoryRender(props: any) {
|
|
32
|
-
const [currentStep, setCurrentStep] = useState('');
|
|
33
|
-
|
|
34
|
-
const currentStepContent = () => {
|
|
35
|
-
if (currentStep === 'Task Details') {
|
|
36
|
-
return (
|
|
37
|
-
<WizardCard>
|
|
38
|
-
<WizardSection>
|
|
39
|
-
<h2 className="section-heading">Task Name</h2>
|
|
40
|
-
|
|
41
|
-
<div className="section-content">hello yes this is dog</div>
|
|
42
|
-
</WizardSection>
|
|
43
|
-
|
|
44
|
-
<WizardSection>
|
|
45
|
-
<h2 className="section-heading">Dataset</h2>
|
|
46
|
-
|
|
47
|
-
<div className="section-content" />
|
|
48
|
-
</WizardSection>
|
|
49
|
-
|
|
50
|
-
<WizardSection>
|
|
51
|
-
<h2 className="section-heading">
|
|
52
|
-
Processors and Branches <span className="supporting-text">(Optional)</span>
|
|
53
|
-
</h2>
|
|
54
|
-
|
|
55
|
-
<div className="section-content" />
|
|
56
|
-
</WizardSection>
|
|
57
|
-
</WizardCard>
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (currentStep === 'Labels and Keywords') {
|
|
62
|
-
return (
|
|
63
|
-
<WizardCard>
|
|
64
|
-
<WizardSection>
|
|
65
|
-
<h2 className="section-heading">Labels</h2>
|
|
66
|
-
|
|
67
|
-
<div className="section-content" />
|
|
68
|
-
</WizardSection>
|
|
69
|
-
|
|
70
|
-
<WizardSection>
|
|
71
|
-
<h2 className="section-heading">Label Predictions</h2>
|
|
72
|
-
|
|
73
|
-
<div className="section-content" />
|
|
74
|
-
</WizardSection>
|
|
75
|
-
|
|
76
|
-
<WizardSection>
|
|
77
|
-
<h2 className="section-heading">
|
|
78
|
-
Keywords <span className="supporting-text">(Optional)</span>
|
|
79
|
-
</h2>
|
|
80
|
-
|
|
81
|
-
<div className="section-content" />
|
|
82
|
-
</WizardSection>
|
|
83
|
-
</WizardCard>
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (currentStep === 'Labelers') {
|
|
88
|
-
return (
|
|
89
|
-
<WizardCard>
|
|
90
|
-
<WizardSection>
|
|
91
|
-
<h2 className="section-heading">Labelers Required Per Example</h2>
|
|
92
|
-
|
|
93
|
-
<div className="section-content" />
|
|
94
|
-
</WizardSection>
|
|
95
|
-
|
|
96
|
-
<WizardSection>
|
|
97
|
-
<h2 className="section-heading">
|
|
98
|
-
Team
|
|
99
|
-
<span className="supporting-text" style={{ marginLeft: '0.25em' }}>
|
|
100
|
-
1
|
|
101
|
-
</span>
|
|
102
|
-
</h2>
|
|
103
|
-
|
|
104
|
-
<div className="section-content" />
|
|
105
|
-
</WizardSection>
|
|
106
|
-
</WizardCard>
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
return (
|
|
112
|
-
<Wizard {...props} onStepChange={(step) => setCurrentStep(step)}>
|
|
113
|
-
{currentStepContent()}
|
|
114
|
-
</Wizard>
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export const Normal: Story = {
|
|
119
|
-
args: {
|
|
120
|
-
startingStep: 'Labels and Keywords',
|
|
121
|
-
},
|
|
122
|
-
render: (args) => {
|
|
123
|
-
return <StoryRender {...args} />;
|
|
124
|
-
},
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
export const FirstStep: Story = {
|
|
128
|
-
// args: {},
|
|
129
|
-
render: (args) => {
|
|
130
|
-
return <StoryRender {...args} />;
|
|
131
|
-
},
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
export const LastStep: Story = {
|
|
135
|
-
args: {
|
|
136
|
-
startingStep: 'Labelers',
|
|
137
|
-
},
|
|
138
|
-
render: (args) => {
|
|
139
|
-
return <StoryRender {...args} />;
|
|
140
|
-
},
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
export const DisabledNextStep: Story = {
|
|
144
|
-
args: {
|
|
145
|
-
disableNextStep: true,
|
|
146
|
-
},
|
|
147
|
-
render: (args) => {
|
|
148
|
-
return <StoryRender {...args} />;
|
|
149
|
-
},
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
export const DisabledPreviousStep: Story = {
|
|
153
|
-
args: {
|
|
154
|
-
startingStep: 'Labels and Keywords',
|
|
155
|
-
disablePrevStep: true,
|
|
156
|
-
},
|
|
157
|
-
render: (args) => {
|
|
158
|
-
return <StoryRender {...args} />;
|
|
159
|
-
},
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
export const SubmitProcessing: Story = {
|
|
163
|
-
args: {
|
|
164
|
-
submitProcessing: 'Adding Teach Task',
|
|
165
|
-
startingStep: 'Labelers',
|
|
166
|
-
},
|
|
167
|
-
render: (args) => {
|
|
168
|
-
return <StoryRender {...args} />;
|
|
169
|
-
},
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
export const LastStepOverride: Story = {
|
|
173
|
-
args: {
|
|
174
|
-
startingStep: 'Labelers',
|
|
175
|
-
isLastStep: false,
|
|
176
|
-
},
|
|
177
|
-
render: (args) => {
|
|
178
|
-
return <StoryRender {...args} />;
|
|
179
|
-
},
|
|
180
|
-
};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
|
|
3
|
-
import { COLORS, TYPOGRAPHY } from '@/legacy/tokens';
|
|
4
|
-
|
|
5
|
-
export const StyledWizard = styled.div`
|
|
6
|
-
nav {
|
|
7
|
-
display: flex;
|
|
8
|
-
align-items: center;
|
|
9
|
-
justify-content: space-between;
|
|
10
|
-
|
|
11
|
-
margin-bottom: 24px;
|
|
12
|
-
|
|
13
|
-
// override for some styling in AppChrome IPA component
|
|
14
|
-
padding-left: 0 !important;
|
|
15
|
-
padding-right: 0 !important;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
h1 {
|
|
19
|
-
margin-bottom: 0;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.wizard-buttons {
|
|
23
|
-
display: flex;
|
|
24
|
-
align-items: center;
|
|
25
|
-
|
|
26
|
-
font-size: ${TYPOGRAPHY.fontSize.subheadLarge};
|
|
27
|
-
|
|
28
|
-
button.link-style {
|
|
29
|
-
font-size: inherit;
|
|
30
|
-
margin-right: 1em;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
`;
|
|
34
|
-
|
|
35
|
-
const commonPadding = '20px';
|
|
36
|
-
|
|
37
|
-
// todo: permafrost: move into css fragment at top level
|
|
38
|
-
export const WizardCard = styled.div`
|
|
39
|
-
width: 100%;
|
|
40
|
-
padding: 14px ${commonPadding};
|
|
41
|
-
|
|
42
|
-
background-color: ${COLORS.clay};
|
|
43
|
-
border: 1px solid ${COLORS.oxfordBlue};
|
|
44
|
-
border-radius: 4px;
|
|
45
|
-
box-shadow: 1px 1px 1px 0 ${COLORS.ebony};
|
|
46
|
-
`;
|
|
47
|
-
|
|
48
|
-
export const WizardSection = styled.div`
|
|
49
|
-
.section-heading {
|
|
50
|
-
margin-bottom: 0;
|
|
51
|
-
// todo: store value elsewhere
|
|
52
|
-
font-size: 22px;
|
|
53
|
-
color: ${COLORS.lightFontColor};
|
|
54
|
-
|
|
55
|
-
.supporting-text {
|
|
56
|
-
font-size: ${TYPOGRAPHY.fontSize.subheadLarge};
|
|
57
|
-
color: ${COLORS.defaultFontColor};
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.section-content {
|
|
62
|
-
padding: ${commonPadding};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
:not(:last-of-type) {
|
|
66
|
-
margin-bottom: ${commonPadding};
|
|
67
|
-
|
|
68
|
-
.section-content {
|
|
69
|
-
border-bottom: 1px solid ${COLORS.ebony};
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
`;
|
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
// TODO: This component's migration was fast-tracked for Insights. Assess for potential refactor and documentation.
|
|
2
|
-
|
|
3
|
-
import React, { useEffect, useMemo, useState } from 'react';
|
|
4
|
-
|
|
5
|
-
import { Button, ConfirmModal, IconButton } from '@/legacy/components';
|
|
6
|
-
import { PermafrostComponent, ButtonSize } from '@/types';
|
|
7
|
-
|
|
8
|
-
import { StyledWizard } from './Wizard.styles';
|
|
9
|
-
|
|
10
|
-
export type CancelText = {
|
|
11
|
-
// "confirm" button text
|
|
12
|
-
confirmText: string;
|
|
13
|
-
message?: string;
|
|
14
|
-
// "reject" button text
|
|
15
|
-
rejectText: string;
|
|
16
|
-
title: string;
|
|
17
|
-
// Optional, supporting text
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
type Props = PermafrostComponent & {
|
|
21
|
-
children: React.ReactNode;
|
|
22
|
-
/**
|
|
23
|
-
* text for the cancel confirmation modal
|
|
24
|
-
*/
|
|
25
|
-
confirmCancel: CancelText;
|
|
26
|
-
disableNextStep?: boolean;
|
|
27
|
-
disablePrevStep?: boolean;
|
|
28
|
-
disableSubmit?: boolean;
|
|
29
|
-
isLastStep?: boolean;
|
|
30
|
-
/**
|
|
31
|
-
* for testing/mocking purposes
|
|
32
|
-
*/
|
|
33
|
-
startingStep?: string;
|
|
34
|
-
steps: string[];
|
|
35
|
-
/**
|
|
36
|
-
* the text to appear on the submit button
|
|
37
|
-
*/
|
|
38
|
-
submitButtonLabel: string;
|
|
39
|
-
/**
|
|
40
|
-
* Puts button in "busy" mode, and replaces button label with this text
|
|
41
|
-
*/
|
|
42
|
-
submitProcessing?: string;
|
|
43
|
-
wizardTitle: string;
|
|
44
|
-
onCancel?(): void;
|
|
45
|
-
onNextPress?(): boolean;
|
|
46
|
-
/**
|
|
47
|
-
* returns the current step name to the parent component
|
|
48
|
-
*/
|
|
49
|
-
onStepChange(stepName: string): void;
|
|
50
|
-
onSubmit(): void;
|
|
51
|
-
/**
|
|
52
|
-
* Allows for any custom attribute to be added directly to "next button" in wizard
|
|
53
|
-
*/
|
|
54
|
-
nextButtonProps?: {
|
|
55
|
-
'data-cy': string;
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const commonButtonProps = {
|
|
60
|
-
size: 'large' as ButtonSize,
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export function Wizard(props: Props) {
|
|
64
|
-
const {
|
|
65
|
-
children,
|
|
66
|
-
className,
|
|
67
|
-
confirmCancel,
|
|
68
|
-
disableNextStep,
|
|
69
|
-
disablePrevStep,
|
|
70
|
-
disableSubmit,
|
|
71
|
-
id,
|
|
72
|
-
isLastStep,
|
|
73
|
-
onCancel,
|
|
74
|
-
onNextPress,
|
|
75
|
-
onStepChange,
|
|
76
|
-
onSubmit,
|
|
77
|
-
startingStep,
|
|
78
|
-
steps,
|
|
79
|
-
submitButtonLabel,
|
|
80
|
-
submitProcessing = '',
|
|
81
|
-
wizardTitle,
|
|
82
|
-
nextButtonProps,
|
|
83
|
-
} = props;
|
|
84
|
-
|
|
85
|
-
const [currentStep, setCurrentStep] = useState<string>(startingStep || steps[0]);
|
|
86
|
-
const [openCancelConfirm, setOpenCancelConfirm] = useState<boolean>(false);
|
|
87
|
-
|
|
88
|
-
const onLastStep: boolean = useMemo(() => {
|
|
89
|
-
if (isLastStep !== undefined) {
|
|
90
|
-
return isLastStep;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return steps.indexOf(currentStep) === steps.length - 1;
|
|
94
|
-
}, [isLastStep, steps, currentStep]);
|
|
95
|
-
|
|
96
|
-
const isBusy = !!(submitProcessing && submitProcessing.length > 0);
|
|
97
|
-
|
|
98
|
-
const nextStep = () => {
|
|
99
|
-
if (!onLastStep) {
|
|
100
|
-
const currentIndex = steps.indexOf(currentStep);
|
|
101
|
-
|
|
102
|
-
setCurrentStep(steps[currentIndex + 1]);
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
const prevStep = () => {
|
|
107
|
-
const currentIndex = steps.indexOf(currentStep);
|
|
108
|
-
|
|
109
|
-
if (currentIndex !== 0) {
|
|
110
|
-
setCurrentStep(steps[currentIndex - 1]);
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
// handles the user's selection in the cancel confirmation modal
|
|
115
|
-
const handleCancelRequest = (confirmCancel: boolean) => {
|
|
116
|
-
if (confirmCancel && onCancel) {
|
|
117
|
-
onCancel();
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
setOpenCancelConfirm(false);
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
const handleNextPress = () => {
|
|
124
|
-
const allowNext = onNextPress ? onNextPress() : true;
|
|
125
|
-
|
|
126
|
-
if (!allowNext) {
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (onLastStep) {
|
|
131
|
-
handleSubmit();
|
|
132
|
-
} else {
|
|
133
|
-
nextStep();
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
const handleSubmit = () => {
|
|
138
|
-
onSubmit();
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
// report current step to the consuming component
|
|
142
|
-
useEffect(() => {
|
|
143
|
-
onStepChange(currentStep);
|
|
144
|
-
}, [currentStep]);
|
|
145
|
-
|
|
146
|
-
// ensures `currentStep` is reset on unmount, just in case
|
|
147
|
-
useEffect(() => {
|
|
148
|
-
return () => setCurrentStep(steps[0] || '');
|
|
149
|
-
}, []);
|
|
150
|
-
|
|
151
|
-
return (
|
|
152
|
-
<StyledWizard className={className} data-cy={props['data-cy']} id={id}>
|
|
153
|
-
<nav>
|
|
154
|
-
<h1>
|
|
155
|
-
{wizardTitle}: {currentStep}
|
|
156
|
-
</h1>
|
|
157
|
-
|
|
158
|
-
<div className="wizard-buttons">
|
|
159
|
-
<Button onClick={() => setOpenCancelConfirm(true)} variant="link-style">
|
|
160
|
-
Cancel
|
|
161
|
-
</Button>
|
|
162
|
-
|
|
163
|
-
{steps.indexOf(currentStep) !== 0 && (
|
|
164
|
-
<IconButton
|
|
165
|
-
{...commonButtonProps}
|
|
166
|
-
iconName="fa-arrow-left"
|
|
167
|
-
label="Previous Step"
|
|
168
|
-
onPress={prevStep}
|
|
169
|
-
isDisabled={disablePrevStep}
|
|
170
|
-
/>
|
|
171
|
-
)}
|
|
172
|
-
|
|
173
|
-
{onLastStep ? (
|
|
174
|
-
<IconButton
|
|
175
|
-
{...commonButtonProps}
|
|
176
|
-
variant="primary"
|
|
177
|
-
iconName="check"
|
|
178
|
-
busy={isBusy}
|
|
179
|
-
label={isBusy ? submitProcessing : submitButtonLabel}
|
|
180
|
-
onPress={handleNextPress}
|
|
181
|
-
isDisabled={disableSubmit}
|
|
182
|
-
/>
|
|
183
|
-
) : (
|
|
184
|
-
<IconButton
|
|
185
|
-
{...commonButtonProps}
|
|
186
|
-
variant="primary"
|
|
187
|
-
iconSide="end"
|
|
188
|
-
iconName="fa-arrow-right"
|
|
189
|
-
label="Next Step"
|
|
190
|
-
onPress={handleNextPress}
|
|
191
|
-
isDisabled={disableNextStep}
|
|
192
|
-
{...nextButtonProps}
|
|
193
|
-
/>
|
|
194
|
-
)}
|
|
195
|
-
</div>
|
|
196
|
-
</nav>
|
|
197
|
-
|
|
198
|
-
<>{children}</>
|
|
199
|
-
|
|
200
|
-
<ConfirmModal
|
|
201
|
-
title={confirmCancel.title}
|
|
202
|
-
message={confirmCancel.message}
|
|
203
|
-
confirmText={confirmCancel.confirmText}
|
|
204
|
-
rejectText={confirmCancel.rejectText}
|
|
205
|
-
open={openCancelConfirm}
|
|
206
|
-
clickOutsideHandler={() => setOpenCancelConfirm(false)}
|
|
207
|
-
responseHandler={handleCancelRequest}
|
|
208
|
-
/>
|
|
209
|
-
</StyledWizard>
|
|
210
|
-
);
|
|
211
|
-
}
|