@registrucentras/rc-ses-react-components 1.4.0 → 1.5.0
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/dist/components/common/Accordion/hooks/useAccordionController.d.ts +1 -0
- package/dist/components/common/Card/index.d.ts +7 -2
- package/dist/components/common/ImageCard/index.d.ts +13 -0
- package/dist/components/common/ListWithIcons/components/ListWithIconsItem.d.ts +9 -0
- package/dist/components/common/ListWithIcons/index.d.ts +14 -0
- package/dist/components/layout/Footer/index.d.ts +5 -0
- package/dist/components/layout/ServiceFormContainer/{components → AccordionFormContainer/components}/AccordionCollapseControls.d.ts +1 -1
- package/dist/components/layout/ServiceFormContainer/{index.d.ts → AccordionFormContainer/index.d.ts} +1 -1
- package/dist/components/layout/ServiceFormContainer/AccordionFormContainer/utils.d.ts +4 -0
- package/dist/components/layout/ServiceFormContainer/CardFormContainer/index.d.ts +12 -0
- package/dist/components/layout/ServiceWizardStepper/StepperTypes.d.ts +0 -3
- package/dist/components/layout/ServiceWizardStepper/components/DesktopStepper.d.ts +3 -1
- package/dist/components/layout/ServiceWizardStepper/components/MobileStepper.d.ts +2 -1
- package/dist/components/layout/ServiceWizardStepper/components/StyledStepLabel.d.ts +2 -2
- package/dist/components/layout/ServiceWizardStepper/index.d.ts +5 -2
- package/dist/library/icons.d.ts +1 -3
- package/dist/library/index.d.ts +12 -16
- package/dist/library/types.d.ts +6 -0
- package/dist/registrucentras-rc-ses-react-components.cjs +12 -12
- package/dist/registrucentras-rc-ses-react-components.js +2472 -2130
- package/dist/stories/ServiceWizardStepper.stories.d.ts +5 -5
- package/dist/stories/components/Card.stories.d.ts +26 -1
- package/dist/stories/components/ImageCard.stories.d.ts +8 -0
- package/dist/stories/components/ListWithIcons.stories.d.ts +33 -0
- package/dist/stories/components/form/CardFormContainer.stories.d.ts +7 -0
- package/dist/stories/components/form/ServiceFormContainer.stories.d.ts +1 -1
- package/dist/stories/components/inputs/FileDropzone.stories.d.ts +32 -0
- package/dist/stories/components/inputs/PhoneInput.stories.d.ts +24 -0
- package/dist/stories/components/inputs/SearchableField.stories.d.ts +2 -2
- package/dist/stories/components/inputs/Select.stories.d.ts +3 -3
- package/dist/stories/components/inputs/TextField.stories.d.ts +5 -5
- package/dist/stories/components/layout/Footer.stories.d.ts +8 -0
- package/package.json +1 -1
- package/src/App.tsx +4 -0
- package/src/components/common/Accordion/hooks/useAccordionController.tsx +43 -11
- package/src/components/common/Card/index.test.tsx +36 -0
- package/src/components/common/Card/index.tsx +62 -22
- package/src/components/common/DataPagination/components/PaginationButton.tsx +1 -1
- package/src/components/common/DataPagination/index.tsx +1 -1
- package/src/components/common/ImageCard/index.test.tsx +78 -0
- package/src/components/common/ImageCard/index.tsx +43 -0
- package/src/components/common/ListWithIcons/components/ListWithIconsItem.tsx +94 -0
- package/src/components/common/ListWithIcons/index.test.tsx +75 -0
- package/src/components/common/ListWithIcons/index.tsx +47 -0
- package/src/components/form/inputs/CheckboxFormControl.tsx +1 -1
- package/src/components/form/inputs/FileDropzone.tsx +1 -1
- package/src/components/form/inputs/FileUpload.tsx +9 -3
- package/src/components/form/inputs/NumberStepper.tsx +2 -2
- package/src/components/form/inputs/PhoneInputFormControl/components/RowComponent.tsx +1 -0
- package/src/components/form/inputs/RadioButtonGroup.tsx +1 -1
- package/src/components/layout/Footer/index.test.tsx +20 -0
- package/src/components/layout/Footer/index.tsx +33 -0
- package/src/components/layout/ServiceFormContainer/{index.tsx → AccordionFormContainer/index.tsx} +22 -5
- package/src/components/layout/ServiceFormContainer/{utils.ts → AccordionFormContainer/utils.ts} +2 -3
- package/src/components/layout/ServiceFormContainer/CardFormContainer/index.test.tsx +80 -0
- package/src/components/layout/ServiceFormContainer/CardFormContainer/index.tsx +71 -0
- package/src/components/layout/ServiceWizardStepper/ServiceWizardStepper.css +19 -3
- package/src/components/layout/ServiceWizardStepper/StepConnector.tsx +1 -1
- package/src/components/layout/ServiceWizardStepper/StepperTypes.ts +0 -3
- package/src/components/layout/ServiceWizardStepper/components/DesktopStepper.test.tsx +33 -4
- package/src/components/layout/ServiceWizardStepper/components/DesktopStepper.tsx +23 -4
- package/src/components/layout/ServiceWizardStepper/components/MobileStepper.test.tsx +34 -7
- package/src/components/layout/ServiceWizardStepper/components/MobileStepper.tsx +4 -2
- package/src/components/layout/ServiceWizardStepper/components/StyledStepLabel.tsx +8 -2
- package/src/components/layout/ServiceWizardStepper/index.tsx +19 -20
- package/src/examples/CardMultipleStepForm/index.tsx +80 -0
- package/src/examples/HorizontalMultiStepForm/index.tsx +22 -17
- package/src/examples/ListWithPagination/index.tsx +41 -11
- package/src/examples/MultipleStepForm/index.tsx +1 -1
- package/src/examples/SingleStepForm/index.tsx +1 -1
- package/src/library/icons.ts +3 -2
- package/src/library/index.ts +20 -23
- package/src/library/types.ts +11 -0
- package/src/main.tsx +5 -0
- package/src/stories/ServiceWizardStepper.stories.tsx +28 -14
- package/src/stories/components/Accordion.stories.tsx +1 -1
- package/src/stories/components/Card.stories.tsx +18 -0
- package/src/stories/components/ImageCard.stories.tsx +54 -0
- package/src/stories/components/ListWithIcons.stories.tsx +74 -0
- package/src/stories/components/form/CardFormContainer.stories.tsx +125 -0
- package/src/stories/components/form/ServiceFormContainer.stories.tsx +1 -1
- package/src/stories/components/inputs/FileDropzone.stories.tsx +117 -0
- package/src/stories/components/inputs/PhoneInput.stories.tsx +110 -0
- package/src/stories/components/layout/Footer.stories.tsx +19 -0
- package/src/theme/light/MuiAutocomplete.ts +4 -0
- package/src/theme/light/MuiCard.tsx +16 -2
- package/src/theme/light/MuiInputBase.ts +3 -1
- package/dist/components/layout/ServiceFormContainer/utils.d.ts +0 -4
- /package/src/components/layout/ServiceFormContainer/{components → AccordionFormContainer/components}/AccordionCollapseControls.tsx +0 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Container } from '@mui/material'
|
|
2
|
+
|
|
3
|
+
import RcSesCard, { RcSesCardProps } from '@/components/common/Card'
|
|
4
|
+
import ServiceWizardStepper from '@/components/layout/ServiceWizardStepper/'
|
|
5
|
+
|
|
6
|
+
import { StepItem } from '../../ServiceWizardStepper/StepperTypes'
|
|
7
|
+
|
|
8
|
+
export type LayoutMode = 'column' | 'row'
|
|
9
|
+
|
|
10
|
+
export interface RcSesCardFormContainerProps extends RcSesCardProps {
|
|
11
|
+
steps: StepItem[]
|
|
12
|
+
onStepClick?: (index: number) => void
|
|
13
|
+
activeStep: number
|
|
14
|
+
layout?: LayoutMode
|
|
15
|
+
isLoading?: boolean
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const RcSesCardFormContainer = ({
|
|
19
|
+
steps,
|
|
20
|
+
onStepClick,
|
|
21
|
+
activeStep,
|
|
22
|
+
layout,
|
|
23
|
+
children,
|
|
24
|
+
isLoading = false,
|
|
25
|
+
...cardProps
|
|
26
|
+
}: RcSesCardFormContainerProps) => {
|
|
27
|
+
const getLayoutDirection = () => {
|
|
28
|
+
if (layout != null) return layout
|
|
29
|
+
if (steps.length > 4) {
|
|
30
|
+
return 'row'
|
|
31
|
+
}
|
|
32
|
+
return 'column'
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const layoutDirection = getLayoutDirection()
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<Container
|
|
39
|
+
sx={{
|
|
40
|
+
display: 'flex',
|
|
41
|
+
flexDirection: {
|
|
42
|
+
xs: 'column',
|
|
43
|
+
md: getLayoutDirection(),
|
|
44
|
+
},
|
|
45
|
+
gap: '24px',
|
|
46
|
+
paddingBottom: '64px',
|
|
47
|
+
}}
|
|
48
|
+
>
|
|
49
|
+
{steps.length > 2 && (
|
|
50
|
+
<ServiceWizardStepper
|
|
51
|
+
steps={steps}
|
|
52
|
+
onStepClick={onStepClick}
|
|
53
|
+
activeStep={activeStep}
|
|
54
|
+
orientation={layoutDirection === 'row' ? 'vertical' : 'horizontal'}
|
|
55
|
+
isLoading={isLoading}
|
|
56
|
+
/>
|
|
57
|
+
)}
|
|
58
|
+
|
|
59
|
+
<RcSesCard
|
|
60
|
+
{...cardProps}
|
|
61
|
+
sx={{
|
|
62
|
+
width: '100%',
|
|
63
|
+
}}
|
|
64
|
+
>
|
|
65
|
+
{children}
|
|
66
|
+
</RcSesCard>
|
|
67
|
+
</Container>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export default RcSesCardFormContainer
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.ServiceWizardStepper {
|
|
1
|
+
.ServiceWizardStepper.ServiceWizardStepper-horizontal {
|
|
2
2
|
width: 100%;
|
|
3
3
|
}
|
|
4
4
|
|
|
@@ -17,10 +17,16 @@
|
|
|
17
17
|
.ServiceWizardStepper-MobileStepperContent {
|
|
18
18
|
flex: 1;
|
|
19
19
|
}
|
|
20
|
+
|
|
20
21
|
.MobileStepperWrapper {
|
|
21
22
|
gap: 12px;
|
|
22
23
|
}
|
|
23
24
|
|
|
25
|
+
.ServiceWizardStepper .MuiStep-root {
|
|
26
|
+
padding-left: 0px;
|
|
27
|
+
padding-right: 0px;
|
|
28
|
+
}
|
|
29
|
+
|
|
24
30
|
.ServiceWizardStepper .MuiStep-root:first-child,
|
|
25
31
|
.ServiceWizardStepper .MuiStep-root:last-child {
|
|
26
32
|
flex: 0.5;
|
|
@@ -36,6 +42,8 @@
|
|
|
36
42
|
|
|
37
43
|
.ServiceWizardStepper .MuiStep-root:first-child .MuiStepLabel-alternativeLabel {
|
|
38
44
|
text-align: left;
|
|
45
|
+
display: flex;
|
|
46
|
+
justify-content: flex-start;
|
|
39
47
|
}
|
|
40
48
|
|
|
41
49
|
.ServiceWizardStepper-horizontal .MuiStep-root:last-child .MuiStepLabel-root {
|
|
@@ -44,11 +52,19 @@
|
|
|
44
52
|
|
|
45
53
|
.ServiceWizardStepper .MuiStep-root:last-child .MuiStepLabel-alternativeLabel {
|
|
46
54
|
text-align: right;
|
|
55
|
+
display: flex;
|
|
56
|
+
justify-content: flex-end;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.ServiceWizardStepper .MuiStepLabel-alternativeLabel {
|
|
60
|
+
display: flex;
|
|
61
|
+
justify-content: center;
|
|
62
|
+
text-align: center;
|
|
47
63
|
}
|
|
48
64
|
|
|
49
65
|
.ServiceWizardStepper .MuiStep-root:last-child .MuiStepConnector-root {
|
|
50
|
-
left: calc(-100% +
|
|
51
|
-
right:
|
|
66
|
+
left: calc(-100% + 20px);
|
|
67
|
+
right: 30px;
|
|
52
68
|
}
|
|
53
69
|
|
|
54
70
|
.ServiceWizardStepper .MuiStep-root:nth-child(2) .MuiStepConnector-root {
|
|
@@ -4,11 +4,17 @@ import { StepItem } from '../StepperTypes'
|
|
|
4
4
|
import DesktopStepper from './DesktopStepper'
|
|
5
5
|
|
|
6
6
|
const steps: StepItem[] = [
|
|
7
|
-
{ id: '1', title: 'Step 1'
|
|
8
|
-
{ id: '2', title: 'Step 2'
|
|
9
|
-
{ id: '3', title: 'Step 3'
|
|
7
|
+
{ id: '1', title: 'Step 1' },
|
|
8
|
+
{ id: '2', title: 'Step 2' },
|
|
9
|
+
{ id: '3', title: 'Step 3' },
|
|
10
10
|
]
|
|
11
11
|
|
|
12
|
+
const getStepState = (index: number, activeStep: number) => {
|
|
13
|
+
if (index < activeStep) return 'completed'
|
|
14
|
+
if (index === activeStep) return 'active'
|
|
15
|
+
return 'pending'
|
|
16
|
+
}
|
|
17
|
+
|
|
12
18
|
describe('DesktopStepper', () => {
|
|
13
19
|
it('renders all steps', () => {
|
|
14
20
|
const { getByText } = render(
|
|
@@ -17,8 +23,10 @@ describe('DesktopStepper', () => {
|
|
|
17
23
|
activeStep={1}
|
|
18
24
|
handleStepClick={() => {}}
|
|
19
25
|
resolvedOrientation='horizontal'
|
|
26
|
+
getStepState={(index) => getStepState(index, 1)}
|
|
20
27
|
/>,
|
|
21
28
|
)
|
|
29
|
+
|
|
22
30
|
expect(getByText('Step 1')).toBeInTheDocument()
|
|
23
31
|
expect(getByText('Step 2')).toBeInTheDocument()
|
|
24
32
|
expect(getByText('Step 3')).toBeInTheDocument()
|
|
@@ -26,15 +34,36 @@ describe('DesktopStepper', () => {
|
|
|
26
34
|
|
|
27
35
|
it('calls handleStepClick when a step is clicked', () => {
|
|
28
36
|
const handleStepClick = vi.fn()
|
|
37
|
+
|
|
29
38
|
const { getByText } = render(
|
|
30
39
|
<DesktopStepper
|
|
31
40
|
stepEntries={steps}
|
|
32
41
|
activeStep={1}
|
|
33
42
|
handleStepClick={handleStepClick}
|
|
34
43
|
resolvedOrientation='horizontal'
|
|
44
|
+
getStepState={(index) => getStepState(index, 1)}
|
|
35
45
|
/>,
|
|
36
46
|
)
|
|
47
|
+
|
|
37
48
|
fireEvent.click(getByText('Step 1'))
|
|
38
|
-
expect(handleStepClick).
|
|
49
|
+
expect(handleStepClick).toHaveBeenCalledWith(0)
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
it('does not allow clicking future steps', () => {
|
|
53
|
+
const handleStepClick = vi.fn()
|
|
54
|
+
|
|
55
|
+
const { getByText } = render(
|
|
56
|
+
<DesktopStepper
|
|
57
|
+
stepEntries={steps}
|
|
58
|
+
activeStep={1}
|
|
59
|
+
handleStepClick={handleStepClick}
|
|
60
|
+
resolvedOrientation='horizontal'
|
|
61
|
+
getStepState={(index) => getStepState(index, 1)}
|
|
62
|
+
/>,
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
fireEvent.click(getByText('Step 3'))
|
|
66
|
+
|
|
67
|
+
expect(handleStepClick).not.toHaveBeenCalled()
|
|
39
68
|
})
|
|
40
69
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Step, StepButton, Stepper } from '@mui/material'
|
|
1
|
+
import { Skeleton, Step, StepButton, Stepper } from '@mui/material'
|
|
2
2
|
|
|
3
3
|
import StepConnector from '../StepConnector'
|
|
4
4
|
import { StepItem } from '../StepperTypes'
|
|
@@ -10,6 +10,8 @@ interface DesktopStepperProps {
|
|
|
10
10
|
activeStep: number
|
|
11
11
|
handleStepClick: (index: number) => void
|
|
12
12
|
resolvedOrientation: 'vertical' | 'horizontal'
|
|
13
|
+
isLoading?: boolean
|
|
14
|
+
getStepState: (index: number) => 'completed' | 'active' | 'pending'
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
const DesktopStepper = ({
|
|
@@ -17,6 +19,8 @@ const DesktopStepper = ({
|
|
|
17
19
|
activeStep,
|
|
18
20
|
handleStepClick,
|
|
19
21
|
resolvedOrientation,
|
|
22
|
+
isLoading = false,
|
|
23
|
+
getStepState,
|
|
20
24
|
}: DesktopStepperProps) => (
|
|
21
25
|
<Stepper
|
|
22
26
|
alternativeLabel={resolvedOrientation === 'horizontal'}
|
|
@@ -24,19 +28,34 @@ const DesktopStepper = ({
|
|
|
24
28
|
orientation={resolvedOrientation}
|
|
25
29
|
connector={resolvedOrientation === 'horizontal' ? <StepConnector /> : undefined}
|
|
26
30
|
className={`ServiceWizardStepper ServiceWizardStepper-${resolvedOrientation}`}
|
|
31
|
+
sx={
|
|
32
|
+
resolvedOrientation === 'vertical'
|
|
33
|
+
? {
|
|
34
|
+
width: 220,
|
|
35
|
+
flexShrink: 0,
|
|
36
|
+
alignSelf: 'flex-start',
|
|
37
|
+
}
|
|
38
|
+
: undefined
|
|
39
|
+
}
|
|
27
40
|
>
|
|
28
41
|
{stepEntries.map((step, index) => {
|
|
29
|
-
const isClickable = index <=
|
|
42
|
+
const isClickable = index <= activeStep
|
|
43
|
+
const stepState = getStepState(index)
|
|
44
|
+
|
|
30
45
|
return (
|
|
31
46
|
<Step key={step.id}>
|
|
32
47
|
<StepButton onClick={() => handleStepClick(index)} disabled={!isClickable}>
|
|
33
48
|
<StyledStepLabel
|
|
34
49
|
StepIconComponent={CustomStepIcon}
|
|
35
|
-
stepState={
|
|
50
|
+
stepState={stepState}
|
|
36
51
|
orientation={resolvedOrientation}
|
|
37
52
|
isLast={index === stepEntries.length - 1}
|
|
38
53
|
>
|
|
39
|
-
{
|
|
54
|
+
{isLoading ? (
|
|
55
|
+
<Skeleton variant='rounded' width={100} height={14} />
|
|
56
|
+
) : (
|
|
57
|
+
step.title
|
|
58
|
+
)}
|
|
40
59
|
</StyledStepLabel>
|
|
41
60
|
</StepButton>
|
|
42
61
|
</Step>
|
|
@@ -4,18 +4,45 @@ import { StepItem } from '../StepperTypes'
|
|
|
4
4
|
import MobileStepper from './MobileStepper'
|
|
5
5
|
|
|
6
6
|
const steps: StepItem[] = [
|
|
7
|
-
{ id: '1', title: 'Step 1'
|
|
8
|
-
{ id: '2', title: 'Step 2'
|
|
9
|
-
{ id: '3', title: 'Step 3'
|
|
7
|
+
{ id: '1', title: 'Step 1' },
|
|
8
|
+
{ id: '2', title: 'Step 2' },
|
|
9
|
+
{ id: '3', title: 'Step 3' },
|
|
10
10
|
]
|
|
11
11
|
|
|
12
|
+
const getStepState = (index: number, activeStep: number) => {
|
|
13
|
+
if (index < activeStep) return 'completed'
|
|
14
|
+
if (index === activeStep) return 'active'
|
|
15
|
+
return 'pending'
|
|
16
|
+
}
|
|
17
|
+
|
|
12
18
|
describe('MobileStepper', () => {
|
|
13
|
-
it('renders all steps', () => {
|
|
19
|
+
it('renders all steps and navigation button', () => {
|
|
20
|
+
render(
|
|
21
|
+
<MobileStepper
|
|
22
|
+
stepEntries={steps}
|
|
23
|
+
activeStep={1}
|
|
24
|
+
handleStepClick={() => {}}
|
|
25
|
+
getStepState={(index) => getStepState(index, 1)}
|
|
26
|
+
/>,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
const buttons = screen.getAllByRole('button')
|
|
30
|
+
|
|
31
|
+
expect(buttons).toHaveLength(steps.length + 1)
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('does not render back button on first step', () => {
|
|
14
35
|
render(
|
|
15
|
-
<MobileStepper
|
|
36
|
+
<MobileStepper
|
|
37
|
+
stepEntries={steps}
|
|
38
|
+
activeStep={0}
|
|
39
|
+
handleStepClick={() => {}}
|
|
40
|
+
getStepState={(index) => getStepState(index, 0)}
|
|
41
|
+
/>,
|
|
16
42
|
)
|
|
17
43
|
|
|
18
|
-
const
|
|
19
|
-
|
|
44
|
+
const buttons = screen.getAllByRole('button')
|
|
45
|
+
|
|
46
|
+
expect(buttons).toHaveLength(steps.length)
|
|
20
47
|
})
|
|
21
48
|
})
|
|
@@ -11,12 +11,14 @@ interface MobileStepperProps {
|
|
|
11
11
|
stepEntries: StepItem[]
|
|
12
12
|
activeStep: number
|
|
13
13
|
handleStepClick: (index: number) => void
|
|
14
|
+
getStepState: (index: number) => 'completed' | 'active' | 'pending'
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
const MobileStepper = ({
|
|
17
18
|
stepEntries,
|
|
18
19
|
activeStep,
|
|
19
20
|
handleStepClick,
|
|
21
|
+
getStepState,
|
|
20
22
|
}: MobileStepperProps) => (
|
|
21
23
|
<Box className='ServiceWizardStepper-MobileStepperWrapper'>
|
|
22
24
|
<Box className='ServiceWizardStepper-NavSlot'>
|
|
@@ -35,12 +37,12 @@ const MobileStepper = ({
|
|
|
35
37
|
connector={<StepConnector />}
|
|
36
38
|
className='ServiceWizardStepper ServiceWizardStepper-horizontal'
|
|
37
39
|
>
|
|
38
|
-
{stepEntries.map((step) => (
|
|
40
|
+
{stepEntries.map((step, index) => (
|
|
39
41
|
<Step key={step.id}>
|
|
40
42
|
<StepButton disabled>
|
|
41
43
|
<StyledStepLabel
|
|
42
44
|
StepIconComponent={CustomStepIcon}
|
|
43
|
-
stepState={
|
|
45
|
+
stepState={getStepState(index)}
|
|
44
46
|
/>
|
|
45
47
|
</StepButton>
|
|
46
48
|
</Step>
|
|
@@ -2,10 +2,10 @@ import { StepLabel, styled } from '@mui/material'
|
|
|
2
2
|
|
|
3
3
|
import palette, { grey } from '@/theme/palette'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
export type StepState = 'completed' | 'active' | 'pending'
|
|
6
6
|
|
|
7
7
|
interface StyledStepLabelProps {
|
|
8
|
-
stepState:
|
|
8
|
+
stepState: StepState
|
|
9
9
|
orientation?: 'vertical' | 'horizontal'
|
|
10
10
|
isLast?: boolean
|
|
11
11
|
}
|
|
@@ -19,6 +19,12 @@ const StyledStepLabel = styled(StepLabel, {
|
|
|
19
19
|
color: stepState === 'pending' ? grey[500] : grey[800],
|
|
20
20
|
},
|
|
21
21
|
|
|
22
|
+
...(orientation === 'vertical' && {
|
|
23
|
+
'& .MuiStepLabel-label.Mui-active': {
|
|
24
|
+
fontSize: '14px',
|
|
25
|
+
},
|
|
26
|
+
}),
|
|
27
|
+
|
|
22
28
|
...(orientation === 'vertical' &&
|
|
23
29
|
!isLast && {
|
|
24
30
|
'&.MuiStepLabel-root.MuiStepLabel-vertical .MuiStepLabel-label': {
|
|
@@ -1,61 +1,60 @@
|
|
|
1
1
|
import { useMediaQuery, useTheme } from '@mui/material'
|
|
2
|
-
import { useEffect, useState } from 'react'
|
|
3
2
|
|
|
4
3
|
import './ServiceWizardStepper.css'
|
|
5
4
|
import { StepItem } from './StepperTypes'
|
|
6
5
|
import DesktopStepper from './components/DesktopStepper'
|
|
7
6
|
import MobileStepper from './components/MobileStepper'
|
|
8
7
|
|
|
9
|
-
interface ServiceWizardStepperProps {
|
|
8
|
+
export interface ServiceWizardStepperProps {
|
|
10
9
|
orientation?: 'vertical' | 'horizontal'
|
|
11
10
|
steps: StepItem[]
|
|
11
|
+
activeStep: number
|
|
12
|
+
onStepClick?: (index: number) => void
|
|
13
|
+
isLoading?: boolean
|
|
12
14
|
}
|
|
13
15
|
|
|
14
|
-
const updateSteps = (index: number, prev: StepItem[]): StepItem[] =>
|
|
15
|
-
prev.map((step, i) => {
|
|
16
|
-
if (i < index) return { ...step, state: 'completed' }
|
|
17
|
-
if (i === index) return { ...step, state: 'active' }
|
|
18
|
-
return { ...step, state: 'pending' }
|
|
19
|
-
})
|
|
20
|
-
|
|
21
16
|
function ServiceWizardStepper({
|
|
22
17
|
steps,
|
|
18
|
+
activeStep,
|
|
23
19
|
orientation = 'horizontal',
|
|
20
|
+
onStepClick,
|
|
21
|
+
isLoading = false,
|
|
24
22
|
}: ServiceWizardStepperProps) {
|
|
25
|
-
const [currentSteps, setCurrentSteps] = useState(steps)
|
|
26
|
-
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
setCurrentSteps(steps)
|
|
29
|
-
}, [steps])
|
|
30
|
-
|
|
31
23
|
const theme = useTheme()
|
|
32
|
-
const isMobile = useMediaQuery(theme.breakpoints.down('
|
|
24
|
+
const isMobile = useMediaQuery(theme.breakpoints.down('md'))
|
|
33
25
|
|
|
34
26
|
const resolvedOrientation = isMobile ? 'horizontal' : orientation
|
|
35
27
|
|
|
36
|
-
const
|
|
28
|
+
const getStepState = (index: number) => {
|
|
29
|
+
if (index < activeStep) return 'completed'
|
|
30
|
+
if (index === activeStep) return 'active'
|
|
31
|
+
return 'pending'
|
|
32
|
+
}
|
|
37
33
|
|
|
38
34
|
const handleStepClick = (index: number) => {
|
|
39
35
|
if (index < 0 || index > activeStep) return
|
|
40
|
-
|
|
36
|
+
onStepClick?.(index)
|
|
41
37
|
}
|
|
42
38
|
|
|
43
39
|
if (isMobile) {
|
|
44
40
|
return (
|
|
45
41
|
<MobileStepper
|
|
46
|
-
stepEntries={
|
|
42
|
+
stepEntries={steps}
|
|
47
43
|
activeStep={activeStep}
|
|
48
44
|
handleStepClick={handleStepClick}
|
|
45
|
+
getStepState={getStepState}
|
|
49
46
|
/>
|
|
50
47
|
)
|
|
51
48
|
}
|
|
52
49
|
|
|
53
50
|
return (
|
|
54
51
|
<DesktopStepper
|
|
55
|
-
stepEntries={
|
|
52
|
+
stepEntries={steps}
|
|
56
53
|
activeStep={activeStep}
|
|
57
54
|
handleStepClick={handleStepClick}
|
|
58
55
|
resolvedOrientation={resolvedOrientation}
|
|
56
|
+
isLoading={isLoading}
|
|
57
|
+
getStepState={getStepState}
|
|
59
58
|
/>
|
|
60
59
|
)
|
|
61
60
|
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Button, Typography } from '@mui/material'
|
|
2
|
+
import { useState } from 'react'
|
|
3
|
+
|
|
4
|
+
import RcSesCardFormContainer from '@/components/layout/ServiceFormContainer/CardFormContainer'
|
|
5
|
+
import ServiceHeader from '@/components/layout/ServiceHeader'
|
|
6
|
+
import ServicePage from '@/components/layout/ServicePage'
|
|
7
|
+
import { StepItem } from '@/components/layout/ServiceWizardStepper/StepperTypes'
|
|
8
|
+
|
|
9
|
+
const steps: StepItem[] = [
|
|
10
|
+
{ id: '1', title: '1-2 žodžių tekstas' },
|
|
11
|
+
{ id: '2', title: '1-2 žodžių tekstas' },
|
|
12
|
+
{ id: '3', title: '1-2 žodžių tekstas' },
|
|
13
|
+
{ id: '4', title: '1-2 žodžių tekstas' },
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
function CardMultipleStepForm() {
|
|
17
|
+
const [activeStep, setActiveStep] = useState(0)
|
|
18
|
+
|
|
19
|
+
const handleBack = () => {
|
|
20
|
+
setActiveStep((prev) => Math.max(prev - 1, 0))
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const handleNext = () => {
|
|
24
|
+
setActiveStep((prev) => Math.min(prev + 1, steps.length - 1))
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const handleStepClick = (index: number) => {
|
|
28
|
+
if (index > activeStep) return
|
|
29
|
+
setActiveStep(index)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<ServicePage>
|
|
34
|
+
<ServiceHeader
|
|
35
|
+
breadcrumbsProps={{
|
|
36
|
+
path: [
|
|
37
|
+
{ label: 'Pagrindinis', path: '/' },
|
|
38
|
+
{
|
|
39
|
+
label: 'Horizontalios formos su vedliu pavyzdys',
|
|
40
|
+
path: '/horizontal-sample-form-multiple-steps',
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
}}
|
|
44
|
+
title='Nekilnojamojo turto registro išrašas pagal nurodytą turto adresą'
|
|
45
|
+
>
|
|
46
|
+
<Typography variant='body1'>
|
|
47
|
+
Šiame puslapyje Jūs galite užsisakyti Nekilnojamojo turto registro išrašus,
|
|
48
|
+
pažymas bei kitus dokumentus. Užsakytą NTR išrašą, pažymą ar kitą dokumentą
|
|
49
|
+
galėsite gauti elektroniniu būdu arba atsiimti pasirinktame VĮ Registrų centro
|
|
50
|
+
padalinyje.
|
|
51
|
+
</Typography>
|
|
52
|
+
</ServiceHeader>
|
|
53
|
+
|
|
54
|
+
<RcSesCardFormContainer
|
|
55
|
+
steps={steps}
|
|
56
|
+
activeStep={activeStep}
|
|
57
|
+
onStepClick={handleStepClick}
|
|
58
|
+
title='Test'
|
|
59
|
+
description='Test description'
|
|
60
|
+
leadingActions={activeStep !== 0 && <Button onClick={handleBack}>Back</Button>}
|
|
61
|
+
trailingActions={
|
|
62
|
+
<>
|
|
63
|
+
<Button variant='outlined'>Button</Button>
|
|
64
|
+
<Button
|
|
65
|
+
variant='contained'
|
|
66
|
+
onClick={handleNext}
|
|
67
|
+
disabled={activeStep === steps.length - 1}
|
|
68
|
+
>
|
|
69
|
+
Next
|
|
70
|
+
</Button>
|
|
71
|
+
</>
|
|
72
|
+
}
|
|
73
|
+
>
|
|
74
|
+
<Typography variant='body1'>{`Current Step: ${activeStep + 1}`}</Typography>
|
|
75
|
+
</RcSesCardFormContainer>
|
|
76
|
+
</ServicePage>
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export default CardMultipleStepForm
|
|
@@ -6,24 +6,24 @@ import ServiceWizardStepper from '@/components/layout/ServiceWizardStepper'
|
|
|
6
6
|
import { StepItem } from '@/components/layout/ServiceWizardStepper/StepperTypes'
|
|
7
7
|
|
|
8
8
|
const steps3: StepItem[] = [
|
|
9
|
-
{ id: '1',
|
|
10
|
-
{ id: '2',
|
|
11
|
-
{ id: '3',
|
|
9
|
+
{ id: '1', title: '1-2 žodžių tekstas' },
|
|
10
|
+
{ id: '2', title: '1-2 žodžių tekstas' },
|
|
11
|
+
{ id: '3', title: '1-2 žodžių tekstas' },
|
|
12
12
|
]
|
|
13
13
|
|
|
14
14
|
const steps4: StepItem[] = [
|
|
15
|
-
{ id: '1',
|
|
16
|
-
{ id: '2',
|
|
17
|
-
{ id: '3',
|
|
18
|
-
{ id: '4',
|
|
15
|
+
{ id: '1', title: '1-2 žodžių tekstas' },
|
|
16
|
+
{ id: '2', title: '1-2 žodžių tekstas' },
|
|
17
|
+
{ id: '3', title: '1-2 žodžių tekstas' },
|
|
18
|
+
{ id: '4', title: '1-2 žodžių tekstas' },
|
|
19
19
|
]
|
|
20
20
|
|
|
21
21
|
const steps5: StepItem[] = [
|
|
22
|
-
{ id: '1',
|
|
23
|
-
{ id: '2',
|
|
24
|
-
{ id: '3',
|
|
25
|
-
{ id: '4',
|
|
26
|
-
{ id: '5',
|
|
22
|
+
{ id: '1', title: '1-2 žodžių tekstas' },
|
|
23
|
+
{ id: '2', title: '1-2 žodžių tekstas' },
|
|
24
|
+
{ id: '3', title: '1-2 žodžių tekstas' },
|
|
25
|
+
{ id: '4', title: '1-2 žodžių tekstas' },
|
|
26
|
+
{ id: '5', title: '1-2 žodžių tekstas' },
|
|
27
27
|
]
|
|
28
28
|
|
|
29
29
|
function HorizontalMultipleStepForm() {
|
|
@@ -50,13 +50,18 @@ function HorizontalMultipleStepForm() {
|
|
|
50
50
|
</ServiceHeader>
|
|
51
51
|
|
|
52
52
|
<div
|
|
53
|
-
style={{
|
|
53
|
+
style={{
|
|
54
|
+
padding: '2rem',
|
|
55
|
+
display: 'flex',
|
|
56
|
+
flexDirection: 'column',
|
|
57
|
+
gap: '2rem',
|
|
58
|
+
}}
|
|
54
59
|
>
|
|
55
|
-
<ServiceWizardStepper steps={steps3} />
|
|
56
|
-
<ServiceWizardStepper steps={steps4} />
|
|
57
|
-
<ServiceWizardStepper steps={steps5} />
|
|
60
|
+
<ServiceWizardStepper steps={steps3} activeStep={1} />
|
|
61
|
+
<ServiceWizardStepper steps={steps4} activeStep={0} />
|
|
62
|
+
<ServiceWizardStepper steps={steps5} activeStep={2} />
|
|
58
63
|
</div>
|
|
59
|
-
<ServiceWizardStepper steps={steps5} />
|
|
64
|
+
<ServiceWizardStepper steps={steps5} activeStep={4} />
|
|
60
65
|
</ServicePage>
|
|
61
66
|
)
|
|
62
67
|
}
|