@registrucentras/rc-ses-react-components 1.3.0 → 1.4.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/README.md +3 -1
- package/dist/assets/IconProps.d.ts +4 -2
- package/dist/assets/icons/ArrowLeftIcon.d.ts +3 -0
- package/dist/assets/icons/ArrowRightIcon.d.ts +1 -1
- package/dist/assets/icons/BarcodeIcon.d.ts +3 -0
- package/dist/assets/icons/CalendarBlankIcon.d.ts +1 -1
- package/dist/assets/icons/CaretDoubleLeftBoldIcon.d.ts +1 -1
- package/dist/assets/icons/CaretDoubleRightBoldIcon.d.ts +1 -1
- package/dist/assets/icons/CaretDownBoldIcon.d.ts +1 -1
- package/dist/assets/icons/CaretDownFill.d.ts +2 -2
- package/dist/assets/icons/CaretDownIcon.d.ts +1 -1
- package/dist/assets/icons/CaretLeftBoldIcon.d.ts +1 -1
- package/dist/assets/icons/CaretLeftIcon.d.ts +1 -1
- package/dist/assets/icons/CaretRightBoldIcon.d.ts +1 -1
- package/dist/assets/icons/CheckBoldIcon.d.ts +1 -1
- package/dist/assets/icons/CheckCircleFillIcon.d.ts +2 -2
- package/dist/assets/icons/CheckUncheckedBoldIcon.d.ts +1 -1
- package/dist/assets/icons/CircleFilledIcon.d.ts +3 -0
- package/dist/assets/icons/CloseIcon.d.ts +1 -1
- package/dist/assets/icons/CollapseChevronsIcon.d.ts +1 -1
- package/dist/assets/icons/DotCircleFilledIcon.d.ts +3 -0
- package/dist/assets/icons/ExpandChevronsIcon.d.ts +1 -1
- package/dist/assets/icons/InfoFillIcon.d.ts +1 -1
- package/dist/assets/icons/MagnifyingGlassIcon.d.ts +2 -2
- package/dist/assets/icons/MapPinAreaIcon.d.ts +3 -0
- package/dist/assets/icons/MinusBoldIcon.d.ts +1 -1
- package/dist/assets/icons/PlusBoldIcon.d.ts +1 -1
- package/dist/assets/icons/QuestionFillIcon.d.ts +1 -1
- package/dist/assets/icons/QuestionIcon.d.ts +1 -1
- package/dist/assets/icons/ScalesIcon.d.ts +3 -0
- package/dist/assets/icons/ScrollIcon.d.ts +1 -1
- package/dist/assets/icons/SpinnerGapBoldIcon.d.ts +1 -1
- package/dist/assets/icons/UploadSimpleIcon.d.ts +1 -1
- package/dist/assets/icons/WarningDiamondFillIcon.d.ts +1 -1
- package/dist/assets/icons/WarningFillIcon.d.ts +1 -1
- package/dist/assets/icons/XCircleFillIcon.d.ts +2 -2
- package/dist/components/common/Button/index.d.ts +2 -2
- package/dist/components/common/Card/index.d.ts +31 -0
- package/dist/components/common/DataPagination/components/PaginationButton.d.ts +8 -0
- package/dist/components/common/DataPagination/index.d.ts +10 -0
- package/dist/components/layout/ServiceFormContainer/utils.d.ts +4 -0
- package/dist/components/layout/ServiceWizardStepper/StepConnector.d.ts +7 -0
- package/dist/components/layout/ServiceWizardStepper/StepperTypes.d.ts +7 -0
- package/dist/components/layout/ServiceWizardStepper/components/CustomStepIcon.d.ts +3 -0
- package/dist/components/layout/ServiceWizardStepper/components/DesktopStepper.d.ts +9 -0
- package/dist/components/layout/ServiceWizardStepper/components/HorizontalStepperButton.d.ts +6 -0
- package/dist/components/layout/ServiceWizardStepper/components/MobileStepper.d.ts +8 -0
- package/dist/components/layout/ServiceWizardStepper/components/StyledStepLabel.d.ts +11 -0
- package/dist/components/layout/ServiceWizardStepper/index.d.ts +6 -5
- package/dist/library/icons.d.ts +27 -3
- package/dist/library/index.d.ts +6 -2
- package/dist/registrucentras-rc-ses-react-components.cjs +12 -12
- package/dist/registrucentras-rc-ses-react-components.js +3893 -2677
- package/dist/stories/ServiceWizardStepper.stories.d.ts +7 -0
- package/dist/stories/components/Accordion.stories.d.ts +2 -2
- package/dist/stories/components/Card.stories.d.ts +24 -0
- package/dist/stories/components/DataPagination.stories.d.ts +47 -0
- package/dist/stories/components/Icons.stories.d.ts +6 -0
- package/dist/stories/components/buttons/Button.stories.d.ts +10 -0
- package/dist/stories/components/form/CheckboxFormControl.stories.d.ts +2 -2
- package/dist/stories/components/inputs/Checkbox.stories.d.ts +2 -2
- package/dist/stories/components/inputs/FileUpload.stories.d.ts +2 -2
- package/dist/stories/components/inputs/NumberStepper.stories.d.ts +2 -2
- package/dist/stories/components/inputs/SearchableField.stories.d.ts +60 -60
- package/dist/stories/components/inputs/Select.stories.d.ts +126 -126
- package/dist/stories/components/inputs/TextField.stories.d.ts +113 -113
- package/dist/theme/light/MuiPagination.d.ts +2 -1
- package/package.json +2 -1
- package/src/App.tsx +8 -0
- package/src/assets/IconProps.ts +5 -2
- package/src/assets/icons/ArrowLeftIcon.tsx +16 -0
- package/src/assets/icons/ArrowRightIcon.tsx +8 -13
- package/src/assets/icons/BarcodeIcon.tsx +9 -0
- package/src/assets/icons/CalendarBlankIcon.tsx +4 -16
- package/src/assets/icons/CaretDoubleLeftBoldIcon.tsx +14 -12
- package/src/assets/icons/CaretDoubleRightBoldIcon.tsx +14 -12
- package/src/assets/icons/CaretDownBoldIcon.tsx +9 -12
- package/src/assets/icons/CaretDownFill.tsx +11 -10
- package/src/assets/icons/CaretDownIcon.tsx +4 -16
- package/src/assets/icons/CaretLeftBoldIcon.tsx +9 -12
- package/src/assets/icons/CaretLeftIcon.tsx +4 -16
- package/src/assets/icons/CaretRightBoldIcon.tsx +9 -12
- package/src/assets/icons/CheckBoldIcon.tsx +9 -24
- package/src/assets/icons/CheckCircleFillIcon.tsx +10 -14
- package/src/assets/icons/CheckUncheckedBoldIcon.tsx +4 -23
- package/src/assets/icons/CircleFilledIcon.tsx +11 -0
- package/src/assets/icons/CloseIcon.tsx +4 -16
- package/src/assets/icons/CollapseChevronsIcon.tsx +9 -13
- package/src/assets/icons/DotCircleFilledIcon.tsx +23 -0
- package/src/assets/icons/ExpandChevronsIcon.tsx +9 -13
- package/src/assets/icons/InfoFillIcon.tsx +4 -14
- package/src/assets/icons/MagnifyingGlassIcon.tsx +5 -12
- package/src/assets/icons/MapPinAreaIcon.tsx +9 -0
- package/src/assets/icons/MinusBoldIcon.tsx +4 -14
- package/src/assets/icons/PlusBoldIcon.tsx +4 -14
- package/src/assets/icons/QuestionFillIcon.tsx +9 -13
- package/src/assets/icons/QuestionIcon.tsx +4 -16
- package/src/assets/icons/ScalesIcon.tsx +9 -0
- package/src/assets/icons/ScrollIcon.tsx +4 -16
- package/src/assets/icons/SpinnerGapBoldIcon.tsx +9 -12
- package/src/assets/icons/UploadSimpleIcon.tsx +4 -16
- package/src/assets/icons/WarningDiamondFillIcon.tsx +9 -13
- package/src/assets/icons/WarningFillIcon.tsx +9 -13
- package/src/assets/icons/XCircleFillIcon.tsx +11 -10
- package/src/components/common/Alert/index.test.tsx +3 -10
- package/src/components/common/Alert/index.tsx +44 -16
- package/src/components/common/Button/index.tsx +34 -3
- package/src/components/common/Card/index.test.tsx +136 -0
- package/src/components/common/Card/index.tsx +231 -0
- package/src/components/common/DataPagination/components/PaginationButton.tsx +63 -0
- package/src/components/common/DataPagination/index.test.tsx +122 -0
- package/src/components/common/DataPagination/index.tsx +70 -0
- package/src/components/form/inputs/CheckboxFormControl.tsx +1 -11
- package/src/components/form/inputs/PhoneInputFormControl/components/AutocompleteInput.tsx +1 -1
- package/src/components/form/inputs/PhoneInputFormControl/index.tsx +3 -4
- package/src/components/layout/ServiceFormContainer/index.tsx +5 -1
- package/src/components/layout/ServiceFormContainer/utils.ts +12 -0
- package/src/components/layout/ServiceWizardStepper/ServiceWizardStepper.css +69 -0
- package/src/components/layout/ServiceWizardStepper/StepConnector.tsx +29 -0
- package/src/components/layout/ServiceWizardStepper/StepperTypes.ts +7 -0
- package/src/components/layout/ServiceWizardStepper/components/CustomStepIcon.test.tsx +22 -0
- package/src/components/layout/ServiceWizardStepper/components/CustomStepIcon.tsx +41 -0
- package/src/components/layout/ServiceWizardStepper/components/DesktopStepper.test.tsx +40 -0
- package/src/components/layout/ServiceWizardStepper/components/DesktopStepper.tsx +48 -0
- package/src/components/layout/ServiceWizardStepper/components/HorizontalStepperButton.test.tsx +24 -0
- package/src/components/layout/ServiceWizardStepper/components/HorizontalStepperButton.tsx +46 -0
- package/src/components/layout/ServiceWizardStepper/components/MobileStepper.test.tsx +21 -0
- package/src/components/layout/ServiceWizardStepper/components/MobileStepper.tsx +54 -0
- package/src/components/layout/ServiceWizardStepper/components/StyledStepLabel.tsx +53 -0
- package/src/components/layout/ServiceWizardStepper/index.tsx +56 -37
- package/src/examples/HorizontalMultiStepForm/index.tsx +64 -0
- package/src/examples/ListWithPagination/index.tsx +44 -0
- package/src/library/icons.ts +51 -4
- package/src/library/index.ts +6 -2
- package/src/main.tsx +10 -0
- package/src/stories/ServiceWizardStepper.stories.tsx +39 -0
- package/src/stories/components/Alert.stories.tsx +1 -8
- package/src/stories/components/Card.stories.tsx +51 -0
- package/src/stories/components/Card.test.tsx +18 -0
- package/src/stories/components/DataPagination.stories.tsx +75 -0
- package/src/stories/components/Icons.stories.tsx +352 -0
- package/src/stories/components/buttons/Button.stories.tsx +30 -0
- package/src/theme/light/MuiAlert.tsx +10 -10
- package/src/theme/light/MuiButton.tsx +42 -15
- package/src/theme/light/MuiCard.tsx +2 -2
- package/src/theme/light/MuiPagination.ts +40 -12
- package/src/theme/light/index.tsx +2 -1
- package/src/types/buttons/ButtonProps.tsx +3 -1
- package/dist/assets/icons/CheckBoldDisabledIcon.d.ts +0 -3
- package/dist/components/layout/ServiceWizardStepper/components/ActiveStepIcon.d.ts +0 -2
- package/dist/components/layout/ServiceWizardStepper/components/CompletedStepIcon.d.ts +0 -2
- package/dist/components/layout/ServiceWizardStepper/components/PendingStepIcon.d.ts +0 -2
- package/src/assets/icons/CheckBoldDisabledIcon.tsx +0 -32
- package/src/components/layout/ServiceWizardStepper/components/ActiveStepIcon.tsx +0 -15
- package/src/components/layout/ServiceWizardStepper/components/CompletedStepIcon.tsx +0 -19
- package/src/components/layout/ServiceWizardStepper/components/PendingStepIcon.tsx +0 -15
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { useMediaQuery } from '@mui/material'
|
|
2
|
+
import { ThemeProvider } from '@mui/material/styles'
|
|
3
|
+
import { fireEvent, render, screen } from '@testing-library/react'
|
|
4
|
+
import { ReactElement } from 'react'
|
|
5
|
+
import { beforeEach, describe, expect, test, vi } from 'vitest'
|
|
6
|
+
|
|
7
|
+
import theme from '@/theme/light'
|
|
8
|
+
|
|
9
|
+
import DataPagination from './index'
|
|
10
|
+
|
|
11
|
+
vi.mock('@mui/material', async () => {
|
|
12
|
+
const actual = await vi.importActual<typeof import('@mui/material')>('@mui/material')
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
...actual,
|
|
16
|
+
useMediaQuery: vi.fn(() => false),
|
|
17
|
+
}
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
const renderPagination = (ui: ReactElement) =>
|
|
21
|
+
render(<ThemeProvider theme={theme}>{ui}</ThemeProvider>)
|
|
22
|
+
|
|
23
|
+
const mockedUseMediaQuery = vi.mocked(useMediaQuery)
|
|
24
|
+
|
|
25
|
+
beforeEach(() => {
|
|
26
|
+
mockedUseMediaQuery.mockReturnValue(false)
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
describe('DataPagination', () => {
|
|
30
|
+
test('renders labels and disables previous button on first page', () => {
|
|
31
|
+
renderPagination(
|
|
32
|
+
<DataPagination count={5} prevLabel='Previous page' nextLabel='Next page' />,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
expect(screen.getByRole('button', { name: 'Previous page' })).toBeDisabled()
|
|
36
|
+
expect(screen.getByRole('button', { name: 'Next page' })).toBeEnabled()
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
test('updates internal page and calls onChange in uncontrolled mode', () => {
|
|
40
|
+
const onChange = vi.fn()
|
|
41
|
+
|
|
42
|
+
renderPagination(
|
|
43
|
+
<DataPagination
|
|
44
|
+
count={3}
|
|
45
|
+
defaultPage={1}
|
|
46
|
+
onChange={onChange}
|
|
47
|
+
prevLabel='Previous page'
|
|
48
|
+
nextLabel='Next page'
|
|
49
|
+
/>,
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
const nextButton = screen.getByRole('button', { name: 'Next page' })
|
|
53
|
+
|
|
54
|
+
fireEvent.click(nextButton)
|
|
55
|
+
fireEvent.click(nextButton)
|
|
56
|
+
|
|
57
|
+
expect(onChange).toHaveBeenNthCalledWith(1, 2)
|
|
58
|
+
expect(onChange).toHaveBeenNthCalledWith(2, 3)
|
|
59
|
+
expect(nextButton).toBeDisabled()
|
|
60
|
+
expect(screen.getByRole('button', { name: 'Previous page' })).toBeEnabled()
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
test('does not call onChange when trying to go before page 1', () => {
|
|
64
|
+
const onChange = vi.fn()
|
|
65
|
+
|
|
66
|
+
renderPagination(
|
|
67
|
+
<DataPagination
|
|
68
|
+
count={4}
|
|
69
|
+
defaultPage={1}
|
|
70
|
+
onChange={onChange}
|
|
71
|
+
prevLabel='Previous page'
|
|
72
|
+
/>,
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
fireEvent.click(screen.getByRole('button', { name: 'Previous page' }))
|
|
76
|
+
|
|
77
|
+
expect(onChange).not.toHaveBeenCalled()
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
test('uses controlled page value and only emits next page in callback', () => {
|
|
81
|
+
const onChange = vi.fn()
|
|
82
|
+
|
|
83
|
+
renderPagination(
|
|
84
|
+
<DataPagination
|
|
85
|
+
count={5}
|
|
86
|
+
page={1}
|
|
87
|
+
onChange={onChange}
|
|
88
|
+
prevLabel='Previous page'
|
|
89
|
+
nextLabel='Next page'
|
|
90
|
+
/>,
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
fireEvent.click(screen.getByRole('button', { name: 'Next page' }))
|
|
94
|
+
|
|
95
|
+
expect(onChange).toHaveBeenCalledWith(2)
|
|
96
|
+
expect(screen.getByRole('button', { name: 'Previous page' })).toBeDisabled()
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
test('shows 1 2 3 ... x page buttons on mobile', () => {
|
|
100
|
+
mockedUseMediaQuery.mockReturnValue(true)
|
|
101
|
+
|
|
102
|
+
renderPagination(<DataPagination count={10} defaultPage={1} />)
|
|
103
|
+
|
|
104
|
+
expect(screen.getByRole('button', { name: 'page 1' })).toBeInTheDocument()
|
|
105
|
+
expect(screen.getByRole('button', { name: 'Go to page 2' })).toBeInTheDocument()
|
|
106
|
+
expect(screen.getByRole('button', { name: 'Go to page 3' })).toBeInTheDocument()
|
|
107
|
+
expect(screen.queryByRole('button', { name: 'Go to page 4' })).not.toBeInTheDocument()
|
|
108
|
+
expect(screen.getByRole('button', { name: 'Go to page 10' })).toBeInTheDocument()
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
test('shows 1 2 3 4 ... x page buttons on desktop', () => {
|
|
112
|
+
mockedUseMediaQuery.mockReturnValue(false)
|
|
113
|
+
|
|
114
|
+
renderPagination(<DataPagination count={10} defaultPage={1} />)
|
|
115
|
+
|
|
116
|
+
expect(screen.getByRole('button', { name: 'page 1' })).toBeInTheDocument()
|
|
117
|
+
expect(screen.getByRole('button', { name: 'Go to page 2' })).toBeInTheDocument()
|
|
118
|
+
expect(screen.getByRole('button', { name: 'Go to page 3' })).toBeInTheDocument()
|
|
119
|
+
expect(screen.getByRole('button', { name: 'Go to page 4' })).toBeInTheDocument()
|
|
120
|
+
expect(screen.getByRole('button', { name: 'Go to page 10' })).toBeInTheDocument()
|
|
121
|
+
})
|
|
122
|
+
})
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Pagination, useMediaQuery, useTheme } from '@mui/material'
|
|
2
|
+
import { Box } from '@mui/system'
|
|
3
|
+
import { useState } from 'react'
|
|
4
|
+
|
|
5
|
+
import ArrowLeftIcon from '@/assets/icons/ArrowLeftIcon'
|
|
6
|
+
import ArrowRightIcon from '@/assets/icons/ArrowRightIcon'
|
|
7
|
+
|
|
8
|
+
import PaginationButton from './components/PaginationButton'
|
|
9
|
+
|
|
10
|
+
export interface DataPaginationProps {
|
|
11
|
+
count: number
|
|
12
|
+
page?: number
|
|
13
|
+
defaultPage?: number
|
|
14
|
+
onChange?: (page: number) => void
|
|
15
|
+
prevLabel?: string
|
|
16
|
+
nextLabel?: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const DataPagination = ({
|
|
20
|
+
count,
|
|
21
|
+
page,
|
|
22
|
+
defaultPage = 1,
|
|
23
|
+
onChange,
|
|
24
|
+
prevLabel = 'Atgal',
|
|
25
|
+
nextLabel = 'Kitas',
|
|
26
|
+
}: DataPaginationProps) => {
|
|
27
|
+
const theme = useTheme()
|
|
28
|
+
const isMobile = useMediaQuery(theme.breakpoints.down('sm'))
|
|
29
|
+
const isControlled = page !== undefined
|
|
30
|
+
const [internalPage, setInternalPage] = useState(defaultPage)
|
|
31
|
+
|
|
32
|
+
const currentPage = isControlled ? page : internalPage
|
|
33
|
+
|
|
34
|
+
const handlePageChange = (newPage: number) => {
|
|
35
|
+
if (newPage < 1 || newPage > count) return
|
|
36
|
+
|
|
37
|
+
if (!isControlled) {
|
|
38
|
+
setInternalPage(newPage)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
onChange?.(newPage)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<Box display='flex' alignItems='center' gap={1}>
|
|
46
|
+
<PaginationButton
|
|
47
|
+
onClick={() => handlePageChange(currentPage - 1)}
|
|
48
|
+
disabled={currentPage === 1}
|
|
49
|
+
label={prevLabel}
|
|
50
|
+
icon={<ArrowLeftIcon size={16} />}
|
|
51
|
+
/>
|
|
52
|
+
<Pagination
|
|
53
|
+
count={count}
|
|
54
|
+
page={currentPage}
|
|
55
|
+
siblingCount={isMobile ? 0 : 1}
|
|
56
|
+
boundaryCount={1}
|
|
57
|
+
onChange={(_, p) => handlePageChange(p)}
|
|
58
|
+
/>
|
|
59
|
+
<PaginationButton
|
|
60
|
+
onClick={() => handlePageChange(currentPage + 1)}
|
|
61
|
+
disabled={currentPage === count}
|
|
62
|
+
label={nextLabel}
|
|
63
|
+
icon={<ArrowRightIcon size={16} />}
|
|
64
|
+
iconPosition='end'
|
|
65
|
+
/>
|
|
66
|
+
</Box>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export default DataPagination
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable no-nested-ternary */
|
|
2
1
|
import {
|
|
3
2
|
FormControlLabel,
|
|
4
3
|
FormControlLabelProps,
|
|
@@ -10,7 +9,6 @@ import {
|
|
|
10
9
|
import React from 'react'
|
|
11
10
|
import { UseControllerProps, useController } from 'react-hook-form'
|
|
12
11
|
|
|
13
|
-
import CheckBoldDisabledIcon from '@/assets/icons/CheckBoldDisabledIcon'
|
|
14
12
|
import CheckBoldIcon from '@/assets/icons/CheckBoldIcon'
|
|
15
13
|
import CheckUncheckedBoldIcon from '@/assets/icons/CheckUncheckedBoldIcon'
|
|
16
14
|
import SpinnerGapBoldIcon from '@/assets/icons/SpinnerGapBoldIcon'
|
|
@@ -78,15 +76,7 @@ function RcSesCheckboxFormControl(props: Props) {
|
|
|
78
76
|
<MuiCheckbox
|
|
79
77
|
id={id}
|
|
80
78
|
checked={value === true}
|
|
81
|
-
checkedIcon={
|
|
82
|
-
loading ? (
|
|
83
|
-
<LoadingStateIcon />
|
|
84
|
-
) : disabled ? (
|
|
85
|
-
<CheckBoldDisabledIcon />
|
|
86
|
-
) : (
|
|
87
|
-
<CheckBoldIcon />
|
|
88
|
-
)
|
|
89
|
-
}
|
|
79
|
+
checkedIcon={loading ? <LoadingStateIcon /> : <CheckBoldIcon />}
|
|
90
80
|
disabled={disabled}
|
|
91
81
|
icon={loading ? <LoadingStateIcon /> : <CheckUncheckedBoldIcon />}
|
|
92
82
|
{...controllerProps}
|
|
@@ -23,7 +23,7 @@ function AutocompleteInput(props: AutocompleteRenderInputParams) {
|
|
|
23
23
|
endAdornment: null,
|
|
24
24
|
startAdornment: (
|
|
25
25
|
<InputAdornment position='start' sx={{ pl: 1 }}>
|
|
26
|
-
<MagnifyingGlassIcon
|
|
26
|
+
<MagnifyingGlassIcon fillColor={palette.grey[900]} />
|
|
27
27
|
</InputAdornment>
|
|
28
28
|
),
|
|
29
29
|
}}
|
|
@@ -142,10 +142,9 @@ function RcSesPhoneInputFormControl(props: Props) {
|
|
|
142
142
|
}}
|
|
143
143
|
title={country?.name}
|
|
144
144
|
/>
|
|
145
|
-
<
|
|
146
|
-
aria-hidden
|
|
147
|
-
|
|
148
|
-
/>
|
|
145
|
+
<Box component='span' sx={{ display: 'flex', ml: 1 }}>
|
|
146
|
+
<CaretDownFill aria-hidden size={12} />
|
|
147
|
+
</Box>
|
|
149
148
|
</Button>
|
|
150
149
|
</InputAdornment>
|
|
151
150
|
|
|
@@ -7,6 +7,7 @@ import palette from '@/theme/palette'
|
|
|
7
7
|
|
|
8
8
|
import ServiceWizardStepper from '../ServiceWizardStepper'
|
|
9
9
|
import AccordionCollapseControls from './components/AccordionCollapseControls'
|
|
10
|
+
import mapAccordionStateToSteps from './utils'
|
|
10
11
|
|
|
11
12
|
type Props = {
|
|
12
13
|
accordionController: ReturnType<typeof useAccordionController>
|
|
@@ -51,7 +52,10 @@ function RcSesServiceFormContainer({
|
|
|
51
52
|
>
|
|
52
53
|
{showProgressStepper && (
|
|
53
54
|
<Grid item sx={{ display: { xs: 'none', md: 'block' }, flex: '0 0 270px' }}>
|
|
54
|
-
<ServiceWizardStepper
|
|
55
|
+
<ServiceWizardStepper
|
|
56
|
+
steps={mapAccordionStateToSteps(state)}
|
|
57
|
+
orientation='vertical'
|
|
58
|
+
/>
|
|
55
59
|
</Grid>
|
|
56
60
|
)}
|
|
57
61
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AccordionControllerState } from '../../common/Accordion/types/AccordionControllerState'
|
|
2
|
+
import { StepItem } from '../ServiceWizardStepper/StepperTypes'
|
|
3
|
+
|
|
4
|
+
function mapAccordionStateToSteps(state: AccordionControllerState): StepItem[] {
|
|
5
|
+
return Object.entries(state).map(([id, step]) => ({
|
|
6
|
+
id,
|
|
7
|
+
title: step.title,
|
|
8
|
+
state: step.state,
|
|
9
|
+
}))
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default mapAccordionStateToSteps
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
.ServiceWizardStepper {
|
|
2
|
+
width: 100%;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.ServiceWizardStepper-MobileStepperWrapper {
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
padding: 0 20px;
|
|
9
|
+
gap: 12px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.ServiceWizardStepper-NavSlot {
|
|
13
|
+
width: 36px;
|
|
14
|
+
height: 36px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.ServiceWizardStepper-MobileStepperContent {
|
|
18
|
+
flex: 1;
|
|
19
|
+
}
|
|
20
|
+
.MobileStepperWrapper {
|
|
21
|
+
gap: 12px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.ServiceWizardStepper .MuiStep-root:first-child,
|
|
25
|
+
.ServiceWizardStepper .MuiStep-root:last-child {
|
|
26
|
+
flex: 0.5;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.ServiceWizardStepper.MuiStepper-vertical .MuiStep-root {
|
|
30
|
+
margin-bottom: 10px;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.ServiceWizardStepper-horizontal .MuiStep-root:first-child .MuiStepLabel-root {
|
|
34
|
+
align-items: flex-start;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.ServiceWizardStepper .MuiStep-root:first-child .MuiStepLabel-alternativeLabel {
|
|
38
|
+
text-align: left;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.ServiceWizardStepper-horizontal .MuiStep-root:last-child .MuiStepLabel-root {
|
|
42
|
+
align-items: flex-end;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.ServiceWizardStepper .MuiStep-root:last-child .MuiStepLabel-alternativeLabel {
|
|
46
|
+
text-align: right;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.ServiceWizardStepper .MuiStep-root:last-child .MuiStepConnector-root {
|
|
50
|
+
left: calc(-100% + 28px);
|
|
51
|
+
right: 36px;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.ServiceWizardStepper .MuiStep-root:nth-child(2) .MuiStepConnector-root {
|
|
55
|
+
left: calc(-50% + 28px);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.ServiceWizardStepper.MuiStepper-horizontal .MuiStepConnector-line {
|
|
59
|
+
border-top-width: 2px;
|
|
60
|
+
border-radius: 99px;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.ServiceWizardStepper.MuiStepper-vertical .MuiStepConnector-line {
|
|
64
|
+
display: none;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.MuiStepButton-root .MuiStepLabel-root {
|
|
68
|
+
width: 100%;
|
|
69
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import styled from '@emotion/styled'
|
|
2
|
+
import { StepConnector as MuiStepConnector, stepConnectorClasses } from '@mui/material'
|
|
3
|
+
|
|
4
|
+
import theme from '@/theme/light'
|
|
5
|
+
import palette from '@/theme/palette'
|
|
6
|
+
|
|
7
|
+
const StepConnector = styled(MuiStepConnector)(() => ({
|
|
8
|
+
[`&.${stepConnectorClasses.alternativeLabel}`]: {
|
|
9
|
+
top: 12,
|
|
10
|
+
[theme.breakpoints.up('sm')]: {
|
|
11
|
+
top: 9,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
[`&.${stepConnectorClasses.active}`]: {
|
|
15
|
+
[`& .${stepConnectorClasses.line}`]: {
|
|
16
|
+
borderColor: palette.primary[400],
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
[`&.${stepConnectorClasses.completed}`]: {
|
|
20
|
+
[`& .${stepConnectorClasses.line}`]: {
|
|
21
|
+
borderColor: palette.primary[400],
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
[`& .${stepConnectorClasses.line}`]: {
|
|
25
|
+
borderColor: palette.grey[300],
|
|
26
|
+
},
|
|
27
|
+
}))
|
|
28
|
+
|
|
29
|
+
export default StepConnector
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { render } from '@testing-library/react'
|
|
2
|
+
|
|
3
|
+
import CustomStepIcon from './CustomStepIcon'
|
|
4
|
+
|
|
5
|
+
describe('CustomStepIcon', () => {
|
|
6
|
+
it('renders active icon', () => {
|
|
7
|
+
const { container } = render(<CustomStepIcon active completed={false} icon={1} />)
|
|
8
|
+
expect(container.querySelector('svg')).toBeInTheDocument()
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
it('renders completed icon', () => {
|
|
12
|
+
const { container } = render(<CustomStepIcon completed active={false} icon={1} />)
|
|
13
|
+
expect(container.querySelector('svg')).toBeInTheDocument()
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
it('renders pending icon', () => {
|
|
17
|
+
const { container } = render(
|
|
18
|
+
<CustomStepIcon active={false} completed={false} icon={1} />,
|
|
19
|
+
)
|
|
20
|
+
expect(container.querySelector('svg')).toBeInTheDocument()
|
|
21
|
+
})
|
|
22
|
+
})
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { StepIconProps } from '@mui/material'
|
|
2
|
+
|
|
3
|
+
import CheckCircleFillIcon from '@/assets/icons/CheckCircleFillIcon'
|
|
4
|
+
import CircleFilledIcon from '@/assets/icons/CircleFilledIcon'
|
|
5
|
+
import DotCircleFilledIcon from '@/assets/icons/DotCircleFilledIcon'
|
|
6
|
+
import palette from '@/theme/palette'
|
|
7
|
+
|
|
8
|
+
const CustomStepIcon = ({ active, completed, className, style }: StepIconProps) => {
|
|
9
|
+
if (completed) {
|
|
10
|
+
return (
|
|
11
|
+
<CheckCircleFillIcon
|
|
12
|
+
className={className}
|
|
13
|
+
style={style}
|
|
14
|
+
fillColor={palette.primary[400]}
|
|
15
|
+
size={20}
|
|
16
|
+
/>
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (active) {
|
|
21
|
+
return (
|
|
22
|
+
<DotCircleFilledIcon
|
|
23
|
+
className={className}
|
|
24
|
+
style={style}
|
|
25
|
+
fillColor={palette.primary[400]}
|
|
26
|
+
size={20}
|
|
27
|
+
/>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<CircleFilledIcon
|
|
33
|
+
className={className}
|
|
34
|
+
style={style}
|
|
35
|
+
fillColor={palette.grey[300]}
|
|
36
|
+
size={20}
|
|
37
|
+
/>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default CustomStepIcon
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { fireEvent, render } from '@testing-library/react'
|
|
2
|
+
|
|
3
|
+
import { StepItem } from '../StepperTypes'
|
|
4
|
+
import DesktopStepper from './DesktopStepper'
|
|
5
|
+
|
|
6
|
+
const steps: StepItem[] = [
|
|
7
|
+
{ id: '1', title: 'Step 1', state: 'completed' },
|
|
8
|
+
{ id: '2', title: 'Step 2', state: 'active' },
|
|
9
|
+
{ id: '3', title: 'Step 3', state: 'pending' },
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
describe('DesktopStepper', () => {
|
|
13
|
+
it('renders all steps', () => {
|
|
14
|
+
const { getByText } = render(
|
|
15
|
+
<DesktopStepper
|
|
16
|
+
stepEntries={steps}
|
|
17
|
+
activeStep={1}
|
|
18
|
+
handleStepClick={() => {}}
|
|
19
|
+
resolvedOrientation='horizontal'
|
|
20
|
+
/>,
|
|
21
|
+
)
|
|
22
|
+
expect(getByText('Step 1')).toBeInTheDocument()
|
|
23
|
+
expect(getByText('Step 2')).toBeInTheDocument()
|
|
24
|
+
expect(getByText('Step 3')).toBeInTheDocument()
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it('calls handleStepClick when a step is clicked', () => {
|
|
28
|
+
const handleStepClick = vi.fn()
|
|
29
|
+
const { getByText } = render(
|
|
30
|
+
<DesktopStepper
|
|
31
|
+
stepEntries={steps}
|
|
32
|
+
activeStep={1}
|
|
33
|
+
handleStepClick={handleStepClick}
|
|
34
|
+
resolvedOrientation='horizontal'
|
|
35
|
+
/>,
|
|
36
|
+
)
|
|
37
|
+
fireEvent.click(getByText('Step 1'))
|
|
38
|
+
expect(handleStepClick).toHaveBeenCalled()
|
|
39
|
+
})
|
|
40
|
+
})
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Step, StepButton, Stepper } from '@mui/material'
|
|
2
|
+
|
|
3
|
+
import StepConnector from '../StepConnector'
|
|
4
|
+
import { StepItem } from '../StepperTypes'
|
|
5
|
+
import CustomStepIcon from './CustomStepIcon'
|
|
6
|
+
import StyledStepLabel from './StyledStepLabel'
|
|
7
|
+
|
|
8
|
+
interface DesktopStepperProps {
|
|
9
|
+
stepEntries: StepItem[]
|
|
10
|
+
activeStep: number
|
|
11
|
+
handleStepClick: (index: number) => void
|
|
12
|
+
resolvedOrientation: 'vertical' | 'horizontal'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const DesktopStepper = ({
|
|
16
|
+
stepEntries,
|
|
17
|
+
activeStep,
|
|
18
|
+
handleStepClick,
|
|
19
|
+
resolvedOrientation,
|
|
20
|
+
}: DesktopStepperProps) => (
|
|
21
|
+
<Stepper
|
|
22
|
+
alternativeLabel={resolvedOrientation === 'horizontal'}
|
|
23
|
+
activeStep={activeStep}
|
|
24
|
+
orientation={resolvedOrientation}
|
|
25
|
+
connector={resolvedOrientation === 'horizontal' ? <StepConnector /> : undefined}
|
|
26
|
+
className={`ServiceWizardStepper ServiceWizardStepper-${resolvedOrientation}`}
|
|
27
|
+
>
|
|
28
|
+
{stepEntries.map((step, index) => {
|
|
29
|
+
const isClickable = index <= (activeStep === -1 ? 0 : activeStep)
|
|
30
|
+
return (
|
|
31
|
+
<Step key={step.id}>
|
|
32
|
+
<StepButton onClick={() => handleStepClick(index)} disabled={!isClickable}>
|
|
33
|
+
<StyledStepLabel
|
|
34
|
+
StepIconComponent={CustomStepIcon}
|
|
35
|
+
stepState={step.state}
|
|
36
|
+
orientation={resolvedOrientation}
|
|
37
|
+
isLast={index === stepEntries.length - 1}
|
|
38
|
+
>
|
|
39
|
+
{step.title}
|
|
40
|
+
</StyledStepLabel>
|
|
41
|
+
</StepButton>
|
|
42
|
+
</Step>
|
|
43
|
+
)
|
|
44
|
+
})}
|
|
45
|
+
</Stepper>
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
export default DesktopStepper
|
package/src/components/layout/ServiceWizardStepper/components/HorizontalStepperButton.test.tsx
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { fireEvent, render } from '@testing-library/react'
|
|
2
|
+
|
|
3
|
+
import HorizontalStepperButton from './HorizontalStepperButton'
|
|
4
|
+
|
|
5
|
+
describe('HorizontalStepperButton', () => {
|
|
6
|
+
it('renders back icon', () => {
|
|
7
|
+
const { container } = render(<HorizontalStepperButton direction='back' />)
|
|
8
|
+
expect(container.querySelector('svg')).toBeInTheDocument()
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
it('renders forward icon', () => {
|
|
12
|
+
const { container } = render(<HorizontalStepperButton direction='forward' />)
|
|
13
|
+
expect(container.querySelector('svg')).toBeInTheDocument()
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
it('calls onClick', () => {
|
|
17
|
+
const onClick = vi.fn()
|
|
18
|
+
const { getByRole } = render(
|
|
19
|
+
<HorizontalStepperButton direction='forward' onClick={onClick} />,
|
|
20
|
+
)
|
|
21
|
+
fireEvent.click(getByRole('button'))
|
|
22
|
+
expect(onClick).toHaveBeenCalled()
|
|
23
|
+
})
|
|
24
|
+
})
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Button, ButtonProps } from '@mui/material'
|
|
2
|
+
|
|
3
|
+
import CaretLeftIcon from '@/assets/icons/CaretLeftIcon'
|
|
4
|
+
import CaretRightBoldIcon from '@/assets/icons/CaretRightBoldIcon'
|
|
5
|
+
import palette from '@/theme/palette'
|
|
6
|
+
|
|
7
|
+
type Props = ButtonProps & {
|
|
8
|
+
direction: 'back' | 'forward'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const HorizontalStepperButton = ({ direction, sx, ...rest }: Props) => {
|
|
12
|
+
const isBack = direction === 'back'
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<Button
|
|
16
|
+
variant='outlined'
|
|
17
|
+
color='inherit'
|
|
18
|
+
{...rest}
|
|
19
|
+
sx={{
|
|
20
|
+
minWidth: 36,
|
|
21
|
+
width: 36,
|
|
22
|
+
height: 36,
|
|
23
|
+
padding: 0,
|
|
24
|
+
borderRadius: 2,
|
|
25
|
+
borderColor: palette.grey[600],
|
|
26
|
+
color: palette.grey[800],
|
|
27
|
+
|
|
28
|
+
'&:hover': {
|
|
29
|
+
borderColor: palette.grey[800],
|
|
30
|
+
backgroundColor: palette.grey[800],
|
|
31
|
+
color: '#fff',
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
'&.Mui-disabled': {
|
|
35
|
+
opacity: 0.5,
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
...sx,
|
|
39
|
+
}}
|
|
40
|
+
>
|
|
41
|
+
{isBack ? <CaretLeftIcon /> : <CaretRightBoldIcon />}
|
|
42
|
+
</Button>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default HorizontalStepperButton
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react'
|
|
2
|
+
|
|
3
|
+
import { StepItem } from '../StepperTypes'
|
|
4
|
+
import MobileStepper from './MobileStepper'
|
|
5
|
+
|
|
6
|
+
const steps: StepItem[] = [
|
|
7
|
+
{ id: '1', title: 'Step 1', state: 'completed' },
|
|
8
|
+
{ id: '2', title: 'Step 2', state: 'active' },
|
|
9
|
+
{ id: '3', title: 'Step 3', state: 'pending' },
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
describe('MobileStepper', () => {
|
|
13
|
+
it('renders all steps', () => {
|
|
14
|
+
render(
|
|
15
|
+
<MobileStepper stepEntries={steps} activeStep={1} handleStepClick={() => {}} />,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
const stepButtons = screen.getAllByRole('button')
|
|
19
|
+
expect(stepButtons).toHaveLength(steps.length + 1) // +1 for the "previous" button
|
|
20
|
+
})
|
|
21
|
+
})
|