-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e43632e
commit e042451
Showing
15 changed files
with
403 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 22 additions & 42 deletions
64
packages/stepper/src/components/StepperForm/StepperForm.component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
packages/stepper/src/components/StepperForm/StepperForm.context.ts
This file was deleted.
Oops, something went wrong.
55 changes: 55 additions & 0 deletions
55
packages/stepper/src/components/StepperForm/StepperForm.context.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { createContext, ReactNode } from 'react'; | ||
|
||
import { useStepperForm } from '../../hooks/useStepperForm/useStepperForm.hook'; | ||
import { StepperState } from '../../hooks/useStepperForm/useStepperForm.types'; | ||
import { StepperStep } from './StepperForm.types'; | ||
|
||
const emptyFn = () => {}; | ||
|
||
interface StepperFormValues { | ||
currentStep: number; | ||
onDisableStep: (stepKey: string, cause: string) => void; | ||
onEnableStep: (stepKey: string) => void; | ||
onNext: () => void; | ||
onPrevious: () => void; | ||
steps: StepperState; | ||
} | ||
|
||
export const StepperFormContext = createContext<StepperFormValues>({ | ||
onDisableStep: emptyFn, | ||
onEnableStep: emptyFn, | ||
onNext: emptyFn, | ||
onPrevious: emptyFn, | ||
steps: [], | ||
currentStep: 0, | ||
}); | ||
|
||
export interface StepperFormProviderProps { | ||
children: ReactNode; | ||
initialStepIndex: number; | ||
steps: StepperStep[]; | ||
} | ||
|
||
export const StepperFormContextProvider = ({ | ||
children, | ||
initialStepIndex, | ||
steps, | ||
}: StepperFormProviderProps) => { | ||
const { currentStep, onDisableStep, onEnableStep, onNextStep, onPreviousStep, stepperSteps } = | ||
useStepperForm(steps, initialStepIndex); | ||
|
||
return ( | ||
<StepperFormContext.Provider | ||
value={{ | ||
currentStep, | ||
onDisableStep, | ||
onEnableStep, | ||
onNext: onNextStep, | ||
onPrevious: onPreviousStep, | ||
steps: stepperSteps, | ||
}} | ||
> | ||
{children} | ||
</StepperFormContext.Provider> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,10 @@ | |
|
||
&__content { | ||
height: calc(100% - 11.5rem); | ||
|
||
fieldset { | ||
height: 100%; | ||
} | ||
} | ||
|
||
&__footer { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
packages/stepper/src/components/StepperForm/StepperFormFooter/StepperFormFooter.types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
packages/stepper/src/components/StepperForm/StepperFormFooter/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import StepperFormFooter from './StepperFormFooter.component'; | ||
|
||
export default StepperFormFooter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
import StepperForm from './StepperForm.component'; | ||
import StepperFormFooter from './StepperFormFooter'; | ||
import { StepperFormContextProvider } from './StepperForm.context'; | ||
|
||
export default StepperForm; | ||
const StepperFormComponent = StepperForm as typeof StepperForm & { | ||
ContextProvider: typeof StepperFormContextProvider; | ||
Footer: typeof StepperFormFooter; | ||
}; | ||
|
||
StepperFormComponent.ContextProvider = StepperFormContextProvider; | ||
StepperFormComponent.Footer = StepperFormFooter; | ||
|
||
export default StepperFormComponent; |
Oops, something went wrong.