Skip to content

Commit cdb022d

Browse files
committed
feat/navigation
- isNavigationEnabled: optional boolean
1 parent a3c396b commit cdb022d

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ Common date-time formats can be viewed [here](https://docs.sheetjs.com/docs/csf/
205205
autoMapHeaders?: boolean
206206
// Headers matching accuracy: 1 for strict and up for more flexible matching. Default: 2
207207
autoMapDistance?: number
208+
// Enable navigation in stepper component and show back button. Default: false
209+
isNavigationEnabled?: boolean
208210
```
209211

210212
## Customisation

src/steps/Steps.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { steps, stepTypeToStepIndex, stepIndexToStepType } from "../utils/steps"
1010
const CheckIcon = ({ color }: { color: string }) => <CgCheck size="2.25rem" color={color} />
1111

1212
export const Steps = () => {
13-
const { initialStepState, translations } = useRsi()
13+
const { initialStepState, translations, isNavigationEnabled } = useRsi()
1414

1515
const initialStep = stepTypeToStepIndex(initialStepState?.type)
1616

@@ -45,13 +45,17 @@ export const Steps = () => {
4545
return (
4646
<>
4747
<ModalHeader display={["none", "none", "block"]}>
48-
<Stepper activeStep={activeStep} checkIcon={CheckIcon} onClickStep={onClickStep}>
48+
<Stepper
49+
activeStep={activeStep}
50+
checkIcon={CheckIcon}
51+
onClickStep={isNavigationEnabled ? onClickStep : undefined}
52+
>
4953
{steps.map((key) => (
5054
<Step label={translations[key].title} key={key} />
5155
))}
5256
</Stepper>
5357
</ModalHeader>
54-
<UploadFlow state={state} onNext={onNext} onBack={onBack} />
58+
<UploadFlow state={state} onNext={onNext} onBack={isNavigationEnabled ? onBack : undefined} />
5559
</>
5660
)
5761
}

src/stories/Default.stories.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@ export const Basic = () => {
2222
<Link href="./exampleFile.csv" border="2px solid #718096" p="8px" borderRadius="8px" download="exampleCSV">
2323
Download example file
2424
</Link>
25-
<ReactSpreadsheetImport {...mockRsiValues} isOpen={isOpen} onClose={onClose} onSubmit={setData} />
25+
<ReactSpreadsheetImport
26+
{...mockRsiValues}
27+
isOpen={isOpen}
28+
onClose={onClose}
29+
onSubmit={setData}
30+
isNavigationEnabled={true}
31+
/>
2632
{!!data && (
2733
<Box pt={64} display="flex" gap="8px" flexDirection="column">
2834
<b>Returned data (showing first 100 rows):</b>

src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ export type RsiProps<T extends string> = {
2525
onSubmit: (data: Result<T>, file: File) => void
2626
// Allows submitting with errors. Default: true
2727
allowInvalidSubmit?: boolean
28+
// Enable navigation in stepper component and show back button. Default: false
29+
isNavigationEnabled?: boolean
2830
// Translations for each text
2931
translations?: TranslationsRSIProps
3032
// Theme configuration passed to underlying Chakra-UI

0 commit comments

Comments
 (0)