@registrucentras/rc-ses-react-components 1.4.1 → 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.
Files changed (74) hide show
  1. package/dist/components/common/Accordion/hooks/useAccordionController.d.ts +1 -0
  2. package/dist/components/common/Card/index.d.ts +7 -2
  3. package/dist/components/common/ImageCard/index.d.ts +13 -0
  4. package/dist/components/common/ListWithIcons/components/ListWithIconsItem.d.ts +9 -0
  5. package/dist/components/common/ListWithIcons/index.d.ts +14 -0
  6. package/dist/components/layout/Footer/index.d.ts +5 -0
  7. package/dist/components/layout/ServiceFormContainer/CardFormContainer/index.d.ts +3 -2
  8. package/dist/components/layout/ServiceWizardStepper/StepperTypes.d.ts +0 -3
  9. package/dist/components/layout/ServiceWizardStepper/components/DesktopStepper.d.ts +2 -1
  10. package/dist/components/layout/ServiceWizardStepper/components/MobileStepper.d.ts +2 -1
  11. package/dist/components/layout/ServiceWizardStepper/components/StyledStepLabel.d.ts +2 -2
  12. package/dist/components/layout/ServiceWizardStepper/index.d.ts +3 -2
  13. package/dist/library/icons.d.ts +1 -3
  14. package/dist/library/index.d.ts +6 -14
  15. package/dist/library/types.d.ts +2 -0
  16. package/dist/registrucentras-rc-ses-react-components.cjs +11 -11
  17. package/dist/registrucentras-rc-ses-react-components.js +2530 -2251
  18. package/dist/stories/ServiceWizardStepper.stories.d.ts +5 -5
  19. package/dist/stories/components/Card.stories.d.ts +26 -1
  20. package/dist/stories/components/ImageCard.stories.d.ts +8 -0
  21. package/dist/stories/components/ListWithIcons.stories.d.ts +33 -0
  22. package/dist/stories/components/inputs/FileDropzone.stories.d.ts +32 -0
  23. package/dist/stories/components/inputs/PhoneInput.stories.d.ts +24 -0
  24. package/dist/stories/components/inputs/SearchableField.stories.d.ts +2 -2
  25. package/dist/stories/components/inputs/Select.stories.d.ts +3 -3
  26. package/dist/stories/components/inputs/TextField.stories.d.ts +5 -5
  27. package/dist/stories/components/layout/Footer.stories.d.ts +8 -0
  28. package/package.json +1 -1
  29. package/src/components/common/Accordion/hooks/useAccordionController.tsx +43 -11
  30. package/src/components/common/Card/index.test.tsx +36 -0
  31. package/src/components/common/Card/index.tsx +62 -22
  32. package/src/components/common/DataPagination/components/PaginationButton.tsx +1 -1
  33. package/src/components/common/DataPagination/index.tsx +1 -1
  34. package/src/components/common/ImageCard/index.test.tsx +78 -0
  35. package/src/components/common/ImageCard/index.tsx +43 -0
  36. package/src/components/common/ListWithIcons/components/ListWithIconsItem.tsx +94 -0
  37. package/src/components/common/ListWithIcons/index.test.tsx +75 -0
  38. package/src/components/common/ListWithIcons/index.tsx +47 -0
  39. package/src/components/form/inputs/CheckboxFormControl.tsx +1 -1
  40. package/src/components/form/inputs/FileDropzone.tsx +1 -1
  41. package/src/components/form/inputs/FileUpload.tsx +9 -3
  42. package/src/components/form/inputs/NumberStepper.tsx +2 -2
  43. package/src/components/form/inputs/PhoneInputFormControl/components/RowComponent.tsx +1 -0
  44. package/src/components/form/inputs/RadioButtonGroup.tsx +1 -1
  45. package/src/components/layout/Footer/index.test.tsx +20 -0
  46. package/src/components/layout/Footer/index.tsx +33 -0
  47. package/src/components/layout/ServiceFormContainer/AccordionFormContainer/index.tsx +21 -4
  48. package/src/components/layout/ServiceFormContainer/AccordionFormContainer/utils.ts +0 -1
  49. package/src/components/layout/ServiceFormContainer/CardFormContainer/index.test.tsx +14 -12
  50. package/src/components/layout/ServiceFormContainer/CardFormContainer/index.tsx +4 -1
  51. package/src/components/layout/ServiceWizardStepper/StepperTypes.ts +0 -3
  52. package/src/components/layout/ServiceWizardStepper/components/DesktopStepper.test.tsx +33 -4
  53. package/src/components/layout/ServiceWizardStepper/components/DesktopStepper.tsx +6 -2
  54. package/src/components/layout/ServiceWizardStepper/components/MobileStepper.test.tsx +34 -7
  55. package/src/components/layout/ServiceWizardStepper/components/MobileStepper.tsx +4 -2
  56. package/src/components/layout/ServiceWizardStepper/components/StyledStepLabel.tsx +4 -2
  57. package/src/components/layout/ServiceWizardStepper/index.tsx +13 -21
  58. package/src/examples/CardMultipleStepForm/index.tsx +18 -31
  59. package/src/examples/HorizontalMultiStepForm/index.tsx +22 -17
  60. package/src/examples/ListWithPagination/index.tsx +41 -11
  61. package/src/library/icons.ts +3 -2
  62. package/src/library/index.ts +14 -22
  63. package/src/library/types.ts +6 -0
  64. package/src/stories/ServiceWizardStepper.stories.tsx +28 -14
  65. package/src/stories/components/Card.stories.tsx +18 -0
  66. package/src/stories/components/ImageCard.stories.tsx +54 -0
  67. package/src/stories/components/ListWithIcons.stories.tsx +74 -0
  68. package/src/stories/components/form/CardFormContainer.stories.tsx +22 -32
  69. package/src/stories/components/inputs/FileDropzone.stories.tsx +117 -0
  70. package/src/stories/components/inputs/PhoneInput.stories.tsx +110 -0
  71. package/src/stories/components/layout/Footer.stories.tsx +19 -0
  72. package/src/theme/light/MuiAutocomplete.ts +4 -0
  73. package/src/theme/light/MuiCard.tsx +16 -2
  74. package/src/theme/light/MuiInputBase.ts +3 -1
@@ -0,0 +1,78 @@
1
+ import { ThemeProvider } from '@mui/material/styles'
2
+ import '@testing-library/jest-dom'
3
+ import { render, screen } from '@testing-library/react'
4
+ import { type ReactElement } from 'react'
5
+ import { describe, expect, test } from 'vitest'
6
+
7
+ import theme from '../../../theme/light'
8
+ import RcSesImageCard from './index'
9
+
10
+ const renderCard = (ui: ReactElement) =>
11
+ render(<ThemeProvider theme={theme}>{ui}</ThemeProvider>)
12
+
13
+ describe('RcSesImageCard', () => {
14
+ test('renders image, title, description and button', () => {
15
+ renderCard(
16
+ <RcSesImageCard
17
+ image={<img src='test.png' alt='icon' />}
18
+ title='Heading text'
19
+ description='Description text'
20
+ button={<button type='button'>Click me</button>}
21
+ />,
22
+ )
23
+
24
+ expect(screen.getByRole('img', { name: 'icon' })).toBeInTheDocument()
25
+ expect(screen.getByText('Heading text')).toBeInTheDocument()
26
+ expect(screen.getByText('Description text')).toBeInTheDocument()
27
+ expect(screen.getByRole('button', { name: 'Click me' })).toBeInTheDocument()
28
+ })
29
+
30
+ test('renders without description and button', () => {
31
+ renderCard(
32
+ <RcSesImageCard image={<img src='test.png' alt='icon' />} title='Title only' />,
33
+ )
34
+
35
+ expect(screen.getByRole('img', { name: 'icon' })).toBeInTheDocument()
36
+ expect(screen.getByText('Title only')).toBeInTheDocument()
37
+ expect(screen.queryByText('Description text')).not.toBeInTheDocument()
38
+ expect(screen.queryByRole('button')).not.toBeInTheDocument()
39
+ })
40
+
41
+ test('hides button when not provided', () => {
42
+ renderCard(
43
+ <RcSesImageCard
44
+ image={<img src='test.png' alt='icon' />}
45
+ title='No button'
46
+ description='Some description'
47
+ />,
48
+ )
49
+
50
+ expect(screen.queryByRole('button')).not.toBeInTheDocument()
51
+ })
52
+
53
+ test('forwards testIds to internal sections', () => {
54
+ renderCard(
55
+ <RcSesImageCard
56
+ image={<img src='test.png' alt='icon' />}
57
+ title='Test ids'
58
+ description='Description'
59
+ button={<button type='button'>Action</button>}
60
+ testIds={{
61
+ root: 'image-card-root',
62
+ image: 'image-card-image',
63
+ header: 'image-card-header',
64
+ title: 'image-card-title',
65
+ description: 'image-card-description',
66
+ content: 'image-card-content',
67
+ }}
68
+ />,
69
+ )
70
+
71
+ expect(screen.getByTestId('image-card-root')).toBeInTheDocument()
72
+ expect(screen.getByTestId('image-card-image')).toBeInTheDocument()
73
+ expect(screen.getByTestId('image-card-header')).toBeInTheDocument()
74
+ expect(screen.getByTestId('image-card-title')).toBeInTheDocument()
75
+ expect(screen.getByTestId('image-card-description')).toBeInTheDocument()
76
+ expect(screen.getByTestId('image-card-content')).toBeInTheDocument()
77
+ })
78
+ })
@@ -0,0 +1,43 @@
1
+ import { ReactNode } from 'react'
2
+
3
+ import RcSesCard, { RcSesCardProps, RcSesCardTestIds } from '@/components/common/Card'
4
+
5
+ export type RcSesImageCardTestIds = Pick<
6
+ RcSesCardTestIds,
7
+ 'root' | 'image' | 'header' | 'title' | 'description' | 'content'
8
+ >
9
+
10
+ export type RcSesImageCardProps = {
11
+ image: ReactNode
12
+ title: ReactNode
13
+ description?: ReactNode
14
+ button?: ReactNode
15
+ testIds?: RcSesImageCardTestIds
16
+ slotProps?: RcSesCardProps['slotProps']
17
+ }
18
+
19
+ function RcSesImageCard({
20
+ image,
21
+ title,
22
+ description,
23
+ button,
24
+ testIds,
25
+ slotProps,
26
+ }: RcSesImageCardProps) {
27
+ return (
28
+ <RcSesCard
29
+ centered
30
+ contentBackground={false}
31
+ description={description}
32
+ image={image}
33
+ slotProps={slotProps}
34
+ testIds={testIds}
35
+ title={title}
36
+ variant='elevation'
37
+ >
38
+ {button}
39
+ </RcSesCard>
40
+ )
41
+ }
42
+
43
+ export default RcSesImageCard
@@ -0,0 +1,94 @@
1
+ import { Box, Skeleton, Tooltip, Typography } from '@mui/material'
2
+
3
+ import palette from '@/theme/palette'
4
+
5
+ interface Props {
6
+ icon?: React.ReactNode
7
+ text?: string
8
+ disabled?: boolean
9
+ tooltip?: string
10
+ isLoading?: boolean
11
+ }
12
+
13
+ const ListWithIconsItem = ({ icon, text, disabled, tooltip, isLoading }: Props) => {
14
+ const content = (
15
+ <Box
16
+ sx={{
17
+ display: 'inline-flex',
18
+ alignItems: 'center',
19
+ gap: 0.5,
20
+ maxWidth: { xs: '100%', md: 'none' },
21
+ }}
22
+ >
23
+ <Box sx={{ display: 'flex', alignItems: 'center', width: 20 }}>{icon}</Box>
24
+ <Typography
25
+ variant='body2'
26
+ sx={{
27
+ fontSize: '14px',
28
+ fontWeight: 300,
29
+ whiteSpace: 'nowrap',
30
+ }}
31
+ >
32
+ {text}
33
+ </Typography>
34
+ </Box>
35
+ )
36
+
37
+ const contentToReturn = tooltip ? (
38
+ <Tooltip
39
+ title={tooltip ?? ''}
40
+ arrow
41
+ placement='top'
42
+ slotProps={{
43
+ tooltip: {
44
+ sx: {
45
+ bgcolor: palette.grey[50],
46
+ color: 'text.primary',
47
+ fontSize: '14px',
48
+ fontWeight: 300,
49
+ px: 2,
50
+ py: 1,
51
+ borderRadius: '12px',
52
+ boxShadow: '0px 8px 10px rgba(0,0,0,0.15)',
53
+ },
54
+ },
55
+ arrow: { sx: { color: palette.grey[50] } },
56
+ }}
57
+ >
58
+ {content}
59
+ </Tooltip>
60
+ ) : (
61
+ content
62
+ )
63
+
64
+ return (
65
+ <Box
66
+ component='li'
67
+ sx={{
68
+ display: 'flex',
69
+ alignItems: 'center',
70
+ width: { xs: '100%', md: isLoading ? '120px' : 'auto' },
71
+ gap: 0.5,
72
+ minHeight: 20,
73
+ opacity: disabled ? 0.5 : 1,
74
+ pointerEvents: disabled ? 'none' : 'auto',
75
+ }}
76
+ >
77
+ {isLoading ? (
78
+ <Skeleton
79
+ variant='rectangular'
80
+ sx={{
81
+ flex: 1,
82
+ height: 16,
83
+ borderRadius: 1,
84
+ width: { xs: '100%', md: 120 },
85
+ }}
86
+ />
87
+ ) : (
88
+ contentToReturn
89
+ )}
90
+ </Box>
91
+ )
92
+ }
93
+
94
+ export default ListWithIconsItem
@@ -0,0 +1,75 @@
1
+ import { ThemeProvider } from '@mui/material/styles'
2
+ import { fireEvent, render, screen } from '@testing-library/react'
3
+ import { type ReactElement } from 'react'
4
+ import { describe, expect, test } from 'vitest'
5
+
6
+ import theme from '@/theme/light'
7
+
8
+ import ListWithIcons from './index'
9
+
10
+ const renderListWithIcons = (ui: ReactElement) =>
11
+ render(<ThemeProvider theme={theme}>{ui}</ThemeProvider>)
12
+
13
+ describe('ListWithIcons', () => {
14
+ test('renders all provided items with their text and icon', () => {
15
+ renderListWithIcons(
16
+ <ListWithIcons
17
+ items={[
18
+ {
19
+ id: 'first',
20
+ icon: <span data-testid='first-icon'>I1</span>,
21
+ text: 'First item',
22
+ tooltip: 'First tooltip',
23
+ },
24
+ {
25
+ id: 'second',
26
+ icon: <span data-testid='second-icon'>I2</span>,
27
+ text: 'Second item',
28
+ tooltip: 'Second tooltip',
29
+ },
30
+ ]}
31
+ />,
32
+ )
33
+
34
+ expect(screen.getByRole('list')).toBeInTheDocument()
35
+ expect(screen.getAllByRole('listitem')).toHaveLength(2)
36
+ expect(screen.getByText('First item')).toBeInTheDocument()
37
+ expect(screen.getByText('Second item')).toBeInTheDocument()
38
+ expect(screen.getByTestId('first-icon')).toBeInTheDocument()
39
+ expect(screen.getByTestId('second-icon')).toBeInTheDocument()
40
+ })
41
+
42
+ test('renders one loading skeleton per item when isLoading is true', () => {
43
+ const { container } = renderListWithIcons(
44
+ <ListWithIcons
45
+ isLoading
46
+ items={[
47
+ { id: 'first', text: 'First item' },
48
+ { id: 'second', text: 'Second item' },
49
+ { id: 'third', text: 'Third item' },
50
+ ]}
51
+ />,
52
+ )
53
+
54
+ expect(container.querySelectorAll('.MuiSkeleton-root')).toHaveLength(3)
55
+ expect(screen.queryByText('First item')).not.toBeInTheDocument()
56
+ })
57
+
58
+ test('shows tooltip content on hover when tooltip is provided', async () => {
59
+ renderListWithIcons(
60
+ <ListWithIcons
61
+ items={[
62
+ {
63
+ id: 'first',
64
+ text: 'Hover me',
65
+ tooltip: 'Helpful tooltip text',
66
+ },
67
+ ]}
68
+ />,
69
+ )
70
+
71
+ fireEvent.mouseOver(screen.getByText('Hover me'))
72
+
73
+ expect(await screen.findByRole('tooltip')).toHaveTextContent('Helpful tooltip text')
74
+ })
75
+ })
@@ -0,0 +1,47 @@
1
+ import { Box } from '@mui/material'
2
+
3
+ import ListWithIconsItem from './components/ListWithIconsItem'
4
+
5
+ export interface ListWithIconsItemData {
6
+ id: string
7
+ icon?: React.ReactNode
8
+ text?: string
9
+ disabled?: boolean
10
+ tooltip?: string
11
+ }
12
+
13
+ export interface ListWithIconsProps {
14
+ items: ListWithIconsItemData[]
15
+ layout?: 'horizontal' | 'vertical'
16
+ isLoading?: boolean
17
+ }
18
+
19
+ const ListWithIcons = ({ items, layout = 'vertical', isLoading }: ListWithIconsProps) => (
20
+ <Box
21
+ component='ul'
22
+ sx={{
23
+ p: 0,
24
+ m: 0,
25
+ width: '100%',
26
+ minWidth: {
27
+ md: 120,
28
+ },
29
+ display: 'flex',
30
+ flexDirection: {
31
+ xs: 'column',
32
+ md: layout === 'horizontal' ? 'row' : 'column',
33
+ },
34
+ flexWrap: layout === 'horizontal' ? 'wrap' : 'nowrap',
35
+ gap: {
36
+ xs: '4px',
37
+ md: layout === 'horizontal' ? '16px' : '8px',
38
+ },
39
+ }}
40
+ >
41
+ {items.map((item) => (
42
+ <ListWithIconsItem key={item.id} {...item} isLoading={isLoading} />
43
+ ))}
44
+ </Box>
45
+ )
46
+
47
+ export default ListWithIcons
@@ -111,7 +111,7 @@ function RcSesCheckboxFormControl(props: Props) {
111
111
  borderColor: palette.grey['500'],
112
112
  borderStyle: 'solid',
113
113
  borderWidth: '1px',
114
- borderRadius: '.25rem',
114
+ borderRadius: '.5rem',
115
115
  margin: 0,
116
116
  padding: '1rem 1.25rem 1rem .875rem',
117
117
  }
@@ -101,7 +101,7 @@ function RcSesFileDropzone(props: Props) {
101
101
  if (fieldProps.disabled) return palette.grey[300]
102
102
  return isDragActive ? palette.primary[500] : palette.grey[500]
103
103
  },
104
- borderRadius: '.1875rem',
104
+ borderRadius: '.5rem',
105
105
  borderStyle: 'dashed',
106
106
  borderWidth: 1,
107
107
  px: 5.5,
@@ -76,9 +76,12 @@ function RcSesFileUpload(props: Props) {
76
76
  role={undefined}
77
77
  sx={{
78
78
  backgroundColor: 'white !important',
79
+ borderRadius: '0.5rem',
79
80
  display: 'flex',
80
81
  justifyContent: 'space-between',
81
- overflow: 'visible',
82
+ minHeight: '2.75rem',
83
+ overflow: 'hidden',
84
+ p: 0,
82
85
  pl: 1.25,
83
86
  pr: 0,
84
87
  position: 'relative',
@@ -88,7 +91,7 @@ function RcSesFileUpload(props: Props) {
88
91
  background: 'transparent',
89
92
  border: '2px solid',
90
93
  borderColor: palette.grey[950],
91
- borderRadius: '.375rem',
94
+ borderRadius: '.5rem',
92
95
  height: 'calc(100% + 6px)',
93
96
  left: '-3px',
94
97
  position: 'absolute',
@@ -116,13 +119,16 @@ function RcSesFileUpload(props: Props) {
116
119
  className='faux-button'
117
120
  sx={{
118
121
  alignItems: 'center',
122
+ alignSelf: 'stretch',
119
123
  backgroundColor: palette.grey['100'],
120
124
  borderColor: palette.grey['500'],
125
+ borderBottomRightRadius: 'calc(0.5rem - 1px)',
121
126
  borderLeftStyle: 'solid',
122
127
  borderLeftWidth: '1px',
128
+ borderTopRightRadius: 'calc(0.5rem - 1px)',
123
129
  color: palette.grey['900'],
124
130
  display: 'flex',
125
- height: '42px',
131
+ flexShrink: 0,
126
132
  position: 'relative',
127
133
  px: 2,
128
134
  ':hover': {
@@ -33,8 +33,8 @@ const NumberInput = styled(OutlinedInput)({
33
33
  borderRightStyle: 'none !important',
34
34
 
35
35
  '&:last-of-type': {
36
- borderTopRightRadius: '.25rem',
37
- borderBottomRightRadius: '.25rem',
36
+ borderTopRightRadius: '.5rem',
37
+ borderBottomRightRadius: '.5rem',
38
38
  },
39
39
 
40
40
  '&:hover:not(:disabled)': {
@@ -14,6 +14,7 @@ function RowComponent(props: ListChildComponentProps) {
14
14
  sx={{
15
15
  alignItems: 'center !important',
16
16
  backgroundSize: 'auto',
17
+ borderRadius: '.375rem',
17
18
  flexDirection: 'row !important',
18
19
  gap: 1.5,
19
20
  right: 0,
@@ -103,7 +103,7 @@ const RcSesRadioButtonGroup = styled(UnstyledRcSesRadioButtonGroup)((props) => (
103
103
  borderColor: props.variant === 'outlined' ? palette.grey['500'] : 'transparent',
104
104
  borderStyle: 'solid',
105
105
  borderWidth: props.variant === 'outlined' ? '1px' : 0,
106
- borderRadius: '.1875rem',
106
+ borderRadius: '.5rem',
107
107
  margin: 0,
108
108
  padding: props.hideNativeRadio ? undefined : '.25rem .75rem',
109
109
  },
@@ -0,0 +1,20 @@
1
+ import { ThemeProvider } from '@mui/material/styles'
2
+ import '@testing-library/jest-dom'
3
+ import { render, screen } from '@testing-library/react'
4
+ import { type ReactElement } from 'react'
5
+ import { describe, expect, test } from 'vitest'
6
+
7
+ import theme from '@/theme/light'
8
+
9
+ import RcSesFooter from './index'
10
+
11
+ const renderFooter = (ui: ReactElement) =>
12
+ render(<ThemeProvider theme={theme}>{ui}</ThemeProvider>)
13
+
14
+ describe('RcSesFooter', () => {
15
+ test('renders footer text', () => {
16
+ renderFooter(<RcSesFooter text='Footer text' />)
17
+
18
+ expect(screen.getByText('Footer text')).toBeInTheDocument()
19
+ })
20
+ })
@@ -0,0 +1,33 @@
1
+ import { Box, Container, Typography } from '@mui/material'
2
+
3
+ import palette from '@/theme/palette'
4
+
5
+ type Props = {
6
+ text: string
7
+ }
8
+
9
+ function RcSesFooter({ text }: Props) {
10
+ return (
11
+ <Box
12
+ sx={{
13
+ backgroundColor: palette.grey['900'],
14
+ px: { xs: 2, md: 4 },
15
+ py: 3,
16
+ textAlign: 'center',
17
+ }}
18
+ >
19
+ <Container>
20
+ <Typography
21
+ color={palette.grey['200']}
22
+ component='div'
23
+ sx={{ lineHeight: '1.25rem', whiteSpace: 'pre-line' }}
24
+ variant='caption'
25
+ >
26
+ {text}
27
+ </Typography>
28
+ </Container>
29
+ </Box>
30
+ )
31
+ }
32
+
33
+ export default RcSesFooter
@@ -1,6 +1,6 @@
1
1
  import { Container, Grid } from '@mui/material'
2
2
  import { ContainerProps } from '@mui/system'
3
- import React from 'react'
3
+ import React, { useMemo } from 'react'
4
4
 
5
5
  import useAccordionController from '@/components/common/Accordion/hooks/useAccordionController'
6
6
  import palette from '@/theme/palette'
@@ -26,13 +26,28 @@ function RcSesServiceFormContainer({
26
26
  showProgressStepper = false,
27
27
  slotProps,
28
28
  }: Props) {
29
- const { state } = accordionController
29
+ const { state, open } = accordionController
30
30
 
31
- const areAccordionCollapseControlsVisible = React.useMemo(() => {
31
+ const steps = useMemo(() => mapAccordionStateToSteps(state), [state])
32
+
33
+ const activeStep = useMemo(() => {
34
+ const entries = Object.values(state)
35
+ const index = entries.findIndex((item) => item.expanded)
36
+ return index === -1 ? 0 : index
37
+ }, [state])
38
+
39
+ const areAccordionCollapseControlsVisible = useMemo(() => {
32
40
  if (Object.keys(state).length <= 1 || !showAccordionCollapseControls) return false
33
41
  return true
34
42
  }, [showAccordionCollapseControls, state])
35
43
 
44
+ const handleStepClick = (index: number) => {
45
+ const step = steps[index]
46
+ if (step) {
47
+ open(step.id)
48
+ }
49
+ }
50
+
36
51
  return (
37
52
  <Container
38
53
  maxWidth={showProgressStepper ? 'lg' : 'md'}
@@ -53,8 +68,10 @@ function RcSesServiceFormContainer({
53
68
  {showProgressStepper && (
54
69
  <Grid item sx={{ display: { xs: 'none', md: 'block' }, flex: '0 0 270px' }}>
55
70
  <ServiceWizardStepper
56
- steps={mapAccordionStateToSteps(state)}
71
+ steps={steps}
57
72
  orientation='vertical'
73
+ activeStep={activeStep}
74
+ onStepClick={handleStepClick}
58
75
  />
59
76
  </Grid>
60
77
  )}
@@ -5,7 +5,6 @@ function mapAccordionStateToSteps(state: AccordionControllerState): StepItem[] {
5
5
  return Object.entries(state).map(([id, step]) => ({
6
6
  id,
7
7
  title: step.title,
8
- state: step.state,
9
8
  }))
10
9
  }
11
10
 
@@ -8,9 +8,9 @@ import { StepItem } from '../../ServiceWizardStepper/StepperTypes'
8
8
  import RcSesCardFormContainer from './index'
9
9
 
10
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' },
11
+ { id: '1', title: 'Step 1' },
12
+ { id: '2', title: 'Step 2' },
13
+ { id: '3', title: 'Step 3' },
14
14
  ]
15
15
 
16
16
  const renderWithTheme = (ui: ReactElement) =>
@@ -19,7 +19,7 @@ const renderWithTheme = (ui: ReactElement) =>
19
19
  describe('RcSesCardFormContainer', () => {
20
20
  test('renders stepper, card content, and card title', () => {
21
21
  renderWithTheme(
22
- <RcSesCardFormContainer steps={baseSteps} title='Form title'>
22
+ <RcSesCardFormContainer steps={baseSteps} activeStep={1} title='Form title'>
23
23
  <div>Form content</div>
24
24
  </RcSesCardFormContainer>,
25
25
  )
@@ -33,7 +33,7 @@ describe('RcSesCardFormContainer', () => {
33
33
 
34
34
  test('uses horizontal orientation by default', () => {
35
35
  const { container } = renderWithTheme(
36
- <RcSesCardFormContainer steps={baseSteps} title='Default layout'>
36
+ <RcSesCardFormContainer steps={baseSteps} activeStep={1} title='Default layout'>
37
37
  <div>Body</div>
38
38
  </RcSesCardFormContainer>,
39
39
  )
@@ -45,7 +45,12 @@ describe('RcSesCardFormContainer', () => {
45
45
 
46
46
  test('uses vertical orientation when layout is row', () => {
47
47
  const { container } = renderWithTheme(
48
- <RcSesCardFormContainer steps={baseSteps} title='Row layout' layout='row'>
48
+ <RcSesCardFormContainer
49
+ steps={baseSteps}
50
+ activeStep={1}
51
+ title='Row layout'
52
+ layout='row'
53
+ >
49
54
  <div>Body</div>
50
55
  </RcSesCardFormContainer>,
51
56
  )
@@ -53,12 +58,13 @@ describe('RcSesCardFormContainer', () => {
53
58
  expect(container.querySelector('.ServiceWizardStepper-vertical')).toBeInTheDocument()
54
59
  })
55
60
 
56
- test('forwards step click updates through onStepClick', () => {
61
+ test('calls onStepClick with index when a step is clicked', () => {
57
62
  const onStepClick = vi.fn()
58
63
 
59
64
  renderWithTheme(
60
65
  <RcSesCardFormContainer
61
66
  steps={baseSteps}
67
+ activeStep={1}
62
68
  title='Clickable steps'
63
69
  onStepClick={onStepClick}
64
70
  >
@@ -69,10 +75,6 @@ describe('RcSesCardFormContainer', () => {
69
75
  fireEvent.click(screen.getByText('Step 1'))
70
76
 
71
77
  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
- ])
78
+ expect(onStepClick).toHaveBeenCalledWith(0)
77
79
  })
78
80
  })
@@ -9,7 +9,8 @@ export type LayoutMode = 'column' | 'row'
9
9
 
10
10
  export interface RcSesCardFormContainerProps extends RcSesCardProps {
11
11
  steps: StepItem[]
12
- onStepClick?: (steps: StepItem[]) => void
12
+ onStepClick?: (index: number) => void
13
+ activeStep: number
13
14
  layout?: LayoutMode
14
15
  isLoading?: boolean
15
16
  }
@@ -17,6 +18,7 @@ export interface RcSesCardFormContainerProps extends RcSesCardProps {
17
18
  const RcSesCardFormContainer = ({
18
19
  steps,
19
20
  onStepClick,
21
+ activeStep,
20
22
  layout,
21
23
  children,
22
24
  isLoading = false,
@@ -48,6 +50,7 @@ const RcSesCardFormContainer = ({
48
50
  <ServiceWizardStepper
49
51
  steps={steps}
50
52
  onStepClick={onStepClick}
53
+ activeStep={activeStep}
51
54
  orientation={layoutDirection === 'row' ? 'vertical' : 'horizontal'}
52
55
  isLoading={isLoading}
53
56
  />
@@ -1,7 +1,4 @@
1
- type StepState = 'active' | 'completed' | 'pending'
2
-
3
1
  export interface StepItem {
4
2
  id: string
5
3
  title: string
6
- state: StepState
7
4
  }