@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,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: '.
|
|
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: '.
|
|
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
|
-
|
|
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: '.
|
|
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
|
-
|
|
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: '.
|
|
37
|
-
borderBottomRightRadius: '.
|
|
36
|
+
borderTopRightRadius: '.5rem',
|
|
37
|
+
borderBottomRightRadius: '.5rem',
|
|
38
38
|
},
|
|
39
39
|
|
|
40
40
|
'&:hover:not(:disabled)': {
|
|
@@ -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: '.
|
|
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
|
package/src/components/layout/ServiceFormContainer/{index.tsx → AccordionFormContainer/index.tsx}
RENAMED
|
@@ -1,11 +1,11 @@
|
|
|
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'
|
|
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
|
|
|
@@ -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
|
|
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={
|
|
71
|
+
steps={steps}
|
|
57
72
|
orientation='vertical'
|
|
73
|
+
activeStep={activeStep}
|
|
74
|
+
onStepClick={handleStepClick}
|
|
58
75
|
/>
|
|
59
76
|
</Grid>
|
|
60
77
|
)}
|
package/src/components/layout/ServiceFormContainer/{utils.ts → AccordionFormContainer/utils.ts}
RENAMED
|
@@ -1,11 +1,10 @@
|
|
|
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]) => ({
|
|
6
6
|
id,
|
|
7
7
|
title: step.title,
|
|
8
|
-
state: step.state,
|
|
9
8
|
}))
|
|
10
9
|
}
|
|
11
10
|
|
|
@@ -0,0 +1,80 @@
|
|
|
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' },
|
|
12
|
+
{ id: '2', title: 'Step 2' },
|
|
13
|
+
{ id: '3', title: 'Step 3' },
|
|
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} activeStep={1} 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} activeStep={1} 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
|
|
49
|
+
steps={baseSteps}
|
|
50
|
+
activeStep={1}
|
|
51
|
+
title='Row layout'
|
|
52
|
+
layout='row'
|
|
53
|
+
>
|
|
54
|
+
<div>Body</div>
|
|
55
|
+
</RcSesCardFormContainer>,
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
expect(container.querySelector('.ServiceWizardStepper-vertical')).toBeInTheDocument()
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
test('calls onStepClick with index when a step is clicked', () => {
|
|
62
|
+
const onStepClick = vi.fn()
|
|
63
|
+
|
|
64
|
+
renderWithTheme(
|
|
65
|
+
<RcSesCardFormContainer
|
|
66
|
+
steps={baseSteps}
|
|
67
|
+
activeStep={1}
|
|
68
|
+
title='Clickable steps'
|
|
69
|
+
onStepClick={onStepClick}
|
|
70
|
+
>
|
|
71
|
+
<div>Body</div>
|
|
72
|
+
</RcSesCardFormContainer>,
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
fireEvent.click(screen.getByText('Step 1'))
|
|
76
|
+
|
|
77
|
+
expect(onStepClick).toHaveBeenCalledTimes(1)
|
|
78
|
+
expect(onStepClick).toHaveBeenCalledWith(0)
|
|
79
|
+
})
|
|
80
|
+
})
|