@registrucentras/rc-ses-react-components 1.6.0 → 1.6.2
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/assets/icons/WarningCircleIcon.d.ts +3 -0
- package/dist/components/common/DataPagination/components/DataPaginationSkeleton.d.ts +5 -0
- package/dist/components/common/DataPagination/index.d.ts +2 -1
- package/dist/components/common/ListWithIcons/ListWithIcons.types.d.ts +11 -0
- package/dist/components/common/ListWithIcons/components/ListWithIconsItem.d.ts +3 -6
- package/dist/components/common/ListWithIcons/index.d.ts +3 -8
- package/dist/components/common/SelectableCardList/components/SelectableCardListItem.d.ts +11 -0
- package/dist/components/common/SelectableCardList/index.d.ts +16 -0
- package/dist/library/icons.d.ts +2 -1
- package/dist/library/index.d.ts +2 -0
- package/dist/library/types.d.ts +4 -1
- package/dist/registrucentras-rc-ses-react-components.cjs +9 -9
- package/dist/registrucentras-rc-ses-react-components.js +2345 -2129
- package/dist/stories/components/SelectableCardList.stories.d.ts +29 -0
- package/dist/stories/components/display/ListWithIcons.stories.d.ts +3 -2
- package/dist/stories/components/navigation/DataPagination.stories.d.ts +1 -1
- package/dist/types/assets/IconProps.d.ts +16 -0
- package/dist/types/buttons/ButtonProps.d.ts +4 -0
- package/dist/types/cards/CardServiceProps.d.ts +7 -0
- package/dist/types/common/ColorType.d.ts +2 -0
- package/dist/types/common/QuickLinkType.d.ts +5 -0
- package/dist/types/inputs/InputIconProps.d.ts +4 -0
- package/dist/types/lists/ListNewsItemType.d.ts +5 -0
- package/dist/types/lists/ListServicesItemType.d.ts +7 -0
- package/dist/types/order/OrderItemStatusType.d.ts +2 -0
- package/package.json +3 -2
- package/src/assets/icons/WarningCircleIcon.tsx +16 -0
- package/src/components/common/DataPagination/components/DataPaginationSkeleton.tsx +48 -0
- package/src/components/common/DataPagination/components/PaginationButton.tsx +1 -2
- package/src/components/common/DataPagination/index.tsx +40 -22
- package/src/components/common/ListWithIcons/ListWithIcons.types.ts +9 -0
- package/src/components/common/ListWithIcons/components/ListWithIconsItem.tsx +18 -7
- package/src/components/common/ListWithIcons/index.test.tsx +3 -13
- package/src/components/common/ListWithIcons/index.tsx +22 -17
- package/src/components/common/SelectableCardList/components/SelectableCardListItem.test.tsx +97 -0
- package/src/components/common/SelectableCardList/components/SelectableCardListItem.tsx +106 -0
- package/src/components/common/SelectableCardList/index.test.tsx +106 -0
- package/src/components/common/SelectableCardList/index.tsx +98 -0
- package/src/components/layout/ServiceWizardStepper/components/MobileStepper.tsx +1 -2
- package/src/examples/ListWithPagination/index.tsx +110 -57
- package/src/library/icons.ts +2 -0
- package/src/library/index.ts +3 -0
- package/src/library/types.ts +4 -4
- package/src/stories/components/SelectableCardList.stories.tsx +99 -0
- package/src/stories/components/display/ListWithIcons.stories.tsx +5 -9
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Box, Radio, Skeleton, Stack, Typography } from '@mui/material'
|
|
2
|
+
|
|
3
|
+
import RcSesCard from '@/components/common/Card'
|
|
4
|
+
import ListWithIcons from '@/components/common/ListWithIcons'
|
|
5
|
+
import palette from '@/theme/palette'
|
|
6
|
+
|
|
7
|
+
import { ListWithIconsItemData } from '../../ListWithIcons/ListWithIcons.types'
|
|
8
|
+
|
|
9
|
+
type Props = {
|
|
10
|
+
title: string
|
|
11
|
+
subtitle?: string
|
|
12
|
+
listItems: ListWithIconsItemData[]
|
|
13
|
+
selected: boolean
|
|
14
|
+
onSelect: () => void
|
|
15
|
+
isLoading?: boolean
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const SelectableCardListItem = ({
|
|
19
|
+
title,
|
|
20
|
+
subtitle,
|
|
21
|
+
listItems,
|
|
22
|
+
selected,
|
|
23
|
+
onSelect,
|
|
24
|
+
isLoading = false,
|
|
25
|
+
}: Props) => {
|
|
26
|
+
const titleTemplate = isLoading ? (
|
|
27
|
+
<Stack direction='row' alignItems='center' gap='0.75rem'>
|
|
28
|
+
<Skeleton variant='circular' width={20} height={20} />
|
|
29
|
+
<Skeleton variant='text' width={100} />
|
|
30
|
+
</Stack>
|
|
31
|
+
) : (
|
|
32
|
+
<Stack direction='row' alignItems='flex-start' gap='0.75rem'>
|
|
33
|
+
<Radio
|
|
34
|
+
aria-label={`Select ${title}`}
|
|
35
|
+
checked={selected}
|
|
36
|
+
sx={{
|
|
37
|
+
p: 0,
|
|
38
|
+
height: '1.25rem',
|
|
39
|
+
width: '1.25rem',
|
|
40
|
+
margin: '0.125rem 0rem',
|
|
41
|
+
}}
|
|
42
|
+
/>
|
|
43
|
+
<Box sx={{ display: 'flex', flexDirection: 'row', flexWrap: 'wrap' }}>
|
|
44
|
+
<Typography
|
|
45
|
+
variant='h3'
|
|
46
|
+
sx={{
|
|
47
|
+
fontSize: '1rem',
|
|
48
|
+
fontWeight: 600,
|
|
49
|
+
lineHeight: '1.5rem',
|
|
50
|
+
paddingRight: '0.25rem',
|
|
51
|
+
}}
|
|
52
|
+
>
|
|
53
|
+
{title}
|
|
54
|
+
</Typography>
|
|
55
|
+
{!!subtitle && (
|
|
56
|
+
<Typography
|
|
57
|
+
variant='body2'
|
|
58
|
+
sx={{
|
|
59
|
+
fontSize: '1rem',
|
|
60
|
+
fontWeight: 300,
|
|
61
|
+
lineHeight: '1.5rem',
|
|
62
|
+
color: palette.grey[800],
|
|
63
|
+
}}
|
|
64
|
+
>
|
|
65
|
+
{subtitle}
|
|
66
|
+
</Typography>
|
|
67
|
+
)}
|
|
68
|
+
</Box>
|
|
69
|
+
</Stack>
|
|
70
|
+
)
|
|
71
|
+
return (
|
|
72
|
+
<RcSesCard
|
|
73
|
+
onClick={onSelect}
|
|
74
|
+
sx={{
|
|
75
|
+
cursor: isLoading ? 'default' : 'pointer',
|
|
76
|
+
pointerEvents: isLoading ? 'none' : 'auto',
|
|
77
|
+
border: '0.125rem solid',
|
|
78
|
+
borderRadius: '0.75rem',
|
|
79
|
+
padding: { xs: '1rem' },
|
|
80
|
+
borderColor: selected ? palette.primary.main : palette.grey[300],
|
|
81
|
+
transition: 'all 0.2s ease',
|
|
82
|
+
gap: { xs: '0.5rem', md: '0.25rem' },
|
|
83
|
+
}}
|
|
84
|
+
title={titleTemplate}
|
|
85
|
+
slotProps={{
|
|
86
|
+
title: {
|
|
87
|
+
sx: {
|
|
88
|
+
fontSize: '1rem',
|
|
89
|
+
fontWeight: 600,
|
|
90
|
+
lineHeight: '1.5rem',
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
content: {
|
|
94
|
+
sx: {
|
|
95
|
+
marginLeft: '2rem',
|
|
96
|
+
backgroundColor: 'transparent',
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
}}
|
|
100
|
+
>
|
|
101
|
+
<ListWithIcons items={listItems} layout='horizontal' isLoading={isLoading} />
|
|
102
|
+
</RcSesCard>
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export default SelectableCardListItem
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { useMediaQuery } from '@mui/material'
|
|
2
|
+
import { ThemeProvider } from '@mui/material/styles'
|
|
3
|
+
import { fireEvent, render, screen } from '@testing-library/react'
|
|
4
|
+
import { type ReactElement } from 'react'
|
|
5
|
+
import { beforeEach, describe, expect, test, vi } from 'vitest'
|
|
6
|
+
|
|
7
|
+
import theme from '@/theme/light'
|
|
8
|
+
|
|
9
|
+
import SelectableCardList, { type SelectableCardListItemData } 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 mockedUseMediaQuery = vi.mocked(useMediaQuery)
|
|
21
|
+
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
mockedUseMediaQuery.mockReturnValue(false)
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
const renderList = (ui: ReactElement) =>
|
|
27
|
+
render(<ThemeProvider theme={theme}>{ui}</ThemeProvider>)
|
|
28
|
+
|
|
29
|
+
const makeItems = (count: number): SelectableCardListItemData[] =>
|
|
30
|
+
Array.from({ length: count }, (_, i) => ({
|
|
31
|
+
id: `item-${i + 1}`,
|
|
32
|
+
title: `Item ${i + 1}`,
|
|
33
|
+
subtitle: `Subtitle ${i + 1}`,
|
|
34
|
+
}))
|
|
35
|
+
|
|
36
|
+
describe('SelectableCardList', () => {
|
|
37
|
+
test('renders skeleton cards when items is undefined', () => {
|
|
38
|
+
renderList(<SelectableCardList onSelect={vi.fn()} />)
|
|
39
|
+
|
|
40
|
+
expect(screen.getByTestId('selectable-card-list-skeleton')).toBeInTheDocument()
|
|
41
|
+
expect(screen.queryByRole('radio')).not.toBeInTheDocument()
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
test('renders all items on the first page when count <= PAGE_SIZE', () => {
|
|
45
|
+
renderList(<SelectableCardList items={makeItems(3)} onSelect={vi.fn()} />)
|
|
46
|
+
|
|
47
|
+
expect(screen.getByText('Item 1')).toBeInTheDocument()
|
|
48
|
+
expect(screen.getByText('Item 2')).toBeInTheDocument()
|
|
49
|
+
expect(screen.getByText('Item 3')).toBeInTheDocument()
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
test('shows only 5 items per page', () => {
|
|
53
|
+
renderList(<SelectableCardList items={makeItems(8)} onSelect={vi.fn()} />)
|
|
54
|
+
|
|
55
|
+
expect(screen.getByText('Item 1')).toBeInTheDocument()
|
|
56
|
+
expect(screen.getByText('Item 5')).toBeInTheDocument()
|
|
57
|
+
expect(screen.queryByText('Item 6')).not.toBeInTheDocument()
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
test('navigating to next page shows the next set of items', () => {
|
|
61
|
+
renderList(<SelectableCardList items={makeItems(8)} onSelect={vi.fn()} />)
|
|
62
|
+
|
|
63
|
+
fireEvent.click(screen.getByRole('button', { name: 'Kitas' }))
|
|
64
|
+
|
|
65
|
+
expect(screen.getByText('Item 6')).toBeInTheDocument()
|
|
66
|
+
expect(screen.getByText('Item 7')).toBeInTheDocument()
|
|
67
|
+
expect(screen.getByText('Item 8')).toBeInTheDocument()
|
|
68
|
+
expect(screen.queryByText('Item 1')).not.toBeInTheDocument()
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
test('calls onSelect with the correct item id when a card is clicked', async () => {
|
|
72
|
+
const onSelect = vi.fn()
|
|
73
|
+
|
|
74
|
+
renderList(<SelectableCardList items={makeItems(3)} onSelect={onSelect} />)
|
|
75
|
+
|
|
76
|
+
fireEvent.click(screen.getByText('Item 2'))
|
|
77
|
+
|
|
78
|
+
expect(onSelect).toHaveBeenCalledWith('item-2')
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
test('selected item has its radio checked', () => {
|
|
82
|
+
const items = makeItems(3)
|
|
83
|
+
|
|
84
|
+
renderList(
|
|
85
|
+
<SelectableCardList items={items} selectedId='item-2' onSelect={vi.fn()} />,
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
const radios = screen.getAllByRole('radio')
|
|
89
|
+
expect(radios[1]).toBeChecked()
|
|
90
|
+
expect(radios[0]).not.toBeChecked()
|
|
91
|
+
expect(radios[2]).not.toBeChecked()
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
test('renders error node and hides list when error is provided', () => {
|
|
95
|
+
renderList(
|
|
96
|
+
<SelectableCardList
|
|
97
|
+
items={makeItems(3)}
|
|
98
|
+
onSelect={vi.fn()}
|
|
99
|
+
error={<p>Something went wrong</p>}
|
|
100
|
+
/>,
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
expect(screen.getByText('Something went wrong')).toBeInTheDocument()
|
|
104
|
+
expect(screen.queryByText('Item 1')).not.toBeInTheDocument()
|
|
105
|
+
})
|
|
106
|
+
})
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Box, Container } from '@mui/material'
|
|
2
|
+
import { ReactNode, useMemo, useState } from 'react'
|
|
3
|
+
|
|
4
|
+
import DataPagination from '../DataPagination'
|
|
5
|
+
import { ListWithIconsItemData } from '../ListWithIcons/ListWithIcons.types'
|
|
6
|
+
import SelectableCardListItem from './components/SelectableCardListItem'
|
|
7
|
+
|
|
8
|
+
export type SelectableCardListItemData = {
|
|
9
|
+
id: string
|
|
10
|
+
title: string
|
|
11
|
+
subtitle?: string
|
|
12
|
+
listItems?: ListWithIconsItemData[]
|
|
13
|
+
}
|
|
14
|
+
export interface SelectableCardListProps {
|
|
15
|
+
items?: SelectableCardListItemData[]
|
|
16
|
+
selectedId?: string | null
|
|
17
|
+
onSelect: (id: string) => void
|
|
18
|
+
error?: ReactNode
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const SKELETON_COUNT = 5
|
|
22
|
+
const PAGE_SIZE = 5
|
|
23
|
+
const SelectableCardList = ({
|
|
24
|
+
items,
|
|
25
|
+
selectedId,
|
|
26
|
+
onSelect,
|
|
27
|
+
error,
|
|
28
|
+
}: SelectableCardListProps) => {
|
|
29
|
+
const [page, setPage] = useState(1)
|
|
30
|
+
|
|
31
|
+
const totalPages = items ? Math.ceil(items.length / PAGE_SIZE) : 0
|
|
32
|
+
const currentPage = totalPages > 0 ? Math.min(page, totalPages) : 1
|
|
33
|
+
const pagedItems = useMemo(() => {
|
|
34
|
+
if (!items) {
|
|
35
|
+
return []
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const startIndex = (currentPage - 1) * PAGE_SIZE
|
|
39
|
+
return items.slice(startIndex, startIndex + PAGE_SIZE)
|
|
40
|
+
}, [currentPage, items])
|
|
41
|
+
|
|
42
|
+
const renderSkeletons = () =>
|
|
43
|
+
Array.from({ length: SKELETON_COUNT }).map((_, i) => (
|
|
44
|
+
<SelectableCardListItem
|
|
45
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
46
|
+
key={i}
|
|
47
|
+
title=''
|
|
48
|
+
subtitle=''
|
|
49
|
+
selected={false}
|
|
50
|
+
onSelect={() => {}}
|
|
51
|
+
listItems={[]}
|
|
52
|
+
isLoading
|
|
53
|
+
/>
|
|
54
|
+
))
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<Container
|
|
58
|
+
sx={{
|
|
59
|
+
display: 'flex',
|
|
60
|
+
flexDirection: 'column',
|
|
61
|
+
alignItems: 'center',
|
|
62
|
+
gap: '16px',
|
|
63
|
+
}}
|
|
64
|
+
>
|
|
65
|
+
{error != null ? (
|
|
66
|
+
error
|
|
67
|
+
) : (
|
|
68
|
+
<>
|
|
69
|
+
<Box
|
|
70
|
+
data-testid={!items ? 'selectable-card-list-skeleton' : undefined}
|
|
71
|
+
sx={{ display: 'flex', flexDirection: 'column', gap: '10px', width: '100%' }}
|
|
72
|
+
>
|
|
73
|
+
{!items
|
|
74
|
+
? renderSkeletons()
|
|
75
|
+
: pagedItems.map((item) => (
|
|
76
|
+
<SelectableCardListItem
|
|
77
|
+
key={item.id}
|
|
78
|
+
title={item.title}
|
|
79
|
+
subtitle={item.subtitle}
|
|
80
|
+
listItems={item.listItems || []}
|
|
81
|
+
selected={selectedId === item.id}
|
|
82
|
+
onSelect={() => onSelect(item.id)}
|
|
83
|
+
/>
|
|
84
|
+
))}
|
|
85
|
+
</Box>
|
|
86
|
+
<DataPagination
|
|
87
|
+
count={totalPages}
|
|
88
|
+
page={currentPage}
|
|
89
|
+
onChange={setPage}
|
|
90
|
+
isLoading={!items}
|
|
91
|
+
/>
|
|
92
|
+
</>
|
|
93
|
+
)}
|
|
94
|
+
</Container>
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export default SelectableCardList
|
|
@@ -1,72 +1,125 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { Box, Typography } from '@mui/material'
|
|
2
|
+
import { useEffect, useState } from 'react'
|
|
3
3
|
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import Button from '@/components/common/Button'
|
|
5
|
+
import SelectableCardList, {
|
|
6
|
+
SelectableCardListItemData,
|
|
7
|
+
} from '@/components/common/SelectableCardList'
|
|
8
|
+
import ServiceHeader from '@/components/layout/ServiceHeader'
|
|
6
9
|
import ServicePage from '@/components/layout/ServicePage'
|
|
7
|
-
import {
|
|
8
|
-
import palette from '@/theme/palette'
|
|
10
|
+
import { BarcodeIcon, MapPinAreaIcon, ScalesIcon } from '@/library'
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
12
|
+
interface ApiItem {
|
|
13
|
+
id: string
|
|
14
|
+
name: string
|
|
15
|
+
matchedName?: string
|
|
16
|
+
code: string
|
|
17
|
+
legalStatusName: string
|
|
18
|
+
address: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const mockApiData: ApiItem[] = Array.from({ length: 15 }).map((_, i) => ({
|
|
22
|
+
id: (i + 1).toString(),
|
|
23
|
+
code: `12345${i}`,
|
|
24
|
+
name: `Company ${i + 1}`,
|
|
25
|
+
matchedName: `Matched name ${i + 1}`,
|
|
26
|
+
address: `Vilnius, Street ${i + 1}`,
|
|
27
|
+
legalStatusName: i % 2 === 0 ? 'įregistruotas' : 'Neįregistruotas',
|
|
28
|
+
}))
|
|
29
|
+
|
|
30
|
+
const mapToSelectableItems = (data: ApiItem[]): SelectableCardListItemData[] =>
|
|
31
|
+
data.map((item) => ({
|
|
32
|
+
id: item.id,
|
|
33
|
+
title: item.name,
|
|
34
|
+
subtitle: item.matchedName,
|
|
35
|
+
listItems: [
|
|
36
|
+
{
|
|
37
|
+
id: 'code',
|
|
38
|
+
icon: BarcodeIcon,
|
|
39
|
+
text: `Code: ${item.code}`,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: 'status',
|
|
43
|
+
icon: ScalesIcon,
|
|
44
|
+
text: item.legalStatusName,
|
|
45
|
+
textColor: item.legalStatusName === 'Neįregistruotas' ? 'red' : undefined,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: 'address',
|
|
49
|
+
icon: MapPinAreaIcon,
|
|
50
|
+
text: item.address,
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
}))
|
|
37
54
|
|
|
38
55
|
function ListWithPagination() {
|
|
39
|
-
const [
|
|
40
|
-
const [
|
|
41
|
-
const
|
|
56
|
+
const [isLoading, setIsLoading] = useState(true)
|
|
57
|
+
const [data, setData] = useState<SelectableCardListItemData[] | undefined>(undefined)
|
|
58
|
+
const [selectedItemId, setSelectedItemId] = useState<string | null>(null)
|
|
42
59
|
|
|
43
|
-
|
|
44
|
-
()
|
|
45
|
-
Array.from({ length: 42 }, (_, i) => ({
|
|
46
|
-
id: i + 1,
|
|
47
|
-
name: `Item ${i + 1}`,
|
|
48
|
-
})),
|
|
49
|
-
[],
|
|
50
|
-
)
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
setIsLoading(true)
|
|
51
62
|
|
|
52
|
-
|
|
53
|
-
|
|
63
|
+
const timer = setTimeout(() => {
|
|
64
|
+
setData(mapToSelectableItems(mockApiData))
|
|
65
|
+
setIsLoading(false)
|
|
66
|
+
setSelectedItemId(mapToSelectableItems(mockApiData)[0].id)
|
|
67
|
+
}, 1500)
|
|
68
|
+
|
|
69
|
+
return () => clearTimeout(timer)
|
|
70
|
+
}, [])
|
|
71
|
+
|
|
72
|
+
const handleRefetch = () => {
|
|
73
|
+
setIsLoading(true)
|
|
74
|
+
setData(undefined)
|
|
75
|
+
setTimeout(() => {
|
|
76
|
+
setData(mapToSelectableItems(mockApiData))
|
|
77
|
+
setIsLoading(false)
|
|
78
|
+
setSelectedItemId(mapToSelectableItems(mockApiData)[0].id)
|
|
79
|
+
}, 1500)
|
|
54
80
|
}
|
|
55
81
|
|
|
56
82
|
return (
|
|
57
83
|
<ServicePage>
|
|
58
|
-
<
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
84
|
+
<ServiceHeader
|
|
85
|
+
breadcrumbsProps={{
|
|
86
|
+
path: [
|
|
87
|
+
{ label: 'Pagrindinis', path: '/' },
|
|
88
|
+
{
|
|
89
|
+
label: 'Horizontalios formos su vedliu pavyzdys',
|
|
90
|
+
path: '/horizontal-sample-form-multiple-steps',
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
}}
|
|
94
|
+
title='Nekilnojamojo turto registro išrašas pagal nurodytą turto adresą'
|
|
95
|
+
>
|
|
96
|
+
<Typography variant='body1'>
|
|
97
|
+
Šiame puslapyje Jūs galite užsisakyti Nekilnojamojo turto registro išrašus,
|
|
98
|
+
pažymas bei kitus dokumentus. Užsakytą NTR išrašą, pažymą ar kitą dokumentą
|
|
99
|
+
galėsite gauti elektroniniu būdu arba atsiimti pasirinktame VĮ Registrų centro
|
|
100
|
+
padalinyje.
|
|
101
|
+
</Typography>
|
|
102
|
+
</ServiceHeader>
|
|
103
|
+
<SelectableCardList
|
|
104
|
+
items={data}
|
|
105
|
+
selectedId={selectedItemId}
|
|
106
|
+
onSelect={setSelectedItemId}
|
|
66
107
|
/>
|
|
67
|
-
<
|
|
68
|
-
|
|
69
|
-
|
|
108
|
+
<Box
|
|
109
|
+
sx={{
|
|
110
|
+
mt: 2,
|
|
111
|
+
display: 'flex',
|
|
112
|
+
flexDirection: 'column',
|
|
113
|
+
justifyContent: 'center',
|
|
114
|
+
gap: 2,
|
|
115
|
+
alignItems: 'center',
|
|
116
|
+
}}
|
|
117
|
+
>
|
|
118
|
+
<Button variant='contained' onClick={handleRefetch} disabled={isLoading}>
|
|
119
|
+
Refetch
|
|
120
|
+
</Button>
|
|
121
|
+
<Typography variant='body1'>Selected item: {selectedItemId}</Typography>
|
|
122
|
+
</Box>
|
|
70
123
|
</ServicePage>
|
|
71
124
|
)
|
|
72
125
|
}
|
package/src/library/icons.ts
CHANGED
|
@@ -30,6 +30,7 @@ import ScalesIcon from '@/assets/icons/ScalesIcon'
|
|
|
30
30
|
import ScrollIcon from '@/assets/icons/ScrollIcon'
|
|
31
31
|
import SpinnerGapBoldIcon from '@/assets/icons/SpinnerGapBoldIcon'
|
|
32
32
|
import UploadSimpleIcon from '@/assets/icons/UploadSimpleIcon'
|
|
33
|
+
import WarningCircleIcon from '@/assets/icons/WarningCircleIcon'
|
|
33
34
|
import WarningDiamondFillIcon from '@/assets/icons/WarningDiamondFillIcon'
|
|
34
35
|
import WarningFillIcon from '@/assets/icons/WarningFillIcon'
|
|
35
36
|
import XCircleFillIcon from '@/assets/icons/XCircleFillIcon'
|
|
@@ -69,5 +70,6 @@ export {
|
|
|
69
70
|
UploadSimpleIcon,
|
|
70
71
|
WarningDiamondFillIcon,
|
|
71
72
|
WarningFillIcon,
|
|
73
|
+
WarningCircleIcon,
|
|
72
74
|
XCircleFillIcon,
|
|
73
75
|
}
|
package/src/library/index.ts
CHANGED
|
@@ -41,6 +41,8 @@ import ServiceWizardStepper from '@/components/layout/ServiceWizardStepper'
|
|
|
41
41
|
import RcSesTheme from '@/theme/light'
|
|
42
42
|
import RcSesPalette from '@/theme/palette'
|
|
43
43
|
|
|
44
|
+
import SelectableCardList from '../components/common/SelectableCardList'
|
|
45
|
+
|
|
44
46
|
declare module '@mui/x-date-pickers/models' {
|
|
45
47
|
interface PickerValidDateLookup {
|
|
46
48
|
'date-fns': Date
|
|
@@ -72,6 +74,7 @@ export { RcSesTextField }
|
|
|
72
74
|
export { DataPagination }
|
|
73
75
|
export { ListWithIcons }
|
|
74
76
|
export { ServiceWizardStepper }
|
|
77
|
+
export { SelectableCardList }
|
|
75
78
|
export type * from './types'
|
|
76
79
|
|
|
77
80
|
export {
|
package/src/library/types.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { RcSesCardProps } from '@/components/common/Card'
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
ListWithIconsProps,
|
|
5
|
-
} from '@/components/common/ListWithIcons'
|
|
2
|
+
import { ListWithIconsProps } from '@/components/common/ListWithIcons'
|
|
3
|
+
import { ListWithIconsItemData } from '@/components/common/ListWithIcons/ListWithIcons.types'
|
|
6
4
|
import { RcSesCardFormContainerProps } from '@/components/layout/ServiceFormContainer/CardFormContainer'
|
|
7
5
|
import { ServiceWizardStepperProps } from '@/components/layout/ServiceWizardStepper'
|
|
6
|
+
import { ButtonProps } from '@/types/buttons/ButtonProps'
|
|
8
7
|
|
|
9
8
|
export type { ListWithIconsProps, ListWithIconsItemData }
|
|
9
|
+
export type { ButtonProps }
|
|
10
10
|
|
|
11
11
|
export type { RcSesCardFormContainerProps, RcSesCardProps, ServiceWizardStepperProps }
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react'
|
|
2
|
+
import { useState } from 'react'
|
|
3
|
+
|
|
4
|
+
import InfoFillIcon from '@/assets/icons/InfoFillIcon'
|
|
5
|
+
import QuestionIcon from '@/assets/icons/QuestionIcon'
|
|
6
|
+
import WarningFillIcon from '@/assets/icons/WarningFillIcon'
|
|
7
|
+
import SelectableCardList, {
|
|
8
|
+
type SelectableCardListItemData,
|
|
9
|
+
type SelectableCardListProps,
|
|
10
|
+
} from '@/components/common/SelectableCardList'
|
|
11
|
+
|
|
12
|
+
const buildItems = (): SelectableCardListItemData[] =>
|
|
13
|
+
Array.from({ length: 8 }, (_, index) => ({
|
|
14
|
+
id: `item-${index + 1}`,
|
|
15
|
+
title: `Service option ${index + 1}`,
|
|
16
|
+
subtitle: index % 2 === 0 ? 'Recommended for most users' : 'Alternative flow',
|
|
17
|
+
listItems: [
|
|
18
|
+
{
|
|
19
|
+
icon: InfoFillIcon,
|
|
20
|
+
text: 'Estimated time: 3 business days',
|
|
21
|
+
tooltip: 'Estimated processing duration.',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
icon: QuestionIcon,
|
|
25
|
+
text: 'Requires identity verification',
|
|
26
|
+
tooltip: 'You may be asked to verify your identity.',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
icon: WarningFillIcon,
|
|
30
|
+
text: 'Additional fees may apply',
|
|
31
|
+
tooltip: 'Fees depend on selected add-ons.',
|
|
32
|
+
disabled: index % 3 === 0,
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
}))
|
|
36
|
+
|
|
37
|
+
const meta = {
|
|
38
|
+
title: 'components/common/SelectableCardList',
|
|
39
|
+
component: SelectableCardList,
|
|
40
|
+
tags: ['autodocs'],
|
|
41
|
+
args: {
|
|
42
|
+
items: buildItems(),
|
|
43
|
+
selectedId: null,
|
|
44
|
+
error: undefined,
|
|
45
|
+
onSelect: () => {},
|
|
46
|
+
},
|
|
47
|
+
argTypes: {
|
|
48
|
+
onSelect: {
|
|
49
|
+
action: 'itemSelected',
|
|
50
|
+
},
|
|
51
|
+
items: {
|
|
52
|
+
control: false,
|
|
53
|
+
},
|
|
54
|
+
error: {
|
|
55
|
+
control: false,
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
} satisfies Meta<typeof SelectableCardList>
|
|
59
|
+
|
|
60
|
+
export default meta
|
|
61
|
+
|
|
62
|
+
type Story = StoryObj<typeof meta>
|
|
63
|
+
|
|
64
|
+
const SelectableCardListStory = ({
|
|
65
|
+
onSelect,
|
|
66
|
+
selectedId: initialSelectedId,
|
|
67
|
+
...restArgs
|
|
68
|
+
}: SelectableCardListProps) => {
|
|
69
|
+
const [selectedId, setSelectedId] = useState<string | null>(initialSelectedId ?? null)
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<SelectableCardList
|
|
73
|
+
{...restArgs}
|
|
74
|
+
selectedId={selectedId}
|
|
75
|
+
onSelect={(id) => {
|
|
76
|
+
setSelectedId(id)
|
|
77
|
+
onSelect(id)
|
|
78
|
+
}}
|
|
79
|
+
/>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export const Main: Story = {
|
|
84
|
+
render: (args) => (
|
|
85
|
+
<SelectableCardListStory {...args} onSelect={args.onSelect ?? (() => {})} />
|
|
86
|
+
),
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export const Loading: Story = {
|
|
90
|
+
args: {
|
|
91
|
+
items: undefined,
|
|
92
|
+
},
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export const Error: Story = {
|
|
96
|
+
args: {
|
|
97
|
+
error: 'Unable to load selectable cards. Please try again.',
|
|
98
|
+
},
|
|
99
|
+
}
|
|
@@ -2,26 +2,22 @@ import type { Meta, StoryObj } from '@storybook/react'
|
|
|
2
2
|
|
|
3
3
|
import CheckCircleFillIcon from '@/assets/icons/CheckCircleFillIcon'
|
|
4
4
|
import WarningFillIcon from '@/assets/icons/WarningFillIcon'
|
|
5
|
-
import ListWithIcons
|
|
6
|
-
|
|
7
|
-
} from '@/components/common/ListWithIcons'
|
|
5
|
+
import ListWithIcons from '@/components/common/ListWithIcons'
|
|
6
|
+
import { type ListWithIconsItemData } from '@/components/common/ListWithIcons/ListWithIcons.types'
|
|
8
7
|
|
|
9
8
|
const baseItems: ListWithIconsItemData[] = [
|
|
10
9
|
{
|
|
11
|
-
|
|
12
|
-
icon: <CheckCircleFillIcon size={20} />,
|
|
10
|
+
icon: CheckCircleFillIcon,
|
|
13
11
|
text: 'Application received',
|
|
14
12
|
tooltip: 'The submission was successfully received.',
|
|
15
13
|
},
|
|
16
14
|
{
|
|
17
|
-
|
|
18
|
-
icon: <WarningFillIcon size={20} />,
|
|
15
|
+
icon: WarningFillIcon,
|
|
19
16
|
text: 'Requires review',
|
|
20
17
|
tooltip: 'A specialist will review the provided details.',
|
|
21
18
|
},
|
|
22
19
|
{
|
|
23
|
-
|
|
24
|
-
icon: <WarningFillIcon size={20} />,
|
|
20
|
+
icon: WarningFillIcon,
|
|
25
21
|
text: 'Unavailable item',
|
|
26
22
|
tooltip: 'This item is currently disabled.',
|
|
27
23
|
disabled: true,
|