@registrucentras/rc-ses-react-components 1.4.0 → 1.4.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/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 +11 -0
- package/dist/components/layout/ServiceWizardStepper/components/DesktopStepper.d.ts +2 -1
- package/dist/components/layout/ServiceWizardStepper/index.d.ts +4 -2
- package/dist/library/index.d.ts +6 -2
- package/dist/library/types.d.ts +4 -0
- package/dist/registrucentras-rc-ses-react-components.cjs +10 -10
- package/dist/registrucentras-rc-ses-react-components.js +985 -922
- package/dist/stories/components/form/CardFormContainer.stories.d.ts +7 -0
- package/dist/stories/components/form/ServiceFormContainer.stories.d.ts +1 -1
- package/package.json +1 -1
- package/src/App.tsx +4 -0
- package/src/components/layout/ServiceFormContainer/{index.tsx → AccordionFormContainer/index.tsx} +1 -1
- package/src/components/layout/ServiceFormContainer/{utils.ts → AccordionFormContainer/utils.ts} +2 -2
- package/src/components/layout/ServiceFormContainer/CardFormContainer/index.test.tsx +78 -0
- package/src/components/layout/ServiceFormContainer/CardFormContainer/index.tsx +68 -0
- package/src/components/layout/ServiceWizardStepper/ServiceWizardStepper.css +19 -3
- package/src/components/layout/ServiceWizardStepper/StepConnector.tsx +1 -1
- package/src/components/layout/ServiceWizardStepper/components/DesktopStepper.tsx +17 -2
- package/src/components/layout/ServiceWizardStepper/components/StyledStepLabel.tsx +5 -1
- package/src/components/layout/ServiceWizardStepper/index.tsx +10 -3
- package/src/examples/CardMultipleStepForm/index.tsx +93 -0
- package/src/examples/MultipleStepForm/index.tsx +1 -1
- package/src/examples/SingleStepForm/index.tsx +1 -1
- package/src/library/index.ts +6 -1
- package/src/library/types.ts +5 -0
- package/src/main.tsx +5 -0
- package/src/stories/components/Accordion.stories.tsx +1 -1
- package/src/stories/components/form/CardFormContainer.stories.tsx +135 -0
- package/src/stories/components/form/ServiceFormContainer.stories.tsx +1 -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,7 @@
|
|
|
1
|
+
import { Meta, ReactRenderer } from '@storybook/react';
|
|
2
|
+
import { default as RcSesCardFormContainer, RcSesCardFormContainerProps } from '../../../components/layout/ServiceFormContainer/CardFormContainer';
|
|
3
|
+
import { AnnotatedStoryFn } from '@storybook/core/csf';
|
|
4
|
+
declare const meta: Meta<typeof RcSesCardFormContainer>;
|
|
5
|
+
export default meta;
|
|
6
|
+
export declare const HorizontalDemo: AnnotatedStoryFn<ReactRenderer, RcSesCardFormContainerProps>;
|
|
7
|
+
export declare const VerticalDemo: AnnotatedStoryFn<ReactRenderer, RcSesCardFormContainerProps>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Meta, ReactRenderer } from '@storybook/react';
|
|
2
2
|
import { default as useAccordionController } from '../../../components/common/Accordion/hooks/useAccordionController';
|
|
3
|
-
import { default as RcSesServiceFormContainer } from '../../../components/layout/ServiceFormContainer';
|
|
3
|
+
import { default as RcSesServiceFormContainer } from '../../../components/layout/ServiceFormContainer/AccordionFormContainer';
|
|
4
4
|
import { AnnotatedStoryFn } from '@storybook/core/csf';
|
|
5
5
|
import { ContainerProps } from '@mui/system';
|
|
6
6
|
declare const meta: Meta<typeof RcSesServiceFormContainer>;
|
package/package.json
CHANGED
package/src/App.tsx
CHANGED
package/src/components/layout/ServiceFormContainer/{index.tsx → AccordionFormContainer/index.tsx}
RENAMED
|
@@ -5,7 +5,7 @@ import React from 'react'
|
|
|
5
5
|
import useAccordionController from '@/components/common/Accordion/hooks/useAccordionController'
|
|
6
6
|
import palette from '@/theme/palette'
|
|
7
7
|
|
|
8
|
-
import ServiceWizardStepper from '
|
|
8
|
+
import ServiceWizardStepper from '../../ServiceWizardStepper'
|
|
9
9
|
import AccordionCollapseControls from './components/AccordionCollapseControls'
|
|
10
10
|
import mapAccordionStateToSteps from './utils'
|
|
11
11
|
|
package/src/components/layout/ServiceFormContainer/{utils.ts → AccordionFormContainer/utils.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AccordionControllerState } from '
|
|
2
|
-
import { StepItem } from '
|
|
1
|
+
import { AccordionControllerState } from '../../../common/Accordion/types/AccordionControllerState'
|
|
2
|
+
import { StepItem } from '../../ServiceWizardStepper/StepperTypes'
|
|
3
3
|
|
|
4
4
|
function mapAccordionStateToSteps(state: AccordionControllerState): StepItem[] {
|
|
5
5
|
return Object.entries(state).map(([id, step]) => ({
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { ThemeProvider } from '@mui/material/styles'
|
|
2
|
+
import { fireEvent, render, screen } from '@testing-library/react'
|
|
3
|
+
import { ReactElement } from 'react'
|
|
4
|
+
|
|
5
|
+
import theme from '@/theme/light'
|
|
6
|
+
|
|
7
|
+
import { StepItem } from '../../ServiceWizardStepper/StepperTypes'
|
|
8
|
+
import RcSesCardFormContainer from './index'
|
|
9
|
+
|
|
10
|
+
const baseSteps: StepItem[] = [
|
|
11
|
+
{ id: '1', title: 'Step 1', state: 'completed' },
|
|
12
|
+
{ id: '2', title: 'Step 2', state: 'active' },
|
|
13
|
+
{ id: '3', title: 'Step 3', state: 'pending' },
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
const renderWithTheme = (ui: ReactElement) =>
|
|
17
|
+
render(<ThemeProvider theme={theme}>{ui}</ThemeProvider>)
|
|
18
|
+
|
|
19
|
+
describe('RcSesCardFormContainer', () => {
|
|
20
|
+
test('renders stepper, card content, and card title', () => {
|
|
21
|
+
renderWithTheme(
|
|
22
|
+
<RcSesCardFormContainer steps={baseSteps} title='Form title'>
|
|
23
|
+
<div>Form content</div>
|
|
24
|
+
</RcSesCardFormContainer>,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
expect(screen.getByText('Step 1')).toBeInTheDocument()
|
|
28
|
+
expect(screen.getByText('Step 2')).toBeInTheDocument()
|
|
29
|
+
expect(screen.getByText('Step 3')).toBeInTheDocument()
|
|
30
|
+
expect(screen.getByText('Form title')).toBeInTheDocument()
|
|
31
|
+
expect(screen.getByText('Form content')).toBeInTheDocument()
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
test('uses horizontal orientation by default', () => {
|
|
35
|
+
const { container } = renderWithTheme(
|
|
36
|
+
<RcSesCardFormContainer steps={baseSteps} title='Default layout'>
|
|
37
|
+
<div>Body</div>
|
|
38
|
+
</RcSesCardFormContainer>,
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
expect(
|
|
42
|
+
container.querySelector('.ServiceWizardStepper-horizontal'),
|
|
43
|
+
).toBeInTheDocument()
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
test('uses vertical orientation when layout is row', () => {
|
|
47
|
+
const { container } = renderWithTheme(
|
|
48
|
+
<RcSesCardFormContainer steps={baseSteps} title='Row layout' layout='row'>
|
|
49
|
+
<div>Body</div>
|
|
50
|
+
</RcSesCardFormContainer>,
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
expect(container.querySelector('.ServiceWizardStepper-vertical')).toBeInTheDocument()
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
test('forwards step click updates through onStepClick', () => {
|
|
57
|
+
const onStepClick = vi.fn()
|
|
58
|
+
|
|
59
|
+
renderWithTheme(
|
|
60
|
+
<RcSesCardFormContainer
|
|
61
|
+
steps={baseSteps}
|
|
62
|
+
title='Clickable steps'
|
|
63
|
+
onStepClick={onStepClick}
|
|
64
|
+
>
|
|
65
|
+
<div>Body</div>
|
|
66
|
+
</RcSesCardFormContainer>,
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
fireEvent.click(screen.getByText('Step 1'))
|
|
70
|
+
|
|
71
|
+
expect(onStepClick).toHaveBeenCalledTimes(1)
|
|
72
|
+
expect(onStepClick).toHaveBeenCalledWith([
|
|
73
|
+
{ id: '1', title: 'Step 1', state: 'active' },
|
|
74
|
+
{ id: '2', title: 'Step 2', state: 'pending' },
|
|
75
|
+
{ id: '3', title: 'Step 3', state: 'pending' },
|
|
76
|
+
])
|
|
77
|
+
})
|
|
78
|
+
})
|
|
@@ -0,0 +1,68 @@
|
|
|
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?: (steps: StepItem[]) => void
|
|
13
|
+
layout?: LayoutMode
|
|
14
|
+
isLoading?: boolean
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const RcSesCardFormContainer = ({
|
|
18
|
+
steps,
|
|
19
|
+
onStepClick,
|
|
20
|
+
layout,
|
|
21
|
+
children,
|
|
22
|
+
isLoading = false,
|
|
23
|
+
...cardProps
|
|
24
|
+
}: RcSesCardFormContainerProps) => {
|
|
25
|
+
const getLayoutDirection = () => {
|
|
26
|
+
if (layout != null) return layout
|
|
27
|
+
if (steps.length > 4) {
|
|
28
|
+
return 'row'
|
|
29
|
+
}
|
|
30
|
+
return 'column'
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const layoutDirection = getLayoutDirection()
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<Container
|
|
37
|
+
sx={{
|
|
38
|
+
display: 'flex',
|
|
39
|
+
flexDirection: {
|
|
40
|
+
xs: 'column',
|
|
41
|
+
md: getLayoutDirection(),
|
|
42
|
+
},
|
|
43
|
+
gap: '24px',
|
|
44
|
+
paddingBottom: '64px',
|
|
45
|
+
}}
|
|
46
|
+
>
|
|
47
|
+
{steps.length > 2 && (
|
|
48
|
+
<ServiceWizardStepper
|
|
49
|
+
steps={steps}
|
|
50
|
+
onStepClick={onStepClick}
|
|
51
|
+
orientation={layoutDirection === 'row' ? 'vertical' : 'horizontal'}
|
|
52
|
+
isLoading={isLoading}
|
|
53
|
+
/>
|
|
54
|
+
)}
|
|
55
|
+
|
|
56
|
+
<RcSesCard
|
|
57
|
+
{...cardProps}
|
|
58
|
+
sx={{
|
|
59
|
+
width: '100%',
|
|
60
|
+
}}
|
|
61
|
+
>
|
|
62
|
+
{children}
|
|
63
|
+
</RcSesCard>
|
|
64
|
+
</Container>
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
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 {
|
|
@@ -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,7 @@ interface DesktopStepperProps {
|
|
|
10
10
|
activeStep: number
|
|
11
11
|
handleStepClick: (index: number) => void
|
|
12
12
|
resolvedOrientation: 'vertical' | 'horizontal'
|
|
13
|
+
isLoading?: boolean
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
const DesktopStepper = ({
|
|
@@ -17,6 +18,7 @@ const DesktopStepper = ({
|
|
|
17
18
|
activeStep,
|
|
18
19
|
handleStepClick,
|
|
19
20
|
resolvedOrientation,
|
|
21
|
+
isLoading = false,
|
|
20
22
|
}: DesktopStepperProps) => (
|
|
21
23
|
<Stepper
|
|
22
24
|
alternativeLabel={resolvedOrientation === 'horizontal'}
|
|
@@ -24,6 +26,15 @@ const DesktopStepper = ({
|
|
|
24
26
|
orientation={resolvedOrientation}
|
|
25
27
|
connector={resolvedOrientation === 'horizontal' ? <StepConnector /> : undefined}
|
|
26
28
|
className={`ServiceWizardStepper ServiceWizardStepper-${resolvedOrientation}`}
|
|
29
|
+
sx={
|
|
30
|
+
resolvedOrientation === 'vertical'
|
|
31
|
+
? {
|
|
32
|
+
width: 220,
|
|
33
|
+
flexShrink: 0,
|
|
34
|
+
alignSelf: 'flex-start',
|
|
35
|
+
}
|
|
36
|
+
: undefined
|
|
37
|
+
}
|
|
27
38
|
>
|
|
28
39
|
{stepEntries.map((step, index) => {
|
|
29
40
|
const isClickable = index <= (activeStep === -1 ? 0 : activeStep)
|
|
@@ -36,7 +47,11 @@ const DesktopStepper = ({
|
|
|
36
47
|
orientation={resolvedOrientation}
|
|
37
48
|
isLast={index === stepEntries.length - 1}
|
|
38
49
|
>
|
|
39
|
-
{
|
|
50
|
+
{isLoading ? (
|
|
51
|
+
<Skeleton variant='rounded' width={100} height={14} />
|
|
52
|
+
) : (
|
|
53
|
+
step.title
|
|
54
|
+
)}
|
|
40
55
|
</StyledStepLabel>
|
|
41
56
|
</StepButton>
|
|
42
57
|
</Step>
|
|
@@ -18,7 +18,11 @@ const StyledStepLabel = styled(StepLabel, {
|
|
|
18
18
|
fontWeight: stepState === 'active' ? 700 : 400,
|
|
19
19
|
color: stepState === 'pending' ? grey[500] : grey[800],
|
|
20
20
|
},
|
|
21
|
-
|
|
21
|
+
...(orientation === 'vertical' && {
|
|
22
|
+
'& .MuiStepLabel-label.Mui-active': {
|
|
23
|
+
fontSize: '14px',
|
|
24
|
+
},
|
|
25
|
+
}),
|
|
22
26
|
...(orientation === 'vertical' &&
|
|
23
27
|
!isLast && {
|
|
24
28
|
'&.MuiStepLabel-root.MuiStepLabel-vertical .MuiStepLabel-label': {
|
|
@@ -6,9 +6,11 @@ import { StepItem } from './StepperTypes'
|
|
|
6
6
|
import DesktopStepper from './components/DesktopStepper'
|
|
7
7
|
import MobileStepper from './components/MobileStepper'
|
|
8
8
|
|
|
9
|
-
interface ServiceWizardStepperProps {
|
|
9
|
+
export interface ServiceWizardStepperProps {
|
|
10
10
|
orientation?: 'vertical' | 'horizontal'
|
|
11
11
|
steps: StepItem[]
|
|
12
|
+
onStepClick?: (steps: StepItem[]) => void
|
|
13
|
+
isLoading?: boolean
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
const updateSteps = (index: number, prev: StepItem[]): StepItem[] =>
|
|
@@ -21,6 +23,8 @@ const updateSteps = (index: number, prev: StepItem[]): StepItem[] =>
|
|
|
21
23
|
function ServiceWizardStepper({
|
|
22
24
|
steps,
|
|
23
25
|
orientation = 'horizontal',
|
|
26
|
+
onStepClick,
|
|
27
|
+
isLoading = false,
|
|
24
28
|
}: ServiceWizardStepperProps) {
|
|
25
29
|
const [currentSteps, setCurrentSteps] = useState(steps)
|
|
26
30
|
|
|
@@ -29,7 +33,7 @@ function ServiceWizardStepper({
|
|
|
29
33
|
}, [steps])
|
|
30
34
|
|
|
31
35
|
const theme = useTheme()
|
|
32
|
-
const isMobile = useMediaQuery(theme.breakpoints.down('
|
|
36
|
+
const isMobile = useMediaQuery(theme.breakpoints.down('md'))
|
|
33
37
|
|
|
34
38
|
const resolvedOrientation = isMobile ? 'horizontal' : orientation
|
|
35
39
|
|
|
@@ -37,7 +41,9 @@ function ServiceWizardStepper({
|
|
|
37
41
|
|
|
38
42
|
const handleStepClick = (index: number) => {
|
|
39
43
|
if (index < 0 || index > activeStep) return
|
|
40
|
-
|
|
44
|
+
const updatedSteps = updateSteps(index, currentSteps)
|
|
45
|
+
setCurrentSteps(updatedSteps)
|
|
46
|
+
onStepClick?.(updatedSteps)
|
|
41
47
|
}
|
|
42
48
|
|
|
43
49
|
if (isMobile) {
|
|
@@ -56,6 +62,7 @@ function ServiceWizardStepper({
|
|
|
56
62
|
activeStep={activeStep}
|
|
57
63
|
handleStepClick={handleStepClick}
|
|
58
64
|
resolvedOrientation={resolvedOrientation}
|
|
65
|
+
isLoading={isLoading}
|
|
59
66
|
/>
|
|
60
67
|
)
|
|
61
68
|
}
|
|
@@ -0,0 +1,93 @@
|
|
|
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', state: 'completed', title: '1-2 žodžių tekstas' },
|
|
11
|
+
{ id: '2', state: 'active', title: '1-2 žodžių tekstas' },
|
|
12
|
+
{ id: '3', state: 'pending', title: '1-2 žodžių tekstas' },
|
|
13
|
+
{ id: '4', state: 'pending', title: '1-2 žodžių tekstas' },
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
function CardMultipleStepForm() {
|
|
17
|
+
const [currentSteps, setSteps] = useState(steps)
|
|
18
|
+
const activeStep = currentSteps.findIndex((s) => s.state === 'active')
|
|
19
|
+
|
|
20
|
+
const handleBack = () => {
|
|
21
|
+
if (activeStep <= 0) return
|
|
22
|
+
|
|
23
|
+
const updatedSteps: StepItem[] = currentSteps.map((step, index) => {
|
|
24
|
+
if (index < activeStep - 1) return { ...step, state: 'completed' }
|
|
25
|
+
if (index === activeStep - 1) return { ...step, state: 'active' }
|
|
26
|
+
return { ...step, state: 'pending' }
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
setSteps(updatedSteps)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const handleNext = () => {
|
|
33
|
+
const activeIndex = currentSteps.findIndex((s) => s.state === 'active')
|
|
34
|
+
if (activeIndex === -1 || activeIndex === currentSteps.length - 1) return
|
|
35
|
+
const updatedSteps: StepItem[] = currentSteps.map((step, index) => {
|
|
36
|
+
if (index < activeIndex + 1) return { ...step, state: 'completed' }
|
|
37
|
+
if (index === activeIndex + 1) return { ...step, state: 'active' }
|
|
38
|
+
return { ...step, state: 'pending' }
|
|
39
|
+
})
|
|
40
|
+
setSteps(updatedSteps)
|
|
41
|
+
}
|
|
42
|
+
return (
|
|
43
|
+
<ServicePage>
|
|
44
|
+
<ServiceHeader
|
|
45
|
+
breadcrumbsProps={{
|
|
46
|
+
path: [
|
|
47
|
+
{ label: 'Pagrindinis', path: '/' },
|
|
48
|
+
{
|
|
49
|
+
label: 'Horizontalios formos su vedliu pavyzdys',
|
|
50
|
+
path: '/horizontal-sample-form-multiple-steps',
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
}}
|
|
54
|
+
title='Nekilnojamojo turto registro išrašas pagal nurodytą turto adresą'
|
|
55
|
+
>
|
|
56
|
+
<Typography variant='body1'>
|
|
57
|
+
Šiame puslapyje Jūs galite užsisakyti Nekilnojamojo turto registro išrašus,
|
|
58
|
+
pažymas bei kitus dokumentus. Užsakytą NTR išrašą, pažymą ar kitą dokumentą
|
|
59
|
+
galėsite gauti elektroniniu būdu arba atsiimti pasirinktame VĮ Registrų centro
|
|
60
|
+
padalinyje.
|
|
61
|
+
</Typography>
|
|
62
|
+
</ServiceHeader>
|
|
63
|
+
|
|
64
|
+
<RcSesCardFormContainer
|
|
65
|
+
steps={currentSteps}
|
|
66
|
+
onStepClick={(newSteps) => setSteps(newSteps)}
|
|
67
|
+
title='Test'
|
|
68
|
+
description='Test description'
|
|
69
|
+
leadingActions={
|
|
70
|
+
<Button onClick={handleBack} disabled={activeStep === 0}>
|
|
71
|
+
Back
|
|
72
|
+
</Button>
|
|
73
|
+
}
|
|
74
|
+
trailingActions={
|
|
75
|
+
<>
|
|
76
|
+
<Button variant='outlined'>Button</Button>
|
|
77
|
+
<Button
|
|
78
|
+
variant='contained'
|
|
79
|
+
onClick={handleNext}
|
|
80
|
+
disabled={activeStep === currentSteps.length - 1}
|
|
81
|
+
>
|
|
82
|
+
Next
|
|
83
|
+
</Button>
|
|
84
|
+
</>
|
|
85
|
+
}
|
|
86
|
+
>
|
|
87
|
+
<Typography variant='body1'>{`Current Step: ${activeStep + 1}`}</Typography>
|
|
88
|
+
</RcSesCardFormContainer>
|
|
89
|
+
</ServicePage>
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export default CardMultipleStepForm
|
|
@@ -4,7 +4,7 @@ import { useNavigate } from 'react-router-dom'
|
|
|
4
4
|
import RcSesAccordion from '@/components/common/Accordion'
|
|
5
5
|
import useAccordionController from '@/components/common/Accordion/hooks/useAccordionController'
|
|
6
6
|
import ServiceFormActions from '@/components/layout/ServiceFormActions'
|
|
7
|
-
import RcSesServiceFormContainer from '@/components/layout/ServiceFormContainer'
|
|
7
|
+
import RcSesServiceFormContainer from '@/components/layout/ServiceFormContainer/AccordionFormContainer'
|
|
8
8
|
import ServiceHeader from '@/components/layout/ServiceHeader'
|
|
9
9
|
import ServicePage from '@/components/layout/ServicePage'
|
|
10
10
|
|
|
@@ -17,7 +17,7 @@ import RcSesSearchableField from '@/components/form/inputs/SearchableField'
|
|
|
17
17
|
import RcSesSelect from '@/components/form/inputs/Select'
|
|
18
18
|
import RcSesTextField from '@/components/form/inputs/TextField'
|
|
19
19
|
import ServiceFormActions from '@/components/layout/ServiceFormActions'
|
|
20
|
-
import RcSesServiceFormContainer from '@/components/layout/ServiceFormContainer'
|
|
20
|
+
import RcSesServiceFormContainer from '@/components/layout/ServiceFormContainer/AccordionFormContainer'
|
|
21
21
|
import ServiceHeader from '@/components/layout/ServiceHeader'
|
|
22
22
|
import ServicePage from '@/components/layout/ServicePage'
|
|
23
23
|
|
package/src/library/index.ts
CHANGED
|
@@ -40,9 +40,11 @@ import RcSesSearchableField from '@/components/form/inputs/SearchableField'
|
|
|
40
40
|
import RcSesSelect from '@/components/form/inputs/Select'
|
|
41
41
|
import RcSesTextField from '@/components/form/inputs/TextField'
|
|
42
42
|
import RcSesServiceFormActions from '@/components/layout/ServiceFormActions'
|
|
43
|
-
import RcSesServiceFormContainer from '@/components/layout/ServiceFormContainer'
|
|
43
|
+
import RcSesServiceFormContainer from '@/components/layout/ServiceFormContainer/AccordionFormContainer'
|
|
44
|
+
import RcSesCardFormContainer from '@/components/layout/ServiceFormContainer/CardFormContainer'
|
|
44
45
|
import RcSesServiceHeader from '@/components/layout/ServiceHeader'
|
|
45
46
|
import RcSesServicePage from '@/components/layout/ServicePage'
|
|
47
|
+
import ServiceWizardStepper from '@/components/layout/ServiceWizardStepper'
|
|
46
48
|
import RcSesTheme from '@/theme/light'
|
|
47
49
|
import RcSesPalette from '@/theme/palette'
|
|
48
50
|
|
|
@@ -67,10 +69,13 @@ export { RcSesSelect }
|
|
|
67
69
|
export { RcSesTab, RcSesTabPanel, RcSesTabs, RcSesTabsWrapper }
|
|
68
70
|
export { RcSesTextField }
|
|
69
71
|
export { DataPagination }
|
|
72
|
+
export { ServiceWizardStepper }
|
|
73
|
+
export type * from './types'
|
|
70
74
|
|
|
71
75
|
export {
|
|
72
76
|
RcSesServiceFormActions,
|
|
73
77
|
RcSesServiceFormContainer,
|
|
78
|
+
RcSesCardFormContainer,
|
|
74
79
|
RcSesFormControlWrapper,
|
|
75
80
|
RcSesServiceHeader,
|
|
76
81
|
RcSesServicePage,
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { RcSesCardProps } from '@/components/common/Card'
|
|
2
|
+
import { RcSesCardFormContainerProps } from '@/components/layout/ServiceFormContainer/CardFormContainer'
|
|
3
|
+
import { ServiceWizardStepperProps } from '@/components/layout/ServiceWizardStepper'
|
|
4
|
+
|
|
5
|
+
export type { RcSesCardFormContainerProps, RcSesCardProps, ServiceWizardStepperProps }
|
package/src/main.tsx
CHANGED
|
@@ -13,6 +13,7 @@ import { RouterProvider, createBrowserRouter } from 'react-router-dom'
|
|
|
13
13
|
import theme from '@/theme/light'
|
|
14
14
|
|
|
15
15
|
import App from './App'
|
|
16
|
+
import CardMultipleStepForm from './examples/CardMultipleStepForm'
|
|
16
17
|
import HorizontalMultipleStepForm from './examples/HorizontalMultiStepForm'
|
|
17
18
|
import ListWithPagination from './examples/ListWithPagination'
|
|
18
19
|
import MultipleStepForm from './examples/MultipleStepForm'
|
|
@@ -41,6 +42,10 @@ const router = createBrowserRouter([
|
|
|
41
42
|
path: '/horizontal-multi-step-form',
|
|
42
43
|
element: <HorizontalMultipleStepForm />,
|
|
43
44
|
},
|
|
45
|
+
{
|
|
46
|
+
path: '/card-multi-step-form',
|
|
47
|
+
element: <CardMultipleStepForm />,
|
|
48
|
+
},
|
|
44
49
|
])
|
|
45
50
|
|
|
46
51
|
const adapterLocale = i18n.language === 'lt' ? lt : enUS
|
|
@@ -3,7 +3,7 @@ import { Meta, StoryContext, StoryFn } from '@storybook/react'
|
|
|
3
3
|
|
|
4
4
|
import RcSesAccordion from '@/components/common/Accordion'
|
|
5
5
|
import useAccordionController from '@/components/common/Accordion/hooks/useAccordionController'
|
|
6
|
-
import RcSesServiceFormContainer from '@/components/layout/ServiceFormContainer'
|
|
6
|
+
import RcSesServiceFormContainer from '@/components/layout/ServiceFormContainer/AccordionFormContainer'
|
|
7
7
|
import FieldView from '@/components/storybook/FieldView'
|
|
8
8
|
|
|
9
9
|
const meta: Meta<typeof RcSesAccordion> = {
|